Updated setup color dialog RGBA derivation to parse hex palette components with gdk_rgba_parse for GTK3 paths.

Standardized GtkCellRendererText foreground color binding to use the palette foreground property macro across user list, DCC, and notify views.
This commit is contained in:
2026-01-22 23:18:59 -07:00
parent bc11f40a7a
commit dae5eadf1a
4 changed files with 9 additions and 14 deletions

View File

@@ -731,11 +731,7 @@ static void
dcc_add_column (GtkWidget *tree, int textcol, int colorcol, char *title, gboolean right_justified) dcc_add_column (GtkWidget *tree, int textcol, int colorcol, char *title, gboolean right_justified)
{ {
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
#if GTK_CHECK_VERSION(3,0,0) const char *foreground_property = PALETTE_FOREGROUND_PROPERTY;
const char *foreground_property = "foreground-rgba";
#else
const char *foreground_property = "foreground-gdk";
#endif
renderer = gtk_cell_renderer_text_new (); renderer = gtk_cell_renderer_text_new ();
if (right_justified) if (right_justified)

View File

@@ -80,11 +80,11 @@ notify_treecell_property_mapper (GtkTreeViewColumn *col, GtkCellRenderer *cell,
model_column, &text, -1); model_column, &text, -1);
g_object_set (G_OBJECT (cell), "text", text, NULL); g_object_set (G_OBJECT (cell), "text", text, NULL);
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
g_object_set (G_OBJECT (cell), "foreground-rgba", colour, NULL); g_object_set (G_OBJECT (cell), PALETTE_FOREGROUND_PROPERTY, colour, NULL);
if (colour) if (colour)
gdk_rgba_free (colour); gdk_rgba_free (colour);
#else #else
g_object_set (G_OBJECT (cell), "foreground-gdk", colour, NULL); g_object_set (G_OBJECT (cell), PALETTE_FOREGROUND_PROPERTY, colour, NULL);
if (colour) if (colour)
gdk_color_free (colour); gdk_color_free (colour);
#endif #endif

View File

@@ -1536,9 +1536,12 @@ typedef struct
static void static void
setup_rgba_from_palette (const PaletteColor *color, GdkRGBA *rgba) setup_rgba_from_palette (const PaletteColor *color, GdkRGBA *rgba)
{ {
g_autofree char *color_string = gdk_rgba_to_string (color); guint16 red, green, blue;
char color_string[16];
if (!color_string || !gdk_rgba_parse (rgba, color_string)) palette_color_get_rgb16 (color, &red, &green, &blue);
g_snprintf (color_string, sizeof (color_string), "#%04x%04x%04x", red, green, blue);
if (!gdk_rgba_parse (rgba, color_string))
*rgba = *color; *rgba = *color;
} }

View File

@@ -533,11 +533,7 @@ static void
userlist_add_columns (GtkTreeView * treeview) userlist_add_columns (GtkTreeView * treeview)
{ {
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
#if GTK_CHECK_VERSION(3,0,0) const char *foreground_property = PALETTE_FOREGROUND_PROPERTY;
const char *foreground_property = "foreground-rgba";
#else
const char *foreground_property = "foreground-gdk";
#endif
/* icon column */ /* icon column */
renderer = gtk_cell_renderer_pixbuf_new (); renderer = gtk_cell_renderer_pixbuf_new ();