mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-18 03:30:18 +00:00
Updated emoji font fallback/primary application to use GTK3 style context fonts with gtk_widget_override_font, while keeping GTK2 style/modify calls behind #if !HAVE_GTK3.
Applied GTK3 font overrides for the user list font setting in setup_apply_to_sess, with GTK2 fallback preserved under #if !HAVE_GTK3
This commit is contained in:
@@ -3178,42 +3178,84 @@ mg_fontdesc_with_fallback (const PangoFontDescription *base_desc, gboolean emoji
|
|||||||
static void
|
static void
|
||||||
mg_apply_emoji_fallback_widget (GtkWidget *widget)
|
mg_apply_emoji_fallback_widget (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
GtkStyle *style;
|
|
||||||
PangoFontDescription *desc;
|
PangoFontDescription *desc;
|
||||||
|
#if HAVE_GTK3
|
||||||
|
GtkStyleContext *context;
|
||||||
|
const PangoFontDescription *base_desc;
|
||||||
|
#else
|
||||||
|
GtkStyle *style;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!widget)
|
if (!widget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if HAVE_GTK3
|
||||||
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
if (!context)
|
||||||
|
return;
|
||||||
|
|
||||||
|
base_desc = gtk_style_context_get_font (context, GTK_STATE_FLAG_NORMAL);
|
||||||
|
if (!base_desc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
desc = mg_fontdesc_with_fallback (base_desc, FALSE);
|
||||||
|
#else
|
||||||
style = gtk_widget_get_style (widget);
|
style = gtk_widget_get_style (widget);
|
||||||
if (!style || !style->font_desc)
|
if (!style || !style->font_desc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
desc = mg_fontdesc_with_fallback (style->font_desc, FALSE);
|
desc = mg_fontdesc_with_fallback (style->font_desc, FALSE);
|
||||||
|
#endif
|
||||||
if (!desc)
|
if (!desc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if HAVE_GTK3
|
||||||
|
gtk_widget_override_font (widget, desc);
|
||||||
|
#else
|
||||||
gtk_widget_modify_font (widget, desc);
|
gtk_widget_modify_font (widget, desc);
|
||||||
|
#endif
|
||||||
pango_font_description_free (desc);
|
pango_font_description_free (desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mg_apply_emoji_primary_widget (GtkWidget *widget)
|
mg_apply_emoji_primary_widget (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
GtkStyle *style;
|
|
||||||
PangoFontDescription *desc;
|
PangoFontDescription *desc;
|
||||||
|
#if HAVE_GTK3
|
||||||
|
GtkStyleContext *context;
|
||||||
|
const PangoFontDescription *base_desc;
|
||||||
|
#else
|
||||||
|
GtkStyle *style;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!widget)
|
if (!widget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if HAVE_GTK3
|
||||||
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
if (!context)
|
||||||
|
return;
|
||||||
|
|
||||||
|
base_desc = gtk_style_context_get_font (context, GTK_STATE_FLAG_NORMAL);
|
||||||
|
if (!base_desc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
desc = mg_fontdesc_with_fallback (base_desc, TRUE);
|
||||||
|
#else
|
||||||
style = gtk_widget_get_style (widget);
|
style = gtk_widget_get_style (widget);
|
||||||
if (!style || !style->font_desc)
|
if (!style || !style->font_desc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
desc = mg_fontdesc_with_fallback (style->font_desc, TRUE);
|
desc = mg_fontdesc_with_fallback (style->font_desc, TRUE);
|
||||||
|
#endif
|
||||||
if (!desc)
|
if (!desc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if HAVE_GTK3
|
||||||
|
gtk_widget_override_font (widget, desc);
|
||||||
|
#else
|
||||||
gtk_widget_modify_font (widget, desc);
|
gtk_widget_modify_font (widget, desc);
|
||||||
|
#endif
|
||||||
pango_font_description_free (desc);
|
pango_font_description_free (desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2814,7 +2814,13 @@ setup_apply_to_sess (session_gui *gui)
|
|||||||
chanview_apply_theme ((chanview *) gui->chanview);
|
chanview_apply_theme ((chanview *) gui->chanview);
|
||||||
|
|
||||||
if (prefs.hex_gui_ulist_style)
|
if (prefs.hex_gui_ulist_style)
|
||||||
|
{
|
||||||
|
#if HAVE_GTK3
|
||||||
|
gtk_widget_override_font (gui->user_tree, input_style->font_desc);
|
||||||
|
#else
|
||||||
gtk_widget_modify_font (gui->user_tree, input_style->font_desc);
|
gtk_widget_modify_font (gui->user_tree, input_style->font_desc);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
if (prefs.hex_gui_ulist_style || fe_dark_mode_is_enabled ())
|
if (prefs.hex_gui_ulist_style || fe_dark_mode_is_enabled ())
|
||||||
|
|||||||
Reference in New Issue
Block a user