mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 16:00:18 +00:00
Updated GTK3 color parsing in the palette/setup helpers to use RGBA-friendly hex strings with gdk_rgba_parse fallbacks while preserving GTK2 behavior.
Switched GtkCellRendererText foreground property selection to foreground-rgba on GTK3 paths (with GTK2 guarded), covering userlist, notify, and DCC views.
This commit is contained in:
@@ -731,7 +731,12 @@ static void
|
||||
dcc_add_column (GtkWidget *tree, int textcol, int colorcol, char *title, gboolean right_justified)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
const char *foreground_property = PALETTE_FOREGROUND_PROPERTY;
|
||||
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)
|
||||
|
||||
@@ -74,18 +74,24 @@ 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,
|
||||
PALETTE_FOREGROUND_PROPERTY, colour, NULL);
|
||||
foreground_property, colour, NULL);
|
||||
if (colour)
|
||||
gdk_rgba_free (colour);
|
||||
#else
|
||||
g_object_set (G_OBJECT (cell), "text", text,
|
||||
PALETTE_FOREGROUND_PROPERTY, colour, NULL);
|
||||
foreground_property, colour, NULL);
|
||||
if (colour)
|
||||
gdk_color_free (colour);
|
||||
#endif
|
||||
|
||||
@@ -47,13 +47,13 @@
|
||||
static void
|
||||
palette_color_set_rgb16 (PaletteColor *color, guint16 red, guint16 green, guint16 blue)
|
||||
{
|
||||
char color_string[16];
|
||||
|
||||
g_snprintf (color_string, sizeof (color_string), "#%04x%04x%04x", red, green, blue);
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
char color_string[8];
|
||||
GdkRGBA parsed = { 0 };
|
||||
gboolean parsed_ok;
|
||||
|
||||
g_snprintf (color_string, sizeof (color_string), "#%02x%02x%02x",
|
||||
red >> 8, green >> 8, blue >> 8);
|
||||
parsed_ok = gdk_rgba_parse (&parsed, color_string);
|
||||
if (!parsed_ok)
|
||||
{
|
||||
@@ -64,6 +64,9 @@ palette_color_set_rgb16 (PaletteColor *color, guint16 red, guint16 green, guint1
|
||||
}
|
||||
*color = parsed;
|
||||
#else
|
||||
char color_string[16];
|
||||
|
||||
g_snprintf (color_string, sizeof (color_string), "#%04x%04x%04x", red, green, blue);
|
||||
if (!gdk_color_parse (color_string, color))
|
||||
{
|
||||
color->red = red;
|
||||
|
||||
@@ -1537,10 +1537,11 @@ static void
|
||||
setup_rgba_from_palette (const PaletteColor *color, GdkRGBA *rgba)
|
||||
{
|
||||
guint16 red, green, blue;
|
||||
char color_string[16];
|
||||
char color_string[8];
|
||||
|
||||
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), "#%02x%02x%02x",
|
||||
red >> 8, green >> 8, blue >> 8);
|
||||
if (!gdk_rgba_parse (rgba, color_string))
|
||||
{
|
||||
rgba->red = red / 65535.0;
|
||||
|
||||
@@ -533,7 +533,12 @@ static void
|
||||
userlist_add_columns (GtkTreeView * treeview)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
const char *foreground_property = PALETTE_FOREGROUND_PROPERTY;
|
||||
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 ();
|
||||
|
||||
Reference in New Issue
Block a user