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_filtering.h"
61 #include "prefs_scoring.h"
62 #include "prefs_account.h"
63 #include "prefs_folder_item.h"
65 #include "addressbook.h"
66 #include "headerwindow.h"
67 #include "logwindow.h"
68 #include "manage_window.h"
69 #include "alertpanel.h"
70 #include "statusbar.h"
71 #include "inputdialog.h"
78 #define AC_LABEL_WIDTH 240
80 #define STATUSBAR_PUSH(mainwin, str) \
82 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
83 mainwin->mainwin_cid, str); \
84 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
87 #define STATUSBAR_POP(mainwin) \
89 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
90 mainwin->mainwin_cid); \
93 /* list of all instantiated MainWindow */
94 static GList *mainwin_list = NULL;
96 static GdkCursor *watch_cursor;
98 static void main_window_show_cur_account (MainWindow *mainwin);
100 static void main_window_set_widgets (MainWindow *mainwin,
102 static void main_window_toolbar_create (MainWindow *mainwin,
103 GtkWidget *container);
105 /* callback functions */
106 static void toolbar_inc_cb (GtkWidget *widget,
108 static void toolbar_inc_all_cb (GtkWidget *widget,
110 static void toolbar_send_cb (GtkWidget *widget,
113 static void toolbar_compose_cb (GtkWidget *widget,
115 static void toolbar_popup_compose_type_cb(GtkWidget *widget,
117 static void toolbar_popup_compose_type_set(GtkWidget *widget,
119 static void toolbar_compose_news_cb (GtkWidget *widget,
121 static void toolbar_compose_mail_cb (GtkWidget *widget,
123 static void toolbar_reply_cb (GtkWidget *widget,
125 static void toolbar_reply_to_all_cb (GtkWidget *widget,
127 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
129 static void toolbar_forward_cb (GtkWidget *widget,
132 static void toolbar_delete_cb (GtkWidget *widget,
134 static void toolbar_exec_cb (GtkWidget *widget,
137 static void toolbar_next_unread_cb (GtkWidget *widget,
140 static void toolbar_prefs_cb (GtkWidget *widget,
142 static void toolbar_account_cb (GtkWidget *widget,
145 static void toolbar_account_button_pressed (GtkWidget *widget,
146 GdkEventButton *event,
148 static void ac_label_button_pressed (GtkWidget *widget,
149 GdkEventButton *event,
152 static gint main_window_close_cb (GtkWidget *widget,
156 static void add_mailbox_cb (MainWindow *mainwin,
159 static void add_mbox_cb (MainWindow *mainwin,
162 static void update_folderview_cb (MainWindow *mainwin,
165 static void new_folder_cb (MainWindow *mainwin,
168 static void rename_folder_cb (MainWindow *mainwin,
171 static void delete_folder_cb (MainWindow *mainwin,
174 static void import_mbox_cb (MainWindow *mainwin,
177 static void export_mbox_cb (MainWindow *mainwin,
180 static void empty_trash_cb (MainWindow *mainwin,
184 static void save_as_cb (MainWindow *mainwin,
187 static void print_cb (MainWindow *mainwin,
190 static void app_exit_cb (MainWindow *mainwin,
194 static void toggle_folder_cb (MainWindow *mainwin,
197 static void toggle_message_cb (MainWindow *mainwin,
200 static void toggle_toolbar_cb (MainWindow *mainwin,
203 static void toggle_statusbar_cb (MainWindow *mainwin,
206 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action);
208 static void addressbook_open_cb (MainWindow *mainwin,
211 static void log_window_show_cb (MainWindow *mainwin,
215 static void inc_mail_cb (MainWindow *mainwin,
218 static void inc_all_account_mail_cb (MainWindow *mainwin,
222 static void send_queue_cb (MainWindow *mainwin,
226 static void compose_cb (MainWindow *mainwin,
229 static void compose_mail_cb(MainWindow *mainwin, guint action,
231 static void compose_news_cb(MainWindow *mainwin, guint action,
233 static void reply_cb (MainWindow *mainwin,
237 static void open_msg_cb (MainWindow *mainwin,
241 static void view_source_cb (MainWindow *mainwin,
245 static void reedit_cb (MainWindow *mainwin,
249 static void move_to_cb (MainWindow *mainwin,
252 static void copy_to_cb (MainWindow *mainwin,
255 static void delete_cb (MainWindow *mainwin,
259 static void mark_cb (MainWindow *mainwin,
262 static void unmark_cb (MainWindow *mainwin,
266 static void mark_as_unread_cb (MainWindow *mainwin,
269 static void mark_as_read_cb (MainWindow *mainwin,
273 static void set_charset_cb (MainWindow *mainwin,
277 static void thread_cb (MainWindow *mainwin,
280 static void set_display_item_cb (MainWindow *mainwin,
283 static void sort_summary_cb (MainWindow *mainwin,
286 static void attract_by_subject_cb(MainWindow *mainwin,
290 static void delete_duplicated_cb (MainWindow *mainwin,
293 static void filter_cb (MainWindow *mainwin,
296 static void execute_summary_cb (MainWindow *mainwin,
299 static void update_summary_cb (MainWindow *mainwin,
303 static void prev_cb (MainWindow *mainwin,
306 static void next_cb (MainWindow *mainwin,
310 static void next_unread_cb (MainWindow *mainwin,
314 static void next_marked_cb (MainWindow *mainwin,
318 static void prev_marked_cb (MainWindow *mainwin,
322 static void goto_folder_cb (MainWindow *mainwin,
326 static void copy_cb (MainWindow *mainwin,
329 static void allsel_cb (MainWindow *mainwin,
333 static void prefs_common_open_cb (MainWindow *mainwin,
336 static void prefs_filter_open_cb (MainWindow *mainwin,
339 static void prefs_scoring_open_cb (MainWindow *mainwin,
342 static void prefs_filtering_open_cb (MainWindow *mainwin,
345 static void prefs_account_open_cb(MainWindow *mainwin,
348 static void new_account_cb (MainWindow *mainwin,
352 static void account_menu_cb (GtkMenuItem *menuitem,
355 static void manual_open_cb (MainWindow *mainwin,
359 static void scan_tree_func (Folder *folder,
363 static void activate_compose_button (MainWindow *mainwin,
364 ComposeButtonType type);
366 #define SEPARATE_ACTION 667
368 static GtkItemFactoryEntry mainwin_entries[] =
370 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
371 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
372 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
373 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
374 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
375 {N_("/_File/_Folder/Create _new folder..."),
376 NULL, new_folder_cb, 0, NULL},
377 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
378 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
379 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
380 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
381 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
382 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
383 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
384 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
385 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
386 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
387 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
389 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
390 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
391 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
392 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
393 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
395 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
396 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
397 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
398 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
399 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
400 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
401 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
402 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
403 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
404 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
405 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
406 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
407 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
408 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
409 {N_("/_View/_Code set/_Auto detect"),
410 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
412 #define CODESET_SEPARATOR \
413 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
414 #define CODESET_ACTION(action) \
415 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
417 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
418 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
419 CODESET_ACTION(C_US_ASCII)},
422 {N_("/_View/_Code set/Unicode (_UTF-8)"),
423 CODESET_ACTION(C_UTF_8)},
426 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
427 CODESET_ACTION(C_ISO_8859_1)},
430 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
431 CODESET_ACTION(C_ISO_8859_2)},
433 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
434 CODESET_ACTION(C_ISO_8859_13)},
435 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
436 CODESET_ACTION(C_ISO_8859_4)},
438 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
439 CODESET_ACTION(C_ISO_8859_7)},
441 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
442 CODESET_ACTION(C_ISO_8859_9)},
444 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
445 CODESET_ACTION(C_ISO_8859_5)},
446 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
447 CODESET_ACTION(C_KOI8_R)},
448 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
449 CODESET_ACTION(C_CP1251)},
452 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
453 CODESET_ACTION(C_ISO_2022_JP)},
455 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
456 CODESET_ACTION(C_ISO_2022_JP_2)},
458 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
459 CODESET_ACTION(C_EUC_JP)},
460 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
461 CODESET_ACTION(C_SHIFT_JIS)},
464 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
465 CODESET_ACTION(C_GB2312)},
466 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
467 CODESET_ACTION(C_BIG5)},
468 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
469 CODESET_ACTION(C_EUC_TW)},
470 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
471 CODESET_ACTION(C_ISO_2022_CN)},
473 {N_("/_View/_Code set/Korean (EUC-_KR)"),
474 CODESET_ACTION(C_EUC_KR)},
475 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
476 CODESET_ACTION(C_ISO_2022_KR)},
479 #undef CODESET_SEPARATOR
480 #undef CODESET_ACTION
482 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
483 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
484 {N_("/_Message/Get from _all accounts"),
485 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
486 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
487 {N_("/_Message/Send queued messa_ges"),
488 NULL, send_queue_cb, 0, NULL},
489 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
490 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
491 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
492 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
493 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
494 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
495 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
496 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
497 {N_("/_Message/Forward as a_ttachment"),
498 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
499 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
500 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
501 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
502 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
503 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
504 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
505 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
506 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
507 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
508 {N_("/_Message/_Mark/Mark as rea_d"),
509 NULL, mark_as_read_cb, 0, NULL},
510 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
512 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
513 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
514 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
516 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
517 {N_("/_Summary/_Delete duplicated messages"),
518 NULL, delete_duplicated_cb, 0, NULL},
519 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
520 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
521 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
522 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
523 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
524 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
525 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
526 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
527 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
528 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
529 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
530 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
531 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
532 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
533 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
534 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
535 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
536 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
537 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
538 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_Summary/_Sort/_Attract by subject"),
540 NULL, attract_by_subject_cb, 0, NULL},
541 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
542 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
543 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
545 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
546 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
547 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
549 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
550 {N_("/_Configuration/_Common preferences..."),
551 NULL, prefs_common_open_cb, 0, NULL},
552 {N_("/_Configuration/_Filter setting..."),
553 NULL, prefs_filter_open_cb, 0, NULL},
554 {N_("/_Configuration/_Scoring ..."),
555 NULL, prefs_scoring_open_cb, 0, NULL},
556 {N_("/_Configuration/_Filtering ..."),
557 NULL, prefs_filtering_open_cb, 0, NULL},
558 {N_("/_Configuration/_Preferences per account..."),
559 NULL, prefs_account_open_cb, 0, NULL},
560 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
561 {N_("/_Configuration/Create _new account..."),
562 NULL, new_account_cb, 0, NULL},
563 {N_("/_Configuration/_Edit accounts..."),
564 NULL, account_edit_open, 0, NULL},
565 {N_("/_Configuration/C_hange current account"),
566 NULL, NULL, 0, "<Branch>"},
568 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
569 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
570 {N_("/_Help/_Manual/_English"), NULL, NULL, MANUAL_LANG_EN, NULL},
571 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
572 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
573 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
576 MainWindow *main_window_create(SeparateType type)
582 GtkWidget *handlebox;
583 GtkWidget *vbox_body;
584 GtkWidget *hbox_stat;
585 GtkWidget *statusbar;
586 GtkWidget *ac_button;
589 FolderView *folderview;
590 SummaryView *summaryview;
591 MessageView *messageview;
592 GdkColormap *colormap;
595 guint n_menu_entries;
596 GtkItemFactory *ifactory;
601 debug_print(_("Creating main window...\n"));
602 mainwin = g_new0(MainWindow, 1);
605 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
606 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
607 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
608 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
609 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
610 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
611 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
612 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
613 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
614 gtk_widget_realize(window);
616 vbox = gtk_vbox_new(FALSE, 0);
617 gtk_widget_show(vbox);
618 gtk_container_add(GTK_CONTAINER(window), vbox);
621 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
622 menubar = menubar_create(window, mainwin_entries,
623 n_menu_entries, "<Main>", mainwin);
624 gtk_widget_show(menubar);
625 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
627 handlebox = gtk_handle_box_new();
628 gtk_widget_show(handlebox);
629 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
631 main_window_toolbar_create(mainwin, handlebox);
633 /* vbox that contains body */
634 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
635 gtk_widget_show(vbox_body);
636 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
637 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
639 hbox_stat = gtk_hbox_new(FALSE, 2);
640 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
642 statusbar = statusbar_create();
643 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
645 ac_button = gtk_button_new();
646 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
647 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
648 gtk_widget_set_usize(ac_button, -1, 1);
649 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
650 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
651 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
653 ac_label = gtk_label_new("");
654 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
656 gtk_widget_show_all(hbox_stat);
659 mainwin->folderview = folderview = folderview_create();
660 mainwin->summaryview = summaryview = summary_create();
661 mainwin->messageview = messageview = messageview_create();
662 mainwin->headerwin = header_window_create();
663 mainwin->logwin = log_window_create();
665 folderview->mainwin = mainwin;
666 folderview->summaryview = summaryview;
668 summaryview->mainwin = mainwin;
669 summaryview->folderview = folderview;
670 summaryview->messageview = messageview;
671 summaryview->headerwin = mainwin->headerwin;
672 summaryview->window = window;
674 messageview->mainwin = mainwin;
676 mainwin->window = window;
677 mainwin->vbox = vbox;
678 mainwin->menubar = menubar;
679 mainwin->handlebox = handlebox;
680 mainwin->vbox_body = vbox_body;
681 mainwin->hbox_stat = hbox_stat;
682 mainwin->statusbar = statusbar;
683 mainwin->ac_button = ac_button;
684 mainwin->ac_label = ac_label;
686 /* set context IDs for status bar */
687 mainwin->mainwin_cid = gtk_statusbar_get_context_id
688 (GTK_STATUSBAR(statusbar), "Main Window");
689 mainwin->folderview_cid = gtk_statusbar_get_context_id
690 (GTK_STATUSBAR(statusbar), "Folder View");
691 mainwin->summaryview_cid = gtk_statusbar_get_context_id
692 (GTK_STATUSBAR(statusbar), "Summary View");
694 /* allocate colors for summary view and folder view */
695 summaryview->color_marked.red = summaryview->color_marked.green = 0;
696 summaryview->color_marked.blue = (guint16)65535;
698 summaryview->color_dim.red = summaryview->color_dim.green =
699 summaryview->color_dim.blue = COLOR_DIM;
701 summaryview->color_normal.red = summaryview->color_normal.green =
702 summaryview->color_normal.blue = 0;
704 folderview->color_new.red = (guint16)55000;
705 folderview->color_new.green = folderview->color_new.blue = 15000;
707 folderview->color_normal.red = folderview->color_normal.green =
708 folderview->color_normal.blue = 0;
710 summaryview->color_important.red = 0;
711 summaryview->color_marked.green = 0;
712 summaryview->color_important.blue = (guint16)65535;
714 color[0] = summaryview->color_marked;
715 color[1] = summaryview->color_dim;
716 color[2] = summaryview->color_normal;
717 color[3] = folderview->color_new;
718 color[4] = folderview->color_normal;
720 colormap = gdk_window_get_colormap(window->window);
721 gdk_colormap_alloc_colors(colormap, color, 5, FALSE, TRUE, success);
722 for (i = 0; i < 5; i++) {
723 if (success[i] == FALSE)
724 g_warning(_("MainWindow: color allocation %d failed\n"), i);
727 debug_print(_("done.\n"));
729 main_window_set_widgets(mainwin, type);
732 ifactory = gtk_item_factory_from_widget(menubar);
733 menuitem = gtk_item_factory_get_item
734 (ifactory, "/View/Code set/Auto detect");
735 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
737 switch (prefs_common.toolbar_style) {
739 menuitem = gtk_item_factory_get_item
740 (ifactory, "/View/Toolbar/None");
743 menuitem = gtk_item_factory_get_item
744 (ifactory, "/View/Toolbar/Icon");
747 menuitem = gtk_item_factory_get_item
748 (ifactory, "/View/Toolbar/Text");
751 menuitem = gtk_item_factory_get_item
752 (ifactory, "/View/Toolbar/Icon and text");
754 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
756 gtk_widget_hide(mainwin->hbox_stat);
757 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
758 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
759 prefs_common.show_statusbar);
761 /* set the check of the SEPARATE_xxx menu items. we also need the main window
762 * as a property and pass the action type to the callback */
763 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
765 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
766 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
767 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
768 GUINT_TO_POINTER(SEPARATE_FOLDER));
770 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
772 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
773 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
774 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
775 GUINT_TO_POINTER(SEPARATE_MESSAGE));
778 menu_set_sensitive(ifactory, "/Summary/Thread view",
779 prefs_common.enable_thread ? FALSE : TRUE);
780 menu_set_sensitive(ifactory, "/Summary/Unthread view",
781 prefs_common.enable_thread ? TRUE : FALSE);
783 main_window_set_thread_option(mainwin);
785 menu_set_sensitive(ifactory, "/Help/Manual/English", FALSE);
787 /* set account selection menu */
788 ac_menu = gtk_item_factory_get_widget
789 (ifactory, "/Configuration/Change current account");
790 mainwin->ac_menu = ac_menu;
792 main_window_set_toolbar_sensitive(mainwin, FALSE);
794 /* show main window */
795 gtk_widget_set_uposition(mainwin->window,
796 prefs_common.mainwin_x,
797 prefs_common.mainwin_y);
798 gtk_widget_set_usize(window, prefs_common.mainwin_width,
799 prefs_common.mainwin_height);
800 gtk_widget_show(mainwin->window);
802 /* initialize views */
803 folderview_init(folderview);
804 summary_init(summaryview);
805 messageview_init(messageview);
806 header_window_init(mainwin->headerwin);
807 log_window_init(mainwin->logwin);
812 gtk_widget_ensure_style(folderview->ctree);
813 newstyle = gtk_widget_get_style(folderview->ctree);
814 newstyle = gtk_style_copy(newstyle);
815 gtk_widget_set_style(summaryview->ctree, newstyle);
816 gtk_widget_ensure_style(summaryview->ctree);
817 gtk_widget_realize(summaryview->ctree);
820 mainwin->cursor_count = 0;
823 watch_cursor = gdk_cursor_new(GDK_WATCH);
825 mainwin_list = g_list_append(mainwin_list, mainwin);
830 void main_window_cursor_wait(MainWindow *mainwin)
832 if (mainwin->cursor_count == 0)
833 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
835 mainwin->cursor_count++;
840 void main_window_cursor_normal(MainWindow *mainwin)
842 if (mainwin->cursor_count)
843 mainwin->cursor_count--;
845 if (mainwin->cursor_count == 0)
846 gdk_window_set_cursor(mainwin->window->window, NULL);
851 void main_window_reflect_prefs_all(void)
856 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
857 mainwin = (MainWindow *)cur->data;
859 main_window_show_cur_account(mainwin);
861 gtk_widget_set_sensitive(mainwin->get_btn, TRUE);
862 gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
864 gtk_widget_set_sensitive(mainwin->get_btn, FALSE);
865 gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
868 if (prefs_common.immediate_exec)
869 gtk_widget_hide(mainwin->exec_btn);
871 gtk_widget_show(mainwin->exec_btn);
873 summary_change_display_item(mainwin->summaryview);
874 summary_redisplay_msg(mainwin->summaryview);
875 headerview_set_visibility(mainwin->messageview->headerview,
876 prefs_common.display_header_pane);
880 void main_window_set_account_menu(GList *account_list)
882 GList *cur, *cur_ac, *cur_item;
885 PrefsAccount *ac_prefs;
887 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
888 mainwin = (MainWindow *)cur->data;
890 /* destroy all previous menu item */
891 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
892 while (cur_item != NULL) {
893 GList *next = cur_item->next;
894 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
898 for (cur_ac = account_list; cur_ac != NULL;
899 cur_ac = cur_ac->next) {
900 ac_prefs = (PrefsAccount *)cur_ac->data;
902 menuitem = gtk_menu_item_new_with_label
903 (ac_prefs->account_name
904 ? ac_prefs->account_name : _("Untitled"));
905 gtk_widget_show(menuitem);
906 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
907 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
908 GTK_SIGNAL_FUNC(account_menu_cb),
914 static void main_window_show_cur_account(MainWindow *mainwin)
919 ac_name = g_strdup(cur_account
920 ? (cur_account->account_name
921 ? cur_account->account_name : _("Untitled"))
925 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
927 buf = g_strdup(PROG_VERSION);
928 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
931 buf = g_strdup_printf(_("Current account: %s"), ac_name);
932 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
933 gtk_widget_queue_resize(mainwin->ac_button);
939 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
941 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
942 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
943 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
945 if (mainwin->type == type) return;
947 /* remove widgets from those containers */
948 gtk_widget_ref(folder_wid);
949 gtk_widget_ref(summary_wid);
950 gtk_widget_ref(message_wid);
952 (GTK_CONTAINER(folder_wid->parent), folder_wid);
954 (GTK_CONTAINER(summary_wid->parent), summary_wid);
956 (GTK_CONTAINER(message_wid->parent), message_wid);
958 /* clean containers */
959 switch (mainwin->type) {
961 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
963 case SEPARATE_FOLDER:
964 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
965 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
967 case SEPARATE_MESSAGE:
968 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
969 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
972 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
973 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
977 gtk_widget_hide(mainwin->window);
978 main_window_set_widgets(mainwin, type);
979 gtk_widget_show(mainwin->window);
981 gtk_widget_unref(folder_wid);
982 gtk_widget_unref(summary_wid);
983 gtk_widget_unref(message_wid);
986 void main_window_get_size(MainWindow *mainwin)
988 GtkAllocation *allocation;
990 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
992 prefs_common.summaryview_width = allocation->width;
994 if (mainwin->summaryview->msg_is_toggled_on)
995 prefs_common.summaryview_height = allocation->height;
997 prefs_common.mainview_width = allocation->width;
999 allocation = &mainwin->window->allocation;
1001 prefs_common.mainview_height = allocation->height;
1002 prefs_common.mainwin_width = allocation->width;
1003 prefs_common.mainwin_height = allocation->height;
1005 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1007 prefs_common.folderview_width = allocation->width;
1008 prefs_common.folderview_height = allocation->height;
1011 void main_window_get_position(MainWindow *mainwin)
1015 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1017 prefs_common.mainview_x = x;
1018 prefs_common.mainview_y = y;
1019 prefs_common.mainwin_x = x;
1020 prefs_common.mainwin_y = y;
1022 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1025 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1030 if (alertpanel(_("Empty trash"),
1031 _("Empty all messages in trash?"),
1032 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1034 manage_window_focus_in(mainwin->window, NULL, NULL);
1037 procmsg_empty_trash();
1039 for (list = folder_get_list(); list != NULL; list = list->next) {
1042 folder = list->data;
1043 if (folder->trash) {
1044 folder_item_scan(folder->trash);
1045 folderview_update_item(folder->trash, TRUE);
1049 if (mainwin->summaryview->folder_item &&
1050 mainwin->summaryview->folder_item->stype == F_TRASH)
1051 gtk_widget_grab_focus(mainwin->folderview->ctree);
1054 void main_window_add_mailbox(MainWindow *mainwin)
1059 path = input_dialog(_("Add mailbox"),
1060 _("Input the location of mailbox.\n"
1061 "If the existing mailbox is specified, it will be\n"
1062 "scanned automatically."),
1065 if (folder_find_from_path(path)) {
1066 alertpanel_error(_("The mailbox `%s' already exists."), path);
1071 if (!strcmp(path, "Mail"))
1072 folder = folder_new(F_MH, _("Mailbox"), path);
1074 folder = folder_new(F_MH, g_basename(path), path);
1078 if (folder->create_tree(folder) < 0) {
1079 alertpanel_error(_("Creation of the mailbox failed.\n"
1080 "Maybe some files already exist, or you don't have the permission to write there."));
1081 folder_destroy(folder);
1086 folder_set_ui_func(folder, scan_tree_func, mainwin);
1087 folder->scan_tree(folder);
1088 folder_set_ui_func(folder, NULL, NULL);
1090 folderview_set(mainwin->folderview);
1093 void main_window_add_mbox(MainWindow *mainwin)
1099 path = input_dialog(_("Add mbox mailbox"),
1100 _("Input the location of mailbox."),
1105 if (folder_find_from_path(path)) {
1106 alertpanel_error(_("The mailbox `%s' already exists."), path);
1112 if (!strcmp(path, "Mail"))
1113 folder = folder_new(F_MBOX, _("Mailbox"), path);
1117 folder = folder_new(F_MBOX, g_basename(path), path);
1120 if (folder->create_tree(folder) < 0) {
1121 alertpanel_error(_("Creation of the mailbox failed."));
1122 folder_destroy(folder);
1128 item = folder_item_new(folder->name, NULL);
1129 item->folder = folder;
1130 folder->node = g_node_new(item);
1132 folder->create_folder(folder, item, "inbox");
1133 folder->create_folder(folder, item, "outbox");
1134 folder->create_folder(folder, item, "queue");
1135 folder->create_folder(folder, item, "draft");
1136 folder->create_folder(folder, item, "trash");
1138 folderview_set(mainwin->folderview);
1141 void main_window_set_toolbar_sensitive(MainWindow *mainwin, gboolean sensitive)
1143 gtk_widget_set_sensitive(mainwin->reply_btn, sensitive);
1144 gtk_widget_set_sensitive(mainwin->replyall_btn, sensitive);
1145 gtk_widget_set_sensitive(mainwin->replysender_btn, sensitive);
1146 gtk_widget_set_sensitive(mainwin->fwd_btn, sensitive);
1147 gtk_widget_set_sensitive(mainwin->exec_btn, sensitive);
1148 gtk_widget_set_sensitive(mainwin->next_btn, sensitive);
1150 if (!mainwin->summaryview->folder_item ||
1151 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1152 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1154 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1157 void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
1159 GtkItemFactory *ifactory;
1163 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1165 if (selection == SUMMARY_SELECTED_SINGLE)
1169 if (!mainwin->summaryview->folder_item ||
1170 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1175 menu_set_sensitive(ifactory, "/File/Save as...", sens);
1176 menu_set_sensitive(ifactory, "/Message/Reply", sens);
1177 menu_set_sensitive(ifactory, "/Message/Reply to sender", sens);
1178 menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
1179 menu_set_sensitive(ifactory, "/Message/Forward", sens);
1180 menu_set_sensitive(ifactory, "/Message/Forward as attachment", sens);
1181 menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
1182 menu_set_sensitive(ifactory, "/Message/Show all header", sens);
1183 menu_set_sensitive(ifactory, "/Message/View source", sens);
1184 if (sens && (!mainwin->summaryview->folder_item ||
1185 mainwin->summaryview->folder_item->stype != F_DRAFT))
1187 menu_set_sensitive(ifactory, "/Message/Re-edit", sens);
1189 if (selection == SUMMARY_SELECTED_SINGLE ||
1190 selection == SUMMARY_SELECTED_MULTIPLE)
1195 menu_set_sensitive(ifactory, "/File/Print..." , sens);
1196 menu_set_sensitive(ifactory, "/Message/Move...", sens && exec);
1197 menu_set_sensitive(ifactory, "/Message/Copy...", sens && exec);
1198 menu_set_sensitive(ifactory, "/Message/Delete" , sens && exec);
1199 menu_set_sensitive(ifactory, "/Message/Mark" , sens);
1201 if (selection != SUMMARY_NONE)
1206 menu_set_sensitive(ifactory, "/Summary/Delete duplicated messages", sens && exec);
1207 menu_set_sensitive(ifactory, "/Summary/Filter messages", sens && exec);
1208 menu_set_sensitive(ifactory, "/Summary/Execute", sens);
1209 menu_set_sensitive(ifactory, "/Summary/Prev message", sens);
1210 menu_set_sensitive(ifactory, "/Summary/Next message", sens);
1211 menu_set_sensitive(ifactory, "/Summary/Next unread message", sens);
1212 menu_set_sensitive(ifactory, "/Summary/Sort", sens);
1214 if (mainwin->summaryview->folder_item &&
1215 mainwin->summaryview->folder_item->folder->account)
1216 sens = mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP;
1219 menu_set_sensitive(ifactory, "/Message/Follow-up and reply to", sens);
1222 void main_window_popup(MainWindow *mainwin)
1228 gdk_window_get_origin(mainwin->window->window, &x, &y);
1229 sx = gdk_screen_width();
1230 sy = gdk_screen_height();
1231 x %= sx; if (x < 0) x += sx;
1232 y %= sy; if (y < 0) y += sy;
1233 gdk_window_move(mainwin->window->window, x, y);
1234 gdk_window_raise(mainwin->window->window);
1236 debug_print("window position: x = %d, y = %d\n", x, y);
1238 switch (mainwin->type) {
1239 case SEPARATE_FOLDER:
1240 widget = mainwin->win.sep_folder.folderwin;
1241 gdk_window_get_origin(widget->window, &x, &y);
1242 x %= sx; if (x < 0) x += sx;
1243 y %= sy; if (y < 0) y += sy;
1244 gdk_window_move(widget->window, x, y);
1245 gdk_window_raise(widget->window);
1247 case SEPARATE_MESSAGE:
1248 widget = mainwin->win.sep_message.messagewin;
1249 gdk_window_get_origin(widget->window, &x, &y);
1250 x %= sx; if (x < 0) x += sx;
1251 y %= sy; if (y < 0) y += sy;
1252 gdk_window_move(widget->window, x, y);
1253 gdk_window_raise(widget->window);
1256 widget = mainwin->win.sep_both.folderwin;
1257 gdk_window_get_origin(widget->window, &x, &y);
1258 x %= sx; if (x < 0) x += sx;
1259 y %= sy; if (y < 0) y += sy;
1260 gdk_window_move(widget->window, x, y);
1261 gdk_window_raise(widget->window);
1262 widget = mainwin->win.sep_both.messagewin;
1263 gdk_window_get_origin(widget->window, &x, &y);
1264 x %= sx; if (x < 0) x += sx;
1265 y %= sy; if (y < 0) y += sy;
1266 gdk_window_move(widget->window, x, y);
1267 gdk_window_raise(widget->window);
1273 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1275 GtkWidget *folderwin = NULL;
1276 GtkWidget *messagewin = NULL;
1279 GtkWidget *vbox_body = mainwin->vbox_body;
1281 debug_print(_("Setting widgets..."));
1283 /* create separated window(s) if needed */
1284 if (type & SEPARATE_FOLDER) {
1285 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1286 gtk_window_set_policy(GTK_WINDOW(folderwin),
1288 gtk_widget_set_usize(folderwin, -1,
1289 prefs_common.mainview_height);
1290 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1292 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1293 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1296 if (type & SEPARATE_MESSAGE) {
1297 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1298 gtk_window_set_policy(GTK_WINDOW(messagewin),
1300 gtk_widget_set_usize
1301 (messagewin, prefs_common.mainview_width,
1302 prefs_common.mainview_height
1303 - prefs_common.summaryview_height
1304 + DEFAULT_HEADERVIEW_HEIGHT);
1305 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1307 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1308 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1314 hpaned = gtk_hpaned_new();
1315 gtk_widget_show(hpaned);
1316 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1317 gtk_paned_add1(GTK_PANED(hpaned),
1318 GTK_WIDGET_PTR(mainwin->folderview));
1320 vpaned = gtk_vpaned_new();
1321 if (mainwin->summaryview->msg_is_toggled_on) {
1322 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1323 gtk_paned_add1(GTK_PANED(vpaned),
1324 GTK_WIDGET_PTR(mainwin->summaryview));
1326 gtk_paned_add2(GTK_PANED(hpaned),
1327 GTK_WIDGET_PTR(mainwin->summaryview));
1328 gtk_widget_ref(vpaned);
1330 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1331 prefs_common.summaryview_width,
1332 prefs_common.summaryview_height);
1333 gtk_paned_add2(GTK_PANED(vpaned),
1334 GTK_WIDGET_PTR(mainwin->messageview));
1335 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1336 prefs_common.mainview_width, -1);
1337 gtk_widget_set_usize(mainwin->window,
1338 prefs_common.folderview_width +
1339 prefs_common.mainview_width,
1340 prefs_common.mainwin_height);
1341 gtk_widget_show_all(vpaned);
1343 mainwin->win.sep_none.hpaned = hpaned;
1344 mainwin->win.sep_none.vpaned = vpaned;
1346 case SEPARATE_FOLDER:
1347 vpaned = gtk_vpaned_new();
1348 if (mainwin->summaryview->msg_is_toggled_on) {
1349 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1351 gtk_paned_add1(GTK_PANED(vpaned),
1352 GTK_WIDGET_PTR(mainwin->summaryview));
1354 gtk_box_pack_start(GTK_BOX(vbox_body),
1355 GTK_WIDGET_PTR(mainwin->summaryview),
1357 gtk_widget_ref(vpaned);
1359 gtk_paned_add2(GTK_PANED(vpaned),
1360 GTK_WIDGET_PTR(mainwin->messageview));
1361 gtk_widget_show_all(vpaned);
1362 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1363 prefs_common.summaryview_width,
1364 prefs_common.summaryview_height);
1365 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1366 prefs_common.mainview_width, -1);
1367 gtk_widget_set_usize(mainwin->window,
1368 prefs_common.mainview_width,
1369 prefs_common.mainview_height);
1371 gtk_container_add(GTK_CONTAINER(folderwin),
1372 GTK_WIDGET_PTR(mainwin->folderview));
1374 mainwin->win.sep_folder.folderwin = folderwin;
1375 mainwin->win.sep_folder.vpaned = vpaned;
1377 gtk_widget_show_all(folderwin);
1379 case SEPARATE_MESSAGE:
1380 hpaned = gtk_hpaned_new();
1381 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1383 gtk_paned_add1(GTK_PANED(hpaned),
1384 GTK_WIDGET_PTR(mainwin->folderview));
1385 gtk_paned_add2(GTK_PANED(hpaned),
1386 GTK_WIDGET_PTR(mainwin->summaryview));
1387 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1388 prefs_common.summaryview_width,
1389 prefs_common.summaryview_height);
1390 gtk_widget_set_usize(mainwin->window,
1391 prefs_common.folderview_width +
1392 prefs_common.mainview_width,
1393 prefs_common.mainwin_height);
1394 gtk_widget_show_all(hpaned);
1395 gtk_container_add(GTK_CONTAINER(messagewin),
1396 GTK_WIDGET_PTR(mainwin->messageview));
1398 mainwin->win.sep_message.messagewin = messagewin;
1399 mainwin->win.sep_message.hpaned = hpaned;
1401 gtk_widget_show_all(messagewin);
1404 gtk_box_pack_start(GTK_BOX(vbox_body),
1405 GTK_WIDGET_PTR(mainwin->summaryview),
1407 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1408 prefs_common.summaryview_width,
1409 prefs_common.summaryview_height);
1410 gtk_widget_set_usize(mainwin->window,
1411 prefs_common.mainview_width,
1412 prefs_common.mainwin_height);
1413 gtk_container_add(GTK_CONTAINER(folderwin),
1414 GTK_WIDGET_PTR(mainwin->folderview));
1415 gtk_container_add(GTK_CONTAINER(messagewin),
1416 GTK_WIDGET_PTR(mainwin->messageview));
1418 mainwin->win.sep_both.folderwin = folderwin;
1419 mainwin->win.sep_both.messagewin = messagewin;
1421 gtk_widget_show_all(folderwin);
1422 gtk_widget_show_all(messagewin);
1426 mainwin->type = type;
1428 debug_print(_("done.\n"));
1431 #include "pixmaps/stock_mail_receive.xpm"
1432 #include "pixmaps/stock_mail_receive_all.xpm"
1433 #include "pixmaps/stock_mail_compose.xpm"
1434 #include "pixmaps/stock_news_compose.xpm"
1435 #include "pixmaps/stock_mail_reply.xpm"
1436 #include "pixmaps/stock_mail_reply_to_all.xpm"
1437 #include "pixmaps/stock_mail_reply_to_author.xpm"
1438 #include "pixmaps/stock_mail_forward.xpm"
1439 #include "pixmaps/stock_mail_send.xpm"
1440 #include "pixmaps/stock_preferences.xpm"
1441 #include "pixmaps/stock_properties.xpm"
1442 #include "pixmaps/stock_down_arrow.xpm"
1443 #include "pixmaps/stock_close.xpm"
1444 #include "pixmaps/stock_exec.xpm"
1446 #define CREATE_TOOLBAR_ICON(xpm_d) \
1448 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1449 &container->style->white, \
1451 icon_wid = gtk_pixmap_new(icon, mask); \
1454 static void main_window_toolbar_create(MainWindow *mainwin,
1455 GtkWidget *container)
1460 GtkWidget *icon_wid;
1462 GtkWidget *getall_btn;
1463 GtkWidget *compose_mail_btn;
1464 GtkWidget *compose_news_btn;
1465 GtkWidget *reply_btn;
1466 GtkWidget *replyall_btn;
1467 GtkWidget *replysender_btn;
1469 GtkWidget *send_btn;
1471 GtkWidget *prefs_btn;
1472 GtkWidget *account_btn;
1474 GtkWidget *next_btn;
1475 GtkWidget *delete_btn;
1476 GtkWidget *exec_btn;
1478 GtkWidget *compose_type_btn;
1479 GtkWidget *compose_type_arrow;
1480 GtkWidget *compose_box;
1481 GtkWidget *compose_label;
1483 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1485 gtk_container_add(GTK_CONTAINER(container), toolbar);
1486 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1487 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1488 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1489 GTK_TOOLBAR_SPACE_LINE);
1491 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1492 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1494 _("Get new mail from current account"),
1496 icon_wid, toolbar_inc_cb, mainwin);
1497 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1498 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1500 _("Get new mail from all accounts"),
1506 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1508 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1509 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1511 _("Send queued message(s)"),
1517 /* insert compose mail button widget */
1519 compose_mail_btn = gtk_button_new();
1520 gtk_widget_show(compose_mail_btn);
1522 compose_box = gtk_vbox_new(0, 0);
1523 gtk_widget_show(compose_box);
1525 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1526 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1527 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1529 compose_label = gtk_label_new(_("Compose email"));
1530 gtk_widget_show(compose_label);
1531 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1533 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1534 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1535 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1538 /* insert compose news button widget */
1540 compose_news_btn = gtk_button_new();
1541 gtk_widget_show(compose_news_btn);
1543 compose_box = gtk_vbox_new(0, 0);
1544 gtk_widget_show(compose_box);
1546 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1547 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1548 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1550 compose_label = gtk_label_new(_("Compose news"));
1551 gtk_widget_show(compose_label);
1552 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1554 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_news_btn), GTK_CAN_FOCUS);
1555 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1556 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1559 /* insert compose button type widget */
1561 compose_type_btn = gtk_button_new();
1562 gtk_widget_show(compose_type_btn);
1564 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1565 gtk_widget_show(compose_type_arrow);
1567 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1569 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1570 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1572 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1576 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1577 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1579 _("Compose a news message"),
1582 toolbar_compose_news_cb,
1586 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1588 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1589 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1591 _("Reply to the message"),
1596 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1597 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1602 toolbar_reply_to_all_cb,
1604 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1605 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1607 _("Reply to sender"),
1610 toolbar_reply_to_sender_cb,
1612 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1613 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1615 _("Forward the message"),
1621 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1623 CREATE_TOOLBAR_ICON(stock_close_xpm);
1624 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1626 _("Delete the message"),
1632 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1633 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1635 _("Execute marked process"),
1641 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1642 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1644 _("Next unread message"),
1647 toolbar_next_unread_cb,
1651 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1653 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1654 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1656 _("Common preference"),
1661 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1662 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1664 _("Account setting"),
1669 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1670 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1674 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1675 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1678 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1679 GTK_SIGNAL_FUNC(toolbar_compose_cb),
1682 mainwin->toolbar = toolbar;
1683 mainwin->get_btn = get_btn;
1684 mainwin->getall_btn = getall_btn;
1685 mainwin->compose_mail_btn = compose_mail_btn;
1686 mainwin->compose_news_btn = compose_news_btn;
1687 mainwin->reply_btn = reply_btn;
1688 mainwin->replyall_btn = replyall_btn;
1689 mainwin->replysender_btn = replysender_btn;
1690 mainwin->fwd_btn = fwd_btn;
1691 mainwin->send_btn = send_btn;
1693 mainwin->prefs_btn = prefs_btn;
1694 mainwin->account_btn = account_btn;
1696 mainwin->next_btn = next_btn;
1697 mainwin->delete_btn = delete_btn;
1698 mainwin->exec_btn = exec_btn;
1700 gtk_widget_show_all(toolbar);
1702 activate_compose_button(mainwin, COMPOSEBUTTON_MAIL);
1705 /* callback functions */
1707 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1710 MainWindow *mainwindow = (MainWindow *) data;
1711 GtkWidget *compose_menu, *compose_item;
1713 g_return_if_fail(mainwindow != NULL);
1715 compose_menu = gtk_menu_new();
1717 compose_item = gtk_menu_item_new_with_label(_("E-Mail message"));
1718 gtk_widget_show(compose_item);
1719 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1720 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1721 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1723 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1725 compose_item = gtk_menu_item_new_with_label(_("News article"));
1726 gtk_widget_show(compose_item);
1727 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1728 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1729 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1731 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1733 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1737 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1739 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1740 MainWindow *mainwindow = (MainWindow *) data;
1742 mainwindow->compose_btn_type = compose_type;
1744 activate_compose_button(mainwindow, mainwindow->compose_btn_type);
1747 static void toolbar_inc_cb (GtkWidget *widget,
1750 MainWindow *mainwin = (MainWindow *)data;
1752 inc_mail_cb(mainwin, 0, NULL);
1755 static void toolbar_inc_all_cb (GtkWidget *widget,
1758 MainWindow *mainwin = (MainWindow *)data;
1760 inc_all_account_mail_cb(mainwin, 0, NULL);
1763 static void toolbar_send_cb (GtkWidget *widget,
1766 MainWindow *mainwin = (MainWindow *)data;
1768 send_queue_cb(mainwin, 0, NULL);
1771 static void toolbar_compose_cb (GtkWidget *widget,
1774 MainWindow *mainwin = (MainWindow *)data;
1776 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1777 compose_cb(mainwin, 0, NULL);
1779 compose_news_cb(mainwin, 0, NULL);
1782 static void toolbar_compose_news_cb (GtkWidget *widget,
1785 MainWindow *mainwin = (MainWindow *)data;
1787 compose_news_cb(mainwin, 0, NULL);
1790 static void toolbar_compose_mail_cb (GtkWidget *widget,
1793 MainWindow *mainwin = (MainWindow *)data;
1795 compose_mail_cb(mainwin, 0, NULL);
1798 static void toolbar_reply_cb (GtkWidget *widget,
1801 MainWindow *mainwin = (MainWindow *)data;
1803 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1806 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1809 MainWindow *mainwin = (MainWindow *)data;
1811 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1814 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1817 MainWindow *mainwin = (MainWindow *)data;
1819 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1822 static void toolbar_forward_cb (GtkWidget *widget,
1825 MainWindow *mainwin = (MainWindow *)data;
1827 if (prefs_common.forward_as_attachment)
1828 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
1830 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1833 static void toolbar_delete_cb (GtkWidget *widget,
1836 MainWindow *mainwin = (MainWindow *)data;
1838 summary_delete(mainwin->summaryview);
1841 static void toolbar_exec_cb (GtkWidget *widget,
1844 MainWindow *mainwin = (MainWindow *)data;
1846 summary_execute(mainwin->summaryview);
1849 static void toolbar_next_unread_cb (GtkWidget *widget,
1852 MainWindow *mainwin = (MainWindow *)data;
1854 next_unread_cb(mainwin, 0, NULL);
1857 static void toolbar_prefs_cb (GtkWidget *widget,
1860 prefs_common_open();
1863 static void toolbar_account_cb (GtkWidget *widget,
1866 MainWindow *mainwin = (MainWindow *)data;
1868 prefs_account_open_cb(mainwin, 0, NULL);
1871 static void toolbar_account_button_pressed(GtkWidget *widget,
1872 GdkEventButton *event,
1875 MainWindow *mainwin = (MainWindow *)data;
1878 if (event->button != 3) return;
1880 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1881 event->button, event->time);
1884 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1887 MainWindow *mainwin = (MainWindow *)data;
1891 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1892 event->button, event->time);
1895 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1898 app_exit_cb(data, 0, widget);
1903 static void add_mailbox_cb(MainWindow *mainwin, guint action,
1906 main_window_add_mailbox(mainwin);
1909 static void add_mbox_cb(MainWindow *mainwin, guint action,
1912 main_window_add_mbox(mainwin);
1915 static void update_folderview_cb(MainWindow *mainwin, guint action,
1918 summary_show(mainwin->summaryview, NULL, FALSE);
1919 folderview_update_all();
1922 static void new_folder_cb(MainWindow *mainwin, guint action,
1925 folderview_new_folder(mainwin->folderview);
1928 static void rename_folder_cb(MainWindow *mainwin, guint action,
1931 folderview_rename_folder(mainwin->folderview);
1934 static void delete_folder_cb(MainWindow *mainwin, guint action,
1937 folderview_delete_folder(mainwin->folderview);
1940 static void import_mbox_cb(MainWindow *mainwin, guint action,
1943 import_mbox(mainwin->summaryview->folder_item);
1946 static void export_mbox_cb(MainWindow *mainwin, guint action,
1949 export_mbox(mainwin->summaryview->folder_item);
1952 static void empty_trash_cb(MainWindow *mainwin, guint action,
1955 main_window_empty_trash(mainwin, TRUE);
1958 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1960 summary_save_as(mainwin->summaryview);
1963 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1965 summary_print(mainwin->summaryview);
1968 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1970 if (prefs_common.confirm_on_exit) {
1971 if (alertpanel(_("Exit"), _("Exit this program?"),
1972 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
1974 manage_window_focus_in(mainwin->window, NULL, NULL);
1977 app_will_exit(widget, mainwin);
1980 static void toggle_folder_cb(MainWindow *mainwin, guint action,
1983 switch (mainwin->type) {
1985 case SEPARATE_MESSAGE:
1987 case SEPARATE_FOLDER:
1988 if (GTK_CHECK_MENU_ITEM(widget)->active)
1989 gtk_widget_show(mainwin->win.sep_folder.folderwin);
1991 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1994 if (GTK_CHECK_MENU_ITEM(widget)->active)
1995 gtk_widget_show(mainwin->win.sep_both.folderwin);
1997 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2002 static void toggle_message_cb(MainWindow *mainwin, guint action,
2005 switch (mainwin->type) {
2007 case SEPARATE_FOLDER:
2009 case SEPARATE_MESSAGE:
2010 if (GTK_CHECK_MENU_ITEM(widget)->active)
2011 gtk_widget_show(mainwin->win.sep_message.messagewin);
2013 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2016 if (GTK_CHECK_MENU_ITEM(widget)->active)
2017 gtk_widget_show(mainwin->win.sep_both.messagewin);
2019 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2024 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2027 switch ((ToolbarStyle)action) {
2029 gtk_widget_hide(mainwin->handlebox);
2031 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2035 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2039 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2044 if (action != TOOLBAR_NONE) {
2045 gtk_widget_show(mainwin->handlebox);
2046 gtk_widget_queue_resize(mainwin->handlebox);
2049 mainwin->toolbar_style = (ToolbarStyle)action;
2050 prefs_common.toolbar_style = (ToolbarStyle)action;
2053 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2056 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2057 gtk_widget_show(mainwin->hbox_stat);
2058 prefs_common.show_statusbar = TRUE;
2060 gtk_widget_hide(mainwin->hbox_stat);
2061 prefs_common.show_statusbar = FALSE;
2065 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action)
2067 MainWindow *mainwin;
2070 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2071 g_return_if_fail(mainwin != NULL);
2073 type = mainwin->type ^ action;
2074 main_window_separation_change(mainwin, type);
2076 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2077 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2080 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2083 addressbook_open(NULL);
2086 static void log_window_show_cb(MainWindow *mainwin, guint action,
2089 log_window_show(mainwin->logwin);
2092 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2097 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2100 inc_all_account_mail(mainwin);
2103 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2107 if (procmsg_send_queue() < 0)
2108 alertpanel_error(_("Sending queued message failed."));
2110 statusbar_pop_all();
2112 for (list = folder_get_list(); list != NULL; list = list->next) {
2115 folder = list->data;
2116 if (folder->queue) {
2117 folder_item_scan(folder->queue);
2118 folderview_update_item(folder->queue, TRUE);
2123 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2125 if (mainwin->summaryview->folder_item) {
2126 if (mainwin->summaryview->folder_item->folder->account != NULL
2127 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2128 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2130 compose_new(mainwin->summaryview->folder_item->folder->account);
2136 static void compose_mail_cb(MainWindow *mainwin, guint action,
2143 if (mainwin->summaryview->folder_item) {
2144 ac = mainwin->summaryview->folder_item->folder->account;
2145 if (ac && ac->protocol != A_NNTP) {
2151 list = account_get_list();
2152 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2153 ac = (PrefsAccount *) cur->data;
2154 if (ac->protocol != A_NNTP) {
2161 static void compose_news_cb(MainWindow *mainwin, guint action,
2164 PrefsAccount * ac = NULL;
2168 if (mainwin->summaryview->folder_item) {
2169 ac = mainwin->summaryview->folder_item->folder->account;
2170 if (ac && ac->protocol == A_NNTP) {
2171 compose_new_with_recipient
2172 (ac, mainwin->summaryview->folder_item->path);
2177 list = account_get_list();
2178 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2179 ac = (PrefsAccount *) cur->data;
2180 if (ac->protocol == A_NNTP) {
2187 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2191 msginfo = gtk_ctree_node_get_row_data
2192 (GTK_CTREE(mainwin->summaryview->ctree),
2193 mainwin->summaryview->selected);
2195 if (!msginfo) return;
2199 compose_reply(msginfo, prefs_common.reply_with_quote,
2202 case COMPOSE_REPLY_TO_SENDER:
2203 compose_reply(msginfo, prefs_common.reply_with_quote,
2206 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2207 compose_followup_and_reply_to(msginfo,
2208 prefs_common.reply_with_quote,
2211 case COMPOSE_REPLY_TO_ALL:
2212 compose_reply(msginfo, prefs_common.reply_with_quote,
2215 case COMPOSE_FORWARD:
2216 compose_forward(NULL, msginfo, FALSE);
2218 case COMPOSE_FORWARD_AS_ATTACH:
2219 compose_forward(NULL, msginfo, TRUE);
2222 g_warning("reply_cb(): invalid action type: %d\n", action);
2225 summary_set_marks_selected(mainwin->summaryview);
2228 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2230 summary_move_to(mainwin->summaryview);
2233 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2235 summary_copy_to(mainwin->summaryview);
2238 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2240 summary_delete(mainwin->summaryview);
2243 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2245 summary_open_msg(mainwin->summaryview);
2248 static void view_source_cb(MainWindow *mainwin, guint action,
2251 summary_view_source(mainwin->summaryview);
2254 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2256 summary_reedit(mainwin->summaryview);
2259 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2261 summary_mark(mainwin->summaryview);
2264 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2266 summary_unmark(mainwin->summaryview);
2269 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2272 summary_mark_as_unread(mainwin->summaryview);
2275 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2278 summary_mark_as_read(mainwin->summaryview);
2281 static void set_charset_cb(MainWindow *mainwin, guint action,
2286 str = conv_get_charset_str((CharSet)action);
2287 g_free(prefs_common.force_charset);
2288 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2290 summary_redisplay_msg(mainwin->summaryview);
2292 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2295 void main_window_set_thread_option(MainWindow *mainwin)
2297 GtkItemFactory *ifactory;
2298 gboolean no_item = FALSE;
2300 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2302 if (mainwin->summaryview == NULL)
2304 else if (mainwin->summaryview->folder_item == NULL)
2308 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2309 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2312 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2313 menu_set_sensitive(ifactory,
2314 "/Summary/Thread view", FALSE);
2315 menu_set_sensitive(ifactory,
2316 "/Summary/Unthread view", TRUE);
2317 summary_thread_build(mainwin->summaryview);
2320 menu_set_sensitive(ifactory,
2321 "/Summary/Thread view", TRUE);
2322 menu_set_sensitive(ifactory,
2323 "/Summary/Unthread view", FALSE);
2324 summary_unthread(mainwin->summaryview);
2326 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2330 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2332 mainwin->summaryview->folder_item->prefs->enable_thread =
2333 !mainwin->summaryview->folder_item->prefs->enable_thread;
2334 main_window_set_thread_option(mainwin);
2338 summary_thread_build(mainwin->summaryview);
2339 mainwin->summaryview->folder_item->prefs->enable_thread =
2341 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2342 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2344 summary_unthread(mainwin->summaryview);
2345 mainwin->summaryview->folder_item->prefs->enable_thread =
2347 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2348 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2353 static void set_display_item_cb(MainWindow *mainwin, guint action,
2356 prefs_summary_display_item_set();
2359 static void sort_summary_cb(MainWindow *mainwin, guint action,
2362 summary_sort(mainwin->summaryview, (SummarySortType)action);
2365 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2368 summary_attract_by_subject(mainwin->summaryview);
2371 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2374 summary_delete_duplicated(mainwin->summaryview);
2377 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2379 summary_filter(mainwin->summaryview);
2382 static void execute_summary_cb(MainWindow *mainwin, guint action,
2385 summary_execute(mainwin->summaryview);
2388 static void update_summary_cb(MainWindow *mainwin, guint action,
2392 FolderView *folderview = mainwin->folderview;
2394 if (!mainwin->summaryview->folder_item) return;
2395 if (!folderview->opened) return;
2397 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2398 folderview->opened);
2401 summary_show(mainwin->summaryview, fitem, TRUE);
2404 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2406 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2409 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2411 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2414 static void next_unread_cb(MainWindow *mainwin, guint action,
2417 summary_select_next_unread(mainwin->summaryview);
2420 static void next_marked_cb(MainWindow *mainwin, guint action,
2423 summary_select_next_marked(mainwin->summaryview);
2426 static void prev_marked_cb(MainWindow *mainwin, guint action,
2429 summary_select_prev_marked(mainwin->summaryview);
2432 static void goto_folder_cb(MainWindow *mainwin, guint action,
2435 FolderItem *to_folder;
2437 to_folder = foldersel_folder_sel(NULL, NULL);
2440 folderview_select(mainwin->folderview, to_folder);
2443 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2445 messageview_copy_clipboard(mainwin->messageview);
2448 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2450 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2451 summary_select_all(mainwin->summaryview);
2452 else if (mainwin->summaryview->msg_is_toggled_on &&
2453 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2454 messageview_select_all(mainwin->messageview);
2457 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2460 prefs_common_open();
2463 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2466 prefs_filter_open();
2469 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2472 prefs_scoring_open(NULL);
2475 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2478 prefs_filtering_open();
2481 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2485 new_account_cb(mainwin, 0, widget);
2487 gboolean prev_default = cur_account->is_default;
2489 prefs_account_open(cur_account);
2490 if (!prev_default && cur_account->is_default)
2491 account_set_as_default(cur_account);
2492 account_save_config_all();
2494 main_window_reflect_prefs_all();
2498 static void new_account_cb(MainWindow *mainwin, guint action,
2501 account_edit_open();
2502 if (!compose_get_compose_list()) account_add();
2505 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2507 cur_account = (PrefsAccount *)data;
2508 main_window_reflect_prefs_all();
2511 static void manual_open_cb(MainWindow *mainwin, guint action,
2514 manual_open((ManualLang)action);
2517 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2519 MainWindow *mainwin = (MainWindow *)data;
2523 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2524 LOCAL_FOLDER(folder)->rootpath,
2528 str = g_strdup_printf(_("Scanning folder %s ..."),
2529 LOCAL_FOLDER(folder)->rootpath);
2531 STATUSBAR_PUSH(mainwin, str);
2532 STATUSBAR_POP(mainwin);
2536 static void activate_compose_button (MainWindow *mainwin,
2537 ComposeButtonType type)
2539 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2540 : mainwin->compose_news_btn);
2541 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2542 : mainwin->compose_mail_btn);
2543 mainwin->compose_btn_type = type;