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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://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"
|
|
|
|
|
2013-05-13 01:51:52 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2006-10-22 02:46:49 +08:00
|
|
|
#include "dialogs/fade-dialog.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
|
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 */
|
|
|
|
|
2016-09-20 05:53:40 +08:00
|
|
|
static void edit_paste (GimpDisplay *display,
|
2017-11-13 01:41:05 +08:00
|
|
|
GimpPasteType paste_type,
|
2016-09-20 05:53:40 +08:00
|
|
|
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
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_undo_cmd_callback (GtkAction *action,
|
2004-01-16 18:06:19 +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
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_redo_cmd_callback (GtkAction *action,
|
2004-01-16 18:06:19 +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
|
|
|
|
edit_strong_undo_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
|
|
|
if (gimp_image_strong_undo (image))
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_strong_redo_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
edit_undo_clear_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2016-09-18 01:45:45 +08:00
|
|
|
void
|
|
|
|
edit_fade_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
return_if_no_image (image, data);
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
dialog = fade_dialog_new (image, widget);
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
|
|
|
g_signal_connect_object (image, "disconnect",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
dialog, G_CONNECT_SWAPPED);
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_cut_cmd_callback (GtkAction *action,
|
2004-01-16 18:06:19 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-02-19 20:49:15 +08:00
|
|
|
GimpDrawable *drawable;
|
2016-09-20 05:53:40 +08:00
|
|
|
GimpObject *cut;
|
2007-12-14 21:58:10 +08:00
|
|
|
GError *error = NULL;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_drawable (image, drawable, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2016-09-20 05:53:40 +08:00
|
|
|
cut = gimp_edit_cut (image, drawable, action_data_get_context (data),
|
|
|
|
&error);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_copy_cmd_callback (GtkAction *action,
|
2004-01-16 18:06:19 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-02-19 20:49:15 +08:00
|
|
|
GimpDrawable *drawable;
|
2016-09-20 05:53:40 +08:00
|
|
|
GimpObject *copy;
|
2007-12-14 21:58:10 +08:00
|
|
|
GError *error = NULL;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_drawable (image, drawable, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2016-09-20 05:53:40 +08:00
|
|
|
copy = gimp_edit_copy (image, drawable, action_data_get_context (data),
|
|
|
|
&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);
|
|
|
|
}
|
2004-12-12 22:01:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_copy_visible_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
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
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_paste_cmd_callback (GtkAction *action,
|
2017-11-13 01:41:05 +08:00
|
|
|
gint value,
|
2004-04-19 22:54:24 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2017-11-13 01:41:05 +08:00
|
|
|
GimpDisplay *display = action_data_get_display (data);
|
|
|
|
GimpPasteType paste_type = (GimpPasteType) 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))
|
|
|
|
{
|
|
|
|
edit_paste_as_new_image_cmd_callback (action, data);
|
|
|
|
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
|
2016-09-19 18:14:02 +08:00
|
|
|
edit_paste_as_new_image_cmd_callback (GtkAction *action,
|
|
|
|
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
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_named_cut_cmd_callback (GtkAction *action,
|
2004-01-16 18:06:19 +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",
|
|
|
|
cut_named_buffer_callback, image);
|
2004-10-19 22:08:44 +08:00
|
|
|
gtk_widget_show (dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_named_copy_cmd_callback (GtkAction *action,
|
2004-01-16 18:06:19 +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",
|
|
|
|
copy_named_buffer_callback, image);
|
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
|
|
|
|
edit_named_copy_visible_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
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",
|
|
|
|
copy_named_visible_buffer_callback, image);
|
2005-09-05 08:37:25 +08:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_named_paste_cmd_callback (GtkAction *action,
|
2004-01-16 18:06:19 +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
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_clear_cmd_callback (GtkAction *action,
|
2004-01-16 18:06:19 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-02-19 20:49:15 +08:00
|
|
|
GimpDrawable *drawable;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_drawable (image, drawable, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2018-04-19 05:44:34 +08:00
|
|
|
gimp_drawable_edit_clear (drawable, action_data_get_context (data));
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
edit_fill_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2016-03-12 02:52:36 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpFillType fill_type;
|
|
|
|
GimpFillOptions *options;
|
|
|
|
GError *error = NULL;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_drawable (image, drawable, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
fill_type = (GimpFillType) 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
|
|
|
{
|
2018-04-19 05:44:34 +08:00
|
|
|
gimp_drawable_edit_fill (drawable, options, NULL);
|
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
|
|
|
|
|
|
|
g_object_unref (options);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
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)
|
|
|
|
{
|
2016-09-21 18:37:51 +08:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
|
|
|
gint x, y;
|
|
|
|
gint width, height;
|
|
|
|
|
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
|
|
|
|
|
|
|
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2007-07-19 22:59:51 +08:00
|
|
|
GimpImage *image = GIMP_IMAGE (data);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
2007-12-14 21:58:10 +08:00
|
|
|
GError *error = NULL;
|
2004-02-19 20:49:15 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
if (! drawable)
|
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,
|
2013-09-15 00:59:20 +08:00
|
|
|
_("There is no active layer or channel 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
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (gimp_edit_named_cut (image, name, drawable,
|
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);
|
|
|
|
}
|
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
|
|
|
{
|
2007-07-19 22:59:51 +08:00
|
|
|
GimpImage *image = GIMP_IMAGE (data);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
2007-12-14 21:58:10 +08:00
|
|
|
GError *error = NULL;
|
2004-02-19 20:49:15 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
if (! drawable)
|
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,
|
2013-09-15 00:59:20 +08:00
|
|
|
_("There is no active layer or channel 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
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (gimp_edit_named_copy (image, name, drawable,
|
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);
|
|
|
|
}
|
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
|
|
|
}
|