/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
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,
{
{"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) },
};
"/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,
"foreground-gdk", "e_colors[2],
NULL);
}
-#if GTK_CHECK_VERSION(2, 8, 0)
gtk_text_buffer_create_tag(buffer, "tags",
"foreground-gdk", &black,
"paragraph-background-gdk", &yellow,
NULL);
-#else
- gtk_text_buffer_create_tag(buffer, "tags",
- "foreground-gdk", &emphasis_color,
- NULL);
-#endif
gtk_text_buffer_create_tag(buffer, "emphasis",
"foreground-gdk", &emphasis_color,
NULL);
textview_create_tags(GTK_TEXT_VIEW(textview->text), textview);
}
-#if GTK_CHECK_VERSION(2, 8, 0)
#define CHANGE_TAG_COLOR(tagname, colorfg, colorbg) { \
tag = gtk_text_tag_table_lookup(tags, tagname); \
if (tag) \
g_object_set(G_OBJECT(tag), "foreground-gdk", colorfg, "paragraph-background-gdk", colorbg, NULL); \
}
-#else
- #define CHANGE_TAG_COLOR(tagname, colorfg, colorbg) { \
- tag = gtk_text_tag_table_lookup(tags, tagname); \
- if (tag) \
- g_object_set(G_OBJECT(tag), "foreground-gdk", colorfg, NULL); \
- }
-#endif
static void textview_update_message_colors(TextView *textview)
{
void textview_show_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp)
{
START_TIMING("");
- g_return_if_fail(mimeinfo != NULL);
- g_return_if_fail(fp != NULL);
+ cm_return_if_fail(mimeinfo != NULL);
+ cm_return_if_fail(fp != NULL);
if ((mimeinfo->type == MIMETYPE_MULTIPART) ||
((mimeinfo->type == MIMETYPE_MESSAGE) && !g_ascii_strcasecmp(mimeinfo->subtype, "rfc822"))) {
gint charcount;
START_TIMING("");
- g_return_if_fail(mimeinfo != NULL);
+ cm_return_if_fail(mimeinfo != NULL);
text = GTK_TEXT_VIEW(textview->text);
buffer = gtk_text_view_get_buffer(text);
charcount = gtk_text_buffer_get_char_count(buffer);
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);
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 =
&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);
}
static void textview_add_parts(TextView *textview, MimeInfo *mimeinfo)
{
- g_return_if_fail(mimeinfo != NULL);
+ cm_return_if_fail(mimeinfo != NULL);
recursive_add_parts(textview, mimeinfo->node);
}
TEXTVIEW_INSERT_LINK(_("'View Log'"), "sc://view_log", NULL);
TEXTVIEW_INSERT(_(" in the Tools menu for more information."));
textview_show_icon(textview, GTK_STOCK_DIALOG_ERROR);
-
}
void textview_show_mime_part(TextView *textview, MimeInfo *partinfo)
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);
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 "
if (textview->stop_loading) {
fclose(tmpfp);
waitpid(pid, pfd, 0);
- unlink(fname);
+ g_unlink(fname);
return;
}
}
fclose(tmpfp);
waitpid(pid, pfd, 0);
- unlink(fname);
+ g_unlink(fname);
#endif
} else {
textview_default:
gint lines = 0;
parser = sc_html_parser_new(fp, conv);
- g_return_if_fail(parser != NULL);
+ cm_return_if_fail(parser != NULL);
while ((str = sc_html_parse(parser)) != NULL) {
if (parser->state == SC_HTML_HREF) {
gint lines = 0;
parser = ertf_parser_new(fp, conv);
- g_return_if_fail(parser != NULL);
+ cm_return_if_fail(parser != NULL);
while ((str = ertf_parse(parser)) != NULL) {
textview_write_line(textview, str, NULL, FALSE);
{"https://", strcasestr, get_uri_part, make_uri_string},
{"ftp://", strcasestr, get_uri_part, make_uri_string},
{"sftp://", strcasestr, get_uri_part, make_uri_string},
+ {"gopher://",strcasestr, get_uri_part, make_uri_string},
{"www.", strcasestr, get_uri_part, make_http_string},
{"mailto:", strcasestr, get_uri_part, make_uri_string},
{"@", strcasestr, get_email_part, make_email_string}
} else {
g_print("oops (%d %d)\n",
real_quotelevel, textview->prev_quote_level);
- }
- if (lasturi->is_quote == FALSE) {
- textview->prev_quote_level = -1;
- goto do_quote;
+ }
+ if (lasturi) {
+ if (lasturi->is_quote == FALSE) {
+ textview->prev_quote_level = -1;
+ goto do_quote;
+ }
+ e_len = lasturi->data ? strlen(lasturi->data):0;
+ n_len = strlen(buf);
+ lasturi->data = g_realloc((gchar *)lasturi->data, e_len + n_len + 1);
+ strcpy((gchar *)lasturi->data + e_len, buf);
+ *((gchar *)lasturi->data + e_len + n_len) = '\0';
}
- e_len = lasturi->data ? strlen(lasturi->data):0;
- n_len = strlen(buf);
- lasturi->data = g_realloc((gchar *)lasturi->data, e_len + n_len + 1);
- strcpy((gchar *)lasturi->data + e_len, buf);
- *((gchar *)lasturi->data + e_len + n_len) = '\0';
}
} else {
textview_make_clickable_parts(textview, fg_color, "link", buf, FALSE);
GtkTextView *view;
GtkTextBuffer *buffer;
- g_return_if_fail(textview != NULL);
- g_return_if_fail(text != NULL);
+ cm_return_if_fail(textview != NULL);
+ cm_return_if_fail(text != NULL);
textview_clear(textview);
"X-Claws-Account-Id:", "X-Claws-Sign:", "X-Claws-Encrypt:",
"X-Claws-Privacy-System:", "X-Claws-End-Special-Headers:",
"X-Sylpheed-Account-Id:", "X-Sylpheed-Sign:", "X-Sylpheed-Encrypt:",
+ "X-Claws-Auto-Wrapping:", "X-Claws-Auto-Indent:",
"X-Sylpheed-Privacy-System:", "X-Sylpheed-End-Special-Headers:",
NULL};
int i;
Header *header;
gint i;
- g_return_val_if_fail(fp != NULL, NULL);
+ cm_return_val_if_fail(fp != NULL, NULL);
if (textview->show_all_headers) {
headers = procheader_get_header_array_asis(fp);
gtk_widget_destroy(textview->image);
textview->image = face_get_from_header(msginfo->extradata->face);
- g_return_if_fail(textview->image != NULL);
+ cm_return_if_fail(textview->image != NULL);
gtk_widget_show(textview->image);
gtk_widget_destroy(textview->image);
textview->image = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_DIALOG);
- g_return_if_fail(textview->image != NULL);
+ cm_return_if_fail(textview->image != NULL);
gtk_widget_show(textview->image);
textview->image = xface_get_from_header(msginfo->extradata->xface,
&textview->text->style->white,
window);
- g_return_if_fail(textview->image != NULL);
+ cm_return_if_fail(textview->image != NULL);
gtk_widget_show(textview->image);
textview->image = gtk_image_new_from_pixbuf(picture);
g_object_unref(picture);
}
- g_return_if_fail(textview->image != NULL);
+ cm_return_if_fail(textview->image != NULL);
gtk_widget_show(textview->image);
Header *header;
gint i;
- g_return_if_fail(headers != NULL);
+ cm_return_if_fail(headers != NULL);
for (i = 0; i < headers->len; i++) {
header = g_ptr_array_index(headers, i);
- g_return_if_fail(header->name != NULL);
+ cm_return_if_fail(header->name != NULL);
gtk_text_buffer_get_end_iter (buffer, &iter);
if(prefs_common.trans_hdr == TRUE) {
TEXTVIEW_STATUSBAR_POP(textview);
if (uri) {
- char *trimmed_uri;
-
if (!uri->is_quote)
gtk_text_buffer_apply_tag_by_name(buffer,
"link-hover",
&start_iter,
&end_iter);
-
- trimmed_uri = trim_string(uri->uri, 60);
- TEXTVIEW_STATUSBAR_PUSH(textview, trimmed_uri);
- g_free(trimmed_uri);
+ TEXTVIEW_STATUSBAR_PUSH(textview, uri->uri);
}
}
}
}
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) {
} else {
PrefsAccount *account = NULL;
FolderItem *folder_item = NULL;
+ Compose *compose;
+
if (textview->messageview && textview->messageview->msginfo &&
textview->messageview->msginfo->folder) {
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)) {
subst_for_filename(filename);
- if (prefs_common.attach_save_dir)
+ if (prefs_common.attach_save_dir && *prefs_common.attach_save_dir)
filepath = g_strconcat(prefs_common.attach_save_dir,
G_DIR_SEPARATOR_S, filename, NULL);
else
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)
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)