[gimp] app: change gimp_edit_fill() to take a GimpFillOptions
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: change gimp_edit_fill() to take a GimpFillOptions
- Date: Fri, 11 Mar 2016 18:56:42 +0000 (UTC)
commit e1e77f88fa06347ddf9f57a6f1be0a570bec3151
Author: Michael Natterer <mitch gimp org>
Date: Fri Mar 11 19:52:36 2016 +0100
app: change gimp_edit_fill() to take a GimpFillOptions
instead of a long list of parameters. Get rid of gimp_edit_fill_full().
app/actions/edit-commands.c | 21 ++++--
app/core/gimp-edit.c | 104 ++++++++++--------------------
app/core/gimp-edit.h | 95 ++++++++++++---------------
app/display/gimpdisplayshell-dnd.c | 25 ++++++--
app/pdb/edit-cmds.c | 124 ++++++++++++++++++++++--------------
app/tools/gimpbucketfilltool.c | 75 +++++++++++++---------
app/widgets/gimpdrawabletreeview.c | 77 +++++++++++++++-------
tools/pdbgen/pdb/edit.pdb | 124 ++++++++++++++++++++++--------------
8 files changed, 360 insertions(+), 285 deletions(-)
---
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index e0d3f4e..7544fef 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -32,6 +32,7 @@
#include "core/gimpbuffer.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h"
+#include "core/gimpfilloptions.h"
#include "core/gimplayer.h"
#include "core/gimplayer-new.h"
#include "core/gimpimage.h"
@@ -495,18 +496,22 @@ edit_fill_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
- GimpImage *image;
- GimpDrawable *drawable;
- GimpFillType fill_type;
- GError *error = NULL;
+ GimpImage *image;
+ GimpDrawable *drawable;
+ GimpFillType fill_type;
+ GimpFillOptions *options;
+ GError *error = NULL;
return_if_no_drawable (image, drawable, data);
fill_type = (GimpFillType) value;
- if (gimp_edit_fill (image, drawable, action_data_get_context (data),
- fill_type, GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
- &error))
+ options = gimp_fill_options_new (action_data_get_gimp (data));
+
+ if (gimp_fill_options_set_by_fill_type (options,
+ action_data_get_context (data),
+ fill_type, &error))
{
+ gimp_edit_fill (image, drawable, options, NULL);
gimp_image_flush (image);
}
else
@@ -515,6 +520,8 @@ edit_fill_cmd_callback (GtkAction *action,
error->message);
g_clear_error (&error);
}
+
+ g_object_unref (options);
}
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index e9230f9..02fc914 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -36,6 +36,7 @@
#include "gimpbuffer.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
+#include "gimpfilloptions.h"
#include "gimpdrawableundo.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
@@ -399,99 +400,62 @@ gimp_edit_clear (GimpImage *image,
GimpDrawable *drawable,
GimpContext *context)
{
- GimpRGB background;
- GimpLayerModeEffects paint_mode;
+ GimpFillOptions *options;
+ gboolean success;
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 (GIMP_IS_CONTEXT (context), FALSE);
- gimp_context_get_background (context, &background);
+ options = gimp_fill_options_new (context->gimp);
if (gimp_drawable_has_alpha (drawable))
- paint_mode = GIMP_ERASE_MODE;
+ gimp_fill_options_set_by_fill_type (options, context,
+ GIMP_FILL_TRANSPARENT, NULL);
else
- paint_mode = GIMP_NORMAL_MODE;
+ gimp_fill_options_set_by_fill_type (options, context,
+ GIMP_FILL_BACKGROUND, NULL);
- return gimp_edit_fill_full (image, drawable,
- &background, NULL,
- GIMP_OPACITY_OPAQUE, paint_mode,
- C_("undo-type", "Clear"));
+ success = gimp_edit_fill (image, drawable, options,
+ C_("undo-type", "Clear"));
+
+ g_object_unref (options);
+
+ return success;
}
gboolean
-gimp_edit_fill (GimpImage *image,
- GimpDrawable *drawable,
- GimpContext *context,
- GimpFillType fill_type,
- gdouble opacity,
- GimpLayerModeEffects paint_mode,
- GError **error)
+gimp_edit_fill (GimpImage *image,
+ GimpDrawable *drawable,
+ GimpFillOptions *options,
+ const gchar *undo_desc)
{
+ GeglBuffer *dest_buffer;
+ GimpPattern *pattern = NULL;
GimpRGB color;
- GimpPattern *pattern;
- const gchar *undo_desc = NULL;
+ const Babl *format;
+ gint x, y, width, height;
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 (GIMP_IS_CONTEXT (context), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), FALSE);
- if (! gimp_get_fill_params (context, fill_type, &color, &pattern, error))
- return FALSE;
+ if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
+ return TRUE; /* nothing to do, but the fill succeeded */
- switch (fill_type)
+ switch (gimp_fill_options_get_style (options))
{
- case GIMP_FILL_FOREGROUND:
- undo_desc = C_("undo-type", "Fill with Foreground Color");
- break;
-
- case GIMP_FILL_BACKGROUND:
- undo_desc = C_("undo-type", "Fill with Background Color");
+ case GIMP_FILL_STYLE_SOLID:
+ gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
break;
- case GIMP_FILL_WHITE:
- undo_desc = C_("undo-type", "Fill with White");
- break;
-
- case GIMP_FILL_TRANSPARENT:
- undo_desc = C_("undo-type", "Fill with Transparency");
- break;
-
- case GIMP_FILL_PATTERN:
- undo_desc = C_("undo-type", "Fill with Pattern");
+ case GIMP_FILL_STYLE_PATTERN:
+ pattern = gimp_context_get_pattern (GIMP_CONTEXT (options));
break;
}
- return gimp_edit_fill_full (image, drawable,
- &color, pattern,
- opacity, paint_mode,
- undo_desc);
-}
-
-gboolean
-gimp_edit_fill_full (GimpImage *image,
- GimpDrawable *drawable,
- const GimpRGB *color,
- GimpPattern *pattern,
- gdouble opacity,
- GimpLayerModeEffects paint_mode,
- const gchar *undo_desc)
-{
- GeglBuffer *dest_buffer;
- const Babl *format;
- gint x, y, width, height;
-
- 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);
-
- if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
- return TRUE; /* nothing to do, but the fill succeeded */
-
if (pattern &&
babl_format_has_alpha (gimp_temp_buf_get_format (pattern->mask)) &&
! gimp_drawable_has_alpha (drawable))
@@ -515,16 +479,20 @@ gimp_edit_fill_full (GimpImage *image,
}
else
{
- GeglColor *gegl_color = gimp_gegl_color_new (color);
+ GeglColor *gegl_color = gimp_gegl_color_new (&color);
gegl_buffer_set_color (dest_buffer, NULL, gegl_color);
g_object_unref (gegl_color);
}
+ if (! undo_desc)
+ undo_desc = gimp_fill_options_get_undo_desc (options);
+
gimp_drawable_apply_buffer (drawable, dest_buffer,
GEGL_RECTANGLE (0, 0, width, height),
TRUE, undo_desc,
- opacity, paint_mode,
+ gimp_context_get_opacity (GIMP_CONTEXT (options)),
+ gimp_context_get_paint_mode (GIMP_CONTEXT (options)),
NULL, x, y);
g_object_unref (dest_buffer);
diff --git a/app/core/gimp-edit.h b/app/core/gimp-edit.h
index 38b1a94..d22f392 100644
--- a/app/core/gimp-edit.h
+++ b/app/core/gimp-edit.h
@@ -19,62 +19,51 @@
#define __GIMP_EDIT_H__
-const GimpBuffer * gimp_edit_cut (GimpImage *image,
- GimpDrawable *drawable,
- GimpContext *context,
- GError **error);
-const GimpBuffer * gimp_edit_copy (GimpImage *image,
- GimpDrawable *drawable,
- GimpContext *context,
- GError **error);
-const GimpBuffer * gimp_edit_copy_visible (GimpImage *image,
- GimpContext *context,
- GError **error);
-GimpLayer * gimp_edit_paste (GimpImage *image,
- GimpDrawable *drawable,
- GimpBuffer *paste,
- gboolean paste_into,
- gint viewport_x,
- gint viewport_y,
- gint viewport_width,
- gint viewport_height);
+const GimpBuffer * gimp_edit_cut (GimpImage *image,
+ GimpDrawable *drawable,
+ GimpContext *context,
+ GError **error);
+const GimpBuffer * gimp_edit_copy (GimpImage *image,
+ GimpDrawable *drawable,
+ GimpContext *context,
+ GError **error);
+const GimpBuffer * gimp_edit_copy_visible (GimpImage *image,
+ GimpContext *context,
+ GError **error);
+GimpLayer * gimp_edit_paste (GimpImage *image,
+ GimpDrawable *drawable,
+ GimpBuffer *paste,
+ gboolean paste_into,
+ gint viewport_x,
+ gint viewport_y,
+ gint viewport_width,
+ gint viewport_height);
-const gchar * gimp_edit_named_cut (GimpImage *image,
- const gchar *name,
- GimpDrawable *drawable,
- GimpContext *context,
- GError **error);
-const gchar * gimp_edit_named_copy (GimpImage *image,
- const gchar *name,
- GimpDrawable *drawable,
- GimpContext *context,
- GError **error);
-const gchar * gimp_edit_named_copy_visible (GimpImage *image,
- const gchar *name,
- GimpContext *context,
- GError **error);
+const gchar * gimp_edit_named_cut (GimpImage *image,
+ const gchar *name,
+ GimpDrawable *drawable,
+ GimpContext *context,
+ GError **error);
+const gchar * gimp_edit_named_copy (GimpImage *image,
+ const gchar *name,
+ GimpDrawable *drawable,
+ GimpContext *context,
+ GError **error);
+const gchar * gimp_edit_named_copy_visible (GimpImage *image,
+ const gchar *name,
+ GimpContext *context,
+ GError **error);
-gboolean gimp_edit_clear (GimpImage *image,
- GimpDrawable *drawable,
- GimpContext *context);
-gboolean gimp_edit_fill (GimpImage *image,
- GimpDrawable *drawable,
- GimpContext *context,
- GimpFillType fill_type,
- gdouble opacity,
- GimpLayerModeEffects paint_mode,
- GError **error);
+gboolean gimp_edit_clear (GimpImage *image,
+ GimpDrawable *drawable,
+ GimpContext *context);
+gboolean gimp_edit_fill (GimpImage *image,
+ GimpDrawable *drawable,
+ GimpFillOptions *options,
+ const gchar *undo_desc);
-gboolean gimp_edit_fill_full (GimpImage *image,
- GimpDrawable *drawable,
- const GimpRGB *color,
- GimpPattern *pattern,
- gdouble opacity,
- GimpLayerModeEffects paint_mode,
- const gchar *undo_desc);
-
-gboolean gimp_edit_fade (GimpImage *image,
- GimpContext *context);
+gboolean gimp_edit_fade (GimpImage *image,
+ GimpContext *context);
#endif /* __GIMP_EDIT_H__ */
diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c
index 74e736c..47ff138 100644
--- a/app/display/gimpdisplayshell-dnd.c
+++ b/app/display/gimpdisplayshell-dnd.c
@@ -32,6 +32,7 @@
#include "core/gimpbuffer.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
+#include "core/gimpfilloptions.h"
#include "core/gimpimage.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage-new.h"
@@ -382,12 +383,24 @@ gimp_display_shell_dnd_fill (GimpDisplayShell *shell,
}
else
{
- gimp_edit_fill_full (image, drawable,
- color, pattern,
- GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
- pattern ?
- C_("undo-type", "Drop pattern to layer") :
- C_("undo-type", "Drop color to layer"));
+ GimpFillOptions *options = gimp_fill_options_new (image->gimp);
+
+ if (color)
+ {
+ gimp_context_set_foreground (GIMP_CONTEXT (options), color);
+ }
+ else
+ {
+ gimp_fill_options_set_style (options, GIMP_FILL_STYLE_PATTERN);
+ gimp_context_set_pattern (GIMP_CONTEXT (options), pattern);
+ }
+
+ gimp_edit_fill (image, drawable, options,
+ pattern ?
+ C_("undo-type", "Drop pattern to layer") :
+ C_("undo-type", "Drop color to layer"));
+
+ g_object_unref (options);
}
gimp_display_shell_dnd_flush (shell, image);
diff --git a/app/pdb/edit-cmds.c b/app/pdb/edit-cmds.c
index df471a9..dbe3236 100644
--- a/app/pdb/edit-cmds.c
+++ b/app/pdb/edit-cmds.c
@@ -553,12 +553,16 @@ edit_fill_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
- GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+ GimpFillOptions *options = gimp_fill_options_new (gimp);
+
+ success = gimp_fill_options_set_by_fill_type (options, context,
+ fill_type, error);
- success = gimp_edit_fill (image, drawable, context,
- (GimpFillType) fill_type,
- GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
- error);
+ if (success)
+ success = gimp_edit_fill (image, drawable, options, NULL);
+
+ g_object_unref (options);
}
else
success = FALSE;
@@ -601,36 +605,48 @@ edit_bucket_fill_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
- GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
- GimpFillType fill_type;
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
if (paint_mode == GIMP_OVERLAY_MODE)
paint_mode = GIMP_SOFTLIGHT_MODE;
- switch (fill_mode)
+ if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
- default:
- case GIMP_BUCKET_FILL_FG:
- fill_type = GIMP_FILL_FOREGROUND;
- break;
+ GimpFillOptions *options = gimp_fill_options_new (gimp);
- case GIMP_BUCKET_FILL_BG:
- fill_type = GIMP_FILL_BACKGROUND;
- break;
+ success = gimp_fill_options_set_by_fill_mode (options, context,
+ fill_mode, error);
- case GIMP_BUCKET_FILL_PATTERN:
- fill_type = GIMP_FILL_PATTERN;
- break;
- }
+ if (success)
+ {
+ gimp_context_set_opacity (GIMP_CONTEXT (options), opacity / 100.0);
+ gimp_context_set_paint_mode (GIMP_CONTEXT (options), paint_mode);
- if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
- {
- success = gimp_edit_fill (image, drawable, context, fill_type,
- opacity / 100.0, paint_mode,
- error);
+ success = gimp_edit_fill (image, drawable, options, NULL);
+ }
+
+ g_object_unref (options);
}
else
{
+ GimpFillType fill_type;
+
+ switch (fill_mode)
+ {
+ default:
+ case GIMP_BUCKET_FILL_FG:
+ fill_type = GIMP_FILL_FOREGROUND;
+ break;
+
+ case GIMP_BUCKET_FILL_BG:
+ fill_type = GIMP_FILL_BACKGROUND;
+ break;
+
+ case GIMP_BUCKET_FILL_PATTERN:
+ fill_type = GIMP_FILL_PATTERN;
+ break;
+ }
+
success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0,
FALSE /* don't fill transparent */,
@@ -687,37 +703,49 @@ edit_bucket_fill_full_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
- GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
- GimpFillType fill_type;
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
if (paint_mode == GIMP_OVERLAY_MODE)
paint_mode = GIMP_SOFTLIGHT_MODE;
- switch (fill_mode)
+ if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
- default:
- case GIMP_BUCKET_FILL_FG:
- fill_type = GIMP_FILL_FOREGROUND;
- break;
+ GimpFillOptions *options = gimp_fill_options_new (gimp);
- case GIMP_BUCKET_FILL_BG:
- fill_type = GIMP_FILL_BACKGROUND;
- break;
+ success = gimp_fill_options_set_by_fill_mode (options, context,
+ fill_mode, error);
- case GIMP_BUCKET_FILL_PATTERN:
- fill_type = GIMP_FILL_PATTERN;
- break;
- }
+ if (success)
+ {
+ gimp_context_set_opacity (GIMP_CONTEXT (options), opacity / 100.0);
+ gimp_context_set_paint_mode (GIMP_CONTEXT (options), paint_mode);
- if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
- {
- success = gimp_edit_fill (image, drawable, context, fill_type,
- opacity / 100.0, paint_mode,
- error);
+ success = gimp_edit_fill (image, drawable, options, NULL);
+ }
+
+ g_object_unref (options);
}
else
{
- success = gimp_drawable_bucket_fill (drawable, context, fill_type,
+ GimpFillType fill_type;
+
+ switch (fill_mode)
+ {
+ default:
+ case GIMP_BUCKET_FILL_FG:
+ fill_type = GIMP_FILL_FOREGROUND;
+ break;
+
+ case GIMP_BUCKET_FILL_BG:
+ fill_type = GIMP_FILL_BACKGROUND;
+ break;
+
+ case GIMP_BUCKET_FILL_PATTERN:
+ fill_type = GIMP_FILL_PATTERN;
+ break;
+ }
+
+ success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0,
fill_transparent,
select_criterion,
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index 8feafec..8d30364 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -28,6 +28,7 @@
#include "core/gimp-edit.h"
#include "core/gimpdrawable-bucket-fill.h"
#include "core/gimperror.h"
+#include "core/gimpfilloptions.h"
#include "core/gimpimage.h"
#include "core/gimpitem.h"
#include "core/gimppickable.h"
@@ -173,47 +174,61 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
{
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpContext *context = GIMP_CONTEXT (options);
- GimpFillType fill_type;
- gint x, y;
gboolean success;
GError *error = NULL;
- switch (options->fill_mode)
+ if (options->fill_selection)
{
- default:
- case GIMP_BUCKET_FILL_FG:
- fill_type = GIMP_FILL_FOREGROUND;
- break;
- case GIMP_BUCKET_FILL_BG:
- fill_type = GIMP_FILL_BACKGROUND;
- break;
- case GIMP_BUCKET_FILL_PATTERN:
- fill_type = GIMP_FILL_PATTERN;
- break;
- }
+ GimpFillOptions *fill_options = gimp_fill_options_new (image->gimp);
- x = coords->x;
- y = coords->y;
+ success = gimp_fill_options_set_by_fill_mode (fill_options, context,
+ options->fill_mode,
+ &error);
- if (! options->sample_merged)
- {
- gint off_x, off_y;
-
- gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
+ if (success)
+ {
+ gimp_context_set_opacity (GIMP_CONTEXT (fill_options),
+ gimp_context_get_opacity (context));
+ gimp_context_set_paint_mode (GIMP_CONTEXT (fill_options),
+ gimp_context_get_paint_mode (context));
- x -= off_x;
- y -= off_y;
- }
+ success = gimp_edit_fill (image, drawable, fill_options, NULL);
+ }
- if (options->fill_selection)
- {
- success = gimp_edit_fill (image, drawable, context, fill_type,
- gimp_context_get_opacity (context),
- gimp_context_get_paint_mode (context),
- &error);
+ g_object_unref (fill_options);
}
else
{
+ GimpFillType fill_type;
+ gint x, y;
+
+ x = coords->x;
+ y = coords->y;
+
+ switch (options->fill_mode)
+ {
+ default:
+ case GIMP_BUCKET_FILL_FG:
+ fill_type = GIMP_FILL_FOREGROUND;
+ break;
+ case GIMP_BUCKET_FILL_BG:
+ fill_type = GIMP_FILL_BACKGROUND;
+ break;
+ case GIMP_BUCKET_FILL_PATTERN:
+ fill_type = GIMP_FILL_PATTERN;
+ break;
+ }
+
+ if (! options->sample_merged)
+ {
+ gint off_x, off_y;
+
+ gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
+
+ x -= off_x;
+ y -= off_y;
+ }
+
success = gimp_drawable_bucket_fill (drawable, context, fill_type,
gimp_context_get_paint_mode (context),
gimp_context_get_opacity (context),
diff --git a/app/widgets/gimpdrawabletreeview.c b/app/widgets/gimpdrawabletreeview.c
index 0994093..aedc1a1 100644
--- a/app/widgets/gimpdrawabletreeview.c
+++ b/app/widgets/gimpdrawabletreeview.c
@@ -31,6 +31,7 @@
#include "core/gimp-edit.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
+#include "core/gimpfilloptions.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "core/gimppattern.h"
@@ -235,13 +236,20 @@ gimp_drawable_tree_view_drop_viewable (GimpContainerTreeView *view,
{
if (dest_viewable && GIMP_IS_PATTERN (src_viewable))
{
- gimp_edit_fill_full (gimp_item_get_image (GIMP_ITEM (dest_viewable)),
- GIMP_DRAWABLE (dest_viewable),
- NULL, GIMP_PATTERN (src_viewable),
- GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
- C_("undo-type", "Drop pattern to layer"));
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (dest_viewable));
+ GimpFillOptions *options = gimp_fill_options_new (image->gimp);
- gimp_image_flush (gimp_item_get_image (GIMP_ITEM (dest_viewable)));
+ gimp_fill_options_set_style (options, GIMP_FILL_STYLE_PATTERN);
+ gimp_context_set_pattern (GIMP_CONTEXT (options),
+ GIMP_PATTERN (src_viewable));
+
+ gimp_edit_fill (image, GIMP_DRAWABLE (dest_viewable),
+ options,
+ C_("undo-type", "Drop pattern to layer"));
+
+ g_object_unref (options);
+
+ gimp_image_flush (image);
return;
}
@@ -259,13 +267,18 @@ gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
{
if (dest_viewable)
{
- gimp_edit_fill_full (gimp_item_get_image (GIMP_ITEM (dest_viewable)),
- GIMP_DRAWABLE (dest_viewable),
- color, NULL,
- GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
- C_("undo-type", "Drop color to layer"));
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (dest_viewable));
+ GimpFillOptions *options = gimp_fill_options_new (image->gimp);
+
+ gimp_context_set_foreground (GIMP_CONTEXT (options), color);
- gimp_image_flush (gimp_item_get_image (GIMP_ITEM (dest_viewable)));
+ gimp_edit_fill (image, GIMP_DRAWABLE (dest_viewable),
+ options,
+ C_("undo-type", "Drop color to layer"));
+
+ g_object_unref (options);
+
+ gimp_image_flush (image);
}
}
@@ -307,28 +320,42 @@ gimp_drawable_tree_view_floating_selection_changed (GimpImage *image,
}
static void
-gimp_drawable_tree_view_new_dropped (GimpItemTreeView *view,
- gint x,
- gint y,
- const GimpRGB *color,
- GimpPattern *pattern)
+gimp_drawable_tree_view_new_dropped (GimpItemTreeView *view,
+ gint x,
+ gint y,
+ const GimpRGB *color,
+ GimpPattern *pattern)
{
GimpItem *item;
- gimp_image_undo_group_start (gimp_item_tree_view_get_image (view), GIMP_UNDO_GROUP_EDIT_PASTE,
+ gimp_image_undo_group_start (gimp_item_tree_view_get_image (view),
+ GIMP_UNDO_GROUP_EDIT_PASTE,
_("New Layer"));
item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->new_item (gimp_item_tree_view_get_image (view));
if (item)
{
- gimp_edit_fill_full (gimp_item_get_image (item),
- GIMP_DRAWABLE (item),
- color, pattern,
- GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
- pattern ?
- C_("undo-type", "Drop pattern to layer") :
- C_("undo-type", "Drop color to layer"));
+ GimpImage *image = gimp_item_get_image (item);
+ GimpFillOptions *options = gimp_fill_options_new (image->gimp);
+
+ if (color)
+ {
+ gimp_context_set_foreground (GIMP_CONTEXT (options), color);
+ }
+ else
+ {
+ gimp_fill_options_set_style (options, GIMP_FILL_STYLE_PATTERN);
+ gimp_context_set_pattern (GIMP_CONTEXT (options), pattern);
+ }
+
+ gimp_edit_fill (image, GIMP_DRAWABLE (item),
+ options,
+ pattern ?
+ C_("undo-type", "Drop pattern to layer") :
+ C_("undo-type", "Drop color to layer"));
+
+ g_object_unref (options);
}
gimp_image_undo_group_end (gimp_item_tree_view_get_image (view));
diff --git a/tools/pdbgen/pdb/edit.pdb b/tools/pdbgen/pdb/edit.pdb
index a7d1ba4..5d889ca 100644
--- a/tools/pdbgen/pdb/edit.pdb
+++ b/tools/pdbgen/pdb/edit.pdb
@@ -565,12 +565,16 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
- GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+ GimpFillOptions *options = gimp_fill_options_new (gimp);
+
+ success = gimp_fill_options_set_by_fill_type (options, context,
+ fill_type, error);
- success = gimp_edit_fill (image, drawable, context,
- (GimpFillType) fill_type,
- GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
- error);
+ if (success)
+ success = gimp_edit_fill (image, drawable, options, NULL);
+
+ g_object_unref (options);
}
else
success = FALSE;
@@ -637,36 +641,48 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
- GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
- GimpFillType fill_type;
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
if (paint_mode == GIMP_OVERLAY_MODE)
paint_mode = GIMP_SOFTLIGHT_MODE;
- switch (fill_mode)
+ if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
- default:
- case GIMP_BUCKET_FILL_FG:
- fill_type = GIMP_FILL_FOREGROUND;
- break;
+ GimpFillOptions *options = gimp_fill_options_new (gimp);
- case GIMP_BUCKET_FILL_BG:
- fill_type = GIMP_FILL_BACKGROUND;
- break;
+ success = gimp_fill_options_set_by_fill_mode (options, context,
+ fill_mode, error);
- case GIMP_BUCKET_FILL_PATTERN:
- fill_type = GIMP_FILL_PATTERN;
- break;
- }
+ if (success)
+ {
+ gimp_context_set_opacity (GIMP_CONTEXT (options), opacity / 100.0);
+ gimp_context_set_paint_mode (GIMP_CONTEXT (options), paint_mode);
- if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
- {
- success = gimp_edit_fill (image, drawable, context, fill_type,
- opacity / 100.0, paint_mode,
- error);
+ success = gimp_edit_fill (image, drawable, options, NULL);
+ }
+
+ g_object_unref (options);
}
else
{
+ GimpFillType fill_type;
+
+ switch (fill_mode)
+ {
+ default:
+ case GIMP_BUCKET_FILL_FG:
+ fill_type = GIMP_FILL_FOREGROUND;
+ break;
+
+ case GIMP_BUCKET_FILL_BG:
+ fill_type = GIMP_FILL_BACKGROUND;
+ break;
+
+ case GIMP_BUCKET_FILL_PATTERN:
+ fill_type = GIMP_FILL_PATTERN;
+ break;
+ }
+
success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0,
FALSE /* don't fill transparent */,
@@ -751,37 +767,49 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
- GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
- GimpFillType fill_type;
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
if (paint_mode == GIMP_OVERLAY_MODE)
paint_mode = GIMP_SOFTLIGHT_MODE;
- switch (fill_mode)
+ if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
- default:
- case GIMP_BUCKET_FILL_FG:
- fill_type = GIMP_FILL_FOREGROUND;
- break;
+ GimpFillOptions *options = gimp_fill_options_new (gimp);
- case GIMP_BUCKET_FILL_BG:
- fill_type = GIMP_FILL_BACKGROUND;
- break;
+ success = gimp_fill_options_set_by_fill_mode (options, context,
+ fill_mode, error);
- case GIMP_BUCKET_FILL_PATTERN:
- fill_type = GIMP_FILL_PATTERN;
- break;
- }
+ if (success)
+ {
+ gimp_context_set_opacity (GIMP_CONTEXT (options), opacity / 100.0);
+ gimp_context_set_paint_mode (GIMP_CONTEXT (options), paint_mode);
- if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
- {
- success = gimp_edit_fill (image, drawable, context, fill_type,
- opacity / 100.0, paint_mode,
- error);
+ success = gimp_edit_fill (image, drawable, options, NULL);
+ }
+
+ g_object_unref (options);
}
else
{
- success = gimp_drawable_bucket_fill (drawable, context, fill_type,
+ GimpFillType fill_type;
+
+ switch (fill_mode)
+ {
+ default:
+ case GIMP_BUCKET_FILL_FG:
+ fill_type = GIMP_FILL_FOREGROUND;
+ break;
+
+ case GIMP_BUCKET_FILL_BG:
+ fill_type = GIMP_FILL_BACKGROUND;
+ break;
+
+ case GIMP_BUCKET_FILL_PATTERN:
+ fill_type = GIMP_FILL_PATTERN;
+ break;
+ }
+
+ success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0,
fill_transparent,
select_criterion,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]