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/gimpbuffer.h"
#include "core/gimpcontainer.h" #include "core/gimpcontainer.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpfilloptions.h"
#include "core/gimplayer.h" #include "core/gimplayer.h"
#include "core/gimplayer-new.h" #include "core/gimplayer-new.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
@ -495,18 +496,22 @@ edit_fill_cmd_callback (GtkAction *action,
gint value, gint value,
gpointer data) gpointer data)
{ {
GimpImage *image; GimpImage *image;
GimpDrawable *drawable; GimpDrawable *drawable;
GimpFillType fill_type; GimpFillType fill_type;
GError *error = NULL; GimpFillOptions *options;
GError *error = NULL;
return_if_no_drawable (image, drawable, data); return_if_no_drawable (image, drawable, data);
fill_type = (GimpFillType) value; fill_type = (GimpFillType) value;
if (gimp_edit_fill (image, drawable, action_data_get_context (data), options = gimp_fill_options_new (action_data_get_gimp (data));
fill_type, GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
&error)) 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); gimp_image_flush (image);
} }
else else
@ -515,6 +520,8 @@ edit_fill_cmd_callback (GtkAction *action,
error->message); error->message);
g_clear_error (&error); g_clear_error (&error);
} }
g_object_unref (options);
} }

View File

@ -36,6 +36,7 @@
#include "gimpbuffer.h" #include "gimpbuffer.h"
#include "gimpchannel.h" #include "gimpchannel.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpfilloptions.h"
#include "gimpdrawableundo.h" #include "gimpdrawableundo.h"
#include "gimpimage.h" #include "gimpimage.h"
#include "gimpimage-undo.h" #include "gimpimage-undo.h"
@ -399,99 +400,62 @@ gimp_edit_clear (GimpImage *image,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context) GimpContext *context)
{ {
GimpRGB background; GimpFillOptions *options;
GimpLayerModeEffects paint_mode; gboolean success;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); 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_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (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 (GIMP_IS_CONTEXT (context), FALSE);
gimp_context_get_background (context, &background); options = gimp_fill_options_new (context->gimp);
if (gimp_drawable_has_alpha (drawable)) 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 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, success = gimp_edit_fill (image, drawable, options,
&background, NULL, C_("undo-type", "Clear"));
GIMP_OPACITY_OPAQUE, paint_mode,
C_("undo-type", "Clear")); g_object_unref (options);
return success;
} }
gboolean gboolean
gimp_edit_fill (GimpImage *image, gimp_edit_fill (GimpImage *image,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpFillOptions *options,
GimpFillType fill_type, const gchar *undo_desc)
gdouble opacity,
GimpLayerModeEffects paint_mode,
GError **error)
{ {
GeglBuffer *dest_buffer;
GimpPattern *pattern = NULL;
GimpRGB color; GimpRGB color;
GimpPattern *pattern; const Babl *format;
const gchar *undo_desc = NULL; gint x, y, width, height;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); 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_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (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 (GIMP_IS_FILL_OPTIONS (options), 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);
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height)) if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
return TRUE; /* nothing to do, but the fill succeeded */ 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 && if (pattern &&
babl_format_has_alpha (gimp_temp_buf_get_format (pattern->mask)) && babl_format_has_alpha (gimp_temp_buf_get_format (pattern->mask)) &&
! gimp_drawable_has_alpha (drawable)) ! gimp_drawable_has_alpha (drawable))
@ -515,16 +479,20 @@ gimp_edit_fill_full (GimpImage *image,
} }
else 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); gegl_buffer_set_color (dest_buffer, NULL, gegl_color);
g_object_unref (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, gimp_drawable_apply_buffer (drawable, dest_buffer,
GEGL_RECTANGLE (0, 0, width, height), GEGL_RECTANGLE (0, 0, width, height),
TRUE, undo_desc, TRUE, undo_desc,
opacity, paint_mode, gimp_context_get_opacity (GIMP_CONTEXT (options)),
gimp_context_get_paint_mode (GIMP_CONTEXT (options)),
NULL, x, y); NULL, x, y);
g_object_unref (dest_buffer); g_object_unref (dest_buffer);

View File

