[gimp] app: make the gimp_drawable_fill*() API symmetric to gimp_edit_fill*()



commit ee3846cc8b52e0201343901f7287030862d1ed6d
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jun 3 14:11:59 2014 +0200

    app: make the gimp_drawable_fill*() API symmetric to gimp_edit_fill*()

 app/actions/channels-commands.c |   12 ++++----
 app/actions/layers-commands.c   |   12 ++++----
 app/core/gimpdrawable.c         |   58 +++++++++++++++++++-------------------
 app/core/gimpdrawable.h         |    6 ++--
 app/core/gimpimage-new.c        |    4 +-
 app/pdb/drawable-cmds.c         |    4 ++-
 tools/pdbgen/pdb/drawable.pdb   |    4 ++-
 7 files changed, 52 insertions(+), 48 deletions(-)
---
diff --git a/app/actions/channels-commands.c b/app/actions/channels-commands.c
index 48714f0..4466a2f 100644
--- a/app/actions/channels-commands.c
+++ b/app/actions/channels-commands.c
@@ -161,9 +161,9 @@ channels_new_last_vals_cmd_callback (GtkAction *action,
   new_channel = gimp_channel_new (image, width, height,
                                   channel_name, &color);
 
-  gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_channel),
-                              action_data_get_context (data),
-                              GIMP_FILL_TRANSPARENT);
+  gimp_drawable_fill (GIMP_DRAWABLE (new_channel),
+                      action_data_get_context (data),
+                      GIMP_FILL_TRANSPARENT);
 
   gimp_image_add_channel (image, new_channel,
                           GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
@@ -358,9 +358,9 @@ channels_new_channel_response (GtkWidget            *widget,
                                           channel_name,
                                           &channel_color);
 
-          gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_channel),
-                                      options->context,
-                                      GIMP_FILL_TRANSPARENT);
+          gimp_drawable_fill (GIMP_DRAWABLE (new_channel),
+                              options->context,
+                              GIMP_FILL_TRANSPARENT);
         }
 
       gimp_image_add_channel (options->image, new_channel,
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index b5be1de..38264b6 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -326,9 +326,9 @@ layers_new_last_vals_cmd_callback (GtkAction *action,
                               layer_name,
                               opacity, mode);
 
-  gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_layer),
-                              action_data_get_context (data),
-                              layer_fill_type);
+  gimp_drawable_fill (GIMP_DRAWABLE (new_layer),
+                      action_data_get_context (data),
+                      layer_fill_type);
   gimp_item_translate (GIMP_ITEM (new_layer), off_x, off_y, FALSE);
 
   gimp_image_add_layer (image, new_layer,
@@ -1035,9 +1035,9 @@ layers_new_layer_response (GtkWidget          *widget,
 
       if (layer)
         {
-          gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
-                                      dialog->context,
-                                      layer_fill_type);
+          gimp_drawable_fill (GIMP_DRAWABLE (layer),
+                              dialog->context,
+                              layer_fill_type);
 
           gimp_image_add_layer (dialog->image, layer,
                                 GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 9744797..2241295 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1490,15 +1490,39 @@ gimp_drawable_push_undo (GimpDrawable *drawable,
 }
 
 void
-gimp_drawable_fill (GimpDrawable      *drawable,
-                    const GimpRGB     *color,
-                    const GimpPattern *pattern)
+gimp_drawable_fill (GimpDrawable *drawable,
+                    GimpContext  *context,
+                    GimpFillType  fill_type)
+{
+  GimpRGB      color;
+  GimpPattern *pattern;
+
+  g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
+
+  if (! gimp_get_fill_params (context, fill_type, &color, &pattern, NULL))
+    return;
+
+  gimp_drawable_fill_full (drawable, &color, pattern);
+}
+
+void
+gimp_drawable_fill_full (GimpDrawable      *drawable,
+                         const GimpRGB     *color,
+                         const GimpPattern *pattern)
 {
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
-  g_return_if_fail (color != NULL || pattern != NULL);
+  g_return_if_fail (color != NULL);
   g_return_if_fail (pattern == NULL || GIMP_IS_PATTERN (pattern));
 
-  if (color)
+  if (pattern)
+    {
+      GeglBuffer *src_buffer = gimp_pattern_create_buffer (pattern);
+
+      gegl_buffer_set_pattern (gimp_drawable_get_buffer (drawable),
+                               NULL, src_buffer, 0, 0);
+      g_object_unref (src_buffer);
+    }
+  else
     {
       GimpRGB    c = *color;
       GeglColor *col;
@@ -1511,14 +1535,6 @@ gimp_drawable_fill (GimpDrawable      *drawable,
                              NULL, col);
       g_object_unref (col);
     }
-  else
-    {
-      GeglBuffer *src_buffer = gimp_pattern_create_buffer (pattern);
-
-      gegl_buffer_set_pattern (gimp_drawable_get_buffer (drawable),
-                               NULL, src_buffer, 0, 0);
-      g_object_unref (src_buffer);
-    }
 
   gimp_drawable_update (drawable,
                         0, 0,
@@ -1526,22 +1542,6 @@ gimp_drawable_fill (GimpDrawable      *drawable,
                         gimp_item_get_height (GIMP_ITEM (drawable)));
 }
 
-void
-gimp_drawable_fill_by_type (GimpDrawable *drawable,
-                            GimpContext  *context,
-                            GimpFillType  fill_type)
-{
-  GimpRGB      color;
-  GimpPattern *pattern;
-
-  g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
-
-  if (! gimp_get_fill_params (context, fill_type, &color, &pattern, NULL))
-    return;
-
-  gimp_drawable_fill (drawable, pattern ? NULL : &color, pattern);
-}
-
 const Babl *
 gimp_drawable_get_format (const GimpDrawable *drawable)
 {
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 24713fb..67e6743 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -194,11 +194,11 @@ void            gimp_drawable_push_undo          (GimpDrawable       *drawable,
                                                   gint                height);
 
 void            gimp_drawable_fill               (GimpDrawable       *drawable,
-                                                  const GimpRGB      *color,
-                                                  const GimpPattern  *pattern);
-void            gimp_drawable_fill_by_type       (GimpDrawable       *drawable,
                                                   GimpContext        *context,
                                                   GimpFillType        fill_type);
+void            gimp_drawable_fill_full          (GimpDrawable       *drawable,
+                                                  const GimpRGB      *color,
+                                                  const GimpPattern  *pattern);
 
 const Babl    * gimp_drawable_get_format         (const GimpDrawable *drawable);
 const Babl    * gimp_drawable_get_format_with_alpha
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index b0a7a99..d9e6fb9 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -136,8 +136,8 @@ gimp_image_new_from_template (Gimp         *gimp,
                           _("Background"),
                           GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
 
-  gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
-                              context, gimp_template_get_fill_type (template));
+  gimp_drawable_fill (GIMP_DRAWABLE (layer),
+                      context, gimp_template_get_fill_type (template));
 
   gimp_image_add_layer (image, layer, NULL, 0, FALSE);
 
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index 55027fd..a12e493 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -712,7 +712,9 @@ drawable_fill_invoker (GimpProcedure         *procedure,
       if (gimp_pdb_item_is_modifyable (GIMP_ITEM (drawable),
                                        GIMP_PDB_ITEM_CONTENT, error) &&
           gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
-        gimp_drawable_fill_by_type (drawable, context, (GimpFillType) fill_type);
+        {
+          gimp_drawable_fill (drawable, context, (GimpFillType) fill_type);
+        }
       else
         success = FALSE;
     }
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index 774f803..0166643 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -124,7 +124,9 @@ HELP
   if (gimp_pdb_item_is_modifyable (GIMP_ITEM (drawable),
                                    GIMP_PDB_ITEM_CONTENT, error) &&
       gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
-    gimp_drawable_fill_by_type (drawable, context, (GimpFillType) fill_type);
+    {
+      gimp_drawable_fill (drawable, context, (GimpFillType) fill_type);
+    }
   else
     success = FALSE;
 }


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