[gimp] app: show error on attempt to clear/cut layer with locked alpha channel
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: show error on attempt to clear/cut layer with locked alpha channel
- Date: Mon, 31 Dec 2018 09:41:08 +0000 (UTC)
commit e967e5fa9efa77af1886416dc6097242478b985e
Author: Ell <ell_se yahoo com>
Date: Mon Dec 31 04:37:50 2018 -0500
app: show error on attempt to clear/cut layer with locked alpha channel
Show an error message, and blink the layers-dialog lock-box, when
attempting to clear/cut a layer with a locked alpha channel.
app/actions/edit-commands.c | 59 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 12 deletions(-)
---
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index 499dffe8d8..2f34cc34ff 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -53,6 +53,7 @@
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-transform.h"
+#include "tools/gimptools-utils.h"
#include "tools/tool_manager.h"
#include "actions.h"
@@ -63,18 +64,20 @@
/* local function prototypes */
-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);
+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);
/* public functions */
@@ -212,6 +215,9 @@ edit_cut_cmd_callback (GtkAction *action,
GError *error = NULL;
return_if_no_drawable (image, drawable, data);
+ if (! check_drawable_alpha (drawable, data))
+ return;
+
cut = gimp_edit_cut (image, drawable, action_data_get_context (data),
&error);
@@ -456,6 +462,9 @@ edit_clear_cmd_callback (GtkAction *action,
GimpDrawable *drawable;
return_if_no_drawable (image, drawable, data);
+ if (! check_drawable_alpha (drawable, data))
+ return;
+
gimp_drawable_edit_clear (drawable, action_data_get_context (data));
gimp_image_flush (image);
}
@@ -496,6 +505,32 @@ edit_fill_cmd_callback (GtkAction *action,
/* private functions */
+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;
+}
+
static void
edit_paste (GimpDisplay *display,
GimpPasteType paste_type,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]