]> 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 a3d14a07decc0a3b10ac8277559ea19526ab2d07..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?|ftps?|nntp|news|javascript|about|ghelp|apt|telnet|"\
-               "file|webcal|mailto)"
-#define BODY "([^\\ ]+)"
-#define END_BODY "([^\\ ]*[^,;\?><()\\ \"\\.])"
-#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 {
@@ -323,7 +306,7 @@ chat_text_view_populate_popup (EmpathyChatTextView *view,
                                                    &start, &end, FALSE);
            }
        
-       if (G_STR_EMPTY (str)) {
+       if (EMP_STR_EMPTY (str)) {
                g_free (str);
                return;
        }
@@ -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);
@@ -762,7 +747,7 @@ chat_text_view_append_event (EmpathyChatView *view,
 
 
        g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view));
-       g_return_if_fail (!G_STR_EMPTY (str));
+       g_return_if_fail (!EMP_STR_EMPTY (str));
 
        bottom = chat_text_view_is_scrolled_down (text_view);
        chat_text_view_maybe_trim_buffer (EMPATHY_CHAT_TEXT_VIEW (view));
@@ -856,7 +841,7 @@ chat_text_view_find_previous (EmpathyChatView *view,
        
        buffer = priv->buffer;
        
-       if (G_STR_EMPTY (search_criteria)) {
+       if (EMP_STR_EMPTY (search_criteria)) {
                if (priv->find_mark_previous) {
                        gtk_text_buffer_get_start_iter (buffer, &iter_at_mark);
                        
@@ -971,7 +956,7 @@ chat_text_view_find_next (EmpathyChatView *view,
        
        buffer = priv->buffer;
        
-       if (G_STR_EMPTY (search_criteria)) {
+       if (EMP_STR_EMPTY (search_criteria)) {
                if (priv->find_mark_next) {
                        gtk_text_buffer_get_start_iter (buffer, &iter_at_mark);
                        
@@ -1142,7 +1127,7 @@ chat_text_view_highlight (EmpathyChatView *view,
                                            &iter_start,
                                            &iter_end);
        
-       if (G_STR_EMPTY (text)) {
+       if (EMP_STR_EMPTY (text)) {
                return;
        }
        
@@ -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);