From 3c0a4e4995b6484f38b0b851ec05d97f37ed20ea Mon Sep 17 00:00:00 2001 From: deepend Date: Thu, 22 Jan 2026 22:36:49 -0700 Subject: [PATCH] Updated RGB16 palette parsing to use 16-bit RGBA strings with gdk_rgba_parse for GTK3 builds. Parsed palette colors before initializing the GTK3 color chooser dialog to ensure RGBA normalization. Switched GTK3 GtkCellRendererText foreground bindings to foreground-rgba with GTK2 fallbacks in user list, notify, and DCC views. --- src/fe-gtk/dccgui.c | 8 +++++++- src/fe-gtk/notifygui.c | 6 +++++- src/fe-gtk/palette.c | 2 +- src/fe-gtk/setup.c | 8 +++++++- src/fe-gtk/userlistgui.c | 8 +++++++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c index 59a77373..cbf4e697 100644 --- a/src/fe-gtk/dccgui.c +++ b/src/fe-gtk/dccgui.c @@ -735,9 +735,15 @@ dcc_add_column (GtkWidget *tree, int textcol, int colorcol, char *title, gboolea renderer = gtk_cell_renderer_text_new (); if (right_justified) g_object_set (G_OBJECT (renderer), "xalign", (float) 1.0, NULL); +#if GTK_CHECK_VERSION(3,0,0) gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, title, renderer, - "text", textcol, PALETTE_FOREGROUND_PROPERTY, colorcol, + "text", textcol, "foreground-rgba", colorcol, NULL); +#else + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, title, renderer, + "text", textcol, "foreground-gdk", colorcol, + NULL); +#endif gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1); } diff --git a/src/fe-gtk/notifygui.c b/src/fe-gtk/notifygui.c index c036b210..b7d8b86f 100644 --- a/src/fe-gtk/notifygui.c +++ b/src/fe-gtk/notifygui.c @@ -79,7 +79,11 @@ notify_treecell_property_mapper (GtkTreeViewColumn *col, GtkCellRenderer *cell, COLOUR_COLUMN, &colour, model_column, &text, -1); g_object_set (G_OBJECT (cell), "text", text, NULL); - g_object_set (G_OBJECT (cell), PALETTE_FOREGROUND_PROPERTY, colour, NULL); +#if GTK_CHECK_VERSION(3,0,0) + g_object_set (G_OBJECT (cell), "foreground-rgba", colour, NULL); +#else + g_object_set (G_OBJECT (cell), "foreground-gdk", colour, NULL); +#endif g_free (text); } diff --git a/src/fe-gtk/palette.c b/src/fe-gtk/palette.c index 3365ed8f..f666a6a5 100644 --- a/src/fe-gtk/palette.c +++ b/src/fe-gtk/palette.c @@ -52,7 +52,7 @@ palette_color_set_rgb16 (PaletteColor *color, guint16 red, guint16 green, guint1 gboolean parsed_ok; char *color_string; - color_string = g_strdup_printf ("#%02x%02x%02x", red >> 8, green >> 8, blue >> 8); + color_string = g_strdup_printf ("#%04x%04x%04x", red, green, blue); parsed_ok = gdk_rgba_parse (&parsed, color_string); g_free (color_string); if (!parsed_ok) diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index a3924dc7..9a98a7db 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -1595,12 +1595,18 @@ setup_color_cb (GtkWidget *button, gpointer userdata) GtkWidget *dialog; PaletteColor *color; GdkRGBA rgba; + gboolean parsed_ok; + char *color_string; setup_color_dialog_data *data; color = &colors[GPOINTER_TO_INT (userdata)]; dialog = gtk_color_chooser_dialog_new (_("Select color"), GTK_WINDOW (setup_window)); - rgba = *color; + color_string = gdk_rgba_to_string (color); + parsed_ok = gdk_rgba_parse (&rgba, color_string); + g_free (color_string); + if (!parsed_ok) + rgba = *color; gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &rgba); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); diff --git a/src/fe-gtk/userlistgui.c b/src/fe-gtk/userlistgui.c index 7676dc34..76a9bef9 100644 --- a/src/fe-gtk/userlistgui.c +++ b/src/fe-gtk/userlistgui.c @@ -547,9 +547,15 @@ userlist_add_columns (GtkTreeView * treeview) if (prefs.hex_gui_compact) g_object_set (G_OBJECT (renderer), "ypad", 0, NULL); gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1); +#if GTK_CHECK_VERSION(3,0,0) gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1, NULL, renderer, - "text", 1, PALETTE_FOREGROUND_PROPERTY, 4, NULL); + "text", 1, "foreground-rgba", 4, NULL); +#else + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), + -1, NULL, renderer, + "text", 1, "foreground-gdk", 4, NULL); +#endif if (prefs.hex_gui_ulist_show_hosts) {