summaryrefslogtreecommitdiff
path: root/gtk/gtkshortcuttrigger.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-08-23 21:07:36 +0200
committerMatthias Clasen <mclasen@redhat.com>2020-03-25 23:14:28 -0400
commit7974751e2432178686b13f9057efcb7dbe39af60 (patch)
tree916a0c071a0e9357d2f11499920d3ed809db60b3 /gtk/gtkshortcuttrigger.c
parentdaa7d9072dc3e0dee3fe041354ddddbb97695061 (diff)
downloadgtk+-7974751e2432178686b13f9057efcb7dbe39af60.tar.gz
shortcuttrigger: Add gtk_shortcut_triger_new_parse_string()
And hook it up into the GtkBuilder infrastructure.
Diffstat (limited to 'gtk/gtkshortcuttrigger.c')
-rw-r--r--gtk/gtkshortcuttrigger.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gtk/gtkshortcuttrigger.c b/gtk/gtkshortcuttrigger.c
index e582eb75de..470a8cecc2 100644
--- a/gtk/gtkshortcuttrigger.c
+++ b/gtk/gtkshortcuttrigger.c
@@ -182,6 +182,35 @@ gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self,
}
/**
+ * gtk_shortcut_trigger_parse_string:
+ * @string: the string to parse
+ *
+ * Tries to parse the given string into a trigger. On success,
+ * the parsed trigger is returned. When parsing failed, %NULL is
+ * returned.
+ *
+ * FIXME: Document the supported format here once we've figured
+ * it out.
+ * For now, this function only supports gtk_accelerator_parse() and
+ * can only return a trigger of type %GTK_SHORTCUT_TRIGGER_KEYVAL.
+ *
+ * Returns: a new #GtkShortcutTrigger or %NULL on error
+ **/
+GtkShortcutTrigger *
+gtk_shortcut_trigger_parse_string (const char *string)
+{
+ GdkModifierType modifiers;
+ guint keyval;
+
+ g_return_val_if_fail (string != NULL, NULL);
+
+ if (gtk_accelerator_parse (string, &keyval, &modifiers))
+ return gtk_keyval_trigger_new (keyval, modifiers);
+
+ return NULL;
+}
+
+/**
* gtk_shortcut_trigger_to_string:
* @self: a #GtkShortcutTrigger
*