app/display: Connect GimpStatusBar to icon size changes

Inspired by Mark Sweeney's work.
This patch passes the user-defined button
icon size from GimpDisplayShell to
GimpStatusBar, and updates the
Soft Proofing button and current tool
icon sizes based off of it.
This commit is contained in:
Alx Sa 2024-12-04 23:25:06 +00:00
parent 5eb9b6ac4b
commit b6be63eae3
3 changed files with 25 additions and 2 deletions

View file

@ -760,6 +760,7 @@ gimp_display_shell_constructed (GObject *object)
gimp_statusbar_set_shell (GIMP_STATUSBAR (shell->statusbar), shell);
gimp_help_set_help_data (shell->statusbar, NULL,
GIMP_HELP_IMAGE_WINDOW_STATUS_BAR);
GIMP_STATUSBAR (shell->statusbar)->icon_size = button_icon_size;
/* pack all the widgets */
gtk_grid_attach (GTK_GRID (grid), shell->origin, 0, 0, 1, 1);
@ -1035,6 +1036,14 @@ gimp_display_shell_style_updated (GtkWidget *widget)
gtk_image_set_pixel_size (GTK_IMAGE (children->data), pixel_size);
g_list_free (children);
}
if (shell->statusbar)
{
GimpStatusbar *statusbar = GIMP_STATUSBAR (shell->statusbar);
statusbar->icon_size = icon_size;
GTK_WIDGET_GET_CLASS (statusbar)->style_updated (GTK_WIDGET (statusbar));
}
}
static void

View file

@ -670,11 +670,20 @@ gimp_statusbar_style_updated (GtkWidget *widget)
{
GimpStatusbar *statusbar = GIMP_STATUSBAR (widget);
PangoLayout *layout;
GList *children;
gint pixel_size;
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
gtk_icon_size_lookup (statusbar->icon_size, &pixel_size, NULL);
g_clear_pointer (&statusbar->icon_hash, g_hash_table_unref);
children =
gtk_container_get_children (GTK_CONTAINER (statusbar->soft_proof_button));
gtk_image_set_pixel_size (GTK_IMAGE (children->data), pixel_size);
g_list_free (children);
layout = gtk_widget_create_pango_layout (widget, " ");
pango_layout_get_pixel_size (layout, &statusbar->icon_space_width, NULL);
g_object_unref (layout);
@ -2405,6 +2414,7 @@ gimp_statusbar_load_icon (GimpStatusbar *statusbar,
const gchar *icon_name)
{
GdkPixbuf *icon;
gint pixel_size;
if (G_UNLIKELY (! statusbar->icon_hash))
{
@ -2420,10 +2430,13 @@ gimp_statusbar_load_icon (GimpStatusbar *statusbar,
if (icon)
return g_object_ref (icon);
icon = gimp_widget_load_icon (statusbar->label, icon_name, 16);
gtk_icon_size_lookup (statusbar->icon_size, &pixel_size, NULL);
icon = gimp_widget_load_icon (statusbar->label, icon_name,
pixel_size);
/* this is not optimal but so what */
if (g_hash_table_size (statusbar->icon_hash) > 16)
if (g_hash_table_size (statusbar->icon_hash) > pixel_size)
g_hash_table_remove_all (statusbar->icon_hash);
g_hash_table_insert (statusbar->icon_hash,

View file

@ -53,6 +53,7 @@ struct _GimpStatusbar
GdkPixbuf *icon;
GHashTable *icon_hash;
gint icon_space_width;
GtkIconSize icon_size;
guint temp_context_id;
guint temp_timeout_id;