From ed02b21228c6433c5d0f76e99fed81cc7291ba76 Mon Sep 17 00:00:00 2001 From: deepend Date: Wed, 25 Feb 2026 21:22:56 -0700 Subject: [PATCH] =?UTF-8?q?=20=20=20=20Extended=20setup=5Fdark=5Fmode=5Fme?= =?UTF-8?q?nu=5Fcb=20so=20after=20setup=5Fmenu=5Fcb=20it=20now=20computes?= =?UTF-8?q?=20the=20selected=20dark-mode=20state=20via=20fe=5Fdark=5Fmode?= =?UTF-8?q?=5Fis=5Fenabled=5Ffor(setup=5Fprefs.hex=5Fgui=5Fdark=5Fmode),?= =?UTF-8?q?=20swaps=20the=20in-memory=20editor=20palette=20with=20palette?= =?UTF-8?q?=5Fapply=5Fdark=5Fmode(...),=20and=20immediately=20refreshes=20?= =?UTF-8?q?color=20swatches.=20This=20keeps=20the=20editor=20model=20synch?= =?UTF-8?q?ronized=20with=20the=20dark-mode=20combo=20selection.=20=20=20?= =?UTF-8?q?=20=20Added=20setup=5Frefresh=5Fcolor=5Fselector=5Fwidgets()=20?= =?UTF-8?q?to=20iterate=20color=5Fselector=5Fwidgets,=20resolve=20each=20b?= =?UTF-8?q?utton=E2=80=99s=20stored=20color=20index,=20and=20re-run=20setu?= =?UTF-8?q?p=5Fcolor=5Fbutton=5Fapply=20against=20colors[]=20so=20all=20se?= =?UTF-8?q?lectors=20repaint=20to=20the=20active=20palette.=20=20=20=20=20?= =?UTF-8?q?Updated=20setup=5Fcreate=5Fcolor=5Fbutton=20to=20register=20eac?= =?UTF-8?q?h=20widget=E2=80=99s=20palette=20index=20(zoitechat-color-index?= =?UTF-8?q?),=20enabling=20correct=20per-button=20repaint=20during=20mode?= =?UTF-8?q?=20switches.=20=20=20=20=20Preserved=20existing=20persistence?= =?UTF-8?q?=20behavior=20in=20setup=5Fcolor=5Fresponse=5Fcb=20(palette=5Fd?= =?UTF-8?q?ark=5Fset=5Fcolor=20vs=20palette=5Fuser=5Fset=5Fcolor)=20so=20c?= =?UTF-8?q?hanges=20remain=20non-destructive=20until=20existing=20OK/Save?= =?UTF-8?q?=20flow=20persists=20them.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fe-gtk/setup.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index dc46013b..7fb37e93 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -1474,6 +1474,9 @@ setup_create_page (const setting *set) return tab; } +static void +setup_color_button_apply (GtkWidget *button, const PaletteColor *color); + static void setup_color_selectors_set_sensitive (gboolean sensitive) { @@ -1487,10 +1490,47 @@ setup_color_selectors_set_sensitive (gboolean sensitive) } } +static void +setup_refresh_color_selector_widgets (void) +{ + GSList *l = color_selector_widgets; + + while (l) + { + GtkWidget *w = (GtkWidget *) l->data; + gpointer color_index_ptr; + int color_index; + + if (!GTK_IS_WIDGET (w)) + { + l = l->next; + continue; + } + + color_index_ptr = g_object_get_data (G_OBJECT (w), "zoitechat-color-index"); + if (!color_index_ptr) + { + l = l->next; + continue; + } + + color_index = GPOINTER_TO_INT (color_index_ptr); + if (color_index >= 0 && color_index <= MAX_COL) + setup_color_button_apply (w, &colors[color_index]); + + l = l->next; + } +} + static void setup_dark_mode_menu_cb (GtkWidget *cbox, const setting *set) { + gboolean dark_mode_enabled; + setup_menu_cb (cbox, set); + dark_mode_enabled = fe_dark_mode_is_enabled_for (setup_prefs.hex_gui_dark_mode); + palette_apply_dark_mode (dark_mode_enabled); + setup_refresh_color_selector_widgets (); /* Keep color selectors usable even when dark mode is enabled. */ setup_color_selectors_set_sensitive (TRUE); } @@ -1640,6 +1680,7 @@ setup_create_color_button (GtkWidget *table, int num, int row, int col) /* win32 build uses this to turn off themeing */ g_object_set_data (G_OBJECT (but), "zoitechat-color", (gpointer)1); g_object_set_data (G_OBJECT (but), "zoitechat-color-box", box); + g_object_set_data (G_OBJECT (but), "zoitechat-color-index", GINT_TO_POINTER (num)); setup_table_attach (table, but, col, col + 1, row, row + 1, FALSE, FALSE, SETUP_ALIGN_CENTER, SETUP_ALIGN_CENTER, 0, 0); g_signal_connect (G_OBJECT (but), "clicked", @@ -2486,7 +2527,7 @@ setup_apply_to_sess (session_gui *gui) char buf[128]; char *color_string = gdk_rgba_to_string (&colors[COL_FG]); - g_snprintf (buf, sizeof (buf), ".zoitechat-inputbox { caret-color: %s; }", + g_snprintf (buf, sizeof (buf), "#zoitechat-inputbox { caret-color: %s; }", color_string); g_free (color_string);