From 59cb3e36e10d5355f264093cb180581e03a5faf3 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 11 Mar 2023 14:36:50 +0000 Subject: [PATCH] app: Toggle on-canvas text editor visibility This adds a new boolean to text options, "Show on-canvas editor". When toggled, it immediately hides (or re-shows) the current text layer's on-canvas text editor. It uses the same signal and function as the "use-editor" property. --- app/tools/gimptextoptions.c | 20 +++++++++++++++++++- app/tools/gimptextoptions.h | 1 + app/tools/gimptexttool-editor.c | 12 +++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c index eb69392852b..c6e09414791 100644 --- a/app/tools/gimptextoptions.c +++ b/app/tools/gimptextoptions.c @@ -84,6 +84,7 @@ enum PROP_OUTLINE_DASH_OFFSET, PROP_OUTLINE_DASH_INFO, PROP_USE_EDITOR, + PROP_SHOW_ON_CANVAS_EDITOR, PROP_FONT_VIEW_TYPE, PROP_FONT_VIEW_SIZE @@ -245,11 +246,18 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass) GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_USE_EDITOR, "use-editor", - _("Use editor"), + _("Use editor window"), _("Use an external editor window for text entry"), FALSE, GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_ON_CANVAS_EDITOR, + "show-on-canvas", + _("Show on-canvas editor"), + _("Show on-canvas text editor"), + TRUE, + GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_ENUM (object_class, PROP_FONT_VIEW_TYPE, "font-view-type", NULL, NULL, @@ -457,6 +465,9 @@ gimp_text_options_get_property (GObject *object, case PROP_USE_EDITOR: g_value_set_boolean (value, options->use_editor); break; + case PROP_SHOW_ON_CANVAS_EDITOR: + g_value_set_boolean (value, options->show_on_canvas); + break; case PROP_FONT_VIEW_TYPE: g_value_set_enum (value, options->font_view_type); @@ -571,6 +582,9 @@ gimp_text_options_set_property (GObject *object, case PROP_USE_EDITOR: options->use_editor = g_value_get_boolean (value); break; + case PROP_SHOW_ON_CANVAS_EDITOR: + options->show_on_canvas = g_value_get_boolean (value); + break; case PROP_FONT_VIEW_TYPE: options->font_view_type = g_value_get_enum (value); @@ -626,6 +640,7 @@ gimp_text_options_reset (GimpConfig *config) gimp_config_reset_property (object, "outline-dash-info"); gimp_config_reset_property (object, "use-editor"); + gimp_config_reset_property (object, "use-on-canvas"); } static void @@ -803,6 +818,9 @@ gimp_text_options_gui (GimpToolOptions *tool_options) button = gimp_prop_check_button_new (config, "use-editor", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + button = gimp_prop_check_button_new (config, "show-on-canvas", NULL); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + button = gimp_prop_check_button_new (config, "antialias", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); diff --git a/app/tools/gimptextoptions.h b/app/tools/gimptextoptions.h index b45d8625d81..0a85bb8f7e2 100644 --- a/app/tools/gimptextoptions.h +++ b/app/tools/gimptextoptions.h @@ -66,6 +66,7 @@ struct _GimpTextOptions GimpViewSize font_view_size; gboolean use_editor; + gboolean show_on_canvas; /* options gui */ GtkWidget *size_entry; diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c index ee73694ae8b..9a8d97808c6 100644 --- a/app/tools/gimptexttool-editor.c +++ b/app/tools/gimptexttool-editor.c @@ -193,6 +193,9 @@ gimp_text_tool_editor_start (GimpTextTool *text_tool) g_signal_connect (options, "notify::use-editor", G_CALLBACK (gimp_text_tool_options_notify), text_tool); + g_signal_connect (options, "notify::show-on-canvas", + G_CALLBACK (gimp_text_tool_options_notify), + text_tool); if (! text_tool->style_overlay) { @@ -223,7 +226,9 @@ gimp_text_tool_editor_start (GimpTextTool *text_tool) xres, yres); gtk_container_add (GTK_CONTAINER (text_tool->style_overlay), text_tool->style_editor); - gtk_widget_show (text_tool->style_editor); + + if (options->show_on_canvas) + gtk_widget_show (text_tool->style_editor); } gimp_text_tool_editor_position (text_tool); @@ -1328,6 +1333,11 @@ gimp_text_tool_options_notify (GimpTextOptions *options, gtk_widget_destroy (text_tool->editor_dialog); } } + else if (! strcmp (param_name, "show-on-canvas")) + { + gtk_widget_set_visible (text_tool->style_editor, + options->show_on_canvas); + } } static void -- GitLab