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,
210 static void addressbook_open_cb (MainWindow *mainwin,
213 static void log_window_show_cb (MainWindow *mainwin,
217 static void inc_mail_cb (MainWindow *mainwin,
220 static void inc_all_account_mail_cb (MainWindow *mainwin,
224 static void send_queue_cb (MainWindow *mainwin,
228 static void compose_cb (MainWindow *mainwin,
231 static void compose_mail_cb(MainWindow *mainwin, guint action,
233 static void compose_news_cb(MainWindow *mainwin, guint action,
235 static void reply_cb (MainWindow *mainwin,
239 static void open_msg_cb (MainWindow *mainwin,
243 static void view_source_cb (MainWindow *mainwin,
247 static void reedit_cb (MainWindow *mainwin,
251 static void move_to_cb (MainWindow *mainwin,
254 static void copy_to_cb (MainWindow *mainwin,
257 static void delete_cb (MainWindow *mainwin,
261 static void mark_cb (MainWindow *mainwin,
264 static void unmark_cb (MainWindow *mainwin,
268 static void mark_as_unread_cb (MainWindow *mainwin,
271 static void mark_as_read_cb (MainWindow *mainwin,
275 static void set_charset_cb (MainWindow *mainwin,
279 static void thread_cb (MainWindow *mainwin,
282 static void set_display_item_cb (MainWindow *mainwin,
285 static void sort_summary_cb (MainWindow *mainwin,
288 static void attract_by_subject_cb(MainWindow *mainwin,
292 static void delete_duplicated_cb (MainWindow *mainwin,
295 static void filter_cb (MainWindow *mainwin,
298 static void execute_summary_cb (MainWindow *mainwin,
301 static void update_summary_cb (MainWindow *mainwin,
305 static void prev_cb (MainWindow *mainwin,
308 static void next_cb (MainWindow *mainwin,
312 static void next_unread_cb (MainWindow *mainwin,
316 static void next_marked_cb (MainWindow *mainwin,
320 static void prev_marked_cb (MainWindow *mainwin,
324 static void goto_folder_cb (MainWindow *mainwin,
328 static void copy_cb (MainWindow *mainwin,
331 static void allsel_cb (MainWindow *mainwin,
335 static void prefs_common_open_cb (MainWindow *mainwin,
338 static void prefs_filter_open_cb (MainWindow *mainwin,
341 static void prefs_scoring_open_cb (MainWindow *mainwin,
344 static void prefs_filtering_open_cb (MainWindow *mainwin,
347 static void prefs_account_open_cb(MainWindow *mainwin,
350 static void new_account_cb (MainWindow *mainwin,
354 static void account_menu_cb (GtkMenuItem *menuitem,
357 static void manual_open_cb (MainWindow *mainwin,
361 static void scan_tree_func (Folder *folder,
365 static void activate_compose_button (MainWindow *mainwin,
367 ComposeButtonType type);
369 #define SEPARATE_ACTION 667
371 static GtkItemFactoryEntry mainwin_entries[] =
373 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
374 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
375 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
376 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
377 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
378 {N_("/_File/_Folder/Create _new folder..."),
379 NULL, new_folder_cb, 0, NULL},
380 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
381 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
382 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
383 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
384 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
385 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
386 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
387 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
388 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
389 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
390 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
392 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
393 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
394 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
395 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
396 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
398 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
399 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
400 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
401 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
402 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
403 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
404 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
405 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
406 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
407 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
408 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
409 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
410 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
411 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
412 {N_("/_View/_Code set/_Auto detect"),
413 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
415 #define CODESET_SEPARATOR \
416 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
417 #define CODESET_ACTION(action) \
418 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
420 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
421 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
422 CODESET_ACTION(C_US_ASCII)},
425 {N_("/_View/_Code set/Unicode (_UTF-8)"),
426 CODESET_ACTION(C_UTF_8)},
429 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
430 CODESET_ACTION(C_ISO_8859_1)},
433 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
434 CODESET_ACTION(C_ISO_8859_2)},
436 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
437 CODESET_ACTION(C_ISO_8859_13)},
438 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
439 CODESET_ACTION(C_ISO_8859_4)},
441 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
442 CODESET_ACTION(C_ISO_8859_7)},
444 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
445 CODESET_ACTION(C_ISO_8859_9)},
447 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
448 CODESET_ACTION(C_ISO_8859_5)},
449 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
450 CODESET_ACTION(C_KOI8_R)},
451 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
452 CODESET_ACTION(C_CP1251)},
455 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
456 CODESET_ACTION(C_ISO_2022_JP)},
458 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
459 CODESET_ACTION(C_ISO_2022_JP_2)},
461 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
462 CODESET_ACTION(C_EUC_JP)},
463 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
464 CODESET_ACTION(C_SHIFT_JIS)},
467 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
468 CODESET_ACTION(C_GB2312)},
469 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
470 CODESET_ACTION(C_BIG5)},
471 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
472 CODESET_ACTION(C_EUC_TW)},
473 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
474 CODESET_ACTION(C_ISO_2022_CN)},
476 {N_("/_View/_Code set/Korean (EUC-_KR)"),
477 CODESET_ACTION(C_EUC_KR)},
478 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
479 CODESET_ACTION(C_ISO_2022_KR)},
482 #undef CODESET_SEPARATOR
483 #undef CODESET_ACTION
485 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
486 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
487 {N_("/_Message/Get from _all accounts"),
488 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
489 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
490 {N_("/_Message/Send queued messa_ges"),
491 NULL, send_queue_cb, 0, NULL},
492 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
493 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
494 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
495 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
496 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
497 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
498 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
499 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
500 {N_("/_Message/Forward as a_ttachment"),
501 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
502 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
503 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
504 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
505 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
506 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
507 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
508 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
509 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
511 {N_("/_Message/_Mark/Mark as rea_d"),
512 NULL, mark_as_read_cb, 0, NULL},
513 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
514 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
515 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
516 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
517 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
519 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
520 {N_("/_Summary/_Delete duplicated messages"),
521 NULL, delete_duplicated_cb, 0, NULL},
522 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
523 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
524 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
525 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
527 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
528 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
529 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
530 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
531 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
532 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
533 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
536 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
537 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
538 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
539 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
540 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
541 {N_("/_Summary/_Sort/Sort by _label"), NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
542 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
543 {N_("/_Summary/_Sort/_Attract by subject"),
544 NULL, attract_by_subject_cb, 0, NULL},
545 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
546 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
547 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
549 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
550 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
551 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
553 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
554 {N_("/_Configuration/_Common preferences..."),
555 NULL, prefs_common_open_cb, 0, NULL},
556 {N_("/_Configuration/_Filter setting..."),
557 NULL, prefs_filter_open_cb, 0, NULL},
558 {N_("/_Configuration/_Scoring ..."),
559 NULL, prefs_scoring_open_cb, 0, NULL},
560 {N_("/_Configuration/_Filtering ..."),
561 NULL, prefs_filtering_open_cb, 0, NULL},
562 {N_("/_Configuration/_Preferences per account..."),
563 NULL, prefs_account_open_cb, 0, NULL},
564 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
565 {N_("/_Configuration/Create _new account..."),
566 NULL, new_account_cb, 0, NULL},
567 {N_("/_Configuration/_Edit accounts..."),
568 NULL, account_edit_open, 0, NULL},
569 {N_("/_Configuration/C_hange current account"),
570 NULL, NULL, 0, "<Branch>"},
572 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
573 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
574 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
575 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
576 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
577 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
580 MainWindow *main_window_create(SeparateType type)
586 GtkWidget *handlebox;
587 GtkWidget *vbox_body;
588 GtkWidget *hbox_stat;
589 GtkWidget *statusbar;
590 GtkWidget *ac_button;
593 FolderView *folderview;
594 SummaryView *summaryview;
595 MessageView *messageview;
596 GdkColormap *colormap;
599 guint n_menu_entries;
600 GtkItemFactory *ifactory;
605 debug_print(_("Creating main window...\n"));
606 mainwin = g_new0(MainWindow, 1);
609 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
610 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
611 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
612 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
613 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
614 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
615 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
616 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
617 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
618 gtk_widget_realize(window);
620 vbox = gtk_vbox_new(FALSE, 0);
621 gtk_widget_show(vbox);
622 gtk_container_add(GTK_CONTAINER(window), vbox);
625 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
626 menubar = menubar_create(window, mainwin_entries,
627 n_menu_entries, "<Main>", mainwin);
628 gtk_widget_show(menubar);
629 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
631 handlebox = gtk_handle_box_new();
632 gtk_widget_show(handlebox);
633 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
635 main_window_toolbar_create(mainwin, handlebox);
637 /* vbox that contains body */
638 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
639 gtk_widget_show(vbox_body);
640 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
641 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
643 hbox_stat = gtk_hbox_new(FALSE, 2);
644 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
646 statusbar = statusbar_create();
647 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
649 ac_button = gtk_button_new();
650 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
651 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
652 gtk_widget_set_usize(ac_button, -1, 1);
653 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
654 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
655 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
657 ac_label = gtk_label_new("");
658 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
660 gtk_widget_show_all(hbox_stat);
663 mainwin->folderview = folderview = folderview_create();
664 mainwin->summaryview = summaryview = summary_create();
665 mainwin->messageview = messageview = messageview_create();
666 mainwin->headerwin = header_window_create();
667 mainwin->logwin = log_window_create();
669 folderview->mainwin = mainwin;
670 folderview->summaryview = summaryview;
672 summaryview->mainwin = mainwin;
673 summaryview->folderview = folderview;
674 summaryview->messageview = messageview;
675 summaryview->headerwin = mainwin->headerwin;
676 summaryview->window = window;
678 messageview->mainwin = mainwin;
680 mainwin->window = window;
681 mainwin->vbox = vbox;
682 mainwin->menubar = menubar;
683 mainwin->handlebox = handlebox;
684 mainwin->vbox_body = vbox_body;
685 mainwin->hbox_stat = hbox_stat;
686 mainwin->statusbar = statusbar;
687 mainwin->ac_button = ac_button;
688 mainwin->ac_label = ac_label;
690 /* set context IDs for status bar */
691 mainwin->mainwin_cid = gtk_statusbar_get_context_id
692 (GTK_STATUSBAR(statusbar), "Main Window");
693 mainwin->folderview_cid = gtk_statusbar_get_context_id
694 (GTK_STATUSBAR(statusbar), "Folder View");
695 mainwin->summaryview_cid = gtk_statusbar_get_context_id
696 (GTK_STATUSBAR(statusbar), "Summary View");
698 /* allocate colors for summary view and folder view */
699 summaryview->color_marked.red = summaryview->color_marked.green = 0;
700 summaryview->color_marked.blue = (guint16)65535;
702 summaryview->color_dim.red = summaryview->color_dim.green =
703 summaryview->color_dim.blue = COLOR_DIM;
705 folderview->color_new.red = (guint16)55000;
706 folderview->color_new.green = folderview->color_new.blue = 15000;
708 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
709 &folderview->color_op);
711 summaryview->color_important.red = 0;
712 summaryview->color_marked.green = 0;
713 summaryview->color_important.blue = (guint16)65535;
715 color[0] = summaryview->color_marked;
716 color[1] = summaryview->color_dim;
717 color[2] = folderview->color_new;
718 color[3] = folderview->color_op;
720 colormap = gdk_window_get_colormap(window->window);
721 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
722 for (i = 0; i < 4; 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);*/
786 /* set account selection menu */
787 ac_menu = gtk_item_factory_get_widget
788 (ifactory, "/Configuration/Change current account");
789 mainwin->ac_menu = ac_menu;
791 main_window_set_toolbar_sensitive(mainwin, FALSE);
793 /* show main window */
794 gtk_widget_set_uposition(mainwin->window,
795 prefs_common.mainwin_x,
796 prefs_common.mainwin_y);
797 gtk_widget_set_usize(window, prefs_common.mainwin_width,
798 prefs_common.mainwin_height);
799 gtk_widget_show(mainwin->window);
801 /* initialize views */
802 folderview_init(folderview);
803 summary_init(summaryview);
804 messageview_init(messageview);
805 header_window_init(mainwin->headerwin);
806 log_window_init(mainwin->logwin);
808 mainwin->cursor_count = 0;
811 watch_cursor = gdk_cursor_new(GDK_WATCH);
813 mainwin_list = g_list_append(mainwin_list, mainwin);
818 void main_window_cursor_wait(MainWindow *mainwin)
820 if (mainwin->cursor_count == 0)
821 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
823 mainwin->cursor_count++;
828 void main_window_cursor_normal(MainWindow *mainwin)
830 if (mainwin->cursor_count)
831 mainwin->cursor_count--;
833 if (mainwin->cursor_count == 0)
834 gdk_window_set_cursor(mainwin->window->window, NULL);
839 void main_window_reflect_prefs_all(void)
844 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
845 mainwin = (MainWindow *)cur->data;
847 main_window_show_cur_account(mainwin);
849 gtk_widget_set_sensitive(mainwin->get_btn, TRUE);
850 gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
852 gtk_widget_set_sensitive(mainwin->get_btn, FALSE);
853 gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
856 if (prefs_common.immediate_exec)
857 gtk_widget_hide(mainwin->exec_btn);
859 gtk_widget_show(mainwin->exec_btn);
861 summary_change_display_item(mainwin->summaryview);
862 summary_redisplay_msg(mainwin->summaryview);
863 headerview_set_visibility(mainwin->messageview->headerview,
864 prefs_common.display_header_pane);
868 void main_window_set_account_menu(GList *account_list)
870 GList *cur, *cur_ac, *cur_item;
873 PrefsAccount *ac_prefs;
875 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
876 mainwin = (MainWindow *)cur->data;
878 /* destroy all previous menu item */
879 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
880 while (cur_item != NULL) {
881 GList *next = cur_item->next;
882 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
886 for (cur_ac = account_list; cur_ac != NULL;
887 cur_ac = cur_ac->next) {
888 ac_prefs = (PrefsAccount *)cur_ac->data;
890 menuitem = gtk_menu_item_new_with_label
891 (ac_prefs->account_name
892 ? ac_prefs->account_name : _("Untitled"));
893 gtk_widget_show(menuitem);
894 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
895 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
896 GTK_SIGNAL_FUNC(account_menu_cb),
902 static void main_window_show_cur_account(MainWindow *mainwin)
907 ac_name = g_strdup(cur_account
908 ? (cur_account->account_name
909 ? cur_account->account_name : _("Untitled"))
913 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
915 buf = g_strdup(PROG_VERSION);
916 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
919 buf = g_strdup_printf(_("Current account: %s"), ac_name);
920 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
921 gtk_widget_queue_resize(mainwin->ac_button);
927 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
929 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
930 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
931 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
933 if (mainwin->type == type) return;
935 /* remove widgets from those containers */
936 gtk_widget_ref(folder_wid);
937 gtk_widget_ref(summary_wid);
938 gtk_widget_ref(message_wid);
940 (GTK_CONTAINER(folder_wid->parent), folder_wid);
942 (GTK_CONTAINER(summary_wid->parent), summary_wid);
944 (GTK_CONTAINER(message_wid->parent), message_wid);
946 /* clean containers */
947 switch (mainwin->type) {
949 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
951 case SEPARATE_FOLDER:
952 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
953 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
955 case SEPARATE_MESSAGE:
956 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
957 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
960 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
961 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
965 gtk_widget_hide(mainwin->window);
966 main_window_set_widgets(mainwin, type);
967 gtk_widget_show(mainwin->window);
969 gtk_widget_unref(folder_wid);
970 gtk_widget_unref(summary_wid);
971 gtk_widget_unref(message_wid);
974 void main_window_get_size(MainWindow *mainwin)
976 GtkAllocation *allocation;
978 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
980 prefs_common.summaryview_width = allocation->width;
982 if (mainwin->summaryview->msg_is_toggled_on)
983 prefs_common.summaryview_height = allocation->height;
985 prefs_common.mainview_width = allocation->width;
987 allocation = &mainwin->window->allocation;
989 prefs_common.mainview_height = allocation->height;
990 prefs_common.mainwin_width = allocation->width;
991 prefs_common.mainwin_height = allocation->height;
993 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
995 prefs_common.folderview_width = allocation->width;
996 prefs_common.folderview_height = allocation->height;
999 void main_window_get_position(MainWindow *mainwin)
1003 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1005 prefs_common.mainview_x = x;
1006 prefs_common.mainview_y = y;
1007 prefs_common.mainwin_x = x;
1008 prefs_common.mainwin_y = y;
1010 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1013 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1018 if (alertpanel(_("Empty trash"),
1019 _("Empty all messages in trash?"),
1020 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1022 manage_window_focus_in(mainwin->window, NULL, NULL);
1025 procmsg_empty_trash();
1027 for (list = folder_get_list(); list != NULL; list = list->next) {
1030 folder = list->data;
1031 if (folder->trash) {
1032 folder_item_scan(folder->trash);
1033 folderview_update_item(folder->trash, TRUE);
1037 if (mainwin->summaryview->folder_item &&
1038 mainwin->summaryview->folder_item->stype == F_TRASH)
1039 gtk_widget_grab_focus(mainwin->folderview->ctree);
1042 void main_window_add_mailbox(MainWindow *mainwin)
1047 path = input_dialog(_("Add mailbox"),
1048 _("Input the location of mailbox.\n"
1049 "If the existing mailbox is specified, it will be\n"
1050 "scanned automatically."),
1053 if (folder_find_from_path(path)) {
1054 alertpanel_error(_("The mailbox `%s' already exists."), path);
1058 if (!strcmp(path, "Mail"))
1059 folder = folder_new(F_MH, _("Mailbox"), path);
1061 folder = folder_new(F_MH, g_basename(path), path);
1064 if (folder->create_tree(folder) < 0) {
1065 alertpanel_error(_("Creation of the mailbox failed.\n"
1066 "Maybe some files already exist, or you don't have the permission to write there."));
1067 folder_destroy(folder);
1072 folder_set_ui_func(folder, scan_tree_func, mainwin);
1073 folder->scan_tree(folder);
1074 folder_set_ui_func(folder, NULL, NULL);
1076 folderview_set(mainwin->folderview);
1079 void main_window_add_mbox(MainWindow *mainwin)
1085 path = input_dialog(_("Add mbox mailbox"),
1086 _("Input the location of mailbox."),
1091 if (folder_find_from_path(path)) {
1092 alertpanel_error(_("The mailbox `%s' already exists."), path);
1098 if (!strcmp(path, "Mail"))
1099 folder = folder_new(F_MBOX, _("Mailbox"), path);
1103 folder = folder_new(F_MBOX, g_basename(path), path);
1106 if (folder->create_tree(folder) < 0) {
1107 alertpanel_error(_("Creation of the mailbox failed."));
1108 folder_destroy(folder);
1114 item = folder_item_new(folder->name, NULL);
1115 item->folder = folder;
1116 folder->node = g_node_new(item);
1118 folder->create_folder(folder, item, "inbox");
1119 folder->create_folder(folder, item, "outbox");
1120 folder->create_folder(folder, item, "queue");
1121 folder->create_folder(folder, item, "draft");
1122 folder->create_folder(folder, item, "trash");
1124 folderview_set(mainwin->folderview);
1127 void main_window_set_toolbar_sensitive(MainWindow *mainwin, gboolean sensitive)
1129 gtk_widget_set_sensitive(mainwin->reply_btn, sensitive);
1130 gtk_widget_set_sensitive(mainwin->replyall_btn, sensitive);
1131 gtk_widget_set_sensitive(mainwin->replysender_btn, sensitive);
1132 gtk_widget_set_sensitive(mainwin->fwd_btn, sensitive);
1133 gtk_widget_set_sensitive(mainwin->exec_btn, sensitive);
1134 gtk_widget_set_sensitive(mainwin->next_btn, sensitive);
1136 if (!mainwin->summaryview->folder_item ||
1137 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1138 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1140 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1143 void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
1145 GtkItemFactory *ifactory;
1149 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1151 if (selection == SUMMARY_SELECTED_SINGLE)
1155 if (!mainwin->summaryview->folder_item ||
1156 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1161 menu_set_sensitive(ifactory, "/File/Save as...", sens);
1162 menu_set_sensitive(ifactory, "/Message/Reply", sens);
1163 menu_set_sensitive(ifactory, "/Message/Reply to sender", sens);
1164 menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
1165 menu_set_sensitive(ifactory, "/Message/Forward", TRUE);
1166 menu_set_sensitive(ifactory, "/Message/Forward as attachment", TRUE);
1167 menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
1168 menu_set_sensitive(ifactory, "/Message/Show all header", sens);
1169 menu_set_sensitive(ifactory, "/Message/View source", sens);
1170 if (sens && (!mainwin->summaryview->folder_item ||
1171 mainwin->summaryview->folder_item->stype != F_DRAFT))
1173 menu_set_sensitive(ifactory, "/Message/Re-edit", sens);
1175 if (selection == SUMMARY_SELECTED_SINGLE ||
1176 selection == SUMMARY_SELECTED_MULTIPLE)
1181 menu_set_sensitive(ifactory, "/File/Print..." , sens);
1182 menu_set_sensitive(ifactory, "/Message/Move...", sens && exec);
1183 menu_set_sensitive(ifactory, "/Message/Copy...", sens && exec);
1184 menu_set_sensitive(ifactory, "/Message/Delete" , sens && exec);
1185 menu_set_sensitive(ifactory, "/Message/Mark" , sens);
1187 if (selection != SUMMARY_NONE)
1192 menu_set_sensitive(ifactory, "/Summary/Delete duplicated messages", sens && exec);
1193 menu_set_sensitive(ifactory, "/Summary/Filter messages", sens && exec);
1194 menu_set_sensitive(ifactory, "/Summary/Execute", sens);
1195 menu_set_sensitive(ifactory, "/Summary/Prev message", sens);
1196 menu_set_sensitive(ifactory, "/Summary/Next message", sens);
1197 menu_set_sensitive(ifactory, "/Summary/Next unread message", sens);
1198 menu_set_sensitive(ifactory, "/Summary/Sort", sens);
1200 if (mainwin->summaryview->folder_item &&
1201 mainwin->summaryview->folder_item->folder->account)
1202 sens = mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP;
1205 menu_set_sensitive(ifactory, "/Message/Follow-up and reply to", sens);
1208 void main_window_popup(MainWindow *mainwin)
1214 gdk_window_get_origin(mainwin->window->window, &x, &y);
1215 sx = gdk_screen_width();
1216 sy = gdk_screen_height();
1217 x %= sx; if (x < 0) x += sx;
1218 y %= sy; if (y < 0) y += sy;
1219 gdk_window_move(mainwin->window->window, x, y);
1220 gdk_window_raise(mainwin->window->window);
1221 gdk_window_show(mainwin->window->window);
1223 debug_print("window position: x = %d, y = %d\n", x, y);
1225 switch (mainwin->type) {
1226 case SEPARATE_FOLDER:
1227 widget = mainwin->win.sep_folder.folderwin;
1228 gdk_window_get_origin(widget->window, &x, &y);
1229 x %= sx; if (x < 0) x += sx;
1230 y %= sy; if (y < 0) y += sy;
1231 gdk_window_move(widget->window, x, y);
1232 gdk_window_raise(widget->window);
1234 case SEPARATE_MESSAGE:
1235 widget = mainwin->win.sep_message.messagewin;
1236 gdk_window_get_origin(widget->window, &x, &y);
1237 x %= sx; if (x < 0) x += sx;
1238 y %= sy; if (y < 0) y += sy;
1239 gdk_window_move(widget->window, x, y);
1240 gdk_window_raise(widget->window);
1243 widget = mainwin->win.sep_both.folderwin;
1244 gdk_window_get_origin(widget->window, &x, &y);
1245 x %= sx; if (x < 0) x += sx;
1246 y %= sy; if (y < 0) y += sy;
1247 gdk_window_move(widget->window, x, y);
1248 gdk_window_raise(widget->window);
1249 widget = mainwin->win.sep_both.messagewin;
1250 gdk_window_get_origin(widget->window, &x, &y);
1251 x %= sx; if (x < 0) x += sx;
1252 y %= sy; if (y < 0) y += sy;
1253 gdk_window_move(widget->window, x, y);
1254 gdk_window_raise(widget->window);
1261 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1263 GtkWidget *folderwin = NULL;
1264 GtkWidget *messagewin = NULL;
1267 GtkWidget *vbox_body = mainwin->vbox_body;
1269 debug_print(_("Setting widgets..."));
1271 /* create separated window(s) if needed */
1272 if (type & SEPARATE_FOLDER) {
1273 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1274 gtk_window_set_policy(GTK_WINDOW(folderwin),
1276 gtk_widget_set_usize(folderwin, -1,
1277 prefs_common.mainview_height);
1278 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1280 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1281 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1284 if (type & SEPARATE_MESSAGE) {
1285 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1286 gtk_window_set_policy(GTK_WINDOW(messagewin),
1288 gtk_widget_set_usize
1289 (messagewin, prefs_common.mainview_width,
1290 prefs_common.mainview_height
1291 - prefs_common.summaryview_height
1292 + DEFAULT_HEADERVIEW_HEIGHT);
1293 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1295 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1296 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1302 hpaned = gtk_hpaned_new();
1303 gtk_widget_show(hpaned);
1304 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1305 gtk_paned_add1(GTK_PANED(hpaned),
1306 GTK_WIDGET_PTR(mainwin->folderview));
1308 vpaned = gtk_vpaned_new();
1309 if (mainwin->summaryview->msg_is_toggled_on) {
1310 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1311 gtk_paned_add1(GTK_PANED(vpaned),
1312 GTK_WIDGET_PTR(mainwin->summaryview));
1314 gtk_paned_add2(GTK_PANED(hpaned),
1315 GTK_WIDGET_PTR(mainwin->summaryview));
1316 gtk_widget_ref(vpaned);
1318 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1319 prefs_common.summaryview_width,
1320 prefs_common.summaryview_height);
1321 gtk_paned_add2(GTK_PANED(vpaned),
1322 GTK_WIDGET_PTR(mainwin->messageview));
1323 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1324 prefs_common.mainview_width, -1);
1325 gtk_widget_set_usize(mainwin->window,
1326 prefs_common.folderview_width +
1327 prefs_common.mainview_width,
1328 prefs_common.mainwin_height);
1329 gtk_widget_show_all(vpaned);
1331 mainwin->win.sep_none.hpaned = hpaned;
1332 mainwin->win.sep_none.vpaned = vpaned;
1334 case SEPARATE_FOLDER:
1335 vpaned = gtk_vpaned_new();
1336 if (mainwin->summaryview->msg_is_toggled_on) {
1337 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1339 gtk_paned_add1(GTK_PANED(vpaned),
1340 GTK_WIDGET_PTR(mainwin->summaryview));
1342 gtk_box_pack_start(GTK_BOX(vbox_body),
1343 GTK_WIDGET_PTR(mainwin->summaryview),
1345 gtk_widget_ref(vpaned);
1347 gtk_paned_add2(GTK_PANED(vpaned),
1348 GTK_WIDGET_PTR(mainwin->messageview));
1349 gtk_widget_show_all(vpaned);
1350 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1351 prefs_common.summaryview_width,
1352 prefs_common.summaryview_height);
1353 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1354 prefs_common.mainview_width, -1);
1355 gtk_widget_set_usize(mainwin->window,
1356 prefs_common.mainview_width,
1357 prefs_common.mainview_height);
1359 gtk_container_add(GTK_CONTAINER(folderwin),
1360 GTK_WIDGET_PTR(mainwin->folderview));
1362 mainwin->win.sep_folder.folderwin = folderwin;
1363 mainwin->win.sep_folder.vpaned = vpaned;
1365 gtk_widget_show_all(folderwin);
1367 case SEPARATE_MESSAGE:
1368 hpaned = gtk_hpaned_new();
1369 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1371 gtk_paned_add1(GTK_PANED(hpaned),
1372 GTK_WIDGET_PTR(mainwin->folderview));
1373 gtk_paned_add2(GTK_PANED(hpaned),
1374 GTK_WIDGET_PTR(mainwin->summaryview));
1375 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1376 prefs_common.summaryview_width,
1377 prefs_common.summaryview_height);
1378 gtk_widget_set_usize(mainwin->window,
1379 prefs_common.folderview_width +
1380 prefs_common.mainview_width,
1381 prefs_common.mainwin_height);
1382 gtk_widget_show_all(hpaned);
1383 gtk_container_add(GTK_CONTAINER(messagewin),
1384 GTK_WIDGET_PTR(mainwin->messageview));
1386 mainwin->win.sep_message.messagewin = messagewin;
1387 mainwin->win.sep_message.hpaned = hpaned;
1389 gtk_widget_show_all(messagewin);
1392 gtk_box_pack_start(GTK_BOX(vbox_body),
1393 GTK_WIDGET_PTR(mainwin->summaryview),
1395 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1396 prefs_common.summaryview_width,
1397 prefs_common.summaryview_height);
1398 gtk_widget_set_usize(mainwin->window,
1399 prefs_common.mainview_width,
1400 prefs_common.mainwin_height);
1401 gtk_container_add(GTK_CONTAINER(folderwin),
1402 GTK_WIDGET_PTR(mainwin->folderview));
1403 gtk_container_add(GTK_CONTAINER(messagewin),
1404 GTK_WIDGET_PTR(mainwin->messageview));
1406 mainwin->win.sep_both.folderwin = folderwin;
1407 mainwin->win.sep_both.messagewin = messagewin;
1409 gtk_widget_show_all(folderwin);
1410 gtk_widget_show_all(messagewin);
1414 mainwin->type = type;
1416 debug_print(_("done.\n"));
1419 #include "pixmaps/stock_mail_receive.xpm"
1420 #include "pixmaps/stock_mail_receive_all.xpm"
1421 #include "pixmaps/stock_mail_compose.xpm"
1422 #include "pixmaps/stock_news_compose.xpm"
1423 #include "pixmaps/stock_mail_reply.xpm"
1424 #include "pixmaps/stock_mail_reply_to_all.xpm"
1425 #include "pixmaps/stock_mail_reply_to_author.xpm"
1426 #include "pixmaps/stock_mail_forward.xpm"
1427 #include "pixmaps/stock_mail_send.xpm"
1428 #include "pixmaps/stock_preferences.xpm"
1429 #include "pixmaps/stock_properties.xpm"
1430 #include "pixmaps/stock_down_arrow.xpm"
1431 #include "pixmaps/stock_close.xpm"
1432 #include "pixmaps/stock_exec.xpm"
1434 #define CREATE_TOOLBAR_ICON(xpm_d) \
1436 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1437 &container->style->white, \
1439 icon_wid = gtk_pixmap_new(icon, mask); \
1442 static void main_window_toolbar_create(MainWindow *mainwin,
1443 GtkWidget *container)
1448 GtkWidget *icon_wid;
1450 GtkWidget *getall_btn;
1451 GtkWidget *compose_mail_btn;
1452 GtkWidget *compose_news_btn;
1453 GtkWidget *compose_mail_btn_plain;
1454 GtkWidget *compose_news_btn_plain;
1455 GtkWidget *reply_btn;
1456 GtkWidget *replyall_btn;
1457 GtkWidget *replysender_btn;
1459 GtkWidget *send_btn;
1461 GtkWidget *prefs_btn;
1462 GtkWidget *account_btn;
1464 GtkWidget *next_btn;
1465 GtkWidget *delete_btn;
1466 GtkWidget *exec_btn;
1467 GtkWidget *compose_type_btn;
1468 GtkWidget *compose_type_arrow;
1469 GtkWidget *compose_box;
1470 GtkWidget *compose_label;
1471 GtkTooltips *tooltips;
1473 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1475 gtk_container_add(GTK_CONTAINER(container), toolbar);
1476 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1477 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1478 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1479 GTK_TOOLBAR_SPACE_LINE);
1481 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1482 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1484 _("Get new mail from current account"),
1486 icon_wid, toolbar_inc_cb, mainwin);
1487 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1488 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1490 _("Get new mail from all accounts"),
1496 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1498 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1499 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1501 _("Send queued message(s)"),
1507 /* to implement Leandro's "combined" compose buttons, we create
1508 * two sets of compose buttons, one for normal (text + icon)
1509 * toolbar, and one for both text-only and icon-only toolbar;
1510 * we switch between those sets. */
1512 /* insert compose mail button widget */
1514 compose_mail_btn = gtk_button_new();
1515 gtk_widget_show(compose_mail_btn);
1516 tooltips = gtk_tooltips_new();
1517 gtk_tooltips_set_tip(tooltips, compose_mail_btn,
1518 _("Compose email message"),
1520 compose_box = gtk_vbox_new(0, 0);
1521 gtk_widget_show(compose_box);
1523 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1524 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1525 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1527 compose_label = gtk_label_new(_("Email"));
1528 gtk_widget_show(compose_label);
1529 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1531 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1532 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1533 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1536 /* insert compose news button widget */
1538 compose_news_btn = gtk_button_new();
1539 gtk_widget_show(compose_news_btn);
1540 tooltips = gtk_tooltips_new();
1541 gtk_tooltips_set_tip(tooltips, compose_news_btn,
1542 _("Compose news article"),
1544 compose_box = gtk_vbox_new(0, 0);
1545 gtk_widget_show(compose_box);
1547 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1548 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1549 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1551 compose_label = gtk_label_new(_("News"));
1552 gtk_widget_show(compose_label);
1553 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1555 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_news_btn), GTK_CAN_FOCUS);
1556 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1557 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1560 /* insert compose btn plain */
1562 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1563 compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1565 _("Compose an email message"),
1568 toolbar_compose_mail_cb,
1571 /* insert compose btn plain */
1573 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1574 compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1576 _("Compose a news message"),
1579 toolbar_compose_news_cb,
1582 /* insert compose button type widget */
1584 compose_type_btn = gtk_button_new();
1585 gtk_widget_show(compose_type_btn);
1587 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1588 gtk_widget_show(compose_type_arrow);
1590 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1592 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1593 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1595 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1598 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1600 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1601 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1603 _("Reply to the message"),
1608 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1609 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1614 toolbar_reply_to_all_cb,
1616 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1617 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1619 _("Reply to sender"),
1622 toolbar_reply_to_sender_cb,
1624 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1625 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1627 _("Forward the message"),
1633 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1635 CREATE_TOOLBAR_ICON(stock_close_xpm);
1636 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1638 _("Delete the message"),
1644 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1645 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1647 _("Execute marked process"),
1653 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1654 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1656 _("Next unread message"),
1659 toolbar_next_unread_cb,
1663 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1665 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1666 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1668 _("Common preference"),
1673 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1674 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1676 _("Account setting"),
1681 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1682 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1686 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1687 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1690 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1691 GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
1694 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
1695 GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
1698 mainwin->toolbar = toolbar;
1699 mainwin->get_btn = get_btn;
1700 mainwin->getall_btn = getall_btn;
1701 mainwin->compose_mail_btn = compose_mail_btn;
1702 mainwin->compose_news_btn = compose_news_btn;
1703 mainwin->compose_mail_btn_plain = compose_mail_btn_plain;
1704 mainwin->compose_news_btn_plain = compose_news_btn_plain;
1705 mainwin->reply_btn = reply_btn;
1706 mainwin->replyall_btn = replyall_btn;
1707 mainwin->replysender_btn = replysender_btn;
1708 mainwin->fwd_btn = fwd_btn;
1709 mainwin->send_btn = send_btn;
1711 mainwin->prefs_btn = prefs_btn;
1712 mainwin->account_btn = account_btn;
1714 mainwin->next_btn = next_btn;
1715 mainwin->delete_btn = delete_btn;
1716 mainwin->exec_btn = exec_btn;
1718 gtk_widget_show_all(toolbar);
1720 /* activate Leandro menu system */
1721 activate_compose_button(mainwin,
1722 prefs_common.toolbar_style,
1723 mainwin->compose_btn_type);
1726 /* callback functions */
1728 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1731 MainWindow *mainwindow = (MainWindow *) data;
1732 GtkWidget *compose_menu, *compose_item;
1734 g_return_if_fail(mainwindow != NULL);
1736 compose_menu = gtk_menu_new();
1738 compose_item = gtk_menu_item_new_with_label(_("Email message"));
1739 gtk_widget_show(compose_item);
1740 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1741 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1742 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1744 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1746 compose_item = gtk_menu_item_new_with_label(_("News article"));
1747 gtk_widget_show(compose_item);
1748 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1749 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1750 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1752 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1754 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1758 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1760 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1761 MainWindow *mainwindow = (MainWindow *) data;
1763 mainwindow->compose_btn_type = compose_type;
1765 activate_compose_button(mainwindow, prefs_common.toolbar_style, mainwindow->compose_btn_type);
1768 static void toolbar_inc_cb (GtkWidget *widget,
1771 MainWindow *mainwin = (MainWindow *)data;
1773 inc_mail_cb(mainwin, 0, NULL);
1776 static void toolbar_inc_all_cb (GtkWidget *widget,
1779 MainWindow *mainwin = (MainWindow *)data;
1781 inc_all_account_mail_cb(mainwin, 0, NULL);
1784 static void toolbar_send_cb (GtkWidget *widget,
1787 MainWindow *mainwin = (MainWindow *)data;
1789 send_queue_cb(mainwin, 0, NULL);
1792 static void toolbar_compose_cb (GtkWidget *widget,
1795 MainWindow *mainwin = (MainWindow *)data;
1797 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1798 compose_cb(mainwin, 0, NULL);
1800 compose_news_cb(mainwin, 0, NULL);
1803 static void toolbar_compose_news_cb (GtkWidget *widget,
1806 MainWindow *mainwin = (MainWindow *)data;
1808 compose_news_cb(mainwin, 0, NULL);
1811 static void toolbar_compose_mail_cb (GtkWidget *widget,
1814 MainWindow *mainwin = (MainWindow *)data;
1816 compose_mail_cb(mainwin, 0, NULL);
1819 static void toolbar_reply_cb (GtkWidget *widget,
1822 MainWindow *mainwin = (MainWindow *)data;
1824 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1827 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1830 MainWindow *mainwin = (MainWindow *)data;
1832 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1835 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1838 MainWindow *mainwin = (MainWindow *)data;
1840 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1843 static void toolbar_forward_cb (GtkWidget *widget,
1846 MainWindow *mainwin = (MainWindow *)data;
1848 if (prefs_common.forward_as_attachment)
1849 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
1851 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1854 static void toolbar_delete_cb (GtkWidget *widget,
1857 MainWindow *mainwin = (MainWindow *)data;
1859 summary_delete(mainwin->summaryview);
1862 static void toolbar_exec_cb (GtkWidget *widget,
1865 MainWindow *mainwin = (MainWindow *)data;
1867 summary_execute(mainwin->summaryview);
1870 static void toolbar_next_unread_cb (GtkWidget *widget,
1873 MainWindow *mainwin = (MainWindow *)data;
1875 next_unread_cb(mainwin, 0, NULL);
1878 static void toolbar_prefs_cb (GtkWidget *widget,
1881 prefs_common_open();
1884 static void toolbar_account_cb (GtkWidget *widget,
1887 MainWindow *mainwin = (MainWindow *)data;
1889 prefs_account_open_cb(mainwin, 0, NULL);
1892 static void toolbar_account_button_pressed(GtkWidget *widget,
1893 GdkEventButton *event,
1896 MainWindow *mainwin = (MainWindow *)data;
1899 if (event->button != 3) return;
1901 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1902 event->button, event->time);
1905 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1908 MainWindow *mainwin = (MainWindow *)data;
1912 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1913 event->button, event->time);
1916 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1919 app_exit_cb(data, 0, widget);
1924 static void add_mailbox_cb(MainWindow *mainwin, guint action,
1927 main_window_add_mailbox(mainwin);
1930 static void add_mbox_cb(MainWindow *mainwin, guint action,
1933 main_window_add_mbox(mainwin);
1936 static void update_folderview_cb(MainWindow *mainwin, guint action,
1939 summary_show(mainwin->summaryview, NULL, FALSE);
1940 folderview_update_all_node();
1943 static void new_folder_cb(MainWindow *mainwin, guint action,
1946 folderview_new_folder(mainwin->folderview);
1949 static void rename_folder_cb(MainWindow *mainwin, guint action,
1952 folderview_rename_folder(mainwin->folderview);
1955 static void delete_folder_cb(MainWindow *mainwin, guint action,
1958 folderview_delete_folder(mainwin->folderview);
1961 static void import_mbox_cb(MainWindow *mainwin, guint action,
1964 import_mbox(mainwin->summaryview->folder_item);
1967 static void export_mbox_cb(MainWindow *mainwin, guint action,
1970 export_mbox(mainwin->summaryview->folder_item);
1973 static void empty_trash_cb(MainWindow *mainwin, guint action,
1976 main_window_empty_trash(mainwin, TRUE);
1979 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1981 summary_save_as(mainwin->summaryview);
1984 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1986 summary_print(mainwin->summaryview);
1989 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1991 if (prefs_common.confirm_on_exit) {
1992 if (alertpanel(_("Exit"), _("Exit this program?"),
1993 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
1995 manage_window_focus_in(mainwin->window, NULL, NULL);
1998 app_will_exit(widget, mainwin);
2001 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2004 switch (mainwin->type) {
2006 case SEPARATE_MESSAGE:
2008 case SEPARATE_FOLDER:
2009 if (GTK_CHECK_MENU_ITEM(widget)->active)
2010 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2012 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2015 if (GTK_CHECK_MENU_ITEM(widget)->active)
2016 gtk_widget_show(mainwin->win.sep_both.folderwin);
2018 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2023 static void toggle_message_cb(MainWindow *mainwin, guint action,
2026 switch (mainwin->type) {
2028 case SEPARATE_FOLDER:
2030 case SEPARATE_MESSAGE:
2031 if (GTK_CHECK_MENU_ITEM(widget)->active)
2032 gtk_widget_show(mainwin->win.sep_message.messagewin);
2034 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2037 if (GTK_CHECK_MENU_ITEM(widget)->active)
2038 gtk_widget_show(mainwin->win.sep_both.messagewin);
2040 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2045 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2048 activate_compose_button(mainwin, (ToolbarStyle)action,
2049 mainwin->compose_btn_type);
2051 switch ((ToolbarStyle)action) {
2053 gtk_widget_hide(mainwin->handlebox);
2055 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2059 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2063 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2068 if (action != TOOLBAR_NONE) {
2069 gtk_widget_show(mainwin->handlebox);
2070 gtk_widget_queue_resize(mainwin->handlebox);
2073 mainwin->toolbar_style = (ToolbarStyle)action;
2074 prefs_common.toolbar_style = (ToolbarStyle)action;
2077 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2080 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2081 gtk_widget_show(mainwin->hbox_stat);
2082 prefs_common.show_statusbar = TRUE;
2084 gtk_widget_hide(mainwin->hbox_stat);
2085 prefs_common.show_statusbar = FALSE;
2089 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2092 MainWindow *mainwin;
2095 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2096 g_return_if_fail(mainwin != NULL);
2098 type = mainwin->type ^ action;
2099 main_window_separation_change(mainwin, type);
2101 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2102 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2105 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2108 addressbook_open(NULL);
2111 static void log_window_show_cb(MainWindow *mainwin, guint action,
2114 log_window_show(mainwin->logwin);
2117 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2122 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2125 inc_all_account_mail(mainwin);
2128 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2132 if (procmsg_send_queue() < 0)
2133 alertpanel_error(_("Sending queued message failed."));
2135 statusbar_pop_all();
2137 for (list = folder_get_list(); list != NULL; list = list->next) {
2140 folder = list->data;
2141 if (folder->queue) {
2142 folder_item_scan(folder->queue);
2143 folderview_update_item(folder->queue, TRUE);
2148 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2150 if (mainwin->summaryview->folder_item) {
2151 if (mainwin->summaryview->folder_item->folder->account != NULL
2152 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2153 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2155 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2161 static void compose_mail_cb(MainWindow *mainwin, guint action,
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_folderitem(ac, mainwin->summaryview->folder_item);
2176 if(cur_account && (cur_account->protocol != A_NNTP)) {
2177 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2181 list = account_get_list();
2182 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2183 ac = (PrefsAccount *) cur->data;
2184 if (ac->protocol != A_NNTP) {
2185 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2191 static void compose_news_cb(MainWindow *mainwin, guint action,
2194 PrefsAccount * ac = NULL;
2198 if (mainwin->summaryview->folder_item) {
2199 ac = mainwin->summaryview->folder_item->folder->account;
2200 if (ac && ac->protocol == A_NNTP) {
2201 compose_new_with_recipient
2202 (ac, mainwin->summaryview->folder_item->path);
2207 list = account_get_list();
2208 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2209 ac = (PrefsAccount *) cur->data;
2210 if (ac->protocol == A_NNTP) {
2217 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2219 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2222 msginfo = gtk_ctree_node_get_row_data
2223 (GTK_CTREE(mainwin->summaryview->ctree),
2224 mainwin->summaryview->selected);
2226 if (!msginfo) return;
2230 compose_reply(msginfo, prefs_common.reply_with_quote,
2233 case COMPOSE_REPLY_TO_SENDER:
2234 compose_reply(msginfo, prefs_common.reply_with_quote,
2237 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2238 compose_followup_and_reply_to(msginfo,
2239 prefs_common.reply_with_quote,
2242 case COMPOSE_REPLY_TO_ALL:
2243 compose_reply(msginfo, prefs_common.reply_with_quote,
2246 case COMPOSE_FORWARD:
2248 compose_forward(NULL, msginfo, FALSE);
2251 /* if (sel->next) FALL_THROUGH */
2252 case COMPOSE_FORWARD_AS_ATTACH:
2254 GSList *msginfo_list = NULL;
2255 for ( ; sel != NULL; sel = sel->next)
2256 msginfo_list = g_slist_append(msginfo_list,
2257 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2258 GTK_CTREE_NODE(sel->data)));
2259 compose_forward_multiple(NULL, msginfo_list);
2260 g_slist_free(msginfo_list);
2264 g_warning("reply_cb(): invalid action type: %d\n", action);
2267 summary_set_marks_selected(mainwin->summaryview);
2270 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2272 summary_move_to(mainwin->summaryview);
2275 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2277 summary_copy_to(mainwin->summaryview);
2280 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2282 summary_delete(mainwin->summaryview);
2285 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2287 summary_open_msg(mainwin->summaryview);
2290 static void view_source_cb(MainWindow *mainwin, guint action,
2293 summary_view_source(mainwin->summaryview);
2296 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2298 summary_reedit(mainwin->summaryview);
2301 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2303 summary_mark(mainwin->summaryview);
2306 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2308 summary_unmark(mainwin->summaryview);
2311 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2314 summary_mark_as_unread(mainwin->summaryview);
2317 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2320 summary_mark_as_read(mainwin->summaryview);
2323 static void set_charset_cb(MainWindow *mainwin, guint action,
2328 str = conv_get_charset_str((CharSet)action);
2329 g_free(prefs_common.force_charset);
2330 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2332 summary_redisplay_msg(mainwin->summaryview);
2334 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2337 /*void main_window_set_thread_option(MainWindow *mainwin)
2339 GtkItemFactory *ifactory;
2340 gboolean no_item = FALSE;
2342 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2344 if (mainwin->summaryview == NULL)
2346 else if (mainwin->summaryview->folder_item == NULL)
2350 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2351 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2354 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2355 menu_set_sensitive(ifactory,
2356 "/Summary/Thread view", FALSE);
2357 menu_set_sensitive(ifactory,
2358 "/Summary/Unthread view", TRUE);
2359 summary_thread_build(mainwin->summaryview, TRUE);
2362 menu_set_sensitive(ifactory,
2363 "/Summary/Thread view", TRUE);
2364 menu_set_sensitive(ifactory,
2365 "/Summary/Unthread view", FALSE);
2366 summary_unthread(mainwin->summaryview);
2368 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2372 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2374 /*mainwin->summaryview->folder_item->prefs->enable_thread =
2375 !mainwin->summaryview->folder_item->prefs->enable_thread;
2376 main_window_set_thread_option(mainwin);
2379 GtkItemFactory *ifactory;
2381 ifactory = gtk_item_factory_from_widget(widget);
2384 summary_thread_build(mainwin->summaryview, FALSE);
2385 prefs_common.enable_thread = TRUE;
2386 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2387 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2389 summary_unthread(mainwin->summaryview);
2390 prefs_common.enable_thread = FALSE;
2391 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2392 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2397 static void set_display_item_cb(MainWindow *mainwin, guint action,
2400 prefs_summary_display_item_set();
2403 static void sort_summary_cb(MainWindow *mainwin, guint action,
2406 summary_sort(mainwin->summaryview, (SummarySortType)action);
2409 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2412 summary_attract_by_subject(mainwin->summaryview);
2415 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2418 summary_delete_duplicated(mainwin->summaryview);
2421 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2423 summary_filter(mainwin->summaryview);
2426 static void execute_summary_cb(MainWindow *mainwin, guint action,
2429 summary_execute(mainwin->summaryview);
2432 static void update_summary_cb(MainWindow *mainwin, guint action,
2436 FolderView *folderview = mainwin->folderview;
2438 if (!mainwin->summaryview->folder_item) return;
2439 if (!folderview->opened) return;
2441 folder_update_op_count();
2443 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2444 folderview->opened);
2447 summary_show(mainwin->summaryview, fitem, TRUE);
2450 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2452 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2455 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2457 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2460 static void next_unread_cb(MainWindow *mainwin, guint action,
2463 summary_select_next_unread(mainwin->summaryview);
2466 static void next_marked_cb(MainWindow *mainwin, guint action,
2469 summary_select_next_marked(mainwin->summaryview);
2472 static void prev_marked_cb(MainWindow *mainwin, guint action,
2475 summary_select_prev_marked(mainwin->summaryview);
2478 static void goto_folder_cb(MainWindow *mainwin, guint action,
2481 FolderItem *to_folder;
2483 to_folder = foldersel_folder_sel(NULL, NULL);
2486 folderview_select(mainwin->folderview, to_folder);
2489 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2491 messageview_copy_clipboard(mainwin->messageview);
2494 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2496 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2497 summary_select_all(mainwin->summaryview);
2498 else if (mainwin->summaryview->msg_is_toggled_on &&
2499 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2500 messageview_select_all(mainwin->messageview);
2503 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2506 prefs_common_open();
2509 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2512 prefs_filter_open();
2515 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2518 prefs_scoring_open(NULL);
2521 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2524 prefs_filtering_open();
2527 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2531 new_account_cb(mainwin, 0, widget);
2533 gboolean prev_default = cur_account->is_default;
2535 prefs_account_open(cur_account);
2536 if (!prev_default && cur_account->is_default)
2537 account_set_as_default(cur_account);
2538 account_save_config_all();
2540 main_window_reflect_prefs_all();
2544 static void new_account_cb(MainWindow *mainwin, guint action,
2547 account_edit_open();
2548 if (!compose_get_compose_list()) account_add();
2551 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2553 cur_account = (PrefsAccount *)data;
2554 main_window_reflect_prefs_all();
2557 static void manual_open_cb(MainWindow *mainwin, guint action,
2560 manual_open((ManualLang)action);
2563 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2565 MainWindow *mainwin = (MainWindow *)data;
2569 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2570 LOCAL_FOLDER(folder)->rootpath,
2574 str = g_strdup_printf(_("Scanning folder %s ..."),
2575 LOCAL_FOLDER(folder)->rootpath);
2577 STATUSBAR_PUSH(mainwin, str);
2578 STATUSBAR_POP(mainwin);
2582 static void activate_compose_button (MainWindow *mainwin,
2584 ComposeButtonType type)
2586 if (style == TOOLBAR_NONE)
2589 if (style == TOOLBAR_BOTH) {
2590 gtk_widget_hide(mainwin->compose_mail_btn_plain);
2591 gtk_widget_hide(mainwin->compose_news_btn_plain);
2592 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2593 : mainwin->compose_news_btn);
2594 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2595 : mainwin->compose_mail_btn);
2596 mainwin->compose_btn_type = type;
2599 gtk_widget_hide(mainwin->compose_news_btn);
2600 gtk_widget_hide(mainwin->compose_mail_btn);
2601 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn_plain
2602 : mainwin->compose_news_btn_plain);
2603 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn_plain
2604 : mainwin->compose_mail_btn_plain);
2605 mainwin->compose_btn_type = type;