[glade] GtkListBox support: Added action to add list box rows to a list box.



commit e95245f5f1c93016489f137060ad79e25487f51e
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Wed Aug 7 16:03:06 2013 +0200

    GtkListBox support: Added action to add list box rows to a list box.

 plugins/gtk+/glade-gtk-list-box.c |   23 +++++++++++++++++++++--
 plugins/gtk+/gtk+.xml.in          |    6 ++++++
 2 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-list-box.c b/plugins/gtk+/glade-gtk-list-box.c
index 8b05699..78c2c6c 100644
--- a/plugins/gtk+/glade-gtk-list-box.c
+++ b/plugins/gtk+/glade-gtk-list-box.c
@@ -189,8 +189,6 @@ glade_gtk_listbox_add_verify (GladeWidgetAdaptor *adaptor,
                               GtkWidget          *child,
                               gboolean            user_feedback)
 {
-  g_return_if_fail (GTK_IS_LIST_BOX (container));
-
   if (!GTK_IS_LIST_BOX_ROW (child))
     {
       if (user_feedback)
@@ -271,6 +269,26 @@ glade_gtk_listbox_child_insert_action (GladeWidgetAdaptor *adaptor,
 }
 
 void
+glade_gtk_listbox_action_activate (GladeWidgetAdaptor * adaptor,
+                                  GObject * object,
+                                  const gchar * action_path)
+{
+  if (strcmp (action_path, "add_row") == 0)
+    {
+      GladeWidgetAdaptor *adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LIST_BOX_ROW);
+      GladeWidget *gparent = glade_widget_get_from_gobject (object);
+      GladeProject *project = glade_widget_get_project (gparent);
+
+      glade_command_create (adaptor, gparent, NULL, project);
+
+      glade_project_selection_set (project, object, TRUE);
+    }
+  else
+    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
+                                                         object, action_path);
+}
+
+void
 glade_gtk_listbox_child_action_activate (GladeWidgetAdaptor *adaptor,
                                          GObject            *container,
                                          GObject            *object,
@@ -296,3 +314,4 @@ glade_gtk_listbox_child_action_activate (GladeWidgetAdaptor *adaptor,
                                                                  action_path);
     }
 }
+
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index e0fb11b..fbf656f 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1990,6 +1990,8 @@ range of values</_tooltip>
     <glade-widget-class name="GtkAspectFrame" generic-name="aspectframe" _title="Aspect Frame"/>
 
     <glade-widget-class name="GtkListBox" generic-name="listbox" _title="List Box" use-placeholders="False">
+
+      <action-activate-function>glade_gtk_listbox_action_activate</action-activate-function>
       
<child-action-activate-function>glade_gtk_listbox_child_action_activate</child-action-activate-function>
       <create-widget-function>glade_gtk_create_fixed_widget</create-widget-function>
       <post-create-function>glade_gtk_listbox_post_create</post-create-function>
@@ -1999,6 +2001,10 @@ range of values</_tooltip>
       <child-set-property-function>glade_gtk_listbox_set_child_property</child-set-property-function>
       <child-get-property-function>glade_gtk_listbox_get_child_property</child-get-property-function>
 
+      <actions>
+        <action id="add_row" _name="Add Row" stock="gtk-add" important="True"/>
+      </actions>
+
       <packing-actions>
         <action id="insert_before" _name="Insert Before" stock="gtk-add"/>
         <action id="insert_after" _name="Insert After" stock="gtk-add"/>


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