Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
27011:f2ca52166a0d | 27012:af4a4ebc6441 |
---|---|
1037 tmp = g_strndup(css_value_start, css_value_end - css_value_start + 1); | 1037 tmp = g_strndup(css_value_start, css_value_end - css_value_start + 1); |
1038 ret = purple_unescape_html(tmp); | 1038 ret = purple_unescape_html(tmp); |
1039 g_free(tmp); | 1039 g_free(tmp); |
1040 | 1040 |
1041 return ret; | 1041 return ret; |
1042 } | |
1043 | |
1044 gboolean purple_markup_is_rtl(const char *html) | |
1045 { | |
1046 GData *attributes; | |
1047 const gchar *start, *end; | |
1048 gboolean res = FALSE; | |
1049 | |
1050 if (purple_markup_find_tag("span", html, &start, &end, &attributes)) | |
1051 { | |
1052 /* tmp is a member of attributes and is free with g_datalist_clear call */ | |
1053 const char *tmp = g_datalist_get_data(&attributes, "dir"); | |
1054 if (tmp && !g_ascii_strcasecmp(tmp, "RTL")) | |
1055 res = TRUE; | |
1056 if (!res) | |
1057 { | |
1058 tmp = g_datalist_get_data(&attributes, "style"); | |
1059 if (tmp) | |
1060 { | |
1061 char *tmp2 = purple_markup_get_css_property(tmp, "direction"); | |
1062 if (tmp2 && !g_ascii_strcasecmp(tmp2, "RTL")) | |
1063 res = TRUE; | |
1064 g_free(tmp2); | |
1065 } | |
1066 | |
1067 } | |
1068 g_datalist_clear(&attributes); | |
1069 } | |
1070 return res; | |
1042 } | 1071 } |
1043 | 1072 |
1044 gboolean | 1073 gboolean |
1045 purple_markup_find_tag(const char *needle, const char *haystack, | 1074 purple_markup_find_tag(const char *needle, const char *haystack, |
1046 const char **start, const char **end, GData **attributes) | 1075 const char **start, const char **end, GData **attributes) |