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.
This commit is contained in:
Ell 2020-02-01 13:05:49 +02:00
parent 2caa518b19
commit 3cda972100
8 changed files with 61 additions and 7 deletions

View File

@ -67,6 +67,7 @@ enum
PROP_TOOLBOX_FOO_AREA,
PROP_TOOLBOX_IMAGE_AREA,
PROP_TOOLBOX_WILBER,
PROP_TOOLBOX_GROUPS,
PROP_THEME_PATH,
PROP_THEME,
PROP_PREFER_DARK_THEME,
@ -278,6 +279,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",
@ -622,6 +630,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);
@ -791,6 +802,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;

View File

@ -62,6 +62,7 @@ struct _GimpGuiConfig
gboolean toolbox_foo_area;
gboolean toolbox_image_area;
gboolean toolbox_wilber;
gboolean toolbox_groups;
gchar *theme_path;
gchar *theme;
gboolean prefer_dark_theme;

View File

@ -672,6 +672,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.")

View File

@ -72,6 +72,7 @@
#include "gimppattern.h"
#include "gimptemplate.h"
#include "gimptoolinfo.h"
#include "gimptreeproxy.h"
#include "gimp-intl.h"
@ -276,6 +277,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);
@ -398,6 +404,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,
@ -405,8 +414,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);
@ -932,6 +939,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)
{

View File

@ -112,6 +112,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;
@ -190,6 +191,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);

View File

@ -1108,6 +1108,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 */

View File

@ -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);

View File

@ -330,7 +330,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))
{
@ -339,13 +339,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);
}