@ -19,62 +19,51 @@
#define __GIMP_EDIT_H__ #define __GIMP_EDIT_H__
const GimpBuffer * gimp_edit_cut (GimpImage *image, const GimpBuffer * gimp_edit_cut (GimpImage *image,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GError **error); GError **error);
const GimpBuffer * gimp_edit_copy (GimpImage *image, const GimpBuffer * gimp_edit_copy (GimpImage *image,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GError **error); GError **error);
const GimpBuffer * gimp_edit_copy_visible (GimpImage *image, const GimpBuffer * gimp_edit_copy_visible (GimpImage *image,
GimpContext *context, GimpContext *context,
GError **error); GError **error);
GimpLayer * gimp_edit_paste (GimpImage *image, GimpLayer * gimp_edit_paste (GimpImage *image,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpBuffer *paste, GimpBuffer *paste,
gboolean paste_into, gboolean paste_into,
gint viewport_x, gint viewport_x,
gint viewport_y, gint viewport_y,
gint viewport_width, gint viewport_width,
gint viewport_height); gint viewport_height);
const gchar * gimp_edit_named_cut (GimpImage *image, const gchar * gimp_edit_named_cut (GimpImage *image,
const gchar *name, const gchar *name,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GError **error); GError **error);
const gchar * gimp_edit_named_copy (GimpImage *image, const gchar * gimp_edit_named_copy (GimpImage *image,
const gchar *name, const gchar *name,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GError **error); GError **error);
const gchar * gimp_edit_named_copy_visible (GimpImage *image, const gchar * gimp_edit_named_copy_visible (GimpImage *image,
const gchar *name, const gchar *name,
GimpContext *context, GimpContext *context,
GError **error); GError **error);
gboolean gimp_edit_clear (GimpImage *image, gboolean gimp_edit_clear (GimpImage *image,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context); GimpContext *context);
gboolean gimp_edit_fill (GimpImage *image, gboolean gimp_edit_fill (GimpImage *image,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpFillOptions *options,
GimpFillType fill_type, const gchar *undo_desc);
gdouble opacity,
GimpLayerModeEffects paint_mode,
GError **error);
gboolean gimp_edit_fill_full (GimpImage *image, gboolean gimp_edit_fade (GimpImage *image,
GimpDrawable *drawable, GimpContext *context);
const GimpRGB *color,
GimpPattern *pattern,
gdouble opacity,
GimpLayerModeEffects paint_mode,
const gchar *undo_desc);
gboolean gimp_edit_fade (GimpImage *image,
GimpContext *context);
#endif /* __GIMP_EDIT_H__ */ #endif /* __GIMP_EDIT_H__ */

View File

