[gimp] app: remove empty text layer when it becomes inactive
- From: Massimo Valentini <mvalentini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove empty text layer when it becomes inactive
- Date: Mon, 27 Jun 2016 15:04:19 +0000 (UTC)
commit 1e07de1858b4ba9cce497dc4464bfb5afcf036e1
Author: Massimo Valentini <mvalentini src gnome org>
Date: Mon Jun 27 16:48:19 2016 +0200
app: remove empty text layer when it becomes inactive
only if auto_rename is TRUE and text->box_mode is not
FIXED
app/tools/gimptexttool.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index 6e3ea03..de10ce0 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -318,6 +318,37 @@ gimp_text_tool_finalize (GObject *object)
}
static void
+gimp_text_tool_remove_empty_text_layer (GimpTextTool *text_tool)
+{
+ GimpTextLayer *text_layer = text_tool->layer;
+
+ if (text_layer && text_layer->auto_rename)
+ {
+ GimpText *text = gimp_text_layer_get_text (text_layer);
+
+ if (text->box_mode == GIMP_TEXT_BOX_DYNAMIC &&
+ (! text->text || text->text[0] == '\0') &&
+ (! text->markup || text->markup[0] == '\0'))
+ {
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (text_layer));
+
+ if (text_tool->image == image)
+ g_signal_handlers_block_by_func (image,
+ gimp_text_tool_layer_changed,
+ text_tool);
+
+ gimp_image_remove_layer (image, GIMP_LAYER (text_layer), TRUE, NULL);
+ gimp_image_flush (image);
+
+ if (text_tool->image == image)
+ g_signal_handlers_unblock_by_func (image,
+ gimp_text_tool_layer_changed,
+ text_tool);
+ }
+ }
+}
+
+static void
gimp_text_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
@@ -1092,6 +1123,8 @@ gimp_text_tool_connect (GimpTextTool *text_tool,
gimp_text_tool_layer_notify,
text_tool);
+ gimp_text_tool_remove_empty_text_layer (text_tool);
+
text_tool->layer = layer;
if (layer)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]