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,
365 ComposeButtonType type);
367 #define SEPARATE_ACTION 667
369 static GtkItemFactoryEntry mainwin_entries[] =
371 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
372 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
373 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
374 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
375 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
376 {N_("/_File/_Folder/Create _new folder..."),
377 NULL, new_folder_cb, 0, NULL},
378 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
379 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
380 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
381 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
382 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
383 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
384 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
385 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
386 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
387 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
388 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
390 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
391 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
392 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
393 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
394 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
396 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
397 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
398 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
399 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
400 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
401 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
402 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
403 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
404 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
405 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
406 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
407 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
408 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
409 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
410 {N_("/_View/_Code set/_Auto detect"),
411 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
413 #define CODESET_SEPARATOR \
414 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
415 #define CODESET_ACTION(action) \
416 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
418 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
419 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
420 CODESET_ACTION(C_US_ASCII)},
423 {N_("/_View/_Code set/Unicode (_UTF-8)"),
424 CODESET_ACTION(C_UTF_8)},
427 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
428 CODESET_ACTION(C_ISO_8859_1)},
431 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
432 CODESET_ACTION(C_ISO_8859_2)},
434 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
435 CODESET_ACTION(C_ISO_8859_13)},
436 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
437 CODESET_ACTION(C_ISO_8859_4)},
439 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
440 CODESET_ACTION(C_ISO_8859_7)},
442 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
443 CODESET_ACTION(C_ISO_8859_9)},
445 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
446 CODESET_ACTION(C_ISO_8859_5)},
447 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
448 CODESET_ACTION(C_KOI8_R)},
449 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
450 CODESET_ACTION(C_CP1251)},
453 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
454 CODESET_ACTION(C_ISO_2022_JP)},
456 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
457 CODESET_ACTION(C_ISO_2022_JP_2)},
459 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
460 CODESET_ACTION(C_EUC_JP)},
461 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
462 CODESET_ACTION(C_SHIFT_JIS)},
465 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
466 CODESET_ACTION(C_GB2312)},
467 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
468 CODESET_ACTION(C_BIG5)},
469 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
470 CODESET_ACTION(C_EUC_TW)},
471 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
472 CODESET_ACTION(C_ISO_2022_CN)},
474 {N_("/_View/_Code set/Korean (EUC-_KR)"),
475 CODESET_ACTION(C_EUC_KR)},
476 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
477 CODESET_ACTION(C_ISO_2022_KR)},
480 #undef CODESET_SEPARATOR
481 #undef CODESET_ACTION
483 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
484 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
485 {N_("/_Message/Get from _all accounts"),
486 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
487 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
488 {N_("/_Message/Send queued messa_ges"),
489 NULL, send_queue_cb, 0, NULL},
490 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
491 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
492 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
493 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
494 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
495 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
496 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
497 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
498 {N_("/_Message/Forward as a_ttachment"),
499 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
500 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
501 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
502 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
503 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
504 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
505 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
506 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
507 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
508 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
509 {N_("/_Message/_Mark/Mark as rea_d"),
510 NULL, mark_as_read_cb, 0, NULL},
511 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
513 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
514 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
515 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
517 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
518 {N_("/_Summary/_Delete duplicated messages"),
519 NULL, delete_duplicated_cb, 0, NULL},
520 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
521 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
522 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
523 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
525 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
526 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
527 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
528 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
529 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
530 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
531 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
532 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
533 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
534 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
535 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
536 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
537 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
538 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
539 {N_("/_Summary/_Sort/Sort by _label"), NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
540 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_Summary/_Sort/_Attract by subject"),
542 NULL, attract_by_subject_cb, 0, NULL},
543 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
544 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
545 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
547 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
548 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
549 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
551 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
552 {N_("/_Configuration/_Common preferences..."),
553 NULL, prefs_common_open_cb, 0, NULL},
554 {N_("/_Configuration/_Filter setting..."),
555 NULL, prefs_filter_open_cb, 0, NULL},
556 {N_("/_Configuration/_Scoring ..."),
557 NULL, prefs_scoring_open_cb, 0, NULL},
558 {N_("/_Configuration/_Filtering ..."),
559 NULL, prefs_filtering_open_cb, 0, NULL},
560 {N_("/_Configuration/_Preferences per account..."),
561 NULL, prefs_account_open_cb, 0, NULL},
562 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_Configuration/Create _new account..."),
564 NULL, new_account_cb, 0, NULL},
565 {N_("/_Configuration/_Edit accounts..."),
566 NULL, account_edit_open, 0, NULL},
567 {N_("/_Configuration/C_hange current account"),
568 NULL, NULL, 0, "<Branch>"},
570 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
571 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
572 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
573 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
574 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
575 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
578 MainWindow *main_window_create(SeparateType type)
584 GtkWidget *handlebox;
585 GtkWidget *vbox_body;
586 GtkWidget *hbox_stat;
587 GtkWidget *statusbar;
588 GtkWidget *ac_button;
591 FolderView *folderview;
592 SummaryView *summaryview;
593 MessageView *messageview;
594 GdkColormap *colormap;
597 guint n_menu_entries;
598 GtkItemFactory *ifactory;
603 debug_print(_("Creating main window...\n"));
604 mainwin = g_new0(MainWindow, 1);
607 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
608 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
609 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
610 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
611 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
612 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
613 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
614 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
615 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
616 gtk_widget_realize(window);
618 vbox = gtk_vbox_new(FALSE, 0);
619 gtk_widget_show(vbox);
620 gtk_container_add(GTK_CONTAINER(window), vbox);
623 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
624 menubar = menubar_create(window, mainwin_entries,
625 n_menu_entries, "<Main>", mainwin);
626 gtk_widget_show(menubar);
627 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
629 handlebox = gtk_handle_box_new();
630 gtk_widget_show(handlebox);
631 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
633 main_window_toolbar_create(mainwin, handlebox);
635 /* vbox that contains body */
636 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
637 gtk_widget_show(vbox_body);
638 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
639 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
641 hbox_stat = gtk_hbox_new(FALSE, 2);
642 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
644 statusbar = statusbar_create();
645 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
647 ac_button = gtk_button_new();
648 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
649 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
650 gtk_widget_set_usize(ac_button, -1, 1);
651 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
652 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
653 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
655 ac_label = gtk_label_new("");
656 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
658 gtk_widget_show_all(hbox_stat);
661 mainwin->folderview = folderview = folderview_create();
662 mainwin->summaryview = summaryview = summary_create();
663 mainwin->messageview = messageview = messageview_create();
664 mainwin->headerwin = header_window_create();
665 mainwin->logwin = log_window_create();
667 folderview->mainwin = mainwin;
668 folderview->summaryview = summaryview;
670 summaryview->mainwin = mainwin;
671 summaryview->folderview = folderview;
672 summaryview->messageview = messageview;
673 summaryview->headerwin = mainwin->headerwin;
674 summaryview->window = window;
676 messageview->mainwin = mainwin;
678 mainwin->window = window;
679 mainwin->vbox = vbox;
680 mainwin->menubar = menubar;
681 mainwin->handlebox = handlebox;
682 mainwin->vbox_body = vbox_body;
683 mainwin->hbox_stat = hbox_stat;
684 mainwin->statusbar = statusbar;
685 mainwin->ac_button = ac_button;
686 mainwin->ac_label = ac_label;
688 /* set context IDs for status bar */
689 mainwin->mainwin_cid = gtk_statusbar_get_context_id
690 (GTK_STATUSBAR(statusbar), "Main Window");
691 mainwin->folderview_cid = gtk_statusbar_get_context_id
692 (GTK_STATUSBAR(statusbar), "Folder View");
693 mainwin->summaryview_cid = gtk_statusbar_get_context_id
694 (GTK_STATUSBAR(statusbar), "Summary View");
696 /* allocate colors for summary view and folder view */
697 summaryview->color_marked.red = summaryview->color_marked.green = 0;
698 summaryview->color_marked.blue = (guint16)65535;
700 summaryview->color_dim.red = summaryview->color_dim.green =
701 summaryview->color_dim.blue = COLOR_DIM;
703 folderview->color_new.red = (guint16)55000;
704 folderview->color_new.green = folderview->color_new.blue = 15000;
706 summaryview->color_important.red = 0;
707 summaryview->color_marked.green = 0;
708 summaryview->color_important.blue = (guint16)65535;
710 color[0] = summaryview->color_marked;
711 color[1] = summaryview->color_dim;
712 color[2] = folderview->color_new;
714 colormap = gdk_window_get_colormap(window->window);
715 gdk_colormap_alloc_colors(colormap, color, 3, FALSE, TRUE, success);
716 for (i = 0; i < 3; i++) {
717 if (success[i] == FALSE)
718 g_warning(_("MainWindow: color allocation %d failed\n"), i);
721 debug_print(_("done.\n"));
723 main_window_set_widgets(mainwin, type);
726 ifactory = gtk_item_factory_from_widget(menubar);
727 menuitem = gtk_item_factory_get_item
728 (ifactory, "/View/Code set/Auto detect");
729 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
731 switch (prefs_common.toolbar_style) {
733 menuitem = gtk_item_factory_get_item
734 (ifactory, "/View/Toolbar/None");
737 menuitem = gtk_item_factory_get_item
738 (ifactory, "/View/Toolbar/Icon");
741 menuitem = gtk_item_factory_get_item
742 (ifactory, "/View/Toolbar/Text");
745 menuitem = gtk_item_factory_get_item
746 (ifactory, "/View/Toolbar/Icon and text");
748 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
750 gtk_widget_hide(mainwin->hbox_stat);
751 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
752 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
753 prefs_common.show_statusbar);
755 /* set the check of the SEPARATE_xxx menu items. we also need the main window
756 * as a property and pass the action type to the callback */
757 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
759 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
760 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
761 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
762 GUINT_TO_POINTER(SEPARATE_FOLDER));
764 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
766 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
767 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
768 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
769 GUINT_TO_POINTER(SEPARATE_MESSAGE));
772 menu_set_sensitive(ifactory, "/Summary/Thread view",
773 prefs_common.enable_thread ? FALSE : TRUE);
774 menu_set_sensitive(ifactory, "/Summary/Unthread view",
775 prefs_common.enable_thread ? TRUE : FALSE);
777 main_window_set_thread_option(mainwin);
779 /* menu_set_sensitive(ifactory, "/Help/Manual/English", FALSE); */
781 /* set account selection menu */
782 ac_menu = gtk_item_factory_get_widget
783 (ifactory, "/Configuration/Change current account");
784 mainwin->ac_menu = ac_menu;
786 main_window_set_toolbar_sensitive(mainwin, FALSE);
788 /* show main window */
789 gtk_widget_set_uposition(mainwin->window,
790 prefs_common.mainwin_x,
791 prefs_common.mainwin_y);
792 gtk_widget_set_usize(window, prefs_common.mainwin_width,
793 prefs_common.mainwin_height);
794 gtk_widget_show(mainwin->window);
796 /* initialize views */
797 folderview_init(folderview);
798 summary_init(summaryview);
799 messageview_init(messageview);
800 header_window_init(mainwin->headerwin);
801 log_window_init(mainwin->logwin);
806 gtk_widget_ensure_style(folderview->ctree);
807 newstyle = gtk_widget_get_style(folderview->ctree);
808 newstyle = gtk_style_copy(newstyle);
809 gtk_widget_set_style(summaryview->ctree, newstyle);
810 gtk_widget_ensure_style(summaryview->ctree);
811 gtk_widget_realize(summaryview->ctree);
814 mainwin->cursor_count = 0;
817 watch_cursor = gdk_cursor_new(GDK_WATCH);
819 mainwin_list = g_list_append(mainwin_list, mainwin);
824 void main_window_cursor_wait(MainWindow *mainwin)
826 if (mainwin->cursor_count == 0)
827 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
829 mainwin->cursor_count++;
834 void main_window_cursor_normal(MainWindow *mainwin)
836 if (mainwin->cursor_count)
837 mainwin->cursor_count--;
839 if (mainwin->cursor_count == 0)
840 gdk_window_set_cursor(mainwin->window->window, NULL);
845 void main_window_reflect_prefs_all(void)
850 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
851 mainwin = (MainWindow *)cur->data;
853 main_window_show_cur_account(mainwin);
855 gtk_widget_set_sensitive(mainwin->get_btn, TRUE);
856 gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
858 gtk_widget_set_sensitive(mainwin->get_btn, FALSE);
859 gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
862 if (prefs_common.immediate_exec)
863 gtk_widget_hide(mainwin->exec_btn);
865 gtk_widget_show(mainwin->exec_btn);
867 summary_change_display_item(mainwin->summaryview);
868 summary_redisplay_msg(mainwin->summaryview);
869 headerview_set_visibility(mainwin->messageview->headerview,
870 prefs_common.display_header_pane);
874 void main_window_set_account_menu(GList *account_list)
876 GList *cur, *cur_ac, *cur_item;
879 PrefsAccount *ac_prefs;
881 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
882 mainwin = (MainWindow *)cur->data;
884 /* destroy all previous menu item */
885 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
886 while (cur_item != NULL) {
887 GList *next = cur_item->next;
888 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
892 for (cur_ac = account_list; cur_ac != NULL;
893 cur_ac = cur_ac->next) {
894 ac_prefs = (PrefsAccount *)cur_ac->data;
896 menuitem = gtk_menu_item_new_with_label
897 (ac_prefs->account_name
898 ? ac_prefs->account_name : _("Untitled"));
899 gtk_widget_show(menuitem);
900 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
901 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
902 GTK_SIGNAL_FUNC(account_menu_cb),
908 static void main_window_show_cur_account(MainWindow *mainwin)
913 ac_name = g_strdup(cur_account
914 ? (cur_account->account_name
915 ? cur_account->account_name : _("Untitled"))
919 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
921 buf = g_strdup(PROG_VERSION);
922 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
925 buf = g_strdup_printf(_("Current account: %s"), ac_name);
926 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
927 gtk_widget_queue_resize(mainwin->ac_button);
933 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
935 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
936 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
937 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
939 if (mainwin->type == type) return;
941 /* remove widgets from those containers */
942 gtk_widget_ref(folder_wid);
943 gtk_widget_ref(summary_wid);
944 gtk_widget_ref(message_wid);
946 (GTK_CONTAINER(folder_wid->parent), folder_wid);
948 (GTK_CONTAINER(summary_wid->parent), summary_wid);
950 (GTK_CONTAINER(message_wid->parent), message_wid);
952 /* clean containers */
953 switch (mainwin->type) {
955 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
957 case SEPARATE_FOLDER:
958 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
959 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
961 case SEPARATE_MESSAGE:
962 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
963 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
966 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
967 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
971 gtk_widget_hide(mainwin->window);
972 main_window_set_widgets(mainwin, type);
973 gtk_widget_show(mainwin->window);
975 gtk_widget_unref(folder_wid);
976 gtk_widget_unref(summary_wid);
977 gtk_widget_unref(message_wid);
980 void main_window_get_size(MainWindow *mainwin)
982 GtkAllocation *allocation;
984 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
986 prefs_common.summaryview_width = allocation->width;
988 if (mainwin->summaryview->msg_is_toggled_on)
989 prefs_common.summaryview_height = allocation->height;
991 prefs_common.mainview_width = allocation->width;
993 allocation = &mainwin->window->allocation;
995 prefs_common.mainview_height = allocation->height;
996 prefs_common.mainwin_width = allocation->width;
997 prefs_common.mainwin_height = allocation->height;
999 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1001 prefs_common.folderview_width = allocation->width;
1002 prefs_common.folderview_height = allocation->height;
1005 void main_window_get_position(MainWindow *mainwin)
1009 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1011 prefs_common.mainview_x = x;
1012 prefs_common.mainview_y = y;
1013 prefs_common.mainwin_x = x;
1014 prefs_common.mainwin_y = y;
1016 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1019 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1024 if (alertpanel(_("Empty trash"),
1025 _("Empty all messages in trash?"),
1026 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1028 manage_window_focus_in(mainwin->window, NULL, NULL);
1031 procmsg_empty_trash();
1033 for (list = folder_get_list(); list != NULL; list = list->next) {
1036 folder = list->data;
1037 if (folder->trash) {
1038 folder_item_scan(folder->trash);
1039 folderview_update_item(folder->trash, TRUE);
1043 if (mainwin->summaryview->folder_item &&
1044 mainwin->summaryview->folder_item->stype == F_TRASH)
1045 gtk_widget_grab_focus(mainwin->folderview->ctree);
1048 void main_window_add_mailbox(MainWindow *mainwin)
1053 path = input_dialog(_("Add mailbox"),
1054 _("Input the location of mailbox.\n"
1055 "If the existing mailbox is specified, it will be\n"
1056 "scanned automatically."),
1059 if (folder_find_from_path(path)) {
1060 alertpanel_error(_("The mailbox `%s' already exists."), path);
1065 if (!strcmp(path, "Mail"))
1066 folder = folder_new(F_MH, _("Mailbox"), path);
1068 folder = folder_new(F_MH, g_basename(path), path);
1072 if (folder->create_tree(folder) < 0) {
1073 alertpanel_error(_("Creation of the mailbox failed.\n"
1074 "Maybe some files already exist, or you don't have the permission to write there."));
1075 folder_destroy(folder);
1080 folder_set_ui_func(folder, scan_tree_func, mainwin);
1081 folder->scan_tree(folder);
1082 folder_set_ui_func(folder, NULL, NULL);
1084 folderview_set(mainwin->folderview);
1087 void main_window_add_mbox(MainWindow *mainwin)
1093 path = input_dialog(_("Add mbox mailbox"),
1094 _("Input the location of mailbox."),
1099 if (folder_find_from_path(path)) {
1100 alertpanel_error(_("The mailbox `%s' already exists."), path);
1106 if (!strcmp(path, "Mail"))
1107 folder = folder_new(F_MBOX, _("Mailbox"), path);
1111 folder = folder_new(F_MBOX, g_basename(path), path);
1114 if (folder->create_tree(folder) < 0) {
1115 alertpanel_error(_("Creation of the mailbox failed."));
1116 folder_destroy(folder);
1122 item = folder_item_new(folder->name, NULL);
1123 item->folder = folder;
1124 folder->node = g_node_new(item);
1126 folder->create_folder(folder, item, "inbox");
1127 folder->create_folder(folder, item, "outbox");
1128 folder->create_folder(folder, item, "queue");
1129 folder->create_folder(folder, item, "draft");
1130 folder->create_folder(folder, item, "trash");
1132 folderview_set(mainwin->folderview);
1135 void main_window_set_toolbar_sensitive(MainWindow *mainwin, gboolean sensitive)
1137 gtk_widget_set_sensitive(mainwin->reply_btn, sensitive);
1138 gtk_widget_set_sensitive(mainwin->replyall_btn, sensitive);
1139 gtk_widget_set_sensitive(mainwin->replysender_btn, sensitive);
1140 gtk_widget_set_sensitive(mainwin->fwd_btn, sensitive);
1141 gtk_widget_set_sensitive(mainwin->exec_btn, sensitive);
1142 gtk_widget_set_sensitive(mainwin->next_btn, sensitive);
1144 if (!mainwin->summaryview->folder_item ||
1145 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1146 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1148 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1151 void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
1153 GtkItemFactory *ifactory;
1157 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1159 if (selection == SUMMARY_SELECTED_SINGLE)
1163 if (!mainwin->summaryview->folder_item ||
1164 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1169 menu_set_sensitive(ifactory, "/File/Save as...", sens);
1170 menu_set_sensitive(ifactory, "/Message/Reply", sens);
1171 menu_set_sensitive(ifactory, "/Message/Reply to sender", sens);
1172 menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
1173 menu_set_sensitive(ifactory, "/Message/Forward", TRUE);
1174 menu_set_sensitive(ifactory, "/Message/Forward as attachment", TRUE);
1175 menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
1176 menu_set_sensitive(ifactory, "/Message/Show all header", sens);
1177 menu_set_sensitive(ifactory, "/Message/View source", sens);
1178 if (sens && (!mainwin->summaryview->folder_item ||
1179 mainwin->summaryview->folder_item->stype != F_DRAFT))
1181 menu_set_sensitive(ifactory, "/Message/Re-edit", sens);
1183 if (selection == SUMMARY_SELECTED_SINGLE ||
1184 selection == SUMMARY_SELECTED_MULTIPLE)
1189 menu_set_sensitive(ifactory, "/File/Print..." , sens);
1190 menu_set_sensitive(ifactory, "/Message/Move...", sens && exec);
1191 menu_set_sensitive(ifactory, "/Message/Copy...", sens && exec);
1192 menu_set_sensitive(ifactory, "/Message/Delete" , sens && exec);
1193 menu_set_sensitive(ifactory, "/Message/Mark" , sens);
1195 if (selection != SUMMARY_NONE)
1200 menu_set_sensitive(ifactory, "/Summary/Delete duplicated messages", sens && exec);
1201 menu_set_sensitive(ifactory, "/Summary/Filter messages", sens && exec);
1202 menu_set_sensitive(ifactory, "/Summary/Execute", sens);
1203 menu_set_sensitive(ifactory, "/Summary/Prev message", sens);
1204 menu_set_sensitive(ifactory, "/Summary/Next message", sens);
1205 menu_set_sensitive(ifactory, "/Summary/Next unread message", sens);
1206 menu_set_sensitive(ifactory, "/Summary/Sort", sens);
1208 if (mainwin->summaryview->folder_item &&
1209 mainwin->summaryview->folder_item->folder->account)
1210 sens = mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP;
1213 menu_set_sensitive(ifactory, "/Message/Follow-up and reply to", sens);
1216 void main_window_popup(MainWindow *mainwin)
1222 gdk_window_get_origin(mainwin->window->window, &x, &y);
1223 sx = gdk_screen_width();
1224 sy = gdk_screen_height();
1225 x %= sx; if (x < 0) x += sx;
1226 y %= sy; if (y < 0) y += sy;
1227 gdk_window_move(mainwin->window->window, x, y);
1228 gdk_window_raise(mainwin->window->window);
1230 debug_print("window position: x = %d, y = %d\n", x, y);
1232 switch (mainwin->type) {
1233 case SEPARATE_FOLDER:
1234 widget = mainwin->win.sep_folder.folderwin;
1235 gdk_window_get_origin(widget->window, &x, &y);
1236 x %= sx; if (x < 0) x += sx;
1237 y %= sy; if (y < 0) y += sy;
1238 gdk_window_move(widget->window, x, y);
1239 gdk_window_raise(widget->window);
1241 case SEPARATE_MESSAGE:
1242 widget = mainwin->win.sep_message.messagewin;
1243 gdk_window_get_origin(widget->window, &x, &y);
1244 x %= sx; if (x < 0) x += sx;
1245 y %= sy; if (y < 0) y += sy;
1246 gdk_window_move(widget->window, x, y);
1247 gdk_window_raise(widget->window);
1250 widget = mainwin->win.sep_both.folderwin;
1251 gdk_window_get_origin(widget->window, &x, &y);
1252 x %= sx; if (x < 0) x += sx;
1253 y %= sy; if (y < 0) y += sy;
1254 gdk_window_move(widget->window, x, y);
1255 gdk_window_raise(widget->window);
1256 widget = mainwin->win.sep_both.messagewin;
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);
1268 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1270 GtkWidget *folderwin = NULL;
1271 GtkWidget *messagewin = NULL;
1274 GtkWidget *vbox_body = mainwin->vbox_body;
1276 debug_print(_("Setting widgets..."));
1278 /* create separated window(s) if needed */
1279 if (type & SEPARATE_FOLDER) {
1280 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1281 gtk_window_set_policy(GTK_WINDOW(folderwin),
1283 gtk_widget_set_usize(folderwin, -1,
1284 prefs_common.mainview_height);
1285 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1287 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1288 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1291 if (type & SEPARATE_MESSAGE) {
1292 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1293 gtk_window_set_policy(GTK_WINDOW(messagewin),
1295 gtk_widget_set_usize
1296 (messagewin, prefs_common.mainview_width,
1297 prefs_common.mainview_height
1298 - prefs_common.summaryview_height
1299 + DEFAULT_HEADERVIEW_HEIGHT);
1300 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1302 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1303 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1309 hpaned = gtk_hpaned_new();
1310 gtk_widget_show(hpaned);
1311 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1312 gtk_paned_add1(GTK_PANED(hpaned),
1313 GTK_WIDGET_PTR(mainwin->folderview));
1315 vpaned = gtk_vpaned_new();
1316 if (mainwin->summaryview->msg_is_toggled_on) {
1317 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1318 gtk_paned_add1(GTK_PANED(vpaned),
1319 GTK_WIDGET_PTR(mainwin->summaryview));
1321 gtk_paned_add2(GTK_PANED(hpaned),
1322 GTK_WIDGET_PTR(mainwin->summaryview));
1323 gtk_widget_ref(vpaned);
1325 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1326 prefs_common.summaryview_width,
1327 prefs_common.summaryview_height);
1328 gtk_paned_add2(GTK_PANED(vpaned),
1329 GTK_WIDGET_PTR(mainwin->messageview));
1330 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1331 prefs_common.mainview_width, -1);
1332 gtk_widget_set_usize(mainwin->window,
1333 prefs_common.folderview_width +
1334 prefs_common.mainview_width,
1335 prefs_common.mainwin_height);
1336 gtk_widget_show_all(vpaned);
1338 mainwin->win.sep_none.hpaned = hpaned;
1339 mainwin->win.sep_none.vpaned = vpaned;
1341 case SEPARATE_FOLDER:
1342 vpaned = gtk_vpaned_new();
1343 if (mainwin->summaryview->msg_is_toggled_on) {
1344 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1346 gtk_paned_add1(GTK_PANED(vpaned),
1347 GTK_WIDGET_PTR(mainwin->summaryview));
1349 gtk_box_pack_start(GTK_BOX(vbox_body),
1350 GTK_WIDGET_PTR(mainwin->summaryview),
1352 gtk_widget_ref(vpaned);
1354 gtk_paned_add2(GTK_PANED(vpaned),
1355 GTK_WIDGET_PTR(mainwin->messageview));
1356 gtk_widget_show_all(vpaned);
1357 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1358 prefs_common.summaryview_width,
1359 prefs_common.summaryview_height);
1360 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1361 prefs_common.mainview_width, -1);
1362 gtk_widget_set_usize(mainwin->window,
1363 prefs_common.mainview_width,
1364 prefs_common.mainview_height);
1366 gtk_container_add(GTK_CONTAINER(folderwin),
1367 GTK_WIDGET_PTR(mainwin->folderview));
1369 mainwin->win.sep_folder.folderwin = folderwin;
1370 mainwin->win.sep_folder.vpaned = vpaned;
1372 gtk_widget_show_all(folderwin);
1374 case SEPARATE_MESSAGE:
1375 hpaned = gtk_hpaned_new();
1376 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1378 gtk_paned_add1(GTK_PANED(hpaned),
1379 GTK_WIDGET_PTR(mainwin->folderview));
1380 gtk_paned_add2(GTK_PANED(hpaned),
1381 GTK_WIDGET_PTR(mainwin->summaryview));
1382 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1383 prefs_common.summaryview_width,
1384 prefs_common.summaryview_height);
1385 gtk_widget_set_usize(mainwin->window,
1386 prefs_common.folderview_width +
1387 prefs_common.mainview_width,
1388 prefs_common.mainwin_height);
1389 gtk_widget_show_all(hpaned);
1390 gtk_container_add(GTK_CONTAINER(messagewin),
1391 GTK_WIDGET_PTR(mainwin->messageview));
1393 mainwin->win.sep_message.messagewin = messagewin;
1394 mainwin->win.sep_message.hpaned = hpaned;
1396 gtk_widget_show_all(messagewin);
1399 gtk_box_pack_start(GTK_BOX(vbox_body),
1400 GTK_WIDGET_PTR(mainwin->summaryview),
1402 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1403 prefs_common.summaryview_width,
1404 prefs_common.summaryview_height);
1405 gtk_widget_set_usize(mainwin->window,
1406 prefs_common.mainview_width,
1407 prefs_common.mainwin_height);
1408 gtk_container_add(GTK_CONTAINER(folderwin),
1409 GTK_WIDGET_PTR(mainwin->folderview));
1410 gtk_container_add(GTK_CONTAINER(messagewin),
1411 GTK_WIDGET_PTR(mainwin->messageview));
1413 mainwin->win.sep_both.folderwin = folderwin;
1414 mainwin->win.sep_both.messagewin = messagewin;
1416 gtk_widget_show_all(folderwin);
1417 gtk_widget_show_all(messagewin);
1421 mainwin->type = type;
1423 debug_print(_("done.\n"));
1426 #include "pixmaps/stock_mail_receive.xpm"
1427 #include "pixmaps/stock_mail_receive_all.xpm"
1428 #include "pixmaps/stock_mail_compose.xpm"
1429 #include "pixmaps/stock_news_compose.xpm"
1430 #include "pixmaps/stock_mail_reply.xpm"
1431 #include "pixmaps/stock_mail_reply_to_all.xpm"
1432 #include "pixmaps/stock_mail_reply_to_author.xpm"
1433 #include "pixmaps/stock_mail_forward.xpm"
1434 #include "pixmaps/stock_mail_send.xpm"
1435 #include "pixmaps/stock_preferences.xpm"
1436 #include "pixmaps/stock_properties.xpm"
1437 #include "pixmaps/stock_down_arrow.xpm"
1438 #include "pixmaps/stock_close.xpm"
1439 #include "pixmaps/stock_exec.xpm"
1441 #define CREATE_TOOLBAR_ICON(xpm_d) \
1443 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1444 &container->style->white, \
1446 icon_wid = gtk_pixmap_new(icon, mask); \
1449 static void main_window_toolbar_create(MainWindow *mainwin,
1450 GtkWidget *container)
1455 GtkWidget *icon_wid;
1457 GtkWidget *getall_btn;
1458 GtkWidget *compose_mail_btn;
1459 GtkWidget *compose_news_btn;
1460 GtkWidget *compose_mail_btn_plain;
1461 GtkWidget *compose_news_btn_plain;
1462 GtkWidget *reply_btn;
1463 GtkWidget *replyall_btn;
1464 GtkWidget *replysender_btn;
1466 GtkWidget *send_btn;
1468 GtkWidget *prefs_btn;
1469 GtkWidget *account_btn;
1471 GtkWidget *next_btn;
1472 GtkWidget *delete_btn;
1473 GtkWidget *exec_btn;
1474 GtkWidget *compose_type_btn;
1475 GtkWidget *compose_type_arrow;
1476 GtkWidget *compose_box;
1477 GtkWidget *compose_label;
1478 GtkTooltips *tooltips;
1480 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1482 gtk_container_add(GTK_CONTAINER(container), toolbar);
1483 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1484 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1485 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1486 GTK_TOOLBAR_SPACE_LINE);
1488 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1489 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1491 _("Get new mail from current account"),
1493 icon_wid, toolbar_inc_cb, mainwin);
1494 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1495 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1497 _("Get new mail from all accounts"),
1503 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1505 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1506 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1508 _("Send queued message(s)"),
1514 /* to implement Leandro's "combined" compose buttons, we create
1515 * two sets of compose buttons, one for normal (text + icon)
1516 * toolbar, and one for both text-only and icon-only toolbar;
1517 * we switch between those sets. */
1519 /* insert compose mail button widget */
1521 compose_mail_btn = gtk_button_new();
1522 gtk_widget_show(compose_mail_btn);
1523 tooltips = gtk_tooltips_new();
1524 gtk_tooltips_set_tip(tooltips, compose_mail_btn,
1525 _("Compose email message"),
1527 compose_box = gtk_vbox_new(0, 0);
1528 gtk_widget_show(compose_box);
1530 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1531 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1532 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1534 compose_label = gtk_label_new(_("Email"));
1535 gtk_widget_show(compose_label);
1536 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1538 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1539 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1540 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1543 /* insert compose news button widget */
1545 compose_news_btn = gtk_button_new();
1546 gtk_widget_show(compose_news_btn);
1547 tooltips = gtk_tooltips_new();
1548 gtk_tooltips_set_tip(tooltips, compose_news_btn,
1549 _("Compose news article"),
1551 compose_box = gtk_vbox_new(0, 0);
1552 gtk_widget_show(compose_box);
1554 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1555 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1556 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1558 compose_label = gtk_label_new(_("News"));
1559 gtk_widget_show(compose_label);
1560 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1562 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_news_btn), GTK_CAN_FOCUS);
1563 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1564 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1567 /* insert compose btn plain */
1569 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1570 compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1572 _("Compose an email message"),
1575 toolbar_compose_mail_cb,
1578 /* insert compose btn plain */
1580 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1581 compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1583 _("Compose a news message"),
1586 toolbar_compose_news_cb,
1589 /* insert compose button type widget */
1591 compose_type_btn = gtk_button_new();
1592 gtk_widget_show(compose_type_btn);
1594 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1595 gtk_widget_show(compose_type_arrow);
1597 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1599 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1600 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1602 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1605 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1607 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1608 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1610 _("Reply to the message"),
1615 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1616 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1621 toolbar_reply_to_all_cb,
1623 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1624 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1626 _("Reply to sender"),
1629 toolbar_reply_to_sender_cb,
1631 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1632 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1634 _("Forward the message"),
1640 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1642 CREATE_TOOLBAR_ICON(stock_close_xpm);
1643 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1645 _("Delete the message"),
1651 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1652 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1654 _("Execute marked process"),
1660 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1661 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1663 _("Next unread message"),
1666 toolbar_next_unread_cb,
1670 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1672 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1673 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1675 _("Common preference"),
1680 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1681 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1683 _("Account setting"),
1688 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1689 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1693 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1694 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1697 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1698 GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
1701 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
1702 GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
1705 mainwin->toolbar = toolbar;
1706 mainwin->get_btn = get_btn;
1707 mainwin->getall_btn = getall_btn;
1708 mainwin->compose_mail_btn = compose_mail_btn;
1709 mainwin->compose_news_btn = compose_news_btn;
1710 mainwin->compose_mail_btn_plain = compose_mail_btn_plain;
1711 mainwin->compose_news_btn_plain = compose_news_btn_plain;
1712 mainwin->reply_btn = reply_btn;
1713 mainwin->replyall_btn = replyall_btn;
1714 mainwin->replysender_btn = replysender_btn;
1715 mainwin->fwd_btn = fwd_btn;
1716 mainwin->send_btn = send_btn;
1718 mainwin->prefs_btn = prefs_btn;
1719 mainwin->account_btn = account_btn;
1721 mainwin->next_btn = next_btn;
1722 mainwin->delete_btn = delete_btn;
1723 mainwin->exec_btn = exec_btn;
1725 gtk_widget_show_all(toolbar);
1727 /* activate Leandro menu system */
1728 activate_compose_button(mainwin,
1729 prefs_common.toolbar_style,
1730 mainwin->compose_btn_type);
1733 /* callback functions */
1735 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1738 MainWindow *mainwindow = (MainWindow *) data;
1739 GtkWidget *compose_menu, *compose_item;
1741 g_return_if_fail(mainwindow != NULL);
1743 compose_menu = gtk_menu_new();
1745 compose_item = gtk_menu_item_new_with_label(_("Email message"));
1746 gtk_widget_show(compose_item);
1747 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1748 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1749 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1751 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1753 compose_item = gtk_menu_item_new_with_label(_("News article"));
1754 gtk_widget_show(compose_item);
1755 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1756 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1757 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1759 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1761 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1765 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1767 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1768 MainWindow *mainwindow = (MainWindow *) data;
1770 mainwindow->compose_btn_type = compose_type;
1772 activate_compose_button(mainwindow, prefs_common.toolbar_style, mainwindow->compose_btn_type);
1775 static void toolbar_inc_cb (GtkWidget *widget,
1778 MainWindow *mainwin = (MainWindow *)data;
1780 inc_mail_cb(mainwin, 0, NULL);
1783 static void toolbar_inc_all_cb (GtkWidget *widget,
1786 MainWindow *mainwin = (MainWindow *)data;
1788 inc_all_account_mail_cb(mainwin, 0, NULL);
1791 static void toolbar_send_cb (GtkWidget *widget,
1794 MainWindow *mainwin = (MainWindow *)data;
1796 send_queue_cb(mainwin, 0, NULL);
1799 static void toolbar_compose_cb (GtkWidget *widget,
1802 MainWindow *mainwin = (MainWindow *)data;
1804 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1805 compose_cb(mainwin, 0, NULL);
1807 compose_news_cb(mainwin, 0, NULL);
1810 static void toolbar_compose_news_cb (GtkWidget *widget,
1813 MainWindow *mainwin = (MainWindow *)data;
1815 compose_news_cb(mainwin, 0, NULL);
1818 static void toolbar_compose_mail_cb (GtkWidget *widget,
1821 MainWindow *mainwin = (MainWindow *)data;
1823 compose_mail_cb(mainwin, 0, NULL);
1826 static void toolbar_reply_cb (GtkWidget *widget,
1829 MainWindow *mainwin = (MainWindow *)data;
1831 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1834 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1837 MainWindow *mainwin = (MainWindow *)data;
1839 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1842 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1845 MainWindow *mainwin = (MainWindow *)data;
1847 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1850 static void toolbar_forward_cb (GtkWidget *widget,
1853 MainWindow *mainwin = (MainWindow *)data;
1855 if (prefs_common.forward_as_attachment)
1856 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
1858 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1861 static void toolbar_delete_cb (GtkWidget *widget,
1864 MainWindow *mainwin = (MainWindow *)data;
1866 summary_delete(mainwin->summaryview);
1869 static void toolbar_exec_cb (GtkWidget *widget,
1872 MainWindow *mainwin = (MainWindow *)data;
1874 summary_execute(mainwin->summaryview);
1877 static void toolbar_next_unread_cb (GtkWidget *widget,
1880 MainWindow *mainwin = (MainWindow *)data;
1882 next_unread_cb(mainwin, 0, NULL);
1885 static void toolbar_prefs_cb (GtkWidget *widget,
1888 prefs_common_open();
1891 static void toolbar_account_cb (GtkWidget *widget,
1894 MainWindow *mainwin = (MainWindow *)data;
1896 prefs_account_open_cb(mainwin, 0, NULL);
1899 static void toolbar_account_button_pressed(GtkWidget *widget,
1900 GdkEventButton *event,
1903 MainWindow *mainwin = (MainWindow *)data;
1906 if (event->button != 3) return;
1908 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1909 event->button, event->time);
1912 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1915 MainWindow *mainwin = (MainWindow *)data;
1919 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1920 event->button, event->time);
1923 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1926 app_exit_cb(data, 0, widget);
1931 static void add_mailbox_cb(MainWindow *mainwin, guint action,
1934 main_window_add_mailbox(mainwin);
1937 static void add_mbox_cb(MainWindow *mainwin, guint action,
1940 main_window_add_mbox(mainwin);
1943 static void update_folderview_cb(MainWindow *mainwin, guint action,
1946 summary_show(mainwin->summaryview, NULL, FALSE);
1947 folderview_update_all();
1950 static void new_folder_cb(MainWindow *mainwin, guint action,
1953 folderview_new_folder(mainwin->folderview);
1956 static void rename_folder_cb(MainWindow *mainwin, guint action,
1959 folderview_rename_folder(mainwin->folderview);
1962 static void delete_folder_cb(MainWindow *mainwin, guint action,
1965 folderview_delete_folder(mainwin->folderview);
1968 static void import_mbox_cb(MainWindow *mainwin, guint action,
1971 import_mbox(mainwin->summaryview->folder_item);
1974 static void export_mbox_cb(MainWindow *mainwin, guint action,
1977 export_mbox(mainwin->summaryview->folder_item);
1980 static void empty_trash_cb(MainWindow *mainwin, guint action,
1983 main_window_empty_trash(mainwin, TRUE);
1986 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1988 summary_save_as(mainwin->summaryview);
1991 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1993 summary_print(mainwin->summaryview);
1996 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1998 if (prefs_common.confirm_on_exit) {
1999 if (alertpanel(_("Exit"), _("Exit this program?"),
2000 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2002 manage_window_focus_in(mainwin->window, NULL, NULL);
2005 app_will_exit(widget, mainwin);
2008 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2011 switch (mainwin->type) {
2013 case SEPARATE_MESSAGE:
2015 case SEPARATE_FOLDER:
2016 if (GTK_CHECK_MENU_ITEM(widget)->active)
2017 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2019 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2022 if (GTK_CHECK_MENU_ITEM(widget)->active)
2023 gtk_widget_show(mainwin->win.sep_both.folderwin);
2025 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2030 static void toggle_message_cb(MainWindow *mainwin, guint action,
2033 switch (mainwin->type) {
2035 case SEPARATE_FOLDER:
2037 case SEPARATE_MESSAGE:
2038 if (GTK_CHECK_MENU_ITEM(widget)->active)
2039 gtk_widget_show(mainwin->win.sep_message.messagewin);
2041 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2044 if (GTK_CHECK_MENU_ITEM(widget)->active)
2045 gtk_widget_show(mainwin->win.sep_both.messagewin);
2047 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2052 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2055 activate_compose_button(mainwin, (ToolbarStyle)action,
2056 mainwin->compose_btn_type);
2058 switch ((ToolbarStyle)action) {
2060 gtk_widget_hide(mainwin->handlebox);
2062 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2066 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2070 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2075 if (action != TOOLBAR_NONE) {
2076 gtk_widget_show(mainwin->handlebox);
2077 gtk_widget_queue_resize(mainwin->handlebox);
2080 mainwin->toolbar_style = (ToolbarStyle)action;
2081 prefs_common.toolbar_style = (ToolbarStyle)action;
2084 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2087 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2088 gtk_widget_show(mainwin->hbox_stat);
2089 prefs_common.show_statusbar = TRUE;
2091 gtk_widget_hide(mainwin->hbox_stat);
2092 prefs_common.show_statusbar = FALSE;
2096 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action)
2098 MainWindow *mainwin;
2101 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2102 g_return_if_fail(mainwin != NULL);
2104 type = mainwin->type ^ action;
2105 main_window_separation_change(mainwin, type);
2107 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2108 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2111 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2114 addressbook_open(NULL);
2117 static void log_window_show_cb(MainWindow *mainwin, guint action,
2120 log_window_show(mainwin->logwin);
2123 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2128 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2131 inc_all_account_mail(mainwin);
2134 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2138 if (procmsg_send_queue() < 0)
2139 alertpanel_error(_("Sending queued message failed."));
2141 statusbar_pop_all();
2143 for (list = folder_get_list(); list != NULL; list = list->next) {
2146 folder = list->data;
2147 if (folder->queue) {
2148 folder_item_scan(folder->queue);
2149 folderview_update_item(folder->queue, TRUE);
2154 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2156 if (mainwin->summaryview->folder_item) {
2157 if (mainwin->summaryview->folder_item->folder->account != NULL
2158 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2159 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2161 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2167 static void compose_mail_cb(MainWindow *mainwin, guint action,
2174 if (mainwin->summaryview->folder_item) {
2175 ac = mainwin->summaryview->folder_item->folder->account;
2176 if (ac && ac->protocol != A_NNTP) {
2177 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2182 if(cur_account && (cur_account->protocol != A_NNTP)) {
2183 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2187 list = account_get_list();
2188 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2189 ac = (PrefsAccount *) cur->data;
2190 if (ac->protocol != A_NNTP) {
2191 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2197 static void compose_news_cb(MainWindow *mainwin, guint action,
2200 PrefsAccount * ac = NULL;
2204 if (mainwin->summaryview->folder_item) {
2205 ac = mainwin->summaryview->folder_item->folder->account;
2206 if (ac && ac->protocol == A_NNTP) {
2207 compose_new_with_recipient
2208 (ac, mainwin->summaryview->folder_item->path);
2213 list = account_get_list();
2214 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2215 ac = (PrefsAccount *) cur->data;
2216 if (ac->protocol == A_NNTP) {
2223 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2225 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2228 msginfo = gtk_ctree_node_get_row_data
2229 (GTK_CTREE(mainwin->summaryview->ctree),
2230 mainwin->summaryview->selected);
2232 if (!msginfo) return;
2236 compose_reply(msginfo, prefs_common.reply_with_quote,
2239 case COMPOSE_REPLY_TO_SENDER:
2240 compose_reply(msginfo, prefs_common.reply_with_quote,
2243 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2244 compose_followup_and_reply_to(msginfo,
2245 prefs_common.reply_with_quote,
2248 case COMPOSE_REPLY_TO_ALL:
2249 compose_reply(msginfo, prefs_common.reply_with_quote,
2252 case COMPOSE_FORWARD:
2254 compose_forward(NULL, msginfo, FALSE);
2257 /* if (sel->next) FALL_THROUGH */
2258 case COMPOSE_FORWARD_AS_ATTACH:
2260 GSList *msginfo_list = NULL;
2261 for ( ; sel != NULL; sel = sel->next)
2262 msginfo_list = g_slist_append(msginfo_list,
2263 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2264 GTK_CTREE_NODE(sel->data)));
2265 compose_forward_multiple(NULL, msginfo_list);
2266 g_slist_free(msginfo_list);
2270 g_warning("reply_cb(): invalid action type: %d\n", action);
2273 summary_set_marks_selected(mainwin->summaryview);
2276 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2278 summary_move_to(mainwin->summaryview);
2281 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2283 summary_copy_to(mainwin->summaryview);
2286 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2288 summary_delete(mainwin->summaryview);
2291 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2293 summary_open_msg(mainwin->summaryview);
2296 static void view_source_cb(MainWindow *mainwin, guint action,
2299 summary_view_source(mainwin->summaryview);
2302 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2304 summary_reedit(mainwin->summaryview);
2307 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2309 summary_mark(mainwin->summaryview);
2312 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2314 summary_unmark(mainwin->summaryview);
2317 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2320 summary_mark_as_unread(mainwin->summaryview);
2323 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2326 summary_mark_as_read(mainwin->summaryview);
2329 static void set_charset_cb(MainWindow *mainwin, guint action,
2334 str = conv_get_charset_str((CharSet)action);
2335 g_free(prefs_common.force_charset);
2336 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2338 summary_redisplay_msg(mainwin->summaryview);
2340 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2343 void main_window_set_thread_option(MainWindow *mainwin)
2345 GtkItemFactory *ifactory;
2346 gboolean no_item = FALSE;
2348 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2350 if (mainwin->summaryview == NULL)
2352 else if (mainwin->summaryview->folder_item == NULL)
2356 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2357 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2360 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2361 menu_set_sensitive(ifactory,
2362 "/Summary/Thread view", FALSE);
2363 menu_set_sensitive(ifactory,
2364 "/Summary/Unthread view", TRUE);
2365 summary_thread_build(mainwin->summaryview);
2368 menu_set_sensitive(ifactory,
2369 "/Summary/Thread view", TRUE);
2370 menu_set_sensitive(ifactory,
2371 "/Summary/Unthread view", FALSE);
2372 summary_unthread(mainwin->summaryview);
2374 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2378 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2380 mainwin->summaryview->folder_item->prefs->enable_thread =
2381 !mainwin->summaryview->folder_item->prefs->enable_thread;
2382 main_window_set_thread_option(mainwin);
2386 summary_thread_build(mainwin->summaryview);
2387 mainwin->summaryview->folder_item->prefs->enable_thread =
2389 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2390 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2392 summary_unthread(mainwin->summaryview);
2393 mainwin->summaryview->folder_item->prefs->enable_thread =
2395 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2396 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2401 static void set_display_item_cb(MainWindow *mainwin, guint action,
2404 prefs_summary_display_item_set();
2407 static void sort_summary_cb(MainWindow *mainwin, guint action,
2410 summary_sort(mainwin->summaryview, (SummarySortType)action);
2413 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2416 summary_attract_by_subject(mainwin->summaryview);
2419 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2422 summary_delete_duplicated(mainwin->summaryview);
2425 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2427 summary_filter(mainwin->summaryview);
2430 static void execute_summary_cb(MainWindow *mainwin, guint action,
2433 summary_execute(mainwin->summaryview);
2436 static void update_summary_cb(MainWindow *mainwin, guint action,
2440 FolderView *folderview = mainwin->folderview;
2442 if (!mainwin->summaryview->folder_item) return;
2443 if (!folderview->opened) return;
2445 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2446 folderview->opened);
2449 summary_show(mainwin->summaryview, fitem, TRUE);
2452 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2454 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2457 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2459 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2462 static void next_unread_cb(MainWindow *mainwin, guint action,
2465 summary_select_next_unread(mainwin->summaryview);
2468 static void next_marked_cb(MainWindow *mainwin, guint action,
2471 summary_select_next_marked(mainwin->summaryview);
2474 static void prev_marked_cb(MainWindow *mainwin, guint action,
2477 summary_select_prev_marked(mainwin->summaryview);
2480 static void goto_folder_cb(MainWindow *mainwin, guint action,
2483 FolderItem *to_folder;
2485 to_folder = foldersel_folder_sel(NULL, NULL);
2488 folderview_select(mainwin->folderview, to_folder);
2491 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2493 messageview_copy_clipboard(mainwin->messageview);
2496 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2498 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2499 summary_select_all(mainwin->summaryview);
2500 else if (mainwin->summaryview->msg_is_toggled_on &&
2501 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2502 messageview_select_all(mainwin->messageview);
2505 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2508 prefs_common_open();
2511 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2514 prefs_filter_open();
2517 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2520 prefs_scoring_open(NULL);
2523 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2526 prefs_filtering_open();
2529 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2533 new_account_cb(mainwin, 0, widget);
2535 gboolean prev_default = cur_account->is_default;
2537 prefs_account_open(cur_account);
2538 if (!prev_default && cur_account->is_default)
2539 account_set_as_default(cur_account);
2540 account_save_config_all();
2542 main_window_reflect_prefs_all();
2546 static void new_account_cb(MainWindow *mainwin, guint action,
2549 account_edit_open();
2550 if (!compose_get_compose_list()) account_add();
2553 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2555 cur_account = (PrefsAccount *)data;
2556 main_window_reflect_prefs_all();
2559 static void manual_open_cb(MainWindow *mainwin, guint action,
2562 manual_open((ManualLang)action);
2565 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2567 MainWindow *mainwin = (MainWindow *)data;
2571 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2572 LOCAL_FOLDER(folder)->rootpath,
2576 str = g_strdup_printf(_("Scanning folder %s ..."),
2577 LOCAL_FOLDER(folder)->rootpath);
2579 STATUSBAR_PUSH(mainwin, str);
2580 STATUSBAR_POP(mainwin);
2584 static void activate_compose_button (MainWindow *mainwin,
2586 ComposeButtonType type)
2588 if (style == TOOLBAR_NONE)
2591 if (style == TOOLBAR_BOTH) {
2592 gtk_widget_hide(mainwin->compose_mail_btn_plain);
2593 gtk_widget_hide(mainwin->compose_news_btn_plain);
2594 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2595 : mainwin->compose_news_btn);
2596 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2597 : mainwin->compose_mail_btn);
2598 mainwin->compose_btn_type = type;
2601 gtk_widget_hide(mainwin->compose_news_btn);
2602 gtk_widget_hide(mainwin->compose_mail_btn);
2603 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn_plain
2604 : mainwin->compose_news_btn_plain);
2605 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn_plain
2606 : mainwin->compose_mail_btn_plain);
2607 mainwin->compose_btn_type = type;