Mercurial > pidgin
diff libpurple/util.c @ 27012:af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Use this function to check for RTL text in messages. Fixes #9261.
| author | Sadrul Habib Chowdhury <imadil@gmail.com> |
|---|---|
| date | Wed, 03 Jun 2009 17:04:05 +0000 |
| parents | f303787f144d |
| children | bf9db4c67679 |
line wrap: on
line diff
--- a/libpurple/util.c Wed Jun 03 15:50:08 2009 +0000 +++ b/libpurple/util.c Wed Jun 03 17:04:05 2009 +0000 @@ -1041,6 +1041,35 @@ return ret; } +gboolean purple_markup_is_rtl(const char *html) +{ + GData *attributes; + const gchar *start, *end; + gboolean res = FALSE; + + if (purple_markup_find_tag("span", html, &start, &end, &attributes)) + { + /* tmp is a member of attributes and is free with g_datalist_clear call */ + const char *tmp = g_datalist_get_data(&attributes, "dir"); + if (tmp && !g_ascii_strcasecmp(tmp, "RTL")) + res = TRUE; + if (!res) + { + tmp = g_datalist_get_data(&attributes, "style"); + if (tmp) + { + char *tmp2 = purple_markup_get_css_property(tmp, "direction"); + if (tmp2 && !g_ascii_strcasecmp(tmp2, "RTL")) + res = TRUE; + g_free(tmp2); + } + + } + g_datalist_clear(&attributes); + } + return res; +} + gboolean purple_markup_find_tag(const char *needle, const char *haystack, const char **start, const char **end, GData **attributes)
