From d0b9e3b2c02f0c9eda898f87654808dba68c49f6 Mon Sep 17 00:00:00 2001 From: Paul Mangan Date: Sat, 5 Apr 2003 08:58:21 +0000 Subject: [PATCH] sync with 0.8.11cvs18 --- ChangeLog | 19 ++ ChangeLog.claws | 5 + ChangeLog.jp | 19 ++ configure.ac | 2 +- src/gtk/menu.c | 89 +++++++- src/gtk/menu.h | 8 +- src/mainwindow.c | 24 +-- src/messageview.c | 528 +++++++++++++++++++++++++++++++++++++++++---- src/messageview.h | 7 +- src/mimeview.c | 2 +- src/mimeview.h | 2 +- src/prefs_common.c | 55 +---- src/textview.c | 14 +- src/textview.h | 2 +- 14 files changed, 652 insertions(+), 124 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ae9d7ba9..ed973f75b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2003-04-04 + + * src/messageview.[ch]: separated the forced charset of message view + in separate window from the main window. + src/textview.c: + textview_show_message() + textview_show_part() + textview_add_part(): use MessageView::forced_charset if specified. + +2003-04-03 + + * src/mainwindow.c: modified File menu a bit. + * src/menu.[ch]: added functions to handle item factory rc strings. + * src/messageview.[ch]: added a menu, and made it take over main + window's menu shortcuts. + added msginfo which is duplicated on display to MessageView. + * src/prefs_common.c: prefs_keybind_apply_clicked(): use + menu_factory_clear_rc(). + 2003-03-28 * send_message.c: send_message_smtp(): diff --git a/ChangeLog.claws b/ChangeLog.claws index b234ff611..cd48ca98f 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,8 @@ +2003-04-05 [paul] 0.8.11claws71 + + * sync with 0.8.11cvs18 + see ChangeLog 2003-04-03 and 2003-04-04 + 2003-04-02 [christoph] 0.8.11claws70 * src/folder.[ch] diff --git a/ChangeLog.jp b/ChangeLog.jp index 8fdfde6ee..363a628c7 100644 --- a/ChangeLog.jp +++ b/ChangeLog.jp @@ -1,3 +1,22 @@ +2003-04-04 + + * src/messageview.[ch]: ÊÌ¥¦¥£¥ó¥É¥¦¤Î¥á¥Ã¥»¡¼¥¸¥Ó¥å¡¼¤Îʸ»ú¥³¡¼¥É + ¶¯À©»ØÄê¤ò¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤«¤éʬΥ¡£ + textview_show_message() + textview_show_part() + textview_add_part(): »ØÄꤵ¤ì¤Æ¤¤¤ì¤Ð MessageView::forced_charset + ¤ò»ÈÍÑ¡£ + +2003-04-03 + + * src/mainwindow.c: ¥Õ¥¡¥¤¥ë¥á¥Ë¥å¡¼¤ò¾¯¤·½¤Àµ¡£ + * src/menu.[ch]: item factory ¤Î rc ʸ»úÎó¤ò°·¤¦´Ø¿ô¤òÄɲᣠ+ * src/messageview.[ch]: ¥á¥Ë¥å¡¼¤òÄɲä·¡¢¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤Î¥á¥Ë¥å¡¼ + ¥·¥ç¡¼¥È¥«¥Ã¥È¤ò°ú¤­·Ñ¤°¤è¤¦¤Ë¤·¤¿¡£ + msginfo (ɽ¼¨»þ¤ËÊ£À½¤µ¤ì¤ë)¤ò MessageView ¤ËÄɲᣠ+ * src/prefs_common.c: prefs_keybind_apply_clicked(): + menu_factory_clear_rc() ¤ò»ÈÍÑ¡£ + 2003-03-28 * send_message.c: send_message_smtp(): diff --git a/configure.ac b/configure.ac index 4bee9a8ee..decebbd78 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=11 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws70 +EXTRA_VERSION=claws71 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/gtk/menu.c b/src/gtk/menu.c index 3db4865ea..eec7bb4b3 100644 --- a/src/gtk/menu.c +++ b/src/gtk/menu.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2001 Hiroyuki Yamamoto + * Copyright (C) 1999-2003 Hiroyuki Yamamoto * * 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 @@ -51,14 +51,12 @@ GtkWidget *menubar_create(GtkWidget *window, GtkItemFactoryEntry *entries, guint n_entries, const gchar *path, gpointer data) { GtkItemFactory *factory; - GtkAccelGroup *accel_group; - accel_group = gtk_accel_group_new(); - factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, path, accel_group); + factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, path, NULL); gtk_item_factory_set_translate_func(factory, menu_translate, NULL, NULL); gtk_item_factory_create_items(factory, n_entries, entries, data); - gtk_accel_group_attach(accel_group, GTK_OBJECT(window)); + gtk_accel_group_attach(factory->accel_group, GTK_OBJECT(window)); return gtk_item_factory_get_widget(factory, path); } @@ -100,6 +98,87 @@ static gchar *menu_translate(const gchar *path, gpointer data) return retval; } +static void factory_print_func(gpointer data, gchar *string) +{ + GString *out_str = data; + + g_string_append(out_str, string); + g_string_append_c(out_str, '\n'); +} + +GString *menu_factory_get_rc(const gchar *path) +{ + GString *string; + GtkPatternSpec *pspec; + gchar pattern[256]; + + pspec = g_new(GtkPatternSpec, 1); + g_snprintf(pattern, sizeof(pattern), "%s*", path); + gtk_pattern_spec_init(pspec, pattern); + string = g_string_new(""); + gtk_item_factory_dump_items(pspec, FALSE, factory_print_func, + string); + gtk_pattern_spec_free_segs(pspec); + + return string; +} + +void menu_factory_clear_rc(const gchar *rc_str) +{ + GString *string; + gchar *p; + gchar *start, *end; + guint pos = 0; + + string = g_string_new(rc_str); + while ((p = strstr(string->str + pos, "(menu-path \"")) != NULL) { + pos = p + 12 - string->str; + p = strchr(p + 12, '"'); + if (!p) continue; + start = strchr(p + 1, '"'); + if (!start) continue; + end = strchr(start + 1, '"'); + if (!end) continue; + pos = start + 1 - string->str; + if (end > start + 1) + g_string_erase(string, pos, end - (start + 1)); + } + + gtk_item_factory_parse_rc_string(string->str); + g_string_free(string, TRUE); +} + +void menu_factory_copy_rc(const gchar *src_path, const gchar *dest_path) +{ + GString *string; + gint src_path_len; + gint dest_path_len; + gchar *p; + guint pos = 0; + + string = menu_factory_get_rc(src_path); + src_path_len = strlen(src_path); + dest_path_len = strlen(dest_path); + + while ((p = strstr(string->str + pos, src_path)) != NULL) { + pos = p - string->str; + g_string_erase(string, pos, src_path_len); + g_string_insert(string, pos, dest_path); + pos += dest_path_len; + } + + pos = 0; + while ((p = strchr(string->str + pos, ';')) != NULL) { + pos = p - string->str; + if (pos == 0 || *(p - 1) == '\n') + g_string_erase(string, pos, 1); + } + + menu_factory_clear_rc(string->str); + gtk_item_factory_parse_rc_string(string->str); + g_string_free(string, TRUE); +} + void menu_set_sensitive(GtkItemFactory *ifactory, const gchar *path, gboolean sensitive) { diff --git a/src/gtk/menu.h b/src/gtk/menu.h index d4a49dba6..467e616ee 100644 --- a/src/gtk/menu.h +++ b/src/gtk/menu.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2002 Hiroyuki Yamamoto + * Copyright (C) 1999-2003 Hiroyuki Yamamoto * * 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 @@ -55,6 +55,12 @@ GtkWidget *popupmenu_create(GtkWidget *window, guint n_entries, const gchar *path, gpointer data); + +GString *menu_factory_get_rc (const gchar *path); +void menu_factory_clear_rc (const gchar *rc_str); +void menu_factory_copy_rc (const gchar *src_path, + const gchar *dest_path); + void menu_set_sensitive (GtkItemFactory *ifactory, const gchar *path, gboolean sensitive); diff --git a/src/mainwindow.c b/src/mainwindow.c index ef14372ba..5fe4c4b92 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2002 Hiroyuki Yamamoto + * Copyright (C) 1999-2003 Hiroyuki Yamamoto * * 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 @@ -123,22 +123,22 @@ static gint message_window_close_cb (GtkWidget *widget, GdkEventAny *event, gpointer data); -static void add_mailbox_cb (MainWindow *mainwin, +static void new_folder_cb (MainWindow *mainwin, guint action, GtkWidget *widget); static void add_mbox_cb (MainWindow *mainwin, guint action, GtkWidget *widget); -static void update_folderview_cb (MainWindow *mainwin, +static void rename_folder_cb (MainWindow *mainwin, guint action, GtkWidget *widget); -static void new_folder_cb (MainWindow *mainwin, +static void delete_folder_cb (MainWindow *mainwin, guint action, GtkWidget *widget); -static void rename_folder_cb (MainWindow *mainwin, +static void update_folderview_cb (MainWindow *mainwin, guint action, GtkWidget *widget); -static void delete_folder_cb (MainWindow *mainwin, +static void add_mailbox_cb (MainWindow *mainwin, guint action, GtkWidget *widget); static void import_mbox_cb (MainWindow *mainwin, @@ -405,15 +405,16 @@ gboolean mainwindow_progressindicator_hook (gpointer source, static GtkItemFactoryEntry mainwin_entries[] = { {N_("/_File"), NULL, NULL, 0, ""}, - {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL}, - {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL}, - {N_("/_File/_Check for new messages in all folders"), - NULL, update_folderview_cb, 0, NULL}, {N_("/_File/_Folder"), NULL, NULL, 0, ""}, {N_("/_File/_Folder/Create _new folder..."), NULL, new_folder_cb, 0, NULL}, {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL}, {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL}, + {N_("/_File/_Folder/---"), NULL, NULL, 0, ""}, + {N_("/_File/_Folder/_Check for new messages in all folders"), + NULL, update_folderview_cb, 0, NULL}, + {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL}, + {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL}, {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL}, {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL}, {N_("/_File/Empty _trash"), "D", empty_trash_cb, 0, NULL}, @@ -1526,10 +1527,9 @@ void main_window_set_menu_sensitive(MainWindow *mainwin) gchar *const entry; SensitiveCond cond; } entry[] = { + {"/File/Folder" , M_UNLOCKED}, {"/File/Add mailbox..." , M_UNLOCKED}, {"/File/Add mbox mailbox..." , M_UNLOCKED}, - {"/File/Check for new messages in all folders", M_UNLOCKED}, - {"/File/Folder" , M_UNLOCKED}, {"/File/Import mbox file..." , M_UNLOCKED}, {"/File/Export to mbox file..." , M_UNLOCKED}, {"/File/Empty trash" , M_UNLOCKED}, diff --git a/src/messageview.c b/src/messageview.c index effc4352c..707fe9479 100644 --- a/src/messageview.c +++ b/src/messageview.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2002 Hiroyuki Yamamoto + * Copyright (C) 1999-2003 Hiroyuki Yamamoto * * 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 @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -33,23 +35,30 @@ #include "intl.h" #include "main.h" #include "messageview.h" +#include "message_search.h" #include "headerview.h" #include "summaryview.h" #include "textview.h" #include "mimeview.h" +#include "menu.h" +#include "about.h" +#include "filesel.h" +#include "sourcewindow.h" +#include "addressbook.h" +#include "alertpanel.h" +#include "inputdialog.h" +#include "manage_window.h" #include "procmsg.h" #include "procheader.h" #include "procmime.h" +#include "account.h" #include "prefs_common.h" +#include "prefs_account.h" #include "gtkutils.h" #include "utils.h" #include "rfc2015.h" -#include "about.h" -#include "account.h" -#include "alertpanel.h" #include "send_message.h" #include "pgptext.h" -#include "menu.h" #include "stock_pixmap.h" @@ -67,23 +76,206 @@ static void return_receipt_show (NoticeView *noticeview, MsgInfo *msginfo); static void return_receipt_send_clicked (NoticeView *noticeview, MsgInfo *msginfo); +static void save_as_cb (gpointer data, + guint action, + GtkWidget *widget); +static void print_cb (gpointer data, + guint action, + GtkWidget *widget); +static void close_cb (gpointer data, + guint action, + GtkWidget *widget); +static void copy_cb (gpointer data, + guint action, + GtkWidget *widget); +static void allsel_cb (gpointer data, + guint action, + GtkWidget *widget); +static void search_cb (gpointer data, + guint action, + GtkWidget *widget); + +static void set_charset_cb (gpointer data, + guint action, + GtkWidget *widget); +static void view_source_cb (gpointer data, + guint action, + GtkWidget *widget); +static void show_all_header_cb (gpointer data, + guint action, + GtkWidget *widget); + +static void compose_cb (gpointer data, + guint action, + GtkWidget *widget); +static void reply_cb (gpointer data, + guint action, + GtkWidget *widget); +static void reedit_cb (gpointer data, + guint action, + GtkWidget *widget); static PrefsAccount *select_account_from_list (GList *ac_list); +static void addressbook_open_cb (gpointer data, + guint action, + GtkWidget *widget); +static void add_address_cb (gpointer data, + guint action, + GtkWidget *widget); +static void create_filter_cb (gpointer data, + guint action, + GtkWidget *widget); static void messageview_menubar_cb (MessageView *msgview, guint action, GtkWidget *widget); -static void messageview_delete_cb (MessageView *msgview, - guint action, - GtkWidget *widget); -static void messageview_close_cb (gpointer data, +static void about_cb (gpointer data, guint action, GtkWidget *widget); static void messageview_update (MessageView *msgview); static void messageview_update_all (MessageView *msgview); static GList *msgview_list = NULL; +static GtkItemFactoryEntry msgview_entries[] = +{ + {N_("/_File"), NULL, NULL, 0, ""}, + {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL}, + {N_("/_File/_Print..."), NULL, print_cb, 0, NULL}, + {N_("/_File/---"), NULL, NULL, 0, ""}, + {N_("/_File/_Close"), NULL, close_cb, 0, NULL}, + + {N_("/_Edit"), NULL, NULL, 0, ""}, + {N_("/_Edit/_Copy"), NULL, copy_cb, 0, NULL}, + {N_("/_Edit/Select _all"), NULL, allsel_cb, 0, NULL}, + {N_("/_Edit/---"), NULL, NULL, 0, ""}, + {N_("/_Edit/_Find in current message..."), + NULL, search_cb, 0, NULL}, + + {N_("/_View"), NULL, NULL, 0, ""}, + +#define CODESET_SEPARATOR \ + {N_("/_View/_Code set/---"), NULL, NULL, 0, ""} +#define CODESET_ACTION(action) \ + NULL, set_charset_cb, action, "/View/Code set/Auto detect" + + {N_("/_View/_Code set"), NULL, NULL, 0, ""}, + {N_("/_View/_Code set/_Auto detect"), + NULL, set_charset_cb, C_AUTO, ""}, + CODESET_SEPARATOR, + {N_("/_View/_Code set/7bit ascii (US-ASC_II)"), + CODESET_ACTION(C_US_ASCII)}, + +#if HAVE_ICONV + {N_("/_View/_Code set/Unicode (_UTF-8)"), + CODESET_ACTION(C_UTF_8)}, + CODESET_SEPARATOR, +#endif + {N_("/_View/_Code set/Western European (ISO-8859-_1)"), + CODESET_ACTION(C_ISO_8859_1)}, + {N_("/_View/_Code set/Western European (ISO-8859-15)"), + CODESET_ACTION(C_ISO_8859_15)}, + CODESET_SEPARATOR, +#if HAVE_ICONV + {N_("/_View/_Code set/Central European (ISO-8859-_2)"), + CODESET_ACTION(C_ISO_8859_2)}, + CODESET_SEPARATOR, + {N_("/_View/_Code set/_Baltic (ISO-8859-13)"), + CODESET_ACTION(C_ISO_8859_13)}, + {N_("/_View/_Code set/Baltic (ISO-8859-_4)"), + CODESET_ACTION(C_ISO_8859_4)}, + CODESET_SEPARATOR, + {N_("/_View/_Code set/Greek (ISO-8859-_7)"), + CODESET_ACTION(C_ISO_8859_7)}, + CODESET_SEPARATOR, + {N_("/_View/_Code set/Turkish (ISO-8859-_9)"), + CODESET_ACTION(C_ISO_8859_9)}, + CODESET_SEPARATOR, + {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"), + CODESET_ACTION(C_ISO_8859_5)}, + {N_("/_View/_Code set/Cyrillic (KOI8-_R)"), + CODESET_ACTION(C_KOI8_R)}, + {N_("/_View/_Code set/Cyrillic (Windows-1251)"), + CODESET_ACTION(C_CP1251)}, + CODESET_SEPARATOR, +#endif + {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"), + CODESET_ACTION(C_ISO_2022_JP)}, +#if HAVE_ICONV + {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"), + CODESET_ACTION(C_ISO_2022_JP_2)}, +#endif + {N_("/_View/_Code set/Japanese (_EUC-JP)"), + CODESET_ACTION(C_EUC_JP)}, + {N_("/_View/_Code set/Japanese (_Shift__JIS)"), + CODESET_ACTION(C_SHIFT_JIS)}, +#if HAVE_ICONV + CODESET_SEPARATOR, + {N_("/_View/_Code set/Simplified Chinese (_GB2312)"), + CODESET_ACTION(C_GB2312)}, + {N_("/_View/_Code set/Traditional Chinese (_Big5)"), + CODESET_ACTION(C_BIG5)}, + {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"), + CODESET_ACTION(C_EUC_TW)}, + {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"), + CODESET_ACTION(C_ISO_2022_CN)}, + CODESET_SEPARATOR, + {N_("/_View/_Code set/Korean (EUC-_KR)"), + CODESET_ACTION(C_EUC_KR)}, + {N_("/_View/_Code set/Korean (ISO-2022-KR)"), + CODESET_ACTION(C_ISO_2022_KR)}, + CODESET_SEPARATOR, + {N_("/_View/_Code set/Thai (TIS-620)"), + CODESET_ACTION(C_TIS_620)}, + {N_("/_View/_Code set/Thai (Windows-874)"), + CODESET_ACTION(C_WINDOWS_874)}, +#endif + +#undef CODESET_SEPARATOR +#undef CODESET_ACTION + + {N_("/_View/---"), NULL, NULL, 0, ""}, + {N_("/_View/Mess_age source"), NULL, view_source_cb, 0, NULL}, + {N_("/_View/Show all _header"), NULL, show_all_header_cb, 0, ""}, + + {N_("/_Message"), NULL, NULL, 0, ""}, + {N_("/_Message/Compose _new message"), + NULL, compose_cb, 0, NULL}, + {N_("/_Message/---"), NULL, NULL, 0, ""}, + {N_("/_Message/_Reply"), NULL, reply_cb, COMPOSE_REPLY, NULL}, + {N_("/_Message/Repl_y to/_all"), + NULL, reply_cb, COMPOSE_REPLY_TO_ALL, NULL}, + {N_("/_Message/Repl_y to/_sender"), + NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL}, + {N_("/_Message/Repl_y to/mailing _list"), + NULL, reply_cb, COMPOSE_REPLY_TO_LIST, NULL}, + {N_("/_Message/---"), NULL, NULL, 0, ""}, + {N_("/_Message/_Forward"), NULL, reply_cb, COMPOSE_FORWARD, NULL}, + {N_("/_Message/For_ward as attachment"), + NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}, + {N_("/_Message/Redirec_t"), NULL, reply_cb, COMPOSE_REDIRECT, NULL}, + {N_("/_Message/---"), NULL, NULL, 0, ""}, + {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL}, + + {N_("/_Tools"), NULL, NULL, 0, ""}, + {N_("/_Tools/_Address book"), NULL, addressbook_open_cb, 0, NULL}, + {N_("/_Tools/Add sender to address boo_k"), + NULL, add_address_cb, 0, NULL}, + {N_("/_Tools/---"), NULL, NULL, 0, ""}, + {N_("/_Tools/_Create filter rule"), + NULL, NULL, 0, ""}, + {N_("/_Tools/_Create filter rule/_Automatically"), + NULL, create_filter_cb, FILTER_BY_AUTO, NULL}, + {N_("/_Tools/_Create filter rule/by _From"), + NULL, create_filter_cb, FILTER_BY_FROM, NULL}, + {N_("/_Tools/_Create filter rule/by _To"), + NULL, create_filter_cb, FILTER_BY_TO, NULL}, + {N_("/_Tools/_Create filter rule/by _Subject"), + NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL}, + + {N_("/_Help"), NULL, NULL, 0, ""}, + {N_("/_Help/_About"), NULL, about_cb, 0, NULL} +}; MessageView *messageview_create(MainWindow *mainwin) { @@ -136,30 +328,6 @@ MessageView *messageview_create(MainWindow *mainwin) return messageview; } -static GtkItemFactoryEntry messageview_entries[] = -{ - {N_("/_File"), NULL, NULL, 0, ""}, - {N_("/_File/---"), NULL, NULL, 0, ""}, - {N_("/_File/_Close"), "W", messageview_close_cb, 0, NULL}, - - {N_("/_Message"), NULL, NULL, 0, ""}, - {N_("/_Message/_Reply"), "R", messageview_menubar_cb, COMPOSE_REPLY, NULL}, - {N_("/_Message/Repl_y to"), NULL, NULL, 0, ""}, - {N_("/_Message/Repl_y to/_all"), "R", messageview_menubar_cb, COMPOSE_REPLY_TO_ALL, NULL}, - {N_("/_Message/Repl_y to/_sender"), NULL, messageview_menubar_cb, COMPOSE_REPLY_TO_SENDER, NULL}, - {N_("/_Message/Repl_y to/mailing _list"), - "L", messageview_menubar_cb, COMPOSE_REPLY_TO_LIST, NULL}, -/* {N_("/_Message/Follow-up and reply to"),NULL, messageview_menubar_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL}, */ - {N_("/_Message/---"), NULL, NULL, 0, ""}, - {N_("/_Message/_Forward"), "F", messageview_menubar_cb, COMPOSE_FORWARD, NULL}, - {N_("/_Message/Redirect"), NULL, messageview_menubar_cb, COMPOSE_REDIRECT, NULL}, - {N_("/_Message/---"), NULL, NULL, 0, ""}, - {N_("/_Message/_Delete"), "D", messageview_delete_cb, 0, NULL}, - - {N_("/_Help"), NULL, NULL, 0, ""}, - {N_("/_Help/_About"), NULL, about_show, 0, NULL} -}; - GList *messageview_get_msgview_list(void) { @@ -177,8 +345,8 @@ void messageview_add_toolbar(MessageView *msgview, GtkWidget *window) gtk_widget_show(vbox); gtk_container_add(GTK_CONTAINER(window), vbox); - n_menu_entries = sizeof(messageview_entries) / sizeof(messageview_entries[0]); - menubar = menubar_create(window, messageview_entries, + n_menu_entries = sizeof(msgview_entries) / sizeof(msgview_entries[0]); + menubar = menubar_create(window, msgview_entries, n_menu_entries, "", msgview); gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0); @@ -499,10 +667,8 @@ void messageview_show(MessageView *messageview, MsgInfo *msginfo, FILE *fp; gchar *file; MimeInfo *mimeinfo; - MsgInfo *tmpmsginfo; g_return_if_fail(msginfo != NULL); - messageview->msginfo = msginfo; #if USE_GPGME if ((fp = procmsg_open_message_decrypted(msginfo, &mimeinfo)) == NULL) @@ -521,10 +687,11 @@ void messageview_show(MessageView *messageview, MsgInfo *msginfo, return; } - tmpmsginfo = procheader_parse_file(file, msginfo->flags, TRUE, TRUE); - - headerview_show(messageview->headerview, tmpmsginfo); - procmsg_msginfo_free(tmpmsginfo); + if (messageview->msginfo != msginfo) { + procmsg_msginfo_free(messageview->msginfo); + messageview->msginfo = procmsg_msginfo_get_full_info(msginfo); + } + headerview_show(messageview->headerview, messageview->msginfo); messageview->all_headers = all_headers; textview_set_all_headers(messageview->textview, all_headers); @@ -594,6 +761,8 @@ void messageview_reflect_prefs_pixmap_theme(void) void messageview_clear(MessageView *messageview) { + procmsg_msginfo_free(messageview->msginfo); + messageview->msginfo = NULL; messageview_change_view_type(messageview, MVIEW_TEXT); headerview_clear(messageview->headerview); textview_clear(messageview->textview); @@ -611,6 +780,7 @@ void messageview_destroy(MessageView *messageview) mimeview_destroy(messageview->mimeview); noticeview_destroy(messageview->noticeview); + procmsg_msginfo_free(messageview->msginfo); toolbar_clear_list(TOOLBAR_MSGVIEW); if (messageview->toolbar) { toolbar_destroy(messageview->toolbar); @@ -776,6 +946,38 @@ gboolean messageview_is_visible(MessageView *messageview) return messageview->visible; } +void messageview_save_as(MessageView *messageview) +{ + gchar *filename = NULL; + MsgInfo *msginfo; + gchar *src, *dest; + + if (!messageview->msginfo) return; + msginfo = messageview->msginfo; + + if (msginfo->subject) { + Xstrdup_a(filename, msginfo->subject, return); + subst_for_filename(filename); + } + dest = filesel_select_file(_("Save as"), filename); + if (!dest) return; + if (is_file_exist(dest)) { + AlertValue aval; + + aval = alertpanel(_("Overwrite"), + _("Overwrite existing file?"), + _("OK"), _("Cancel"), NULL); + if (G_ALERTDEFAULT != aval) return; + } + + src = procmsg_get_message_file(msginfo); + if (copy_file(src, dest, TRUE) < 0) { + alertpanel_error(_("Can't save the file `%s'."), + g_basename(dest)); + } + g_free(src); +} + static void messageview_destroy_cb(GtkWidget *widget, MessageView *messageview) { messageview_destroy(messageview); @@ -955,9 +1157,249 @@ static void messageview_menubar_cb(MessageView *msgview, guint action, GtkWidget g_slist_free(msginfo_list); } -static void messageview_close_cb(gpointer data, guint action, GtkWidget *widget) +static void save_as_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + messageview_save_as(messageview); +} + +static void print_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + gchar *cmdline; + gchar *p; + + if (!messageview->msginfo) return; + + cmdline = input_dialog(_("Print"), + _("Enter the print command line:\n" + "(`%s' will be replaced with file name)"), + prefs_common.print_cmd); + if (!cmdline) return; + if (!(p = strchr(cmdline, '%')) || *(p + 1) != 's' || + strchr(p + 2, '%')) { + alertpanel_error(_("Print command line is invalid:\n`%s'"), + cmdline); + g_free(cmdline); + return; + } + + procmsg_print_message(messageview->msginfo, cmdline); + g_free(cmdline); +} + +static void close_cb(gpointer data, guint action, GtkWidget *widget) { MessageView *messageview = (MessageView *)data; - gtk_widget_destroy(messageview->window); } + +static void copy_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + messageview_copy_clipboard(messageview); +} + +static void allsel_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + messageview_select_all(messageview); +} + +static void search_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + message_search(messageview); +} + +static void set_charset_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + const gchar *charset; + + if (GTK_CHECK_MENU_ITEM(widget)->active) { + charset = conv_get_charset_str((CharSet)action); + g_free(messageview->forced_charset); + messageview->forced_charset = g_strdup(charset); + messageview_show(messageview, messageview->msginfo, FALSE); + } +} + +static void view_source_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + SourceWindow *srcwin; + + if (!messageview->msginfo) return; + + srcwin = source_window_create(); + source_window_show_msg(srcwin, messageview->msginfo); + source_window_show(srcwin); +} + +static void show_all_header_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + MsgInfo *msginfo = messageview->msginfo; + + if (!msginfo) return; + messageview->msginfo = NULL; + messageview_show(messageview, msginfo, + GTK_CHECK_MENU_ITEM(widget)->active); + procmsg_msginfo_free(msginfo); +} + +static void compose_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + PrefsAccount *ac = NULL; + FolderItem *item = NULL; + + if (messageview->msginfo) + item = messageview->msginfo->folder; + + if (item) { + ac = account_find_from_item(item); + if (ac && ac->protocol == A_NNTP && + item->stype == F_NEWS) { + compose_new(ac, item->path, NULL); + return; + } + } + + compose_new(ac, NULL, NULL); +} + +static void reply_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + GSList *mlist = NULL; + MsgInfo *msginfo; + gchar *text = NULL; + ComposeMode mode = (ComposeMode)action; + + msginfo = messageview->msginfo; + mlist = g_slist_append(NULL, msginfo); + + text = gtkut_editable_get_selection + (GTK_EDITABLE(messageview->textview->text)); + if (text && *text == '\0') { + g_free(text); + text = NULL; + } + + switch (mode) { + case COMPOSE_REPLY: + compose_reply(msginfo, prefs_common.reply_with_quote, + FALSE, prefs_common.default_reply_list, FALSE, text); + break; + case COMPOSE_REPLY_WITH_QUOTE: + compose_reply(msginfo, TRUE, FALSE, prefs_common.default_reply_list, FALSE, text); + break; + case COMPOSE_REPLY_WITHOUT_QUOTE: + compose_reply(msginfo, FALSE, FALSE, prefs_common.default_reply_list, FALSE, NULL); + break; + case COMPOSE_REPLY_TO_SENDER: + compose_reply(msginfo, prefs_common.reply_with_quote, + FALSE, FALSE, TRUE, text); + break; + case COMPOSE_FOLLOWUP_AND_REPLY_TO: + compose_followup_and_reply_to(msginfo, + prefs_common.reply_with_quote, + FALSE, FALSE, text); + break; + case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE: + compose_reply(msginfo, TRUE, FALSE, FALSE, TRUE, text); + break; + case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE: + compose_reply(msginfo, FALSE, FALSE, FALSE, TRUE, NULL); + break; + case COMPOSE_REPLY_TO_ALL: + compose_reply(msginfo, prefs_common.reply_with_quote, + TRUE, FALSE, FALSE, text); + break; + case COMPOSE_REPLY_TO_ALL_WITH_QUOTE: + compose_reply(msginfo, TRUE, TRUE, FALSE, FALSE, text); + break; + case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE: + compose_reply(msginfo, FALSE, TRUE, FALSE, FALSE, NULL); + break; + case COMPOSE_REPLY_TO_LIST: + compose_reply(msginfo, prefs_common.reply_with_quote, + FALSE, TRUE, FALSE, text); + break; + case COMPOSE_REPLY_TO_LIST_WITH_QUOTE: + compose_reply(msginfo, TRUE, FALSE, TRUE, FALSE, text); + break; + case COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE: + compose_reply(msginfo, FALSE, FALSE, TRUE, FALSE, NULL); + break; + case COMPOSE_FORWARD: + if (prefs_common.forward_as_attachment) { + compose_reply_mode(COMPOSE_FORWARD_AS_ATTACH, mlist, text); + return; + } else { + compose_reply_mode(COMPOSE_FORWARD_INLINE, mlist, text); + return; + } + break; + case COMPOSE_FORWARD_INLINE: + compose_forward(NULL, msginfo, FALSE, text); + break; + case COMPOSE_FORWARD_AS_ATTACH: + compose_forward_multiple(NULL, mlist); + break; + case COMPOSE_REDIRECT: + compose_redirect(NULL, msginfo); + break; + default: + g_warning("compose_reply(): invalid Compose Mode: %d\n", mode); + } + + /* summary_set_marks_selected(summaryview); */ + g_free(text); + g_slist_free(mlist); +} + +static void reedit_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + MsgInfo *msginfo; + + if (!messageview->msginfo) return; + msginfo = messageview->msginfo; + if (!msginfo->folder) return; + if (msginfo->folder->stype != F_OUTBOX && + msginfo->folder->stype != F_DRAFT && + msginfo->folder->stype != F_QUEUE) return; + + compose_reedit(msginfo); +} + +static void addressbook_open_cb(gpointer data, guint action, GtkWidget *widget) +{ + addressbook_open(NULL); +} + +static void add_address_cb(gpointer data, guint action, GtkWidget *widget) +{ + MessageView *messageview = (MessageView *)data; + MsgInfo *msginfo; + gchar *from; + + if (!messageview->msginfo) return; + msginfo = messageview->msginfo; + Xstrdup_a(from, msginfo->from, return); + eliminate_address_comment(from); + extract_address(from); + addressbook_add_contact(msginfo->fromname, from, NULL); +} + +static void create_filter_cb(gpointer data, guint action, GtkWidget *widget) +{ +} + +static void about_cb(gpointer data, guint action, GtkWidget *widget) +{ + about_show(); +} diff --git a/src/messageview.h b/src/messageview.h index 57ee9feca..28d802c61 100644 --- a/src/messageview.h +++ b/src/messageview.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2002 Hiroyuki Yamamoto + * Copyright (C) 1999-2003 Hiroyuki Yamamoto * * 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 @@ -59,11 +59,14 @@ struct _MessageView MainWindow *mainwin; + MsgInfo *msginfo; + + gchar *forced_charset; + gboolean visible; /* From messageview_show */ gboolean all_headers; - MsgInfo *msginfo; }; MessageView *messageview_create (MainWindow *mainwin); diff --git a/src/mimeview.c b/src/mimeview.c index 14b27166b..01d5b471d 100644 --- a/src/mimeview.c +++ b/src/mimeview.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2002 Hiroyuki Yamamoto + * Copyright (C) 1999-2003 Hiroyuki Yamamoto * * 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 diff --git a/src/mimeview.h b/src/mimeview.h index 1551d2866..faffcda56 100644 --- a/src/mimeview.h +++ b/src/mimeview.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2002 Hiroyuki Yamamoto + * Copyright (C) 1999-2003 Hiroyuki Yamamoto * * 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 diff --git a/src/prefs_common.c b/src/prefs_common.c index 349f22cc7..6150292ba 100644 --- a/src/prefs_common.c +++ b/src/prefs_common.c @@ -4026,59 +4026,6 @@ static void prefs_keybind_apply_clicked(GtkWidget *widget) "(menu-path \"/Edit/Advanced/Delete a word backward\" \"W\")\n" "(menu-path \"/Edit/Advanced/Delete a word forward\" \"D\")"; - static gchar *empty_menurc = - "(menu-path \"
/File/Empty trash\" \"\")\n" - "(menu-path \"
/File/Save as...\" \"\")\n" - "(menu-path \"
/File/Print...\" \"\")\n" - "(menu-path \"
/File/Exit\" \"\")\n" - - "(menu-path \"
/Edit/Copy\" \"\")\n" - "(menu-path \"
/Edit/Select all\" \"\")\n" - "(menu-path \"
/Edit/Find in current message...\" \"\")\n" - "(menu-path \"
/Edit/Search folder...\" \"\")\n" - - "(menu-path \"
/View/Expand Summary View\" \"\")\n" - "(menu-path \"
/View/Expand Message View\" \"\")\n" - "(menu-path \"
/View/Thread view\" \"\")\n" - "(menu-path \"
/View/Go to/Prev message\" \"\")\n" - "(menu-path \"
/View/Go to/Next message\" \"\")\n" - "(menu-path \"
/View/Go to/Prev unread message\" \"\")\n" - "(menu-path \"
/View/Go to/Next unread message\" \"\")\n" - "(menu-path \"
/View/Go to/Other folder...\" \"\")\n" - "(menu-path \"
/View/Open in new window\" \"\")\n" - "(menu-path \"
/View/View source\" \"\")\n" - "(menu-path \"
/View/Show all headers\" \"\")\n" - "(menu-path \"
/View/Update\" \"\")\n" - - "(menu-path \"
/Message/Get new mail\" \"\")\n" - "(menu-path \"
/Message/Get from all accounts\" \"\")\n" - "(menu-path \"
/Message/Compose an email message\" \"\")\n" - "(menu-path \"
/Message/Reply\" \"\")\n" - "(menu-path \"
/Message/Reply to/all\" \"\")\n" - "(menu-path \"
/Message/Reply to/sender\" \"\")\n" - "(menu-path \"
/Message/Reply to/mailing list\" \"\")\n" - "(menu-path \"
/Message/Forward\" \"\")\n" - /* "(menu-path \"
/Message/Forward as attachment\" \"\")\n" */ - "(menu-path \"
/Message/Move...\" \"\")\n" - "(menu-path \"
/Message/Copy...\" \"\")\n" - "(menu-path \"
/Message/Delete\" \"\")\n" - "(menu-path \"
/Message/Mark/Mark\" \"\")\n" - "(menu-path \"
/Message/Mark/Unmark\" \"\")\n" - "(menu-path \"
/Message/Mark/Mark as unread\" \"\")\n" - "(menu-path \"
/Message/Mark/Mark as read\" \"\")\n" - - "(menu-path \"
/Tools/Address book\" \"\")\n" - "(menu-path \"
/Tools/Execute\" \"\")\n" - "(menu-path \"
/Tools/Log window\" \"\")\n" - - "(menu-path \"/File/Close\" \"\")\n" - "(menu-path \"/Edit/Select all\" \"\")\n" - "(menu-path \"/Edit/Advanced/Move a word backward\" \"\")\n" - "(menu-path \"/Edit/Advanced/Move a word forward\" \"\")\n" - "(menu-path \"/Edit/Advanced/Move to beginning of line\" \"\")\n" - "(menu-path \"/Edit/Advanced/Delete a word backward\" \"\")\n" - "(menu-path \"/Edit/Advanced/Delete a word forward\" \"\")"; - text = gtk_entry_get_text(entry); if (!strcmp(text, _("Default"))) @@ -4092,7 +4039,7 @@ static void prefs_keybind_apply_clicked(GtkWidget *widget) else return; - gtk_item_factory_parse_rc_string(empty_menurc); + menu_factory_clear_rc(rc_str); gtk_item_factory_parse_rc_string(rc_str); gtk_widget_destroy(keybind.window); diff --git a/src/textview.c b/src/textview.c index bc412c983..06dab5f84 100644 --- a/src/textview.c +++ b/src/textview.c @@ -329,10 +329,13 @@ void textview_show_message(TextView *textview, MimeInfo *mimeinfo, return; } - if (prefs_common.force_charset) + if (textview->messageview->forced_charset) + charset = textview->messageview->forced_charset; + else if (prefs_common.force_charset) charset = prefs_common.force_charset; else if (mimeinfo->charset) charset = mimeinfo->charset; + textview_set_font(textview, charset); textview_clear(textview); @@ -426,10 +429,13 @@ void textview_show_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp) is_rfc822_part = TRUE; } - if (prefs_common.force_charset) + if (textview->messageview->forced_charset) + charset = textview->messageview->forced_charset; + else if (prefs_common.force_charset) charset = prefs_common.force_charset; else if (mimeinfo->charset) charset = mimeinfo->charset; + textview_set_font(textview, charset); text = GTK_STEXT(textview->text); @@ -551,7 +557,9 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp) gtk_stext_insert(text, NULL, NULL, NULL, buf, -1); else if (prefs_common.display_header) gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1); - if (prefs_common.force_charset) + if (textview->messageview->forced_charset) + charset = textview->messageview->forced_charset; + else if (prefs_common.force_charset) charset = prefs_common.force_charset; else if (mimeinfo->charset) charset = mimeinfo->charset; diff --git a/src/textview.h b/src/textview.h index 4011d932c..5ed886ef4 100644 --- a/src/textview.h +++ b/src/textview.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2002 Hiroyuki Yamamoto + * Copyright (C) 1999-2003 Hiroyuki Yamamoto * * 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 -- 2.25.1