From 33fce2af2abdd75a0569c9ae9d6dc6f7dd518d5a Mon Sep 17 00:00:00 2001 From: deepend-tildeclub Date: Sun, 22 Mar 2026 10:39:07 -0600 Subject: [PATCH] Refresh GTK3 theme changes live --- .../test-theme-preferences-gtk3-populate.c | 6 ++++++ src/fe-gtk/theme/theme-preferences.c | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/fe-gtk/theme/tests/test-theme-preferences-gtk3-populate.c b/src/fe-gtk/theme/tests/test-theme-preferences-gtk3-populate.c index 6f4b1059..38c43167 100644 --- a/src/fe-gtk/theme/tests/test-theme-preferences-gtk3-populate.c +++ b/src/fe-gtk/theme/tests/test-theme-preferences-gtk3-populate.c @@ -102,6 +102,12 @@ theme_manager_save_preferences (void) return TRUE; } +void +theme_manager_dispatch_changed (ThemeChangedReason reasons) +{ + (void)reasons; +} + ThemePaletteBehavior theme_manager_get_userlist_palette_behavior (const PangoFontDescription *font_desc) { diff --git a/src/fe-gtk/theme/theme-preferences.c b/src/fe-gtk/theme/theme-preferences.c index 9b49a43e..bc557326 100644 --- a/src/fe-gtk/theme/theme-preferences.c +++ b/src/fe-gtk/theme/theme-preferences.c @@ -1350,6 +1350,19 @@ theme_preferences_gtk3_sync_remove_state (theme_preferences_ui *ui) gtk_widget_set_sensitive (ui->gtk3_remove, source == ZOITECHAT_GTK3_THEME_SOURCE_USER); } +static gboolean +theme_preferences_gtk3_apply_and_refresh (GError **error) +{ + if (!theme_gtk3_apply_current (error)) + return FALSE; + theme_manager_dispatch_changed (THEME_CHANGED_REASON_THEME_PACK | + THEME_CHANGED_REASON_PALETTE | + THEME_CHANGED_REASON_WIDGET_STYLE | + THEME_CHANGED_REASON_USERLIST | + THEME_CHANGED_REASON_MODE); + return TRUE; +} + static void theme_preferences_gtk3_changed_cb (GtkComboBox *combo, gpointer user_data) { @@ -1380,7 +1393,7 @@ theme_preferences_gtk3_changed_cb (GtkComboBox *combo, gpointer user_data) ui->setup_prefs->hex_gui_gtk3_variant = prefs.hex_gui_gtk3_variant; } - if (selection_changed && !theme_gtk3_apply_current (&error)) + if (selection_changed && !theme_preferences_gtk3_apply_and_refresh (&error)) { theme_preferences_show_message (ui, GTK_MESSAGE_ERROR, error ? error->message : _("Failed to apply GTK3 theme.")); @@ -1557,7 +1570,7 @@ theme_preferences_populate_gtk3 (theme_preferences_ui *ui) g_free (final_id); } - if (should_apply && !theme_gtk3_apply_current (&error)) + if (should_apply && !theme_preferences_gtk3_apply_and_refresh (&error)) { theme_preferences_show_message (ui, GTK_MESSAGE_ERROR, error ? error->message : _("Failed to apply GTK3 theme."));