pidgin/gtkconv.c

changeset 27234
82035475de62
parent 27141
271318a26229
child 27321
98f2f5ce5085
child 27361
62f1aa8045bb
child 27439
482df00eccd3
child 27591
efc1df00bf0b
equal deleted inserted replaced
27230:17f893b060d7 27234:82035475de62
5627 g_free(*str); 5627 g_free(*str);
5628 *str = ret; 5628 *str = ret;
5629 #endif 5629 #endif
5630 } 5630 }
5631 5631
5632 /* Returns true if the given HTML contains RTL text */
5633 static gboolean
5634 html_is_rtl(const char *html)
5635 {
5636 GData *attributes;
5637 const gchar *start, *end;
5638 gboolean res = FALSE;
5639
5640 if (purple_markup_find_tag("span", html, &start, &end, &attributes))
5641 {
5642 /* tmp is a member of attributes and is free with g_datalist_clear call */
5643 const char *tmp = g_datalist_get_data(&attributes, "dir");
5644 if (tmp && !g_ascii_strcasecmp(tmp, "RTL"))
5645 res = TRUE;
5646 if (!res)
5647 {
5648 tmp = g_datalist_get_data(&attributes, "style");
5649 if (tmp)
5650 {
5651 char *tmp2 = purple_markup_get_css_property(tmp, "direction");
5652 if (tmp2 && !g_ascii_strcasecmp(tmp2, "RTL"))
5653 res = TRUE;
5654 g_free(tmp2);
5655 }
5656
5657 }
5658 g_datalist_clear(&attributes);
5659 }
5660 return res;
5661 }
5662
5663
5664 static void 5632 static void
5665 pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *alias, 5633 pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *alias,
5666 const char *message, PurpleMessageFlags flags, 5634 const char *message, PurpleMessageFlags flags,
5667 time_t mtime) 5635 time_t mtime)
5668 { 5636 {
5820 tmp = purple_time_format(tm); 5788 tmp = purple_time_format(tm);
5821 mdate = g_strdup_printf("(%s)", tmp); 5789 mdate = g_strdup_printf("(%s)", tmp);
5822 } 5790 }
5823 5791
5824 /* Bi-Directional support - set timestamp direction using unicode characters */ 5792 /* Bi-Directional support - set timestamp direction using unicode characters */
5825 is_rtl_message = html_is_rtl(message); 5793 is_rtl_message = purple_markup_is_rtl(message);
5826 /* Enforce direction only if message is RTL - doesn't effect LTR users */ 5794 /* Enforce direction only if message is RTL - doesn't effect LTR users */
5827 if (is_rtl_message) 5795 if (is_rtl_message)
5828 str_embed_direction_chars(&mdate); 5796 str_embed_direction_chars(&mdate);
5829 5797
5830 if (mtime >= gtkconv->newday) 5798 if (mtime >= gtkconv->newday)

mercurial