[glade3] * gladeui/glade-project.c: Restore proper sorting of objects at save time.



commit be45db8438513caec56f2dde926e7d3088d7fe13
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Fri Dec 17 23:00:11 2010 +0900

    	* gladeui/glade-project.c: Restore proper sorting of objects at save time.
    
    Conflicts:
    
    	ChangeLog

 ChangeLog               |    6 ++++++
 gladeui/glade-project.c |   44 +++++++++++++++++++++++---------------------
 2 files changed, 29 insertions(+), 21 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6fcf2d7..0b982e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-12-17  Tristan Van Berkom <tristanvb openismus com>
 
+	* gladeui/glade-project.c: Restore proper sorting of objects at save time.
+
+	* Marking ChangeLog, this is where 3.7.2 was rolled.
+
+2010-12-17  Tristan Van Berkom <tristanvb openismus com>
+
 	* gladeui/glade-app.[ch]: Added glade_app_queue_selection_changed()
 
 	* gladeui/glade-command.c: queue selection changes when widgets are added, this
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index d5c753e..d0e8796 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -1671,6 +1671,22 @@ glade_project_write_resource_path (GladeProject    *project,
 	}
 }
 
+static gint
+sort_project_dependancies (GObject *a, GObject *b)
+{
+	GladeWidget *ga, *gb;
+
+	ga = glade_widget_get_from_gobject (a);
+	gb = glade_widget_get_from_gobject (b);
+
+	if (glade_widget_adaptor_depends (ga->adaptor, ga, gb))
+		return 1;
+	else if (glade_widget_adaptor_depends (gb->adaptor, gb, ga))
+		return -1;
+	else 
+		return strcmp (ga->name, gb->name);
+}
+
 static GladeXmlContext *
 glade_project_write (GladeProject *project)
 {
@@ -1696,6 +1712,11 @@ glade_project_write (GladeProject *project)
 
 	glade_project_write_resource_path (project, context, root);
 
+	/* Sort the whole thing */
+	project->priv->objects = 
+		g_list_sort (project->priv->objects, 
+			     (GCompareFunc)sort_project_dependancies);
+
 	for (list = project->priv->objects; list; list = list->next)
 	{
 		GladeWidget *widget;
@@ -2807,22 +2828,6 @@ glade_project_set_widget_name (GladeProject *project,
 	gtk_tree_path_free (path);
 }
 
-static gint
-sort_project_dependancies (GObject *a, GObject *b)
-{
-	GladeWidget *ga, *gb;
-
-	ga = glade_widget_get_from_gobject (a);
-	gb = glade_widget_get_from_gobject (b);
-
-	if (glade_widget_adaptor_depends (ga->adaptor, ga, gb))
-		return 1;
-	else if (glade_widget_adaptor_depends (gb->adaptor, gb, ga))
-		return -1;
-	else 
-		return 1;
-}
-
 static gboolean
 glade_project_has_widget (GladeProject *project)
 {
@@ -2918,13 +2923,10 @@ glade_project_add_object (GladeProject *project,
 	glade_widget_set_project (gwidget, (gpointer)project);
 	g_object_ref_sink (gwidget);
 
+	/* Be sure to update the lists before emitting signals */
 	if (glade_widget_get_parent (gwidget) == NULL)
-	{
-		project->priv->tree = g_list_insert_sorted (project->priv->tree, object, 
-		                                            (GCompareFunc)sort_project_dependancies);
-	}
+		project->priv->tree = g_list_append (project->priv->tree, object);
 
-	/* Be sure to update the list before emitting signals */
 	project->priv->objects = g_list_prepend (project->priv->objects, object);
 
 	if (!project->priv->loading)



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