[gimp/gimp-2-10] app: add a "Use tool groups" option to the toolbox preferences



commit 9362e89b5019ef0b26f82714ccbecd41f2530703
Author: Ell <ell_se yahoo com>
Date:   Sat Feb 1 13:05:49 2020 +0200

    app: add a "Use tool groups" option to the toolbox preferences
    
    Add a new Gimp::tool_item_ui_list, which is a GimpTreeProxy over
    Gimp::tool_item_list.  This allows us to use either a hierarchical
    or a flat tool list in the UI, by setting the "flat" property of
    the new list.
    
    Use Gimp::tool_item_ui_list in GimpToolPalette, so that the toolbox
    layout is affected by this choice.
    
    Add a "Use tool groups" toggle to the toolbox preferences, and bind
    it to the "flat" property of Gimp::tool_item_ui_list.
    
    (cherry picked from commit 3cda972100ac741c5f9af04aa677ce4c875c5c92)

 app/config/gimpguiconfig.c       | 14 ++++++++++++++
 app/config/gimpguiconfig.h       |  1 +
 app/config/gimprc-blurbs.h       |  3 +++
 app/core/gimp.c                  | 19 +++++++++++++++++--
 app/core/gimp.h                  |  2 ++
 app/dialogs/preferences-dialog.c | 10 ++++++++++
 app/tools/gimp-tools.c           | 11 ++++++++++-
 app/widgets/gimptoolpalette.c    |  8 ++++----
 8 files changed, 61 insertions(+), 7 deletions(-)
---
diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c
index c74fbe1122..81ebf52305 100644
--- a/app/config/gimpguiconfig.c
+++ b/app/config/gimpguiconfig.c
@@ -76,6 +76,7 @@ enum
   PROP_TOOLBOX_FOO_AREA,
   PROP_TOOLBOX_IMAGE_AREA,
   PROP_TOOLBOX_WILBER,
+  PROP_TOOLBOX_GROUPS,
   PROP_THEME_PATH,
   PROP_THEME,
   PROP_ICON_THEME_PATH,
@@ -323,6 +324,13 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
                             TRUE,
                             GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_TOOLBOX_GROUPS,
