[gimp] app: drop a color or a buffer multi-layer aware.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: drop a color or a buffer multi-layer aware.
- Date: Sat, 1 Aug 2020 17:24:49 +0000 (UTC)
commit 67b757f55ac3231dc3f8671dc3a93cf8a723b368
Author: Jehan <jehan girinstud io>
Date: Sat Aug 1 19:14:21 2020 +0200
app: drop a color or a buffer multi-layer aware.
When dropping a color, we fill all the selected layers with this color.
When dropping a buffer, multi-layer is same as no layers selected (i.e.
we paste once as a new layer, not multiple times).
app/display/gimpdisplayshell-dnd.c | 80 ++++++++++++++++++++++----------------
1 file changed, 47 insertions(+), 33 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c
index 20651202a0..d3a0612d47 100644
--- a/app/display/gimpdisplayshell-dnd.c
+++ b/app/display/gimpdisplayshell-dnd.c
@@ -343,7 +343,8 @@ gimp_display_shell_dnd_fill (GimpDisplayShell *shell,
const gchar *undo_desc)
{
GimpImage *image = gimp_display_get_image (shell->display);
- GimpDrawable *drawable;
+ GList *drawables;
+ GList *iter;
if (shell->display->gimp->busy)
return;
@@ -351,46 +352,55 @@ gimp_display_shell_dnd_fill (GimpDisplayShell *shell,
if (! image)
return;
- drawable = gimp_image_get_active_drawable (image);
+ drawables = gimp_image_get_selected_drawables (image);
- if (! drawable)
+ if (! drawables)
return;
- if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
+ for (iter = drawables; iter; iter = iter->next)
{
- gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display),
- GIMP_MESSAGE_ERROR,
- _("Cannot modify the pixels of layer groups."));
- return;
- }
+ if (gimp_viewable_get_children (iter->data))
+ {
+ gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display),
+ GIMP_MESSAGE_ERROR,
+ _("Cannot modify the pixels of layer groups."));
+ return;
+ }
- if (gimp_item_is_content_locked (GIMP_ITEM (drawable)))
- {
- gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display),
- GIMP_MESSAGE_ERROR,
- _("The active layer's pixels are locked."));
- return;
+ if (gimp_item_is_content_locked (iter->data))
+ {
+ gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display),
+ GIMP_MESSAGE_ERROR,
+ _("A selected layer's pixels are locked."));
+ return;
+ }
}
- /* FIXME: there should be a virtual method for this that the
- * GimpTextLayer can override.
- */
- if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_SOLID &&
- gimp_item_is_text_layer (GIMP_ITEM (drawable)))
+ gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT, undo_desc);
+
+ for (iter = drawables; iter; iter = iter->next)
{
- GimpRGB color;
+ /* FIXME: there should be a virtual method for this that the
+ * GimpTextLayer can override.
+ */
+ if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_SOLID &&
+ gimp_item_is_text_layer (iter->data))
+ {
+ GimpRGB color;
- gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
+ gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
- gimp_text_layer_set (GIMP_TEXT_LAYER (drawable), NULL,
- "color", &color,
- NULL);
- }
- else
- {
- gimp_drawable_edit_fill (drawable, options, undo_desc);
+ gimp_text_layer_set (iter->data, NULL,
+ "color", &color,
+ NULL);
+ }
+ else
+ {
+ gimp_drawable_edit_fill (iter->data, options, undo_desc);
+ }
}
+ gimp_image_undo_group_end (image);
gimp_display_shell_dnd_flush (shell, image);
}
@@ -445,9 +455,10 @@ gimp_display_shell_drop_buffer (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
- GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
- GimpImage *image = gimp_display_get_image (shell->display);
- GimpDrawable *drawable;
+ GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
+ GimpImage *image = gimp_display_get_image (shell->display);
+ GimpDrawable *drawable = NULL;
+ GList *drawables;
GimpBuffer *buffer;
GimpPasteType paste_type;
gint x, y, width, height;
@@ -470,7 +481,10 @@ gimp_display_shell_drop_buffer (GtkWidget *widget,
paste_type = GIMP_PASTE_TYPE_FLOATING;
- drawable = gimp_image_get_active_drawable (image);
+ drawables = gimp_image_get_selected_drawables (image);
+ if (g_list_length (drawables) == 1)
+ drawable = drawables->data;
+ g_list_free (drawables);
if (drawable)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]