[glade] glade-gtk-action-widgets.[ch]: Added a function to ensure action widget names



commit 49f93cc5c8dad3b1a3221d692fa372b9cbf9abd0
Author: Tristan Van Berkom <tristan upstairslabs com>
Date:   Thu Jan 28 16:17:01 2016 +0100

    glade-gtk-action-widgets.[ch]: Added a function to ensure action widget names
    
    When saving dialogs and infobars, we just work around the problem and ensure
    that buttons with response ids enabled in the action area have names, not undoably.

 plugins/gtk+/glade-gtk-action-widgets.c |   35 +++++++++++++++++++++++++++++++
 plugins/gtk+/glade-gtk-action-widgets.h |    3 ++
 2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-action-widgets.c b/plugins/gtk+/glade-gtk-action-widgets.c
index 3b4bc96..b40db6d 100644
--- a/plugins/gtk+/glade-gtk-action-widgets.c
+++ b/plugins/gtk+/glade-gtk-action-widgets.c
@@ -141,6 +141,41 @@ glade_gtk_action_widgets_write_responses (GladeWidget *widget,
 }
 
 void
+glade_gtk_action_widgets_ensure_names (GladeWidget *widget, gchar *action_container)
+{
+  GList *l, *action_widgets;
+  GladeWidget *action_area;
+
+  if ((action_area = glade_gtk_action_widgets_get_area (widget, action_container)) == NULL)
+   {
+     g_warning ("%s: Could not find action widgets container [%s]", __func__, action_container);
+     return;
+   }
+
+  action_widgets = glade_widget_get_children (action_area);
+
+  for (l = action_widgets; l; l = l->next)
+    {
+      GladeWidget *action_widget;
+      GladeProperty *property;
+
+      if ((action_widget = glade_widget_get_from_gobject (l->data)) == NULL)
+        continue;
+
+      if ((property =
+           glade_widget_get_property (action_widget, "response-id")) == NULL)
+        continue;
+
+      if (!glade_property_get_enabled (property))
+       continue;
+
+      glade_widget_ensure_name (action_widget, glade_widget_get_project (action_widget), FALSE);
+    }
+
+  g_list_free (action_widgets);
+}
+
+void
 glade_gtk_action_widgets_write_child (GladeWidget *widget,
                                       GladeXmlContext *context,
                                       GladeXmlNode *node,
diff --git a/plugins/gtk+/glade-gtk-action-widgets.h b/plugins/gtk+/glade-gtk-action-widgets.h
index 283786f..3336885 100644
--- a/plugins/gtk+/glade-gtk-action-widgets.h
+++ b/plugins/gtk+/glade-gtk-action-widgets.h
@@ -33,6 +33,9 @@ G_BEGIN_DECLS
 #define GLADE_TAG_ACTION_WIDGET  "action-widget"
 #define GLADE_TAG_RESPONSE       "response"
 
+void glade_gtk_action_widgets_ensure_names (GladeWidget *widget,
+                                           gchar *action_container);
+
 void glade_gtk_action_widgets_read_child  (GladeWidget *widget,
                                            GladeXmlNode *node,
                                            gchar *action_container);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]