]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-chat-text-view.c
empathy-call-window.c: update priv->sending_video *before* changing widget's state
[empathy.git] / libempathy-gtk / empathy-chat-text-view.c
index b87128cc35e5f614a56fcd143d18a90f50580c25..fbe40120a7215f1c62da96d4008fc35f12cf02ee 100644 (file)
 #include <time.h>
 
 #include <glib/gi18n-lib.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkimagemenuitem.h>
-#include <gtk/gtkstock.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtksizegroup.h>
-#include <glade/glade.h>
+#include <gtk/gtk.h>
 
 #include <telepathy-glib/util.h>
 #include <libmissioncontrol/mc-account.h>
 #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 {
@@ -436,7 +419,9 @@ chat_text_view_append_timestamp (EmpathyChatTextView *view,
 
                date = g_date_new ();
                g_date_set_time_t (date, timestamp);
-               g_date_strftime (buf, 256, _("%A %d %B %Y"), date);
+               /* Translators: timestamp displayed between conversations in
+                * chat windows (strftime format string) */
+               g_date_strftime (buf, 256, _("%A %B %d %Y"), date);
                g_string_append (str, buf);
                g_string_append (str, ", ");
                g_date_free (date);
@@ -1262,6 +1247,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;
@@ -1273,10 +1259,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))
@@ -1306,6 +1289,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);