[gimp] Really don't paint on locked drawables



commit 7b5e176eeecd394b83b69ca1b8cbce8ad56a7002
Author: Michael Natterer <mitch gimp org>
Date:   Fri Aug 21 11:55:18 2009 +0200

    Really don't paint on locked drawables
    
    Remove GimpTool::initialize() implementation again and check for the
    drawable being locked in GimpTool::button_press() so we can't paint if
    the tool has been used before on the same drawable when it was
    unlocked.

 app/tools/gimppainttool.c |   38 +++++++++-----------------------------
 1 files changed, 9 insertions(+), 29 deletions(-)
---
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index 34ad4fd..137be79 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -59,9 +59,6 @@ static GObject * gimp_paint_tool_constructor (GType                  type,
                                               GObjectConstructParam *params);
 static void   gimp_paint_tool_finalize       (GObject               *object);
 
-static gboolean  gimp_paint_tool_initialize  (GimpTool              *tool,
-                                              GimpDisplay           *display,
-                                              GError               **error);
 static void   gimp_paint_tool_control        (GimpTool              *tool,
                                               GimpToolAction         action,
                                               GimpDisplay           *display);
@@ -115,7 +112,6 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
   object_class->constructor  = gimp_paint_tool_constructor;
   object_class->finalize     = gimp_paint_tool_finalize;
 
-  tool_class->initialize     = gimp_paint_tool_initialize;
   tool_class->control        = gimp_paint_tool_control;
   tool_class->button_press   = gimp_paint_tool_button_press;
   tool_class->button_release = gimp_paint_tool_button_release;
@@ -221,29 +217,6 @@ gimp_paint_tool_enable_color_picker (GimpPaintTool     *tool,
   GIMP_COLOR_TOOL (tool)->pick_mode = mode;
 }
 
-static gboolean
-gimp_paint_tool_initialize (GimpTool     *tool,
-                            GimpDisplay  *display,
-                            GError      **error)
-{
-  GimpDrawable *drawable = gimp_image_get_active_drawable (display->image);
-
-  if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
-    {
-      return FALSE;
-    }
-
-  if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)) &&
-      gimp_item_get_lock_content (GIMP_ITEM (drawable)))
-    {
-      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
-			   _("The active layer's pixels are locked."));
-      return FALSE;
-    }
-
-  return TRUE;
-}
-
 static void
 gimp_paint_tool_control (GimpTool       *tool,
                          GimpToolAction  action,
@@ -294,10 +267,17 @@ gimp_paint_tool_button_press (GimpTool            *tool,
       return;
     }
 
-  curr_coords = *coords;
-
   drawable = gimp_image_get_active_drawable (display->image);
 
+  if (gimp_item_get_lock_content (GIMP_ITEM (drawable)))
+    {
+      gimp_tool_message_literal (tool, display,
+                                 _("The active layer's pixels are locked."));
+      return;
+    }
+
+  curr_coords = *coords;
+
   gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
 
   curr_coords.x -= off_x;



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