mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-24 22:40:18 +00:00
Merge pull request #3 from ZoiteChat/feature/dark-mode-toggle
Feature/dark mode toggle
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
project('zoitechat', 'c',
|
project('zoitechat', 'c',
|
||||||
version: '2.17.0',
|
version: '2.17.1',
|
||||||
meson_version: '>= 0.47.0',
|
meson_version: '>= 0.47.0',
|
||||||
default_options: [
|
default_options: [
|
||||||
'c_std=gnu89',
|
'c_std=gnu89',
|
||||||
|
|||||||
@@ -433,6 +433,7 @@ const struct prefs vars[] =
|
|||||||
{"gui_tab_dialogs", P_OFFINT (hex_gui_tab_dialogs), TYPE_BOOL},
|
{"gui_tab_dialogs", P_OFFINT (hex_gui_tab_dialogs), TYPE_BOOL},
|
||||||
{"gui_tab_dots", P_OFFINT (hex_gui_tab_dots), TYPE_BOOL},
|
{"gui_tab_dots", P_OFFINT (hex_gui_tab_dots), TYPE_BOOL},
|
||||||
{"gui_tab_icons", P_OFFINT (hex_gui_tab_icons), TYPE_BOOL},
|
{"gui_tab_icons", P_OFFINT (hex_gui_tab_icons), TYPE_BOOL},
|
||||||
|
{"gui_dark_mode", P_OFFINT (hex_gui_dark_mode), TYPE_BOOL},
|
||||||
{"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT},
|
{"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT},
|
||||||
{"gui_tab_middleclose", P_OFFINT (hex_gui_tab_middleclose), TYPE_BOOL},
|
{"gui_tab_middleclose", P_OFFINT (hex_gui_tab_middleclose), TYPE_BOOL},
|
||||||
{"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT},
|
{"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT},
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ struct zoitechatprefs
|
|||||||
unsigned int hex_gui_tab_dialogs;
|
unsigned int hex_gui_tab_dialogs;
|
||||||
unsigned int hex_gui_tab_dots;
|
unsigned int hex_gui_tab_dots;
|
||||||
unsigned int hex_gui_tab_icons;
|
unsigned int hex_gui_tab_icons;
|
||||||
|
unsigned int hex_gui_dark_mode;
|
||||||
unsigned int hex_gui_tab_scrollchans;
|
unsigned int hex_gui_tab_scrollchans;
|
||||||
unsigned int hex_gui_tab_server;
|
unsigned int hex_gui_tab_server;
|
||||||
unsigned int hex_gui_tab_sort;
|
unsigned int hex_gui_tab_sort;
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ cv_tree_init (chanview *cv)
|
|||||||
|
|
||||||
((treeview *)cv)->tree = GTK_TREE_VIEW (view);
|
((treeview *)cv)->tree = GTK_TREE_VIEW (view);
|
||||||
((treeview *)cv)->scrollw = win;
|
((treeview *)cv)->scrollw = win;
|
||||||
|
chanview_apply_theme (cv);
|
||||||
gtk_widget_show (view);
|
gtk_widget_show (view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "maingui.h"
|
#include "maingui.h"
|
||||||
#include "gtkutil.h"
|
#include "gtkutil.h"
|
||||||
#include "chanview.h"
|
#include "chanview.h"
|
||||||
|
#include "palette.h"
|
||||||
|
|
||||||
/* treeStore columns */
|
/* treeStore columns */
|
||||||
#define COL_NAME 0 /* (char *) */
|
#define COL_NAME 0 /* (char *) */
|
||||||
@@ -103,6 +104,37 @@ static int cv_find_number_of_chan (chanview *cv, chan *find_ch);
|
|||||||
|
|
||||||
/* ==== ABSTRACT CHANVIEW ==== */
|
/* ==== ABSTRACT CHANVIEW ==== */
|
||||||
|
|
||||||
|
void
|
||||||
|
chanview_apply_theme (chanview *cv)
|
||||||
|
{
|
||||||
|
GtkWidget *w;
|
||||||
|
treeview *tv;
|
||||||
|
|
||||||
|
if (cv == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Only the tree implementation has a GtkTreeView we can explicitly style. */
|
||||||
|
if (cv->func_init != cv_tree_init)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tv = (treeview *) cv;
|
||||||
|
if (tv->tree == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
w = GTK_WIDGET (tv->tree);
|
||||||
|
if (prefs.hex_gui_dark_mode)
|
||||||
|
{
|
||||||
|
gtk_widget_modify_base (w, GTK_STATE_NORMAL, &colors[COL_BG]);
|
||||||
|
gtk_widget_modify_text (w, GTK_STATE_NORMAL, &colors[COL_FG]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Revert back to theme defaults. */
|
||||||
|
gtk_widget_modify_base (w, GTK_STATE_NORMAL, NULL);
|
||||||
|
gtk_widget_modify_text (w, GTK_STATE_NORMAL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
truncate_tab_name (char *name, int max)
|
truncate_tab_name (char *name, int max)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ gboolean chan_remove (chan *ch, gboolean force);
|
|||||||
gboolean chan_is_collapsed (chan *ch);
|
gboolean chan_is_collapsed (chan *ch);
|
||||||
chan * chan_get_parent (chan *ch);
|
chan * chan_get_parent (chan *ch);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Apply ZoiteChat's optional "dark mode" styling to the channel list.
|
||||||
|
*
|
||||||
|
* This is a no-op for implementations that don't have a tree view.
|
||||||
|
*/
|
||||||
|
void chanview_apply_theme (chanview *cv);
|
||||||
|
|
||||||
#define FOCUS_NEW_ALL 1
|
#define FOCUS_NEW_ALL 1
|
||||||
#define FOCUS_NEW_ONLY_ASKED 2
|
#define FOCUS_NEW_ONLY_ASKED 2
|
||||||
#define FOCUS_NEW_NONE 0
|
#define FOCUS_NEW_NONE 0
|
||||||
|
|||||||
@@ -317,6 +317,7 @@ void
|
|||||||
fe_init (void)
|
fe_init (void)
|
||||||
{
|
{
|
||||||
palette_load ();
|
palette_load ();
|
||||||
|
palette_apply_dark_mode (prefs.hex_gui_dark_mode);
|
||||||
key_init ();
|
key_init ();
|
||||||
pixmaps_init ();
|
pixmaps_init ();
|
||||||
|
|
||||||
|
|||||||
@@ -2480,7 +2480,20 @@ mg_create_userlist (session_gui *gui, GtkWidget *box)
|
|||||||
if (prefs.hex_gui_ulist_style)
|
if (prefs.hex_gui_ulist_style)
|
||||||
{
|
{
|
||||||
gtk_widget_set_style (ulist, input_style);
|
gtk_widget_set_style (ulist, input_style);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keep the user list in sync with the chat palette.
|
||||||
|
*
|
||||||
|
* - When "Use the text box font and colors" is enabled, we already want the
|
||||||
|
* palette background.
|
||||||
|
* - When "Dark mode" is enabled, we also force the user list to use the
|
||||||
|
* palette colors so it doesn't stay blindingly white on GTK2 themes.
|
||||||
|
*/
|
||||||
|
if (prefs.hex_gui_ulist_style || prefs.hex_gui_dark_mode)
|
||||||
|
{
|
||||||
gtk_widget_modify_base (ulist, GTK_STATE_NORMAL, &colors[COL_BG]);
|
gtk_widget_modify_base (ulist, GTK_STATE_NORMAL, &colors[COL_BG]);
|
||||||
|
gtk_widget_modify_text (ulist, GTK_STATE_NORMAL, &colors[COL_FG]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mg_create_meters (gui, vbox);
|
mg_create_meters (gui, vbox);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
|
|
||||||
#include "../common/zoitechat.h"
|
#include "../common/zoitechat.h"
|
||||||
|
#include "../common/zoitechatc.h" /* prefs */
|
||||||
#include "../common/util.h"
|
#include "../common/util.h"
|
||||||
#include "../common/cfgfiles.h"
|
#include "../common/cfgfiles.h"
|
||||||
#include "../common/typedef.h"
|
#include "../common/typedef.h"
|
||||||
@@ -87,6 +89,76 @@ GdkColor colors[] = {
|
|||||||
{0, 0xa4a4, 0x0000, 0x0000}, /* 41 spell checker color (red) */
|
{0, 0xa4a4, 0x0000, 0x0000}, /* 41 spell checker color (red) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* User palette snapshot (what we write to colors.conf) */
|
||||||
|
static GdkColor user_colors[MAX_COL + 1];
|
||||||
|
static gboolean user_colors_valid = FALSE;
|
||||||
|
|
||||||
|
/* ZoiteChat's curated dark palette (applies when prefs.hex_gui_dark_mode is enabled). */
|
||||||
|
static const GdkColor dark_colors[MAX_COL + 1] = {
|
||||||
|
/* mIRC colors 0-15 */
|
||||||
|
{0, 0xe5e5, 0xe5e5, 0xe5e5}, /* 0 white */
|
||||||
|
{0, 0x3c3c, 0x3c3c, 0x3c3c}, /* 1 black (dark gray for contrast) */
|
||||||
|
{0, 0x5656, 0x9c9c, 0xd6d6}, /* 2 blue */
|
||||||
|
{0, 0x0d0d, 0xbcbc, 0x7979}, /* 3 green */
|
||||||
|
{0, 0xf4f4, 0x4747, 0x4747}, /* 4 red */
|
||||||
|
{0, 0xcece, 0x9191, 0x7878}, /* 5 light red / brown */
|
||||||
|
{0, 0xc5c5, 0x8686, 0xc0c0}, /* 6 purple */
|
||||||
|
{0, 0xd7d7, 0xbaba, 0x7d7d}, /* 7 orange */
|
||||||
|
{0, 0xdcdc, 0xdcdc, 0xaaaa}, /* 8 yellow */
|
||||||
|
{0, 0xb5b5, 0xcece, 0xa8a8}, /* 9 light green */
|
||||||
|
{0, 0x4e4e, 0xc9c9, 0xb0b0}, /* 10 aqua */
|
||||||
|
{0, 0x9c9c, 0xdcdc, 0xfefe}, /* 11 light aqua */
|
||||||
|
{0, 0x3737, 0x9494, 0xffff}, /* 12 light blue */
|
||||||
|
{0, 0xd6d6, 0x7070, 0xd6d6}, /* 13 pink */
|
||||||
|
{0, 0x8080, 0x8080, 0x8080}, /* 14 gray */
|
||||||
|
{0, 0xc0c0, 0xc0c0, 0xc0c0}, /* 15 light gray */
|
||||||
|
/* mIRC colors 16-31 (repeat) */
|
||||||
|
{0, 0xe5e5, 0xe5e5, 0xe5e5}, {0, 0x3c3c, 0x3c3c, 0x3c3c},
|
||||||
|
{0, 0x5656, 0x9c9c, 0xd6d6}, {0, 0x0d0d, 0xbcbc, 0x7979},
|
||||||
|
{0, 0xf4f4, 0x4747, 0x4747}, {0, 0xcece, 0x9191, 0x7878},
|
||||||
|
{0, 0xc5c5, 0x8686, 0xc0c0}, {0, 0xd7d7, 0xbaba, 0x7d7d},
|
||||||
|
{0, 0xdcdc, 0xdcdc, 0xaaaa}, {0, 0xb5b5, 0xcece, 0xa8a8},
|
||||||
|
{0, 0x4e4e, 0xc9c9, 0xb0b0}, {0, 0x9c9c, 0xdcdc, 0xfefe},
|
||||||
|
{0, 0x3737, 0x9494, 0xffff}, {0, 0xd6d6, 0x7070, 0xd6d6},
|
||||||
|
{0, 0x8080, 0x8080, 0x8080}, {0, 0xc0c0, 0xc0c0, 0xc0c0},
|
||||||
|
|
||||||
|
/* selection colors */
|
||||||
|
{0, 0xffff, 0xffff, 0xffff}, /* 32 COL_MARK_FG */
|
||||||
|
{0, 0x2626, 0x4f4f, 0x7878}, /* 33 COL_MARK_BG */
|
||||||
|
|
||||||
|
/* foreground/background */
|
||||||
|
{0, 0xd4d4, 0xd4d4, 0xd4d4}, /* 34 COL_FG */
|
||||||
|
{0, 0x1e1e, 0x1e1e, 0x1e1e}, /* 35 COL_BG */
|
||||||
|
|
||||||
|
/* interface colors */
|
||||||
|
{0, 0x4040, 0x4040, 0x4040}, /* 36 COL_MARKER (marker line) */
|
||||||
|
{0, 0x3737, 0x9494, 0xffff}, /* 37 COL_NEW_DATA (tab: new data) */
|
||||||
|
{0, 0xd7d7, 0xbaba, 0x7d7d}, /* 38 COL_HILIGHT (tab: nick mentioned) */
|
||||||
|
{0, 0xf4f4, 0x4747, 0x4747}, /* 39 COL_NEW_MSG (tab: new message) */
|
||||||
|
{0, 0x8080, 0x8080, 0x8080}, /* 40 COL_AWAY (tab: away) */
|
||||||
|
{0, 0xf4f4, 0x4747, 0x4747}, /* 41 COL_SPELL (spellcheck underline) */
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
palette_user_set_color (int idx, const GdkColor *col)
|
||||||
|
{
|
||||||
|
if (!col)
|
||||||
|
return;
|
||||||
|
if (idx < 0 || idx > MAX_COL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!user_colors_valid)
|
||||||
|
{
|
||||||
|
memcpy (user_colors, colors, sizeof (user_colors));
|
||||||
|
user_colors_valid = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
user_colors[idx].red = col->red;
|
||||||
|
user_colors[idx].green = col->green;
|
||||||
|
user_colors[idx].blue = col->blue;
|
||||||
|
user_colors[idx].pixel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
palette_alloc (GtkWidget * widget)
|
palette_alloc (GtkWidget * widget)
|
||||||
{
|
{
|
||||||
@@ -141,6 +213,10 @@ palette_load (void)
|
|||||||
g_free (cfg);
|
g_free (cfg);
|
||||||
close (fh);
|
close (fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Snapshot the user's palette for dark mode toggling. */
|
||||||
|
memcpy (user_colors, colors, sizeof (user_colors));
|
||||||
|
user_colors_valid = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -148,6 +224,11 @@ palette_save (void)
|
|||||||
{
|
{
|
||||||
int i, j, fh;
|
int i, j, fh;
|
||||||
char prefname[256];
|
char prefname[256];
|
||||||
|
const GdkColor *outpal = colors;
|
||||||
|
|
||||||
|
/* Don't clobber the user's colors.conf with the dark palette. */
|
||||||
|
if (prefs.hex_gui_dark_mode && user_colors_valid)
|
||||||
|
outpal = user_colors;
|
||||||
|
|
||||||
fh = zoitechat_open_file ("colors.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
|
fh = zoitechat_open_file ("colors.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
|
||||||
if (fh != -1)
|
if (fh != -1)
|
||||||
@@ -156,16 +237,64 @@ palette_save (void)
|
|||||||
for (i = 0; i < 32; i++)
|
for (i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
g_snprintf (prefname, sizeof prefname, "color_%d", i);
|
g_snprintf (prefname, sizeof prefname, "color_%d", i);
|
||||||
cfg_put_color (fh, colors[i].red, colors[i].green, colors[i].blue, prefname);
|
cfg_put_color (fh, outpal[i].red, outpal[i].green, outpal[i].blue, prefname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* our special colors are mapped at 256+ */
|
/* our special colors are mapped at 256+ */
|
||||||
for (i = 256, j = 32; j < MAX_COL+1; i++, j++)
|
for (i = 256, j = 32; j < MAX_COL+1; i++, j++)
|
||||||
{
|
{
|
||||||
g_snprintf (prefname, sizeof prefname, "color_%d", i);
|
g_snprintf (prefname, sizeof prefname, "color_%d", i);
|
||||||
cfg_put_color (fh, colors[j].red, colors[j].green, colors[j].blue, prefname);
|
cfg_put_color (fh, outpal[j].red, outpal[j].green, outpal[j].blue, prefname);
|
||||||
}
|
}
|
||||||
|
|
||||||
close (fh);
|
close (fh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
palette_color_eq (const GdkColor *a, const GdkColor *b)
|
||||||
|
{
|
||||||
|
return a->red == b->red && a->green == b->green && a->blue == b->blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
palette_apply_dark_mode (gboolean enable)
|
||||||
|
{
|
||||||
|
GdkColor old_colors[MAX_COL + 1];
|
||||||
|
GdkColormap *cmap;
|
||||||
|
int i;
|
||||||
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
|
memcpy (old_colors, colors, sizeof (old_colors));
|
||||||
|
|
||||||
|
/* Ensure we have a snapshot of the user's palette before overriding anything. */
|
||||||
|
if (!user_colors_valid)
|
||||||
|
{
|
||||||
|
memcpy (user_colors, colors, sizeof (user_colors));
|
||||||
|
user_colors_valid = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
memcpy (colors, dark_colors, sizeof (colors));
|
||||||
|
else
|
||||||
|
memcpy (colors, user_colors, sizeof (colors));
|
||||||
|
|
||||||
|
/* Allocate the new colors for GTK's colormap. */
|
||||||
|
cmap = gdk_colormap_get_system ();
|
||||||
|
for (i = 0; i <= MAX_COL; i++)
|
||||||
|
gdk_colormap_alloc_color (cmap, &colors[i], FALSE, TRUE);
|
||||||
|
|
||||||
|
for (i = 0; i <= MAX_COL; i++)
|
||||||
|
{
|
||||||
|
if (old_colors[i].red != colors[i].red ||
|
||||||
|
old_colors[i].green != colors[i].green ||
|
||||||
|
old_colors[i].blue != colors[i].blue)
|
||||||
|
{
|
||||||
|
changed = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,4 +38,24 @@ void palette_alloc (GtkWidget * widget);
|
|||||||
void palette_load (void);
|
void palette_load (void);
|
||||||
void palette_save (void);
|
void palette_save (void);
|
||||||
|
|
||||||
|
/* Keep a copy of the user's palette so dark mode can be toggled without losing it. */
|
||||||
|
void palette_user_set_color (int idx, const GdkColor *col);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Apply ZoiteChat's built-in "dark mode" palette.
|
||||||
|
*
|
||||||
|
* When enabled, ZoiteChat switches to a curated dark-friendly palette for:
|
||||||
|
* - message colors (mIRC palette)
|
||||||
|
* - selection colors
|
||||||
|
* - tab highlight colors
|
||||||
|
* - chat/user/channel list background + foreground
|
||||||
|
*
|
||||||
|
* The user's palette is preserved in-memory and written to colors.conf even
|
||||||
|
* while dark mode is enabled, so disabling dark mode restores the previous
|
||||||
|
* colors without surprises.
|
||||||
|
*
|
||||||
|
* Returns TRUE if any palette entries were changed.
|
||||||
|
*/
|
||||||
|
gboolean palette_apply_dark_mode (gboolean enable);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "fe-gtk.h"
|
#include "fe-gtk.h"
|
||||||
#include "gtkutil.h"
|
#include "gtkutil.h"
|
||||||
#include "maingui.h"
|
#include "maingui.h"
|
||||||
|
#include "chanview.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "pixmaps.h"
|
#include "pixmaps.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
@@ -53,6 +54,8 @@ static int last_selected_page = 0;
|
|||||||
static int last_selected_row = 0; /* sound row */
|
static int last_selected_row = 0; /* sound row */
|
||||||
static gboolean color_change;
|
static gboolean color_change;
|
||||||
static struct zoitechatprefs setup_prefs;
|
static struct zoitechatprefs setup_prefs;
|
||||||
|
static GSList *color_selector_widgets;
|
||||||
|
static GtkWidget *dark_mode_toggle_widget;
|
||||||
static GtkWidget *cancel_button;
|
static GtkWidget *cancel_button;
|
||||||
static GtkWidget *font_dialog = NULL;
|
static GtkWidget *font_dialog = NULL;
|
||||||
|
|
||||||
@@ -341,6 +344,17 @@ static const setting color_settings[] =
|
|||||||
{ST_END, 0, 0, 0, 0, 0}
|
{ST_END, 0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const setting dark_mode_setting =
|
||||||
|
{
|
||||||
|
ST_TOGGLE,
|
||||||
|
N_("Enable dark mode"),
|
||||||
|
P_OFFINTNL(hex_gui_dark_mode),
|
||||||
|
N_("Applies ZoiteChat's built-in dark palette to the chat buffer, channel list, and user list.\n"
|
||||||
|
"This includes message colors, selection colors, and interface highlights.\n"),
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
static const char *const dccaccept[] =
|
static const char *const dccaccept[] =
|
||||||
{
|
{
|
||||||
N_("Ask for confirmation"),
|
N_("Ask for confirmation"),
|
||||||
@@ -1401,6 +1415,28 @@ setup_create_page (const setting *set)
|
|||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_color_selectors_set_sensitive (gboolean sensitive)
|
||||||
|
{
|
||||||
|
GSList *l = color_selector_widgets;
|
||||||
|
while (l)
|
||||||
|
{
|
||||||
|
GtkWidget *w = (GtkWidget *) l->data;
|
||||||
|
if (GTK_IS_WIDGET (w))
|
||||||
|
gtk_widget_set_sensitive (w, sensitive);
|
||||||
|
l = l->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_dark_mode_ui_toggle_cb (GtkToggleButton *but, gpointer userdata)
|
||||||
|
{
|
||||||
|
(void) but;
|
||||||
|
(void) userdata;
|
||||||
|
/* Keep color selectors usable even when dark mode is enabled. */
|
||||||
|
setup_color_selectors_set_sensitive (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_color_ok_cb (GtkWidget *button, GtkWidget *dialog)
|
setup_color_ok_cb (GtkWidget *button, GtkWidget *dialog)
|
||||||
{
|
{
|
||||||
@@ -1434,6 +1470,10 @@ setup_color_ok_cb (GtkWidget *button, GtkWidget *dialog)
|
|||||||
/* is this line correct?? */
|
/* is this line correct?? */
|
||||||
gdk_colormap_free_colors (gtk_widget_get_colormap (button), &old_color, 1);
|
gdk_colormap_free_colors (gtk_widget_get_colormap (button), &old_color, 1);
|
||||||
|
|
||||||
|
/* Keep a copy of the user's palette so we can restore it after dark mode. */
|
||||||
|
if (!prefs.hex_gui_dark_mode)
|
||||||
|
palette_user_set_color ((int)(col - colors), col);
|
||||||
|
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1495,6 +1535,9 @@ setup_create_color_button (GtkWidget *table, int num, int row, int col)
|
|||||||
style->bg[GTK_STATE_NORMAL] = colors[num];
|
style->bg[GTK_STATE_NORMAL] = colors[num];
|
||||||
gtk_widget_set_style (but, style);
|
gtk_widget_set_style (but, style);
|
||||||
g_object_unref (style);
|
g_object_unref (style);
|
||||||
|
|
||||||
|
/* Track all color selector widgets (used for dark mode UI behavior). */
|
||||||
|
color_selector_widgets = g_slist_prepend (color_selector_widgets, but);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1524,6 +1567,9 @@ setup_create_other_color (char *text, int num, int row, GtkWidget *tab)
|
|||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
setup_create_color_page (void)
|
setup_create_color_page (void)
|
||||||
{
|
{
|
||||||
|
color_selector_widgets = NULL;
|
||||||
|
dark_mode_toggle_widget = NULL;
|
||||||
|
|
||||||
GtkWidget *tab, *box, *label;
|
GtkWidget *tab, *box, *label;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -1570,8 +1616,11 @@ setup_create_color_page (void)
|
|||||||
setup_create_other_colorR (_("Away user:"), COL_AWAY, 10, tab);
|
setup_create_other_colorR (_("Away user:"), COL_AWAY, 10, tab);
|
||||||
setup_create_other_color (_("Highlight:"), COL_HILIGHT, 11, tab);
|
setup_create_other_color (_("Highlight:"), COL_HILIGHT, 11, tab);
|
||||||
setup_create_other_colorR (_("Spell checker:"), COL_SPELL, 11, tab);
|
setup_create_other_colorR (_("Spell checker:"), COL_SPELL, 11, tab);
|
||||||
|
dark_mode_toggle_widget = setup_create_toggleL (tab, 13, &dark_mode_setting);
|
||||||
setup_create_header (tab, 15, N_("Color Stripping"));
|
g_signal_connect (G_OBJECT (dark_mode_toggle_widget), "toggled",
|
||||||
|
G_CALLBACK (setup_dark_mode_ui_toggle_cb), NULL);
|
||||||
|
setup_color_selectors_set_sensitive (TRUE);
|
||||||
|
setup_create_header (tab, 15, N_("Color Stripping"));
|
||||||
|
|
||||||
/* label = gtk_label_new (_("Strip colors from:"));
|
/* label = gtk_label_new (_("Strip colors from:"));
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||||
@@ -2048,10 +2097,25 @@ static void
|
|||||||
setup_apply_to_sess (session_gui *gui)
|
setup_apply_to_sess (session_gui *gui)
|
||||||
{
|
{
|
||||||
mg_update_xtext (gui->xtext);
|
mg_update_xtext (gui->xtext);
|
||||||
|
chanview_apply_theme ((chanview *) gui->chanview);
|
||||||
|
|
||||||
if (prefs.hex_gui_ulist_style)
|
if (prefs.hex_gui_ulist_style)
|
||||||
gtk_widget_set_style (gui->user_tree, input_style);
|
gtk_widget_set_style (gui->user_tree, input_style);
|
||||||
|
|
||||||
|
if (prefs.hex_gui_ulist_style || prefs.hex_gui_dark_mode)
|
||||||
|
{
|
||||||
|
gtk_widget_modify_base (gui->user_tree, GTK_STATE_NORMAL, &colors[COL_BG]);
|
||||||
|
if (prefs.hex_gui_dark_mode)
|
||||||
|
gtk_widget_modify_text (gui->user_tree, GTK_STATE_NORMAL, &colors[COL_FG]);
|
||||||
|
else
|
||||||
|
gtk_widget_modify_text (gui->user_tree, GTK_STATE_NORMAL, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_widget_modify_base (gui->user_tree, GTK_STATE_NORMAL, NULL);
|
||||||
|
gtk_widget_modify_text (gui->user_tree, GTK_STATE_NORMAL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (prefs.hex_gui_input_style)
|
if (prefs.hex_gui_input_style)
|
||||||
{
|
{
|
||||||
extern char cursor_color_rc[];
|
extern char cursor_color_rc[];
|
||||||
@@ -2168,6 +2232,7 @@ setup_apply (struct zoitechatprefs *pr)
|
|||||||
int do_ulist = FALSE;
|
int do_ulist = FALSE;
|
||||||
int do_layout = FALSE;
|
int do_layout = FALSE;
|
||||||
int do_identd = FALSE;
|
int do_identd = FALSE;
|
||||||
|
int old_dark_mode = prefs.hex_gui_dark_mode;
|
||||||
|
|
||||||
if (strcmp (pr->hex_text_background, prefs.hex_text_background) != 0)
|
if (strcmp (pr->hex_text_background, prefs.hex_text_background) != 0)
|
||||||
new_pix = TRUE;
|
new_pix = TRUE;
|
||||||
@@ -2238,6 +2303,19 @@ setup_apply (struct zoitechatprefs *pr)
|
|||||||
|
|
||||||
memcpy (&prefs, pr, sizeof (prefs));
|
memcpy (&prefs, pr, sizeof (prefs));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "Dark mode" applies ZoiteChat's built-in dark palette to the chat views.
|
||||||
|
*
|
||||||
|
* IMPORTANT: don't short-circuit this call.
|
||||||
|
* We MUST run palette_apply_dark_mode() when the toggle changes, otherwise
|
||||||
|
* the preference flips but the palette stays the same (aka: "nothing happens").
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
gboolean pal_changed = palette_apply_dark_mode (prefs.hex_gui_dark_mode);
|
||||||
|
if (prefs.hex_gui_dark_mode != old_dark_mode || pal_changed)
|
||||||
|
color_change = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
/* merge hex_font_main and hex_font_alternative into hex_font_normal */
|
/* merge hex_font_main and hex_font_alternative into hex_font_normal */
|
||||||
old_desc = pango_font_description_from_string (prefs.hex_text_font_main);
|
old_desc = pango_font_description_from_string (prefs.hex_text_font_main);
|
||||||
@@ -2333,6 +2411,13 @@ setup_close_cb (GtkWidget *win, GtkWidget **swin)
|
|||||||
{
|
{
|
||||||
*swin = NULL;
|
*swin = NULL;
|
||||||
|
|
||||||
|
if (color_selector_widgets)
|
||||||
|
{
|
||||||
|
g_slist_free (color_selector_widgets);
|
||||||
|
color_selector_widgets = NULL;
|
||||||
|
dark_mode_toggle_widget = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (font_dialog)
|
if (font_dialog)
|
||||||
{
|
{
|
||||||
gtk_widget_destroy (font_dialog);
|
gtk_widget_destroy (font_dialog);
|
||||||
|
|||||||
Reference in New Issue
Block a user