diff options
author | Corentin Noël <corentin@elementary.io> | 2019-10-04 13:59:39 +0000 |
---|---|---|
committer | Alberto Fanjul <albertofanjul@gmail.com> | 2019-10-04 13:59:39 +0000 |
commit | 3512d2eb8522a7fa323086462883593a0ae2cce7 (patch) | |
tree | 8428dd089149ea88d992602845da38163bbb3158 /plugins | |
parent | ddcb64d2e5a7698688c71881db40a3cc317102ed (diff) | |
download | glade-3512d2eb8522a7fa323086462883593a0ae2cce7.tar.gz |
gtk+: Allow to use GtkResponseType with GtkDialog and GtkInfobar buttons
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtk+/glade-gtk-action-widgets.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/plugins/gtk+/glade-gtk-action-widgets.c b/plugins/gtk+/glade-gtk-action-widgets.c index 47e8db0d..cb5beb14 100644 --- a/plugins/gtk+/glade-gtk-action-widgets.c +++ b/plugins/gtk+/glade-gtk-action-widgets.c @@ -44,7 +44,7 @@ glade_gtk_action_widgets_read_responses (GladeWidget *widget, GladeXmlNode *widgets_node, gchar *action_container) { - GladeWidget *action_widget, *action_area; + GladeWidget *action_area; GladeXmlNode *node; if ((action_area = glade_gtk_action_widgets_get_area (widget, action_container)) == NULL) @@ -52,11 +52,11 @@ glade_gtk_action_widgets_read_responses (GladeWidget *widget, g_warning ("%s: Could not find action widgets container [%s]", __func__, action_container); return; } - + for (node = glade_xml_node_get_children (widgets_node); node; node = glade_xml_node_next (node)) { - gchar *widget_name, *response; + gchar *response; if (!glade_xml_node_verify (node, GLADE_TAG_ACTION_WIDGET)) continue; @@ -64,17 +64,41 @@ glade_gtk_action_widgets_read_responses (GladeWidget *widget, response = glade_xml_get_property_string_required (node, GLADE_TAG_RESPONSE, NULL); - widget_name = glade_xml_get_content (node); - - if ((action_widget = glade_widget_find_child (action_area, widget_name))) + if (response) { - glade_widget_property_set_enabled (action_widget, "response-id", TRUE); - glade_widget_property_set (action_widget, "response-id", - (gint)g_ascii_strtoll (response, NULL, 10)); + gchar *widget_name = glade_xml_get_content (node); + GladeWidget *action_widget = glade_widget_find_child (action_area, widget_name); + + if (action_widget) + { + gint response_id = (gint)g_ascii_strtoll (response, NULL, 10); + if (response_id == 0) { + GEnumClass *enum_class = g_type_class_ref (GTK_TYPE_RESPONSE_TYPE); + GEnumValue *value = g_enum_get_value_by_name (enum_class, response); + if (value) + { + response_id = value->value; + } + else + { + value = g_enum_get_value_by_nick (enum_class, response); + if (value) + { + response_id = value->value; + } + } + + g_type_class_unref (enum_class); + } + + glade_widget_property_set_enabled (action_widget, "response-id", TRUE); + glade_widget_property_set (action_widget, "response-id", response_id); + } + + g_free (widget_name); } g_free (response); - g_free (widget_name); } } |