diff options
author | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2013-09-11 18:05:26 -0300 |
---|---|---|
committer | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2013-09-11 18:22:18 -0300 |
commit | 78cec7bd42188b37d57016fbadc300f6cb1e99bb (patch) | |
tree | 860bc775349909eecd09d3e540c81316726940c5 /gladeui/glade-widget.c | |
parent | 9e1b474621314dd3fa41ace6b17c615a9bdb498e (diff) | |
download | glade-78cec7bd42188b37d57016fbadc300f6cb1e99bb.tar.gz |
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!
Diffstat (limited to 'gladeui/glade-widget.c')
-rw-r--r-- | 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 caa1d6d2..c95a1bc0 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)) |