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



commit 300eeca773564dc44a4b65159b5b971c21a033cc
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Fri Dec 17 23:50:02 2010 +0900

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

 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 dadd254..71844c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,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.
+
 2010-12-17  Tristan Van Berkom <tristanvb openismus com>
 
 	* NEWS, configure.ac: Rolling 3.7.2.
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 40965b1..2329446 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 445028c..d058836 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]