aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat-text-view.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-03-03 17:46:50 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-03-03 17:46:50 +0800
commitba7eae326c9cd3e12447bf636cedfae6284b2581 (patch)
tree25d1aec934c513dc6165b59fb7d6a8430713c319 /libempathy-gtk/empathy-chat-text-view.c
parent02c2e9960f1a66ed3661e67f1038a6aeea7a2d69 (diff)
downloadgsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar
gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.gz
gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.bz2
gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.lz
gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.xz
gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.zst
gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.zip
Move URI regex to empathy-ui-utils
From: Xavier Claessens <xclaesse@gmail.com> svn path=/trunk/; revision=2549
Diffstat (limited to 'libempathy-gtk/empathy-chat-text-view.c')
-rw-r--r--libempathy-gtk/empathy-chat-text-view.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c
index f645cf88c..f15d076ff 100644
--- a/libempathy-gtk/empathy-chat-text-view.c
+++ b/libempathy-gtk/empathy-chat-text-view.c
@@ -62,15 +62,6 @@
#define MAX_SCROLL_TIME 0.4 /* seconds */
#define SCROLL_DELAY 33 /* milliseconds */
-#define SCHEMES "(https?|s?ftps?|nntp|news|javascript|about|ghelp|apt|telnet|"\
- "file|webcal|mailto)"
-#define BODY "([^\\ \\n]+)"
-#define END_BODY "([^\\ \\n]*[^,;\?><()\\ \"\\.\\n])"
-#define URI_REGEX "("SCHEMES"://"END_BODY")" \
- "|((mailto:)?"BODY"@"BODY"\\."END_BODY")"\
- "|((www|ftp)\\."END_BODY")"
-static GRegex *uri_regex = NULL;
-
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatTextView)
typedef struct {
@@ -1264,6 +1255,7 @@ empathy_chat_text_view_append_body (EmpathyChatTextView *view,
GtkTextIter start_iter, end_iter;
GtkTextMark *mark;
GtkTextIter iter;
+ GRegex *uri_regex;
GMatchInfo *match_info;
gboolean match;
gint last = 0;
@@ -1275,10 +1267,7 @@ empathy_chat_text_view_append_body (EmpathyChatTextView *view,
gtk_text_buffer_get_end_iter (priv->buffer, &start_iter);
mark = gtk_text_buffer_create_mark (priv->buffer, NULL, &start_iter, TRUE);
- if (!uri_regex) {
- uri_regex = g_regex_new (URI_REGEX, 0, 0, NULL);
- }
-
+ uri_regex = empathy_uri_regex_dup_singleton ();
for (match = g_regex_match (uri_regex, body, 0, &match_info); match;
match = g_match_info_next (match_info, NULL)) {
if (!g_match_info_fetch_pos (match_info, 0, &s, &e))
@@ -1308,6 +1297,7 @@ empathy_chat_text_view_append_body (EmpathyChatTextView *view,
last = e;
}
g_match_info_free (match_info);
+ g_regex_unref (uri_regex);
if (last < strlen (body)) {
gtk_text_buffer_get_end_iter (priv->buffer, &iter);