mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
Updated gtkutil_menu_icon_theme_variant() to select the menu icon theme variant from the app’s effective dark-mode state first (fe_dark_mode_state_is_initialized() + fe_dark_mode_is_enabled()), and only use GTK/theme-name heuristics as fallback before app state is initialized. This preserves the existing light-asset fallback behavior in menu icon loading logic.
Added a new frontend helper declaration fe_dark_mode_state_is_initialized() in the GTK frontend header so callers can check whether dark-mode state is ready. Implemented dark-mode initialization tracking in fe-gtk.c via a new static flag, set when auto mode state is externally set and during fe_init(), and exposed it through fe_dark_mode_state_is_initialized().
This commit is contained in:
@@ -587,6 +587,7 @@ fe_system_prefers_dark (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean auto_dark_mode_enabled = FALSE;
|
static gboolean auto_dark_mode_enabled = FALSE;
|
||||||
|
static gboolean dark_mode_state_initialized = FALSE;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fe_set_gtk_prefer_dark_theme (gboolean dark)
|
fe_set_gtk_prefer_dark_theme (gboolean dark)
|
||||||
@@ -657,6 +658,13 @@ void
|
|||||||
fe_set_auto_dark_mode_state (gboolean enabled)
|
fe_set_auto_dark_mode_state (gboolean enabled)
|
||||||
{
|
{
|
||||||
auto_dark_mode_enabled = enabled;
|
auto_dark_mode_enabled = enabled;
|
||||||
|
dark_mode_state_initialized = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
fe_dark_mode_state_is_initialized (void)
|
||||||
|
{
|
||||||
|
return dark_mode_state_initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1008,7 +1016,10 @@ fe_init (void)
|
|||||||
palette_load ();
|
palette_load ();
|
||||||
settings = gtk_settings_get_default ();
|
settings = gtk_settings_get_default ();
|
||||||
if (settings)
|
if (settings)
|
||||||
|
{
|
||||||
auto_dark_mode_enabled = fe_system_prefers_dark ();
|
auto_dark_mode_enabled = fe_system_prefers_dark ();
|
||||||
|
dark_mode_state_initialized = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
fe_apply_theme_for_mode (prefs.hex_gui_dark_mode, NULL);
|
fe_apply_theme_for_mode (prefs.hex_gui_dark_mode, NULL);
|
||||||
key_init ();
|
key_init ();
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ extern cairo_surface_t *dialogwin_pix;
|
|||||||
|
|
||||||
gboolean fe_dark_mode_is_enabled (void);
|
gboolean fe_dark_mode_is_enabled (void);
|
||||||
gboolean fe_dark_mode_is_enabled_for (unsigned int mode);
|
gboolean fe_dark_mode_is_enabled_for (unsigned int mode);
|
||||||
|
gboolean fe_dark_mode_state_is_initialized (void);
|
||||||
void fe_set_auto_dark_mode_state (gboolean enabled);
|
void fe_set_auto_dark_mode_state (gboolean enabled);
|
||||||
void fe_refresh_auto_dark_mode (void);
|
void fe_refresh_auto_dark_mode (void);
|
||||||
gboolean fe_apply_theme_for_mode (unsigned int mode, gboolean *palette_changed);
|
gboolean fe_apply_theme_for_mode (unsigned int mode, gboolean *palette_changed);
|
||||||
|
|||||||
@@ -251,6 +251,9 @@ gtkutil_menu_icon_theme_variant (void)
|
|||||||
char *theme_name_lower = NULL;
|
char *theme_name_lower = NULL;
|
||||||
const char *theme_variant = "light";
|
const char *theme_variant = "light";
|
||||||
|
|
||||||
|
if (fe_dark_mode_state_is_initialized ())
|
||||||
|
return fe_dark_mode_is_enabled () ? "dark" : "light";
|
||||||
|
|
||||||
settings = gtk_settings_get_default ();
|
settings = gtk_settings_get_default ();
|
||||||
if (settings)
|
if (settings)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user