]> git.0d.be Git - empathy.git/commitdiff
Make empathy_string_replace_link and empathy_string_replace_escaped public
authorXavier Claessens <xclaesse@gmail.com>
Wed, 3 Mar 2010 14:39:40 +0000 (15:39 +0100)
committerXavier Claessens <xclaesse@gmail.com>
Wed, 3 Mar 2010 15:18:45 +0000 (16:18 +0100)
The code is moved from empathy-theme-adium.c

libempathy-gtk/empathy-string-parser.c
libempathy-gtk/empathy-string-parser.h
libempathy-gtk/empathy-theme-adium.c

index 27421eb59cfd586ba5f2882f1950861484e13e1a..1240edd50acdc5da993475a8803789977c247579 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "empathy-string-parser.h"
 #include "empathy-smiley-manager.h"
+#include "empathy-ui-utils.h"
 
 #define SCHEMES           "([a-zA-Z\\+]+)"
 #define INVALID_CHARS     "\\s\"'"
@@ -152,3 +153,41 @@ empathy_string_match_all (const gchar *text,
        replace_func (text, len, NULL, user_data);
 }
 
+void
+empathy_string_replace_link (const gchar *text,
+                             gssize len,
+                             gpointer match_data,
+                             gpointer user_data)
+{
+       GString *string = user_data;
+       gchar *real_url;
+       gchar *escaped;
+
+       real_url = empathy_make_absolute_url_len (text, len);
+
+       /* The thing we are making a link of may contain
+        * characters which need escaping */
+       escaped = g_markup_escape_text (text, len);
+
+       /* Append the link inside <a href=""></a> tag */
+       g_string_append_printf (string, "<a href=\"%s\">%s</a>",
+                               real_url, escaped);
+
+       g_free (real_url);
+       g_free (escaped);
+}
+
+void
+empathy_string_replace_escaped (const gchar *text,
+                               gssize len,
+                               gpointer match_data,
+                               gpointer user_data)
+{
+       GString *string = user_data;
+       gchar *escaped;
+
+       escaped = g_markup_escape_text (text, len);
+       g_string_append (string, escaped);
+       g_free (escaped);
+}
+
index 696545b65e34edffd33b62719780d36de6f296ab..db646d60b9190457b1b3445ad2ed510004d15e08 100644 (file)
@@ -69,6 +69,19 @@ empathy_string_match_all (const gchar *text,
                          EmpathyStringParser *sub_parsers,
                          gpointer user_data);
 
+/* Replace functions assume user_data is a GString */
+void
+empathy_string_replace_link (const gchar *text,
+                             gssize len,
+                             gpointer match_data,
+                             gpointer user_data);
+
+void
+empathy_string_replace_escaped (const gchar *text,
+                               gssize len,
+                               gpointer match_data,
+                               gpointer user_data);
+
 G_END_DECLS
 
 #endif /*  __EMPATHY_STRING_PARSER_H__ */
index ef7d3a73e5e42167ddeb52b6575eb9eb94ab6289..7736be27070bb2e783fc545502aafaff94d0c0a4 100644 (file)
@@ -221,30 +221,6 @@ theme_adium_match_newline (const gchar *text,
                                      sub_parsers, user_data);
 }
 
-static void
-theme_adium_replace_link (const gchar *text,
-                         gssize len,
-                         gpointer match_data,
-                         gpointer user_data)
-{
-       GString *string = user_data;
-       gchar *real_url;
-       gchar *escaped;
-
-       real_url = empathy_make_absolute_url_len (text, len);
-
-       /* The thing we are making a link of may contain
-        * characters which need escaping */
-       escaped = g_markup_escape_text (text, len);
-
-       /* Append the link inside <a href=""></a> tag */
-       g_string_append_printf (string, "<a href=\"%s\">%s</a>",
-                               real_url, escaped);
-
-       g_free (real_url);
-       g_free (escaped);
-}
-
 static void
 theme_adium_replace_smiley (const gchar *text,
                            gssize len,
@@ -260,32 +236,18 @@ theme_adium_replace_smiley (const gchar *text,
                                hit->path, (int)len, text, (int)len, text);
 }
 
-static void
-theme_adium_replace_escaped (const gchar *text,
-                            gssize len,
-                            gpointer match_data,
-                            gpointer user_data)
-{
-       GString *string = user_data;
-       gchar *escaped;
-
-       escaped = g_markup_escape_text (text, len);
-       g_string_append (string, escaped);
-       g_free (escaped);
-}
-
 static EmpathyStringParser string_parsers[] = {
-       {empathy_string_match_link, theme_adium_replace_link},
+       {empathy_string_match_link, empathy_string_replace_link},
        {theme_adium_match_newline, NULL},
-       {empathy_string_match_all, theme_adium_replace_escaped},
+       {empathy_string_match_all, empathy_string_replace_escaped},
        {NULL, NULL}
 };
 
 static EmpathyStringParser string_parsers_with_smiley[] = {
-       {empathy_string_match_link, theme_adium_replace_link},
+       {empathy_string_match_link, empathy_string_replace_link},
        {empathy_string_match_smiley, theme_adium_replace_smiley},
        {theme_adium_match_newline, NULL},
-       {empathy_string_match_all, theme_adium_replace_escaped},
+       {empathy_string_match_all, empathy_string_replace_escaped},
        {NULL, NULL}
 };