mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
Updated notify list cell rendering to apply GTK3 RGBA foreground properties and free boxed colors correctly while keeping GTK2 behavior intact.
Switched user list and DCC tree view text columns to select the GTK3 foreground-rgba property (with GTK2 fallbacks) for cell renderer text colors. Reused RGBA parsing for palette-backed color chooser defaults and clarified palette change tracking comments.
This commit is contained in:
@@ -731,12 +731,17 @@ static void
|
||||
dcc_add_column (GtkWidget *tree, int textcol, int colorcol, char *title, gboolean right_justified)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
#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 ();
|
||||
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, PALETTE_FOREGROUND_PROPERTY, colorcol,
|
||||
"text", textcol, foreground_property, colorcol,
|
||||
NULL);
|
||||
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,15 @@ 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);
|
||||
if (colour)
|
||||
gdk_rgba_free (colour);
|
||||
#else
|
||||
g_object_set (G_OBJECT (cell), "foreground-gdk", colour, NULL);
|
||||
if (colour)
|
||||
gdk_color_free (colour);
|
||||
#endif
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
|
||||
@@ -468,7 +468,7 @@ palette_apply_dark_mode (gboolean enable)
|
||||
else
|
||||
memcpy (colors, user_colors, sizeof (colors));
|
||||
|
||||
/* Allocate the new colors for GTK's colormap. */
|
||||
/* Track whether any palette entries changed. */
|
||||
(void) i;
|
||||
|
||||
for (i = 0; i <= MAX_COL; i++)
|
||||
|
||||
@@ -1533,6 +1533,15 @@ typedef struct
|
||||
PaletteColor *color;
|
||||
} setup_color_dialog_data;
|
||||
|
||||
static void
|
||||
setup_rgba_from_palette (const PaletteColor *color, GdkRGBA *rgba)
|
||||
{
|
||||
g_autofree char *color_string = gdk_rgba_to_string (color);
|
||||
|
||||
if (!color_string || !gdk_rgba_parse (rgba, color_string))
|
||||
*rgba = *color;
|
||||
}
|
||||
|
||||
static void
|
||||
setup_color_response_cb (GtkDialog *dialog, gint response_id, gpointer user_data)
|
||||
{
|
||||
@@ -1595,17 +1604,12 @@ setup_color_cb (GtkWidget *button, gpointer userdata)
|
||||
GtkWidget *dialog;
|
||||
PaletteColor *color;
|
||||
GdkRGBA rgba;
|
||||
gboolean parsed_ok;
|
||||
g_autofree char *color_string = NULL;
|
||||
setup_color_dialog_data *data;
|
||||
|
||||
color = &colors[GPOINTER_TO_INT (userdata)];
|
||||
|
||||
dialog = gtk_color_chooser_dialog_new (_("Select color"), GTK_WINDOW (setup_window));
|
||||
color_string = gdk_rgba_to_string (color);
|
||||
parsed_ok = color_string && gdk_rgba_parse (&rgba, color_string);
|
||||
if (!parsed_ok)
|
||||
rgba = *color;
|
||||
setup_rgba_from_palette (color, &rgba);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &rgba);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
|
||||
@@ -533,6 +533,11 @@ static void
|
||||
userlist_add_columns (GtkTreeView * treeview)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
const char *foreground_property = "foreground-rgba";
|
||||
#else
|
||||
const char *foreground_property = "foreground-gdk";
|
||||
#endif
|
||||
|
||||
/* icon column */
|
||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
@@ -549,7 +554,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, PALETTE_FOREGROUND_PROPERTY, 4, NULL);
|
||||
"text", 1, foreground_property, 4, NULL);
|
||||
|
||||
if (prefs.hex_gui_ulist_show_hosts)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user