mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-12 08:40:19 +00:00
Added a GTK3 fallback when parsing palette RGB16 values into GdkRGBA colors to keep RGBA initialization robust.
Updated GTK3 list-model color storage and GtkCellRendererText foreground properties to use RGBA values in the user list, notify list, and DCC views while retaining GTK2 behavior. Copied palette RGBA values before initializing the GTK3 color chooser dialog to ensure RGBA usage on the GTK3 path.
This commit is contained in:
@@ -160,8 +160,15 @@ dcc_store_color (GtkListStore *store, GtkTreeIter *iter, int column, int color_i
|
||||
color = &colors[color_index];
|
||||
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
const GdkRGBA *rgba = color;
|
||||
gtk_list_store_set (store, iter, column, rgba, -1);
|
||||
if (color)
|
||||
{
|
||||
GdkRGBA rgba = *color;
|
||||
gtk_list_store_set (store, iter, column, &rgba, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_list_store_set (store, iter, column, NULL, -1);
|
||||
}
|
||||
#else
|
||||
gtk_list_store_set (store, iter, column, color, -1);
|
||||
#endif
|
||||
@@ -728,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -87,8 +91,15 @@ static void
|
||||
notify_store_color (GtkListStore *store, GtkTreeIter *iter, const PaletteColor *color)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
const GdkRGBA *rgba = color;
|
||||
gtk_list_store_set (store, iter, COLOUR_COLUMN, rgba, -1);
|
||||
if (color)
|
||||
{
|
||||
GdkRGBA rgba = *color;
|
||||
gtk_list_store_set (store, iter, COLOUR_COLUMN, &rgba, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_list_store_set (store, iter, COLOUR_COLUMN, NULL, -1);
|
||||
}
|
||||
#else
|
||||
gtk_list_store_set (store, iter, COLOUR_COLUMN, color, -1);
|
||||
#endif
|
||||
|
||||
@@ -50,9 +50,17 @@ palette_color_set_rgb16 (PaletteColor *color, guint16 red, guint16 green, guint1
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
char buf[8];
|
||||
GdkRGBA parsed;
|
||||
gboolean parsed_ok;
|
||||
|
||||
g_snprintf (buf, sizeof (buf), "#%02x%02x%02x", red >> 8, green >> 8, blue >> 8);
|
||||
gdk_rgba_parse (&parsed, buf);
|
||||
parsed_ok = gdk_rgba_parse (&parsed, buf);
|
||||
if (!parsed_ok)
|
||||
{
|
||||
parsed.red = red / 65535.0;
|
||||
parsed.green = green / 65535.0;
|
||||
parsed.blue = blue / 65535.0;
|
||||
parsed.alpha = 1.0;
|
||||
}
|
||||
*color = parsed;
|
||||
#else
|
||||
color->red = red;
|
||||
|
||||
@@ -1594,12 +1594,14 @@ setup_color_cb (GtkWidget *button, gpointer userdata)
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
GtkWidget *dialog;
|
||||
PaletteColor *color;
|
||||
GdkRGBA rgba;
|
||||
setup_color_dialog_data *data;
|
||||
|
||||
color = &colors[GPOINTER_TO_INT (userdata)];
|
||||
|
||||
dialog = gtk_color_chooser_dialog_new (_("Select color"), GTK_WINDOW (setup_window));
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), color);
|
||||
rgba = *color;
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &rgba);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
data = g_new0 (setup_color_dialog_data, 1);
|
||||
|
||||
@@ -474,8 +474,15 @@ userlist_store_color (GtkListStore *store, GtkTreeIter *iter, int color_index)
|
||||
const PaletteColor *color = color_index ? &colors[color_index] : NULL;
|
||||
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
const GdkRGBA *rgba = color;
|
||||
gtk_list_store_set (store, iter, COL_GDKCOLOR, rgba, -1);
|
||||
if (color)
|
||||
{
|
||||
GdkRGBA rgba = *color;
|
||||
gtk_list_store_set (store, iter, COL_GDKCOLOR, &rgba, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_list_store_set (store, iter, COL_GDKCOLOR, NULL, -1);
|
||||
}
|
||||
#else
|
||||
gtk_list_store_set (store, iter, COL_GDKCOLOR, color, -1);
|
||||
#endif
|
||||
@@ -540,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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user