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.
This commit is contained in:
2026-01-22 22:36:49 -07:00
parent 9959cf1f24
commit 3c0a4e4995
5 changed files with 27 additions and 5 deletions

View File

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

View File

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

View File

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

View File

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

View File

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