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.
This commit is contained in:
Matthias Clasen 2019-01-31 14:03:49 -05:00
parent dbd360262c
commit 2350d0945a
3 changed files with 48 additions and 1 deletions

View File

@ -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__ */

View File

@ -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;
}

View File

@ -351,7 +351,6 @@ void gdk_synthesize_surface_state (GdkSurface *surface,
GdkSurfaceState unset_flags,
GdkSurfaceState set_flags);
G_END_DECLS
#endif /* __GDK_INTERNALS_H__ */