[gtk/text-fixes: 1/8] textview: Invalidate Pango contexts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/text-fixes: 1/8] textview: Invalidate Pango contexts
- Date: Sat, 4 Sep 2021 19:37:31 +0000 (UTC)
commit 4fee70935130bf40dd26c70afcddfbabeb3614ae
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 4 14:46:32 2021 -0400
textview: Invalidate Pango contexts
We need to invalidate the Pango contexts when
font settings change.
gtk/gtktextview.c | 46 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 3a66926e98..39398bdd92 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -397,6 +397,8 @@ static void gtk_text_view_css_changed (GtkWidget *widget,
GtkCssStyleChange *change);
static void gtk_text_view_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction);
+static void gtk_text_view_system_setting_changed (GtkWidget *widget,
+ GtkSystemSetting setting);
static void gtk_text_view_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
@@ -819,6 +821,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->map = gtk_text_view_map;
widget_class->css_changed = gtk_text_view_css_changed;
widget_class->direction_changed = gtk_text_view_direction_changed;
+ widget_class->system_setting_changed = gtk_text_view_system_setting_changed;
widget_class->state_flags_changed = gtk_text_view_state_flags_changed;
widget_class->measure = gtk_text_view_measure;
widget_class->size_allocate = gtk_text_view_size_allocate;
@@ -5028,6 +5031,38 @@ gtk_text_view_direction_changed (GtkWidget *widget,
}
}
+static void
+gtk_text_view_update_pango_contexts (GtkTextView *text_view)
+{
+ GtkTextViewPrivate *priv = text_view->priv;
+ PangoContext *ltr_context, *rtl_context;
+
+ if (!priv->layout)
+ return;
+
+ ltr_context = gtk_widget_create_pango_context (GTK_WIDGET (text_view));
+ pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
+ rtl_context = gtk_widget_create_pango_context (GTK_WIDGET (text_view));
+ pango_context_set_base_dir (rtl_context, PANGO_DIRECTION_RTL);
+
+ gtk_text_layout_set_contexts (priv->layout, ltr_context, rtl_context);
+
+ g_object_unref (ltr_context);
+ g_object_unref (rtl_context);
+}
+
+static void
+gtk_text_view_system_setting_changed (GtkWidget *widget,
+ GtkSystemSetting setting)
+{
+ if (setting == GTK_SYSTEM_SETTING_DPI ||
+ setting == GTK_SYSTEM_SETTING_FONT_NAME ||
+ setting == GTK_SYSTEM_SETTING_FONT_CONFIG)
+ {
+ gtk_text_view_update_pango_contexts (GTK_TEXT_VIEW (widget));
+ }
+}
+
static void
gtk_text_view_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state)
@@ -7809,7 +7844,6 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
if (priv->layout == NULL)
{
GtkTextAttributes *style;
- PangoContext *ltr_context, *rtl_context;
const GList *iter;
DV(g_print(G_STRLOC"\n"));
@@ -7842,15 +7876,7 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
gtk_text_layout_set_overwrite_mode (priv->layout,
priv->overwrite_mode && priv->editable);
- ltr_context = gtk_widget_create_pango_context (GTK_WIDGET (text_view));
- pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
- rtl_context = gtk_widget_create_pango_context (GTK_WIDGET (text_view));
- pango_context_set_base_dir (rtl_context, PANGO_DIRECTION_RTL);
-
- gtk_text_layout_set_contexts (priv->layout, ltr_context, rtl_context);
-
- g_object_unref (ltr_context);
- g_object_unref (rtl_context);
+ gtk_text_view_update_pango_contexts (text_view);
gtk_text_view_check_keymap_direction (text_view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]