File glade-bgo702314.patch of Package glade

From: Mike Gorse <mgorse@suse.com>
Date: Thu Mar 27 16:59:40 CDT 2014
Subject: [PATCH] Correctly fix BGO#702314 "Cancelling an Add Parent action is destructive"

Combination of upstream glade-3-16 commits to revert the original fix,
because it introduced another bug, then properly fix the bug.
---
 plugins/gtk+/glade-gtk-widget.c | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/plugins/gtk+/glade-gtk-widget.c b/plugins/gtk+/glade-gtk-widget.c
index 4a817dd..2f82867 100644
--- a/plugins/gtk+/glade-gtk-widget.c
+++ b/plugins/gtk+/glade-gtk-widget.c
@@ -864,31 +864,31 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
         {
           GladeWidgetAdaptor *adaptor =
             glade_widget_adaptor_get_by_type (new_type);
+          GList *saved_props, *prop_cmds;
 	  GladeWidget *gnew_parent;
+          GladeProperty *property;
 
           glade_command_push_group (_("Adding parent %s for %s"),
                                     glade_widget_adaptor_get_title (adaptor), 
 				    glade_widget_get_name (gwidget));
 
+          /* Record packing properties */
+          saved_props =
+	    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 
+	   * widget reference, the reference will be implicitly broken by the 'cut' command */
+          this_widget.data = gwidget;
+          glade_command_delete (&this_widget);
+
           /* Create new widget and put it where the placeholder was */
           if ((gnew_parent =
                glade_command_create (adaptor, gparent, NULL, project)) != NULL)
             {
-              GList *saved_props, *prop_cmds;
-              GladeProperty *property;
-
-              /* Record packing properties */
-              saved_props =
-                glade_widget_dup_properties (gwidget, glade_widget_get_packing_properties (gwidget),
-                                             FALSE, FALSE, FALSE);
-
-              /* Remove "this" widget, If the parent we're removing is a parentless
-               * widget reference, the reference will be implicitly broken by the 'cut' command */
-              this_widget.data = gwidget;
-              glade_command_delete (&this_widget);
-
-              property = glade_widget_get_parentless_widget_ref (gwidget);
-              
 	      /* Now we created the new parent, if gwidget had a parentless widget reference...
 	       * set that reference to the new parent instead */
 	      if (property)
@@ -920,6 +920,15 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
               /* Add "this" widget to the new parent */
               glade_command_add (&this_widget, gnew_parent, NULL, project, FALSE);
             }
+          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 ();
         }
-- 
1.8.4
openSUSE Build Service is sponsored by