mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
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.
This commit is contained in:
@@ -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],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user