2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-11-08 19:14:51 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-11-08 19:14:51 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-11-08 19:14:51 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-11-08 19:14:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2004-12-24 19:11:30 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2001-11-08 19:14:51 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-01-15 17:17:33 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2015-05-06 22:15:30 +02:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2005-01-15 17:17:33 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
#include "display-types.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2003-09-15 17:26:28 +00:00
|
|
|
#include "core/gimp-edit.h"
|
2001-11-08 19:14:51 +00:00
|
|
|
#include "core/gimpbuffer.h"
|
2018-04-18 23:44:34 +02:00
|
|
|
#include "core/gimpdrawable-edit.h"
|
2016-03-11 19:52:36 +01:00
|
|
|
#include "core/gimpfilloptions.h"
|
2001-11-08 19:14:51 +00:00
|
|
|
#include "core/gimpimage.h"
|
2010-02-08 14:47:45 +01:00
|
|
|
#include "core/gimpimage-new.h"
|
2003-02-13 11:23:50 +00:00
|
|
|
#include "core/gimpimage-undo.h"
|
2001-11-08 19:14:51 +00:00
|
|
|
#include "core/gimplayer.h"
|
2015-06-17 13:21:01 +02:00
|
|
|
#include "core/gimplayer-new.h"
|
2005-01-15 19:31:09 +00:00
|
|
|
#include "core/gimplayermask.h"
|
2001-11-08 19:14:51 +00:00
|
|
|
#include "core/gimppattern.h"
|
2004-08-10 18:47:21 +00:00
|
|
|
#include "core/gimpprogress.h"
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2004-06-01 23:14:28 +00:00
|
|
|
#include "file/file-open.h"
|
|
|
|
|
2004-02-11 21:42:22 +00:00
|
|
|
#include "text/gimptext.h"
|
|
|
|
#include "text/gimptextlayer.h"
|
|
|
|
|
2024-07-12 06:16:25 +00:00
|
|
|
#include "vectors/gimppath.h"
|
2024-07-13 05:07:57 +00:00
|
|
|
#include "vectors/gimppath-import.h"
|
2003-05-18 14:47:07 +00:00
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
#include "widgets/gimpdnd.h"
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
#include "gimpdisplay.h"
|
|
|
|
#include "gimpdisplayshell.h"
|
|
|
|
#include "gimpdisplayshell-dnd.h"
|
2004-01-15 14:36:43 +00:00
|
|
|
#include "gimpdisplayshell-transform.h"
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
#include "gimp-log.h"
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2004-06-29 13:34:16 +00:00
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void gimp_display_shell_drop_drawable (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
2024-07-11 00:07:44 +00:00
|
|
|
static void gimp_display_shell_drop_path (GtkWidget *widget,
|
2005-01-15 19:31:09 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_display_shell_drop_svg (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
const guchar *svg_data,
|
|
|
|
gsize svg_data_length,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_display_shell_drop_pattern (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_display_shell_drop_color (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
2023-12-24 20:27:23 +09:00
|
|
|
GeglColor *color,
|
2005-01-15 19:31:09 +00:00
|
|
|
gpointer data);
|
|
|
|
static void gimp_display_shell_drop_buffer (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_display_shell_drop_uri_list (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GList *uri_list,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_display_shell_drop_component (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpChannelType component,
|
|
|
|
gpointer data);
|
2005-04-09 17:56:04 +00:00
|
|
|
static void gimp_display_shell_drop_pixbuf (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GdkPixbuf *pixbuf,
|
|
|
|
gpointer data);
|
2005-01-15 19:31:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
void
|
2005-01-15 19:31:09 +00:00
|
|
|
gimp_display_shell_dnd_init (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2008-03-19 22:18:54 +00:00
|
|
|
gimp_dnd_viewable_dest_add (shell->canvas, GIMP_TYPE_LAYER,
|
2005-01-15 19:31:09 +00:00
|
|
|
gimp_display_shell_drop_drawable,
|
|
|
|
shell);
|
2008-03-19 22:18:54 +00:00
|
|
|
gimp_dnd_viewable_dest_add (shell->canvas, GIMP_TYPE_LAYER_MASK,
|
2005-01-15 19:31:09 +00:00
|
|
|
gimp_display_shell_drop_drawable,
|
|
|
|
shell);
|
2008-03-19 22:18:54 +00:00
|
|
|
gimp_dnd_viewable_dest_add (shell->canvas, GIMP_TYPE_CHANNEL,
|
2005-01-15 19:31:09 +00:00
|
|
|
gimp_display_shell_drop_drawable,
|
|
|
|
shell);
|
2024-07-12 06:16:25 +00:00
|
|
|
gimp_dnd_viewable_dest_add (shell->canvas, GIMP_TYPE_PATH,
|
2024-07-11 00:07:44 +00:00
|
|
|
gimp_display_shell_drop_path,
|
2005-01-15 19:31:09 +00:00
|
|
|
shell);
|
2008-03-19 22:18:54 +00:00
|
|
|
gimp_dnd_viewable_dest_add (shell->canvas, GIMP_TYPE_PATTERN,
|
2005-01-15 19:31:09 +00:00
|
|
|
gimp_display_shell_drop_pattern,
|
|
|
|
shell);
|
2008-03-19 22:18:54 +00:00
|
|
|
gimp_dnd_viewable_dest_add (shell->canvas, GIMP_TYPE_BUFFER,
|
2005-01-15 19:31:09 +00:00
|
|
|
gimp_display_shell_drop_buffer,
|
|
|
|
shell);
|
2008-03-19 22:18:54 +00:00
|
|
|
gimp_dnd_color_dest_add (shell->canvas,
|
2005-01-15 19:31:09 +00:00
|
|
|
gimp_display_shell_drop_color,
|
|
|
|
shell);
|
2008-03-19 22:18:54 +00:00
|
|
|
gimp_dnd_component_dest_add (shell->canvas,
|
2005-01-15 19:31:09 +00:00
|
|
|
gimp_display_shell_drop_component,
|
|
|
|
shell);
|
2010-11-29 22:04:56 +01:00
|
|
|
gimp_dnd_uri_list_dest_add (shell->canvas,
|
|
|
|
gimp_display_shell_drop_uri_list,
|
|
|
|
shell);
|
2013-01-09 00:28:30 +01:00
|
|
|
gimp_dnd_svg_dest_add (shell->canvas,
|
|
|
|
gimp_display_shell_drop_svg,
|
|
|
|
shell);
|
|
|
|
gimp_dnd_pixbuf_dest_add (shell->canvas,
|
|
|
|
gimp_display_shell_drop_pixbuf,
|
|
|
|
shell);
|
2005-01-15 19:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2008-09-25 15:41:57 +00:00
|
|
|
/*
|
|
|
|
* Position the dropped item in the middle of the viewport.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
gimp_display_shell_dnd_position_item (GimpDisplayShell *shell,
|
2012-07-30 16:20:11 +02:00
|
|
|
GimpImage *image,
|
2008-09-25 15:41:57 +00:00
|
|
|
GimpItem *item)
|
|
|
|
{
|
2012-07-30 16:20:11 +02:00
|
|
|
gint item_width = gimp_item_get_width (item);
|
|
|
|
gint item_height = gimp_item_get_height (item);
|
2012-09-05 13:03:47 +02:00
|
|
|
gint off_x, off_y;
|
2008-09-25 15:41:57 +00:00
|
|
|
|
2012-07-30 16:20:11 +02:00
|
|
|
if (item_width >= gimp_image_get_width (image) &&
|
|
|
|
item_height >= gimp_image_get_height (image))
|
|
|
|
{
|
2012-09-05 13:03:47 +02:00
|
|
|
off_x = (gimp_image_get_width (image) - item_width) / 2;
|
|
|
|
off_y = (gimp_image_get_height (image) - item_height) / 2;
|
2012-07-30 16:20:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint x, y;
|
|
|
|
gint width, height;
|
2008-09-25 15:41:57 +00:00
|
|
|
|
2019-09-15 16:25:20 +03:00
|
|
|
gimp_display_shell_untransform_viewport (
|
|
|
|
shell,
|
|
|
|
! gimp_display_shell_get_infinite_canvas (shell),
|
|
|
|
&x, &y, &width, &height);
|
2008-09-25 15:41:57 +00:00
|
|
|
|
2012-09-05 13:03:47 +02:00
|
|
|
off_x = x + (width - item_width) / 2;
|
|
|
|
off_y = y + (height - item_height) / 2;
|
2012-07-30 16:20:11 +02:00
|
|
|
}
|
2012-09-05 13:03:47 +02:00
|
|
|
|
|
|
|
gimp_item_translate (item,
|
|
|
|
off_x - gimp_item_get_offset_x (item),
|
|
|
|
off_y - gimp_item_get_offset_y (item),
|
|
|
|
FALSE);
|
2008-09-25 15:41:57 +00:00
|
|
|
}
|
2007-07-26 10:52:39 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_dnd_flush (GimpDisplayShell *shell,
|
|
|
|
GimpImage *image)
|
|
|
|
{
|
2009-10-04 19:27:58 +02:00
|
|
|
gimp_display_shell_present (shell);
|
2007-07-26 10:52:39 +00:00
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
2008-03-18 21:22:21 +00:00
|
|
|
gimp_context_set_display (gimp_get_user_context (shell->display->gimp),
|
2007-07-26 10:52:39 +00:00
|
|
|
shell->display);
|
|
|
|
}
|
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
static void
|
2001-11-08 19:14:51 +00:00
|
|
|
gimp_display_shell_drop_drawable (GtkWidget *widget,
|
2004-12-31 14:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2001-11-08 19:14:51 +00:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2008-09-04 18:14:56 +00:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
2009-10-06 19:20:44 +02:00
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
2004-01-15 14:36:43 +00:00
|
|
|
GType new_type;
|
|
|
|
GimpItem *new_item;
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
GIMP_LOG (DND, NULL);
|
2004-06-29 13:34:16 +00:00
|
|
|
|
2008-03-18 21:22:21 +00:00
|
|
|
if (shell->display->gimp->busy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! image)
|
2008-09-04 15:45:23 +00:00
|
|
|
{
|
2010-02-08 14:47:45 +01:00
|
|
|
image = gimp_image_new_from_drawable (shell->display->gimp,
|
|
|
|
GIMP_DRAWABLE (viewable));
|
2014-05-02 20:20:46 +02:00
|
|
|
gimp_create_display (shell->display->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
2018-04-29 17:27:47 +02:00
|
|
|
G_OBJECT (gimp_widget_get_monitor (widget)));
|
2008-09-04 18:14:56 +00:00
|
|
|
g_object_unref (image);
|
|
|
|
|
2010-02-08 14:47:45 +01:00
|
|
|
return;
|
2008-09-04 15:45:23 +00:00
|
|
|
}
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2003-08-27 17:21:49 +00:00
|
|
|
if (GIMP_IS_LAYER (viewable))
|
|
|
|
new_type = G_TYPE_FROM_INSTANCE (viewable);
|
|
|
|
else
|
|
|
|
new_type = GIMP_TYPE_LAYER;
|
|
|
|
|
2008-01-08 11:46:15 +00:00
|
|
|
new_item = gimp_item_convert (GIMP_ITEM (viewable), image, new_type);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2003-08-27 17:21:49 +00:00
|
|
|
if (new_item)
|
|
|
|
{
|
2008-09-04 18:14:56 +00:00
|
|
|
GimpLayer *new_layer = GIMP_LAYER (new_item);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE,
|
2003-08-27 17:21:49 +00:00
|
|
|
_("Drop New Layer"));
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2012-07-30 16:20:11 +02:00
|
|
|
gimp_display_shell_dnd_position_item (shell, image, new_item);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2007-05-28 23:44:38 +00:00
|
|
|
gimp_item_set_visible (new_item, TRUE, FALSE);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2009-08-03 22:30:36 +02:00
|
|
|
gimp_image_add_layer (image, new_layer,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_undo_group_end (image);
|
2003-08-27 17:21:49 +00:00
|
|
|
|
2007-07-26 10:52:39 +00:00
|
|
|
gimp_display_shell_dnd_flush (shell, image);
|
2003-08-27 17:21:49 +00:00
|
|
|
}
|
2001-11-08 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
static void
|
2024-07-11 00:07:44 +00:00
|
|
|
gimp_display_shell_drop_path (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
2003-05-18 14:47:07 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
2009-10-06 19:20:44 +02:00
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
2004-01-27 11:30:54 +00:00
|
|
|
GimpItem *new_item;
|
2003-05-18 14:47:07 +00:00
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
GIMP_LOG (DND, NULL);
|
2004-06-29 13:34:16 +00:00
|
|
|
|
2008-03-18 21:22:21 +00:00
|
|
|
if (shell->display->gimp->busy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! image)
|
2003-05-18 14:47:07 +00:00
|
|
|
return;
|
|
|
|
|
2008-01-08 11:46:15 +00:00
|
|
|
new_item = gimp_item_convert (GIMP_ITEM (viewable),
|
|
|
|
image, G_TYPE_FROM_INSTANCE (viewable));
|
2003-05-18 14:47:07 +00:00
|
|
|
|
2003-08-27 17:21:49 +00:00
|
|
|
if (new_item)
|
|
|
|
{
|
2024-07-12 06:16:25 +00:00
|
|
|
GimpPath *new_path = GIMP_PATH (new_item);
|
2003-05-18 14:47:07 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE,
|
2003-08-27 17:21:49 +00:00
|
|
|
_("Drop New Path"));
|
2003-05-18 14:47:07 +00:00
|
|
|
|
2024-07-11 00:07:44 +00:00
|
|
|
gimp_image_add_path (image, new_path,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
2003-05-18 14:47:07 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_undo_group_end (image);
|
2003-05-18 14:47:07 +00:00
|
|
|
|
2007-07-26 10:52:39 +00:00
|
|
|
gimp_display_shell_dnd_flush (shell, image);
|
2003-08-27 17:21:49 +00:00
|
|
|
}
|
2003-05-18 14:47:07 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
static void
|
2003-12-21 22:09:03 +00:00
|
|
|
gimp_display_shell_drop_svg (GtkWidget *widget,
|
2004-12-31 14:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-07-02 14:08:15 +00:00
|
|
|
const guchar *svg_data,
|
2004-06-30 11:57:17 +00:00
|
|
|
gsize svg_data_len,
|
2003-12-21 22:09:03 +00:00
|
|
|
gpointer data)
|
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
2009-10-06 19:20:44 +02:00
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
2004-01-27 11:30:54 +00:00
|
|
|
GError *error = NULL;
|
2003-12-21 22:09:03 +00:00
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
GIMP_LOG (DND, NULL);
|
2004-06-29 13:34:16 +00:00
|
|
|
|
2008-03-18 21:22:21 +00:00
|
|
|
if (shell->display->gimp->busy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! image)
|
2003-12-21 22:09:03 +00:00
|
|
|
return;
|
|
|
|
|
2024-07-13 05:07:57 +00:00
|
|
|
if (! gimp_path_import_buffer (image,
|
|
|
|
(const gchar *) svg_data, svg_data_len,
|
|
|
|
TRUE, FALSE,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1,
|
|
|
|
NULL, &error))
|
2003-12-21 22:09:03 +00:00
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display),
|
2013-09-15 04:59:20 +12:00
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
error->message);
|
2003-12-21 22:09:03 +00:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-26 10:52:39 +00:00
|
|
|
gimp_display_shell_dnd_flush (shell, image);
|
2003-12-21 22:09:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
static void
|
2014-04-29 00:25:02 +02:00
|
|
|
gimp_display_shell_dnd_fill (GimpDisplayShell *shell,
|
2016-03-14 00:29:35 +01:00
|
|
|
GimpFillOptions *options,
|
|
|
|
const gchar *undo_desc)
|
2001-11-08 19:14:51 +00:00
|
|
|
{
|
2009-10-06 19:20:44 +02:00
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
2020-08-01 19:14:21 +02:00
|
|
|
GList *drawables;
|
|
|
|
GList *iter;
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2008-03-18 21:22:21 +00:00
|
|
|
if (shell->display->gimp->busy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! image)
|
2001-11-08 19:14:51 +00:00
|
|
|
return;
|
|
|
|
|
2020-08-01 19:14:21 +02:00
|
|
|
drawables = gimp_image_get_selected_drawables (image);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2020-08-01 19:14:21 +02:00
|
|
|
if (! drawables)
|
2001-11-08 19:14:51 +00:00
|
|
|
return;
|
|
|
|
|
2020-08-01 19:14:21 +02:00
|
|
|
for (iter = drawables; iter; iter = iter->next)
|
2009-08-29 12:27:57 +02:00
|
|
|
{
|
2020-08-01 19:14:21 +02:00
|
|
|
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."));
|
2021-08-16 20:22:44 +02:00
|
|
|
g_list_free (drawables);
|
2020-08-01 19:14:21 +02:00
|
|
|
return;
|
|
|
|
}
|
2009-08-29 12:27:57 +02:00
|
|
|
|
2022-02-15 15:42:44 +01:00
|
|
|
if (gimp_item_is_content_locked (iter->data, NULL))
|
2020-08-01 19:14:21 +02:00
|
|
|
{
|
|
|
|
gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display),
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
_("A selected layer's pixels are locked."));
|
2021-08-16 20:22:44 +02:00
|
|
|
g_list_free (drawables);
|
2020-08-01 19:14:21 +02:00
|
|
|
return;
|
|
|
|
}
|
2009-08-21 13:50:07 +02:00
|
|
|
}
|
|
|
|
|
2020-08-01 19:14:21 +02:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT, undo_desc);
|
|
|
|
|
|
|
|
for (iter = drawables; iter; iter = iter->next)
|
2004-02-11 21:42:22 +00:00
|
|
|
{
|
2020-08-01 19:14:21 +02:00
|
|
|
/* FIXME: there should be a virtual method for this that the
|
|
|
|
* GimpTextLayer can override.
|
|
|
|
*/
|
2022-08-07 11:47:30 +00:00
|
|
|
if (gimp_item_is_text_layer (iter->data) &&
|
|
|
|
(gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR ||
|
|
|
|
gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_BG_COLOR))
|
2020-08-01 19:14:21 +02:00
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color;
|
2016-03-14 00:29:35 +01:00
|
|
|
|
2022-08-07 11:47:30 +00:00
|
|
|
if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR)
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_foreground (GIMP_CONTEXT (options));
|
2022-08-07 11:47:30 +00:00
|
|
|
else
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_background (GIMP_CONTEXT (options));
|
|
|
|
|
2020-08-01 19:14:21 +02:00
|
|
|
gimp_text_layer_set (iter->data, NULL,
|
app, libgimp, pdb, plug-ins: GimpText* using GeglColor.
One of the big improvement in this commit is that text layers are now much
better at space accuracy. They were already space-aware, yet rendered as sRGB u8
only before being converted to the image's space. It means that text layers had
the following limitations:
* Any color out of sRGB gamut were trimmed.
* Precision was always 8-bit (even if the image was high-bit depth).
Now GimpTextLayout keeps track of its source space (for RGB and CMYK only, this
won't be as easy when we will support more backend, since Cairo has only RGB
support for image data) and the image TRC (in case it bypasses the color space's
TRB) and it draws within this gamut and space.
It means first that we are not limited to sRGB colors; we will draw text main
color in the full image gamut, with still 2 remaining limitations:
* Unbounded colors are impossible because Pango format (to color text) uses
hexadecimal (so even with half/float images, you can't draw out-of-gamut text
unfortunately).
* Main color precision is still 8-bit, yet a tiny bit better than before as we
at least follow TRC (so we avoid some of the precision loss when converting,
even though the bit-depth is still the biggest loss).
The outline color on the other hand is drawn through Cairo API entirely, in
float. This means that the outline color will now be without any precision loss.
Note that this depends on CAIRO_FORMAT_RGBA128F which is only available since
Cairo 1.17.2 which is not in Debian bookworm (our current baseline for GIMP
3.0). It means that the old precision will still happen with older Cairo
version, as determined by #if code at compilation.
2023-11-17 22:36:31 +01:00
|
|
|
"color", color,
|
2020-08-01 19:14:21 +02:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_drawable_edit_fill (iter->data, options, undo_desc);
|
|
|
|
}
|
2004-02-11 21:42:22 +00:00
|
|
|
}
|
2004-01-27 11:30:54 +00:00
|
|
|
|
2021-08-16 20:22:44 +02:00
|
|
|
g_list_free (drawables);
|
2020-08-01 19:14:21 +02:00
|
|
|
gimp_image_undo_group_end (image);
|
2007-07-26 10:52:39 +00:00
|
|
|
gimp_display_shell_dnd_flush (shell, image);
|
2001-11-08 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
static void
|
2001-11-08 19:14:51 +00:00
|
|
|
gimp_display_shell_drop_pattern (GtkWidget *widget,
|
2004-12-31 14:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2001-11-08 19:14:51 +00:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2016-03-14 00:29:35 +01:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
2016-03-15 20:10:16 +01:00
|
|
|
GimpFillOptions *options = gimp_fill_options_new (shell->display->gimp,
|
|
|
|
NULL, FALSE);
|
2016-03-14 00:29:35 +01:00
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
GIMP_LOG (DND, NULL);
|
2004-06-29 13:34:16 +00:00
|
|
|
|
2016-03-14 00:29:35 +01:00
|
|
|
gimp_fill_options_set_style (options, GIMP_FILL_STYLE_PATTERN);
|
|
|
|
gimp_context_set_pattern (GIMP_CONTEXT (options), GIMP_PATTERN (viewable));
|
|
|
|
|
|
|
|
gimp_display_shell_dnd_fill (shell, options,
|
|
|
|
C_("undo-type", "Drop pattern to layer"));
|
|
|
|
|
|
|
|
g_object_unref (options);
|
2001-11-08 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
static void
|
2001-11-08 19:14:51 +00:00
|
|
|
gimp_display_shell_drop_color (GtkWidget *widget,
|
2004-12-31 14:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2023-12-24 20:27:23 +09:00
|
|
|
GeglColor *color,
|
2001-11-08 19:14:51 +00:00
|
|
|
gpointer data)
|
|
|
|
{
|
2016-03-14 00:29:35 +01:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
2016-03-15 20:10:16 +01:00
|
|
|
GimpFillOptions *options = gimp_fill_options_new (shell->display->gimp,
|
|
|
|
NULL, FALSE);
|
2016-03-14 00:29:35 +01:00
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
GIMP_LOG (DND, NULL);
|
2004-06-29 13:34:16 +00:00
|
|
|
|
2022-08-07 11:47:30 +00:00
|
|
|
gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
|
2016-03-14 00:29:35 +01:00
|
|
|
gimp_context_set_foreground (GIMP_CONTEXT (options), color);
|
|
|
|
|
|
|
|
gimp_display_shell_dnd_fill (shell, options,
|
|
|
|
C_("undo-type", "Drop color to layer"));
|
|
|
|
|
|
|
|
g_object_unref (options);
|
2001-11-08 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
static void
|
2001-11-08 19:14:51 +00:00
|
|
|
gimp_display_shell_drop_buffer (GtkWidget *widget,
|
2004-12-31 14:36:30 +00:00
|
|
|
gint drop_x,
|
|
|
|
gint drop_y,
|
2001-11-08 19:14:51 +00:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2020-08-01 19:14:21 +02:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
2022-11-12 22:17:00 +01:00
|
|
|
GimpContext *context;
|
2020-08-01 19:14:21 +02:00
|
|
|
GList *drawables;
|
2004-01-15 14:36:43 +00:00
|
|
|
GimpBuffer *buffer;
|
2016-09-19 23:53:40 +02:00
|
|
|
GimpPasteType paste_type;
|
2004-01-15 14:36:43 +00:00
|
|
|
gint x, y, width, height;
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
GIMP_LOG (DND, NULL);
|
2004-06-29 13:34:16 +00:00
|
|
|
|
2008-03-18 21:22:21 +00:00
|
|
|
if (shell->display->gimp->busy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! image)
|
2011-04-28 01:59:38 +02:00
|
|
|
{
|
2017-05-01 18:36:33 +02:00
|
|
|
image = gimp_image_new_from_buffer (shell->display->gimp,
|
2011-04-28 01:59:38 +02:00
|
|
|
GIMP_BUFFER (viewable));
|
2014-05-02 20:20:46 +02:00
|
|
|
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
2018-04-29 17:27:47 +02:00
|
|
|
G_OBJECT (gimp_widget_get_monitor (widget)));
|
2011-04-28 01:59:38 +02:00
|
|
|
g_object_unref (image);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2022-11-12 19:07:47 +01:00
|
|
|
paste_type = GIMP_PASTE_TYPE_NEW_LAYER_OR_FLOATING;
|
|
|
|
drawables = gimp_image_get_selected_drawables (image);
|
2022-11-12 22:17:00 +01:00
|
|
|
context = gimp_get_user_context (shell->display->gimp);
|
|
|
|
buffer = GIMP_BUFFER (viewable);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2019-09-15 16:25:20 +03:00
|
|
|
gimp_display_shell_untransform_viewport (
|
|
|
|
shell,
|
|
|
|
! gimp_display_shell_get_infinite_canvas (shell),
|
|
|
|
&x, &y, &width, &height);
|
2004-01-15 14:36:43 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
/* FIXME: popup a menu for selecting "Paste Into" */
|
|
|
|
|
2022-11-12 19:07:47 +01:00
|
|
|
g_list_free (gimp_edit_paste (image, drawables, GIMP_OBJECT (buffer),
|
2022-11-12 22:17:00 +01:00
|
|
|
paste_type, context, FALSE,
|
|
|
|
x, y, width, height));
|
2004-01-15 14:36:43 +00:00
|
|
|
|
2022-11-12 19:07:47 +01:00
|
|
|
g_list_free (drawables);
|
2007-07-26 10:52:39 +00:00
|
|
|
gimp_display_shell_dnd_flush (shell, image);
|
2001-11-08 19:14:51 +00:00
|
|
|
}
|
2004-06-01 23:14:28 +00:00
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
static void
|
2004-06-30 14:47:23 +00:00
|
|
|
gimp_display_shell_drop_uri_list (GtkWidget *widget,
|
2004-12-31 14:36:30 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-06-30 14:47:23 +00:00
|
|
|
GList *uri_list,
|
|
|
|
gpointer data)
|
2004-06-01 23:14:28 +00:00
|
|
|
{
|
2007-07-26 10:52:39 +00:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
2011-06-10 18:06:02 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GimpContext *context;
|
2004-06-01 23:14:28 +00:00
|
|
|
GList *list;
|
2008-11-04 22:32:15 +00:00
|
|
|
gboolean open_as_layers;
|
2004-06-01 23:14:28 +00:00
|
|
|
|
2019-01-03 16:46:00 +01:00
|
|
|
/* If the app is already being torn down, shell->display might be
|
|
|
|
* NULL here. Play it safe.
|
|
|
|
*/
|
2011-06-10 18:06:02 +02:00
|
|
|
if (! shell->display)
|
2019-01-03 16:46:00 +01:00
|
|
|
return;
|
2011-06-10 18:06:02 +02:00
|
|
|
|
|
|
|
image = gimp_display_get_image (shell->display);
|
|
|
|
context = gimp_get_user_context (shell->display->gimp);
|
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
GIMP_LOG (DND, NULL);
|
2004-06-29 13:34:16 +00:00
|
|
|
|
2009-10-06 19:20:44 +02:00
|
|
|
open_as_layers = (image != NULL);
|
2008-11-04 22:32:15 +00:00
|
|
|
|
2019-01-03 16:46:00 +01:00
|
|
|
if (image)
|
|
|
|
g_object_ref (image);
|
|
|
|
|
2004-06-30 14:47:23 +00:00
|
|
|
for (list = uri_list; list; list = g_list_next (list))
|
2004-06-01 23:14:28 +00:00
|
|
|
{
|
2014-07-07 00:46:25 +02:00
|
|
|
GFile *file = g_file_new_for_uri (list->data);
|
2004-06-01 23:14:28 +00:00
|
|
|
GimpPDBStatusType status;
|
2004-06-02 17:35:55 +00:00
|
|
|
GError *error = NULL;
|
2008-03-18 21:22:21 +00:00
|
|
|
gboolean warn = FALSE;
|
2004-06-01 23:14:28 +00:00
|
|
|
|
2011-06-10 18:06:02 +02:00
|
|
|
if (! shell->display)
|
|
|
|
{
|
|
|
|
/* It seems as if GIMP is being torn down for quitting. Bail out. */
|
2014-07-07 00:46:25 +02:00
|
|
|
g_object_unref (file);
|
2019-01-03 16:46:00 +01:00
|
|
|
g_clear_object (&image);
|
2011-06-10 18:06:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-04 22:32:15 +00:00
|
|
|
if (open_as_layers)
|
2008-03-18 21:22:21 +00:00
|
|
|
{
|
|
|
|
GList *new_layers;
|
|
|
|
|
|
|
|
new_layers = file_open_layers (shell->display->gimp, context,
|
|
|
|
GIMP_PROGRESS (shell->display),
|
|
|
|
image, FALSE,
|
2014-07-07 00:46:25 +02:00
|
|
|
file, GIMP_RUN_INTERACTIVE, NULL,
|
2008-03-18 21:22:21 +00:00
|
|
|
&status, &error);
|
|
|
|
|
|
|
|
if (new_layers)
|
|
|
|
{
|
2019-01-03 16:46:00 +01:00
|
|
|
gint x = 0;
|
|
|
|
gint y = 0;
|
|
|
|
gint width = gimp_image_get_width (image);
|
|
|
|
gint height = gimp_image_get_height (image);
|
2008-03-18 21:22:21 +00:00
|
|
|
|
2019-01-03 16:46:00 +01:00
|
|
|
if (gimp_display_get_image (shell->display))
|
2019-09-15 16:25:20 +03:00
|
|
|
{
|
|
|
|
gimp_display_shell_untransform_viewport (
|
|
|
|
shell,
|
|
|
|
! gimp_display_shell_get_infinite_canvas (shell),
|
|
|
|
&x, &y, &width, &height);
|
|
|
|
}
|
2008-03-18 21:22:21 +00:00
|
|
|
|
2009-08-03 22:30:36 +02:00
|
|
|
gimp_image_add_layers (image, new_layers,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1,
|
2008-03-18 21:22:21 +00:00
|
|
|
x, y, width, height,
|
|
|
|
_("Drop layers"));
|
|
|
|
|
|
|
|
g_list_free (new_layers);
|
|
|
|
}
|
2019-04-12 18:22:06 +02:00
|
|
|
else if (status != GIMP_PDB_CANCEL && status != GIMP_PDB_SUCCESS)
|
2008-03-18 21:22:21 +00:00
|
|
|
{
|
|
|
|
warn = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2009-10-06 19:20:44 +02:00
|
|
|
else if (gimp_display_get_image (shell->display))
|
2008-11-04 22:32:15 +00:00
|
|
|
{
|
|
|
|
/* open any subsequent images in a new display */
|
|
|
|
GimpImage *new_image;
|
|
|
|
|
|
|
|
new_image = file_open_with_display (shell->display->gimp, context,
|
|
|
|
NULL,
|
2014-07-07 00:46:25 +02:00
|
|
|
file, FALSE,
|
2018-04-29 17:27:47 +02:00
|
|
|
G_OBJECT (gimp_widget_get_monitor (widget)),
|
2008-11-04 22:32:15 +00:00
|
|
|
&status, &error);
|
|
|
|
|
2019-04-12 18:22:06 +02:00
|
|
|
if (! new_image && status != GIMP_PDB_CANCEL && status != GIMP_PDB_SUCCESS)
|
2008-11-04 22:32:15 +00:00
|
|
|
warn = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* open the first image in the empty display */
|
|
|
|
image = file_open_with_display (shell->display->gimp, context,
|
|
|
|
GIMP_PROGRESS (shell->display),
|
2014-07-07 00:46:25 +02:00
|
|
|
file, FALSE,
|
2018-04-29 17:27:47 +02:00
|
|
|
G_OBJECT (gimp_widget_get_monitor (widget)),
|
2008-11-04 22:32:15 +00:00
|
|
|
&status, &error);
|
|
|
|
|
2019-01-03 16:46:00 +01:00
|
|
|
if (image)
|
|
|
|
{
|
|
|
|
g_object_ref (image);
|
|
|
|
}
|
2019-04-12 18:22:06 +02:00
|
|
|
else if (status != GIMP_PDB_CANCEL && status != GIMP_PDB_SUCCESS)
|
2019-01-03 16:46:00 +01:00
|
|
|
{
|
|
|
|
warn = TRUE;
|
|
|
|
}
|
2008-11-04 22:32:15 +00:00
|
|
|
}
|
2006-11-03 17:12:27 +00:00
|
|
|
|
2011-06-10 18:06:02 +02:00
|
|
|
/* Something above might have run a few rounds of the main loop. Check
|
|
|
|
* that shell->display is still there, otherwise ignore this as the app
|
2019-01-03 16:46:00 +01:00
|
|
|
* is being torn down for quitting.
|
|
|
|
*/
|
2011-06-10 18:06:02 +02:00
|
|
|
if (warn && shell->display)
|
2004-06-02 17:35:55 +00:00
|
|
|
{
|
2008-03-18 21:22:21 +00:00
|
|
|
gimp_message (shell->display->gimp, G_OBJECT (shell->display),
|
2006-10-09 08:17:22 +00:00
|
|
|
GIMP_MESSAGE_ERROR,
|
2006-08-08 21:06:36 +00:00
|
|
|
_("Opening '%s' failed:\n\n%s"),
|
2014-07-07 00:46:25 +02:00
|
|
|
gimp_file_get_utf8_name (file), error->message);
|
2004-06-02 17:35:55 +00:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2014-07-07 00:46:25 +02:00
|
|
|
|
|
|
|
g_object_unref (file);
|
2004-06-01 23:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-27 12:22:23 +00:00
|
|
|
if (image)
|
|
|
|
gimp_display_shell_dnd_flush (shell, image);
|
2019-01-03 16:46:00 +01:00
|
|
|
|
|
|
|
g_clear_object (&image);
|
2004-06-01 23:14:28 +00:00
|
|
|
}
|
2005-01-15 17:17:33 +00:00
|
|
|
|
2005-01-15 19:31:09 +00:00
|
|
|
static void
|
2005-01-15 17:17:33 +00:00
|
|
|
gimp_display_shell_drop_component (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpChannelType component,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
2009-10-06 19:20:44 +02:00
|
|
|
GimpImage *dest_image = gimp_display_get_image (shell->display);
|
2005-01-15 17:17:33 +00:00
|
|
|
GimpChannel *channel;
|
|
|
|
GimpItem *new_item;
|
|
|
|
const gchar *desc;
|
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
GIMP_LOG (DND, NULL);
|
2005-01-15 17:17:33 +00:00
|
|
|
|
2008-03-18 21:22:21 +00:00
|
|
|
if (shell->display->gimp->busy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! dest_image)
|
2011-04-28 01:59:38 +02:00
|
|
|
{
|
|
|
|
dest_image = gimp_image_new_from_component (image->gimp,
|
|
|
|
image, component);
|
2014-05-02 20:20:46 +02:00
|
|
|
gimp_create_display (dest_image->gimp, dest_image, GIMP_UNIT_PIXEL, 1.0,
|
2018-04-29 17:27:47 +02:00
|
|
|
G_OBJECT (gimp_widget_get_monitor (widget)));
|
2011-04-28 01:59:38 +02:00
|
|
|
g_object_unref (dest_image);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2005-01-15 17:17:33 +00:00
|
|
|
|
|
|
|
channel = gimp_channel_new_from_component (image, component, NULL, NULL);
|
|
|
|
|
2008-01-08 11:46:15 +00:00
|
|
|
new_item = gimp_item_convert (GIMP_ITEM (channel),
|
|
|
|
dest_image, GIMP_TYPE_LAYER);
|
2005-01-15 17:17:33 +00:00
|
|
|
g_object_unref (channel);
|
|
|
|
|
|
|
|
if (new_item)
|
|
|
|
{
|
|
|
|
GimpLayer *new_layer = GIMP_LAYER (new_item);
|
|
|
|
|
|
|
|
gimp_enum_get_value (GIMP_TYPE_CHANNEL_TYPE, component,
|
|
|
|
NULL, NULL, &desc, NULL);
|
2006-04-07 10:51:22 +00:00
|
|
|
gimp_object_take_name (GIMP_OBJECT (new_layer),
|
|
|
|
g_strdup_printf (_("%s Channel Copy"), desc));
|
2005-01-15 17:17:33 +00:00
|
|
|
|
|
|
|
gimp_image_undo_group_start (dest_image, GIMP_UNDO_GROUP_EDIT_PASTE,
|
|
|
|
_("Drop New Layer"));
|
|
|
|
|
2012-07-30 16:20:11 +02:00
|
|
|
gimp_display_shell_dnd_position_item (shell, image, new_item);
|
2005-01-15 17:17:33 +00:00
|
|
|
|
2009-08-03 22:30:36 +02:00
|
|
|
gimp_image_add_layer (dest_image, new_layer,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
2005-01-15 17:17:33 +00:00
|
|
|
|
|
|
|
gimp_image_undo_group_end (dest_image);
|
|
|
|
|
2007-07-26 10:52:39 +00:00
|
|
|
gimp_display_shell_dnd_flush (shell, dest_image);
|
2005-01-15 17:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-09 17:56:04 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_drop_pixbuf (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GdkPixbuf *pixbuf,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2011-04-28 01:59:38 +02:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
2005-04-09 17:56:04 +00:00
|
|
|
GimpLayer *new_layer;
|
2012-04-07 00:46:59 +02:00
|
|
|
gboolean has_alpha = FALSE;
|
2005-04-09 17:56:04 +00:00
|
|
|
|
2007-11-15 13:54:15 +00:00
|
|
|
GIMP_LOG (DND, NULL);
|
2005-04-09 17:56:04 +00:00
|
|
|
|
2008-03-18 21:22:21 +00:00
|
|
|
if (shell->display->gimp->busy)
|
|
|
|
return;
|
|
|
|
|
2010-02-08 14:47:45 +01:00
|
|
|
if (! image)
|
|
|
|
{
|
|
|
|
image = gimp_image_new_from_pixbuf (shell->display->gimp, pixbuf,
|
|
|
|
_("Dropped Buffer"));
|
2014-05-02 20:20:46 +02:00
|
|
|
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
2018-04-29 17:27:47 +02:00
|
|
|
G_OBJECT (gimp_widget_get_monitor (widget)));
|
2010-02-08 14:47:45 +01:00
|
|
|
g_object_unref (image);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-28 01:44:48 +02:00
|
|
|
if (gdk_pixbuf_get_n_channels (pixbuf) == 2 ||
|
|
|
|
gdk_pixbuf_get_n_channels (pixbuf) == 4)
|
2008-09-04 18:14:56 +00:00
|
|
|
{
|
2012-04-07 00:46:59 +02:00
|
|
|
has_alpha = TRUE;
|
2008-09-04 18:14:56 +00:00
|
|
|
}
|
|
|
|
|
2005-04-09 17:56:04 +00:00
|
|
|
new_layer =
|
2012-03-21 20:21:11 +01:00
|
|
|
gimp_layer_new_from_pixbuf (pixbuf, image,
|
2012-04-07 00:46:59 +02:00
|
|
|
gimp_image_get_layer_format (image, has_alpha),
|
2005-04-09 17:56:04 +00:00
|
|
|
_("Dropped Buffer"),
|
2017-01-08 23:00:19 +01:00
|
|
|
GIMP_OPACITY_OPAQUE,
|
2017-08-21 20:04:25 +02:00
|
|
|
gimp_image_get_default_new_layer_mode (image));
|
2005-04-09 17:56:04 +00:00
|
|
|
|
|
|
|
if (new_layer)
|
|
|
|
{
|
2008-09-04 18:14:56 +00:00
|
|
|
GimpItem *new_item = GIMP_ITEM (new_layer);
|
2005-04-09 17:56:04 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE,
|
2005-04-09 17:56:04 +00:00
|
|
|
_("Drop New Layer"));
|
|
|
|
|
2012-07-30 16:20:11 +02:00
|
|
|
gimp_display_shell_dnd_position_item (shell, image, new_item);
|
2005-04-09 17:56:04 +00:00
|
|
|
|
2009-08-03 22:30:36 +02:00
|
|
|
gimp_image_add_layer (image, new_layer,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
2005-04-09 17:56:04 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_undo_group_end (image);
|
2005-04-09 17:56:04 +00:00
|
|
|
|
2007-07-26 10:52:39 +00:00
|
|
|
gimp_display_shell_dnd_flush (shell, image);
|
2005-04-09 17:56:04 +00:00
|
|
|
}
|
|
|
|
}
|