aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-ui-utils.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-11-24 22:54:21 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-11-25 01:29:45 +0800
commit9c1e21c7ad3ba913ebf144b498aa2de6d22a7797 (patch)
tree6ac07a5634e6ca93cf9b7ea0edbe0a9e9cc9bb0a /libempathy-gtk/empathy-ui-utils.c
parentebaadd93adf03514e9e629b6ae7b065803b046e7 (diff)
downloadgsoc2013-empathy-9c1e21c7ad3ba913ebf144b498aa2de6d22a7797.tar
gsoc2013-empathy-9c1e21c7ad3ba913ebf144b498aa2de6d22a7797.tar.gz
gsoc2013-empathy-9c1e21c7ad3ba913ebf144b498aa2de6d22a7797.tar.bz2
gsoc2013-empathy-9c1e21c7ad3ba913ebf144b498aa2de6d22a7797.tar.lz
gsoc2013-empathy-9c1e21c7ad3ba913ebf144b498aa2de6d22a7797.tar.xz
gsoc2013-empathy-9c1e21c7ad3ba913ebf144b498aa2de6d22a7797.tar.zst
gsoc2013-empathy-9c1e21c7ad3ba913ebf144b498aa2de6d22a7797.zip
Replace GString param with a generic gpointer user_data, and port EmpathyChatTextView to new parser API.
Diffstat (limited to 'libempathy-gtk/empathy-ui-utils.c')
-rw-r--r--libempathy-gtk/empathy-ui-utils.c63
1 files changed, 30 insertions, 33 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 137dd3bca..a72a06b9d 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1572,25 +1572,24 @@ empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler)
}
void
-empathy_string_parser_substr (GString *string,
- const gchar *text,
+empathy_string_parser_substr (const gchar *text,
gssize len,
- EmpathyStringParser *parsers)
+ EmpathyStringParser *parsers,
+ gpointer user_data)
{
if (parsers != NULL && parsers[0].match_func != NULL) {
- parsers[0].match_func (string, text, len,
- parsers[0].replace_func, parsers + 1);
- } else {
- g_string_append_len (string, text, len);
+ parsers[0].match_func (text, len,
+ parsers[0].replace_func, parsers + 1,
+ user_data);
}
}
void
-empathy_string_match_link (GString *string,
- const gchar *text,
+empathy_string_match_link (const gchar *text,
gssize len,
EmpathyStringReplace replace_func,
- EmpathyStringParser *sub_parsers)
+ EmpathyStringParser *sub_parsers,
+ gpointer user_data)
{
GRegex *uri_regex;
GMatchInfo *match_info;
@@ -1608,29 +1607,31 @@ empathy_string_match_link (GString *string,
if (s > last) {
/* Append the text between last link (or the
* start of the message) and this link */
- empathy_string_parser_substr (string, text + last,
+ empathy_string_parser_substr (text + last,
s - last,
- sub_parsers);
+ sub_parsers,
+ user_data);
}
- replace_func (string, text + s, e - s, NULL);
+ replace_func (text + s, e - s, NULL, user_data);
last = e;
} while (g_match_info_next (match_info, NULL));
}
- empathy_string_parser_substr (string, text + last, len - last, sub_parsers);
+ empathy_string_parser_substr (text + last, len - last,
+ sub_parsers, user_data);
g_match_info_free (match_info);
g_regex_unref (uri_regex);
}
void
-empathy_string_match_smiley (GString *string,
- const gchar *text,
+empathy_string_match_smiley (const gchar *text,
gssize len,
EmpathyStringReplace replace_func,
- EmpathyStringParser *sub_parsers)
+ EmpathyStringParser *sub_parsers,
+ gpointer user_data)
{
guint last = 0;
EmpathySmileyManager *smiley_manager;
@@ -1645,14 +1646,13 @@ empathy_string_match_smiley (GString *string,
if (hit->start > last) {
/* Append the text between last smiley (or the
* start of the message) and this smiley */
- empathy_string_parser_substr (string, text + last,
+ empathy_string_parser_substr (text + last,
hit->start - last,
- sub_parsers);
+ sub_parsers, user_data);
}
- replace_func (string,
- text + hit->start, hit->end - hit->start,
- hit);
+ replace_func (text + hit->start, hit->end - hit->start,
+ hit, user_data);
last = hit->end;
@@ -1661,20 +1661,17 @@ empathy_string_match_smiley (GString *string,
g_slist_free (hits);
g_object_unref (smiley_manager);
- empathy_string_parser_substr (string, text + last, len - last, sub_parsers);
+ empathy_string_parser_substr (text + last, len - last,
+ sub_parsers, user_data);
}
void
-empathy_string_match_escape (GString *string,
- const gchar *text,
- gssize len,
- EmpathyStringReplace replace_func,
- EmpathyStringParser *sub_parsers)
+empathy_string_match_all (const gchar *text,
+ gssize len,
+ EmpathyStringReplace replace_func,
+ EmpathyStringParser *sub_parsers,
+ gpointer user_data)
{
- gchar *escaped;
-
- escaped = g_markup_escape_text (text, len);
- g_string_append (string, escaped);
- g_free (escaped);
+ replace_func (text, len, NULL, user_data);
}