Issue #7023: icon size selection on GIMP 2.99.

This kinda reverts commit 6aebd30de1 ("app: remove
icon sizing preferences"), except that the code base is different enough since
this old commit was mainly for GIMP 2.10.x.
In any case, after initially thinking that GTK+3 handling for high density
display would be enough, we finally decide that adding back a Preferences-wide
setting for overriding the theme-set icon size is a good idea (additionally to
GTK+3 automatic support).

The base idea for removing the feature was that GTK+3 has high density display
support, through the "scale factor". Typically a high density display will
normally be set as using a ×2 scale factor so all icons will be double size.
Unfortunately it turns out it's not enough.

For instance, on very small screen estate, even with a scale factor of 1, if the
theme sets 24px toolbox icons, it may still take too much space.
Oppositely on huge screens, even with ×2 factor scale detected by the OS, the
icons may still feel too small (this is possibly what happens with #7023).

Furthermore there is also a matter of taste. Some people like small icons even
when they have the space. Others may want bigger icons, easy to click on.

Finally you can like a theme for its color scheme for instance, but it may not
have the icon size you want. Right now, we'd need to duplicate every theme in
small or bigger size. Instead of doing so, let's just have this global setting
overriding the theme rules.

Comparison with the 2.10 implementation:

- We still provide 4 sizes: small, medium, large and huge.
- We don't have the "Guess ideal size" setting anymore. Instead this is now a
  mix of the GTK+3 scale factor logic and the theme-set or custom size. I.e.
  that on a high density display with ×2 scale factor, we could have toolbox
  icons up to 96 pixels (48×2)!
- We now try to have less custom code in widgets as we append the CSS rules to
  the theme (similar to what we were already doing for dark theme or icon
  variants). What happens in widget code is mostly to connect to changes in
  themes and redraw the widgets which need to be.
- The custom size will now affect: toolbox icons, the FG/BG editor widget (in
  both the toolbox and the color dockable), dockable tab icons, the main
  dockable buttons, eye and lock header icons in item tree views, eye and lock
  cell icons in the item lists.

There are still a bunch of areas where it is not taken into account, such as
plug-ins, and various dialogs, but even in custom-made interface in dockables.
Ultimately it might be interesting to have a way to sync more buttons and
widgets to a global size settings.

Lastly, I fixed a bunch of existing bugs where we were updating icon sizes with
gtk_image_set_from_icon_name() using the const icon name taken from
gtk_image_get_icon_name(). As this was reusing the same string pointer, we were
ending with freeing the icon name.
This commit is contained in:
Jehan 2022-09-26 22:56:08 +02:00
parent b48bd7d337
commit d3458a82d0
14 changed files with 534 additions and 56 deletions

View File

@ -201,6 +201,39 @@ gimp_help_browser_type_get_type (void)
return type;
}
GType
gimp_icon_size_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_ICON_SIZE_SMALL, "GIMP_ICON_SIZE_SMALL", "small" },
{ GIMP_ICON_SIZE_MEDIUM, "GIMP_ICON_SIZE_MEDIUM", "medium" },
{ GIMP_ICON_SIZE_LARGE, "GIMP_ICON_SIZE_LARGE", "large" },
{ GIMP_ICON_SIZE_HUGE, "GIMP_ICON_SIZE_HUGE", "huge" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_ICON_SIZE_SMALL, NC_("icon-size", "Small size"), NULL },
{ GIMP_ICON_SIZE_MEDIUM, NC_("icon-size", "Medium size"), NULL },
{ GIMP_ICON_SIZE_LARGE, NC_("icon-size", "Large size"), NULL },
{ GIMP_ICON_SIZE_HUGE, NC_("icon-size", "Huge size"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("GimpIconSize", values);
gimp_type_set_translation_context (type, "icon-size");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_position_get_type (void)
{

View File

@ -95,6 +95,19 @@ typedef enum
} GimpHelpBrowserType;
#define GIMP_TYPE_ICON_SIZE (gimp_icon_size_get_type ())
GType gimp_icon_size_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_ICON_SIZE_SMALL, /*< desc="Small size" > */
GIMP_ICON_SIZE_MEDIUM, /*< desc="Medium size" > */
GIMP_ICON_SIZE_LARGE, /*< desc="Large size" > */
GIMP_ICON_SIZE_HUGE /*< desc="Huge size" > */
} GimpIconSize;
#define GIMP_TYPE_POSITION (gimp_position_get_type ())
GType gimp_position_get_type (void) G_GNUC_CONST;

View File

@ -71,6 +71,8 @@ enum
PROP_THEME_PATH,
PROP_THEME,
PROP_PREFER_DARK_THEME,
PROP_OVERRIDE_THEME_ICON_SIZE,
PROP_CUSTOM_ICON_SIZE,
PROP_ICON_THEME_PATH,
PROP_ICON_THEME,
PROP_PREFER_SYMBOLIC_ICONS,
@ -296,19 +298,31 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
GIMP_CONFIG_PARAM_RESTART);
g_free (path);
GIMP_CONFIG_PROP_STRING (object_class, PROP_THEME,
"theme",
"Theme",
THEME_BLURB,
GIMP_CONFIG_DEFAULT_THEME,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_STRING (object_class, PROP_THEME,
"theme",
"Theme",
THEME_BLURB,
GIMP_CONFIG_DEFAULT_THEME,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_PREFER_DARK_THEME,
"prefer-dark-theme",
"Prefer Dark Theme",
THEME_BLURB,
TRUE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_OVERRIDE_THEME_ICON_SIZE,
"override-theme-icon-size",
"Override theme-set icon sizes",
OVERRIDE_THEME_ICON_SIZE_BLURB,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CUSTOM_ICON_SIZE,
"custom-icon-size",
"Custom icon size",
ICON_SIZE_BLURB,
GIMP_TYPE_ICON_SIZE,
GIMP_ICON_SIZE_MEDIUM,
GIMP_PARAM_STATIC_STRINGS);
path = gimp_config_build_data_path ("icons");
GIMP_CONFIG_PROP_PATH (object_class, PROP_ICON_THEME_PATH,
@ -646,6 +660,12 @@ gimp_gui_config_set_property (GObject *object,
case PROP_PREFER_DARK_THEME:
gui_config->prefer_dark_theme = g_value_get_boolean (value);
break;
case PROP_OVERRIDE_THEME_ICON_SIZE:
gui_config->override_icon_size = g_value_get_boolean (value);
break;
case PROP_CUSTOM_ICON_SIZE:
gui_config->custom_icon_size = g_value_get_enum (value);
break;
case PROP_ICON_THEME_PATH:
g_free (gui_config->icon_theme_path);
gui_config->icon_theme_path = g_value_dup_string (value);
@ -816,6 +836,12 @@ gimp_gui_config_get_property (GObject *object,
case PROP_PREFER_DARK_THEME:
g_value_set_boolean (value, gui_config->prefer_dark_theme);
break;
case PROP_OVERRIDE_THEME_ICON_SIZE:
g_value_set_boolean (value, gui_config->override_icon_size);
break;
case PROP_CUSTOM_ICON_SIZE:
g_value_set_enum (value, gui_config->custom_icon_size);
break;
case PROP_ICON_THEME_PATH:
g_value_set_string (value, gui_config->icon_theme_path);
break;

View File

@ -69,6 +69,8 @@ struct _GimpGuiConfig
gchar *icon_theme_path;
gchar *icon_theme;
gboolean prefer_symbolic_icons;
gboolean override_icon_size;
GimpIconSize custom_icon_size;
gboolean use_help;
gboolean show_help_button;
gchar *help_locales;

View File

@ -540,6 +540,12 @@ _("The name of the theme to use.")
#define ICON_THEME_BLURB \
"The name of the icon theme to use."
#define OVERRIDE_THEME_ICON_SIZE_BLURB \
_("Override theme-set icon sizes.")
#define ICON_SIZE_BLURB \
_("The size of the icons to use.")
#define PREFER_SYMBOLIC_ICONS_BLURB \
_("When enabled, symbolic icons will be preferred if available.")

View File

@ -150,6 +150,12 @@ static void prefs_check_style_callback (GObject *config,
GParamSpec *pspec,
GtkWidget *widget);
static void prefs_gui_config_notify_icon_size (GObject *config,
GParamSpec *pspec,
GtkRange *range);
static void prefs_icon_size_value_changed (GtkRange *range,
GimpGuiConfig *config);
/* private variables */
@ -935,6 +941,39 @@ prefs_check_style_callback (GObject *config,
display_config->transparency_type == GIMP_CHECK_TYPE_CUSTOM_CHECKS);
}
static void
prefs_icon_size_value_changed (GtkRange *range,
GimpGuiConfig *config)
{
gint value = (gint) gtk_range_get_value (range);
g_signal_handlers_block_by_func (config,
G_CALLBACK (prefs_gui_config_notify_icon_size),
range);
g_object_set (G_OBJECT (config),
"custom-icon-size", (GimpIconSize) value,
NULL);
g_signal_handlers_unblock_by_func (config,
G_CALLBACK (prefs_gui_config_notify_icon_size),
range);
}
static void
prefs_gui_config_notify_icon_size (GObject *config,
GParamSpec *pspec,
GtkRange *range)
{
GimpIconSize size = GIMP_GUI_CONFIG (config)->custom_icon_size;
g_signal_handlers_block_by_func (range,
G_CALLBACK (prefs_icon_size_value_changed),
config);
gtk_range_set_value (range, (gdouble) size);
g_signal_handlers_unblock_by_func (range,
G_CALLBACK (prefs_icon_size_value_changed),
config);
}
static void
prefs_format_string_select_callback (GtkListBox *listbox,
GtkListBoxRow *row,
@ -1975,6 +2014,7 @@ prefs_dialog_new (Gimp *gimp,
GtkWidget *scrolled_win;
GtkListStore *list_store;
GtkWidget *view;
GtkWidget *scale;
GtkTreeSelection *sel;
gchar **themes;
gint n_themes;
@ -2044,24 +2084,57 @@ prefs_dialog_new (Gimp *gimp,
g_signal_connect (sel, "changed",
G_CALLBACK (prefs_theme_select_callback),
gimp);
prefs_check_button_add (object, "prefer-dark-theme",
_("Use dark theme variant if available"),
GTK_BOX (vbox2));
/* Override icon sizes. */
button = prefs_check_button_add (object, "override-theme-icon-size",
_("_Override icon sizes set by the theme"),
GTK_BOX (vbox2));
vbox3 = prefs_frame_new (NULL, GTK_CONTAINER (vbox2), FALSE);
g_object_bind_property (button, "active",
vbox3, "sensitive",
G_BINDING_SYNC_CREATE);
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
0.0, 3.0, 1.0);
/* 'draw_value' updates round_digits. So set it first. */
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
gtk_range_set_round_digits (GTK_RANGE (scale), 0.0);
gtk_scale_add_mark (GTK_SCALE (scale), 0.0, GTK_POS_BOTTOM,
_("Small"));
gtk_scale_add_mark (GTK_SCALE (scale), 1.0, GTK_POS_BOTTOM,
_("Medium"));
gtk_scale_add_mark (GTK_SCALE (scale), 2.0, GTK_POS_BOTTOM,
_("Large"));
gtk_scale_add_mark (GTK_SCALE (scale), 3.0, GTK_POS_BOTTOM,
_("Huge"));
gtk_range_set_value (GTK_RANGE (scale),
(gdouble) GIMP_GUI_CONFIG (object)->custom_icon_size);
g_signal_connect (G_OBJECT (scale), "value-changed",
G_CALLBACK (prefs_icon_size_value_changed),
GIMP_GUI_CONFIG (object));
g_signal_connect (G_OBJECT (object), "notify::custom-icon-size",
G_CALLBACK (prefs_gui_config_notify_icon_size),
scale);
gtk_box_pack_start (GTK_BOX (vbox3), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* Reload Current Theme button */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = prefs_button_add (GIMP_ICON_VIEW_REFRESH,
_("Reload C_urrent Theme"),
GTK_BOX (hbox));
g_signal_connect (button, "clicked",
G_CALLBACK (prefs_theme_reload_callback),
gimp);
}
prefs_check_button_add (object, "prefer-dark-theme",
_("Use dark theme variant if available"),
GTK_BOX (vbox2));
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = prefs_button_add (GIMP_ICON_VIEW_REFRESH,
_("Reload C_urrent Theme"),
GTK_BOX (hbox));
g_signal_connect (button, "clicked",
G_CALLBACK (prefs_theme_reload_callback),
gimp);
/****************************/
/* Interface / Icon Theme */
/****************************/

View File

@ -96,6 +96,12 @@ themes_init (Gimp *gimp)
g_signal_connect (config, "notify::prefer-symbolic-icons",
G_CALLBACK (themes_theme_change_notify),
gimp);
g_signal_connect (config, "notify::override-theme-icon-size",
G_CALLBACK (themes_theme_change_notify),
gimp);
g_signal_connect (config, "notify::custom-icon-size",
G_CALLBACK (themes_theme_change_notify),
gimp);
themes_theme_change_notify (config, NULL, gimp);
}
@ -321,10 +327,60 @@ themes_apply_theme (Gimp *gimp,
"\n"
"* { -gtk-icon-style: %s; }\n"
"\n"
"%s"
"/* end of theme.css */\n",
"%s",
config->prefer_symbolic_icons ? "symbolic" : "regular",
config->prefer_dark_theme ? "/* prefer-dark-theme */\n\n" : "");
config->prefer_dark_theme ? "/* prefer-dark-theme */\n" : "");
}
if (! error && config->override_icon_size)
{
const gchar *tool_icon_size = "large-toolbar";
const gchar *tab_icon_size = "small-toolbar";
const gchar *button_icon_size = "small-toolbar";
switch (config->custom_icon_size)
{
case GIMP_ICON_SIZE_SMALL:
tool_icon_size = "small-toolbar";
tab_icon_size = "small-toolbar";
button_icon_size = "small-toolbar";
break;
case GIMP_ICON_SIZE_MEDIUM:
tool_icon_size = "large-toolbar";
tab_icon_size = "small-toolbar";
button_icon_size = "small-toolbar";
break;
case GIMP_ICON_SIZE_LARGE:
tool_icon_size = "dnd";
tab_icon_size = "large-toolbar";
button_icon_size = "large-toolbar";
break;
case GIMP_ICON_SIZE_HUGE:
tool_icon_size = "dialog";
tab_icon_size = "dnd";
button_icon_size = "dnd";
break;
}
g_output_stream_printf (
output, NULL, NULL, &error,
"\n"
"* { -GimpToolPalette-tool-icon-size: %s; }"
"\n"
"* { -GimpDockbook-tab-icon-size: %s; }"
"\n"
"* { -GimpEditor-button-icon-size: %s; }",
tool_icon_size,
tab_icon_size,
button_icon_size);
}
if (! error)
{
g_output_stream_printf (
output, NULL, NULL, &error,
"\n\n"
"/* end of theme.css */\n");
}
if (error)

View File

@ -159,6 +159,8 @@ gimp_color_editor_init (GimpColorEditor *editor)
GimpHSV hsv;
GList *list;
GSList *group;
gint icon_width = 40;
gint icon_height = 38;
editor->context = NULL;
editor->edit_bg = FALSE;
@ -241,6 +243,10 @@ gimp_color_editor_init (GimpColorEditor *editor)
/* FG/BG editor */
editor->fg_bg = gimp_fg_bg_editor_new (NULL);
gtk_icon_size_lookup (button_icon_size, &icon_width, &icon_height);
gtk_widget_set_size_request (editor->fg_bg,
(gint) (icon_width * 1.75),
(gint) (icon_height * 1.75));
gtk_box_pack_start (GTK_BOX (hbox), editor->fg_bg, FALSE, FALSE, 0);
gtk_widget_show (editor->fg_bg);
@ -438,6 +444,10 @@ gimp_color_editor_set_context (GimpDocked *docked,
gimp_color_editor_bg_changed,
editor);
g_signal_handlers_disconnect_by_func (editor->context->gimp->config,
G_CALLBACK (gimp_color_editor_style_updated),
editor);
g_object_unref (editor->context);
}
@ -456,6 +466,19 @@ gimp_color_editor_set_context (GimpDocked *docked,
G_CALLBACK (gimp_color_editor_bg_changed),
editor);
g_signal_connect_object (editor->context->gimp->config,
"notify::theme",
G_CALLBACK (gimp_color_editor_style_updated),
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (context->gimp->config,
"notify::override-theme-icon-size",
G_CALLBACK (gimp_color_editor_style_updated),
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (context->gimp->config,
"notify::custom-icon-size",
G_CALLBACK (gimp_color_editor_style_updated),
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
if (editor->edit_bg)
{
gimp_context_get_background (editor->context, &rgb);
@ -492,11 +515,22 @@ static void
gimp_color_editor_style_updated (GtkWidget *widget)
{
GimpColorEditor *editor = GIMP_COLOR_EDITOR (widget);
GtkIconSize button_icon_size;
gint icon_width = 40;
gint icon_height = 38;
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
if (editor->hbox)
gimp_editor_set_box_style (GIMP_EDITOR (editor), GTK_BOX (editor->hbox));
gtk_widget_style_get (GTK_WIDGET (editor),
"button-icon-size", &button_icon_size,
NULL);
gtk_icon_size_lookup (button_icon_size, &icon_width, &icon_height);
gtk_widget_set_size_request (editor->fg_bg,
(gint) (icon_width * 1.75),
(gint) (icon_height * 1.75));
}

View File

@ -95,6 +95,7 @@ struct _GimpDockbookPrivate
static void gimp_dockbook_finalize (GObject *object);
static void gimp_dockbook_style_updated (GtkWidget *widget);
static void gimp_dockbook_drag_begin (GtkWidget *widget,
GdkDragContext *context);
static void gimp_dockbook_drag_end (GtkWidget *widget,
@ -133,6 +134,7 @@ static void gimp_dockbook_menu_end (GimpDockable *dockable);
static void gimp_dockbook_tab_locked_notify (GimpDockable *dockable,
GParamSpec *pspec,
GimpDockbook *dockbook);
static void gimp_dockbook_help_func (const gchar *help_id,
gpointer help_data);
@ -184,6 +186,7 @@ gimp_dockbook_class_init (GimpDockbookClass *klass)
object_class->finalize = gimp_dockbook_finalize;
widget_class->style_updated = gimp_dockbook_style_updated;
widget_class->drag_begin = gimp_dockbook_drag_begin;
widget_class->drag_end = gimp_dockbook_drag_end;
widget_class->drag_motion = gimp_dockbook_drag_motion;
@ -263,6 +266,36 @@ gimp_dockbook_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_dockbook_style_updated (GtkWidget *widget)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
GimpContext *context;
GtkWidget *tab_widget;
GList *children;
GList *iter;
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
if (! dockbook->p->dock ||
! (context = gimp_dock_get_context (dockbook->p->dock)))
return;
children = gtk_container_get_children (GTK_CONTAINER (dockbook));
for (iter = children; iter; iter = g_list_next (iter))
{
GimpDockable *dockable = GIMP_DOCKABLE (iter->data);
tab_widget = gimp_dockbook_create_tab_widget (dockbook, dockable);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (dockbook),
GTK_WIDGET (dockable),
tab_widget);
}
g_list_free (children);
gimp_dock_invalidate_geometry (GIMP_DOCK (dockbook->p->dock));
}
static void
gimp_dockbook_drag_begin (GtkWidget *widget,
GdkDragContext *context)
@ -693,10 +726,37 @@ void
gimp_dockbook_set_dock (GimpDockbook *dockbook,
GimpDock *dock)
{
GimpContext *context;
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
g_return_if_fail (dock == NULL || GIMP_IS_DOCK (dock));
if (dockbook->p->dock &&
(context = gimp_dock_get_context (dockbook->p->dock)) != NULL)
{
g_signal_handlers_disconnect_by_func (GIMP_GUI_CONFIG (context->gimp->config),
G_CALLBACK (gimp_dockbook_style_updated),
dockbook);
}
dockbook->p->dock = dock;
if (dockbook->p->dock &&
(context = gimp_dock_get_context (dockbook->p->dock)) != NULL)
{
g_signal_connect_object (GIMP_GUI_CONFIG (context->gimp->config),
"notify::theme",
G_CALLBACK (gimp_dockbook_style_updated),
dockbook, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (GIMP_GUI_CONFIG (context->gimp->config),
"notify::override-theme-icon-size",
G_CALLBACK (gimp_dockbook_style_updated),
dockbook, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (GIMP_GUI_CONFIG (context->gimp->config),
"notify::custom-icon-size",
G_CALLBACK (gimp_dockbook_style_updated),
dockbook, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
}
}
GimpUIManager *

View File

@ -244,6 +244,19 @@ gimp_editor_constructed (GObject *object)
gimp_menu_factory_manager_new (editor->priv->menu_factory,
editor->priv->menu_identifier,
editor->priv->popup_data);
g_signal_connect_object (editor->priv->ui_manager->gimp->config,
"notify::theme",
G_CALLBACK (gimp_editor_style_updated),
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (editor->priv->ui_manager->gimp->config,
"notify::override-theme-icon-size",
G_CALLBACK (gimp_editor_style_updated),
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (editor->priv->ui_manager->gimp->config,
"notify::custom-icon-size",
G_CALLBACK (gimp_editor_style_updated),
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
}
}
@ -430,12 +443,27 @@ gimp_editor_create_menu (GimpEditor *editor,
if (editor->priv->ui_manager)
{
g_signal_handlers_disconnect_by_func (editor->priv->ui_manager->gimp->config,
G_CALLBACK (gimp_editor_style_updated),
editor);
g_object_unref (editor->priv->ui_manager);
}
editor->priv->ui_manager = gimp_menu_factory_manager_new (menu_factory,
menu_identifier,
popup_data);
g_signal_connect_object (editor->priv->ui_manager->gimp->config,
"notify::theme",
G_CALLBACK (gimp_editor_style_updated),
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (editor->priv->ui_manager->gimp->config,
"notify::override-theme-icon-size",
G_CALLBACK (gimp_editor_style_updated),
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (editor->priv->ui_manager->gimp->config,
"notify::custom-icon-size",
G_CALLBACK (gimp_editor_style_updated),
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
if (editor->priv->ui_path)
g_free (editor->priv->ui_path);
@ -786,16 +814,23 @@ gimp_editor_set_box_style (GimpEditor *editor,
child = gtk_bin_get_child (GTK_BIN (list->data));
if (GTK_IS_IMAGE (child))
if (GTK_IS_IMAGE (child) &&
gtk_image_get_storage_type (GTK_IMAGE (child)) == GTK_IMAGE_ICON_NAME)
{
GtkIconSize old_size;
const gchar *icon_name;
const gchar *old_icon_name;
gtk_image_get_icon_name (GTK_IMAGE (child), &icon_name, &old_size);
gtk_image_get_icon_name (GTK_IMAGE (child), &old_icon_name, &old_size);
if (button_icon_size != old_size)
gtk_image_set_from_icon_name (GTK_IMAGE (child),
icon_name, button_icon_size);
{
gchar *icon_name;
icon_name = g_strdup (old_icon_name);
gtk_image_set_from_icon_name (GTK_IMAGE (child),
icon_name, button_icon_size);
g_free (icon_name);
}
}
}
}

View File

@ -72,6 +72,9 @@ struct _GimpItemTreeViewPrivate
GtkWidget *options_box;
GtkSizeGroup *options_group;
GtkWidget *eye_header_image;
GtkWidget *lock_header_image;
GimpItem *lock_box_item;
GtkTreePath *lock_box_path;
GtkWidget *lock_popover;
@ -374,7 +377,8 @@ gimp_item_tree_view_constructed (GObject *object)
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (object);
GtkTreeViewColumn *column;
GtkWidget *image;
GtkIconSize button_icon_size;
GtkIconSize button_icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
gint pixel_icon_size = 16;
gint button_spacing;
G_OBJECT_CLASS (parent_class)->constructed (object);
@ -385,6 +389,7 @@ gimp_item_tree_view_constructed (GObject *object)
"button-icon-size", &button_icon_size,
"button-spacing", &button_spacing,
NULL);
gtk_icon_size_lookup (button_icon_size, &pixel_icon_size, NULL);
gimp_container_tree_view_connect_name_edited (tree_view,
G_CALLBACK (gimp_item_tree_view_name_edited),
@ -403,11 +408,13 @@ gimp_item_tree_view_constructed (GObject *object)
gtk_tree_view_column_set_widget (column, image);
gtk_widget_show (image);
gtk_tree_view_insert_column (tree_view->view, column, 0);
item_view->priv->eye_header_image = image;
item_view->priv->eye_cell = gimp_cell_renderer_toggle_new (GIMP_ICON_VISIBLE);
g_object_set (item_view->priv->eye_cell,
"xpad", 0,
"ypad", 0,
"icon-size", pixel_icon_size,
"override-background", TRUE,
NULL);
gtk_tree_view_column_pack_start (column, item_view->priv->eye_cell, FALSE);
@ -432,11 +439,13 @@ gimp_item_tree_view_constructed (GObject *object)
gtk_tree_view_column_set_widget (column, image);
gtk_widget_show (image);
gtk_tree_view_insert_column (tree_view->view, column, 1);
item_view->priv->lock_header_image = image;
item_view->priv->lock_cell = gimp_cell_renderer_toggle_new (GIMP_ICON_LOCK_MULTI);
g_object_set (item_view->priv->lock_cell,
"xpad", 0,
"ypad", 0,
"xpad", 0,
"ypad", 0,
"icon-size", pixel_icon_size,
NULL);
gtk_tree_view_column_pack_start (column, item_view->priv->lock_cell, FALSE);
gtk_tree_view_column_set_attributes (column, item_view->priv->lock_cell,
@ -606,11 +615,16 @@ gimp_item_tree_view_style_updated (GtkWidget *widget)
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (widget);
GList *children;
GList *list;
const gchar *old_icon_name;
gchar *icon_name;
GtkReliefStyle button_relief;
GtkIconSize button_icon_size;
GtkIconSize old_size;
GtkIconSize button_icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
gint pixel_icon_size = 16;
gint content_spacing;
gint button_spacing;
gtk_widget_style_get (widget,
"button-relief", &button_relief,
"button-icon-size", &button_icon_size,
@ -658,14 +672,17 @@ gimp_item_tree_view_style_updated (GtkWidget *widget)
if (GTK_IS_IMAGE (image))
{
GtkIconSize old_size;
const gchar *icon_name;
gtk_image_get_icon_name (GTK_IMAGE (image),
&icon_name, &old_size);
&old_icon_name, &old_size);
if (button_icon_size != old_size)
gtk_image_set_from_icon_name (GTK_IMAGE (image),
icon_name, button_icon_size);
{
icon_name = g_strdup (old_icon_name);
gtk_image_set_from_icon_name (GTK_IMAGE (image),
icon_name, button_icon_size);
g_free (icon_name);
}
}
}
}
@ -673,12 +690,36 @@ gimp_item_tree_view_style_updated (GtkWidget *widget)
g_list_free (children);
}
/* force the toggle cells to recreate their icon */
gtk_image_get_icon_name (GTK_IMAGE (view->priv->lock_header_image),
&old_icon_name, &old_size);
if (button_icon_size != old_size)
{
icon_name = g_strdup (old_icon_name);
gtk_image_set_from_icon_name (GTK_IMAGE (view->priv->lock_header_image),
icon_name, button_icon_size);
g_free (icon_name);
}
gtk_image_get_icon_name (GTK_IMAGE (view->priv->eye_header_image),
&old_icon_name, &old_size);
if (button_icon_size != old_size)
{
icon_name = g_strdup (old_icon_name);
gtk_image_set_from_icon_name (GTK_IMAGE (view->priv->eye_header_image),
icon_name, button_icon_size);
g_free (icon_name);
}
/* force the eye and toggle cells to recreate their icon */
gtk_icon_size_lookup (button_icon_size, &pixel_icon_size, NULL);
g_object_set (view->priv->eye_cell,
"icon-name", GIMP_ICON_VISIBLE,
"icon-size", pixel_icon_size,
NULL);
g_object_set (view->priv->lock_cell,
"icon-name", GIMP_ICON_LOCK_MULTI,
"icon-size", pixel_icon_size,
NULL);
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
@ -1099,6 +1140,9 @@ gimp_item_tree_view_set_context (GimpContainerView *view,
g_signal_handlers_disconnect_by_func (old_context,
gimp_item_tree_view_set_image,
item_view);
g_signal_handlers_disconnect_by_func (old_context->gimp->config,
G_CALLBACK (gimp_item_tree_view_style_updated),
item_view);
}
parent_view_iface->set_context (view, context);
@ -1112,6 +1156,19 @@ gimp_item_tree_view_set_context (GimpContainerView *view,
G_CALLBACK (gimp_item_tree_view_set_image),
item_view);
g_signal_connect_object (context->gimp->config,
"notify::theme",
G_CALLBACK (gimp_item_tree_view_style_updated),
item_view, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (context->gimp->config,
"notify::override-theme-icon-size",
G_CALLBACK (gimp_item_tree_view_style_updated),
item_view, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (context->gimp->config,
"notify::custom-icon-size",
G_CALLBACK (gimp_item_tree_view_style_updated),
item_view, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
image = gimp_context_get_image (context);
}

View File

@ -39,6 +39,7 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimpimage.h"
@ -77,6 +78,7 @@ struct _GimpLayerTreeViewPrivate
GtkWidget *link_button;
GtkWidget *link_popover;
GtkWidget *new_link_button;
GtkWidget *link_list;
GtkWidget *link_entry;
GtkWidget *link_search_entry;
@ -102,6 +104,8 @@ static void gimp_layer_tree_view_view_iface_init (GimpContainer
static void gimp_layer_tree_view_constructed (GObject *object);
static void gimp_layer_tree_view_finalize (GObject *object);
static void gimp_layer_tree_view_style_updated (GtkWidget *widget);
static void gimp_layer_tree_view_set_container (GimpContainerView *view,
GimpContainer *container);
static void gimp_layer_tree_view_set_context (GimpContainerView *view,
@ -218,13 +222,17 @@ gimp_layer_tree_view_class_init (GimpLayerTreeViewClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpContainerTreeViewClass *tree_view_class;
GimpItemTreeViewClass *item_view_class;
GtkWidgetClass *widget_class;
widget_class = GTK_WIDGET_CLASS (klass);
tree_view_class = GIMP_CONTAINER_TREE_VIEW_CLASS (klass);
item_view_class = GIMP_ITEM_TREE_VIEW_CLASS (klass);
object_class->constructed = gimp_layer_tree_view_constructed;
object_class->finalize = gimp_layer_tree_view_finalize;
widget_class->style_updated = gimp_layer_tree_view_style_updated;
tree_view_class->drop_possible = gimp_layer_tree_view_drop_possible;
tree_view_class->drop_color = gimp_layer_tree_view_drop_color;
tree_view_class->drop_uri_list = gimp_layer_tree_view_drop_uri_list;
@ -513,6 +521,7 @@ gimp_layer_tree_view_constructed (GObject *object)
G_CALLBACK (gimp_layer_tree_view_new_link_clicked),
layer_view);
gtk_widget_show (button);
layer_view->priv->new_link_button = button;
/* Enter on any entry activates the link creation then exits in case
* of success.
@ -564,6 +573,50 @@ gimp_layer_tree_view_finalize (GObject *object)
}
/* GimpWidget methods */
static void
gimp_layer_tree_view_style_updated (GtkWidget *widget)
{
GimpLayerTreeView *view = GIMP_LAYER_TREE_VIEW (widget);
GtkWidget *image;
const gchar *old_icon_name;
GtkReliefStyle button_relief;
GtkIconSize old_size;
GtkIconSize button_size;
gtk_widget_style_get (widget,
"button-relief", &button_relief,
"button-icon-size", &button_size,
NULL);
gtk_button_set_relief (GTK_BUTTON (view->priv->link_button),
button_relief);
image = gtk_button_get_image (GTK_BUTTON (view->priv->link_button));
gtk_image_get_icon_name (GTK_IMAGE (image), &old_icon_name, &old_size);
if (button_size != old_size)
{
gchar *icon_name;
/* Changing the link button in dockable button box. */
icon_name = g_strdup (old_icon_name);
gtk_image_set_from_icon_name (GTK_IMAGE (image),
icon_name, button_size);
g_free (icon_name);
/* Changing the new link button inside the popover. */
image = gtk_button_get_image (GTK_BUTTON (view->priv->new_link_button));
gtk_image_get_icon_name (GTK_IMAGE (image), &old_icon_name, &old_size);
icon_name = g_strdup (old_icon_name);
gtk_image_set_from_icon_name (GTK_IMAGE (image),
icon_name, button_size);
g_free (icon_name);
}
}
/* GimpContainerView methods */
static void
@ -651,9 +704,35 @@ gimp_layer_tree_view_set_context (GimpContainerView *view,
{
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
GimpLayerTreeView *layer_view = GIMP_LAYER_TREE_VIEW (view);
GimpContext *old_context;
old_context = gimp_container_view_get_context (view);
if (old_context)
{
g_signal_handlers_disconnect_by_func (old_context->gimp->config,
G_CALLBACK (gimp_layer_tree_view_style_updated),
view);
}
parent_view_iface->set_context (view, context);
if (context)
{
g_signal_connect_object (context->gimp->config,
"notify::theme",
G_CALLBACK (gimp_layer_tree_view_style_updated),
view, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (context->gimp->config,
"notify::override-theme-icon-size",
G_CALLBACK (gimp_layer_tree_view_style_updated),
view, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (context->gimp->config,
"notify::custom-icon-size",
G_CALLBACK (gimp_layer_tree_view_style_updated),
view, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
}
if (tree_view->model)
{
SetContextForeachData context_data = { layer_view->priv->model_column_mask,

View File

@ -656,6 +656,14 @@ toolbox_create_color_area (GimpToolbox *toolbox,
"notify::theme",
G_CALLBACK (gimp_toolbox_notify_theme),
toolbox);
g_signal_connect_after (GIMP_GUI_CONFIG (toolbox->p->context->gimp->config),
"notify::override-theme-icon-size",
G_CALLBACK (gimp_toolbox_notify_theme),
toolbox);
g_signal_connect_after (GIMP_GUI_CONFIG (toolbox->p->context->gimp->config),
"notify::custom-icon-size",
G_CALLBACK (gimp_toolbox_notify_theme),
toolbox);
return col_area;
}

View File

@ -78,10 +78,6 @@ static void gimp_tool_palette_height_for_width (GtkWidget *widget,
gint *pref_height);
static void gimp_tool_palette_style_updated (GtkWidget *widget);
static void gimp_tool_palette_notify_theme (GimpGuiConfig *config,
GParamSpec *pspec,
GimpToolPalette *palette);
static void gimp_tool_palette_tool_add (GimpContainer *container,
GimpToolItem *tool_item,
GimpToolPalette *palette);
@ -302,14 +298,6 @@ gimp_tool_palette_style_updated (GtkWidget *widget)
gimp_dock_invalidate_geometry (GIMP_DOCK (private->toolbox));
}
static void
gimp_tool_palette_notify_theme (GimpGuiConfig *config,
GParamSpec *pspec,
GimpToolPalette *palette)
{
gimp_tool_palette_style_updated (GTK_WIDGET (palette));
}
/* public functions */
@ -361,10 +349,18 @@ gimp_tool_palette_set_toolbox (GimpToolPalette *palette,
G_CALLBACK (gimp_tool_palette_tool_reorder),
palette, 0);
g_signal_connect_after (GIMP_GUI_CONFIG (context->gimp->config),
"notify::theme",
G_CALLBACK (gimp_tool_palette_notify_theme),
palette);
g_signal_connect_object (GIMP_GUI_CONFIG (context->gimp->config),
"notify::theme",
G_CALLBACK (gimp_tool_palette_style_updated),
palette, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (GIMP_GUI_CONFIG (context->gimp->config),
"notify::override-theme-icon-size",
G_CALLBACK (gimp_tool_palette_style_updated),
palette, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_object (GIMP_GUI_CONFIG (context->gimp->config),
"notify::custom-icon-size",
G_CALLBACK (gimp_tool_palette_style_updated),
palette, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
}
gboolean