2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-06-26 20:09:43 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-06-26 20:09:43 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-06-26 20:09:43 +08: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-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-06-26 20:09:43 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-03-28 08:10:56 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2001-06-26 20:09:43 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-05-07 21:56:05 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2003-09-16 01:26:28 +08:00
|
|
|
#include "core/gimp-edit.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "core/gimpbuffer.h"
|
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpdrawable.h"
|
2018-04-19 05:44:34 +08:00
|
|
|
#include "core/gimpdrawable-edit.h"
|
2016-03-12 02:52:36 +08:00
|
|
|
#include "core/gimpfilloptions.h"
|
2008-08-08 01:19:32 +08:00
|
|
|
#include "core/gimplayer.h"
|
2015-06-17 19:21:01 +08:00
|
|
|
#include "core/gimplayer-new.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-02-13 01:11:34 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2005-05-16 20:31:04 +08:00
|
|
|
#include "vectors/gimpvectors-import.h"
|
|
|
|
|
2004-07-07 22:38:23 +08:00
|
|
|
#include "widgets/gimpclipboard.h"
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2001-06-30 03:25:03 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2004-10-13 23:27:00 +08:00
|
|
|
#include "widgets/gimpmessagebox.h"
|
|
|
|
#include "widgets/gimpmessagedialog.h"
|
2014-05-02 09:01:23 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2012-01-31 06:33:21 +08:00
|
|
|
#include "widgets/gimpwindowstrategy.h"
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2009-06-22 05:37:18 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
#include "display/gimpdisplayshell.h"
|
|
|
|
#include "display/gimpdisplayshell-transform.h"
|
|
|
|
|
2018-12-31 17:37:50 +08:00
|
|
|
#include "tools/gimptools-utils.h"
|
2013-05-13 01:51:52 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "edit-commands.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2018-12-31 17:37:50 +08:00
|
|
|
static gboolean check_drawable_alpha (GimpDrawable *drawable,
|
|
|
|
gpointer data);
|
|
|
|
static void edit_paste (GimpDisplay *display,
|
|
|
|
GimpPasteType paste_type,
|
|
|
|
gboolean try_svg);
|
|
|
|
static void cut_named_buffer_callback (GtkWidget *widget,
|
|
|
|
const gchar *name,
|
|
|
|
gpointer data);
|
|
|
|
static void copy_named_buffer_callback (GtkWidget *widget,
|
|
|
|
const gchar *name,
|
|
|
|
gpointer data);
|
|
|
|
static void copy_named_visible_buffer_callback (GtkWidget *widget,
|
|
|
|
const gchar *name,
|
|
|
|
gpointer data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_undo_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2013-05-13 01:51:52 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpDisplay *display;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2013-05-13 01:51:52 +08:00
|
|
|
return_if_no_display (display, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2013-05-13 01:51:52 +08:00
|
|
|
if (tool_manager_undo_active (image->gimp, display) ||
|
|
|
|
gimp_image_undo (image))
|
|
|
|
{
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_redo_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2013-05-13 01:51:52 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpDisplay *display;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2013-05-13 01:51:52 +08:00
|
|
|
return_if_no_display (display, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2013-05-13 01:51:52 +08:00
|
|
|
if (tool_manager_redo_active (image->gimp, display) ||
|
|
|
|
gimp_image_redo (image))
|
|
|
|
{
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2006-06-13 10:03:44 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_strong_undo_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2006-06-13 10:03:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
|
|
|
if (gimp_image_strong_undo (image))
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_strong_redo_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2006-06-13 10:03:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
|
|
|
if (gimp_image_strong_redo (image))
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_undo_clear_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-05-13 02:36:33 +08:00
|
|
|
{
|
2010-02-05 03:06:49 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpUndoStack *undo_stack;
|
|
|
|
GimpUndoStack *redo_stack;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
gchar *size;
|
|
|
|
gint64 memsize;
|
|
|
|
gint64 guisize;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2004-05-13 02:36:33 +08:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
dialog = gimp_message_dialog_new (_("Clear Undo History"),
|
|
|
|
GIMP_ICON_DIALOG_WARNING,
|
2005-07-08 23:27:38 +08:00
|
|
|
widget,
|
|
|
|
GTK_DIALOG_MODAL |
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
2005-05-07 22:27:47 +08:00
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_EDIT_UNDO_CLEAR,
|
2004-10-13 23:27:00 +08:00
|
|
|
|
2017-02-12 23:06:34 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("Cl_ear"), GTK_RESPONSE_OK,
|
2004-10-13 23:27:00 +08:00
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-02-10 19:00:46 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2005-07-08 23:27:38 +08:00
|
|
|
g_signal_connect_object (gtk_widget_get_toplevel (widget), "unmap",
|
2004-10-13 23:27:00 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
dialog, G_CONNECT_SWAPPED);
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_signal_connect_object (image, "disconnect",
|
2005-07-08 23:27:38 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
dialog, G_CONNECT_SWAPPED);
|
2004-10-13 23:27:00 +08:00
|
|
|
|
|
|
|
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
|
|
|
_("Really clear image's undo history?"));
|
|
|
|
|
2010-02-05 03:06:49 +08:00
|
|
|
undo_stack = gimp_image_get_undo_stack (image);
|
|
|
|
redo_stack = gimp_image_get_redo_stack (image);
|
|
|
|
|
|
|
|
memsize = gimp_object_get_memsize (GIMP_OBJECT (undo_stack), &guisize);
|
2005-05-07 21:56:05 +08:00
|
|
|
memsize += guisize;
|
2010-02-05 03:06:49 +08:00
|
|
|
memsize += gimp_object_get_memsize (GIMP_OBJECT (redo_stack), &guisize);
|
2005-05-07 21:56:05 +08:00
|
|
|
memsize += guisize;
|
|
|
|
|
2011-09-13 17:39:24 +08:00
|
|
|
size = g_format_size (memsize);
|
2005-05-07 21:56:05 +08:00
|
|
|
|
|
|
|
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
|
|
|
_("Clearing the undo history of this "
|
|
|
|
"image will gain %s of memory."), size);
|
|
|
|
g_free (size);
|
|
|
|
|
2005-07-08 23:27:38 +08:00
|
|
|
if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_disable (image);
|
|
|
|
gimp_image_undo_enable (image);
|
|
|
|
gimp_image_flush (image);
|
2005-07-08 23:27:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
2004-05-13 02:36:33 +08:00
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_cut_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2020-05-26 22:15:15 +08:00
|
|
|
GList *drawables;
|
|
|
|
GList *iter;
|
2016-09-20 05:53:40 +08:00
|
|
|
GimpObject *cut;
|
2007-12-14 21:58:10 +08:00
|
|
|
GError *error = NULL;
|
2020-05-26 22:15:15 +08:00
|
|
|
return_if_no_drawables (image, drawables, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
for (iter = drawables; iter; iter = iter->next)
|
|
|
|
if (! check_drawable_alpha (iter->data, data))
|
|
|
|
{
|
|
|
|
g_list_free (drawables);
|
|
|
|
return;
|
|
|
|
}
|
2018-12-31 17:37:50 +08:00
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
cut = gimp_edit_cut (image, drawables, action_data_get_context (data), &error);
|
2016-09-20 05:53:40 +08:00
|
|
|
|
|
|
|
if (cut)
|
2007-12-14 21:58:10 +08:00
|
|
|
{
|
2008-03-05 05:37:52 +08:00
|
|
|
GimpDisplay *display = action_data_get_display (data);
|
|
|
|
|
|
|
|
if (display)
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (display), GIMP_MESSAGE_INFO,
|
2016-09-20 05:53:40 +08:00
|
|
|
GIMP_IS_IMAGE (cut) ?
|
|
|
|
_("Cut layer to the clipboard.") :
|
|
|
|
_("Cut pixels to the clipboard."));
|
2008-03-05 05:37:52 +08:00
|
|
|
|
2007-12-14 21:58:10 +08:00
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (action_data_get_display (data)),
|
|
|
|
GIMP_MESSAGE_WARNING,
|
|
|
|
error->message);
|
2007-12-14 21:58:10 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2020-05-26 22:15:15 +08:00
|
|
|
g_list_free (drawables);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_copy_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2020-05-06 21:46:51 +08:00
|
|
|
GList *drawables;
|
2016-09-20 05:53:40 +08:00
|
|
|
GimpObject *copy;
|
2007-12-14 21:58:10 +08:00
|
|
|
GError *error = NULL;
|
2020-05-06 21:46:51 +08:00
|
|
|
return_if_no_drawables (image, drawables, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2020-05-06 21:46:51 +08:00
|
|
|
copy = gimp_edit_copy (image, drawables, action_data_get_context (data),
|
2016-09-20 05:53:40 +08:00
|
|
|
&error);
|
|
|
|
|
|
|
|
if (copy)
|
2007-02-19 02:50:55 +08:00
|
|
|
{
|
|
|
|
GimpDisplay *display = action_data_get_display (data);
|
|
|
|
|
|
|
|
if (display)
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (display), GIMP_MESSAGE_INFO,
|
2016-09-20 05:53:40 +08:00
|
|
|
GIMP_IS_IMAGE (copy) ?
|
|
|
|
_("Copied layer to the clipboard.") :
|
|
|
|
_("Copied pixels to the clipboard."));
|
2007-02-19 02:50:55 +08:00
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
2007-12-14 21:58:10 +08:00
|
|
|
else
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (action_data_get_display (data)),
|
|
|
|
GIMP_MESSAGE_WARNING,
|
|
|
|
error->message);
|
2007-12-14 21:58:10 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2020-05-06 21:46:51 +08:00
|
|
|
|
|
|
|
g_list_free (drawables);
|
2004-12-12 22:01:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_copy_visible_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-12-12 22:01:08 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2007-12-14 21:58:10 +08:00
|
|
|
GError *error = NULL;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2004-12-12 22:01:08 +08:00
|
|
|
|
2007-12-14 21:58:10 +08:00
|
|
|
if (gimp_edit_copy_visible (image, action_data_get_context (data), &error))
|
|
|
|
{
|
2008-03-05 05:37:52 +08:00
|
|
|
GimpDisplay *display = action_data_get_display (data);
|
|
|
|
|
|
|
|
if (display)
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (display), GIMP_MESSAGE_INFO,
|
2016-09-20 05:53:40 +08:00
|
|
|
_("Copied pixels to the clipboard."));
|
2008-03-05 05:37:52 +08:00
|
|
|
|
2007-12-14 21:58:10 +08:00
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (action_data_get_display (data)),
|
|
|
|
GIMP_MESSAGE_WARNING,
|
|
|
|
error->message);
|
2007-12-14 21:58:10 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_paste_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
2017-11-13 01:41:05 +08:00
|
|
|
GimpDisplay *display = action_data_get_display (data);
|
2019-07-04 07:11:48 +08:00
|
|
|
GimpPasteType paste_type = (GimpPasteType) g_variant_get_int32 (value);
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2017-11-13 01:41:05 +08:00
|
|
|
if (paste_type == GIMP_PASTE_TYPE_FLOATING)
|
2016-09-19 18:36:11 +08:00
|
|
|
{
|
2017-11-13 01:41:05 +08:00
|
|
|
if (! display || ! gimp_display_get_image (display))
|
|
|
|
{
|
2019-07-04 07:11:48 +08:00
|
|
|
edit_paste_as_new_image_cmd_callback (action, value, data);
|
2017-11-13 01:41:05 +08:00
|
|
|
return;
|
|
|
|
}
|
2016-09-19 18:36:11 +08:00
|
|
|
}
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2017-11-13 01:41:05 +08:00
|
|
|
if (! display)
|
|
|
|
return;
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2017-11-13 01:41:05 +08:00
|
|
|
switch (paste_type)
|
|
|
|
{
|
|
|
|
case GIMP_PASTE_TYPE_FLOATING:
|
|
|
|
case GIMP_PASTE_TYPE_FLOATING_IN_PLACE:
|
|
|
|
case GIMP_PASTE_TYPE_FLOATING_INTO:
|
|
|
|
case GIMP_PASTE_TYPE_FLOATING_INTO_IN_PLACE:
|
|
|
|
edit_paste (display, paste_type, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PASTE_TYPE_NEW_LAYER:
|
|
|
|
case GIMP_PASTE_TYPE_NEW_LAYER_IN_PLACE:
|
|
|
|
edit_paste (display, paste_type, FALSE);
|
|
|
|
break;
|
|
|
|
}
|
2016-09-21 02:43:01 +08:00
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_paste_as_new_image_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-07-02 22:08:15 +08:00
|
|
|
Gimp *gimp;
|
2014-05-03 02:20:46 +08:00
|
|
|
GtkWidget *widget;
|
2016-09-21 18:37:51 +08:00
|
|
|
GimpObject *paste;
|
|
|
|
GimpImage *image = NULL;
|
2004-05-03 22:46:29 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
2014-05-03 02:20:46 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2016-09-21 18:37:51 +08:00
|
|
|
paste = gimp_clipboard_get_object (gimp);
|
2004-07-02 22:08:15 +08:00
|
|
|
|
2016-09-21 18:37:51 +08:00
|
|
|
if (paste)
|
2004-07-02 22:08:15 +08:00
|
|
|
{
|
2017-05-02 01:10:52 +08:00
|
|
|
image = gimp_edit_paste_as_new_image (gimp, paste);
|
2016-09-21 18:37:51 +08:00
|
|
|
g_object_unref (paste);
|
2016-09-20 05:53:40 +08:00
|
|
|
}
|
2005-09-03 06:50:06 +08:00
|
|
|
|
2016-09-21 18:37:51 +08:00
|
|
|
if (image)
|
2016-09-20 05:53:40 +08:00
|
|
|
{
|
2016-09-21 18:37:51 +08:00
|
|
|
gimp_create_display (gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
2018-04-29 23:27:47 +08:00
|
|
|
G_OBJECT (gimp_widget_get_monitor (widget)));
|
2016-09-21 18:37:51 +08:00
|
|
|
g_object_unref (image);
|
2008-08-08 00:25:46 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING,
|
2016-09-20 05:53:40 +08:00
|
|
|
_("There is no image data in the clipboard "
|
|
|
|
"to paste."));
|
2008-08-08 00:25:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_named_cut_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-03 22:46:29 +08:00
|
|
|
GtkWidget *widget;
|
2004-10-19 22:08:44 +08:00
|
|
|
GtkWidget *dialog;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2004-05-03 22:46:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-10-19 22:08:44 +08:00
|
|
|
dialog = gimp_query_string_box (_("Cut Named"), widget,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_BUFFER_CUT,
|
|
|
|
_("Enter a name for this buffer"),
|
|
|
|
NULL,
|
2006-03-29 01:08:36 +08:00
|
|
|
G_OBJECT (image), "disconnect",
|
2019-08-08 04:48:06 +08:00
|
|
|
cut_named_buffer_callback,
|
|
|
|
image, NULL);
|
2004-10-19 22:08:44 +08:00
|
|
|
gtk_widget_show (dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_named_copy_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-03 22:46:29 +08:00
|
|
|
GtkWidget *widget;
|
2004-10-19 22:08:44 +08:00
|
|
|
GtkWidget *dialog;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2004-05-03 22:46:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-10-19 22:08:44 +08:00
|
|
|
dialog = gimp_query_string_box (_("Copy Named"), widget,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_BUFFER_COPY,
|
|
|
|
_("Enter a name for this buffer"),
|
|
|
|
NULL,
|
2006-03-29 01:08:36 +08:00
|
|
|
G_OBJECT (image), "disconnect",
|
2019-08-08 04:48:06 +08:00
|
|
|
copy_named_buffer_callback,
|
|
|
|
image, NULL);
|
2004-10-19 22:08:44 +08:00
|
|
|
gtk_widget_show (dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2005-09-05 08:37:25 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_named_copy_visible_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2005-09-05 08:37:25 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2005-09-05 08:37:25 +08:00
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2005-09-05 08:37:25 +08:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
dialog = gimp_query_string_box (_("Copy Visible Named "), widget,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_BUFFER_COPY,
|
|
|
|
_("Enter a name for this buffer"),
|
|
|
|
NULL,
|
2006-03-29 01:08:36 +08:00
|
|
|
G_OBJECT (image), "disconnect",
|
2019-08-08 04:48:06 +08:00
|
|
|
copy_named_visible_buffer_callback,
|
|
|
|
image, NULL);
|
2005-09-05 08:37:25 +08:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_named_paste_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2012-01-31 06:24:44 +08:00
|
|
|
Gimp *gimp;
|
2004-05-03 22:46:29 +08:00
|
|
|
GtkWidget *widget;
|
2012-01-31 06:24:44 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
2004-05-03 22:46:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
|
2012-01-31 06:24:44 +08:00
|
|
|
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
|
|
|
|
gimp,
|
|
|
|
gimp_dialog_factory_get_singleton (),
|
2014-05-02 09:01:23 +08:00
|
|
|
gimp_widget_get_monitor (widget),
|
2012-01-31 06:24:44 +08:00
|
|
|
"gimp-buffer-list|gimp-buffer-grid");
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_clear_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2020-07-31 03:18:54 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GList *drawables;
|
|
|
|
GList *iter;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2020-07-31 03:18:54 +08:00
|
|
|
return_if_no_drawables (image, drawables, data);
|
|
|
|
|
|
|
|
for (iter = drawables; iter; iter = iter->next)
|
|
|
|
/* Return if any has a locked alpha. */
|
|
|
|
if (! check_drawable_alpha (iter->data, data))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT,
|
|
|
|
_("Clear"));
|
2018-12-31 17:37:50 +08:00
|
|
|
|
2020-07-31 03:18:54 +08:00
|
|
|
for (iter = drawables; iter; iter = iter->next)
|
|
|
|
if (! gimp_viewable_get_children (GIMP_VIEWABLE (iter->data)) &&
|
|
|
|
! gimp_item_is_content_locked (GIMP_ITEM (iter->data)))
|
|
|
|
gimp_drawable_edit_clear (iter->data, action_data_get_context (data));
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2020-07-31 03:18:54 +08:00
|
|
|
g_list_free (drawables);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
edit_fill_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2016-03-12 02:52:36 +08:00
|
|
|
GimpImage *image;
|
2020-07-31 23:52:53 +08:00
|
|
|
GList *drawables;
|
|
|
|
GList *iter;
|
2016-03-12 02:52:36 +08:00
|
|
|
GimpFillType fill_type;
|
|
|
|
GimpFillOptions *options;
|
|
|
|
GError *error = NULL;
|
2020-07-31 23:52:53 +08:00
|
|
|
return_if_no_drawables (image, drawables, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
fill_type = (GimpFillType) g_variant_get_int32 (value);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2016-03-16 03:10:16 +08:00
|
|
|
options = gimp_fill_options_new (action_data_get_gimp (data), NULL, FALSE);
|
2016-03-12 02:52:36 +08:00
|
|
|
|
|
|
|
if (gimp_fill_options_set_by_fill_type (options,
|
|
|
|
action_data_get_context (data),
|
|
|
|
fill_type, &error))
|
2014-06-03 20:00:01 +08:00
|
|
|
{
|
2020-07-31 23:52:53 +08:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT,
|
|
|
|
gimp_fill_options_get_undo_desc (options));
|
|
|
|
|
|
|
|
for (iter = drawables; iter; iter = iter->next)
|
|
|
|
gimp_drawable_edit_fill (iter->data, options, NULL);
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
2014-06-03 20:00:01 +08:00
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
|
|
|
error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2016-03-12 02:52:36 +08:00
|
|
|
|
2020-08-01 18:04:04 +08:00
|
|
|
g_list_free (drawables);
|
2016-03-12 02:52:36 +08:00
|
|
|
g_object_unref (options);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2018-12-31 17:37:50 +08:00
|
|
|
static gboolean
|
|
|
|
check_drawable_alpha (GimpDrawable *drawable,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (gimp_drawable_has_alpha (drawable) &&
|
|
|
|
GIMP_IS_LAYER (drawable) &&
|
|
|
|
gimp_layer_get_lock_alpha (GIMP_LAYER (drawable)))
|
|
|
|
{
|
|
|
|
Gimp *gimp = action_data_get_gimp (data);
|
|
|
|
GimpDisplay *display = action_data_get_display (data);
|
|
|
|
|
|
|
|
if (gimp && display)
|
|
|
|
{
|
|
|
|
gimp_message_literal (
|
|
|
|
gimp, G_OBJECT (display), GIMP_MESSAGE_WARNING,
|
2020-05-26 22:15:15 +08:00
|
|
|
_("A selected layer's alpha channel is locked."));
|
2018-12-31 17:37:50 +08:00
|
|
|
|
|
|
|
gimp_tools_blink_lock_box (gimp, GIMP_ITEM (drawable));
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-07-07 17:43:35 +08:00
|
|
|
static void
|
2016-09-20 05:53:40 +08:00
|
|
|
edit_paste (GimpDisplay *display,
|
|
|
|
GimpPasteType paste_type,
|
|
|
|
gboolean try_svg)
|
2004-07-07 17:43:35 +08:00
|
|
|
{
|
2016-09-20 05:53:40 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpObject *paste;
|
2005-05-16 20:31:04 +08:00
|
|
|
|
2016-09-20 05:53:40 +08:00
|
|
|
if (try_svg)
|
2004-07-07 17:43:35 +08:00
|
|
|
{
|
2016-09-20 05:53:40 +08:00
|
|
|
gchar *svg;
|
|
|
|
gsize svg_size;
|
|
|
|
|
|
|
|
svg = gimp_clipboard_get_svg (display->gimp, &svg_size);
|
|
|
|
|
|
|
|
if (svg)
|
2005-05-16 20:31:04 +08:00
|
|
|
{
|
2016-09-20 05:53:40 +08:00
|
|
|
if (gimp_vectors_import_buffer (image, svg, svg_size,
|
|
|
|
TRUE, FALSE,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1,
|
|
|
|
NULL, NULL))
|
|
|
|
{
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (svg);
|
|
|
|
|
|
|
|
return;
|
2005-05-16 20:31:04 +08:00
|
|
|
}
|
2016-09-20 05:53:40 +08:00
|
|
|
}
|
2004-07-07 17:43:35 +08:00
|
|
|
|
2016-09-21 18:37:51 +08:00
|
|
|
paste = gimp_clipboard_get_object (display->gimp);
|
2016-09-20 05:53:40 +08:00
|
|
|
|
|
|
|
if (paste)
|
|
|
|
{
|
2020-08-01 18:04:04 +08:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
GList *drawables = gimp_image_get_selected_drawables (image);
|
|
|
|
GimpDrawable *drawable = NULL;
|
2016-09-21 18:37:51 +08:00
|
|
|
gint x, y;
|
|
|
|
gint width, height;
|
|
|
|
|
2020-08-01 18:04:04 +08:00
|
|
|
/* Paste on multiple selection is probably wrong right now (though
|
|
|
|
* I guess it can be argued). For now we just default to the same
|
|
|
|
* as pasting with no selected drawable, which will just create a
|
|
|
|
* new drawable.
|
|
|
|
*/
|
|
|
|
if (g_list_length (drawables) == 1)
|
|
|
|
drawable = drawables->data;
|
|
|
|
|
|
|
|
g_list_free (drawables);
|
|
|
|
|
2018-03-25 00:43:30 +08:00
|
|
|
if (drawable &&
|
|
|
|
paste_type != GIMP_PASTE_TYPE_NEW_LAYER &&
|
|
|
|
paste_type != GIMP_PASTE_TYPE_NEW_LAYER_IN_PLACE)
|
2005-05-16 20:31:04 +08:00
|
|
|
{
|
2016-09-20 05:53:40 +08:00
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
|
2005-05-16 20:31:04 +08:00
|
|
|
{
|
2016-09-20 05:53:40 +08:00
|
|
|
gimp_message_literal (display->gimp, G_OBJECT (display),
|
|
|
|
GIMP_MESSAGE_INFO,
|
|
|
|
_("Pasted as new layer because the "
|
|
|
|
"target is a layer group."));
|
2005-05-16 20:31:04 +08:00
|
|
|
}
|
2016-09-20 05:53:40 +08:00
|
|
|
else if (gimp_item_is_content_locked (GIMP_ITEM (drawable)))
|
|
|
|
{
|
|
|
|
gimp_message_literal (display->gimp, G_OBJECT (display),
|
|
|
|
GIMP_MESSAGE_INFO,
|
|
|
|
_("Pasted as new layer because the "
|
|
|
|
"target's pixels are locked."));
|
|
|
|
}
|
2018-03-25 00:43:30 +08:00
|
|
|
|
|
|
|
/* the actual paste-type conversion happens in gimp_edit_paste() */
|
2005-05-16 20:31:04 +08:00
|
|
|
}
|
2016-09-20 05:53:40 +08:00
|
|
|
|
2019-09-15 21:25:20 +08:00
|
|
|
gimp_display_shell_untransform_viewport (
|
|
|
|
shell,
|
|
|
|
! gimp_display_shell_get_infinite_canvas (shell),
|
|
|
|
&x, &y, &width, &height);
|
2016-09-20 05:53:40 +08:00
|
|
|
|
|
|
|
if (gimp_edit_paste (image, drawable, paste,
|
|
|
|
paste_type, x, y, width, height))
|
2006-09-23 00:44:47 +08:00
|
|
|
{
|
2016-09-20 05:53:40 +08:00
|
|
|
gimp_image_flush (image);
|
2006-09-23 00:44:47 +08:00
|
|
|
}
|
2016-09-20 05:53:40 +08:00
|
|
|
|
|
|
|
g_object_unref (paste);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_message_literal (display->gimp, G_OBJECT (display),
|
|
|
|
GIMP_MESSAGE_WARNING,
|
|
|
|
_("There is no image data in the clipboard "
|
|
|
|
"to paste."));
|
2004-07-07 17:43:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
static void
|
2003-09-05 09:56:50 +08:00
|
|
|
cut_named_buffer_callback (GtkWidget *widget,
|
2004-01-16 18:06:19 +08:00
|
|
|
const gchar *name,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2020-05-26 22:15:15 +08:00
|
|
|
GimpImage *image = GIMP_IMAGE (data);
|
|
|
|
GList *drawables = gimp_image_get_selected_drawables (image);
|
|
|
|
GError *error = NULL;
|
2004-02-19 20:49:15 +08:00
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
if (! drawables)
|
2004-02-19 20:49:15 +08:00
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
2020-05-26 22:15:15 +08:00
|
|
|
_("There are no selected layers or channels to cut from."));
|
2004-02-19 20:49:15 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-09-03 06:50:06 +08:00
|
|
|
if (! (name && strlen (name)))
|
|
|
|
name = _("(Unnamed Buffer)");
|
2001-12-13 07:48:18 +08:00
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
if (gimp_edit_named_cut (image, name, drawables,
|
2007-12-14 21:58:10 +08:00
|
|
|
gimp_get_user_context (image->gimp), &error))
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2004-02-19 20:49:15 +08:00
|
|
|
}
|
2007-12-14 21:58:10 +08:00
|
|
|
else
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
2013-09-15 00:59:20 +08:00
|
|
|
error->message);
|
2007-12-14 21:58:10 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2020-05-26 22:15:15 +08:00
|
|
|
g_list_free (drawables);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-09-05 09:40:29 +08:00
|
|
|
copy_named_buffer_callback (GtkWidget *widget,
|
2006-04-12 20:49:29 +08:00
|
|
|
const gchar *name,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2020-05-26 22:15:15 +08:00
|
|
|
GimpImage *image = GIMP_IMAGE (data);
|
|
|
|
GList *drawables = gimp_image_get_selected_drawables (image);
|
|
|
|
GError *error = NULL;
|
2004-02-19 20:49:15 +08:00
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
if (! drawables)
|
2004-02-19 20:49:15 +08:00
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
2020-05-26 22:15:15 +08:00
|
|
|
_("There are no selected layers or channels to copy from."));
|
2004-02-19 20:49:15 +08:00
|
|
|
return;
|
|
|
|
}
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2005-09-03 06:50:06 +08:00
|
|
|
if (! (name && strlen (name)))
|
|
|
|
name = _("(Unnamed Buffer)");
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
if (gimp_edit_named_copy (image, name, drawables,
|
2007-12-14 21:58:10 +08:00
|
|
|
gimp_get_user_context (image->gimp), &error))
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
2007-12-14 21:58:10 +08:00
|
|
|
else
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
2013-09-15 00:59:20 +08:00
|
|
|
error->message);
|
2007-12-14 21:58:10 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2020-05-26 22:15:15 +08:00
|
|
|
g_list_free (drawables);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
2005-09-05 08:37:25 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
copy_named_visible_buffer_callback (GtkWidget *widget,
|
|
|
|
const gchar *name,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image = GIMP_IMAGE (data);
|
2007-12-14 21:58:10 +08:00
|
|
|
GError *error = NULL;
|
2005-09-05 08:37:25 +08:00
|
|
|
|
|
|
|
if (! (name && strlen (name)))
|
|
|
|
name = _("(Unnamed Buffer)");
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (gimp_edit_named_copy_visible (image, name,
|
2007-12-14 21:58:10 +08:00
|
|
|
gimp_get_user_context (image->gimp),
|
|
|
|
&error))
|
2005-09-05 08:37:25 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2005-09-05 08:37:25 +08:00
|
|
|
}
|
2007-12-14 21:58:10 +08:00
|
|
|
else
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
2013-09-15 00:59:20 +08:00
|
|
|
error->message);
|
2007-12-14 21:58:10 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2005-09-05 08:37:25 +08:00
|
|
|
}
|