From 3e465498802d33989a19ae1bde31672b8eae31f2 Mon Sep 17 00:00:00 2001 From: Jehan Date: Sat, 7 Jun 2025 16:29:09 +0200 Subject: [PATCH] app: small ordering cleanup. No functional change, just some include cleanup, as well as reordering with a private function made public. Also adding a comment saying why we have somewhat unrelated code (about color-scheme) in gui-unique.c. Maybe eventually we should generalize this message-handling invible window code into a separate file, if it becomes further used for more message handling. --- app/gui/gui-unique.c | 8 ++++- app/gui/themes.c | 77 ++++++++++++++++++++++---------------------- app/gui/themes.h | 22 +++++++------ 3 files changed, 57 insertions(+), 50 deletions(-) diff --git a/app/gui/gui-unique.c b/app/gui/gui-unique.c index f2eb9fad03..eff19c9e7d 100644 --- a/app/gui/gui-unique.c +++ b/app/gui/gui-unique.c @@ -30,6 +30,8 @@ #include "gui/gui-types.h" +#include "config/gimpguiconfig.h" + #include "core/gimp.h" #include "core/gimpcontainer.h" @@ -41,7 +43,6 @@ #include "gimpdbusservice.h" #include "gui-unique.h" -#include "config/gimpguiconfig.h" #include "themes.h" @@ -205,6 +206,11 @@ gui_unique_win32_message_handler (HWND hWnd, return TRUE; case WM_SETTINGCHANGE: + /* This message is not about the unique GUI code, but we reuse the + * existing top-level (hidden) window used for receiving messages + * for other purposes too, such as color scheme in this case. + * See !2308. + */ if (lParam != 0 && lstrcmpW((LPCWSTR)lParam, L"ImmersiveColorSet") == 0) { themes_theme_change_notify (GIMP_GUI_CONFIG (unique_gimp->config), NULL, unique_gimp); diff --git a/app/gui/themes.c b/app/gui/themes.c index d9691f643c..a50c589571 100644 --- a/app/gui/themes.c +++ b/app/gui/themes.c @@ -276,6 +276,44 @@ themes_get_theme_file (Gimp *gimp, return file; } +void +themes_theme_change_notify (GimpGuiConfig *config, + GParamSpec *pspec, + Gimp *gimp) +{ + GFile *theme_css; + GError *error = NULL; + + g_object_set (gtk_settings_get_for_screen (gdk_screen_get_default ()), + "gtk-application-prefer-dark-theme", + config->theme_scheme != GIMP_THEME_LIGHT, + NULL); + + themes_apply_theme (gimp, config); + + theme_css = gimp_directory_file ("theme.css", NULL); + + if (gimp->be_verbose) + g_print ("Parsing '%s'\n", + gimp_file_get_utf8_name (theme_css)); + + if (! gtk_css_provider_load_from_file (GTK_CSS_PROVIDER (themes_style_provider), + theme_css, &error)) + { + g_printerr ("%s: error parsing %s: %s\n", G_STRFUNC, + gimp_file_get_utf8_name (theme_css), error->message); + g_clear_error (&error); + } + + g_object_unref (theme_css); + + gtk_style_context_reset_widgets (gdk_screen_get_default ()); + +#ifdef G_OS_WIN32 + themes_set_title_bar (gimp); +#endif +} + /* private functions */ @@ -713,44 +751,6 @@ themes_name_compare (const void *p1, return strcmp (* (char **) p1, * (char **) p2); } -void -themes_theme_change_notify (GimpGuiConfig *config, - GParamSpec *pspec, - Gimp *gimp) -{ - GFile *theme_css; - GError *error = NULL; - - g_object_set (gtk_settings_get_for_screen (gdk_screen_get_default ()), - "gtk-application-prefer-dark-theme", - config->theme_scheme != GIMP_THEME_LIGHT, - NULL); - - themes_apply_theme (gimp, config); - - theme_css = gimp_directory_file ("theme.css", NULL); - - if (gimp->be_verbose) - g_print ("Parsing '%s'\n", - gimp_file_get_utf8_name (theme_css)); - - if (! gtk_css_provider_load_from_file (GTK_CSS_PROVIDER (themes_style_provider), - theme_css, &error)) - { - g_printerr ("%s: error parsing %s: %s\n", G_STRFUNC, - gimp_file_get_utf8_name (theme_css), error->message); - g_clear_error (&error); - } - - g_object_unref (theme_css); - - gtk_style_context_reset_widgets (gdk_screen_get_default ()); - -#ifdef G_OS_WIN32 - themes_set_title_bar (gimp); -#endif -} - static void themes_theme_paths_notify (GimpExtensionManager *manager, GParamSpec *pspec, @@ -892,5 +892,4 @@ themes_win32_is_darkmode_active (void) return status == ERROR_SUCCESS && val == 0; } - #endif diff --git a/app/gui/themes.h b/app/gui/themes.h index 24b778706c..155d150d10 100644 --- a/app/gui/themes.h +++ b/app/gui/themes.h @@ -18,21 +18,23 @@ #ifndef __THEMES_H__ #define __THEMES_H__ -void themes_init (Gimp *gimp); -void themes_exit (Gimp *gimp); +void themes_init (Gimp *gimp); +void themes_exit (Gimp *gimp); + +gchar ** themes_list_themes (Gimp *gimp, + gint *n_themes); +GFile * themes_get_theme_dir (Gimp *gimp, + const gchar *theme_name); +GFile * themes_get_theme_file (Gimp *gimp, + const gchar *first_component, + ...) G_GNUC_NULL_TERMINATED; -gchar ** themes_list_themes (Gimp *gimp, - gint *n_themes); -GFile * themes_get_theme_dir (Gimp *gimp, - const gchar *theme_name); -GFile * themes_get_theme_file (Gimp *gimp, - const gchar *first_component, - ...) G_GNUC_NULL_TERMINATED; void themes_theme_change_notify (GimpGuiConfig *config, GParamSpec *pspec, Gimp *gimp); + #ifdef G_OS_WIN32 -void themes_set_title_bar (Gimp *gimp); +void themes_set_title_bar (Gimp *gimp); #endif #endif /* __THEMES_H__ */