mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-18 19:50:18 +00:00
Extended setup_dark_mode_menu_cb so after setup_menu_cb it now computes the selected dark-mode state via fe_dark_mode_is_enabled_for(setup_prefs.hex_gui_dark_mode), swaps the in-memory editor palette with palette_apply_dark_mode(...), and immediately refreshes color swatches. This keeps the editor model synchronized with the dark-mode combo selection.
Added setup_refresh_color_selector_widgets() to iterate color_selector_widgets, resolve each button’s stored color index, and re-run setup_color_button_apply against colors[] so all selectors repaint to the active palette.
Updated setup_create_color_button to register each widget’s palette index (zoitechat-color-index), enabling correct per-button repaint during mode switches.
Preserved existing persistence behavior in setup_color_response_cb (palette_dark_set_color vs palette_user_set_color) so changes remain non-destructive until existing OK/Save flow persists them.
This commit is contained in:
@@ -1474,6 +1474,9 @@ setup_create_page (const setting *set)
|
|||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_color_button_apply (GtkWidget *button, const PaletteColor *color);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_color_selectors_set_sensitive (gboolean sensitive)
|
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
|
static void
|
||||||
setup_dark_mode_menu_cb (GtkWidget *cbox, const setting *set)
|
setup_dark_mode_menu_cb (GtkWidget *cbox, const setting *set)
|
||||||
{
|
{
|
||||||
|
gboolean dark_mode_enabled;
|
||||||
|
|
||||||
setup_menu_cb (cbox, set);
|
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. */
|
/* Keep color selectors usable even when dark mode is enabled. */
|
||||||
setup_color_selectors_set_sensitive (TRUE);
|
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 */
|
/* 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", (gpointer)1);
|
||||||
g_object_set_data (G_OBJECT (but), "zoitechat-color-box", box);
|
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_table_attach (table, but, col, col + 1, row, row + 1, FALSE, FALSE,
|
||||||
SETUP_ALIGN_CENTER, SETUP_ALIGN_CENTER, 0, 0);
|
SETUP_ALIGN_CENTER, SETUP_ALIGN_CENTER, 0, 0);
|
||||||
g_signal_connect (G_OBJECT (but), "clicked",
|
g_signal_connect (G_OBJECT (but), "clicked",
|
||||||
@@ -2486,7 +2527,7 @@ setup_apply_to_sess (session_gui *gui)
|
|||||||
char buf[128];
|
char buf[128];
|
||||||
char *color_string = gdk_rgba_to_string (&colors[COL_FG]);
|
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);
|
color_string);
|
||||||
g_free (color_string);
|
g_free (color_string);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user