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.
This commit is contained in:
2026-01-23 00:23:00 -07:00
parent ea4ef5be90
commit 1bb0451d75
5 changed files with 10 additions and 28 deletions

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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)
{