@ -32,6 +32,7 @@
#include "core/gimpbuffer.h" #include "core/gimpbuffer.h"
#include "core/gimpcontainer.h" #include "core/gimpcontainer.h"
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpfilloptions.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimage-merge.h" #include "core/gimpimage-merge.h"
#include "core/gimpimage-new.h" #include "core/gimpimage-new.h"
@ -382,12 +383,24 @@ gimp_display_shell_dnd_fill (GimpDisplayShell *shell,
} }
else else
{ {
gimp_edit_fill_full (image, drawable, GimpFillOptions *options = gimp_fill_options_new (image->gimp);
color, pattern,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, if (color)
pattern ? {
C_("undo-type", "Drop pattern to layer") : gimp_context_set_foreground (GIMP_CONTEXT (options), color);
C_("undo-type", "Drop color to layer")); }
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); 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_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), 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, success = gimp_fill_options_set_by_fill_type (options, context,
(GimpFillType) fill_type, fill_type, error);
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
error); if (success)
success = gimp_edit_fill (image, drawable, options, NULL);
g_object_unref (options);
} }
else else
success = FALSE; success = FALSE;
@ -601,36 +605,48 @@ edit_bucket_fill_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) && GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), 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));
GimpFillType fill_type;
if (paint_mode == GIMP_OVERLAY_MODE) if (paint_mode == GIMP_OVERLAY_MODE)
paint_mode = GIMP_SOFTLIGHT_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))) if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{ {
success = gimp_edit_fill (image, drawable, context, fill_type, GimpFillOptions *options = gimp_fill_options_new (gimp);
opacity / 100.0, paint_mode,
error); 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 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, success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0, paint_mode, opacity / 100.0,
FALSE /* don't fill transparent */, FALSE /* don't fill transparent */,
@ -687,37 +703,49 @@ edit_bucket_fill_full_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) && GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), 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));
GimpFillType fill_type;
if (paint_mode == GIMP_OVERLAY_MODE) if (paint_mode == GIMP_OVERLAY_MODE)
paint_mode = GIMP_SOFTLIGHT_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))) if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{ {
success = gimp_edit_fill (image, drawable, context, fill_type, GimpFillOptions *options = gimp_fill_options_new (gimp);
opacity / 100.0, paint_mode,
error); 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 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, paint_mode, opacity / 100.0,
fill_transparent, fill_transparent,
select_criterion, select_criterion,

View File

@ -28,6 +28,7 @@
#include "core/gimp-edit.h" #include "core/gimp-edit.h"
#include "core/gimpdrawable-bucket-fill.h" #include "core/gimpdrawable-bucket-fill.h"
#include "core/gimperror.h" #include "core/gimperror.h"
#include "core/gimpfilloptions.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpitem.h" #include "core/gimpitem.h"
#include "core/gimppickable.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); GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpContext *context = GIMP_CONTEXT (options); GimpContext *context = GIMP_CONTEXT (options);
GimpFillType fill_type;
gint x, y;
gboolean success; gboolean success;
GError *error = NULL; 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) if (options->fill_selection)
{ {
success = gimp_edit_fill (image, drawable, context, fill_type, GimpFillOptions *fill_options = gimp_fill_options_new (image->gimp);
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context), success = gimp_fill_options_set_by_fill_mode (fill_options, context,
&error); 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 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, success = gimp_drawable_bucket_fill (drawable, context, fill_type,
gimp_context_get_paint_mode (context), gimp_context_get_paint_mode (context),
gimp_context_get_opacity (context), gimp_context_get_opacity (context),

View File

@ -31,6 +31,7 @@
#include "core/gimp-edit.h" #include "core/gimp-edit.h"
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpfilloptions.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimage-undo.h" #include "core/gimpimage-undo.h"
#include "core/gimppattern.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)) if (dest_viewable && GIMP_IS_PATTERN (src_viewable))
{ {
gimp_edit_fill_full (gimp_item_get_image (GIMP_ITEM (dest_viewable)), GimpImage *image = gimp_item_get_image (GIMP_ITEM (dest_viewable));
GIMP_DRAWABLE (dest_viewable), GimpFillOptions *options = gimp_fill_options_new (image->gimp);
NULL, GIMP_PATTERN (src_viewable),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
C_("undo-type", "Drop pattern to layer"));
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; return;
} }
@ -259,13 +267,18 @@ gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
{ {
if (dest_viewable) if (dest_viewable)
{ {
gimp_edit_fill_full (gimp_item_get_image (GIMP_ITEM (dest_viewable)), GimpImage *image = gimp_item_get_image (GIMP_ITEM (dest_viewable));
GIMP_DRAWABLE (dest_viewable), GimpFillOptions *options = gimp_fill_options_new (image->gimp);
color, NULL,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
C_("undo-type", "Drop color to layer"));
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 static void
gimp_drawable_tree_view_new_dropped (GimpItemTreeView *view, gimp_drawable_tree_view_new_dropped (GimpItemTreeView *view,
gint x, gint x,
gint y, gint y,
const GimpRGB *color, const GimpRGB *color,
GimpPattern *pattern) GimpPattern *pattern)
{ {
GimpItem *item; 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")); _("New Layer"));
item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->new_item (gimp_item_tree_view_get_image (view)); item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->new_item (gimp_item_tree_view_get_image (view));
if (item) if (item)
{ {
gimp_edit_fill_full (gimp_item_get_image (item), GimpImage *image = gimp_item_get_image (item);
GIMP_DRAWABLE (item), GimpFillOptions *options = gimp_fill_options_new (image->gimp);
color, pattern,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, if (color)
pattern ? {
C_("undo-type", "Drop pattern to layer") : gimp_context_set_foreground (GIMP_CONTEXT (options), color);
C_("undo-type", "Drop color to layer")); }
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)); 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_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), 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, success = gimp_fill_options_set_by_fill_type (options, context,
(GimpFillType) fill_type, fill_type, error);
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
error); if (success)
success = gimp_edit_fill (image, drawable, options, NULL);
g_object_unref (options);
} }
else else
success = FALSE; success = FALSE;
@ -637,36 +641,48 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) && GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), 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));
GimpFillType fill_type;
if (paint_mode == GIMP_OVERLAY_MODE) if (paint_mode == GIMP_OVERLAY_MODE)
paint_mode = GIMP_SOFTLIGHT_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))) if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{ {
success = gimp_edit_fill (image, drawable, context, fill_type, GimpFillOptions *options = gimp_fill_options_new (gimp);
opacity / 100.0, paint_mode,
error); 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 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, success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0, paint_mode, opacity / 100.0,
FALSE /* don't fill transparent */, FALSE /* don't fill transparent */,
@ -751,37 +767,49 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) && GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), 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));
GimpFillType fill_type;
if (paint_mode == GIMP_OVERLAY_MODE) if (paint_mode == GIMP_OVERLAY_MODE)
paint_mode = GIMP_SOFTLIGHT_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))) if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{ {
success = gimp_edit_fill (image, drawable, context, fill_type, GimpFillOptions *options = gimp_fill_options_new (gimp);
opacity / 100.0, paint_mode,
error); 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 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, paint_mode, opacity / 100.0,
fill_transparent, fill_transparent,
select_criterion, select_criterion,