summaryrefslogtreecommitdiff
path: root/gtk/gtkbindings.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2011-01-28 19:36:24 -0500
committerMatthias Clasen <mclasen@redhat.com>2011-01-30 21:27:56 -0500
commit8bb0d552f1be1313cbb9e37607b21d8274ae5ff1 (patch)
tree7f43977c117d49df61479dbbec135a9e27d27921 /gtk/gtkbindings.c
parenta04e721473a6afc45dba8bc9f95256375968edb4 (diff)
downloadgtk+-8bb0d552f1be1313cbb9e37607b21d8274ae5ff1.tar.gz
Improve binding-set parser
Make gtk_binding_entry_add_signal_from_string() return the expected token in case of parsing error, so that we can return a GError instead of spewing. Also, add a separate scope for binding-set, since allowing {} in identifiers in SCOPE_VALUE breaks the fact that the ; after the last assignment in a rule is optional.
Diffstat (limited to 'gtk/gtkbindings.c')
-rw-r--r--gtk/gtkbindings.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/gtk/gtkbindings.c b/gtk/gtkbindings.c
index 2b9d51230f..ef31fb9746 100644
--- a/gtk/gtkbindings.c
+++ b/gtk/gtkbindings.c
@@ -1271,17 +1271,20 @@ create_signal_scanner (void)
* Key combinations must be in a format that can be parsed by
* gtk_accelerator_parse().
*
+ * Returns: %G_TOKEN_NONE if the signal was successfully parsed and added,
+ * the expected token otherwise
+ *
* Since: 3.0
- **/
-void
+ */
+GTokenType
gtk_binding_entry_add_signal_from_string (GtkBindingSet *binding_set,
- const gchar *signal_desc)
+ const gchar *signal_desc)
{
static GScanner *scanner = NULL;
GTokenType ret;
- g_return_if_fail (binding_set != NULL);
- g_return_if_fail (signal_desc != NULL);
+ g_return_val_if_fail (binding_set != NULL, G_TOKEN_NONE);
+ g_return_val_if_fail (signal_desc != NULL, G_TOKEN_NONE);
if (G_UNLIKELY (!scanner))
scanner = create_signal_scanner ();
@@ -1291,12 +1294,10 @@ gtk_binding_entry_add_signal_from_string (GtkBindingSet *binding_set,
ret = gtk_binding_parse_bind (scanner, binding_set);
- if (ret != G_TOKEN_NONE)
- g_scanner_unexp_token (scanner, ret, NULL, NULL, NULL,
- "Could not parse binding", FALSE);
-
/* Reset for next use */
g_scanner_set_scope (scanner, 0);
+
+ return ret;
}
/**