app: change gimp_edit_fill() to take a GimpFillOptions

instead of a long list of parameters. Get rid of gimp_edit_fill_full().
This commit is contained in:
Michael Natterer 2016-03-11 19:52:36 +01:00
parent 00932b57af
commit e1e77f88fa
8 changed files with 367 additions and 292 deletions

View File

@ -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);
}

View File

@ -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);
if (! gimp_get_fill_params (context, fill_type, &color, &pattern, error))
return FALSE;
switch (fill_type)
{
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");
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");
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);
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), FALSE);
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
return TRUE; /* nothing to do, but the fill succeeded */
switch (gimp_fill_options_get_style (options))
{
case GIMP_FILL_STYLE_SOLID:
gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
break;
case GIMP_FILL_STYLE_PATTERN:
pattern = gimp_context_get_pattern (GIMP_CONTEXT (options));
break;
}
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);

View File

@ -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__ */

View File

@ -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);

View File

@ -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_edit_fill (image, drawable, context,
(GimpFillType) fill_type,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
error);
success = gimp_fill_options_set_by_fill_type (options, context,
fill_type, 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)
{
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 (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
success = gimp_edit_fill (image, drawable, context, fill_type,
opacity / 100.0, paint_mode,
error);
GimpFillOptions *options = gimp_fill_options_new (gimp);
success = gimp_fill_options_set_by_fill_mode (options, context,
fill_mode, error);
if (success)
{
gimp_context_set_opacity (GIMP_CONTEXT (options), opacity / 100.0);
gimp_context_set_paint_mode (GIMP_CONTEXT (options), paint_mode);
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)
{
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 (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
success = gimp_edit_fill (image, drawable, context, fill_type,
opacity / 100.0, paint_mode,
error);
GimpFillOptions *options = gimp_fill_options_new (gimp);
success = gimp_fill_options_set_by_fill_mode (options, context,
fill_mode, error);
if (success)
{
gimp_context_set_opacity (GIMP_CONTEXT (options), opacity / 100.0);
gimp_context_set_paint_mode (GIMP_CONTEXT (options), paint_mode);
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,

View File

@ -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)
{
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;
}
x = coords->x;
y = coords->y;
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;
}
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);
GimpFillOptions *fill_options = gimp_fill_options_new (image->gimp);
success = gimp_fill_options_set_by_fill_mode (fill_options, context,
options->fill_mode,
&error);
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));
success = gimp_edit_fill (image, drawable, fill_options, NULL);
}
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),

View File

@ -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_image_flush (gimp_item_get_image (GIMP_ITEM (dest_viewable)));
gimp_context_set_foreground (GIMP_CONTEXT (options), color);
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));

View File

@ -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_edit_fill (image, drawable, context,
(GimpFillType) fill_type,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
error);
success = gimp_fill_options_set_by_fill_type (options, context,
fill_type, 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)
{
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 (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
success = gimp_edit_fill (image, drawable, context, fill_type,
opacity / 100.0, paint_mode,
error);
GimpFillOptions *options = gimp_fill_options_new (gimp);
success = gimp_fill_options_set_by_fill_mode (options, context,
fill_mode, error);
if (success)
{
gimp_context_set_opacity (GIMP_CONTEXT (options), opacity / 100.0);
gimp_context_set_paint_mode (GIMP_CONTEXT (options), paint_mode);
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)
{
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 (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
success = gimp_edit_fill (image, drawable, context, fill_type,
opacity / 100.0, paint_mode,
error);
GimpFillOptions *options = gimp_fill_options_new (gimp);
success = gimp_fill_options_set_by_fill_mode (options, context,
fill_mode, error);
if (success)
{
gimp_context_set_opacity (GIMP_CONTEXT (options), opacity / 100.0);
gimp_context_set_paint_mode (GIMP_CONTEXT (options), paint_mode);
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,