[glade/glade-3-16] Fixed selection bug exposed by Bug #652655 fix.



commit eac22ef55c6a7dae84582884b2e91d0a0c0527c0
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Wed Sep 11 18:05:26 2013 -0300

    Fixed selection bug exposed by Bug #652655 fix.
    
    We made Project selection restoration more robust by saving a list of selected
    objects before rebuilding one of them and clearing it after the rebuild and
    just before restoring the selection.
    
    We still have a minor but obscure bug where the property editor of the
    construct only property does not work after rebuilding the object unless
    the move is moved out of the widget.
    
    This really shows why we need to split model data from runtime objects!

 gladeui/glade-widget.c |   47 ++++++++++++++++++++++++++++++-----------------
 1 files changed, 30 insertions(+), 17 deletions(-)
---
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index caa1d6d..c95a1bc 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -2483,7 +2483,7 @@ glade_widget_rebuild (GladeWidget * gwidget)
   GladeProject *project = NULL;
   GladeWidget  *parent = NULL;
   GList *children;
-  gboolean reselect = FALSE;
+  GList *selection = NULL;
   GList *restore_properties = NULL;
   GList *save_properties, *l;
 
@@ -2513,16 +2513,14 @@ glade_widget_rebuild (GladeWidget * gwidget)
   /* Here we take care removing the widget from the project and
    * the selection before rebuilding the instance.
    */
-  if (gwidget->priv->project && glade_project_has_object (gwidget->priv->project, gwidget->priv->object))
-    project = gwidget->priv->project;
-
-  if (project)
+  if (gwidget->priv->project && glade_project_has_object (gwidget->priv->project,
+                                                          gwidget->priv->object))
     {
+      project = gwidget->priv->project;
+
       if (glade_project_is_selected (project, gwidget->priv->object))
-        {
-          reselect = TRUE;
-          glade_project_selection_remove (project, gwidget->priv->object, FALSE);
-        }
+        selection = g_list_copy (glade_project_selection_get (project));
+
       glade_project_remove_object (project, gwidget->priv->object);
     }
 
@@ -2571,12 +2569,6 @@ glade_widget_rebuild (GladeWidget * gwidget)
   /* Only call this once the object has a proper GladeWidget */
   glade_widget_adaptor_post_create (adaptor, new_object, GLADE_CREATE_REBUILD);
 
-  /* Must call dispose for cases like dialogs and toplevels */
-  if (GTK_IS_WINDOW (old_object))
-    gtk_widget_destroy (GTK_WIDGET (old_object));
-  else
-    g_object_unref (old_object);
-
   /* Reparent any children of the old object to the new object
    * (this function will consume and free the child list).
    */
@@ -2623,10 +2615,31 @@ glade_widget_rebuild (GladeWidget * gwidget)
   if (project)
     {
       glade_project_add_object (project, gwidget->priv->object);
-      if (reselect)
-        glade_project_selection_add (project, gwidget->priv->object, TRUE);
+
+      if (selection)
+        {
+          glade_project_selection_clear (project, FALSE);
+
+          for (l = selection; l; l = g_list_next (l))
+            {
+              GObject *selected = l->data;
+
+              if (selected == old_object)
+                glade_project_selection_add (project, gwidget->priv->object, TRUE);
+              else
+                glade_project_selection_add (project, selected, TRUE);
+            }
+
+          g_list_free (selection);
+        }
     }
 
+  /* Must call dispose for cases like dialogs and toplevels */
+  if (GTK_IS_WINDOW (old_object))
+    gtk_widget_destroy (GTK_WIDGET (old_object));
+  else
+    g_object_unref (old_object);
+  
   /* Ensure rebuilt widget visibility */
   if (GTK_IS_WIDGET (gwidget->priv->object) && 
       !GTK_IS_WINDOW (gwidget->priv->object))


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