2010-12-21 [colin] 3.7.8cvs16
[claws.git] / src / textview.c
index 620e3b7aa40af771b50b0c6266d32aa907a3dfca..b2d334a684a081940f6f74ebc2c691373ec24f09 100644 (file)
@@ -191,6 +191,8 @@ static void copy_uri_cb                             (GtkAction      *action,
                                                 TextView       *textview);
 static void add_uri_to_addrbook_cb             (GtkAction      *action,
                                                 TextView       *textview);
+static void reply_to_uri_cb                    (GtkAction      *action,
+                                                TextView       *textview);
 static void mail_to_uri_cb                     (GtkAction      *action,
                                                 TextView       *textview);
 static void copy_mail_to_uri_cb                        (GtkAction      *action,
@@ -212,6 +214,7 @@ static GtkActionEntry textview_mail_popup_entries[] =
 {
        {"TextviewPopupMail",                   NULL, "TextviewPopupMail" },
        {"TextviewPopupMail/Compose",           NULL, N_("Compose _new message"), NULL, NULL, G_CALLBACK(mail_to_uri_cb) },
+       {"TextviewPopupMail/ReplyTo",           NULL, N_("_Reply to this address"), NULL, NULL, G_CALLBACK(reply_to_uri_cb) },
        {"TextviewPopupMail/AddAB",             NULL, N_("Add to _Address book"), NULL, NULL, G_CALLBACK(add_uri_to_addrbook_cb) },
        {"TextviewPopupMail/Copy",              NULL, N_("Copy this add_ress"), NULL, NULL, G_CALLBACK(copy_mail_to_uri_cb) },
 };
@@ -342,6 +345,8 @@ TextView *textview_create(void)
                        "/Menus/TextviewPopupLink", "Copy", "TextviewPopupLink/Copy", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(textview->ui_manager, 
                        "/Menus/TextviewPopupMail", "Compose", "TextviewPopupMail/Compose", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(textview->ui_manager, 
+                       "/Menus/TextviewPopupMail", "ReplyTo", "TextviewPopupMail/ReplyTo", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(textview->ui_manager, 
                        "/Menus/TextviewPopupMail", "AddAB", "TextviewPopupMail/AddAB", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(textview->ui_manager, 
@@ -706,6 +711,9 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
                                else
                                        pixbuf = gdk_pixbuf_new_from_file(filename, &error);
                        }
+                       if (textview->stop_loading) {
+                               return;
+                       }
                        if (error != NULL) {
                                g_warning("%s\n", error->message);
                                g_error_free(error);
@@ -724,7 +732,10 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
                                uri->start = gtk_text_iter_get_offset(&iter);
                                
                                gtk_text_buffer_insert_pixbuf(buffer, &iter, pixbuf);
-                               
+                               if (textview->stop_loading) {
+                                       g_free(uri);
+                                       return;
+                               }
                                uri->end = uri->start + 1;
                                uri->filename = procmime_get_part_file_name(mimeinfo);
                                textview->uri_list =
@@ -736,6 +747,10 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
                                                &start_iter, &iter);
                        } else {
                                gtk_text_buffer_insert_pixbuf(buffer, &iter, pixbuf);
+                               if (textview->stop_loading) {
+                                       g_free(uri);
+                                       return;
+                               }
                                gtk_text_buffer_insert(buffer, &iter, " ", 1);
                        }
 
@@ -933,9 +948,16 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
        if (textview->messageview->forced_charset)
                charset = textview->messageview->forced_charset;
        else {
+               /* use supersets transparently when possible */
                charset = procmime_mimeinfo_get_parameter(mimeinfo, "charset");
                if (charset && !strcasecmp(charset, CS_ISO_8859_1))
                        charset = CS_WINDOWS_1252;
+               else if (charset && !strcasecmp(charset, CS_X_GBK))
+                       charset = CS_GB18030;
+               else if (charset && !strcasecmp(charset, CS_GBK))
+                       charset = CS_GB18030;
+               else if (charset && !strcasecmp(charset, CS_GB2312))
+                       charset = CS_GB18030;
        }
 
        textview_set_font(textview, charset);
@@ -1006,7 +1028,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
                        argv = strsplit_with_quote(buf, " ", 0);
                        close(1);
                        close(pfd[0]);
-                       dup(pfd[1]);
+                       rc = dup(pfd[1]);
                        rc = execvp(argv[0], argv);
                        close(pfd[1]);
                        g_print(_("The command to view attachment "
@@ -2658,7 +2680,8 @@ static gboolean textview_uri_button_pressed(GtkTextTag *tag, GObject *obj,
                        } 
                        return TRUE;
                } else if (qlink && bevent->button == 1) {
-                       textview_toggle_quote(textview, NULL, uri, FALSE);
+                       if (prefs_common.hide_quoted)
+                               textview_toggle_quote(textview, NULL, uri, FALSE);
                        return TRUE;
                } else if (!g_ascii_strncasecmp(uri->uri, "mailto:", 7)) {
                        if (bevent->button == 3) {
@@ -2671,6 +2694,8 @@ static gboolean textview_uri_button_pressed(GtkTextTag *tag, GObject *obj,
                        } else {
                                PrefsAccount *account = NULL;
                                FolderItem   *folder_item = NULL;
+                               Compose *compose;
+                               
                                if (textview->messageview && textview->messageview->msginfo &&
                                    textview->messageview->msginfo->folder) {
                                        
@@ -2681,7 +2706,9 @@ static gboolean textview_uri_button_pressed(GtkTextTag *tag, GObject *obj,
                                        if (!account)
                                                account = account_find_from_item(folder_item);
                                }
-                               compose_new_with_folderitem(account, folder_item, uri->uri + 7);
+                               compose = compose_new_with_folderitem(account,
+                                                               folder_item, uri->uri + 7);
+                               compose_check_for_email_account(compose);
                        }
                        return TRUE;
                } else if (g_ascii_strncasecmp(uri->uri, "file:", 5)) {
@@ -3026,9 +3053,21 @@ static void add_uri_to_addrbook_cb (GtkAction *action, TextView *textview)
        g_free(fromname);
 }
 
+static void reply_to_uri_cb (GtkAction *action, TextView *textview)
+{
+       ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu),
+                                          "menu_button");
+       if (!textview->messageview || !uri)
+               return;
+
+       compose_reply_to_address (textview->messageview,
+                                 textview->messageview->msginfo, uri->uri+7);
+}
+
 static void mail_to_uri_cb (GtkAction *action, TextView *textview)
 {
        PrefsAccount *account = NULL;
+       Compose *compose;
        ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu),
                                           "menu_button");
        if (uri == NULL)
@@ -3042,10 +3081,11 @@ static void mail_to_uri_cb (GtkAction *action, TextView *textview)
                if (folder_item->prefs && folder_item->prefs->enable_default_account)
                        account = account_find_from_id(folder_item->prefs->default_account);
                
-               compose_new_with_folderitem(account, folder_item, uri->uri+7);
+               compose = compose_new_with_folderitem(account, folder_item, uri->uri+7);
        } else {
-               compose_new(account, uri->uri + 7, NULL);
+               compose = compose_new(account, uri->uri + 7, NULL);
        }
+       compose_check_for_email_account(compose);
 }
 
 static void copy_mail_to_uri_cb        (GtkAction *action, TextView *textview)