+                            "toolbox-groups",
+                            "Use toolbox groups",
+                            TOOLBOX_GROUPS_BLURB,
+                            TRUE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   path = gimp_config_build_data_path ("themes");
   GIMP_CONFIG_PROP_PATH (object_class, PROP_THEME_PATH,
                          "theme-path",
@@ -669,6 +677,9 @@ gimp_gui_config_set_property (GObject      *object,
     case PROP_TOOLBOX_WILBER:
       gui_config->toolbox_wilber = g_value_get_boolean (value);
       break;
+    case PROP_TOOLBOX_GROUPS:
+      gui_config->toolbox_groups = g_value_get_boolean (value);
+      break;
      case PROP_THEME_PATH:
       g_free (gui_config->theme_path);
       gui_config->theme_path = g_value_dup_string (value);
@@ -863,6 +874,9 @@ gimp_gui_config_get_property (GObject    *object,
     case PROP_TOOLBOX_WILBER:
       g_value_set_boolean (value, gui_config->toolbox_wilber);
       break;
+    case PROP_TOOLBOX_GROUPS:
+      g_value_set_boolean (value, gui_config->toolbox_groups);
+      break;
     case PROP_THEME_PATH:
       g_value_set_string (value, gui_config->theme_path);
       break;
diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h
index d1142982db..5f15495981 100644
--- a/app/config/gimpguiconfig.h
+++ b/app/config/gimpguiconfig.h
@@ -65,6 +65,7 @@ struct _GimpGuiConfig
   gboolean             toolbox_foo_area;
   gboolean             toolbox_image_area;
   gboolean             toolbox_wilber;
+  gboolean             toolbox_groups;
   gchar               *theme_path;
   gchar               *theme;
   gchar               *icon_theme_path;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 9702d716b0..0905837cff 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -663,6 +663,9 @@ _("Show the current foreground and background colors in the toolbox.")
 #define TOOLBOX_FOO_AREA_BLURB \
 _("Show the currently selected brush, pattern and gradient in the toolbox.")
 
+#define TOOLBOX_GROUPS_BLURB \
+_("Use a single toolbox button for grouped tools.")
+
 #define TOOLBOX_IMAGE_AREA_BLURB \
 _("Show the currently active image in the toolbox.")
 
diff --git a/app/core/gimp.c b/app/core/gimp.c
index c838c9a369..c17eea52b3 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -70,6 +70,7 @@
 #include "gimppattern.h"
 #include "gimptemplate.h"
 #include "gimptoolinfo.h"
+#include "gimptreeproxy.h"
 
 #include "gimp-intl.h"
 
@@ -269,6 +270,11 @@ gimp_init (Gimp *gimp)
   gimp_object_set_static_name (GIMP_OBJECT (gimp->tool_item_list),
                                "tool items");
 
+  gimp->tool_item_ui_list = gimp_tree_proxy_new_for_container (
+    gimp->tool_item_list);
+  gimp_object_set_static_name (GIMP_OBJECT (gimp->tool_item_ui_list),
+                               "ui tool items");
+
   gimp->documents = gimp_document_list_new (gimp);
 
   gimp->templates = gimp_list_new (GIMP_TYPE_TEMPLATE, TRUE);
@@ -385,6 +391,9 @@ gimp_finalize (GObject *object)
 
   gimp_tool_info_set_standard (gimp, NULL);
 
+  g_clear_object (&gimp->tool_item_list);
+  g_clear_object (&gimp->tool_item_ui_list);
+
   if (gimp->tool_info_list)
     {
       gimp_container_foreach (gimp->tool_info_list,
@@ -392,8 +401,6 @@ gimp_finalize (GObject *object)
       g_clear_object (&gimp->tool_info_list);
     }
 
-  g_clear_object (&gimp->tool_item_list);
-
   file_data_exit (gimp);
   xcf_exit (gimp);
 
@@ -917,6 +924,14 @@ gimp_get_tool_item_iter (Gimp *gimp)
   return GIMP_LIST (gimp->tool_item_list)->queue->head;
 }
 
+GList *
+gimp_get_tool_item_ui_iter (Gimp *gimp)
+{
+  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
+
+  return GIMP_LIST (gimp->tool_item_ui_list)->queue->head;
+}
+
 GimpObject *
 gimp_get_clipboard_object (Gimp *gimp)
 {
diff --git a/app/core/gimp.h b/app/core/gimp.h
index 7bb7a30d2f..f221351387 100644
--- a/app/core/gimp.h
+++ b/app/core/gimp.h
@@ -111,6 +111,7 @@ struct _Gimp
   GimpToolInfo           *standard_tool_info;
 
   GimpContainer          *tool_item_list;
+  GimpContainer          *tool_item_ui_list;
 
   /*  the opened and saved images in MRU order  */
   GimpContainer          *documents;
@@ -189,6 +190,7 @@ GList        * gimp_get_image_windows      (Gimp                *gimp);
 GList        * gimp_get_paint_info_iter    (Gimp                *gimp);
 GList        * gimp_get_tool_info_iter     (Gimp                *gimp);
 GList        * gimp_get_tool_item_iter     (Gimp                *gimp);
+GList        * gimp_get_tool_item_ui_iter  (Gimp                *gimp);
 
 GimpObject   * gimp_get_clipboard_object   (Gimp                *gimp);
 
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 09207ab09b..6539b031fd 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1109,6 +1109,7 @@ prefs_dialog_new (Gimp       *gimp,
   GtkWidget         *entry;
   GtkWidget         *calibrate_button;
   GSList            *group;
+  GtkWidget         *separator;
   GtkWidget         *editor;
   gint               i;
 
@@ -2145,6 +2146,15 @@ prefs_dialog_new (Gimp       *gimp,
                                     GIMP_ICON_IMAGE,
                                     GTK_BOX (vbox2), size_group);
 
+  separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+  gtk_box_pack_start (GTK_BOX (vbox2), separator, FALSE, FALSE, 0);
+  gtk_widget_show (separator);
+
+  prefs_check_button_add_with_icon (object, "toolbox-groups",
+                                    _("Use tool _groups"),
+                                    NULL,
+                                    GTK_BOX (vbox2), size_group);
+
   g_clear_object (&size_group);
 
   /* Tool Editor */
diff --git a/app/tools/gimp-tools.c b/app/tools/gimp-tools.c
index 1ad466f36d..dccf79acfb 100644
--- a/app/tools/gimp-tools.c
+++ b/app/tools/gimp-tools.c
@@ -120,7 +120,8 @@ static void   gimp_tools_copy_structure (Gimp                   *gimp,
 
 /*  private variables  */
 
-static gboolean   tool_options_deleted = FALSE;
+static GBinding *toolbox_groups_binding = NULL;
+static gboolean  tool_options_deleted   = FALSE;
 
 
 /*  public functions  */
@@ -215,6 +216,12 @@ gimp_tools_init (Gimp *gimp)
   gimp_tool_options_manager_init (gimp);
 
   tool_manager_init (gimp);
+
+  toolbox_groups_binding = g_object_bind_property (
+    gimp->config,            "toolbox-groups",
+    gimp->tool_item_ui_list, "flat",
+    G_BINDING_INVERT_BOOLEAN |
+    G_BINDING_SYNC_CREATE);
 }
 
 void
@@ -224,6 +231,8 @@ gimp_tools_exit (Gimp *gimp)
 
   g_return_if_fail (GIMP_IS_GIMP (gimp));
 
+  g_clear_object (&toolbox_groups_binding);
+
   tool_manager_exit (gimp);
 
   gimp_tool_options_manager_exit (gimp);
diff --git a/app/widgets/gimptoolpalette.c b/app/widgets/gimptoolpalette.c
index ddd58d4644..1f96d6d7a3 100644
--- a/app/widgets/gimptoolpalette.c
+++ b/app/widgets/gimptoolpalette.c
@@ -274,7 +274,7 @@ gimp_tool_palette_set_toolbox (GimpToolPalette *palette,
   gtk_container_add (GTK_CONTAINER (palette), private->group);
   gtk_widget_show (private->group);
 
-  for (list = gimp_get_tool_item_iter (context->gimp);
+  for (list = gimp_get_tool_item_ui_iter (context->gimp);
        list;
        list = g_list_next (list))
     {
@@ -283,13 +283,13 @@ gimp_tool_palette_set_toolbox (GimpToolPalette *palette,
       gimp_tool_palette_add_button (palette, tool_item, -1);
     }
 
-  g_signal_connect_object (context->gimp->tool_item_list, "add",
+  g_signal_connect_object (context->gimp->tool_item_ui_list, "add",
                            G_CALLBACK (gimp_tool_palette_tool_add),
                            palette, 0);
-  g_signal_connect_object (context->gimp->tool_item_list, "remove",
+  g_signal_connect_object (context->gimp->tool_item_ui_list, "remove",
                            G_CALLBACK (gimp_tool_palette_tool_remove),
                            palette, 0);
-  g_signal_connect_object (context->gimp->tool_item_list, "reorder",
+  g_signal_connect_object (context->gimp->tool_item_ui_list, "reorder",
                            G_CALLBACK (gimp_tool_palette_tool_reorder),
                            palette, 0);
 


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