From 1bb0451d75016f360889c95704b03b8ea6dfda11 Mon Sep 17 00:00:00 2001 From: deepend Date: Fri, 23 Jan 2026 00:23:00 -0700 Subject: [PATCH] Updated GTK3 palette color parsing to use full 16-bit hex strings when converting to RGBA in palette handling and setup color dialogs. Switched GtkCellRendererText foreground bindings to the palette foreground property macro in user list, notify list, and DCC views. --- src/fe-gtk/dccgui.c | 8 +------- src/fe-gtk/notifygui.c | 10 ++-------- src/fe-gtk/palette.c | 6 +++--- src/fe-gtk/setup.c | 6 +++--- src/fe-gtk/userlistgui.c | 8 +------- 5 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c index 0ef75386..59a77373 100644 --- a/src/fe-gtk/dccgui.c +++ b/src/fe-gtk/dccgui.c @@ -731,18 +731,12 @@ static void dcc_add_column (GtkWidget *tree, int textcol, int colorcol, char *title, gboolean right_justified) { GtkCellRenderer *renderer; - const char *foreground_property = -#if GTK_CHECK_VERSION(3,0,0) - "foreground-rgba"; -#else - "foreground-gdk"; -#endif renderer = gtk_cell_renderer_text_new (); if (right_justified) g_object_set (G_OBJECT (renderer), "xalign", (float) 1.0, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, title, renderer, - "text", textcol, foreground_property, colorcol, + "text", textcol, PALETTE_FOREGROUND_PROPERTY, colorcol, NULL); 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 6d3015ec..ef31e895 100644 --- a/src/fe-gtk/notifygui.c +++ b/src/fe-gtk/notifygui.c @@ -74,24 +74,18 @@ notify_treecell_property_mapper (GtkTreeViewColumn *col, GtkCellRenderer *cell, gchar *text; PaletteColor *colour; int model_column = GPOINTER_TO_INT (data); - const char *foreground_property = -#if GTK_CHECK_VERSION(3,0,0) - "foreground-rgba"; -#else - "foreground-gdk"; -#endif gtk_tree_model_get (GTK_TREE_MODEL (model), iter, COLOUR_COLUMN, &colour, model_column, &text, -1); #if GTK_CHECK_VERSION(3,0,0) g_object_set (G_OBJECT (cell), "text", text, - foreground_property, colour, NULL); + PALETTE_FOREGROUND_PROPERTY, colour, NULL); if (colour) gdk_rgba_free (colour); #else g_object_set (G_OBJECT (cell), "text", text, - foreground_property, colour, NULL); + PALETTE_FOREGROUND_PROPERTY, colour, NULL); if (colour) gdk_color_free (colour); #endif diff --git a/src/fe-gtk/palette.c b/src/fe-gtk/palette.c index 0d91f316..f1412c63 100644 --- a/src/fe-gtk/palette.c +++ b/src/fe-gtk/palette.c @@ -48,12 +48,12 @@ static void palette_color_set_rgb16 (PaletteColor *color, guint16 red, guint16 green, guint16 blue) { #if GTK_CHECK_VERSION(3,0,0) - char color_string[8]; + char color_string[16]; GdkRGBA parsed = { 0 }; gboolean parsed_ok; - g_snprintf (color_string, sizeof (color_string), "#%02x%02x%02x", - red >> 8, green >> 8, blue >> 8); + g_snprintf (color_string, sizeof (color_string), "#%04x%04x%04x", + red, green, blue); parsed_ok = gdk_rgba_parse (&parsed, color_string); if (!parsed_ok) { diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 8d3fa1bf..f41d4c2e 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -1537,11 +1537,11 @@ static void setup_rgba_from_palette (const PaletteColor *color, GdkRGBA *rgba) { guint16 red, green, blue; - char color_string[8]; + char color_string[16]; palette_color_get_rgb16 (color, &red, &green, &blue); - g_snprintf (color_string, sizeof (color_string), "#%02x%02x%02x", - red >> 8, green >> 8, blue >> 8); + g_snprintf (color_string, sizeof (color_string), "#%04x%04x%04x", + red, green, blue); if (!gdk_rgba_parse (rgba, color_string)) { rgba->red = red / 65535.0; diff --git a/src/fe-gtk/userlistgui.c b/src/fe-gtk/userlistgui.c index 5278c741..7676dc34 100644 --- a/src/fe-gtk/userlistgui.c +++ b/src/fe-gtk/userlistgui.c @@ -533,12 +533,6 @@ static void userlist_add_columns (GtkTreeView * treeview) { GtkCellRenderer *renderer; - const char *foreground_property = -#if GTK_CHECK_VERSION(3,0,0) - "foreground-rgba"; -#else - "foreground-gdk"; -#endif /* icon column */ renderer = gtk_cell_renderer_pixbuf_new (); @@ -555,7 +549,7 @@ userlist_add_columns (GtkTreeView * treeview) gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1, NULL, renderer, - "text", 1, foreground_property, 4, NULL); + "text", 1, PALETTE_FOREGROUND_PROPERTY, 4, NULL); if (prefs.hex_gui_ulist_show_hosts) {