From b6be63eae3a823d28f0114be44e1359876161cff Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Wed, 4 Dec 2024 23:25:06 +0000 Subject: [PATCH] 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. --- app/display/gimpdisplayshell.c | 9 +++++++++ app/display/gimpstatusbar.c | 17 +++++++++++++++-- app/display/gimpstatusbar.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 57d5120c0e..dfb17b9233 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -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 diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c index c87f27cae6..3f450572e4 100644 --- a/app/display/gimpstatusbar.c +++ b/app/display/gimpstatusbar.c @@ -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, diff --git a/app/display/gimpstatusbar.h b/app/display/gimpstatusbar.h index 398cb1c453..525bc19f6d 100644 --- a/app/display/gimpstatusbar.h +++ b/app/display/gimpstatusbar.h @@ -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;