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 <gtk/gtkmain.h>
24 #include <gtk/gtkwindow.h>
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtksignal.h>
27 #include <gtk/gtkvbox.h>
28 #include <gtk/gtkcontainer.h>
29 #include <gtk/gtkstatusbar.h>
30 #include <gtk/gtkhpaned.h>
31 #include <gtk/gtkvpaned.h>
32 #include <gtk/gtkcheckmenuitem.h>
33 #include <gtk/gtkitemfactory.h>
34 #include <gtk/gtkeditable.h>
35 #include <gtk/gtkmenu.h>
36 #include <gtk/gtkmenuitem.h>
37 #include <gtk/gtkhandlebox.h>
38 #include <gtk/gtktoolbar.h>
39 #include <gtk/gtkbutton.h>
44 #include "mainwindow.h"
45 #include "folderview.h"
46 #include "foldersel.h"
47 #include "summaryview.h"
48 #include "summary_search.h"
49 #include "messageview.h"
50 #include "headerview.h"
58 #include "prefs_common.h"
59 #include "prefs_filter.h"
60 #include "prefs_scoring.h"
61 #include "prefs_account.h"
62 #include "prefs_folder_item.h"
64 #include "addressbook.h"
65 #include "headerwindow.h"
66 #include "logwindow.h"
67 #include "manage_window.h"
68 #include "alertpanel.h"
69 #include "statusbar.h"
70 #include "inputdialog.h"
77 #define AC_LABEL_WIDTH 240
79 #define STATUSBAR_PUSH(mainwin, str) \
81 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
82 mainwin->mainwin_cid, str); \
83 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
86 #define STATUSBAR_POP(mainwin) \
88 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
89 mainwin->mainwin_cid); \
92 /* list of all instantiated MainWindow */
93 static GList *mainwin_list = NULL;
95 static GdkCursor *watch_cursor;
97 static void main_window_show_cur_account (MainWindow *mainwin);
99 static void main_window_set_widgets (MainWindow *mainwin,
101 static void main_window_toolbar_create (MainWindow *mainwin,
102 GtkWidget *container);
104 /* callback functions */
105 static void toolbar_inc_cb (GtkWidget *widget,
107 static void toolbar_inc_all_cb (GtkWidget *widget,
109 static void toolbar_send_cb (GtkWidget *widget,
112 static void toolbar_compose_cb (GtkWidget *widget,
114 static void toolbar_reply_cb (GtkWidget *widget,
116 static void toolbar_reply_to_all_cb (GtkWidget *widget,
118 static void toolbar_reply_to_author_cb (GtkWidget *widget,
120 static void toolbar_forward_cb (GtkWidget *widget,
123 static void toolbar_delete_cb (GtkWidget *widget,
125 static void toolbar_exec_cb (GtkWidget *widget,
128 static void toolbar_next_unread_cb (GtkWidget *widget,
131 static void toolbar_prefs_cb (GtkWidget *widget,
133 static void toolbar_account_cb (GtkWidget *widget,
136 static void toolbar_account_button_pressed (GtkWidget *widget,
137 GdkEventButton *event,
139 static void ac_label_button_pressed (GtkWidget *widget,
140 GdkEventButton *event,
143 static gint main_window_close_cb (GtkWidget *widget,
147 static void add_mailbox_cb (MainWindow *mainwin,
150 static void add_mbox_cb (MainWindow *mainwin,
153 static void update_folderview_cb (MainWindow *mainwin,
156 static void new_folder_cb (MainWindow *mainwin,
159 static void rename_folder_cb (MainWindow *mainwin,
162 static void delete_folder_cb (MainWindow *mainwin,
165 static void import_mbox_cb (MainWindow *mainwin,
168 static void export_mbox_cb (MainWindow *mainwin,
171 static void empty_trash_cb (MainWindow *mainwin,
175 static void save_as_cb (MainWindow *mainwin,
178 static void print_cb (MainWindow *mainwin,
181 static void app_exit_cb (MainWindow *mainwin,
185 static void toggle_folder_cb (MainWindow *mainwin,
188 static void toggle_message_cb (MainWindow *mainwin,
191 static void toggle_toolbar_cb (MainWindow *mainwin,
194 static void toggle_statusbar_cb (MainWindow *mainwin,
197 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action);
199 static void addressbook_open_cb (MainWindow *mainwin,
202 static void log_window_show_cb (MainWindow *mainwin,
206 static void inc_mail_cb (MainWindow *mainwin,
209 static void inc_all_account_mail_cb (MainWindow *mainwin,
213 static void send_queue_cb (MainWindow *mainwin,
217 static void compose_cb (MainWindow *mainwin,
220 static void reply_cb (MainWindow *mainwin,
224 static void open_msg_cb (MainWindow *mainwin,
228 static void view_source_cb (MainWindow *mainwin,
232 static void reedit_cb (MainWindow *mainwin,
236 static void move_to_cb (MainWindow *mainwin,
239 static void copy_to_cb (MainWindow *mainwin,
242 static void delete_cb (MainWindow *mainwin,
246 static void mark_cb (MainWindow *mainwin,
249 static void unmark_cb (MainWindow *mainwin,
253 static void mark_as_unread_cb (MainWindow *mainwin,
256 static void mark_as_read_cb (MainWindow *mainwin,
260 static void set_charset_cb (MainWindow *mainwin,
264 static void thread_cb (MainWindow *mainwin,
267 static void set_display_item_cb (MainWindow *mainwin,
270 static void sort_summary_cb (MainWindow *mainwin,
273 static void attract_by_subject_cb(MainWindow *mainwin,
277 static void delete_duplicated_cb (MainWindow *mainwin,
280 static void filter_cb (MainWindow *mainwin,
283 static void execute_summary_cb (MainWindow *mainwin,
286 static void update_summary_cb (MainWindow *mainwin,
290 static void prev_cb (MainWindow *mainwin,
293 static void next_cb (MainWindow *mainwin,
297 static void next_unread_cb (MainWindow *mainwin,
301 static void next_marked_cb (MainWindow *mainwin,
305 static void prev_marked_cb (MainWindow *mainwin,
309 static void goto_folder_cb (MainWindow *mainwin,
313 static void copy_cb (MainWindow *mainwin,
316 static void allsel_cb (MainWindow *mainwin,
320 static void prefs_common_open_cb (MainWindow *mainwin,
323 static void prefs_filter_open_cb (MainWindow *mainwin,
326 static void prefs_scoring_open_cb (MainWindow *mainwin,
329 static void prefs_filtering_open_cb (MainWindow *mainwin,
332 static void prefs_account_open_cb(MainWindow *mainwin,
335 static void new_account_cb (MainWindow *mainwin,
339 static void account_menu_cb (GtkMenuItem *menuitem,
342 static void manual_open_cb (MainWindow *mainwin,
346 static void scan_tree_func (Folder *folder,
350 #define SEPARATE_ACTION 667
352 static GtkItemFactoryEntry mainwin_entries[] =
354 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
355 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
356 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
357 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
358 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
359 {N_("/_File/_Folder/Create _new folder..."),
360 NULL, new_folder_cb, 0, NULL},
361 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
362 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
363 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
364 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
365 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
366 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
367 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
368 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
369 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
370 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
371 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
373 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
374 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
375 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
376 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
377 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
379 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
380 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
381 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
382 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
383 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
384 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
385 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
386 {N_("/_View/_Toolbar/_Non-display"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
387 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
388 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
389 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
390 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
391 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
392 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
393 {N_("/_View/_Code set/_Auto detect"),
394 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
396 #define CODESET_SEPARATOR \
397 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
398 #define CODESET_ACTION(action) \
399 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
401 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
402 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
403 CODESET_ACTION(C_US_ASCII)},
406 {N_("/_View/_Code set/Unicode (_UTF-8)"),
407 CODESET_ACTION(C_UTF_8)},
410 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
411 CODESET_ACTION(C_ISO_8859_1)},
414 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
415 CODESET_ACTION(C_ISO_8859_2)},
417 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
418 CODESET_ACTION(C_ISO_8859_13)},
419 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
420 CODESET_ACTION(C_ISO_8859_4)},
422 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
423 CODESET_ACTION(C_ISO_8859_7)},
425 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
426 CODESET_ACTION(C_ISO_8859_9)},
428 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
429 CODESET_ACTION(C_ISO_8859_5)},
430 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
431 CODESET_ACTION(C_KOI8_R)},
432 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
433 CODESET_ACTION(C_CP1251)},
436 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
437 CODESET_ACTION(C_ISO_2022_JP)},
439 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
440 CODESET_ACTION(C_ISO_2022_JP_2)},
442 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
443 CODESET_ACTION(C_EUC_JP)},
444 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
445 CODESET_ACTION(C_SHIFT_JIS)},
448 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
449 CODESET_ACTION(C_GB2312)},
450 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
451 CODESET_ACTION(C_BIG5)},
452 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
453 CODESET_ACTION(C_EUC_TW)},
454 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
455 CODESET_ACTION(C_ISO_2022_CN)},
457 {N_("/_View/_Code set/Korean (EUC-_KR)"),
458 CODESET_ACTION(C_EUC_KR)},
459 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
460 CODESET_ACTION(C_ISO_2022_KR)},
463 #undef CODESET_SEPARATOR
464 #undef CODESET_ACTION
466 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
467 {N_("/_Message/Rece_ive new mail"), "<alt>I", inc_mail_cb, 0, NULL},
468 {N_("/_Message/Receive from _all accounts"),
469 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
470 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
471 {N_("/_Message/Send queued messa_ges"),
472 NULL, send_queue_cb, 0, NULL},
473 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
474 {N_("/_Message/Compose _new message"), "<alt>N", compose_cb, 0, NULL},
475 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
476 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
477 {N_("/_Message/Reply to author"), NULL, reply_cb, COMPOSE_REPLY_TO_AUTHOR, NULL},
478 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
479 {N_("/_Message/Forward as an a_ttachment"),
480 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
481 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
482 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
483 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
484 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
485 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
486 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
487 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
488 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
489 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
490 {N_("/_Message/_Mark/Mark it as _being read"),
491 NULL, mark_as_read_cb, 0, NULL},
492 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
493 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
494 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
495 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
496 {N_("/_Message/Re_edit"), NULL, reedit_cb, 0, NULL},
498 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
499 {N_("/_Summary/_Delete duplicated messages"),
500 NULL, delete_duplicated_cb, 0, NULL},
501 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
502 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
503 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
504 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
505 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
506 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
507 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
508 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
509 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
510 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
512 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
514 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
515 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
516 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
517 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
518 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
519 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
520 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_Summary/_Sort/_Attract by subject"),
522 NULL, attract_by_subject_cb, 0, NULL},
523 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
524 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
525 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
527 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
528 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
529 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
531 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
532 {N_("/_Configuration/_Common preferences..."),
533 NULL, prefs_common_open_cb, 0, NULL},
534 {N_("/_Configuration/_Filter setting..."),
535 NULL, prefs_filter_open_cb, 0, NULL},
536 {N_("/_Configuration/_Scoring ..."),
537 NULL, prefs_scoring_open_cb, 0, NULL},
538 {N_("/_Configuration/_Filtering ..."),
539 NULL, prefs_filtering_open_cb, 0, NULL},
540 {N_("/_Configuration/_Preferences per account..."),
541 NULL, prefs_account_open_cb, 0, NULL},
542 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
543 {N_("/_Configuration/Create _new account..."),
544 NULL, new_account_cb, 0, NULL},
545 {N_("/_Configuration/_Edit accounts..."),
546 NULL, account_edit_open, 0, NULL},
547 {N_("/_Configuration/C_hange current account"),
548 NULL, NULL, 0, "<Branch>"},
550 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
551 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
552 {N_("/_Help/_Manual/_English"), NULL, NULL, MANUAL_LANG_EN, NULL},
553 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
554 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
555 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
558 MainWindow *main_window_create(SeparateType type)
564 GtkWidget *handlebox;
565 GtkWidget *vbox_body;
566 GtkWidget *hbox_stat;
567 GtkWidget *statusbar;
568 GtkWidget *ac_button;
571 FolderView *folderview;
572 SummaryView *summaryview;
573 MessageView *messageview;
574 GdkColormap *colormap;
577 guint n_menu_entries;
578 GtkItemFactory *ifactory;
583 debug_print(_("Creating main window...\n"));
584 mainwin = g_new0(MainWindow, 1);
587 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
588 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
589 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
590 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
591 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
592 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
593 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
594 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
595 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
596 gtk_widget_realize(window);
598 vbox = gtk_vbox_new(FALSE, 0);
599 gtk_widget_show(vbox);
600 gtk_container_add(GTK_CONTAINER(window), vbox);
603 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
604 menubar = menubar_create(window, mainwin_entries,
605 n_menu_entries, "<Main>", mainwin);
607 gtk_widget_show(menubar);
608 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
610 handlebox = gtk_handle_box_new();
611 gtk_widget_show(handlebox);
612 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
614 main_window_toolbar_create(mainwin, handlebox);
616 /* vbox that contains body */
617 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
618 gtk_widget_show(vbox_body);
619 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
620 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
622 hbox_stat = gtk_hbox_new(FALSE, 2);
623 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
625 statusbar = statusbar_create();
626 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
628 ac_button = gtk_button_new();
629 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
630 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
631 gtk_widget_set_usize(ac_button, -1, 1);
632 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
633 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
634 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
636 ac_label = gtk_label_new("");
637 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
639 gtk_widget_show_all(hbox_stat);
642 mainwin->folderview = folderview = folderview_create();
643 mainwin->summaryview = summaryview = summary_create();
644 mainwin->messageview = messageview = messageview_create();
645 mainwin->headerwin = header_window_create();
646 mainwin->logwin = log_window_create();
648 folderview->mainwin = mainwin;
649 folderview->summaryview = summaryview;
651 summaryview->mainwin = mainwin;
652 summaryview->folderview = folderview;
653 summaryview->messageview = messageview;
654 summaryview->headerwin = mainwin->headerwin;
655 summaryview->window = window;
657 messageview->mainwin = mainwin;
659 mainwin->window = window;
660 mainwin->vbox = vbox;
661 mainwin->menubar = menubar;
662 mainwin->handlebox = handlebox;
663 mainwin->vbox_body = vbox_body;
664 mainwin->hbox_stat = hbox_stat;
665 mainwin->statusbar = statusbar;
666 mainwin->ac_button = ac_button;
667 mainwin->ac_label = ac_label;
669 /* set context IDs for status bar */
670 mainwin->mainwin_cid = gtk_statusbar_get_context_id
671 (GTK_STATUSBAR(statusbar), "Main Window");
672 mainwin->folderview_cid = gtk_statusbar_get_context_id
673 (GTK_STATUSBAR(statusbar), "Folder View");
674 mainwin->summaryview_cid = gtk_statusbar_get_context_id
675 (GTK_STATUSBAR(statusbar), "Summary View");
677 /* allocate colors for summary view and folder view */
678 summaryview->color_marked.red = summaryview->color_marked.green = 0;
679 summaryview->color_marked.blue = (guint16)65535;
681 summaryview->color_dim.red = summaryview->color_dim.green =
682 summaryview->color_dim.blue = COLOR_DIM;
684 summaryview->color_normal.red = summaryview->color_normal.green =
685 summaryview->color_normal.blue = 0;
687 folderview->color_new.red = (guint16)55000;
688 folderview->color_new.green = folderview->color_new.blue = 15000;
690 folderview->color_normal.red = folderview->color_normal.green =
691 folderview->color_normal.blue = 0;
693 color[0] = summaryview->color_marked;
694 color[1] = summaryview->color_dim;
695 color[2] = summaryview->color_normal;
696 color[3] = folderview->color_new;
697 color[4] = folderview->color_normal;
699 colormap = gdk_window_get_colormap(window->window);
700 gdk_colormap_alloc_colors(colormap, color, 5, FALSE, TRUE, success);
701 for (i = 0; i < 5; i++) {
702 if (success[i] == FALSE)
703 g_warning(_("MainWindow: color allocation %d failed\n"), i);
706 debug_print(_("done.\n"));
708 main_window_set_widgets(mainwin, type);
711 ifactory = gtk_item_factory_from_widget(menubar);
712 menuitem = gtk_item_factory_get_item
713 (ifactory, "/View/Code set/Auto detect");
714 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
716 switch (prefs_common.toolbar_style) {
718 menuitem = gtk_item_factory_get_item
719 (ifactory, "/View/Toolbar/Non-display");
722 menuitem = gtk_item_factory_get_item
723 (ifactory, "/View/Toolbar/Icon");
726 menuitem = gtk_item_factory_get_item
727 (ifactory, "/View/Toolbar/Text");
730 menuitem = gtk_item_factory_get_item
731 (ifactory, "/View/Toolbar/Icon and text");
733 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
735 gtk_widget_hide(mainwin->hbox_stat);
736 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
737 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
738 prefs_common.show_statusbar);
740 /* set the check of the SEPARATE_xxx menu items. we also need the main window
741 * as a property and pass the action type to the callback */
742 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
744 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
745 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
746 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
747 GUINT_TO_POINTER(SEPARATE_FOLDER));
749 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
751 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
752 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
753 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
754 GUINT_TO_POINTER(SEPARATE_MESSAGE));
756 menu_set_sensitive(ifactory, "/Summary/Thread view",
757 prefs_common.enable_thread ? FALSE : TRUE);
758 menu_set_sensitive(ifactory, "/Summary/Unthread view",
759 prefs_common.enable_thread ? TRUE : FALSE);
760 menu_set_sensitive(ifactory, "/Help/Manual/English", FALSE);
762 /* set account selection menu */
763 ac_menu = gtk_item_factory_get_widget
764 (ifactory, "/Configuration/Change current account");
765 mainwin->ac_menu = ac_menu;
767 main_window_set_toolbar_sensitive(mainwin, FALSE);
769 /* show main window */
770 gtk_widget_set_uposition(mainwin->window,
771 prefs_common.mainwin_x,
772 prefs_common.mainwin_y);
773 gtk_widget_set_usize(window, prefs_common.mainwin_width,
774 prefs_common.mainwin_height);
775 gtk_widget_show(mainwin->window);
777 /* initialize views */
778 folderview_init(folderview);
779 summary_init(summaryview);
780 messageview_init(messageview);
781 header_window_init(mainwin->headerwin);
782 log_window_init(mainwin->logwin);
784 mainwin->cursor_count = 0;
787 watch_cursor = gdk_cursor_new(GDK_WATCH);
789 mainwin_list = g_list_append(mainwin_list, mainwin);
794 void main_window_cursor_wait(MainWindow *mainwin)
796 if (mainwin->cursor_count == 0)
797 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
799 mainwin->cursor_count++;
804 void main_window_cursor_normal(MainWindow *mainwin)
806 if (mainwin->cursor_count)
807 mainwin->cursor_count--;
809 if (mainwin->cursor_count == 0)
810 gdk_window_set_cursor(mainwin->window->window, NULL);
815 void main_window_reflect_prefs_all(void)
820 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
821 mainwin = (MainWindow *)cur->data;
823 main_window_show_cur_account(mainwin);
825 gtk_widget_set_sensitive(mainwin->get_btn, TRUE);
826 gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
828 gtk_widget_set_sensitive(mainwin->get_btn, FALSE);
829 gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
831 if (prefs_common.immediate_exec)
832 gtk_widget_hide(mainwin->exec_btn);
834 gtk_widget_show(mainwin->exec_btn);
836 summary_change_display_item(mainwin->summaryview);
837 summary_redisplay_msg(mainwin->summaryview);
838 headerview_set_visibility(mainwin->messageview->headerview,
839 prefs_common.display_header_pane);
843 void main_window_set_account_menu(GList *account_list)
845 GList *cur, *cur_ac, *cur_item;
848 PrefsAccount *ac_prefs;
850 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
851 mainwin = (MainWindow *)cur->data;
853 /* destroy all previous menu item */
854 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
855 while (cur_item != NULL) {
856 GList *next = cur_item->next;
857 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
861 for (cur_ac = account_list; cur_ac != NULL;
862 cur_ac = cur_ac->next) {
863 ac_prefs = (PrefsAccount *)cur_ac->data;
865 menuitem = gtk_menu_item_new_with_label
866 (ac_prefs->account_name
867 ? ac_prefs->account_name : _("Untitled"));
868 gtk_widget_show(menuitem);
869 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
870 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
871 GTK_SIGNAL_FUNC(account_menu_cb),
877 static void main_window_show_cur_account(MainWindow *mainwin)
882 ac_name = g_strdup(cur_account
883 ? (cur_account->account_name
884 ? cur_account->account_name : _("Untitled"))
888 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
890 buf = g_strdup(PROG_VERSION);
891 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
894 buf = g_strdup_printf(_("Current account: %s"), ac_name);
895 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
896 gtk_widget_queue_resize(mainwin->ac_button);
902 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
904 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
905 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
906 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
908 if (mainwin->type == type) return;
910 /* remove widgets from those containers */
911 gtk_widget_ref(folder_wid);
912 gtk_widget_ref(summary_wid);
913 gtk_widget_ref(message_wid);
915 (GTK_CONTAINER(folder_wid->parent), folder_wid);
917 (GTK_CONTAINER(summary_wid->parent), summary_wid);
919 (GTK_CONTAINER(message_wid->parent), message_wid);
921 /* clean containers */
922 switch (mainwin->type) {
924 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
926 case SEPARATE_FOLDER:
927 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
928 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
930 case SEPARATE_MESSAGE:
931 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
932 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
935 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
936 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
940 gtk_widget_hide(mainwin->window);
941 main_window_set_widgets(mainwin, type);
942 gtk_widget_show(mainwin->window);
944 gtk_widget_unref(folder_wid);
945 gtk_widget_unref(summary_wid);
946 gtk_widget_unref(message_wid);
949 void main_window_get_size(MainWindow *mainwin)
951 GtkAllocation *allocation;
953 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
955 prefs_common.summaryview_width = allocation->width;
957 if (mainwin->summaryview->msg_is_toggled_on)
958 prefs_common.summaryview_height = allocation->height;
960 prefs_common.mainview_width = allocation->width;
962 allocation = &mainwin->window->allocation;
964 prefs_common.mainview_height = allocation->height;
965 prefs_common.mainwin_width = allocation->width;
966 prefs_common.mainwin_height = allocation->height;
968 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
970 prefs_common.folderview_width = allocation->width;
971 prefs_common.folderview_height = allocation->height;
974 void main_window_get_position(MainWindow *mainwin)
978 gtkut_widget_get_uposition(mainwin->window, &x, &y);
980 prefs_common.mainview_x = x;
981 prefs_common.mainview_y = y;
982 prefs_common.mainwin_x = x;
983 prefs_common.mainwin_y = y;
985 debug_print(_("window position: x = %d, y = %d\n"), x, y);
988 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
993 if (alertpanel(_("Empty trash"),
994 _("Empty all messages in trash?"),
995 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
997 manage_window_focus_in(mainwin->window, NULL, NULL);
1000 procmsg_empty_trash();
1002 for (list = folder_get_list(); list != NULL; list = list->next) {
1005 folder = list->data;
1006 if (folder->trash) {
1007 folder_item_scan(folder->trash);
1008 folderview_update_item(folder->trash, TRUE);
1012 if (mainwin->summaryview->folder_item &&
1013 mainwin->summaryview->folder_item->stype == F_TRASH)
1014 gtk_widget_grab_focus(mainwin->folderview->ctree);
1017 void main_window_add_mailbox(MainWindow *mainwin)
1022 path = input_dialog(_("Add mailbox"),
1023 _("Input the location of mailbox.\n"
1024 "If the existing mailbox is specified, it will be\n"
1025 "scanned automatically."),
1028 if (folder_find_from_path(path)) {
1029 alertpanel_error(_("The mailbox `%s' already exists."), path);
1033 if (!strcmp(path, "Mail"))
1034 folder = folder_new(F_MH, _("Mailbox"), path);
1036 folder = folder_new(F_MH, g_basename(path), path);
1039 if (folder->create_tree(folder) < 0) {
1040 alertpanel_error(_("Creation of the mailbox failed.\n"
1041 "Maybe some files already exist, or you don't have the permission to write there."));
1042 folder_destroy(folder);
1047 folder_set_ui_func(folder, scan_tree_func, mainwin);
1048 folder->scan_tree(folder);
1049 folder_set_ui_func(folder, NULL, NULL);
1051 folderview_set(mainwin->folderview);
1054 void main_window_add_mbox(MainWindow *mainwin)
1060 path = input_dialog(_("Add mbox mailbox"),
1061 _("Input the location of mailbox."),
1067 if (folder_find_from_path(path)) {
1068 alertpanel_error(_("The mailbox `%s' already exists."), path);
1075 if (!strcmp(path, "Mail"))
1076 folder = folder_new(F_MBOX, _("Mailbox"), path);
1080 folder = folder_new(F_MBOX, g_basename(path), path);
1083 if (folder->create_tree(folder) < 0) {
1084 alertpanel_error(_("Creation of the mailbox failed."));
1085 folder_destroy(folder);
1091 item = folder_item_new(folder->name, NULL);
1092 item->folder = folder;
1093 folder->node = g_node_new(item);
1095 mbox_create_folder(folder, item, "inbox");
1096 mbox_create_folder(folder, item, "outbox");
1097 mbox_create_folder(folder, item, "queue");
1098 mbox_create_folder(folder, item, "draft");
1099 mbox_create_folder(folder, item, "trash");
1101 folderview_set(mainwin->folderview);
1104 void main_window_set_toolbar_sensitive(MainWindow *mainwin, gboolean sensitive)
1106 gtk_widget_set_sensitive(mainwin->reply_btn, sensitive);
1107 gtk_widget_set_sensitive(mainwin->replyall_btn, sensitive);
1108 gtk_widget_set_sensitive(mainwin->replyauthor_btn, sensitive);
1109 gtk_widget_set_sensitive(mainwin->fwd_btn, sensitive);
1110 gtk_widget_set_sensitive(mainwin->exec_btn, sensitive);
1111 gtk_widget_set_sensitive(mainwin->next_btn, sensitive);
1113 if (!mainwin->summaryview->folder_item ||
1114 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1115 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1117 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1120 void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
1122 GtkItemFactory *ifactory;
1126 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1128 if (selection == SUMMARY_SELECTED_SINGLE)
1132 if (!mainwin->summaryview->folder_item ||
1133 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1138 menu_set_sensitive(ifactory, "/File/Save as...", sens);
1139 menu_set_sensitive(ifactory, "/Message/Reply", sens);
1140 menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
1141 menu_set_sensitive(ifactory, "/Message/Reply to author", sens);
1142 menu_set_sensitive(ifactory, "/Message/Forward", sens);
1143 menu_set_sensitive(ifactory, "/Message/Forward as an attachment", sens);
1144 menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
1145 menu_set_sensitive(ifactory, "/Message/Show all header", sens);
1146 menu_set_sensitive(ifactory, "/Message/View source", sens);
1147 if (sens && (!mainwin->summaryview->folder_item ||
1148 mainwin->summaryview->folder_item->stype != F_DRAFT))
1150 menu_set_sensitive(ifactory, "/Message/Reedit", sens);
1152 if (selection == SUMMARY_SELECTED_SINGLE ||
1153 selection == SUMMARY_SELECTED_MULTIPLE)
1158 menu_set_sensitive(ifactory, "/File/Print..." , sens);
1159 menu_set_sensitive(ifactory, "/Message/Move...", sens && exec);
1160 menu_set_sensitive(ifactory, "/Message/Copy...", sens && exec);
1161 menu_set_sensitive(ifactory, "/Message/Delete" , sens && exec);
1162 menu_set_sensitive(ifactory, "/Message/Mark" , sens);
1164 if (selection != SUMMARY_NONE)
1169 menu_set_sensitive(ifactory, "/Summary/Delete duplicated messages", sens && exec);
1170 menu_set_sensitive(ifactory, "/Summary/Filter messages", sens && exec);
1171 menu_set_sensitive(ifactory, "/Summary/Execute", sens);
1172 menu_set_sensitive(ifactory, "/Summary/Prev message", sens);
1173 menu_set_sensitive(ifactory, "/Summary/Next message", sens);
1174 menu_set_sensitive(ifactory, "/Summary/Next unread message", sens);
1175 menu_set_sensitive(ifactory, "/Summary/Sort", sens);
1178 void main_window_popup(MainWindow *mainwin)
1184 gdk_window_get_origin(mainwin->window->window, &x, &y);
1185 sx = gdk_screen_width();
1186 sy = gdk_screen_height();
1187 x %= sx; if (x < 0) x += sx;
1188 y %= sy; if (y < 0) y += sy;
1189 gdk_window_move(mainwin->window->window, x, y);
1190 gdk_window_raise(mainwin->window->window);
1192 debug_print("window position: x = %d, y = %d\n", x, y);
1194 switch (mainwin->type) {
1195 case SEPARATE_FOLDER:
1196 widget = mainwin->win.sep_folder.folderwin;
1197 gdk_window_get_origin(widget->window, &x, &y);
1198 x %= sx; if (x < 0) x += sx;
1199 y %= sy; if (y < 0) y += sy;
1200 gdk_window_move(widget->window, x, y);
1201 gdk_window_raise(widget->window);
1203 case SEPARATE_MESSAGE:
1204 widget = mainwin->win.sep_message.messagewin;
1205 gdk_window_get_origin(widget->window, &x, &y);
1206 x %= sx; if (x < 0) x += sx;
1207 y %= sy; if (y < 0) y += sy;
1208 gdk_window_move(widget->window, x, y);
1209 gdk_window_raise(widget->window);
1212 widget = mainwin->win.sep_both.folderwin;
1213 gdk_window_get_origin(widget->window, &x, &y);
1214 x %= sx; if (x < 0) x += sx;
1215 y %= sy; if (y < 0) y += sy;
1216 gdk_window_move(widget->window, x, y);
1217 gdk_window_raise(widget->window);
1218 widget = mainwin->win.sep_both.messagewin;
1219 gdk_window_get_origin(widget->window, &x, &y);
1220 x %= sx; if (x < 0) x += sx;
1221 y %= sy; if (y < 0) y += sy;
1222 gdk_window_move(widget->window, x, y);
1223 gdk_window_raise(widget->window);
1229 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1231 GtkWidget *folderwin = NULL;
1232 GtkWidget *messagewin = NULL;
1235 GtkWidget *vbox_body = mainwin->vbox_body;
1237 debug_print(_("Setting widgets..."));
1239 /* create separated window(s) if needed */
1240 if (type & SEPARATE_FOLDER) {
1241 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1242 gtk_window_set_policy(GTK_WINDOW(folderwin),
1244 gtk_widget_set_usize(folderwin, -1,
1245 prefs_common.mainview_height);
1246 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1248 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1249 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1252 if (type & SEPARATE_MESSAGE) {
1253 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1254 gtk_window_set_policy(GTK_WINDOW(messagewin),
1256 gtk_widget_set_usize
1257 (messagewin, prefs_common.mainview_width,
1258 prefs_common.mainview_height
1259 - prefs_common.summaryview_height
1260 + DEFAULT_HEADERVIEW_HEIGHT);
1261 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1263 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1264 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1270 hpaned = gtk_hpaned_new();
1271 gtk_widget_show(hpaned);
1272 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1273 gtk_paned_add1(GTK_PANED(hpaned),
1274 GTK_WIDGET_PTR(mainwin->folderview));
1276 vpaned = gtk_vpaned_new();
1277 if (mainwin->summaryview->msg_is_toggled_on) {
1278 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1279 gtk_paned_add1(GTK_PANED(vpaned),
1280 GTK_WIDGET_PTR(mainwin->summaryview));
1282 gtk_paned_add2(GTK_PANED(hpaned),
1283 GTK_WIDGET_PTR(mainwin->summaryview));
1284 gtk_widget_ref(vpaned);
1286 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1287 prefs_common.summaryview_width,
1288 prefs_common.summaryview_height);
1289 gtk_paned_add2(GTK_PANED(vpaned),
1290 GTK_WIDGET_PTR(mainwin->messageview));
1291 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1292 prefs_common.mainview_width, -1);
1293 gtk_widget_set_usize(mainwin->window,
1294 prefs_common.folderview_width +
1295 prefs_common.mainview_width,
1296 prefs_common.mainwin_height);
1297 gtk_widget_show_all(vpaned);
1299 mainwin->win.sep_none.hpaned = hpaned;
1300 mainwin->win.sep_none.vpaned = vpaned;
1302 case SEPARATE_FOLDER:
1303 vpaned = gtk_vpaned_new();
1304 if (mainwin->summaryview->msg_is_toggled_on) {
1305 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1307 gtk_paned_add1(GTK_PANED(vpaned),
1308 GTK_WIDGET_PTR(mainwin->summaryview));
1310 gtk_box_pack_start(GTK_BOX(vbox_body),
1311 GTK_WIDGET_PTR(mainwin->summaryview),
1313 gtk_widget_ref(vpaned);
1315 gtk_paned_add2(GTK_PANED(vpaned),
1316 GTK_WIDGET_PTR(mainwin->messageview));
1317 gtk_widget_show_all(vpaned);
1318 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1319 prefs_common.summaryview_width,
1320 prefs_common.summaryview_height);
1321 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1322 prefs_common.mainview_width, -1);
1323 gtk_widget_set_usize(mainwin->window,
1324 prefs_common.mainview_width,
1325 prefs_common.mainview_height);
1327 gtk_container_add(GTK_CONTAINER(folderwin),
1328 GTK_WIDGET_PTR(mainwin->folderview));
1330 mainwin->win.sep_folder.folderwin = folderwin;
1331 mainwin->win.sep_folder.vpaned = vpaned;
1333 gtk_widget_show_all(folderwin);
1335 case SEPARATE_MESSAGE:
1336 hpaned = gtk_hpaned_new();
1337 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1339 gtk_paned_add1(GTK_PANED(hpaned),
1340 GTK_WIDGET_PTR(mainwin->folderview));
1341 gtk_paned_add2(GTK_PANED(hpaned),
1342 GTK_WIDGET_PTR(mainwin->summaryview));
1343 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1344 prefs_common.summaryview_width,
1345 prefs_common.summaryview_height);
1346 gtk_widget_set_usize(mainwin->window,
1347 prefs_common.folderview_width +
1348 prefs_common.mainview_width,
1349 prefs_common.mainwin_height);
1350 gtk_widget_show_all(hpaned);
1351 gtk_container_add(GTK_CONTAINER(messagewin),
1352 GTK_WIDGET_PTR(mainwin->messageview));
1354 mainwin->win.sep_message.messagewin = messagewin;
1355 mainwin->win.sep_message.hpaned = hpaned;
1357 gtk_widget_show_all(messagewin);
1360 gtk_box_pack_start(GTK_BOX(vbox_body),
1361 GTK_WIDGET_PTR(mainwin->summaryview),
1363 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1364 prefs_common.summaryview_width,
1365 prefs_common.summaryview_height);
1366 gtk_widget_set_usize(mainwin->window,
1367 prefs_common.mainview_width,
1368 prefs_common.mainwin_height);
1369 gtk_container_add(GTK_CONTAINER(folderwin),
1370 GTK_WIDGET_PTR(mainwin->folderview));
1371 gtk_container_add(GTK_CONTAINER(messagewin),
1372 GTK_WIDGET_PTR(mainwin->messageview));
1374 mainwin->win.sep_both.folderwin = folderwin;
1375 mainwin->win.sep_both.messagewin = messagewin;
1377 gtk_widget_show_all(folderwin);
1378 gtk_widget_show_all(messagewin);
1382 mainwin->type = type;
1384 debug_print(_("done.\n"));
1387 #include "pixmaps/stock_mail_receive.xpm"
1388 #include "pixmaps/stock_mail_receive_all.xpm"
1389 #include "pixmaps/stock_mail_compose.xpm"
1390 #include "pixmaps/stock_mail_reply.xpm"
1391 #include "pixmaps/stock_mail_reply_to_all.xpm"
1392 #include "pixmaps/stock_mail_reply_to_author.xpm"
1393 #include "pixmaps/stock_mail_forward.xpm"
1394 #include "pixmaps/stock_mail_send.xpm"
1395 #include "pixmaps/stock_preferences.xpm"
1396 #include "pixmaps/stock_properties.xpm"
1397 #include "pixmaps/stock_down_arrow.xpm"
1398 #include "pixmaps/stock_close.xpm"
1399 #include "pixmaps/stock_exec.xpm"
1401 #define CREATE_TOOLBAR_ICON(xpm_d) \
1403 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1404 &container->style->white, \
1406 icon_wid = gtk_pixmap_new(icon, mask); \
1409 static void main_window_toolbar_create(MainWindow *mainwin,
1410 GtkWidget *container)
1415 GtkWidget *icon_wid;
1417 GtkWidget *getall_btn;
1418 GtkWidget *compose_btn;
1419 GtkWidget *reply_btn;
1420 GtkWidget *replyall_btn;
1421 GtkWidget *replyauthor_btn;
1423 GtkWidget *send_btn;
1425 GtkWidget *prefs_btn;
1426 GtkWidget *account_btn;
1428 GtkWidget *next_btn;
1429 GtkWidget *delete_btn;
1430 GtkWidget *exec_btn;
1432 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1434 gtk_container_add(GTK_CONTAINER(container), toolbar);
1435 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1436 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1437 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1438 GTK_TOOLBAR_SPACE_LINE);
1440 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1441 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1443 _("Incorporate new mail"),
1445 icon_wid, toolbar_inc_cb, mainwin);
1446 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1447 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1449 _("Incorporate new mail of all accounts"),
1455 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1457 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1458 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1460 _("Send queued message(s)"),
1466 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1468 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1469 compose_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1471 _("Compose new message"),
1476 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1477 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1479 _("Reply to the message"),
1484 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1485 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1490 toolbar_reply_to_all_cb,
1492 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1493 replyauthor_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1495 _("Reply to author"),
1498 toolbar_reply_to_author_cb,
1500 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1501 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1503 _("Forward the message"),
1509 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1511 CREATE_TOOLBAR_ICON(stock_close_xpm);
1512 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1514 _("Delete the message"),
1520 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1521 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1523 _("Execute marked process"),
1529 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1531 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1532 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1534 _("Next unread message"),
1537 toolbar_next_unread_cb,
1541 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1543 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1544 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1546 _("Common preference"),
1551 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1552 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1554 _("Account setting"),
1559 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1560 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1564 mainwin->toolbar = toolbar;
1565 mainwin->get_btn = get_btn;
1566 mainwin->getall_btn = getall_btn;
1567 mainwin->compose_btn = compose_btn;
1568 mainwin->reply_btn = reply_btn;
1569 mainwin->replyall_btn = replyall_btn;
1570 mainwin->replyauthor_btn = replyauthor_btn;
1571 mainwin->fwd_btn = fwd_btn;
1572 mainwin->send_btn = send_btn;
1574 mainwin->prefs_btn = prefs_btn;
1575 mainwin->account_btn = account_btn;
1577 mainwin->next_btn = next_btn;
1578 mainwin->delete_btn = delete_btn;
1579 mainwin->exec_btn = exec_btn;
1581 gtk_widget_show_all(toolbar);
1584 /* callback functions */
1586 static void toolbar_inc_cb (GtkWidget *widget,
1589 MainWindow *mainwin = (MainWindow *)data;
1591 inc_mail_cb(mainwin, 0, NULL);
1594 static void toolbar_inc_all_cb (GtkWidget *widget,
1597 MainWindow *mainwin = (MainWindow *)data;
1599 inc_all_account_mail_cb(mainwin, 0, NULL);
1602 static void toolbar_send_cb (GtkWidget *widget,
1605 MainWindow *mainwin = (MainWindow *)data;
1607 send_queue_cb(mainwin, 0, NULL);
1610 static void toolbar_compose_cb (GtkWidget *widget,
1613 MainWindow *mainwin = (MainWindow *)data;
1615 compose_cb(mainwin, 0, NULL);
1618 static void toolbar_reply_cb (GtkWidget *widget,
1621 MainWindow *mainwin = (MainWindow *)data;
1623 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1626 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1629 MainWindow *mainwin = (MainWindow *)data;
1631 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1634 static void toolbar_reply_to_author_cb (GtkWidget *widget,
1637 MainWindow *mainwin = (MainWindow *)data;
1639 reply_cb(mainwin, COMPOSE_REPLY_TO_AUTHOR, NULL);
1642 static void toolbar_forward_cb (GtkWidget *widget,
1645 MainWindow *mainwin = (MainWindow *)data;
1647 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1650 static void toolbar_delete_cb (GtkWidget *widget,
1653 MainWindow *mainwin = (MainWindow *)data;
1655 summary_delete(mainwin->summaryview);
1658 static void toolbar_exec_cb (GtkWidget *widget,
1661 MainWindow *mainwin = (MainWindow *)data;
1663 summary_execute(mainwin->summaryview);
1666 static void toolbar_next_unread_cb (GtkWidget *widget,
1669 MainWindow *mainwin = (MainWindow *)data;
1671 next_unread_cb(mainwin, 0, NULL);
1674 static void toolbar_prefs_cb (GtkWidget *widget,
1677 prefs_common_open();
1680 static void toolbar_account_cb (GtkWidget *widget,
1683 MainWindow *mainwin = (MainWindow *)data;
1685 prefs_account_open_cb(mainwin, 0, NULL);
1688 static void toolbar_account_button_pressed(GtkWidget *widget,
1689 GdkEventButton *event,
1692 MainWindow *mainwin = (MainWindow *)data;
1695 if (event->button != 3) return;
1697 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1698 event->button, event->time);
1701 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1704 MainWindow *mainwin = (MainWindow *)data;
1708 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1709 event->button, event->time);
1712 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1715 app_exit_cb(data, 0, widget);
1720 static void add_mailbox_cb(MainWindow *mainwin, guint action,
1723 main_window_add_mailbox(mainwin);
1726 static void add_mbox_cb(MainWindow *mainwin, guint action,
1729 main_window_add_mbox(mainwin);
1732 static void update_folderview_cb(MainWindow *mainwin, guint action,
1735 summary_show(mainwin->summaryview, NULL, FALSE);
1736 folderview_update_all();
1739 static void new_folder_cb(MainWindow *mainwin, guint action,
1742 folderview_new_folder(mainwin->folderview);
1745 static void rename_folder_cb(MainWindow *mainwin, guint action,
1748 folderview_rename_folder(mainwin->folderview);
1751 static void delete_folder_cb(MainWindow *mainwin, guint action,
1754 folderview_delete_folder(mainwin->folderview);
1757 static void import_mbox_cb(MainWindow *mainwin, guint action,
1760 import_mbox(mainwin->summaryview->folder_item);
1763 static void export_mbox_cb(MainWindow *mainwin, guint action,
1766 export_mbox(mainwin->summaryview->folder_item);
1769 static void empty_trash_cb(MainWindow *mainwin, guint action,
1772 main_window_empty_trash(mainwin, TRUE);
1775 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1777 summary_save_as(mainwin->summaryview);
1780 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1782 summary_print(mainwin->summaryview);
1785 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1787 if (prefs_common.confirm_on_exit) {
1788 if (alertpanel(_("Exit"), _("Exit this program?"),
1789 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
1791 manage_window_focus_in(mainwin->window, NULL, NULL);
1794 app_will_exit(widget, mainwin);
1797 static void toggle_folder_cb(MainWindow *mainwin, guint action,
1800 switch (mainwin->type) {
1802 case SEPARATE_MESSAGE:
1804 case SEPARATE_FOLDER:
1805 if (GTK_CHECK_MENU_ITEM(widget)->active)
1806 gtk_widget_show(mainwin->win.sep_folder.folderwin);
1808 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1811 if (GTK_CHECK_MENU_ITEM(widget)->active)
1812 gtk_widget_show(mainwin->win.sep_both.folderwin);
1814 gtk_widget_hide(mainwin->win.sep_both.folderwin);
1819 static void toggle_message_cb(MainWindow *mainwin, guint action,
1822 switch (mainwin->type) {
1824 case SEPARATE_FOLDER:
1826 case SEPARATE_MESSAGE:
1827 if (GTK_CHECK_MENU_ITEM(widget)->active)
1828 gtk_widget_show(mainwin->win.sep_message.messagewin);
1830 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1833 if (GTK_CHECK_MENU_ITEM(widget)->active)
1834 gtk_widget_show(mainwin->win.sep_both.messagewin);
1836 gtk_widget_hide(mainwin->win.sep_both.messagewin);
1841 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
1844 switch ((ToolbarStyle)action) {
1846 gtk_widget_hide(mainwin->handlebox);
1848 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1852 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1856 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1861 if (action != TOOLBAR_NONE) {
1862 gtk_widget_show(mainwin->handlebox);
1863 gtk_widget_queue_resize(mainwin->handlebox);
1866 mainwin->toolbar_style = (ToolbarStyle)action;
1867 prefs_common.toolbar_style = (ToolbarStyle)action;
1870 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
1873 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1874 gtk_widget_show(mainwin->hbox_stat);
1875 prefs_common.show_statusbar = TRUE;
1877 gtk_widget_hide(mainwin->hbox_stat);
1878 prefs_common.show_statusbar = FALSE;
1882 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action)
1884 MainWindow *mainwin;
1887 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
1888 g_return_if_fail(mainwin != NULL);
1890 type = mainwin->type ^ action;
1891 main_window_separation_change(mainwin, type);
1893 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
1894 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
1897 static void addressbook_open_cb(MainWindow *mainwin, guint action,
1900 addressbook_open(NULL);
1903 static void log_window_show_cb(MainWindow *mainwin, guint action,
1906 log_window_show(mainwin->logwin);
1909 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1914 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
1917 inc_all_account_mail(mainwin);
1920 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1924 if (procmsg_send_queue() < 0)
1925 alertpanel_error(_("Sending queued message failed."));
1927 statusbar_pop_all();
1929 for (list = folder_get_list(); list != NULL; list = list->next) {
1932 folder = list->data;
1933 if (folder->queue) {
1934 folder_item_scan(folder->queue);
1935 folderview_update_item(folder->queue, TRUE);
1940 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1942 if (mainwin->summaryview->folder_item)
1943 compose_new(mainwin->summaryview->folder_item->folder->account);
1948 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1952 msginfo = gtk_ctree_node_get_row_data
1953 (GTK_CTREE(mainwin->summaryview->ctree),
1954 mainwin->summaryview->selected);
1956 if (!msginfo) return;
1960 compose_reply(msginfo, prefs_common.reply_with_quote,
1963 case COMPOSE_REPLY_TO_ALL:
1964 compose_reply(msginfo, prefs_common.reply_with_quote,
1967 case COMPOSE_REPLY_TO_AUTHOR:
1968 compose_reply(msginfo, prefs_common.reply_with_quote,
1971 case COMPOSE_FORWARD:
1972 compose_forward(NULL, msginfo, FALSE);
1974 case COMPOSE_FORWARD_AS_ATTACH:
1975 compose_forward(NULL, msginfo, TRUE);
1978 compose_reply(msginfo, prefs_common.reply_with_quote,
1982 summary_set_marks_selected(mainwin->summaryview);
1985 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1987 summary_move_to(mainwin->summaryview);
1990 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1992 summary_copy_to(mainwin->summaryview);
1995 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1997 summary_delete(mainwin->summaryview);
2000 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2002 summary_open_msg(mainwin->summaryview);
2005 static void view_source_cb(MainWindow *mainwin, guint action,
2008 summary_view_source(mainwin->summaryview);
2011 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2013 summary_reedit(mainwin->summaryview);
2016 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2018 summary_mark(mainwin->summaryview);
2021 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2023 summary_unmark(mainwin->summaryview);
2026 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2029 summary_mark_as_unread(mainwin->summaryview);
2032 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2035 summary_mark_as_read(mainwin->summaryview);
2038 static void set_charset_cb(MainWindow *mainwin, guint action,
2043 str = conv_get_charset_str((CharSet)action);
2044 g_free(prefs_common.force_charset);
2045 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2047 summary_redisplay_msg(mainwin->summaryview);
2049 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2052 void main_window_set_thread_option(MainWindow *mainwin)
2054 GtkItemFactory *ifactory;
2056 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2058 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2059 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2060 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2061 summary_thread_build(mainwin->summaryview);
2064 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2065 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2066 summary_unthread(mainwin->summaryview);
2068 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2071 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2074 ifactory = gtk_item_factory_from_widget(widget);
2076 mainwin->summaryview->folder_item->prefs->enable_thread =
2077 !mainwin->summaryview->folder_item->prefs->enable_thread;
2078 main_window_set_thread_option(mainwin);
2082 summary_thread_build(mainwin->summaryview);
2083 mainwin->summaryview->folder_item->prefs->enable_thread =
2085 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2086 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2088 summary_unthread(mainwin->summaryview);
2089 mainwin->summaryview->folder_item->prefs->enable_thread =
2091 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2092 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2097 static void set_display_item_cb(MainWindow *mainwin, guint action,
2100 prefs_summary_display_item_set();
2103 static void sort_summary_cb(MainWindow *mainwin, guint action,
2106 summary_sort(mainwin->summaryview, (SummarySortType)action);
2109 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2112 summary_attract_by_subject(mainwin->summaryview);
2115 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2118 summary_delete_duplicated(mainwin->summaryview);
2121 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2123 summary_filter(mainwin->summaryview);
2126 static void execute_summary_cb(MainWindow *mainwin, guint action,
2129 summary_execute(mainwin->summaryview);
2132 static void update_summary_cb(MainWindow *mainwin, guint action,
2136 FolderView *folderview = mainwin->folderview;
2138 if (!mainwin->summaryview->folder_item) return;
2139 if (!folderview->opened) return;
2141 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2142 folderview->opened);
2145 summary_show(mainwin->summaryview, fitem, TRUE);
2148 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2150 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2153 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2155 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2158 static void next_unread_cb(MainWindow *mainwin, guint action,
2161 summary_select_next_unread(mainwin->summaryview);
2164 static void next_marked_cb(MainWindow *mainwin, guint action,
2167 summary_select_next_marked(mainwin->summaryview);
2170 static void prev_marked_cb(MainWindow *mainwin, guint action,
2173 summary_select_prev_marked(mainwin->summaryview);
2176 static void goto_folder_cb(MainWindow *mainwin, guint action,
2179 FolderItem *to_folder;
2181 to_folder = foldersel_folder_sel(NULL);
2184 folderview_select(mainwin->folderview, to_folder);
2187 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2189 messageview_copy_clipboard(mainwin->messageview);
2192 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2194 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2195 summary_select_all(mainwin->summaryview);
2196 else if (mainwin->summaryview->msg_is_toggled_on &&
2197 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2198 messageview_select_all(mainwin->messageview);
2201 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2204 prefs_common_open();
2207 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2210 prefs_filter_open();
2213 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2216 prefs_scoring_open();
2219 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2222 prefs_filtering_open();
2225 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2229 new_account_cb(mainwin, 0, widget);
2231 gboolean prev_default = cur_account->is_default;
2233 prefs_account_open(cur_account);
2234 if (!prev_default && cur_account->is_default)
2235 account_set_as_default(cur_account);
2236 account_save_config_all();
2238 main_window_reflect_prefs_all();
2242 static void new_account_cb(MainWindow *mainwin, guint action,
2245 account_edit_open();
2246 if (!compose_get_compose_list()) account_add();
2249 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2251 cur_account = (PrefsAccount *)data;
2252 main_window_reflect_prefs_all();
2255 static void manual_open_cb(MainWindow *mainwin, guint action,
2258 manual_open((ManualLang)action);
2261 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2263 MainWindow *mainwin = (MainWindow *)data;
2267 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2268 LOCAL_FOLDER(folder)->rootpath,
2272 str = g_strdup_printf(_("Scanning folder %s ..."),
2273 LOCAL_FOLDER(folder)->rootpath);
2275 STATUSBAR_PUSH(mainwin, str);
2276 STATUSBAR_POP(mainwin);