[glade3] * plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c: Alphabetically sort GtkBox children for save.



commit b26878449a76864d10c4090ef88da72a9f168aeb
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Fri Dec 17 23:55:15 2010 +0900

    	* plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c: Alphabetically sort GtkBox children for save.
    
    Conflicts:
    
    	ChangeLog

 ChangeLog                |    2 ++
 plugins/gtk+/glade-gtk.c |   25 +++++++++++++++++++++++--
 plugins/gtk+/gtk+.xml.in |    1 +
 3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4e15c3d..ce9a290 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
 
 	* gladeui/glade-property-class.c: Properly order object properties
 
+	* plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c: Alphabetically sort GtkBox children for save.
+
 	* Marking ChangeLog, this is where 3.7.2 was rolled.
 
 2010-12-17  Tristan Van Berkom <tristanvb openismus com>
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 32bca8e..a4844dc 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -1411,7 +1411,6 @@ glade_gtk_container_get_child_property (GladeWidgetAdaptor *adaptor,
 						  property_name, value);
 }
 
-
 GList *
 glade_gtk_container_get_children (GladeWidgetAdaptor  *adaptor,
 				  GtkContainer        *container)
@@ -1701,6 +1700,29 @@ sort_box_children (GtkWidget *widget_a, GtkWidget *widget_b)
 	return position_a - position_b;
 }
 
+static gint
+alpha_sort_box_children (GtkWidget *a, GtkWidget *b)
+{
+	GladeWidget *ga, *gb;
+
+	ga = glade_widget_get_from_gobject (a);
+	gb = glade_widget_get_from_gobject (b);
+
+	if (!ga || !gb)
+		return 1;
+	else 
+		return strcmp (ga->name, gb->name);
+}
+
+GList *
+glade_gtk_box_get_children (GladeWidgetAdaptor  *adaptor,
+			    GtkContainer        *container)
+{
+	GList *children = glade_util_container_get_all_children (container);
+
+	return g_list_sort (children, (GCompareFunc)alpha_sort_box_children);
+}
+
 void
 glade_gtk_box_set_child_property (GladeWidgetAdaptor *adaptor,
 				  GObject            *container,
@@ -1816,7 +1838,6 @@ glade_gtk_box_set_child_property (GladeWidgetAdaptor *adaptor,
 
 }
 
-
 void
 glade_gtk_box_get_property (GladeWidgetAdaptor *adaptor,
 			    GObject            *object, 
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 33b8508..314e495 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -296,6 +296,7 @@ embedded in another object</_tooltip>
     <glade-widget-class name="GtkBox" _title="Box" fixed="True">
       <post-create-function>glade_gtk_box_post_create</post-create-function>
       <get-internal-child-function>glade_gtk_box_get_internal_child</get-internal-child-function>
+      <get-children-function>glade_gtk_box_get_children</get-children-function>
       <set-property-function>glade_gtk_box_set_property</set-property-function>
       <get-property-function>glade_gtk_box_get_property</get-property-function>
       <verify-function>glade_gtk_box_verify_property</verify-function>



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