[glade] Fixed bug 702314 "Cancelling an Add Parent action is destructive"



commit 434f456caf5460a8483f5de7f4608270551d56c5
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Mon Jan 20 18:22:48 2014 -0300

    Fixed bug 702314 "Cancelling an Add Parent action is destructive"

 plugins/gtk+/glade-gtk-widget.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-widget.c b/plugins/gtk+/glade-gtk-widget.c
index c6ac7e1..14f3718 100644
--- a/plugins/gtk+/glade-gtk-widget.c
+++ b/plugins/gtk+/glade-gtk-widget.c
@@ -904,7 +904,6 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
            glade_widget_dup_properties (gwidget, glade_widget_get_packing_properties (gwidget),
                                         FALSE, FALSE, FALSE);
 
-
          property = glade_widget_get_parentless_widget_ref (gwidget);
 
          /* Remove "this" widget, If the parent we're removing is a parentless 
@@ -936,8 +935,6 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
               /* Create heavy-duty glade-command properties stuff */
               prop_cmds =
                   create_command_property_list (gnew_parent, saved_props);
-              g_list_foreach (saved_props, (GFunc) g_object_unref, NULL);
-              g_list_free (saved_props);
 
               /* Apply the properties in an undoable way */
               if (prop_cmds)
@@ -946,18 +943,26 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
 
               /* Add "this" widget to the new parent */
               glade_command_add (&this_widget, gnew_parent, NULL, project, FALSE);
+
+              glade_command_pop_group ();
             }
           else
            {
-             /* Create parent was cancelled, paste back to parent */
-             glade_command_add (&this_widget, gparent, NULL, project, FALSE);
-
-             /* Restore any parentless widget reference if there was one */
-             if (property)
-               glade_command_set_property (property, glade_widget_get_object (gwidget));
+              glade_command_pop_group ();
+
+              /* Undo delete command
+               * FIXME: this will leave the "Adding parent..." comand in the
+               * redo list, which I think its better than leaving it in the
+               * undo list by using glade_command_add() to add the widget back
+               * to the original parent.
+               * Ideally we need a way to remove a redo item from the project or
+               * simply do not let the user cancel a widget creation!
+               */
+             glade_project_undo (project);
            }
 
-          glade_command_pop_group ();
+          g_list_foreach (saved_props, (GFunc) g_object_unref, NULL);
+          g_list_free (saved_props);
         }
     }
   else if (strcmp (action_path, "sizegroup_add") == 0)


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