From 1fb1865acad6a9205061596380fab7a7326bb048 Mon Sep 17 00:00:00 2001 From: deepend Date: Sat, 31 Jan 2026 13:38:05 -0700 Subject: [PATCH] Switched palette type selection and color conversion helpers to use the HAVE_GTK3 guard consistently in palette definitions and helpers. Updated GTK3-specific palette color storage handling in DCC, notify, and user list views to align with HAVE_GTK3 guards. Standardized setup color application and dialog logic to use HAVE_GTK3 branches for GTK3/GTK2 separation. --- src/fe-gtk/dccgui.c | 2 +- src/fe-gtk/notifygui.c | 4 ++-- src/fe-gtk/palette.c | 10 +++++----- src/fe-gtk/palette.h | 4 ++-- src/fe-gtk/setup.c | 14 +++++++------- src/fe-gtk/userlistgui.c | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c index 079176ce..2e16debb 100644 --- a/src/fe-gtk/dccgui.c +++ b/src/fe-gtk/dccgui.c @@ -192,7 +192,7 @@ dcc_store_color (GtkListStore *store, GtkTreeIter *iter, int column, int color_i if (color_index != 1) color = &colors[color_index]; -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 if (color) { GdkRGBA rgba = *color; diff --git a/src/fe-gtk/notifygui.c b/src/fe-gtk/notifygui.c index 1d9de1d9..e52b4180 100644 --- a/src/fe-gtk/notifygui.c +++ b/src/fe-gtk/notifygui.c @@ -91,7 +91,7 @@ notify_treecell_property_mapper (GtkTreeViewColumn *col, GtkCellRenderer *cell, gtk_tree_model_get (GTK_TREE_MODEL (model), iter, COLOUR_COLUMN, &colour, model_column, &text, -1); -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 g_object_set (G_OBJECT (cell), "text", text, PALETTE_FOREGROUND_PROPERTY, colour, NULL); if (colour) @@ -108,7 +108,7 @@ notify_treecell_property_mapper (GtkTreeViewColumn *col, GtkCellRenderer *cell, static void notify_store_color (GtkListStore *store, GtkTreeIter *iter, const PaletteColor *color) { -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 if (color) { GdkRGBA rgba = *color; diff --git a/src/fe-gtk/palette.c b/src/fe-gtk/palette.c index f1412c63..1092dc6a 100644 --- a/src/fe-gtk/palette.c +++ b/src/fe-gtk/palette.c @@ -38,7 +38,7 @@ #include "../common/cfgfiles.h" #include "../common/typedef.h" -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 #define PALETTE_COLOR_INIT(r, g, b) { (r) / 65535.0, (g) / 65535.0, (b) / 65535.0, 1.0 } #else #define PALETTE_COLOR_INIT(r, g, b) { 0, (r), (g), (b) } @@ -47,7 +47,7 @@ static void palette_color_set_rgb16 (PaletteColor *color, guint16 red, guint16 green, guint16 blue) { -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 char color_string[16]; GdkRGBA parsed = { 0 }; gboolean parsed_ok; @@ -82,7 +82,7 @@ palette_color_from_gdk (const PaletteColor *color) { XTextColor result; -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 result.red = color->red; result.green = color->green; result.blue = color->blue; @@ -227,7 +227,7 @@ palette_user_set_color (int idx, const PaletteColor *col) user_colors_valid = TRUE; } -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 user_colors[idx] = *col; #else user_colors[idx].red = col->red; @@ -252,7 +252,7 @@ palette_dark_set_color (int idx, const PaletteColor *col) dark_user_colors_valid = TRUE; } -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 dark_user_colors[idx] = *col; #else dark_user_colors[idx].red = col->red; diff --git a/src/fe-gtk/palette.h b/src/fe-gtk/palette.h index 1670f323..65c0633f 100644 --- a/src/fe-gtk/palette.h +++ b/src/fe-gtk/palette.h @@ -24,7 +24,7 @@ #include "xtext-color.h" -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 typedef GdkRGBA PaletteColor; #define PALETTE_GDK_TYPE GDK_TYPE_RGBA #define PALETTE_FOREGROUND_PROPERTY "foreground-rgba" @@ -39,7 +39,7 @@ extern PaletteColor colors[]; static inline void palette_color_get_rgb16 (const PaletteColor *color, guint16 *red, guint16 *green, guint16 *blue) { -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 *red = (guint16) CLAMP (color->red * 65535.0 + 0.5, 0.0, 65535.0); *green = (guint16) CLAMP (color->green * 65535.0 + 0.5, 0.0, 65535.0); *blue = (guint16) CLAMP (color->blue * 65535.0 + 0.5, 0.0, 65535.0); diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 645bcb3c..5721d13d 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -1692,7 +1692,7 @@ setup_color_button_apply (GtkWidget *button, const PaletteColor *color) { GtkWidget *target = g_object_get_data (G_OBJECT (button), "zoitechat-color-box"); GtkWidget *apply_widget = GTK_IS_WIDGET (target) ? target : button; -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 GtkStateFlags states[] = { GTK_STATE_FLAG_NORMAL, GTK_STATE_FLAG_PRELIGHT, @@ -1712,7 +1712,7 @@ setup_color_button_apply (GtkWidget *button, const PaletteColor *color) guint i; for (i = 0; i < G_N_ELEMENTS (states); i++) -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 gtk_widget_override_background_color (apply_widget, states[i], color); #else gtk_widget_modify_bg (apply_widget, states[i], color); @@ -1720,7 +1720,7 @@ setup_color_button_apply (GtkWidget *button, const PaletteColor *color) if (apply_widget != button) for (i = 0; i < G_N_ELEMENTS (states); i++) -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 gtk_widget_override_background_color (button, states[i], color); #else gtk_widget_modify_bg (button, states[i], color); @@ -1729,7 +1729,7 @@ setup_color_button_apply (GtkWidget *button, const PaletteColor *color) gtk_widget_queue_draw (button); } -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 typedef struct { GtkWidget *button; @@ -1812,7 +1812,7 @@ setup_color_ok_cb (GtkWidget *button, GtkWidget *dialog) static void setup_color_cb (GtkWidget *button, gpointer userdata) { -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 GtkWidget *dialog; PaletteColor *color; GdkRGBA rgba; @@ -2802,7 +2802,7 @@ setup_create_tree (GtkWidget *box, GtkWidget *book) static void setup_apply_entry_style (GtkWidget *entry) { -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 gtk_widget_override_background_color (entry, GTK_STATE_FLAG_NORMAL, &colors[COL_BG]); gtk_widget_override_color (entry, GTK_STATE_FLAG_NORMAL, &colors[COL_FG]); gtk_widget_override_font (entry, input_style->font_desc); @@ -2828,7 +2828,7 @@ setup_apply_to_sess (session_gui *gui) #endif } -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 if (prefs.hex_gui_ulist_style || fe_dark_mode_is_enabled ()) { gtk_widget_override_background_color (gui->user_tree, GTK_STATE_FLAG_NORMAL, &colors[COL_BG]); diff --git a/src/fe-gtk/userlistgui.c b/src/fe-gtk/userlistgui.c index c0440426..d1862daf 100644 --- a/src/fe-gtk/userlistgui.c +++ b/src/fe-gtk/userlistgui.c @@ -473,7 +473,7 @@ userlist_store_color (GtkListStore *store, GtkTreeIter *iter, int color_index) { const PaletteColor *color = color_index ? &colors[color_index] : NULL; -#if GTK_CHECK_VERSION(3,0,0) +#if HAVE_GTK3 if (color) { GdkRGBA rgba = *color;