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