[gtk/wip/chergert/textview-access-to-contexts] textview: give application developers access to RTL and LTR context




commit 78ac4c883199a625994e33f02c9ad103da011596
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jun 19 12:20:23 2021 -0700

    textview: give application developers access to RTL and LTR context
    
    This allows developers to modify the pango context that is used when
    rendering text within the text view.
    
    Such access can be useful to alter how rounding occurs with API such as
    pango_context_set_round_glyph_positions() and is needed by GtkSourceView
    for proper placement of glyphs within the overview map.

 gtk/gtktextview.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtktextview.h |  4 ++++
 2 files changed, 50 insertions(+)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 669312faa5..2ca95d739a 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -9963,3 +9963,49 @@ gtk_text_view_buffer_notify_undo (GtkTextBuffer *buffer,
                                  (gtk_text_view_get_editable (view) &&
                                   gtk_text_buffer_get_can_undo (buffer)));
 }
+
+/**
+ * gtk_text_view_get_ltr_context:
+ * @text_view: a #GtkTextView
+ *
+ * Gets the #PangoContext that is used for rendering LTR directed
+ * text layouts.
+ *
+ * The context may be replaced when CSS changes occur.
+ *
+ * Returns: (transfer none): a #PangoContext
+ *
+ * Since: 4.4
+ */
+PangoContext *
+gtk_text_view_get_ltr_context (GtkTextView *text_view)
+{
+  g_return_val_if_fail (GTK_IS_TEXT_VIEW (text_view), NULL);
+
+  gtk_text_view_ensure_layout (text_view);
+
+  return text_view->priv->layout->ltr_context;
+}
+
+/**
+ * gtk_text_view_get_rtl_context:
+ * @text_view: a #GtkTextView
+ *
+ * Gets the #PangoContext that is used for rendering RTL directed
+ * text layouts.
+ *
+ * The context may be replaced when CSS changes occur.
+ *
+ * Returns: (transfer none): a #PangoContext
+ *
+ * Since: 4.4
+ */
+PangoContext *
+gtk_text_view_get_rtl_context (GtkTextView *text_view)
+{
+  g_return_val_if_fail (GTK_IS_TEXT_VIEW (text_view), NULL);
+
+  gtk_text_view_ensure_layout (text_view);
+
+  return text_view->priv->layout->rtl_context;
+}
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index 2b412e6500..325077a871 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -427,6 +427,10 @@ void             gtk_text_view_set_extra_menu         (GtkTextView      *text_vi
                                                        GMenuModel       *model);
 GDK_AVAILABLE_IN_ALL
 GMenuModel *     gtk_text_view_get_extra_menu         (GtkTextView      *text_view);
+GDK_AVAILABLE_IN_ALL
+PangoContext    *gtk_text_view_get_rtl_context        (GtkTextView      *text_view);
+GDK_AVAILABLE_IN_ALL
+PangoContext    *gtk_text_view_get_ltr_context        (GtkTextView      *text_view);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]