mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-06-10 17:00:18 +00:00
Fix GTK3 theme background refresh/saving
This commit is contained in:
@@ -107,12 +107,23 @@ theme_manager_reset_mode_colors (unsigned int mode, gboolean *palette_changed)
|
|||||||
*palette_changed = FALSE;
|
*palette_changed = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
theme_runtime_clear_gtk_mapped_custom_tokens (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
theme_manager_save_preferences (void)
|
theme_manager_save_preferences (void)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
theme_manager_apply_to_window (GtkWidget *window)
|
||||||
|
{
|
||||||
|
(void)window;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
theme_manager_dispatch_changed (ThemeChangedReason reasons)
|
theme_manager_dispatch_changed (ThemeChangedReason reasons)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,9 +88,15 @@ theme_application_apply_toplevel_theme (gboolean dark)
|
|||||||
gboolean
|
gboolean
|
||||||
theme_application_apply_mode (unsigned int mode, gboolean *palette_changed)
|
theme_application_apply_mode (unsigned int mode, gboolean *palette_changed)
|
||||||
{
|
{
|
||||||
|
static gboolean runtime_loaded = FALSE;
|
||||||
gboolean dark;
|
gboolean dark;
|
||||||
|
|
||||||
theme_runtime_load ();
|
if (!runtime_loaded)
|
||||||
|
{
|
||||||
|
theme_runtime_load ();
|
||||||
|
runtime_loaded = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
dark = theme_runtime_apply_mode (mode, palette_changed);
|
dark = theme_runtime_apply_mode (mode, palette_changed);
|
||||||
theme_application_apply_toplevel_theme (dark);
|
theme_application_apply_toplevel_theme (dark);
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "theme-gtk3.h"
|
#include "theme-gtk3.h"
|
||||||
#include "theme-manager.h"
|
#include "theme-manager.h"
|
||||||
#include "theme-preferences.h"
|
#include "theme-preferences.h"
|
||||||
|
#include "theme-runtime.h"
|
||||||
|
|
||||||
extern void load_text_events (void);
|
extern void load_text_events (void);
|
||||||
|
|
||||||
@@ -1417,17 +1418,56 @@ theme_preferences_gtk3_sync_remove_state (theme_preferences_ui *ui)
|
|||||||
gtk_widget_set_sensitive (ui->gtk3_remove, source == ZOITECHAT_GTK3_THEME_SOURCE_USER);
|
gtk_widget_set_sensitive (ui->gtk3_remove, source == ZOITECHAT_GTK3_THEME_SOURCE_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
theme_preferences_gtk3_apply_and_refresh (GError **error)
|
theme_preferences_gtk3_sync_runtime_palette (theme_preferences_ui *ui)
|
||||||
{
|
{
|
||||||
if (!theme_gtk3_apply_current (error))
|
ThemeWidgetStyleValues style_values;
|
||||||
return FALSE;
|
GtkWidget *style_source = NULL;
|
||||||
theme_manager_dispatch_changed (THEME_CHANGED_REASON_THEME_PACK |
|
|
||||||
THEME_CHANGED_REASON_PALETTE |
|
if (ui && ui->parent)
|
||||||
THEME_CHANGED_REASON_WIDGET_STYLE |
|
style_source = GTK_WIDGET (ui->parent);
|
||||||
THEME_CHANGED_REASON_USERLIST |
|
else if (ui && ui->gtk3_combo)
|
||||||
THEME_CHANGED_REASON_MODE);
|
style_source = ui->gtk3_combo;
|
||||||
return TRUE;
|
|
||||||
|
theme_runtime_clear_gtk_mapped_custom_tokens ();
|
||||||
|
|
||||||
|
theme_get_widget_style_values_for_widget (style_source, &style_values);
|
||||||
|
|
||||||
|
theme_preferences_staged_set_color (THEME_TOKEN_TEXT_FOREGROUND,
|
||||||
|
&style_values.foreground,
|
||||||
|
NULL,
|
||||||
|
TRUE);
|
||||||
|
theme_preferences_staged_set_color (THEME_TOKEN_TEXT_BACKGROUND,
|
||||||
|
&style_values.background,
|
||||||
|
NULL,
|
||||||
|
TRUE);
|
||||||
|
theme_preferences_staged_set_color (THEME_TOKEN_SELECTION_FOREGROUND,
|
||||||
|
&style_values.selection_foreground,
|
||||||
|
NULL,
|
||||||
|
TRUE);
|
||||||
|
theme_preferences_staged_set_color (THEME_TOKEN_SELECTION_BACKGROUND,
|
||||||
|
&style_values.selection_background,
|
||||||
|
NULL,
|
||||||
|
TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
theme_preferences_gtk3_apply_and_refresh (theme_preferences_ui *ui, GError **error)
|
||||||
|
{
|
||||||
|
if (!theme_gtk3_apply_current (error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (ui && ui->parent)
|
||||||
|
theme_manager_apply_to_window (GTK_WIDGET (ui->parent));
|
||||||
|
|
||||||
|
theme_preferences_gtk3_sync_runtime_palette (ui);
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
@@ -1463,7 +1503,7 @@ theme_preferences_gtk3_changed_cb (GtkComboBox *combo, gpointer user_data)
|
|||||||
ui->setup_prefs->hex_gui_gtk3_variant = prefs.hex_gui_gtk3_variant;
|
ui->setup_prefs->hex_gui_gtk3_variant = prefs.hex_gui_gtk3_variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selection_changed && !theme_preferences_gtk3_apply_and_refresh (&error))
|
if (selection_changed && !theme_preferences_gtk3_apply_and_refresh (ui, &error))
|
||||||
{
|
{
|
||||||
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
|
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
|
||||||
error ? error->message : _("Failed to apply GTK3 theme."));
|
error ? error->message : _("Failed to apply GTK3 theme."));
|
||||||
@@ -1552,7 +1592,7 @@ theme_preferences_populate_gtk3 (theme_preferences_ui *ui)
|
|||||||
g_free (final_id);
|
g_free (final_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_apply && !theme_preferences_gtk3_apply_and_refresh (&error))
|
if (should_apply && !theme_preferences_gtk3_apply_and_refresh (ui, &error))
|
||||||
{
|
{
|
||||||
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
|
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
|
||||||
error ? error->message : _("Failed to apply GTK3 theme."));
|
error ? error->message : _("Failed to apply GTK3 theme."));
|
||||||
|
|||||||
@@ -410,6 +410,20 @@ theme_runtime_reset_mode_colors (gboolean dark_mode)
|
|||||||
dark_mode_active = FALSE;
|
dark_mode_active = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
theme_runtime_clear_gtk_mapped_custom_tokens (void)
|
||||||
|
{
|
||||||
|
light_custom_tokens[THEME_TOKEN_TEXT_FOREGROUND] = FALSE;
|
||||||
|
light_custom_tokens[THEME_TOKEN_TEXT_BACKGROUND] = FALSE;
|
||||||
|
light_custom_tokens[THEME_TOKEN_SELECTION_FOREGROUND] = FALSE;
|
||||||
|
light_custom_tokens[THEME_TOKEN_SELECTION_BACKGROUND] = FALSE;
|
||||||
|
|
||||||
|
dark_custom_tokens[THEME_TOKEN_TEXT_FOREGROUND] = FALSE;
|
||||||
|
dark_custom_tokens[THEME_TOKEN_TEXT_BACKGROUND] = FALSE;
|
||||||
|
dark_custom_tokens[THEME_TOKEN_SELECTION_FOREGROUND] = FALSE;
|
||||||
|
dark_custom_tokens[THEME_TOKEN_SELECTION_BACKGROUND] = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
theme_runtime_load (void)
|
theme_runtime_load (void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ gboolean theme_runtime_apply_dark_mode (gboolean enable);
|
|||||||
void theme_runtime_user_set_color (ThemeSemanticToken token, const GdkRGBA *col);
|
void theme_runtime_user_set_color (ThemeSemanticToken token, const GdkRGBA *col);
|
||||||
void theme_runtime_dark_set_color (ThemeSemanticToken token, const GdkRGBA *col);
|
void theme_runtime_dark_set_color (ThemeSemanticToken token, const GdkRGBA *col);
|
||||||
void theme_runtime_reset_mode_colors (gboolean dark_mode);
|
void theme_runtime_reset_mode_colors (gboolean dark_mode);
|
||||||
|
void theme_runtime_clear_gtk_mapped_custom_tokens (void);
|
||||||
gboolean theme_runtime_get_color (ThemeSemanticToken token, GdkRGBA *out_rgba);
|
gboolean theme_runtime_get_color (ThemeSemanticToken token, GdkRGBA *out_rgba);
|
||||||
gboolean theme_runtime_mode_has_user_colors (gboolean dark_mode);
|
gboolean theme_runtime_mode_has_user_colors (gboolean dark_mode);
|
||||||
void theme_runtime_get_widget_style_values (ThemeWidgetStyleValues *out_values);
|
void theme_runtime_get_widget_style_values (ThemeWidgetStyleValues *out_values);
|
||||||
|
|||||||
Reference in New Issue
Block a user