2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
61 #include "prefs_common.h"
62 #include "prefs_filter.h"
63 #include "prefs_filtering.h"
64 #include "prefs_scoring.h"
65 #include "prefs_account.h"
66 #include "prefs_folder_item.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_template.h"
70 #include "addressbook.h"
71 #include "headerwindow.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
84 #define AC_LABEL_WIDTH 240
86 #define STATUSBAR_PUSH(mainwin, str) \
88 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
89 mainwin->mainwin_cid, str); \
90 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
93 #define STATUSBAR_POP(mainwin) \
95 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
96 mainwin->mainwin_cid); \
99 /* list of all instantiated MainWindow */
100 static GList *mainwin_list = NULL;
102 static GdkCursor *watch_cursor;
104 static void main_window_show_cur_account (MainWindow *mainwin);
106 static void main_window_set_widgets (MainWindow *mainwin,
108 static void main_window_toolbar_create (MainWindow *mainwin,
109 GtkWidget *container);
111 /* callback functions */
112 static void toolbar_inc_cb (GtkWidget *widget,
114 static void toolbar_inc_all_cb (GtkWidget *widget,
116 static void toolbar_send_cb (GtkWidget *widget,
119 static void toolbar_compose_cb (GtkWidget *widget,
121 static void toolbar_compose_news_cb (GtkWidget *widget,
123 static void toolbar_compose_mail_cb (GtkWidget *widget,
125 static void toolbar_compose_popup_cb (GtkWidget *widget,
126 GdkEventButton *event,
128 static void toolbar_reply_cb (GtkWidget *widget,
130 static void toolbar_reply_popup_cb (GtkWidget *widget,
131 GdkEventButton *event,
133 static void toolbar_reply_to_all_cb (GtkWidget *widget,
135 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
136 GdkEventButton *event,
138 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
140 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
141 GdkEventButton *event,
143 static void toolbar_forward_cb (GtkWidget *widget,
145 static void toolbar_forward_popup_cb (GtkWidget *widget,
146 GdkEventButton *event,
149 static void toolbar_delete_cb (GtkWidget *widget,
151 static void toolbar_exec_cb (GtkWidget *widget,
154 static void toolbar_next_unread_cb (GtkWidget *widget,
157 static void toolbar_prefs_cb (GtkWidget *widget,
159 static void toolbar_account_cb (GtkWidget *widget,
162 static void toolbar_account_button_pressed (GtkWidget *widget,
163 GdkEventButton *event,
165 static void ac_label_button_pressed (GtkWidget *widget,
166 GdkEventButton *event,
168 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
171 static gint main_window_close_cb (GtkWidget *widget,
175 static void add_mailbox_cb (MainWindow *mainwin,
178 static void add_mbox_cb (MainWindow *mainwin,
181 static void update_folderview_cb (MainWindow *mainwin,
184 static void new_folder_cb (MainWindow *mainwin,
187 static void rename_folder_cb (MainWindow *mainwin,
190 static void delete_folder_cb (MainWindow *mainwin,
193 static void import_mbox_cb (MainWindow *mainwin,
196 static void export_mbox_cb (MainWindow *mainwin,
199 static void empty_trash_cb (MainWindow *mainwin,
203 static void save_as_cb (MainWindow *mainwin,
206 static void print_cb (MainWindow *mainwin,
209 static void app_exit_cb (MainWindow *mainwin,
213 static void search_cb (MainWindow *mainwin,
217 static void toggle_folder_cb (MainWindow *mainwin,
220 static void toggle_message_cb (MainWindow *mainwin,
223 static void toggle_toolbar_cb (MainWindow *mainwin,
226 static void toggle_statusbar_cb (MainWindow *mainwin,
229 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
233 static void addressbook_open_cb (MainWindow *mainwin,
236 static void log_window_show_cb (MainWindow *mainwin,
240 static void inc_mail_cb (MainWindow *mainwin,
243 static void inc_all_account_mail_cb (MainWindow *mainwin,
247 static void send_queue_cb (MainWindow *mainwin,
251 static void compose_cb (MainWindow *mainwin,
254 static void compose_mail_cb(MainWindow *mainwin, guint action,
256 static void compose_news_cb(MainWindow *mainwin, guint action,
258 static void reply_cb (MainWindow *mainwin,
262 static void open_msg_cb (MainWindow *mainwin,
266 static void view_source_cb (MainWindow *mainwin,
270 static void reedit_cb (MainWindow *mainwin,
274 static void move_to_cb (MainWindow *mainwin,
277 static void copy_to_cb (MainWindow *mainwin,
280 static void delete_cb (MainWindow *mainwin,
284 static void mark_cb (MainWindow *mainwin,
287 static void unmark_cb (MainWindow *mainwin,
291 static void mark_as_unread_cb (MainWindow *mainwin,
294 static void mark_as_read_cb (MainWindow *mainwin,
297 static void mark_all_read_cb (MainWindow *mainwin,
300 static void add_address_cb (MainWindow *mainwin,
304 static void set_charset_cb (MainWindow *mainwin,
308 static void thread_cb (MainWindow *mainwin,
311 static void set_display_item_cb (MainWindow *mainwin,
314 static void sort_summary_cb (MainWindow *mainwin,
317 static void attract_by_subject_cb(MainWindow *mainwin,
321 static void delete_duplicated_cb (MainWindow *mainwin,
324 static void filter_cb (MainWindow *mainwin,
327 static void execute_summary_cb (MainWindow *mainwin,
330 static void update_summary_cb (MainWindow *mainwin,
334 static void prev_cb (MainWindow *mainwin,
337 static void next_cb (MainWindow *mainwin,
341 static void prev_unread_cb (MainWindow *mainwin,
344 static void next_unread_cb (MainWindow *mainwin,
347 static void prev_marked_cb (MainWindow *mainwin,
350 static void next_marked_cb (MainWindow *mainwin,
353 static void prev_labeled_cb (MainWindow *mainwin,
356 static void next_labeled_cb (MainWindow *mainwin,
360 static void goto_folder_cb (MainWindow *mainwin,
364 static void copy_cb (MainWindow *mainwin,
367 static void allsel_cb (MainWindow *mainwin,
371 static void prefs_common_open_cb (MainWindow *mainwin,
374 static void prefs_filter_open_cb (MainWindow *mainwin,
377 static void prefs_scoring_open_cb (MainWindow *mainwin,
380 static void prefs_filtering_open_cb (MainWindow *mainwin,
383 static void prefs_account_open_cb(MainWindow *mainwin,
386 static void prefs_template_open_cb (MainWindow *mainwin,
389 static void new_account_cb (MainWindow *mainwin,
393 static void account_menu_cb (GtkMenuItem *menuitem,
396 static void manual_open_cb (MainWindow *mainwin,
400 static void scan_tree_func (Folder *folder,
404 static void activate_compose_button (MainWindow *mainwin,
406 ComposeButtonType type);
408 #define SEPARATE_ACTION 667
410 static GtkItemFactoryEntry mainwin_entries[] =
412 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
413 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
414 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
415 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
416 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
417 {N_("/_File/_Folder/Create _new folder..."),
418 NULL, new_folder_cb, 0, NULL},
419 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
420 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
421 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
422 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
423 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
424 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
425 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
426 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
427 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
428 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
429 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
431 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
432 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
433 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
434 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
435 {N_("/_Edit/_Find in current message"), "<control>F", search_cb, 0, NULL},
436 {N_("/_Edit/_Search folder"), "<control>S", search_cb, 1, NULL},
438 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
439 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
440 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
441 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
442 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
443 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
444 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
445 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
446 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
447 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
448 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
449 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
450 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
451 {N_("/_View/View _source"), "<control>U", view_source_cb, 0, NULL},
452 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
453 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
454 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
455 {N_("/_View/_Code set/_Auto detect"),
456 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
458 #define CODESET_SEPARATOR \
459 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
460 #define CODESET_ACTION(action) \
461 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
463 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
464 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
465 CODESET_ACTION(C_US_ASCII)},
468 {N_("/_View/_Code set/Unicode (_UTF-8)"),
469 CODESET_ACTION(C_UTF_8)},
472 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
473 CODESET_ACTION(C_ISO_8859_1)},
476 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
477 CODESET_ACTION(C_ISO_8859_2)},
479 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
480 CODESET_ACTION(C_ISO_8859_13)},
481 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
482 CODESET_ACTION(C_ISO_8859_4)},
484 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
485 CODESET_ACTION(C_ISO_8859_7)},
487 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
488 CODESET_ACTION(C_ISO_8859_9)},
490 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
491 CODESET_ACTION(C_ISO_8859_5)},
492 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
493 CODESET_ACTION(C_KOI8_R)},
494 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
495 CODESET_ACTION(C_CP1251)},
498 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
499 CODESET_ACTION(C_ISO_2022_JP)},
501 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
502 CODESET_ACTION(C_ISO_2022_JP_2)},
504 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
505 CODESET_ACTION(C_EUC_JP)},
506 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
507 CODESET_ACTION(C_SHIFT_JIS)},
510 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
511 CODESET_ACTION(C_GB2312)},
512 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
513 CODESET_ACTION(C_BIG5)},
514 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
515 CODESET_ACTION(C_EUC_TW)},
516 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
517 CODESET_ACTION(C_ISO_2022_CN)},
519 {N_("/_View/_Code set/Korean (EUC-_KR)"),
520 CODESET_ACTION(C_EUC_KR)},
521 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
522 CODESET_ACTION(C_ISO_2022_KR)},
524 {N_("/_View/_Code set/Thai (TIS-620)"),
525 CODESET_ACTION(C_TIS_620)},
526 {N_("/_View/_Code set/Thai (Windows-874)"),
527 CODESET_ACTION(C_WINDOWS_874)},
530 #undef CODESET_SEPARATOR
531 #undef CODESET_ACTION
533 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
534 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
535 {N_("/_Message/Get from _all accounts"),
536 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
537 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_Message/Send queued messa_ges"),
539 NULL, send_queue_cb, 0, NULL},
540 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
542 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
543 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
544 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
545 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
546 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
547 {N_("/_Message/_Forward"), "<shift><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
548 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
549 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
550 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
551 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
553 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
554 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
555 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
557 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
558 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
559 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
560 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
561 {N_("/_Message/_Mark/Mark as rea_d"),
562 NULL, mark_as_read_cb, 0, NULL},
563 {N_("/_Message/_Mark/Mark all read"), NULL, mark_all_read_cb, 0, NULL},
564 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
565 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
567 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
568 {N_("/_Summary/_Delete duplicated messages"),
569 NULL, delete_duplicated_cb, 0, NULL},
570 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
571 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
572 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
573 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
574 {N_("/_Summary/Go _to"), NULL, NULL, 0, "<Branch>"},
575 {N_("/_Summary/Go _to/_Prev message"), NULL, prev_cb, 0, NULL},
576 {N_("/_Summary/Go _to/_Next message"), NULL, next_cb, 0, NULL},
577 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_Summary/Go _to/P_rev unread message"),
579 NULL, prev_unread_cb, 0, NULL},
580 {N_("/_Summary/Go _to/N_ext unread message"),
581 NULL, next_unread_cb, 0, NULL},
582 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
583 {N_("/_Summary/Go _to/Prev _marked message"),
584 NULL, prev_marked_cb, 0, NULL},
585 {N_("/_Summary/Go _to/Next m_arked message"),
586 NULL, next_marked_cb, 0, NULL},
587 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
588 {N_("/_Summary/Go _to/Prev _labeled message"),
589 NULL, prev_labeled_cb, 0, NULL},
590 {N_("/_Summary/Go _to/Next la_beled message"),
591 NULL, next_labeled_cb, 0, NULL},
592 {N_("/_Summary/_Go to other folder..."),"<alt>G", goto_folder_cb, 0, NULL},
593 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
594 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
595 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
596 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
597 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
598 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
599 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
600 {N_("/_Summary/_Sort/Sort by _color label"),
601 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
602 {N_("/_Summary/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
603 {N_("/_Summary/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
604 {N_("/_Summary/_Sort/Sort by a_ttachment"),
605 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
606 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
607 {N_("/_Summary/_Sort/_Attract by subject"),
608 NULL, attract_by_subject_cb, 0, NULL},
609 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
610 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
611 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
613 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
614 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
615 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
617 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
618 {N_("/_Configuration/_Common preferences..."),
619 NULL, prefs_common_open_cb, 0, NULL},
620 {N_("/_Configuration/_Filter setting..."),
621 NULL, prefs_filter_open_cb, 0, NULL},
622 {N_("/_Configuration/_Scoring ..."),
623 NULL, prefs_scoring_open_cb, 0, NULL},
624 {N_("/_Configuration/_Filtering ..."),
625 NULL, prefs_filtering_open_cb, 0, NULL},
626 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
627 {N_("/_Configuration/_Preferences for current account..."),
628 NULL, prefs_account_open_cb, 0, NULL},
629 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
630 {N_("/_Configuration/Create _new account..."),
631 NULL, new_account_cb, 0, NULL},
632 {N_("/_Configuration/_Edit accounts..."),
633 NULL, account_edit_open, 0, NULL},
634 {N_("/_Configuration/C_hange current account"),
635 NULL, NULL, 0, "<Branch>"},
637 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
638 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
639 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
640 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
641 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
642 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
644 static GtkItemFactoryEntry compose_popup_entries[] =
646 {N_("/Compose an _email message"), NULL, compose_mail_cb, 0, NULL},
647 {N_("/Compose a _news message"), NULL, compose_news_cb, 0, NULL}
649 static GtkItemFactoryEntry reply_popup_entries[] =
651 {N_("/Reply to message with _quoting it"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
652 {N_("/_Reply to message without quoting it"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
654 static GtkItemFactoryEntry replyall_popup_entries[] =
656 {N_("/Reply to all with _quoting the message"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
657 {N_("/_Reply to all without quoting the message"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
659 static GtkItemFactoryEntry replysender_popup_entries[] =
661 {N_("/Reply to sender with _quoting the message"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
662 {N_("/_Reply to sender without quoting the message"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
664 static GtkItemFactoryEntry fwd_popup_entries[] =
666 {N_("/_Forward message (inline style)"), NULL, reply_cb, COMPOSE_FORWARD_INLINE, NULL},
667 {N_("/Forward message as _attachement"), NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
671 MainWindow *main_window_create(SeparateType type)
677 GtkWidget *handlebox;
678 GtkWidget *vbox_body;
679 GtkWidget *hbox_stat;
680 GtkWidget *statusbar;
681 GtkWidget *progressbar;
682 GtkWidget *statuslabel;
683 GtkWidget *ac_button;
686 FolderView *folderview;
687 SummaryView *summaryview;
688 MessageView *messageview;
689 GdkColormap *colormap;
692 guint n_menu_entries;
693 GtkItemFactory *ifactory;
696 GtkWidget *compose_popup;
697 GtkWidget *reply_popup;
698 GtkWidget *replyall_popup;
699 GtkWidget *replysender_popup;
700 GtkWidget *fwd_popup;
703 debug_print(_("Creating main window...\n"));
704 mainwin = g_new0(MainWindow, 1);
707 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
708 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
709 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
710 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
711 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
712 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
713 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
714 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
715 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
717 gtk_widget_realize(window);
718 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
720 gtkut_widget_set_app_icon(window);
722 vbox = gtk_vbox_new(FALSE, 0);
723 gtk_widget_show(vbox);
724 gtk_container_add(GTK_CONTAINER(window), vbox);
727 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
728 menubar = menubar_create(window, mainwin_entries,
729 n_menu_entries, "<Main>", mainwin);
730 gtk_widget_show(menubar);
731 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
733 handlebox = gtk_handle_box_new();
734 gtk_widget_show(handlebox);
735 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
737 /* create the popup menu for the compose button */
738 n_menu_entries = sizeof(compose_popup_entries) /
739 sizeof(compose_popup_entries[0]);
740 compose_popup = popupmenu_create(window, compose_popup_entries, n_menu_entries,
741 "<ComposePopup>", mainwin);
742 /* create the popup menus for the reply buttons specials */
743 n_menu_entries = sizeof(reply_popup_entries) /
744 sizeof(reply_popup_entries[0]);
745 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
746 "<ReplyPopup>", mainwin);
747 n_menu_entries = sizeof(replyall_popup_entries) /
748 sizeof(replyall_popup_entries[0]);
749 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
750 "<ReplyAllPopup>", mainwin);
751 n_menu_entries = sizeof(replysender_popup_entries) /
752 sizeof(replysender_popup_entries[0]);
753 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
754 "<ReplySenderPopup>", mainwin);
755 /* create the popup menu for the forward button */
756 n_menu_entries = sizeof(fwd_popup_entries) /
757 sizeof(fwd_popup_entries[0]);
758 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
759 "<ForwardPopup>", mainwin);
761 main_window_toolbar_create(mainwin, handlebox);
763 /* vbox that contains body */
764 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
765 gtk_widget_show(vbox_body);
766 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
767 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
769 hbox_stat = gtk_hbox_new(FALSE, 2);
770 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
772 statusbar = statusbar_create();
773 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
775 progressbar = gtk_progress_bar_new();
776 gtk_widget_set_usize(progressbar, 120, 1);
777 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
779 statuslabel = gtk_label_new("");
780 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
782 ac_button = gtk_button_new();
783 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
784 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
785 gtk_widget_set_usize(ac_button, -1, 1);
786 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
787 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
788 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
790 ac_label = gtk_label_new("");
791 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
793 gtk_widget_show_all(hbox_stat);
796 mainwin->folderview = folderview = folderview_create();
797 mainwin->summaryview = summaryview = summary_create();
798 mainwin->messageview = messageview = messageview_create();
799 mainwin->headerwin = header_window_create();
800 mainwin->logwin = log_window_create();
802 folderview->mainwin = mainwin;
803 folderview->summaryview = summaryview;
805 summaryview->mainwin = mainwin;
806 summaryview->folderview = folderview;
807 summaryview->messageview = messageview;
808 summaryview->headerwin = mainwin->headerwin;
809 summaryview->window = window;
811 messageview->mainwin = mainwin;
813 mainwin->window = window;
814 mainwin->vbox = vbox;
815 mainwin->menubar = menubar;
816 mainwin->handlebox = handlebox;
817 mainwin->vbox_body = vbox_body;
818 mainwin->hbox_stat = hbox_stat;
819 mainwin->statusbar = statusbar;
820 mainwin->progressbar = progressbar;
821 mainwin->statuslabel = statuslabel;
822 mainwin->ac_button = ac_button;
823 mainwin->ac_label = ac_label;
824 mainwin->compose_popup = compose_popup;
825 mainwin->reply_popup = reply_popup;
826 mainwin->replyall_popup = replyall_popup;
827 mainwin->replysender_popup = replysender_popup;
828 mainwin->fwd_popup = fwd_popup;
830 /* set context IDs for status bar */
831 mainwin->mainwin_cid = gtk_statusbar_get_context_id
832 (GTK_STATUSBAR(statusbar), "Main Window");
833 mainwin->folderview_cid = gtk_statusbar_get_context_id
834 (GTK_STATUSBAR(statusbar), "Folder View");
835 mainwin->summaryview_cid = gtk_statusbar_get_context_id
836 (GTK_STATUSBAR(statusbar), "Summary View");
838 /* allocate colors for summary view and folder view */
839 summaryview->color_marked.red = summaryview->color_marked.green = 0;
840 summaryview->color_marked.blue = (guint16)65535;
842 summaryview->color_dim.red = summaryview->color_dim.green =
843 summaryview->color_dim.blue = COLOR_DIM;
845 folderview->color_new.red = (guint16)55000;
846 folderview->color_new.green = folderview->color_new.blue = 15000;
848 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
849 &folderview->color_op);
851 summaryview->color_important.red = 0;
852 summaryview->color_marked.green = 0;
853 summaryview->color_important.blue = (guint16)65535;
855 color[0] = summaryview->color_marked;
856 color[1] = summaryview->color_dim;
857 color[2] = folderview->color_new;
858 color[3] = folderview->color_op;
860 colormap = gdk_window_get_colormap(window->window);
861 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
862 for (i = 0; i < 4; i++) {
863 if (success[i] == FALSE)
864 g_warning(_("MainWindow: color allocation %d failed\n"), i);
867 debug_print(_("done.\n"));
869 main_window_set_widgets(mainwin, type);
872 ifactory = gtk_item_factory_from_widget(menubar);
873 menuitem = gtk_item_factory_get_item
874 (ifactory, "/View/Code set/Auto detect");
875 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
877 switch (prefs_common.toolbar_style) {
879 menuitem = gtk_item_factory_get_item
880 (ifactory, "/View/Toolbar/None");
883 menuitem = gtk_item_factory_get_item
884 (ifactory, "/View/Toolbar/Icon");
887 menuitem = gtk_item_factory_get_item
888 (ifactory, "/View/Toolbar/Text");
891 menuitem = gtk_item_factory_get_item
892 (ifactory, "/View/Toolbar/Icon and text");
894 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
896 gtk_widget_hide(mainwin->hbox_stat);
897 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
898 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
899 prefs_common.show_statusbar);
901 /* set the check of the SEPARATE_xxx menu items. we also need the main window
902 * as a property and pass the action type to the callback */
903 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
905 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
906 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
907 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
908 GUINT_TO_POINTER(SEPARATE_FOLDER));
910 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
912 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
913 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
914 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
915 GUINT_TO_POINTER(SEPARATE_MESSAGE));
918 menu_set_sensitive(ifactory, "/Summary/Thread view",
919 prefs_common.enable_thread ? FALSE : TRUE);
920 menu_set_sensitive(ifactory, "/Summary/Unthread view",
921 prefs_common.enable_thread ? TRUE : FALSE);
923 /*main_window_set_thread_option(mainwin);*/
926 /* set account selection menu */
927 ac_menu = gtk_item_factory_get_widget
928 (ifactory, "/Configuration/Change current account");
929 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
930 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
931 mainwin->ac_menu = ac_menu;
933 main_window_set_toolbar_sensitive(mainwin);
935 /* show main window */
936 gtk_widget_set_uposition(mainwin->window,
937 prefs_common.mainwin_x,
938 prefs_common.mainwin_y);
939 gtk_widget_set_usize(window, prefs_common.mainwin_width,
940 prefs_common.mainwin_height);
942 gtk_widget_show(mainwin->window);
944 /* initialize views */
945 folderview_init(folderview);
946 summary_init(summaryview);
947 messageview_init(messageview);
948 header_window_init(mainwin->headerwin);
949 log_window_init(mainwin->logwin);
952 mainwin->lock_count = 0;
953 mainwin->cursor_count = 0;
956 watch_cursor = gdk_cursor_new(GDK_WATCH);
958 mainwin_list = g_list_append(mainwin_list, mainwin);
963 void main_window_cursor_wait(MainWindow *mainwin)
966 if (mainwin->cursor_count == 0)
967 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
969 mainwin->cursor_count++;
974 void main_window_cursor_normal(MainWindow *mainwin)
976 if (mainwin->cursor_count)
977 mainwin->cursor_count--;
979 if (mainwin->cursor_count == 0)
980 gdk_window_set_cursor(mainwin->window->window, NULL);
985 /* lock / unlock the user-interface */
986 void main_window_lock(MainWindow *mainwin)
988 if (mainwin->lock_count == 0)
989 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
991 mainwin->lock_count++;
993 main_window_set_menu_sensitive(mainwin);
994 main_window_set_toolbar_sensitive(mainwin);
997 void main_window_unlock(MainWindow *mainwin)
999 if (mainwin->lock_count)
1000 mainwin->lock_count--;
1002 main_window_set_menu_sensitive(mainwin);
1003 main_window_set_toolbar_sensitive(mainwin);
1005 if (mainwin->lock_count == 0)
1006 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1009 void main_window_reflect_prefs_all(void)
1012 MainWindow *mainwin;
1014 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1015 mainwin = (MainWindow *)cur->data;
1017 main_window_show_cur_account(mainwin);
1018 main_window_set_menu_sensitive(mainwin);
1019 main_window_set_toolbar_sensitive(mainwin);
1021 if (prefs_common.immediate_exec)
1022 gtk_widget_hide(mainwin->exec_btn);
1024 gtk_widget_show(mainwin->exec_btn);
1026 summary_redisplay_msg(mainwin->summaryview);
1027 headerview_set_visibility(mainwin->messageview->headerview,
1028 prefs_common.display_header_pane);
1032 void main_window_set_summary_column(void)
1035 MainWindow *mainwin;
1037 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1038 mainwin = (MainWindow *)cur->data;
1039 summary_set_column_order(mainwin->summaryview);
1043 void main_window_set_account_menu(GList *account_list)
1045 GList *cur, *cur_ac, *cur_item;
1046 GtkWidget *menuitem;
1047 MainWindow *mainwin;
1048 PrefsAccount *ac_prefs;
1050 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1051 mainwin = (MainWindow *)cur->data;
1053 /* destroy all previous menu item */
1054 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1055 while (cur_item != NULL) {
1056 GList *next = cur_item->next;
1057 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1061 for (cur_ac = account_list; cur_ac != NULL;
1062 cur_ac = cur_ac->next) {
1063 ac_prefs = (PrefsAccount *)cur_ac->data;
1065 menuitem = gtk_menu_item_new_with_label
1066 (ac_prefs->account_name
1067 ? ac_prefs->account_name : _("Untitled"));
1068 gtk_widget_show(menuitem);
1069 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1070 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1071 GTK_SIGNAL_FUNC(account_menu_cb),
1077 static void main_window_show_cur_account(MainWindow *mainwin)
1082 ac_name = g_strdup(cur_account
1083 ? (cur_account->account_name
1084 ? cur_account->account_name : _("Untitled"))
1088 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1090 buf = g_strdup(PROG_VERSION);
1091 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1094 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1095 gtk_widget_queue_resize(mainwin->ac_button);
1100 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1102 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1103 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1104 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1106 if (mainwin->type == type) return;
1108 /* remove widgets from those containers */
1109 gtk_widget_ref(folder_wid);
1110 gtk_widget_ref(summary_wid);
1111 gtk_widget_ref(message_wid);
1112 gtk_container_remove
1113 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1114 gtk_container_remove
1115 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1116 gtk_container_remove
1117 (GTK_CONTAINER(message_wid->parent), message_wid);
1119 /* clean containers */
1120 switch (mainwin->type) {
1122 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1124 case SEPARATE_FOLDER:
1125 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1126 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1128 case SEPARATE_MESSAGE:
1129 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1130 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1133 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1134 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1138 gtk_widget_hide(mainwin->window);
1139 main_window_set_widgets(mainwin, type);
1140 gtk_widget_show(mainwin->window);
1142 gtk_widget_unref(folder_wid);
1143 gtk_widget_unref(summary_wid);
1144 gtk_widget_unref(message_wid);
1147 void main_window_get_size(MainWindow *mainwin)
1149 GtkAllocation *allocation;
1151 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1153 prefs_common.summaryview_width = allocation->width;
1155 if (mainwin->summaryview->msg_is_toggled_on)
1156 prefs_common.summaryview_height = allocation->height;
1158 prefs_common.mainview_width = allocation->width;
1160 allocation = &mainwin->window->allocation;
1162 prefs_common.mainview_height = allocation->height;
1163 prefs_common.mainwin_width = allocation->width;
1164 prefs_common.mainwin_height = allocation->height;
1166 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1168 prefs_common.folderview_width = allocation->width;
1169 prefs_common.folderview_height = allocation->height;
1172 void main_window_get_position(MainWindow *mainwin)
1176 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1178 prefs_common.mainview_x = x;
1179 prefs_common.mainview_y = y;
1180 prefs_common.mainwin_x = x;
1181 prefs_common.mainwin_y = y;
1183 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1186 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1189 gboolean hasTrash = 0;
1191 for (list = folder_get_list(); list != NULL; list = list->next) {
1194 folder = list->data;
1195 if (folder->trash) {
1196 hasTrash = (folder->trash->total > 0);
1205 if (alertpanel(_("Empty trash"),
1206 _("Empty all messages in trash?"),
1207 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1209 manage_window_focus_in(mainwin->window, NULL, NULL);
1212 procmsg_empty_trash();
1214 for (list = folder_get_list(); list != NULL; list = list->next) {
1217 folder = list->data;
1218 if (folder->trash) {
1219 folder_item_scan(folder->trash);
1220 folderview_update_item(folder->trash, TRUE);
1224 if (mainwin->summaryview->folder_item &&
1225 mainwin->summaryview->folder_item->stype == F_TRASH)
1226 gtk_widget_grab_focus(mainwin->folderview->ctree);
1229 void main_window_add_mailbox(MainWindow *mainwin)
1234 path = input_dialog(_("Add mailbox"),
1235 _("Input the location of mailbox.\n"
1236 "If the existing mailbox is specified, it will be\n"
1237 "scanned automatically."),
1240 if (folder_find_from_path(path)) {
1241 alertpanel_error(_("The mailbox `%s' already exists."), path);
1245 if (!strcmp(path, "Mail"))
1246 folder = folder_new(F_MH, _("Mailbox"), path);
1248 folder = folder_new(F_MH, g_basename(path), path);
1251 if (folder->create_tree(folder) < 0) {
1252 alertpanel_error(_("Creation of the mailbox failed.\n"
1253 "Maybe some files already exist, or you don't have the permission to write there."));
1254 folder_destroy(folder);
1259 folder_set_ui_func(folder, scan_tree_func, mainwin);
1260 folder->scan_tree(folder);
1261 folder_set_ui_func(folder, NULL, NULL);
1263 folderview_set(mainwin->folderview);
1266 void main_window_add_mbox(MainWindow *mainwin)
1272 path = input_dialog(_("Add mbox mailbox"),
1273 _("Input the location of mailbox."),
1278 if (folder_find_from_path(path)) {
1279 alertpanel_error(_("The mailbox `%s' already exists."), path);
1285 if (!strcmp(path, "Mail"))
1286 folder = folder_new(F_MBOX, _("Mailbox"), path);
1290 folder = folder_new(F_MBOX, g_basename(path), path);
1293 if (folder->create_tree(folder) < 0) {
1294 alertpanel_error(_("Creation of the mailbox failed."));
1295 folder_destroy(folder);
1301 item = folder_item_new(folder->name, NULL);
1302 item->folder = folder;
1303 folder->node = g_node_new(item);
1305 folder->create_folder(folder, item, "inbox");
1306 folder->create_folder(folder, item, "outbox");
1307 folder->create_folder(folder, item, "queue");
1308 folder->create_folder(folder, item, "draft");
1309 folder->create_folder(folder, item, "trash");
1311 folderview_set(mainwin->folderview);
1316 M_UNLOCKED = 1 << 0,
1317 M_MSG_EXIST = 1 << 1,
1318 M_TARGET_EXIST = 1 << 2,
1319 M_SINGLE_TARGET_EXIST = 1 << 3,
1321 M_ALLOW_REEDIT = 1 << 5,
1322 M_HAVE_ACCOUNT = 1 << 6,
1323 M_THREADED = 1 << 7,
1324 M_UNTHREADED = 1 << 8,
1326 M_HAVE_NEWS_ACCOUNT = 1 << 10
1329 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1331 SensitiveCond state = 0;
1332 SummarySelection selection;
1333 FolderItem *item = mainwin->summaryview->folder_item;
1334 GList *account_list = account_get_list();
1336 selection = summary_get_selection_type(mainwin->summaryview);
1338 if (mainwin->lock_count == 0)
1339 state |= M_UNLOCKED;
1340 if (selection != SUMMARY_NONE)
1341 state |= M_MSG_EXIST;
1344 state |= M_THREADED;
1346 state |= M_UNTHREADED;
1348 if (selection == SUMMARY_SELECTED_SINGLE ||
1349 selection == SUMMARY_SELECTED_MULTIPLE)
1350 state |= M_TARGET_EXIST;
1351 if (selection == SUMMARY_SELECTED_SINGLE)
1352 state |= M_SINGLE_TARGET_EXIST;
1353 if (item && item->folder->type != F_NEWS)
1355 if (mainwin->summaryview->folder_item &&
1356 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1358 if (selection == SUMMARY_SELECTED_SINGLE &&
1360 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1361 item->stype == F_QUEUE)))
1362 state |= M_ALLOW_REEDIT;
1364 state |= M_HAVE_ACCOUNT;
1366 for ( ; account_list != NULL; account_list = account_list->next) {
1367 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1368 state |= M_HAVE_NEWS_ACCOUNT;
1376 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1378 SensitiveCond state;
1386 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1387 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1388 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1389 {mainwin->compose_news_btn, M_HAVE_NEWS_ACCOUNT},
1390 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1391 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1392 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1393 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1394 /* {mainwin->prefs_btn , M_UNLOCKED},
1395 {mainwin->account_btn , M_UNLOCKED}, */
1396 {mainwin->next_btn , M_MSG_EXIST},
1397 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1398 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1402 state = main_window_get_current_state(mainwin);
1404 for (i = 0; entry[i].widget != NULL; i++) {
1405 sensitive = ((entry[i].cond & state) == entry[i].cond);
1406 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1409 activate_compose_button(mainwin,
1410 prefs_common.toolbar_style,
1411 mainwin->compose_btn_type);
1414 void main_window_set_menu_sensitive(MainWindow *mainwin)
1416 GtkItemFactory *ifactory;
1417 SensitiveCond state;
1421 static const struct {
1425 {"/File/Add mailbox..." , M_UNLOCKED},
1426 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1427 {"/File/Rescan folder tree" , M_UNLOCKED},
1428 {"/File/Folder" , M_UNLOCKED},
1429 {"/File/Import mbox file..." , M_UNLOCKED},
1430 {"/File/Export to mbox file...", M_UNLOCKED},
1431 {"/File/Empty trash" , M_UNLOCKED},
1432 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1433 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1434 {"/File/Close", M_UNLOCKED},
1435 {"/File/Exit" , M_UNLOCKED},
1437 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1438 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1440 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1441 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1442 /* {"/Message/Compose new message" , M_HAVE_ACCOUNT}, */
1443 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1444 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1445 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1446 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1447 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1448 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1449 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1450 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1451 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1452 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1453 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1454 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1455 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1456 {"/Message/Mark" , M_TARGET_EXIST},
1458 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1459 {"/Summary/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1460 {"/Summary/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1461 {"/Summary/Go to" , M_MSG_EXIST},
1462 {"/Summary/Go to/Prev message" , M_MSG_EXIST},
1463 {"/Summary/Go to/Next message" , M_MSG_EXIST},
1464 {"/Summary/Go to/Next unread message" , M_MSG_EXIST},
1465 {"/Summary/Go to/Prev marked message" , M_MSG_EXIST},
1466 {"/Summary/Go to/Next marked message" , M_MSG_EXIST},
1467 {"/Summary/Go to/Prev labeled message", M_MSG_EXIST},
1468 {"/Summary/Go to/Next labeled message", M_MSG_EXIST},
1469 {"/Summary/Sort" , M_MSG_EXIST},
1470 {"/Summary/Thread view" , M_UNTHREADED},
1471 {"/Summary/Unthread view" , M_THREADED},
1473 {"/Configuration", M_UNLOCKED},
1478 /* the Email/News popup in the toolbar */
1479 static const struct {
1482 } entry_compose_popup[] = {
1483 {"/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1487 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1488 state = main_window_get_current_state(mainwin);
1490 for (i = 0; entry[i].entry != NULL; i++) {
1491 sensitive = ((entry[i].cond & state) == entry[i].cond);
1492 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1495 /* the Email/News popup in the toolbar */
1496 ifactory = gtk_item_factory_from_widget(mainwin->compose_popup);
1498 for (i = 0; entry_compose_popup[i].entry != NULL; i++) {
1499 sensitive = ((entry_compose_popup[i].cond & state) == entry_compose_popup[i].cond);
1500 menu_set_sensitive(ifactory, entry_compose_popup[i].entry, sensitive);
1505 void main_window_popup(MainWindow *mainwin)
1511 gdk_window_get_origin(mainwin->window->window, &x, &y);
1512 sx = gdk_screen_width();
1513 sy = gdk_screen_height();
1514 x %= sx; if (x < 0) x = 0;
1515 y %= sy; if (y < 0) y = 0;
1516 gdk_window_move(mainwin->window->window, x, y);
1517 gdk_window_raise(mainwin->window->window);
1518 gdk_window_show(mainwin->window->window);
1520 debug_print("window position: x = %d, y = %d\n", x, y);
1522 switch (mainwin->type) {
1523 case SEPARATE_FOLDER:
1524 widget = mainwin->win.sep_folder.folderwin;
1525 gdk_window_get_origin(widget->window, &x, &y);
1526 x %= sx; if (x < 0) x = 0;
1527 y %= sy; if (y < 0) y = 0;
1528 gdk_window_move(widget->window, x, y);
1529 gdk_window_raise(widget->window);
1531 case SEPARATE_MESSAGE:
1532 widget = mainwin->win.sep_message.messagewin;
1533 gdk_window_get_origin(widget->window, &x, &y);
1534 x %= sx; if (x < 0) x = 0;
1535 y %= sy; if (y < 0) y = 0;
1536 gdk_window_move(widget->window, x, y);
1537 gdk_window_raise(widget->window);
1540 widget = mainwin->win.sep_both.folderwin;
1541 gdk_window_get_origin(widget->window, &x, &y);
1542 x %= sx; if (x < 0) x = 0;
1543 y %= sy; if (y < 0) y = 0;
1544 gdk_window_move(widget->window, x, y);
1545 gdk_window_raise(widget->window);
1546 widget = mainwin->win.sep_both.messagewin;
1547 gdk_window_get_origin(widget->window, &x, &y);
1548 x %= sx; if (x < 0) x = 0;
1549 y %= sy; if (y < 0) y = 0;
1550 gdk_window_move(widget->window, x, y);
1551 gdk_window_raise(widget->window);
1558 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1560 GtkWidget *folderwin = NULL;
1561 GtkWidget *messagewin = NULL;
1564 GtkWidget *vbox_body = mainwin->vbox_body;
1566 debug_print(_("Setting widgets..."));
1568 /* create separated window(s) if needed */
1569 if (type & SEPARATE_FOLDER) {
1570 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1571 gtk_window_set_policy(GTK_WINDOW(folderwin),
1573 gtk_widget_set_usize(folderwin, -1,
1574 prefs_common.mainview_height);
1575 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1577 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1578 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1581 if (type & SEPARATE_MESSAGE) {
1582 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1583 gtk_window_set_policy(GTK_WINDOW(messagewin),
1585 gtk_widget_set_usize
1586 (messagewin, prefs_common.mainview_width,
1587 prefs_common.mainview_height
1588 - prefs_common.summaryview_height
1589 + DEFAULT_HEADERVIEW_HEIGHT);
1590 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1592 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1593 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1599 hpaned = gtk_hpaned_new();
1600 gtk_widget_show(hpaned);
1601 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1602 gtk_paned_add1(GTK_PANED(hpaned),
1603 GTK_WIDGET_PTR(mainwin->folderview));
1605 vpaned = gtk_vpaned_new();
1606 if (mainwin->summaryview->msg_is_toggled_on) {
1607 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1608 gtk_paned_add1(GTK_PANED(vpaned),
1609 GTK_WIDGET_PTR(mainwin->summaryview));
1611 gtk_paned_add2(GTK_PANED(hpaned),
1612 GTK_WIDGET_PTR(mainwin->summaryview));
1613 gtk_widget_ref(vpaned);
1615 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1616 prefs_common.summaryview_width,
1617 prefs_common.summaryview_height);
1618 gtk_paned_add2(GTK_PANED(vpaned),
1619 GTK_WIDGET_PTR(mainwin->messageview));
1620 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1621 prefs_common.mainview_width, -1);
1622 gtk_widget_set_usize(mainwin->window,
1623 prefs_common.folderview_width +
1624 prefs_common.mainview_width,
1625 prefs_common.mainwin_height);
1626 gtk_widget_show_all(vpaned);
1628 mainwin->win.sep_none.hpaned = hpaned;
1629 mainwin->win.sep_none.vpaned = vpaned;
1631 case SEPARATE_FOLDER:
1632 vpaned = gtk_vpaned_new();
1633 if (mainwin->summaryview->msg_is_toggled_on) {
1634 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1636 gtk_paned_add1(GTK_PANED(vpaned),
1637 GTK_WIDGET_PTR(mainwin->summaryview));
1639 gtk_box_pack_start(GTK_BOX(vbox_body),
1640 GTK_WIDGET_PTR(mainwin->summaryview),
1642 gtk_widget_ref(vpaned);
1644 gtk_paned_add2(GTK_PANED(vpaned),
1645 GTK_WIDGET_PTR(mainwin->messageview));
1646 gtk_widget_show_all(vpaned);
1647 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1648 prefs_common.summaryview_width,
1649 prefs_common.summaryview_height);
1650 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1651 prefs_common.mainview_width, -1);
1652 gtk_widget_set_usize(mainwin->window,
1653 prefs_common.mainview_width,
1654 prefs_common.mainview_height);
1656 gtk_container_add(GTK_CONTAINER(folderwin),
1657 GTK_WIDGET_PTR(mainwin->folderview));
1659 mainwin->win.sep_folder.folderwin = folderwin;
1660 mainwin->win.sep_folder.vpaned = vpaned;
1662 gtk_widget_show_all(folderwin);
1664 case SEPARATE_MESSAGE:
1665 hpaned = gtk_hpaned_new();
1666 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1668 gtk_paned_add1(GTK_PANED(hpaned),
1669 GTK_WIDGET_PTR(mainwin->folderview));
1670 gtk_paned_add2(GTK_PANED(hpaned),
1671 GTK_WIDGET_PTR(mainwin->summaryview));
1672 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1673 prefs_common.summaryview_width,
1674 prefs_common.summaryview_height);
1675 gtk_widget_set_usize(mainwin->window,
1676 prefs_common.folderview_width +
1677 prefs_common.mainview_width,
1678 prefs_common.mainwin_height);
1679 gtk_widget_show_all(hpaned);
1680 gtk_container_add(GTK_CONTAINER(messagewin),
1681 GTK_WIDGET_PTR(mainwin->messageview));
1683 mainwin->win.sep_message.messagewin = messagewin;
1684 mainwin->win.sep_message.hpaned = hpaned;
1686 gtk_widget_show_all(messagewin);
1689 gtk_box_pack_start(GTK_BOX(vbox_body),
1690 GTK_WIDGET_PTR(mainwin->summaryview),
1692 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1693 prefs_common.summaryview_width,
1694 prefs_common.summaryview_height);
1695 gtk_widget_set_usize(mainwin->window,
1696 prefs_common.mainview_width,
1697 prefs_common.mainwin_height);
1698 gtk_container_add(GTK_CONTAINER(folderwin),
1699 GTK_WIDGET_PTR(mainwin->folderview));
1700 gtk_container_add(GTK_CONTAINER(messagewin),
1701 GTK_WIDGET_PTR(mainwin->messageview));
1703 mainwin->win.sep_both.folderwin = folderwin;
1704 mainwin->win.sep_both.messagewin = messagewin;
1706 gtk_widget_show_all(folderwin);
1707 gtk_widget_show_all(messagewin);
1711 mainwin->type = type;
1713 debug_print(_("done.\n"));
1716 #include "pixmaps/stock_mail_receive.xpm"
1717 #include "pixmaps/stock_mail_receive_all.xpm"
1718 #include "pixmaps/stock_mail_compose.xpm"
1719 #include "pixmaps/stock_news_compose.xpm"
1720 #include "pixmaps/stock_mail_reply.xpm"
1721 #include "pixmaps/stock_mail_reply_to_all.xpm"
1722 #include "pixmaps/stock_mail_reply_to_author.xpm"
1723 #include "pixmaps/stock_mail_forward.xpm"
1724 #include "pixmaps/stock_mail_send.xpm"
1725 #include "pixmaps/stock_preferences.xpm"
1726 #include "pixmaps/stock_properties.xpm"
1727 #include "pixmaps/stock_down_arrow.xpm"
1728 #include "pixmaps/stock_close.xpm"
1729 #include "pixmaps/stock_exec.xpm"
1731 #define CREATE_TOOLBAR_ICON(xpm_d) \
1733 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1734 &container->style->white, \
1736 icon_wid = gtk_pixmap_new(icon, mask); \
1739 static void main_window_toolbar_create(MainWindow *mainwin,
1740 GtkWidget *container)
1745 GtkWidget *icon_wid;
1747 GtkWidget *getall_btn;
1748 GtkWidget *compose_mail_btn;
1749 GtkWidget *compose_news_btn;
1750 GtkWidget *reply_btn;
1751 GtkWidget *replyall_btn;
1752 GtkWidget *replysender_btn;
1754 GtkWidget *send_btn;
1756 GtkWidget *prefs_btn;
1757 GtkWidget *account_btn;
1759 GtkWidget *next_btn;
1760 GtkWidget *delete_btn;
1761 GtkWidget *exec_btn;
1763 GtkTooltips *tooltips;
1765 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1767 gtk_container_add(GTK_CONTAINER(container), toolbar);
1768 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1769 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1770 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1771 GTK_TOOLBAR_SPACE_LINE);
1773 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1774 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1776 _("Get new mail from current account"),
1778 icon_wid, toolbar_inc_cb, mainwin);
1779 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1780 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1782 _("Get new mail from all accounts"),
1788 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1790 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1791 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1793 _("Send queued message(s)"),
1799 /* insert compose mail button widget */
1801 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1802 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1804 _("Compose an email message - Right button: more options"),
1807 toolbar_compose_mail_cb,
1810 /* insert compose news button widget */
1812 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1813 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1815 _("Compose a news message - Right button: more options"),
1818 toolbar_compose_news_cb,
1821 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1825 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1826 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1828 _("Reply to the message - Right button: more options"),
1834 /* replyall button */
1836 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1837 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1839 _("Reply to all - Right button: more options"),
1842 toolbar_reply_to_all_cb,
1845 /* reply to sender button */
1847 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1848 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1850 _("Reply to sender - Right button: more options"),
1853 toolbar_reply_to_sender_cb,
1856 /* forward button */
1858 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1859 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1861 _("Forward the message - Right button: more options"),
1867 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1869 CREATE_TOOLBAR_ICON(stock_close_xpm);
1870 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1872 _("Delete the message"),
1878 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1879 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1881 _("Execute marked process"),
1887 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1888 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1890 _("Next unread message"),
1893 toolbar_next_unread_cb,
1897 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1899 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1900 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1902 _("Common preference"),
1907 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1908 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1910 _("Account setting"),
1915 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1916 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1920 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "button_press_event",
1921 GTK_SIGNAL_FUNC(toolbar_compose_popup_cb),
1924 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "button_press_event",
1925 GTK_SIGNAL_FUNC(toolbar_compose_popup_cb),
1928 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1929 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1932 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1933 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1936 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1937 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1940 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1941 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
1945 mainwin->toolbar = toolbar;
1946 mainwin->get_btn = get_btn;
1947 mainwin->getall_btn = getall_btn;
1948 mainwin->compose_mail_btn = compose_mail_btn;
1949 mainwin->compose_news_btn = compose_news_btn;
1950 mainwin->reply_btn = reply_btn;
1951 mainwin->replyall_btn = replyall_btn;
1952 mainwin->replysender_btn = replysender_btn;
1953 mainwin->fwd_btn = fwd_btn;
1954 mainwin->send_btn = send_btn;
1956 mainwin->prefs_btn = prefs_btn;
1957 mainwin->account_btn = account_btn;
1959 mainwin->next_btn = next_btn;
1960 mainwin->delete_btn = delete_btn;
1961 mainwin->exec_btn = exec_btn;
1963 gtk_widget_show_all(toolbar);
1966 /* callback functions */
1967 static void toolbar_compose_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1969 MainWindow *mainwindow = (MainWindow *) data;
1973 if (event->button == 3)
1974 gtk_menu_popup(GTK_MENU(mainwindow->compose_popup), NULL, NULL, NULL, NULL, 1, 0);
1977 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1979 MainWindow *mainwindow = (MainWindow *) data;
1983 if (event->button == 3)
1984 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL, NULL, NULL, 1, 0);
1987 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1989 MainWindow *mainwindow = (MainWindow *) data;
1993 if (event->button == 3)
1994 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL, NULL, NULL, 1, 0);
1997 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1999 MainWindow *mainwindow = (MainWindow *) data;
2000 GtkWidget *replysender_menu, *replysender_item;
2004 if (event->button == 3)
2005 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL, NULL, NULL, 1, 0);
2008 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2010 MainWindow *mainwindow = (MainWindow *) data;
2014 if (event->button == 3)
2015 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL, NULL, NULL, 1, 0);
2018 static void toolbar_inc_cb (GtkWidget *widget,
2021 MainWindow *mainwin = (MainWindow *)data;
2023 inc_mail_cb(mainwin, 0, NULL);
2026 static void toolbar_inc_all_cb (GtkWidget *widget,
2029 MainWindow *mainwin = (MainWindow *)data;
2031 inc_all_account_mail_cb(mainwin, 0, NULL);
2034 static void toolbar_send_cb (GtkWidget *widget,
2037 MainWindow *mainwin = (MainWindow *)data;
2039 send_queue_cb(mainwin, 0, NULL);
2042 static void toolbar_compose_cb (GtkWidget *widget,
2045 MainWindow *mainwin = (MainWindow *)data;
2047 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2048 compose_cb(mainwin, 0, NULL);
2050 compose_news_cb(mainwin, 0, NULL);
2053 static void toolbar_compose_news_cb (GtkWidget *widget,
2056 MainWindow *mainwin = (MainWindow *)data;
2058 compose_news_cb(mainwin, 0, NULL);
2061 static void toolbar_compose_mail_cb (GtkWidget *widget,
2064 MainWindow *mainwin = (MainWindow *)data;
2066 compose_mail_cb(mainwin, 0, NULL);
2069 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2071 MainWindow *mainwin = (MainWindow *)data;
2074 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2075 : COMPOSE_REPLY_WITHOUT_QUOTE,
2079 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2081 MainWindow *mainwin = (MainWindow *)data;
2084 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2085 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2090 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2092 MainWindow *mainwin = (MainWindow *)data;
2095 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2096 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2100 static void toolbar_forward_cb (GtkWidget *widget,
2103 MainWindow *mainwin = (MainWindow *)data;
2105 if (prefs_common.forward_as_attachment)
2106 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2108 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2111 static void toolbar_delete_cb (GtkWidget *widget,
2114 MainWindow *mainwin = (MainWindow *)data;
2116 summary_delete(mainwin->summaryview);
2119 static void toolbar_exec_cb (GtkWidget *widget,
2122 MainWindow *mainwin = (MainWindow *)data;
2124 summary_execute(mainwin->summaryview);
2127 static void toolbar_next_unread_cb (GtkWidget *widget,
2130 MainWindow *mainwin = (MainWindow *)data;
2132 next_unread_cb(mainwin, 0, NULL);
2135 static void toolbar_prefs_cb (GtkWidget *widget,
2138 prefs_common_open();
2141 static void toolbar_account_cb (GtkWidget *widget,
2144 MainWindow *mainwin = (MainWindow *)data;
2146 prefs_account_open_cb(mainwin, 0, NULL);
2149 static void toolbar_account_button_pressed(GtkWidget *widget,
2150 GdkEventButton *event,
2153 MainWindow *mainwin = (MainWindow *)data;
2156 if (event->button != 3) return;
2158 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2159 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2162 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2163 menu_button_position, widget,
2164 event->button, event->time);
2167 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2170 MainWindow *mainwin = (MainWindow *)data;
2174 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2175 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2178 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2179 menu_button_position, widget,
2180 event->button, event->time);
2183 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2185 MainWindow *mainwin = (MainWindow *)data;
2188 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2189 if (!button) return;
2190 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2191 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2192 manage_window_focus_in(mainwin->window, NULL, NULL);
2195 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2198 MainWindow *mainwin = (MainWindow *)data;
2200 if (mainwin->lock_count == 0)
2201 app_exit_cb(data, 0, widget);
2206 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2209 main_window_add_mailbox(mainwin);
2212 static void add_mbox_cb(MainWindow *mainwin, guint action,
2215 main_window_add_mbox(mainwin);
2218 static void update_folderview_cb(MainWindow *mainwin, guint action,
2221 summary_show(mainwin->summaryview, NULL, FALSE);
2222 folderview_update_all();
2225 static void new_folder_cb(MainWindow *mainwin, guint action,
2228 folderview_new_folder(mainwin->folderview);
2231 static void rename_folder_cb(MainWindow *mainwin, guint action,
2234 folderview_rename_folder(mainwin->folderview);
2237 static void delete_folder_cb(MainWindow *mainwin, guint action,
2240 folderview_delete_folder(mainwin->folderview);
2243 static void import_mbox_cb(MainWindow *mainwin, guint action,
2246 import_mbox(mainwin->summaryview->folder_item);
2249 static void export_mbox_cb(MainWindow *mainwin, guint action,
2252 export_mbox(mainwin->summaryview->folder_item);
2255 static void empty_trash_cb(MainWindow *mainwin, guint action,
2258 main_window_empty_trash(mainwin, TRUE);
2261 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2263 summary_save_as(mainwin->summaryview);
2266 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2268 summary_print(mainwin->summaryview);
2271 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2273 if (prefs_common.confirm_on_exit) {
2274 if (alertpanel(_("Exit"), _("Exit this program?"),
2275 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2277 manage_window_focus_in(mainwin->window, NULL, NULL);
2280 app_will_exit(widget, mainwin);
2283 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2286 summary_search(mainwin->summaryview);
2288 message_search(mainwin->messageview);
2291 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2294 switch (mainwin->type) {
2296 case SEPARATE_MESSAGE:
2298 case SEPARATE_FOLDER:
2299 if (GTK_CHECK_MENU_ITEM(widget)->active)
2300 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2302 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2305 if (GTK_CHECK_MENU_ITEM(widget)->active)
2306 gtk_widget_show(mainwin->win.sep_both.folderwin);
2308 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2313 static void toggle_message_cb(MainWindow *mainwin, guint action,
2316 switch (mainwin->type) {
2318 case SEPARATE_FOLDER:
2320 case SEPARATE_MESSAGE:
2321 if (GTK_CHECK_MENU_ITEM(widget)->active)
2322 gtk_widget_show(mainwin->win.sep_message.messagewin);
2324 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2327 if (GTK_CHECK_MENU_ITEM(widget)->active)
2328 gtk_widget_show(mainwin->win.sep_both.messagewin);
2330 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2335 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2338 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2339 mainwin->compose_btn_type);
2340 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2341 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2342 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2343 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2345 switch ((ToolbarStyle)action) {
2347 gtk_widget_hide(mainwin->handlebox);
2349 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2353 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2357 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2362 if (action != TOOLBAR_NONE) {
2363 gtk_widget_show(mainwin->handlebox);
2364 gtk_widget_queue_resize(mainwin->handlebox);
2367 mainwin->toolbar_style = (ToolbarStyle)action;
2368 prefs_common.toolbar_style = (ToolbarStyle)action;
2371 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2374 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2375 gtk_widget_show(mainwin->hbox_stat);
2376 prefs_common.show_statusbar = TRUE;
2378 gtk_widget_hide(mainwin->hbox_stat);
2379 prefs_common.show_statusbar = FALSE;
2383 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2386 MainWindow *mainwin;
2389 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2390 g_return_if_fail(mainwin != NULL);
2392 type = mainwin->type ^ action;
2393 main_window_separation_change(mainwin, type);
2395 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2396 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2399 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2402 addressbook_open(NULL);
2405 static void log_window_show_cb(MainWindow *mainwin, guint action,
2408 log_window_show(mainwin->logwin);
2411 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2416 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2419 inc_all_account_mail(mainwin);
2422 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2426 if (procmsg_send_queue() < 0)
2427 alertpanel_error(_("Some errors occurred while sending queued messages."));
2429 statusbar_pop_all();
2431 for (list = folder_get_list(); list != NULL; list = list->next) {
2434 folder = list->data;
2435 if (folder->queue) {
2436 folder_item_scan(folder->queue);
2437 folderview_update_item(folder->queue, TRUE);
2442 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2444 if (mainwin->summaryview->folder_item) {
2445 if (mainwin->summaryview->folder_item->folder->account != NULL
2446 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2447 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2449 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2455 static void compose_mail_cb(MainWindow *mainwin, guint action,
2462 if (mainwin->summaryview->folder_item) {
2463 ac = mainwin->summaryview->folder_item->folder->account;
2464 if (ac && ac->protocol != A_NNTP) {
2465 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2470 if(cur_account && (cur_account->protocol != A_NNTP)) {
2471 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2475 list = account_get_list();
2476 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2477 ac = (PrefsAccount *) cur->data;
2478 if (ac->protocol != A_NNTP) {
2479 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2485 static void compose_news_cb(MainWindow *mainwin, guint action,
2488 PrefsAccount * ac = NULL;
2492 if (mainwin->summaryview->folder_item) {
2493 ac = mainwin->summaryview->folder_item->folder->account;
2494 if (ac && ac->protocol == A_NNTP) {
2495 compose_new_with_recipient
2496 (ac, mainwin->summaryview->folder_item->path);
2501 list = account_get_list();
2502 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2503 ac = (PrefsAccount *) cur->data;
2504 if (ac->protocol == A_NNTP) {
2511 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2513 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2516 msginfo = gtk_ctree_node_get_row_data
2517 (GTK_CTREE(mainwin->summaryview->ctree),
2518 mainwin->summaryview->selected);
2520 if (!msginfo) return;
2524 compose_reply(msginfo, prefs_common.reply_with_quote,
2527 case COMPOSE_REPLY_WITH_QUOTE:
2528 compose_reply(msginfo, TRUE, FALSE, FALSE);
2530 case COMPOSE_REPLY_WITHOUT_QUOTE:
2531 compose_reply(msginfo, FALSE, FALSE, FALSE);
2533 case COMPOSE_REPLY_TO_SENDER:
2534 compose_reply(msginfo, prefs_common.reply_with_quote,
2537 case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
2538 compose_reply(msginfo, TRUE, FALSE, TRUE);
2540 case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
2541 compose_reply(msginfo, FALSE, FALSE, TRUE);
2543 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2544 compose_followup_and_reply_to(msginfo,
2545 prefs_common.reply_with_quote,
2548 case COMPOSE_REPLY_TO_ALL:
2549 compose_reply(msginfo, prefs_common.reply_with_quote,
2552 case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
2553 compose_reply(msginfo, TRUE, TRUE, TRUE);
2555 case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
2556 compose_reply(msginfo, FALSE, TRUE, TRUE);
2558 case COMPOSE_FORWARD:
2559 if (prefs_common.forward_as_attachment) {
2560 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, widget);
2563 reply_cb(mainwin, COMPOSE_FORWARD_INLINE, widget);
2567 case COMPOSE_FORWARD_INLINE:
2569 compose_forward(NULL, msginfo, FALSE);
2572 /* if (sel->next) FALL_THROUGH */
2573 case COMPOSE_FORWARD_AS_ATTACH:
2575 GSList *msginfo_list = NULL;
2576 for ( ; sel != NULL; sel = sel->next)
2577 msginfo_list = g_slist_append(msginfo_list,
2578 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2579 GTK_CTREE_NODE(sel->data)));
2580 compose_forward_multiple(NULL, msginfo_list);
2581 g_slist_free(msginfo_list);
2584 case COMPOSE_BOUNCE:
2585 compose_bounce(NULL, msginfo);
2588 g_warning("reply_cb(): invalid action type: %d\n", action);
2591 summary_set_marks_selected(mainwin->summaryview);
2594 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2596 summary_move_to(mainwin->summaryview);
2599 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2601 summary_copy_to(mainwin->summaryview);
2604 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2606 summary_delete(mainwin->summaryview);
2609 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2611 summary_open_msg(mainwin->summaryview);
2614 static void view_source_cb(MainWindow *mainwin, guint action,
2617 summary_view_source(mainwin->summaryview);
2620 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2622 summary_reedit(mainwin->summaryview);
2625 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2627 summary_mark(mainwin->summaryview);
2630 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2632 summary_unmark(mainwin->summaryview);
2635 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2638 summary_mark_as_unread(mainwin->summaryview);
2641 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2644 summary_mark_as_read(mainwin->summaryview);
2647 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2650 summary_mark_all_read(mainwin->summaryview);
2653 static void add_address_cb(MainWindow *mainwin, guint action,
2656 summary_add_address(mainwin->summaryview);
2659 static void set_charset_cb(MainWindow *mainwin, guint action,
2664 str = conv_get_charset_str((CharSet)action);
2665 g_free(prefs_common.force_charset);
2666 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2668 summary_redisplay_msg(mainwin->summaryview);
2670 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2673 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2675 GtkItemFactory *ifactory;
2677 if (!mainwin->summaryview->folder_item) return;
2679 ifactory = gtk_item_factory_from_widget(widget);
2682 summary_thread_build(mainwin->summaryview);
2683 mainwin->summaryview->folder_item->threaded = TRUE;
2684 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2685 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2687 summary_unthread(mainwin->summaryview);
2688 mainwin->summaryview->folder_item->threaded = FALSE;
2689 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2690 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2694 static void set_display_item_cb(MainWindow *mainwin, guint action,
2697 prefs_summary_column_open();
2700 static void sort_summary_cb(MainWindow *mainwin, guint action,
2703 summary_sort(mainwin->summaryview, (SummarySortType)action);
2706 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2709 summary_attract_by_subject(mainwin->summaryview);
2712 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2715 summary_delete_duplicated(mainwin->summaryview);
2718 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2720 summary_filter(mainwin->summaryview);
2723 static void execute_summary_cb(MainWindow *mainwin, guint action,
2726 summary_execute(mainwin->summaryview);
2729 static void update_summary_cb(MainWindow *mainwin, guint action,
2733 FolderView *folderview = mainwin->folderview;
2735 if (!mainwin->summaryview->folder_item) return;
2736 if (!folderview->opened) return;
2738 folder_update_op_count();
2740 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2741 folderview->opened);
2744 summary_show(mainwin->summaryview, fitem, TRUE);
2747 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2749 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2752 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2754 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2757 static void prev_unread_cb(MainWindow *mainwin, guint action,
2760 summary_select_prev_unread(mainwin->summaryview);
2763 static void next_unread_cb(MainWindow *mainwin, guint action,
2766 summary_select_next_unread(mainwin->summaryview);
2769 static void prev_marked_cb(MainWindow *mainwin, guint action,
2772 summary_select_prev_marked(mainwin->summaryview);
2775 static void next_marked_cb(MainWindow *mainwin, guint action,
2778 summary_select_next_marked(mainwin->summaryview);
2781 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2784 summary_select_prev_labeled(mainwin->summaryview);
2787 static void next_labeled_cb(MainWindow *mainwin, guint action,
2790 summary_select_next_labeled(mainwin->summaryview);
2793 static void goto_folder_cb(MainWindow *mainwin, guint action,
2796 FolderItem *to_folder;
2798 to_folder = foldersel_folder_sel(NULL, NULL);
2801 folderview_select(mainwin->folderview, to_folder);
2804 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2806 messageview_copy_clipboard(mainwin->messageview);
2809 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2811 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2812 summary_select_all(mainwin->summaryview);
2813 else if (mainwin->summaryview->msg_is_toggled_on &&
2814 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2815 messageview_select_all(mainwin->messageview);
2818 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2821 prefs_common_open();
2824 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2827 prefs_filter_open();
2830 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2833 prefs_scoring_open(NULL);
2836 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2839 prefs_filtering_open(NULL);
2842 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2845 prefs_template_open();
2848 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2852 new_account_cb(mainwin, 0, widget);
2854 gboolean prev_default = cur_account->is_default;
2856 prefs_account_open(cur_account);
2857 if (!prev_default && cur_account->is_default)
2858 account_set_as_default(cur_account);
2859 account_save_config_all();
2861 main_window_reflect_prefs_all();
2865 static void new_account_cb(MainWindow *mainwin, guint action,
2868 account_edit_open();
2869 if (!compose_get_compose_list()) account_add();
2872 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2874 cur_account = (PrefsAccount *)data;
2875 main_window_reflect_prefs_all();
2878 static void manual_open_cb(MainWindow *mainwin, guint action,
2881 manual_open((ManualLang)action);
2884 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2886 MainWindow *mainwin = (MainWindow *)data;
2890 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2891 LOCAL_FOLDER(folder)->rootpath,
2895 str = g_strdup_printf(_("Scanning folder %s ..."),
2896 LOCAL_FOLDER(folder)->rootpath);
2898 STATUSBAR_PUSH(mainwin, str);
2899 STATUSBAR_POP(mainwin);
2903 static void activate_compose_button (MainWindow *mainwin,
2905 ComposeButtonType type)
2907 SensitiveCond state = main_window_get_current_state(mainwin);
2909 if (style == TOOLBAR_NONE)
2912 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2913 : mainwin->compose_news_btn);
2914 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2915 : mainwin->compose_mail_btn);
2916 mainwin->compose_btn_type = type;
2919 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2921 if (mainwin->compose_btn_type != compose_btn_type)
2922 activate_compose_button(mainwin,
2923 prefs_common.toolbar_style,