summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-01-31 14:03:49 -0500
committerMatthias Clasen <mclasen@redhat.com>2019-02-04 18:28:31 -0500
commit2350d0945a5fe185e4911dcad59d5f5ab2626853 (patch)
tree86b10ab8816b49f7670d55d6dc7ecb05b975c24e /gdk
parentdbd360262cf8a56477dafea4293b2d9cec62bae7 (diff)
downloadgtk+-2350d0945a5fe185e4911dcad59d5f5ab2626853.tar.gz
gdk: Add a copy of some deprecated pango api
We use pango_find_base_dir() in a few places, and this api has been deprecated.
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdk-private.h4
-rw-r--r--gdk/gdk.c44
-rw-r--r--gdk/gdkinternals.h1
3 files changed, 48 insertions, 1 deletions
diff --git a/gdk/gdk-private.h b/gdk/gdk-private.h
index 0c83002bfc..551ecac9aa 100644
--- a/gdk/gdk-private.h
+++ b/gdk/gdk-private.h
@@ -36,4 +36,8 @@ gboolean gdk_should_use_portal (void);
const gchar * gdk_get_startup_notification_id (void);
+PangoDirection gdk_unichar_direction (gunichar ch);
+PangoDirection gdk_find_base_dir (const char *text,
+ int len);
+
#endif /* __GDK__PRIVATE_H__ */
diff --git a/gdk/gdk.c b/gdk/gdk.c
index d623afabf9..6954ef772e 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -40,6 +40,8 @@
#include <string.h>
#include <stdlib.h>
+#include <fribidi.h>
+
/**
* SECTION:general
@@ -343,3 +345,45 @@ gdk_should_use_portal (void)
* management for you.
*/
+PangoDirection
+gdk_unichar_direction (gunichar ch)
+{
+ FriBidiCharType fribidi_ch_type;
+
+ G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar));
+
+ fribidi_ch_type = fribidi_get_bidi_type (ch);
+
+ if (!FRIBIDI_IS_STRONG (fribidi_ch_type))
+ return PANGO_DIRECTION_NEUTRAL;
+ else if (FRIBIDI_IS_RTL (fribidi_ch_type))
+ return PANGO_DIRECTION_RTL;
+ else
+ return PANGO_DIRECTION_LTR;
+}
+
+PangoDirection
+gdk_find_base_dir (const gchar *text,
+ gint length)
+{
+ PangoDirection dir = PANGO_DIRECTION_NEUTRAL;
+ const gchar *p;
+
+ g_return_val_if_fail (text != NULL || length == 0, PANGO_DIRECTION_NEUTRAL);
+
+ p = text;
+ while ((length < 0 || p < text + length) && *p)
+ {
+ gunichar wc = g_utf8_get_char (p);
+
+ dir = gdk_unichar_direction (wc);
+
+ if (dir != PANGO_DIRECTION_NEUTRAL)
+ break;
+
+ p = g_utf8_next_char (p);
+ }
+
+ return dir;
+}
+
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index f64f38dd4b..a8c4bb6176 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -351,7 +351,6 @@ void gdk_synthesize_surface_state (GdkSurface *surface,
GdkSurfaceState unset_flags,
GdkSurfaceState set_flags);
-
G_END_DECLS
#endif /* __GDK_INTERNALS_H__ */