From 9bdbeffeb067cbe08efab98e0a9526274b7cdec4 Mon Sep 17 00:00:00 2001 From: deepend Date: Fri, 30 Jan 2026 18:39:49 -0700 Subject: [PATCH] Updated the chanview API to use GTK3-safe font descriptions while keeping GTK2 style handling conditional in the header and implementation. Guarded tree view palette application to use GTK3 font descriptions or GTK2 styles appropriately. Adjusted the chanview creation call site to pass GTK3 font descriptions or GTK2 styles based on the build. --- src/fe-gtk/chanview-tree.c | 10 ++++++++-- src/fe-gtk/chanview.c | 15 ++++++++++++++- src/fe-gtk/chanview.h | 8 +++++++- src/fe-gtk/maingui.c | 7 ++++++- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/fe-gtk/chanview-tree.c b/src/fe-gtk/chanview-tree.c index 7d4ce157..2ffd2cc5 100644 --- a/src/fe-gtk/chanview-tree.c +++ b/src/fe-gtk/chanview-tree.c @@ -116,11 +116,17 @@ cv_tree_init (chanview *cv) view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (cv->store)); gtk_widget_set_name (view, "zoitechat-tree"); - if (cv->style) + if ( +#if HAVE_GTK3 + cv->font_desc +#else + cv->style +#endif + ) { #if HAVE_GTK3 gtkutil_apply_palette (view, &colors[COL_BG], &colors[COL_FG], - cv->style->font_desc); + cv->font_desc); #else gtkutil_apply_palette (view, &cv->style->base[GTK_STATE_NORMAL], &cv->style->text[GTK_STATE_NORMAL], diff --git a/src/fe-gtk/chanview.c b/src/fe-gtk/chanview.c index 2e261c64..b4ded326 100644 --- a/src/fe-gtk/chanview.c +++ b/src/fe-gtk/chanview.c @@ -45,7 +45,11 @@ struct _chanview int size; /* number of channels in view */ GtkWidget *box; /* the box we destroy when changing implementations */ +#if HAVE_GTK3 + PangoFontDescription *font_desc; /* font used for tree */ +#else InputStyle *style; /* style used for tree */ +#endif chan *focused; /* currently focused channel */ int trunc_len; @@ -292,14 +296,23 @@ chanview_box_destroy_cb (GtkWidget *box, chanview *cv) chanview * chanview_new (int type, int trunc_len, gboolean sort, gboolean use_icons, - InputStyle *style) +#if HAVE_GTK3 + PangoFontDescription *font_desc +#else + InputStyle *style +#endif +) { chanview *cv; cv = g_new0 (chanview, 1); cv->store = gtk_tree_store_new (4, G_TYPE_STRING, G_TYPE_POINTER, PANGO_TYPE_ATTR_LIST, GDK_TYPE_PIXBUF); +#if HAVE_GTK3 + cv->font_desc = font_desc; +#else cv->style = style; +#endif #if HAVE_GTK3 cv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #elif !HAVE_GTK3 diff --git a/src/fe-gtk/chanview.h b/src/fe-gtk/chanview.h index dd91d1a7..9b597a1a 100644 --- a/src/fe-gtk/chanview.h +++ b/src/fe-gtk/chanview.h @@ -25,7 +25,13 @@ typedef struct _chanview chanview; typedef struct _chan chan; -chanview *chanview_new (int type, int trunc_len, gboolean sort, gboolean use_icons, InputStyle *style); +chanview *chanview_new (int type, int trunc_len, gboolean sort, gboolean use_icons, +#if HAVE_GTK3 + PangoFontDescription *font_desc +#else + InputStyle *style +#endif +); void chanview_set_callbacks (chanview *cv, void (*cb_focus) (chanview *, chan *, int tag, void *userdata), void (*cb_xbutton) (chanview *, chan *, int tag, void *userdata), diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index d15a3ff5..af5743d6 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -3709,7 +3709,12 @@ mg_create_tabs (session_gui *gui) gui->chanview = chanview_new (prefs.hex_gui_tab_layout, prefs.hex_gui_tab_trunc, prefs.hex_gui_tab_sort, use_icons, - prefs.hex_gui_ulist_style ? input_style : NULL); +#if HAVE_GTK3 + prefs.hex_gui_ulist_style && input_style ? input_style->font_desc : NULL +#else + prefs.hex_gui_ulist_style ? input_style : NULL +#endif + ); chanview_set_callbacks (gui->chanview, mg_switch_tab_cb, mg_xbutton_cb, mg_tab_contextmenu_cb, (void *)mg_tabs_compare); mg_place_userlist_and_chanview (gui);