mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-16 10:40:19 +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)
|
if (right_justified)
|
||||||
g_object_set (G_OBJECT (renderer), "xalign", (float) 1.0, NULL);
|
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,
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, title, renderer,
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
"text", textcol, PALETTE_FOREGROUND_PROPERTY, colorcol,
|
||||||
"text", textcol, "foreground-rgba", colorcol,
|
|
||||||
#else
|
|
||||||
"text", textcol, "foreground-gdk", colorcol,
|
|
||||||
#endif
|
|
||||||
NULL);
|
NULL);
|
||||||
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
|
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,
|
COLOUR_COLUMN, &colour,
|
||||||
model_column, &text, -1);
|
model_column, &text, -1);
|
||||||
g_object_set (G_OBJECT (cell), "text", text, NULL);
|
g_object_set (G_OBJECT (cell), "text", text, NULL);
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
g_object_set (G_OBJECT (cell), PALETTE_FOREGROUND_PROPERTY, colour, NULL);
|
||||||
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);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -248,21 +248,7 @@ palette_dark_set_color (int idx, const PaletteColor *col)
|
|||||||
void
|
void
|
||||||
palette_alloc (GtkWidget * widget)
|
palette_alloc (GtkWidget * widget)
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
|
||||||
(void) widget;
|
(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
|
void
|
||||||
@@ -473,15 +459,7 @@ palette_apply_dark_mode (gboolean enable)
|
|||||||
memcpy (colors, user_colors, sizeof (colors));
|
memcpy (colors, user_colors, sizeof (colors));
|
||||||
|
|
||||||
/* Allocate the new colors for GTK's colormap. */
|
/* Allocate the new colors for GTK's colormap. */
|
||||||
#if !GTK_CHECK_VERSION(3,0,0)
|
(void) i;
|
||||||
{
|
|
||||||
GdkColormap *cmap;
|
|
||||||
|
|
||||||
cmap = gdk_colormap_get_system ();
|
|
||||||
for (i = 0; i <= MAX_COL; i++)
|
|
||||||
gdk_colormap_alloc_color (cmap, &colors[i], FALSE, TRUE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i <= MAX_COL; i++)
|
for (i = 0; i <= MAX_COL; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,9 +27,11 @@
|
|||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
typedef GdkRGBA PaletteColor;
|
typedef GdkRGBA PaletteColor;
|
||||||
#define PALETTE_GDK_TYPE GDK_TYPE_RGBA
|
#define PALETTE_GDK_TYPE GDK_TYPE_RGBA
|
||||||
|
#define PALETTE_FOREGROUND_PROPERTY "foreground-rgba"
|
||||||
#else
|
#else
|
||||||
typedef GdkColor PaletteColor;
|
typedef GdkColor PaletteColor;
|
||||||
#define PALETTE_GDK_TYPE GDK_TYPE_COLOR
|
#define PALETTE_GDK_TYPE GDK_TYPE_COLOR
|
||||||
|
#define PALETTE_FOREGROUND_PROPERTY "foreground-gdk"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern PaletteColor colors[];
|
extern PaletteColor colors[];
|
||||||
|
|||||||
@@ -1559,9 +1559,7 @@ setup_color_ok_cb (GtkWidget *button, GtkWidget *dialog)
|
|||||||
{
|
{
|
||||||
GtkColorSelectionDialog *cdialog = GTK_COLOR_SELECTION_DIALOG (dialog);
|
GtkColorSelectionDialog *cdialog = GTK_COLOR_SELECTION_DIALOG (dialog);
|
||||||
GdkColor *col;
|
GdkColor *col;
|
||||||
GdkColor old_color;
|
|
||||||
col = g_object_get_data (G_OBJECT (button), "c");
|
col = g_object_get_data (G_OBJECT (button), "c");
|
||||||
old_color = *col;
|
|
||||||
|
|
||||||
button = g_object_get_data (G_OBJECT (button), "b");
|
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);
|
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);
|
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. */
|
/* Persist custom colors for the palette the user is editing. */
|
||||||
if (fe_dark_mode_is_enabled_for (setup_prefs.hex_gui_dark_mode))
|
if (fe_dark_mode_is_enabled_for (setup_prefs.hex_gui_dark_mode))
|
||||||
palette_dark_set_color ((int)(col - colors), col);
|
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_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),
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||||
-1, NULL, renderer,
|
-1, NULL, renderer,
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
"text", 1, PALETTE_FOREGROUND_PROPERTY, 4, NULL);
|
||||||
"text", 1, "foreground-rgba", 4, NULL);
|
|
||||||
#else
|
|
||||||
"text", 1, "foreground-gdk", 4, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (prefs.hex_gui_ulist_show_hosts)
|
if (prefs.hex_gui_ulist_show_hosts)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user