gimp r28000 - in trunk: . app/core



Author: mitch
Date: Sat Feb  7 19:23:32 2009
New Revision: 28000
URL: http://svn.gnome.org/viewvc/gimp?rev=28000&view=rev

Log:
2009-02-07  Michael Natterer  <mitch gimp org>

	Simplify floating selection handling a bit more:

	* app/core/gimpdrawable.c
	(gimp_drawable_attach_floating_sel)
	(gimp_drawable_detach_floating_sel): call
	gimp_image_set_floating_selection() from these functions.

	* app/core/gimpfloatingselundo.c (gimp_floating_sel_undo_pop)
	* app/core/gimpimage.c (gimp_image_add,remove_layer)
	* app/core/gimplayer-floating-sel.c (floating_sel_to_layer): don't
	call it here because we already call above functions.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpdrawable.c
   trunk/app/core/gimpfloatingselundo.c
   trunk/app/core/gimpimage.c
   trunk/app/core/gimplayer-floating-sel.c

Modified: trunk/app/core/gimpdrawable.c
==============================================================================
--- trunk/app/core/gimpdrawable.c	(original)
+++ trunk/app/core/gimpdrawable.c	Sat Feb  7 19:23:32 2009
@@ -1809,11 +1809,18 @@
 gimp_drawable_attach_floating_sel (GimpDrawable *drawable,
                                    GimpLayer    *floating_sel)
 {
+  GimpImage *image;
+
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
+  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
   g_return_if_fail (GIMP_IS_LAYER (floating_sel));
 
   g_printerr ("%s\n", G_STRFUNC);
 
+  image = gimp_item_get_image (GIMP_ITEM (drawable));
+
+  gimp_image_set_floating_selection (image, floating_sel);
+
   /*  clear the selection  */
   gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (floating_sel));
 
@@ -1829,11 +1836,15 @@
 gimp_drawable_detach_floating_sel (GimpDrawable *drawable,
                                    GimpLayer    *floating_sel)
 {
+  GimpImage *image;
+
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (GIMP_IS_LAYER (floating_sel));
 
   g_printerr ("%s\n", G_STRFUNC);
 
+  image = gimp_item_get_image (GIMP_ITEM (drawable));
+
   gimp_drawable_sync_source_node (drawable, TRUE);
 
 #ifdef __GNUC__
@@ -1850,4 +1861,6 @@
 
   /*  clear the selection  */
   gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (floating_sel));
+
+  gimp_image_set_floating_selection (image, NULL);
 }

Modified: trunk/app/core/gimpfloatingselundo.c
==============================================================================
--- trunk/app/core/gimpfloatingselundo.c	(original)
+++ trunk/app/core/gimpfloatingselundo.c	Sat Feb  7 19:23:32 2009
@@ -110,7 +110,6 @@
           gimp_layer_set_floating_sel_drawable (floating_layer,
                                                 floating_sel_undo->drawable);
           gimp_image_set_active_layer (undo->image, floating_layer);
-          gimp_image_set_floating_selection (undo->image, floating_layer);
 
           gimp_drawable_attach_floating_sel (gimp_layer_get_floating_sel_drawable (floating_layer),
                                              floating_layer);
@@ -120,9 +119,7 @@
           gimp_drawable_detach_floating_sel (gimp_layer_get_floating_sel_drawable (floating_layer),
                                              floating_layer);
 
-          /*  update the pointers  */
           gimp_layer_set_floating_sel_drawable (floating_layer, NULL);
-          gimp_image_set_floating_selection (undo->image, NULL);
         }
 
       gimp_object_name_changed (GIMP_OBJECT (floating_layer));

Modified: trunk/app/core/gimpimage.c
==============================================================================
--- trunk/app/core/gimpimage.c	(original)
+++ trunk/app/core/gimpimage.c	Sat Feb  7 19:23:32 2009
@@ -2967,14 +2967,10 @@
   /*  notify the layers dialog of the currently active layer  */
   gimp_image_set_active_layer (image, layer);
 
-  /*  If the layer is a floating selection, set the fs pointer  */
+  /*  If the layer is a floating selection, attach it to the drawable  */
   if (gimp_layer_is_floating_sel (layer))
-    {
-      gimp_image_set_floating_selection (image, layer);
-
-      gimp_drawable_attach_floating_sel (gimp_layer_get_floating_sel_drawable (layer),
-                                         layer);
-    }
+    gimp_drawable_attach_floating_sel (gimp_layer_get_floating_sel_drawable (layer),
+                                       layer);
 
   if (old_has_alpha != gimp_image_has_alpha (image))
     image->flush_accum.alpha_changed = TRUE;
@@ -3049,13 +3045,10 @@
   gimp_container_remove (image->layers, GIMP_OBJECT (layer));
   image->layer_stack = g_slist_remove (image->layer_stack, layer);
 
-  if (gimp_image_get_floating_selection (image) == layer)
+  if (gimp_layer_is_floating_sel (layer))
     {
-      /*  If this was the floating selection, reset the fs pointer
-       *  and activate the underlying drawable
+      /*  If this was the floating selection, activate the underlying drawable
        */
-      gimp_image_set_floating_selection (image, NULL);
-
       floating_sel_activate_drawable (layer);
     }
   else if (layer == active_layer)

Modified: trunk/app/core/gimplayer-floating-sel.c
==============================================================================
--- trunk/app/core/gimplayer-floating-sel.c	(original)
+++ trunk/app/core/gimplayer-floating-sel.c	Sat Feb  7 19:23:32 2009
@@ -142,9 +142,7 @@
   gimp_drawable_detach_floating_sel (gimp_layer_get_floating_sel_drawable (layer),
                                      layer);
 
-  /*  Set pointers  */
   gimp_layer_set_floating_sel_drawable (layer, NULL);
-  gimp_image_set_floating_selection (image, NULL);
 
   gimp_item_set_visible (item, TRUE, TRUE);
   gimp_layer_set_lock_alpha (layer, FALSE, TRUE);



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