Corrected a bug that prevented sylpheed to open
[claws.git] / src / textview.c
index 81d465ac9ee29f62eb7238e3263578e48634f4f8..f30c0d46eceda0e4453b514fa376637a2dbb0aa9 100644 (file)
@@ -257,6 +257,7 @@ TextView *textview_create(void)
        textview->cur_pos          = 0;
        textview->show_all_headers = FALSE;
        textview->last_buttonpress = GDK_NOTHING;
+       textview->show_url_msgid   = 0;
 
        return textview;
 }
@@ -526,6 +527,9 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo)
        TEXT_INSERT(_("To display this part as a text message, select "));
        TEXT_INSERT(_("`Display as text', or press `t' key.\n\n"));
 
+       TEXT_INSERT(_("To display this part as an image, select "));
+       TEXT_INSERT(_("`Display image', or press `i' key.\n\n"));
+
        TEXT_INSERT(_("To open this part with external program, select "));
        TEXT_INSERT(_("`Open' or `Open with...', "));
        TEXT_INSERT(_("or double-click, or click the center button, "));
@@ -688,7 +692,7 @@ static gchar *make_uri_string(const gchar *bp, const gchar *ep)
         (ch) > 32   && \
         (ch) != 127 && \
         !isspace(ch) && \
-        !strchr("()<>\"", (ch)))
+        !strchr("(),;<>\"", (ch)))
 
 /* alphabet and number within 7bit ASCII */
 #define IS_ASCII_ALNUM(ch)     (isascii(ch) && isalnum(ch))
@@ -981,8 +985,8 @@ static void textview_write_link(TextView *textview, const gchar *url,
     uri = g_new(RemoteURI, 1);
     uri->uri = g_strdup(url);
     uri->start = gtk_stext_get_point(text);
-    gtk_stext_insert(text, textview->msgfont, link_color, NULL, buf,
-                   strlen(buf));
+    gtk_stext_insert(text, textview->msgfont, link_color, NULL, str,
+                   strlen(str));
     uri->end = gtk_stext_get_point(text);
     textview->uri_list = g_slist_append(textview->uri_list, uri);
 }
@@ -1018,8 +1022,9 @@ static void textview_write_line(TextView *textview, const gchar *str,
           >, foo>, _> ... ok, <foo>, foo bar>, foo-> ... ng
           Up to 3 levels of quotations are detected, and each
           level is colored using a different color. */
-       if (prefs_common.enable_color && strchr(buf, '>')) {
-               quotelevel = get_quote_level(buf);
+       if (prefs_common.enable_color 
+           && line_has_quote_char(buf, prefs_common.quote_chars)) {
+               quotelevel = get_quote_level(buf, prefs_common.quote_chars);
 
                /* set up the correct foreground color */
                if (quotelevel > 2) {
@@ -1341,17 +1346,18 @@ gboolean textview_search_string(TextView *textview, const gchar *str,
                if (text_len - pos < len) break;
                if (gtkut_stext_match_string(text, pos, wcs, len, case_sens)
                    == TRUE) {
+                       gtk_widget_hide(GTK_WIDGET(textview->scrolledwin));
                        gtk_editable_set_position(GTK_EDITABLE(text),
                                                  pos + len);
                        gtk_editable_select_region(GTK_EDITABLE(text),
                                                   pos, pos + len);
+                       gtk_widget_show(GTK_WIDGET(textview->scrolledwin));
                        textview_set_position(textview, pos + len);
                        found = TRUE;
                        break;
                }
                if (text_len - pos == len) break;
        }
-
        g_free(wcs);
        return found;
 }
@@ -1636,6 +1642,16 @@ static gint textview_key_pressed(GtkWidget *widget, GdkEventKey *event,
        return TRUE;
 }
 
+static gint show_url_timeout_cb(TextView    *textview ){
+       if (textview->messageview->mainwin)
+               if (textview->show_url_msgid)
+                       gtk_statusbar_remove(GTK_STATUSBAR(
+                               textview->messageview->mainwin->statusbar),
+                               textview->messageview->mainwin->folderview_cid,
+                               textview->show_url_msgid);
+               return FALSE;
+}
+
 static gint textview_button_pressed(GtkWidget *widget, GdkEventButton *event,
                                    TextView *textview)
 {
@@ -1651,7 +1667,7 @@ static gint textview_button_released(GtkWidget *widget, GdkEventButton *event,
                gtk_editable_get_position(GTK_EDITABLE(textview->text));
 
        if (event && 
-           ((event->button == 1 && textview->last_buttonpress == GDK_2BUTTON_PRESS)
+           ((event->button == 1)
             || event->button == 2 || event->button == 3)) {
                GSList *cur;
 
@@ -1667,6 +1683,25 @@ static gint textview_button_released(GtkWidget *widget, GdkEventButton *event,
 
                        if (textview->cur_pos >= uri->start &&
                            textview->cur_pos <  uri->end) {
+                               /* single click: display url in statusbar */
+                               if (event->button == 1 && textview->last_buttonpress != GDK_2BUTTON_PRESS) {
+                                       if (textview->messageview->mainwin) {
+                                               if (textview->show_url_msgid) {
+                                                       gtk_timeout_remove(textview->show_url_timeout_tag);
+                                                       gtk_statusbar_remove(GTK_STATUSBAR(
+                                                               textview->messageview->mainwin->statusbar),
+                                                               textview->messageview->mainwin->folderview_cid,
+                                                               textview->show_url_msgid);
+                                                       textview->show_url_msgid = 0;
+                                               }
+                                               textview->show_url_msgid = gtk_statusbar_push(
+                                                               GTK_STATUSBAR(textview->messageview->mainwin->statusbar),
+                                                               textview->messageview->mainwin->folderview_cid,
+                                                               uri->uri);
+                                               textview->show_url_timeout_tag = gtk_timeout_add( 2000, show_url_timeout_cb, textview );
+                                               gtkut_widget_wait_for_draw(textview->messageview->mainwin->hbox_stat);
+                                       }
+                               } else
                                if (!g_strncasecmp(uri->uri, "mailto:", 7)) {
                                        if (event->button == 3) {
                                                gchar *fromname, *fromaddress;