diff --git a/gtk/deprecated/gtkactiongroup.c b/gtk/deprecated/gtkactiongroup.c index a08d18c74c..32b913cf18 100644 --- a/gtk/deprecated/gtkactiongroup.c +++ b/gtk/deprecated/gtkactiongroup.c @@ -437,6 +437,7 @@ accelerator_start_element (GMarkupParseContext *context, else if (strcmp (names[i], "modifiers") == 0) { if (!_gtk_builder_flags_from_string (GDK_TYPE_MODIFIER_TYPE, + NULL, values[i], &modifiers, error)) diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index ca51168220..50375d3081 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -1954,7 +1954,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder, { guint flags_value; - if (!_gtk_builder_flags_from_string (type, string, &flags_value, error)) + if (!_gtk_builder_flags_from_string (type, NULL, string, &flags_value, error)) { ret = FALSE; break; @@ -2202,13 +2202,14 @@ _gtk_builder_enum_from_string (GType type, gboolean _gtk_builder_flags_from_string (GType type, + GFlagsValue *aliases, const gchar *string, guint *flags_value, GError **error) { GFlagsClass *fclass; gchar *endptr, *prevptr; - guint i, j, value; + guint i, j, k, value; gchar *flagstr; GFlagsValue *fv; const gchar *flag; @@ -2268,7 +2269,23 @@ _gtk_builder_flags_from_string (GType type, if (endptr > flag) { *endptr = '\0'; - fv = g_flags_get_value_by_name (fclass, flag); + + fv = NULL; + + if (aliases) + { + for (k = 0; aliases[k].value_nick; k++) + { + if (g_ascii_strcasecmp (aliases[k].value_nick, flag) == 0) + { + fv = &aliases[k]; + break; + } + } + } + + if (!fv) + fv = g_flags_get_value_by_name (fclass, flag); if (!fv) fv = g_flags_get_value_by_nick (fclass, flag); diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index ca7a91883f..798f29fd7c 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -587,7 +587,7 @@ parse_property (ParserData *data, if (bind_flags_str) { - if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, bind_flags_str, &bind_flags, error)) + if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, NULL, bind_flags_str, &bind_flags, error)) { _gtk_builder_prefix_error (data->builder, data->ctx, error); return; diff --git a/gtk/gtkbuilderprivate.h b/gtk/gtkbuilderprivate.h index 6fbf996451..06b9a7aefc 100644 --- a/gtk/gtkbuilderprivate.h +++ b/gtk/gtkbuilderprivate.h @@ -162,10 +162,11 @@ gboolean _gtk_builder_enum_from_string (GType type, const gchar *string, gint *enum_value, GError **error); -gboolean _gtk_builder_flags_from_string (GType type, - const char *string, - guint *value, - GError **error); +gboolean _gtk_builder_flags_from_string (GType type, + GFlagsValue *aliases, + const char *string, + guint *value, + GError **error); const gchar * _gtk_builder_parser_translate (const gchar *domain, const gchar *context, const gchar *text); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 508c0ebadd..7c762537c3 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -14257,7 +14257,14 @@ accel_group_start_element (GMarkupParseContext *context, if (modifiers_str != NULL) { - if (!_gtk_builder_flags_from_string (GDK_TYPE_MODIFIER_TYPE, + GFlagsValue aliases[2] = { + { 0, "primary", "primary" }, + { 0, NULL, NULL } + }; + + aliases[0].value = _gtk_get_primary_accel_mod (); + + if (!_gtk_builder_flags_from_string (GDK_TYPE_MODIFIER_TYPE, aliases, modifiers_str, &modifiers, error)) { _gtk_builder_prefix_error (data->builder, context, error);