[gimp/goat-invasion: 138/608] app: add gimp_edit_fill_full() which takes color and pattern



commit 0b589a208b6008c021053b6caa33753729644f47
Author: Michael Natterer <mitch gimp org>
Date:   Sun Mar 18 22:31:11 2012 +0100

    app: add gimp_edit_fill_full() which takes color and pattern
    
    and use it for dropping colors and patterns on the display
    and on the layers dialog, instead of using the overkill
    gimp_drawable_bucket_fill_full().

 app/core/gimp-edit.c               |   18 +++++++++
 app/core/gimp-edit.h               |    5 +++
 app/display/gimpdisplayshell-dnd.c |   15 +++-----
 app/widgets/gimpdrawabletreeview.c |   69 +++++++++++-------------------------
 4 files changed, 49 insertions(+), 58 deletions(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 4098937..9bc4b25 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -454,6 +454,24 @@ gimp_edit_fill (GimpImage    *image,
 }
 
 gboolean
+gimp_edit_fill_full (GimpImage     *image,
+                     GimpDrawable  *drawable,
+                     const GimpRGB *color,
+                     GimpPattern   *pattern,
+                     const gchar   *undo_desc)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
+  g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
+  g_return_val_if_fail (color != NULL || pattern != NULL, FALSE);
+
+  return gimp_edit_fill_internal (image, drawable,
+                                  color, pattern,
+                                  GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
+                                  undo_desc);
+}
+
+gboolean
 gimp_edit_fade (GimpImage   *image,
                 GimpContext *context)
 {
diff --git a/app/core/gimp-edit.h b/app/core/gimp-edit.h
index a9e3e6a..a429082 100644
--- a/app/core/gimp-edit.h
+++ b/app/core/gimp-edit.h
@@ -61,6 +61,11 @@ gboolean           gimp_edit_fill               (GimpImage     *image,
                                                  GimpDrawable  *drawable,
                                                  GimpContext   *context,
                                                  GimpFillType   fill_type);
+gboolean           gimp_edit_fill_full          (GimpImage     *image,
+                                                 GimpDrawable  *drawable,
+                                                 const GimpRGB *color,
+                                                 GimpPattern   *pattern,
+                                                 const gchar   *undo_desc);
 
 gboolean           gimp_edit_fade               (GimpImage     *image,
                                                  GimpContext   *context);
diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c
index 0d78fb0..708399a 100644
--- a/app/display/gimpdisplayshell-dnd.c
+++ b/app/display/gimpdisplayshell-dnd.c
@@ -31,7 +31,6 @@
 #include "core/gimpbuffer.h"
 #include "core/gimpcontainer.h"
 #include "core/gimpcontext.h"
-#include "core/gimpdrawable-bucket-fill.h"
 #include "core/gimpimage.h"
 #include "core/gimpimage-merge.h"
 #include "core/gimpimage-new.h"
@@ -367,15 +366,11 @@ gimp_display_shell_dnd_bucket_fill (GimpDisplayShell   *shell,
     }
   else
     {
-      gimp_drawable_bucket_fill_full (drawable,
-                                      fill_mode,
-                                      GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
-                                      FALSE,             /* no seed fill */
-                                      FALSE,             /* don't fill transp */
-                                      GIMP_SELECT_CRITERION_COMPOSITE,
-                                      0.0, FALSE,        /* fill params  */
-                                      0.0, 0.0,          /* ignored      */
-                                      color, pattern);
+      gimp_edit_fill_full (image, drawable,
+                           color, pattern,
+                           pattern ?
+                           C_("undo-type", "Drop pattern to layer") :
+                           C_("undo-type", "Drop color to layer"));
     }
 
   gimp_display_shell_dnd_flush (shell, image);
diff --git a/app/widgets/gimpdrawabletreeview.c b/app/widgets/gimpdrawabletreeview.c
index 5dc9935..e46b764 100644
--- a/app/widgets/gimpdrawabletreeview.c
+++ b/app/widgets/gimpdrawabletreeview.c
@@ -28,13 +28,12 @@
 #include "widgets-types.h"
 
 #include "core/gimp.h"
+#include "core/gimp-edit.h"
 #include "core/gimpcontext.h"
 #include "core/gimpdrawable.h"
-#include "core/gimpdrawable-bucket-fill.h"
 #include "core/gimpimage.h"
 #include "core/gimpimage-undo.h"
 #include "core/gimppattern.h"
-#include "core/gimptoolinfo.h"
 
 #include "gimpcontainerview.h"
 #include "gimpdnd.h"
@@ -235,16 +234,12 @@ gimp_drawable_tree_view_drop_viewable (GimpContainerTreeView   *view,
 {
   if (dest_viewable && GIMP_IS_PATTERN (src_viewable))
     {
-      gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (dest_viewable),
-                                      GIMP_PATTERN_BUCKET_FILL,
-                                      GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
-                                      FALSE,             /* no seed fill */
-                                      FALSE,             /* don't fill transp */
-                                      GIMP_SELECT_CRITERION_COMPOSITE,
-                                      0.0, FALSE,        /* fill params  */
-                                      0.0, 0.0,          /* ignored      */
-                                      NULL, GIMP_PATTERN (src_viewable));
-      gimp_image_flush (gimp_item_tree_view_get_image (GIMP_ITEM_TREE_VIEW (view)));
+      gimp_edit_fill_full (gimp_item_get_image (GIMP_ITEM (dest_viewable)),
+                           GIMP_DRAWABLE (dest_viewable),
+                           NULL, GIMP_PATTERN (src_viewable),
+                           C_("undo-type", "Drop pattern to layer"));
+
+      gimp_image_flush (gimp_item_get_image (GIMP_ITEM (dest_viewable)));
       return;
     }
 
@@ -262,16 +257,12 @@ gimp_drawable_tree_view_drop_color (GimpContainerTreeView   *view,
 {
   if (dest_viewable)
     {
-      gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (dest_viewable),
-                                      GIMP_FG_BUCKET_FILL,
-                                      GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
-                                      FALSE,             /* no seed fill */
-                                      FALSE,             /* don't fill transp */
-                                      GIMP_SELECT_CRITERION_COMPOSITE,
-                                      0.0, FALSE,        /* fill params  */
-                                      0.0, 0.0,          /* ignored      */
-                                      color, NULL);
-      gimp_image_flush (gimp_item_tree_view_get_image (GIMP_ITEM_TREE_VIEW (view)));
+      gimp_edit_fill_full (gimp_item_get_image (GIMP_ITEM (dest_viewable)),
+                           GIMP_DRAWABLE (dest_viewable),
+                           color, NULL,
+                           C_("undo-type", "Drop color to layer"));
+
+      gimp_image_flush (gimp_item_get_image (GIMP_ITEM (dest_viewable)));
     }
 }
 
@@ -316,7 +307,6 @@ static void
 gimp_drawable_tree_view_new_dropped (GimpItemTreeView   *view,
                                      gint                x,
                                      gint                y,
-                                     GimpBucketFillMode  fill_mode,
                                      const GimpRGB      *color,
                                      GimpPattern        *pattern)
 {
@@ -329,25 +319,12 @@ gimp_drawable_tree_view_new_dropped (GimpItemTreeView   *view,
 
   if (item)
     {
-      /*  Get the bucket fill context  */
-      GimpContext  *context;
-      GimpToolInfo *tool_info = gimp_get_tool_info (gimp_item_tree_view_get_image (view)->gimp,
-                                                    "gimp-bucket-fill-tool");
-
-      if (tool_info && tool_info->tool_options)
-        context = GIMP_CONTEXT (tool_info->tool_options);
-      else
-        context = gimp_container_view_get_context (GIMP_CONTAINER_VIEW (view));
-
-      gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (item),
-                                      fill_mode,
-                                      gimp_context_get_paint_mode (context),
-                                      gimp_context_get_opacity (context),
-                                      FALSE, /* no seed fill */
-                                      FALSE, /* don't fill transp */
-                                      GIMP_SELECT_CRITERION_COMPOSITE,
-                                      0.0, FALSE, 0.0, 0.0 /* fill params */,
-                                      color, pattern);
+      gimp_edit_fill_full (gimp_item_get_image (item),
+                           GIMP_DRAWABLE (item),
+                           color, pattern,
+                           pattern ?
+                           C_("undo-type", "Drop pattern to layer") :
+                           C_("undo-type", "Drop color to layer"));
     }
 
   gimp_image_undo_group_end (gimp_item_tree_view_get_image (view));
@@ -363,9 +340,7 @@ gimp_drawable_tree_view_new_pattern_dropped (GtkWidget    *widget,
                                              gpointer      data)
 {
   gimp_drawable_tree_view_new_dropped (GIMP_ITEM_TREE_VIEW (data), x, y,
-                                       GIMP_PATTERN_BUCKET_FILL,
-                                       NULL,
-                                       GIMP_PATTERN (viewable));
+                                       NULL, GIMP_PATTERN (viewable));
 }
 
 static void
@@ -376,7 +351,5 @@ gimp_drawable_tree_view_new_color_dropped (GtkWidget     *widget,
                                            gpointer       data)
 {
   gimp_drawable_tree_view_new_dropped (GIMP_ITEM_TREE_VIEW (data), x, y,
-                                       GIMP_FG_BUCKET_FILL,
-                                       color,
-                                       NULL);
+                                       color, NULL);
 }



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