mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 16:00:18 +00:00
Centralized the palette foreground property definition for GTK2/GTK3 and applied it to the user list, notify list, and DCC tree renderers to use RGBA where supported.
Removed legacy colormap allocation/free calls in palette handling and setup color selection while preserving the GTK2 path logic.
This commit is contained in:
@@ -730,11 +730,7 @@ dcc_add_column (GtkWidget *tree, int textcol, int colorcol, char *title, gboolea
|
||||
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,
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
"text", textcol, "foreground-rgba", colorcol,
|
||||
#else
|
||||
"text", textcol, "foreground-gdk", colorcol,
|
||||
#endif
|
||||
"text", textcol, PALETTE_FOREGROUND_PROPERTY, colorcol,
|
||||
NULL);
|
||||
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
|
||||
}
|
||||
|
||||
@@ -79,11 +79,7 @@ notify_treecell_property_mapper (GtkTreeViewColumn *col, GtkCellRenderer *cell,
|
||||
COLOUR_COLUMN, &colour,
|
||||
model_column, &text, -1);
|
||||
g_object_set (G_OBJECT (cell), "text", text, 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_object_set (G_OBJECT (cell), PALETTE_FOREGROUND_PROPERTY, colour, NULL);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
|
||||
@@ -248,21 +248,7 @@ palette_dark_set_color (int idx, const PaletteColor *col)
|
||||
void
|
||||
palette_alloc (GtkWidget * widget)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
(void) widget;
|
||||
#else
|
||||
int i;
|
||||
static int done_alloc = FALSE;
|
||||
GdkColormap *cmap;
|
||||
|
||||
if (!done_alloc) /* don't do it again */
|
||||
{
|
||||
done_alloc = TRUE;
|
||||
cmap = gtk_widget_get_colormap (widget);
|
||||
for (i = MAX_COL; i >= 0; i--)
|
||||
gdk_colormap_alloc_color (cmap, &colors[i], FALSE, TRUE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -473,15 +459,7 @@ palette_apply_dark_mode (gboolean enable)
|
||||
memcpy (colors, user_colors, sizeof (colors));
|
||||
|
||||
/* Allocate the new colors for GTK's colormap. */
|
||||
#if !GTK_CHECK_VERSION(3,0,0)
|
||||
{
|
||||
GdkColormap *cmap;
|
||||
|
||||
cmap = gdk_colormap_get_system ();
|
||||
for (i = 0; i <= MAX_COL; i++)
|
||||
gdk_colormap_alloc_color (cmap, &colors[i], FALSE, TRUE);
|
||||
}
|
||||
#endif
|
||||
(void) i;
|
||||
|
||||
for (i = 0; i <= MAX_COL; i++)
|
||||
{
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
typedef GdkRGBA PaletteColor;
|
||||
#define PALETTE_GDK_TYPE GDK_TYPE_RGBA
|
||||
#define PALETTE_FOREGROUND_PROPERTY "foreground-rgba"
|
||||
#else
|
||||
typedef GdkColor PaletteColor;
|
||||
#define PALETTE_GDK_TYPE GDK_TYPE_COLOR
|
||||
#define PALETTE_FOREGROUND_PROPERTY "foreground-gdk"
|
||||
#endif
|
||||
|
||||
extern PaletteColor colors[];
|
||||
|
||||
@@ -1559,9 +1559,7 @@ setup_color_ok_cb (GtkWidget *button, GtkWidget *dialog)
|
||||
{
|
||||
GtkColorSelectionDialog *cdialog = GTK_COLOR_SELECTION_DIALOG (dialog);
|
||||
GdkColor *col;
|
||||
GdkColor old_color;
|
||||
col = g_object_get_data (G_OBJECT (button), "c");
|
||||
old_color = *col;
|
||||
|
||||
button = g_object_get_data (G_OBJECT (button), "b");
|
||||
|
||||
@@ -1575,17 +1573,8 @@ setup_color_ok_cb (GtkWidget *button, GtkWidget *dialog)
|
||||
|
||||
gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (cdialog)), col);
|
||||
|
||||
#if !GTK_CHECK_VERSION(3,0,0)
|
||||
gdk_colormap_alloc_color (gtk_widget_get_colormap (button), col, TRUE, TRUE);
|
||||
#endif
|
||||
|
||||
setup_color_button_apply (button, col);
|
||||
|
||||
/* is this line correct?? */
|
||||
#if !GTK_CHECK_VERSION(3,0,0)
|
||||
gdk_colormap_free_colors (gtk_widget_get_colormap (button), &old_color, 1);
|
||||
#endif
|
||||
|
||||
/* Persist custom colors for the palette the user is editing. */
|
||||
if (fe_dark_mode_is_enabled_for (setup_prefs.hex_gui_dark_mode))
|
||||
palette_dark_set_color ((int)(col - colors), col);
|
||||
|
||||
@@ -528,11 +528,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,
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
"text", 1, "foreground-rgba", 4, NULL);
|
||||
#else
|
||||
"text", 1, "foreground-gdk", 4, NULL);
|
||||
#endif
|
||||
"text", 1, PALETTE_FOREGROUND_PROPERTY, 4, NULL);
|
||||
|
||||
if (prefs.hex_gui_ulist_show_hosts)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user