[gimp/gimp-2-10] app: in filter tools, allow toggling on-canvas controller visibility



commit 293ae15b726003abe3317d94c12a83fcd697f906
Author: Ell <ell_se yahoo com>
Date:   Sun Jan 13 08:02:32 2019 -0500

    app: in filter tools, allow toggling on-canvas controller visibility
    
    In GimpFilterTool, when the filter uses an on-canvas controller,
    provide a toggle in the tool's filter-options dialog allowing to
    toggle the controller's visibility.  This allows getting the
    controller out of the way when unneeded.
    
    (cherry picked from commit 33c22ae2a395d0685513cdcfd366afcd26e9bfef)

 app/tools/gimpfilteroptions.c | 16 ++++++++++++++++
 app/tools/gimpfilteroptions.h |  1 +
 app/tools/gimpfiltertool.c    | 36 ++++++++++++++++++++++++++++++++----
 app/tools/gimpfiltertool.h    |  1 +
 4 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/app/tools/gimpfilteroptions.c b/app/tools/gimpfilteroptions.c
index cbaedd4f81..f9acd9e705 100644
--- a/app/tools/gimpfilteroptions.c
+++ b/app/tools/gimpfilteroptions.c
@@ -36,6 +36,7 @@ enum
   PROP_PREVIEW_SPLIT,
   PROP_PREVIEW_ALIGNMENT,
   PROP_PREVIEW_POSITION,
+  PROP_CONTROLLER,
   PROP_REGION,
   PROP_COLOR_MANAGED,
   PROP_GAMMA_HACK
@@ -96,6 +97,13 @@ gimp_filter_options_class_init (GimpFilterOptionsClass *klass)
                                                         GIMP_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT));
 
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONTROLLER,
+                            "controller",
+                            _("On-canvas con_trols"),
+                            _("Show on-canvas filter controls"),
+                            TRUE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   g_object_class_install_property (object_class, PROP_REGION,
                                    g_param_spec_enum ("region",
                                                       NULL, NULL,
@@ -152,6 +160,10 @@ gimp_filter_options_set_property (GObject      *object,
       options->preview_position = g_value_get_double (value);
       break;
 
+    case PROP_CONTROLLER:
+      options->controller = g_value_get_boolean (value);
+      break;
+
     case PROP_REGION:
       options->region = g_value_get_enum (value);
       break;
@@ -196,6 +208,10 @@ gimp_filter_options_get_property (GObject    *object,
       g_value_set_double (value, options->preview_position);
       break;
 
+    case PROP_CONTROLLER:
+      g_value_set_boolean (value, options->controller);
+      break;
+
     case PROP_REGION:
       g_value_set_enum (value, options->region);
       break;
diff --git a/app/tools/gimpfilteroptions.h b/app/tools/gimpfilteroptions.h
index 468a08281d..3bf38cebbb 100644
--- a/app/tools/gimpfilteroptions.h
+++ b/app/tools/gimpfilteroptions.h
@@ -40,6 +40,7 @@ struct _GimpFilterOptions
   gboolean            preview_split;
   GimpAlignmentType   preview_alignment;
   gdouble             preview_position;
+  gboolean            controller;
   GimpFilterRegion    region;
   gboolean            color_managed;
   gboolean            gamma_hack;
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index c83c5734c3..9bb9ec452d 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -245,8 +245,9 @@ gimp_filter_tool_finalize (GObject *object)
   g_clear_object (&filter_tool->settings);
   g_clear_pointer (&filter_tool->description, g_free);
   g_clear_object (&filter_tool->gui);
-  filter_tool->settings_box = NULL;
-  filter_tool->region_combo = NULL;
+  filter_tool->settings_box      = NULL;
+  filter_tool->controller_toggle = NULL;
+  filter_tool->region_combo      = NULL;
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -375,6 +376,15 @@ gimp_filter_tool_initialize (GimpTool     *tool,
                               toggle,                             "sensitive",
                               G_BINDING_SYNC_CREATE);
 
+      /*  The show-controller toggle  */
+      filter_tool->controller_toggle =
+        gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
+                                    "controller", NULL);
+      gtk_box_pack_end (GTK_BOX (vbox), filter_tool->controller_toggle,
+                        FALSE, FALSE, 0);
+      if (filter_tool->widget)
+        gtk_widget_show (filter_tool->controller_toggle);
+
       /*  The Color Options expander  */
       expander = gtk_expander_new (_("Advanced Color Options"));
       gtk_box_pack_end (GTK_BOX (vbox), expander, FALSE, FALSE, 0);
@@ -788,6 +798,12 @@ gimp_filter_tool_options_notify (GimpTool         *tool,
       if (filter_options->preview_split)
         gimp_filter_tool_move_guide (filter_tool);
     }
+  else if (! strcmp (pspec->name, "controller") &&
+           filter_tool->widget)
+    {
+      gimp_tool_widget_set_visible (filter_tool->widget,
+                                    filter_options->controller);
+    }
   else if (! strcmp (pspec->name, "region") &&
            filter_tool->filter)
     {
@@ -978,8 +994,9 @@ gimp_filter_tool_halt (GimpFilterTool *filter_tool)
         GTK_CONTAINER (gimp_filter_tool_dialog_get_vbox (filter_tool)));
 
       g_clear_object (&filter_tool->gui);
-      filter_tool->settings_box = NULL;
-      filter_tool->region_combo = NULL;
+      filter_tool->settings_box      = NULL;
+      filter_tool->controller_toggle = NULL;
+      filter_tool->region_combo      = NULL;
     }
 
   if (filter_tool->filter)
@@ -1745,12 +1762,23 @@ gimp_filter_tool_set_widget (GimpFilterTool *filter_tool,
 
   if (filter_tool->widget)
     {
+      GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
+
       g_object_ref (filter_tool->widget);
 
+      gimp_tool_widget_set_visible (filter_tool->widget,
+                                    options->controller);
+
       if (GIMP_TOOL (filter_tool)->display)
         gimp_draw_tool_start (GIMP_DRAW_TOOL (filter_tool),
                               GIMP_TOOL (filter_tool)->display);
     }
+
+  if (filter_tool->controller_toggle)
+    {
+      gtk_widget_set_visible (filter_tool->controller_toggle,
+                              filter_tool->widget != NULL);
+    }
 }
 
 gboolean
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index eb56374717..a3eaa4fc8e 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -58,6 +58,7 @@ struct _GimpFilterTool
   gboolean            overlay;
   GimpToolGui        *gui;
   GtkWidget          *settings_box;
+  GtkWidget          *controller_toggle;
   GtkWidget          *region_combo;
   GtkWidget          *active_picker;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]