Parsed palette color strings with RGBA/GdkColor parsing fallbacks for GTK3/GTK2 palette updates.

Adjusted setup RGBA conversion fallback to explicit channel conversion when parsing fails.
Updated GtkCellRendererText foreground property handling for GTK2/GTK3 in user list, DCC list, and notify list rendering.
This commit is contained in:
2026-01-22 23:45:02 -07:00
parent 5596c8825b
commit 864bf5e059
5 changed files with 29 additions and 12 deletions

View File

@@ -731,7 +731,11 @@ 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;
const char *foreground_property = PALETTE_FOREGROUND_PROPERTY; #if GTK_CHECK_VERSION(3,0,0)
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), PALETTE_FOREGROUND_PROPERTY, colour, NULL); g_object_set (G_OBJECT (cell), "foreground-rgba", colour, NULL);
if (colour) if (colour)
gdk_rgba_free (colour); gdk_rgba_free (colour);
#else #else
g_object_set (G_OBJECT (cell), PALETTE_FOREGROUND_PROPERTY, colour, NULL); g_object_set (G_OBJECT (cell), "foreground-gdk", colour, NULL);
if (colour) if (colour)
gdk_color_free (colour); gdk_color_free (colour);
#endif #endif

View File

@@ -47,12 +47,13 @@
static void static void
palette_color_set_rgb16 (PaletteColor *color, guint16 red, guint16 green, guint16 blue) palette_color_set_rgb16 (PaletteColor *color, guint16 red, guint16 green, guint16 blue)
{ {
#if GTK_CHECK_VERSION(3,0,0)
GdkRGBA parsed;
gboolean parsed_ok;
char color_string[16]; char color_string[16];
g_snprintf (color_string, sizeof (color_string), "#%04x%04x%04x", red, green, blue); g_snprintf (color_string, sizeof (color_string), "#%04x%04x%04x", red, green, blue);
#if GTK_CHECK_VERSION(3,0,0)
GdkRGBA parsed;
gboolean parsed_ok;
parsed_ok = gdk_rgba_parse (&parsed, color_string); parsed_ok = gdk_rgba_parse (&parsed, color_string);
if (!parsed_ok) if (!parsed_ok)
{ {
@@ -63,10 +64,13 @@ palette_color_set_rgb16 (PaletteColor *color, guint16 red, guint16 green, guint1
} }
*color = parsed; *color = parsed;
#else #else
color->red = red; if (!gdk_color_parse (color_string, color))
color->green = green; {
color->blue = blue; color->red = red;
color->pixel = 0; color->green = green;
color->blue = blue;
color->pixel = 0;
}
#endif #endif
} }

View File

@@ -1542,7 +1542,12 @@ setup_rgba_from_palette (const PaletteColor *color, GdkRGBA *rgba)
palette_color_get_rgb16 (color, &red, &green, &blue); palette_color_get_rgb16 (color, &red, &green, &blue);
g_snprintf (color_string, sizeof (color_string), "#%04x%04x%04x", red, green, blue); g_snprintf (color_string, sizeof (color_string), "#%04x%04x%04x", red, green, blue);
if (!gdk_rgba_parse (rgba, color_string)) if (!gdk_rgba_parse (rgba, color_string))
*rgba = *color; {
rgba->red = red / 65535.0;
rgba->green = green / 65535.0;
rgba->blue = blue / 65535.0;
rgba->alpha = 1.0;
}
} }
static void static void

View File

@@ -533,7 +533,11 @@ static void
userlist_add_columns (GtkTreeView * treeview) userlist_add_columns (GtkTreeView * treeview)
{ {
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
const char *foreground_property = PALETTE_FOREGROUND_PROPERTY; #if GTK_CHECK_VERSION(3,0,0)
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 ();