mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 16:00:18 +00:00
- Replaced the dark mode checkbox with an Auto/Dark/Light selector in Preferences → Colors and added the new mode labels/setting metadata to match the combo box UI.
- Updated palette handling to respect the effective dark mode (including auto) when saving colors, applying themes, and refreshing user list styling. - Added auto dark-mode tracking that listens to system theme changes and reapplies palette/styles live when Auto is selected, so updates happen without restart (including channel list styling updates via setup_apply_real). - Synced the stored auto dark-mode state when preferences are applied, keeping Auto mode consistent after manual changes. - Exposed a helper for keeping the Auto state synchronized from the GTK layer to preferences handling.
This commit is contained in:
@@ -302,6 +302,35 @@ fe_system_prefers_dark (void)
|
||||
return prefer_dark;
|
||||
}
|
||||
|
||||
static gboolean auto_dark_mode_enabled = FALSE;
|
||||
|
||||
static void
|
||||
fe_auto_dark_mode_changed (GtkSettings *settings, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
gboolean enabled;
|
||||
|
||||
(void) settings;
|
||||
(void) pspec;
|
||||
(void) data;
|
||||
|
||||
if (prefs.hex_gui_dark_mode != ZOITECHAT_DARK_MODE_AUTO)
|
||||
return;
|
||||
|
||||
enabled = fe_system_prefers_dark ();
|
||||
if (enabled == auto_dark_mode_enabled)
|
||||
return;
|
||||
|
||||
auto_dark_mode_enabled = enabled;
|
||||
palette_apply_dark_mode (enabled);
|
||||
setup_apply_real (0, TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
fe_set_auto_dark_mode_state (gboolean enabled)
|
||||
{
|
||||
auto_dark_mode_enabled = enabled;
|
||||
}
|
||||
|
||||
gboolean
|
||||
fe_dark_mode_is_enabled_for (unsigned int mode)
|
||||
{
|
||||
@@ -369,6 +398,8 @@ create_input_style (GtkStyle *style)
|
||||
void
|
||||
fe_init (void)
|
||||
{
|
||||
GtkSettings *settings;
|
||||
|
||||
palette_load ();
|
||||
palette_apply_dark_mode (fe_dark_mode_is_enabled ());
|
||||
key_init ();
|
||||
@@ -379,6 +410,16 @@ fe_init (void)
|
||||
#endif
|
||||
channelwin_pix = pixmap_load_from_file (prefs.hex_text_background);
|
||||
input_style = create_input_style (gtk_style_new ());
|
||||
|
||||
settings = gtk_settings_get_default ();
|
||||
if (settings)
|
||||
{
|
||||
auto_dark_mode_enabled = fe_system_prefers_dark ();
|
||||
g_signal_connect (settings, "notify::gtk-application-prefer-dark-theme",
|
||||
G_CALLBACK (fe_auto_dark_mode_changed), NULL);
|
||||
g_signal_connect (settings, "notify::gtk-theme-name",
|
||||
G_CALLBACK (fe_auto_dark_mode_changed), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_GTK_MAC
|
||||
|
||||
Reference in New Issue
Block a user