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/gtkprogressbar.h>
31 #include <gtk/gtkhpaned.h>
32 #include <gtk/gtkvpaned.h>
33 #include <gtk/gtkcheckmenuitem.h>
34 #include <gtk/gtkitemfactory.h>
35 #include <gtk/gtkeditable.h>
36 #include <gtk/gtkmenu.h>
37 #include <gtk/gtkmenuitem.h>
38 #include <gtk/gtkhandlebox.h>
39 #include <gtk/gtktoolbar.h>
40 #include <gtk/gtkbutton.h>
45 #include "mainwindow.h"
46 #include "folderview.h"
47 #include "foldersel.h"
48 #include "summaryview.h"
49 #include "summary_search.h"
50 #include "messageview.h"
51 #include "headerview.h"
59 #include "prefs_common.h"
60 #include "prefs_filter.h"
61 #include "prefs_filtering.h"
62 #include "prefs_scoring.h"
63 #include "prefs_account.h"
64 #include "prefs_folder_item.h"
66 #include "addressbook.h"
67 #include "headerwindow.h"
68 #include "logwindow.h"
69 #include "manage_window.h"
70 #include "alertpanel.h"
71 #include "statusbar.h"
72 #include "inputdialog.h"
78 #include "prefs_templates.h"
80 #define AC_LABEL_WIDTH 240
82 #define STATUSBAR_PUSH(mainwin, str) \
84 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
85 mainwin->mainwin_cid, str); \
86 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
89 #define STATUSBAR_POP(mainwin) \
91 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
92 mainwin->mainwin_cid); \
95 /* list of all instantiated MainWindow */
96 static GList *mainwin_list = NULL;
98 static GdkCursor *watch_cursor;
100 static void main_window_show_cur_account (MainWindow *mainwin);
102 static void main_window_set_widgets (MainWindow *mainwin,
104 static void main_window_toolbar_create (MainWindow *mainwin,
105 GtkWidget *container);
107 /* callback functions */
108 static void toolbar_inc_cb (GtkWidget *widget,
110 static void toolbar_inc_all_cb (GtkWidget *widget,
112 static void toolbar_send_cb (GtkWidget *widget,
115 static void toolbar_compose_cb (GtkWidget *widget,
117 static void toolbar_popup_compose_type_cb(GtkWidget *widget,
119 static void toolbar_popup_compose_type_set(GtkWidget *widget,
121 static void toolbar_compose_news_cb (GtkWidget *widget,
123 static void toolbar_compose_mail_cb (GtkWidget *widget,
125 static void toolbar_reply_cb (GtkWidget *widget,
127 static void toolbar_reply_to_all_cb (GtkWidget *widget,
129 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
131 static void toolbar_forward_cb (GtkWidget *widget,
134 static void toolbar_delete_cb (GtkWidget *widget,
136 static void toolbar_exec_cb (GtkWidget *widget,
139 static void toolbar_next_unread_cb (GtkWidget *widget,
142 static void toolbar_prefs_cb (GtkWidget *widget,
144 static void toolbar_account_cb (GtkWidget *widget,
147 static void toolbar_account_button_pressed (GtkWidget *widget,
148 GdkEventButton *event,
150 static void ac_label_button_pressed (GtkWidget *widget,
151 GdkEventButton *event,
153 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
156 static gint main_window_close_cb (GtkWidget *widget,
160 static void add_mailbox_cb (MainWindow *mainwin,
163 static void add_mbox_cb (MainWindow *mainwin,
166 static void update_folderview_cb (MainWindow *mainwin,
169 static void new_folder_cb (MainWindow *mainwin,
172 static void rename_folder_cb (MainWindow *mainwin,
175 static void delete_folder_cb (MainWindow *mainwin,
178 static void import_mbox_cb (MainWindow *mainwin,
181 static void export_mbox_cb (MainWindow *mainwin,
184 static void empty_trash_cb (MainWindow *mainwin,
188 static void save_as_cb (MainWindow *mainwin,
191 static void print_cb (MainWindow *mainwin,
194 static void app_exit_cb (MainWindow *mainwin,
198 static void toggle_folder_cb (MainWindow *mainwin,
201 static void toggle_message_cb (MainWindow *mainwin,
204 static void toggle_toolbar_cb (MainWindow *mainwin,
207 static void toggle_statusbar_cb (MainWindow *mainwin,
210 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
214 static void addressbook_open_cb (MainWindow *mainwin,
217 static void log_window_show_cb (MainWindow *mainwin,
221 static void inc_mail_cb (MainWindow *mainwin,
224 static void inc_all_account_mail_cb (MainWindow *mainwin,
228 static void send_queue_cb (MainWindow *mainwin,
232 static void compose_cb (MainWindow *mainwin,
235 static void compose_mail_cb(MainWindow *mainwin, guint action,
237 static void compose_news_cb(MainWindow *mainwin, guint action,
239 static void reply_cb (MainWindow *mainwin,
243 static void open_msg_cb (MainWindow *mainwin,
247 static void view_source_cb (MainWindow *mainwin,
251 static void reedit_cb (MainWindow *mainwin,
255 static void move_to_cb (MainWindow *mainwin,
258 static void copy_to_cb (MainWindow *mainwin,
261 static void delete_cb (MainWindow *mainwin,
265 static void mark_cb (MainWindow *mainwin,
268 static void unmark_cb (MainWindow *mainwin,
272 static void mark_as_unread_cb (MainWindow *mainwin,
275 static void mark_as_read_cb (MainWindow *mainwin,
279 static void set_charset_cb (MainWindow *mainwin,
283 static void thread_cb (MainWindow *mainwin,
286 static void set_display_item_cb (MainWindow *mainwin,
289 static void sort_summary_cb (MainWindow *mainwin,
292 static void attract_by_subject_cb(MainWindow *mainwin,
296 static void delete_duplicated_cb (MainWindow *mainwin,
299 static void filter_cb (MainWindow *mainwin,
302 static void execute_summary_cb (MainWindow *mainwin,
305 static void update_summary_cb (MainWindow *mainwin,
309 static void prev_cb (MainWindow *mainwin,
312 static void next_cb (MainWindow *mainwin,
316 static void next_unread_cb (MainWindow *mainwin,
320 static void next_marked_cb (MainWindow *mainwin,
324 static void prev_marked_cb (MainWindow *mainwin,
328 static void next_labeled_cb (MainWindow *mainwin,
333 static void prev_labeled_cb (MainWindow *mainwin,
338 static void goto_folder_cb (MainWindow *mainwin,
342 static void copy_cb (MainWindow *mainwin,
345 static void allsel_cb (MainWindow *mainwin,
349 static void prefs_common_open_cb (MainWindow *mainwin,
352 static void prefs_filter_open_cb (MainWindow *mainwin,
355 static void prefs_scoring_open_cb (MainWindow *mainwin,
358 static void prefs_filtering_open_cb (MainWindow *mainwin,
361 static void prefs_account_open_cb(MainWindow *mainwin,
364 static void new_account_cb (MainWindow *mainwin,
368 static void account_menu_cb (GtkMenuItem *menuitem,
371 static void manual_open_cb (MainWindow *mainwin,
375 static void scan_tree_func (Folder *folder,
379 static void activate_compose_button (MainWindow *mainwin,
381 ComposeButtonType type);
383 static void prefs_templates_open_cb(MainWindow *mainwin,
387 #define SEPARATE_ACTION 667
389 static GtkItemFactoryEntry mainwin_entries[] =
391 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
392 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
393 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
394 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
395 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
396 {N_("/_File/_Folder/Create _new folder..."),
397 NULL, new_folder_cb, 0, NULL},
398 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
399 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
400 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
401 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
402 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
403 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
404 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
405 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
406 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
407 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
408 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
410 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
411 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
412 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
413 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
414 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
416 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
417 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
418 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
419 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
420 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
421 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
422 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
423 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
424 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
425 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
426 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
427 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
428 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
429 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
430 {N_("/_View/_Code set/_Auto detect"),
431 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
433 #define CODESET_SEPARATOR \
434 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
435 #define CODESET_ACTION(action) \
436 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
438 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
439 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
440 CODESET_ACTION(C_US_ASCII)},
443 {N_("/_View/_Code set/Unicode (_UTF-8)"),
444 CODESET_ACTION(C_UTF_8)},
447 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
448 CODESET_ACTION(C_ISO_8859_1)},
451 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
452 CODESET_ACTION(C_ISO_8859_2)},
454 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
455 CODESET_ACTION(C_ISO_8859_13)},
456 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
457 CODESET_ACTION(C_ISO_8859_4)},
459 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
460 CODESET_ACTION(C_ISO_8859_7)},
462 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
463 CODESET_ACTION(C_ISO_8859_9)},
465 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
466 CODESET_ACTION(C_ISO_8859_5)},
467 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
468 CODESET_ACTION(C_KOI8_R)},
469 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
470 CODESET_ACTION(C_CP1251)},
473 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
474 CODESET_ACTION(C_ISO_2022_JP)},
476 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
477 CODESET_ACTION(C_ISO_2022_JP_2)},
479 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
480 CODESET_ACTION(C_EUC_JP)},
481 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
482 CODESET_ACTION(C_SHIFT_JIS)},
485 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
486 CODESET_ACTION(C_GB2312)},
487 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
488 CODESET_ACTION(C_BIG5)},
489 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
490 CODESET_ACTION(C_EUC_TW)},
491 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
492 CODESET_ACTION(C_ISO_2022_CN)},
494 {N_("/_View/_Code set/Korean (EUC-_KR)"),
495 CODESET_ACTION(C_EUC_KR)},
496 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
497 CODESET_ACTION(C_ISO_2022_KR)},
500 #undef CODESET_SEPARATOR
501 #undef CODESET_ACTION
503 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
504 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
505 {N_("/_Message/Get from _all accounts"),
506 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
507 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
508 {N_("/_Message/Send queued messa_ges"),
509 NULL, send_queue_cb, 0, NULL},
510 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
512 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
513 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
514 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
515 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
516 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
517 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
518 {N_("/_Message/Forward as a_ttachment"),
519 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
520 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
522 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
523 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
524 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
525 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
526 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
527 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
528 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
529 {N_("/_Message/_Mark/Mark as rea_d"),
530 NULL, mark_as_read_cb, 0, NULL},
531 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
532 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
533 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
534 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
535 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
537 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
538 {N_("/_Summary/_Delete duplicated messages"),
539 NULL, delete_duplicated_cb, 0, NULL},
540 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
541 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
542 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
543 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
545 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
546 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
547 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
548 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
549 {N_("/_Summary/Prev labeled message"), NULL, prev_labeled_cb, 0, NULL},
550 {N_("/_Summary/Next labeled message"), NULL, next_labeled_cb, 0, NULL},
551 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
553 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
554 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
555 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
556 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
557 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
558 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
559 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
560 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
561 {N_("/_Summary/_Sort/Sort by _label"), NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
562 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_Summary/_Sort/_Attract by subject"),
564 NULL, attract_by_subject_cb, 0, NULL},
565 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
566 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
567 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
569 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
570 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
571 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
573 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
574 {N_("/_Configuration/_Common preferences..."),
575 NULL, prefs_common_open_cb, 0, NULL},
576 {N_("/_Configuration/_Filter setting..."),
577 NULL, prefs_filter_open_cb, 0, NULL},
578 {N_("/_Configuration/_Scoring ..."),
579 NULL, prefs_scoring_open_cb, 0, NULL},
580 {N_("/_Configuration/_Filtering ..."),
581 NULL, prefs_filtering_open_cb, 0, NULL},
582 {N_("/_Configuration/_Templates ..."),
583 NULL, prefs_templates_open_cb, 0, NULL},
584 {N_("/_Configuration/_Preferences per account..."),
585 NULL, prefs_account_open_cb, 0, NULL},
586 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
587 {N_("/_Configuration/Create _new account..."),
588 NULL, new_account_cb, 0, NULL},
589 {N_("/_Configuration/_Edit accounts..."),
590 NULL, account_edit_open, 0, NULL},
591 {N_("/_Configuration/C_hange current account"),
592 NULL, NULL, 0, "<Branch>"},
594 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
595 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
596 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
597 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
598 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
602 MainWindow *main_window_create(SeparateType type)
608 GtkWidget *handlebox;
609 GtkWidget *vbox_body;
610 GtkWidget *hbox_stat;
611 GtkWidget *statusbar;
612 GtkWidget *progressbar;
613 GtkWidget *statuslabel;
614 GtkWidget *ac_button;
617 FolderView *folderview;
618 SummaryView *summaryview;
619 MessageView *messageview;
620 GdkColormap *colormap;
623 guint n_menu_entries;
624 GtkItemFactory *ifactory;
629 debug_print(_("Creating main window...\n"));
630 mainwin = g_new0(MainWindow, 1);
633 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
634 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
635 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
636 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
637 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
638 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
639 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
640 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
641 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
643 gtk_widget_realize(window);
645 gtkut_widget_set_app_icon(window);
647 vbox = gtk_vbox_new(FALSE, 0);
648 gtk_widget_show(vbox);
649 gtk_container_add(GTK_CONTAINER(window), vbox);
652 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
653 menubar = menubar_create(window, mainwin_entries,
654 n_menu_entries, "<Main>", mainwin);
655 gtk_widget_show(menubar);
656 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
658 handlebox = gtk_handle_box_new();
659 gtk_widget_show(handlebox);
660 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
662 main_window_toolbar_create(mainwin, handlebox);
664 /* vbox that contains body */
665 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
666 gtk_widget_show(vbox_body);
667 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
668 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
670 hbox_stat = gtk_hbox_new(FALSE, 2);
671 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
673 statusbar = statusbar_create();
674 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
676 progressbar = gtk_progress_bar_new();
677 gtk_widget_set_usize(progressbar, 120, 1);
678 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
680 statuslabel = gtk_label_new("");
681 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
683 ac_button = gtk_button_new();
684 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
685 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
686 gtk_widget_set_usize(ac_button, -1, 1);
687 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
688 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
689 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
691 ac_label = gtk_label_new("");
692 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
694 gtk_widget_show_all(hbox_stat);
697 mainwin->folderview = folderview = folderview_create();
698 mainwin->summaryview = summaryview = summary_create();
699 mainwin->messageview = messageview = messageview_create();
700 mainwin->headerwin = header_window_create();
701 mainwin->logwin = log_window_create();
703 folderview->mainwin = mainwin;
704 folderview->summaryview = summaryview;
706 summaryview->mainwin = mainwin;
707 summaryview->folderview = folderview;
708 summaryview->messageview = messageview;
709 summaryview->headerwin = mainwin->headerwin;
710 summaryview->window = window;
712 messageview->mainwin = mainwin;
714 mainwin->window = window;
715 mainwin->vbox = vbox;
716 mainwin->menubar = menubar;
717 mainwin->handlebox = handlebox;
718 mainwin->vbox_body = vbox_body;
719 mainwin->hbox_stat = hbox_stat;
720 mainwin->statusbar = statusbar;
721 mainwin->progressbar = progressbar;
722 mainwin->statuslabel = statuslabel;
723 mainwin->ac_button = ac_button;
724 mainwin->ac_label = ac_label;
726 /* set context IDs for status bar */
727 mainwin->mainwin_cid = gtk_statusbar_get_context_id
728 (GTK_STATUSBAR(statusbar), "Main Window");
729 mainwin->folderview_cid = gtk_statusbar_get_context_id
730 (GTK_STATUSBAR(statusbar), "Folder View");
731 mainwin->summaryview_cid = gtk_statusbar_get_context_id
732 (GTK_STATUSBAR(statusbar), "Summary View");
734 /* allocate colors for summary view and folder view */
735 summaryview->color_marked.red = summaryview->color_marked.green = 0;
736 summaryview->color_marked.blue = (guint16)65535;
738 summaryview->color_dim.red = summaryview->color_dim.green =
739 summaryview->color_dim.blue = COLOR_DIM;
741 folderview->color_new.red = (guint16)55000;
742 folderview->color_new.green = folderview->color_new.blue = 15000;
744 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
745 &folderview->color_op);
747 summaryview->color_important.red = 0;
748 summaryview->color_marked.green = 0;
749 summaryview->color_important.blue = (guint16)65535;
751 color[0] = summaryview->color_marked;
752 color[1] = summaryview->color_dim;
753 color[2] = folderview->color_new;
754 color[3] = folderview->color_op;
756 colormap = gdk_window_get_colormap(window->window);
757 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
758 for (i = 0; i < 4; i++) {
759 if (success[i] == FALSE)
760 g_warning(_("MainWindow: color allocation %d failed\n"), i);
763 debug_print(_("done.\n"));
765 main_window_set_widgets(mainwin, type);
768 ifactory = gtk_item_factory_from_widget(menubar);
769 menuitem = gtk_item_factory_get_item
770 (ifactory, "/View/Code set/Auto detect");
771 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
773 switch (prefs_common.toolbar_style) {
775 menuitem = gtk_item_factory_get_item
776 (ifactory, "/View/Toolbar/None");
779 menuitem = gtk_item_factory_get_item
780 (ifactory, "/View/Toolbar/Icon");
783 menuitem = gtk_item_factory_get_item
784 (ifactory, "/View/Toolbar/Text");
787 menuitem = gtk_item_factory_get_item
788 (ifactory, "/View/Toolbar/Icon and text");
790 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
792 gtk_widget_hide(mainwin->hbox_stat);
793 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
794 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
795 prefs_common.show_statusbar);
797 /* set the check of the SEPARATE_xxx menu items. we also need the main window
798 * as a property and pass the action type to the callback */
799 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
801 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
802 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
803 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
804 GUINT_TO_POINTER(SEPARATE_FOLDER));
806 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
808 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
809 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
810 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
811 GUINT_TO_POINTER(SEPARATE_MESSAGE));
814 menu_set_sensitive(ifactory, "/Summary/Thread view",
815 prefs_common.enable_thread ? FALSE : TRUE);
816 menu_set_sensitive(ifactory, "/Summary/Unthread view",
817 prefs_common.enable_thread ? TRUE : FALSE);
819 /*main_window_set_thread_option(mainwin);*/
822 /* set account selection menu */
823 ac_menu = gtk_item_factory_get_widget
824 (ifactory, "/Configuration/Change current account");
825 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
826 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
827 mainwin->ac_menu = ac_menu;
829 main_window_set_toolbar_sensitive(mainwin);
831 /* show main window */
832 gtk_widget_set_uposition(mainwin->window,
833 prefs_common.mainwin_x,
834 prefs_common.mainwin_y);
835 gtk_widget_set_usize(window, prefs_common.mainwin_width,
836 prefs_common.mainwin_height);
838 gtk_widget_show(mainwin->window);
840 /* initialize views */
841 folderview_init(folderview);
842 summary_init(summaryview);
843 messageview_init(messageview);
844 header_window_init(mainwin->headerwin);
845 log_window_init(mainwin->logwin);
848 mainwin->lock_count = 0;
849 mainwin->cursor_count = 0;
852 watch_cursor = gdk_cursor_new(GDK_WATCH);
854 mainwin_list = g_list_append(mainwin_list, mainwin);
859 void main_window_cursor_wait(MainWindow *mainwin)
862 if (mainwin->cursor_count == 0)
863 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
865 mainwin->cursor_count++;
870 void main_window_cursor_normal(MainWindow *mainwin)
872 if (mainwin->cursor_count)
873 mainwin->cursor_count--;
875 if (mainwin->cursor_count == 0)
876 gdk_window_set_cursor(mainwin->window->window, NULL);
881 /* lock / unlock the user-interface */
882 void main_window_lock(MainWindow *mainwin)
884 if (mainwin->lock_count == 0)
885 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
887 mainwin->lock_count++;
889 main_window_set_menu_sensitive(mainwin);
890 main_window_set_toolbar_sensitive(mainwin);
893 void main_window_unlock(MainWindow *mainwin)
895 if (mainwin->lock_count)
896 mainwin->lock_count--;
898 main_window_set_menu_sensitive(mainwin);
899 main_window_set_toolbar_sensitive(mainwin);
901 if (mainwin->lock_count == 0)
902 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
905 void main_window_reflect_prefs_all(void)
910 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
911 mainwin = (MainWindow *)cur->data;
913 main_window_show_cur_account(mainwin);
914 main_window_set_menu_sensitive(mainwin);
915 main_window_set_toolbar_sensitive(mainwin);
917 if (prefs_common.immediate_exec)
918 gtk_widget_hide(mainwin->exec_btn);
920 gtk_widget_show(mainwin->exec_btn);
922 summary_change_display_item(mainwin->summaryview);
923 summary_redisplay_msg(mainwin->summaryview);
924 headerview_set_visibility(mainwin->messageview->headerview,
925 prefs_common.display_header_pane);
929 void main_window_set_account_menu(GList *account_list)
931 GList *cur, *cur_ac, *cur_item;
934 PrefsAccount *ac_prefs;
936 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
937 mainwin = (MainWindow *)cur->data;
939 /* destroy all previous menu item */
940 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
941 while (cur_item != NULL) {
942 GList *next = cur_item->next;
943 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
947 for (cur_ac = account_list; cur_ac != NULL;
948 cur_ac = cur_ac->next) {
949 ac_prefs = (PrefsAccount *)cur_ac->data;
951 menuitem = gtk_menu_item_new_with_label
952 (ac_prefs->account_name
953 ? ac_prefs->account_name : _("Untitled"));
954 gtk_widget_show(menuitem);
955 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
956 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
957 GTK_SIGNAL_FUNC(account_menu_cb),
963 static void main_window_show_cur_account(MainWindow *mainwin)
968 ac_name = g_strdup(cur_account
969 ? (cur_account->account_name
970 ? cur_account->account_name : _("Untitled"))
974 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
976 buf = g_strdup(PROG_VERSION);
977 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
980 /* buf = g_strdup_printf(_("Current account: %s"), ac_name);
981 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf); */
982 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
983 gtk_widget_queue_resize(mainwin->ac_button);
989 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
991 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
992 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
993 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
995 if (mainwin->type == type) return;
997 /* remove widgets from those containers */
998 gtk_widget_ref(folder_wid);
999 gtk_widget_ref(summary_wid);
1000 gtk_widget_ref(message_wid);
1001 gtk_container_remove
1002 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1003 gtk_container_remove
1004 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1005 gtk_container_remove
1006 (GTK_CONTAINER(message_wid->parent), message_wid);
1008 /* clean containers */
1009 switch (mainwin->type) {
1011 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1013 case SEPARATE_FOLDER:
1014 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1015 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1017 case SEPARATE_MESSAGE:
1018 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1019 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1022 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1023 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1027 gtk_widget_hide(mainwin->window);
1028 main_window_set_widgets(mainwin, type);
1029 gtk_widget_show(mainwin->window);
1031 gtk_widget_unref(folder_wid);
1032 gtk_widget_unref(summary_wid);
1033 gtk_widget_unref(message_wid);
1036 void main_window_get_size(MainWindow *mainwin)
1038 GtkAllocation *allocation;
1040 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1042 prefs_common.summaryview_width = allocation->width;
1044 if (mainwin->summaryview->msg_is_toggled_on)
1045 prefs_common.summaryview_height = allocation->height;
1047 prefs_common.mainview_width = allocation->width;
1049 allocation = &mainwin->window->allocation;
1051 prefs_common.mainview_height = allocation->height;
1052 prefs_common.mainwin_width = allocation->width;
1053 prefs_common.mainwin_height = allocation->height;
1055 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1057 prefs_common.folderview_width = allocation->width;
1058 prefs_common.folderview_height = allocation->height;
1061 void main_window_get_position(MainWindow *mainwin)
1065 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1067 prefs_common.mainview_x = x;
1068 prefs_common.mainview_y = y;
1069 prefs_common.mainwin_x = x;
1070 prefs_common.mainwin_y = y;
1072 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1075 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1080 if (alertpanel(_("Empty trash"),
1081 _("Empty all messages in trash?"),
1082 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1084 manage_window_focus_in(mainwin->window, NULL, NULL);
1087 procmsg_empty_trash();
1089 for (list = folder_get_list(); list != NULL; list = list->next) {
1092 folder = list->data;
1093 if (folder->trash) {
1094 folder_item_scan(folder->trash);
1095 folderview_update_item(folder->trash, TRUE);
1099 if (mainwin->summaryview->folder_item &&
1100 mainwin->summaryview->folder_item->stype == F_TRASH)
1101 gtk_widget_grab_focus(mainwin->folderview->ctree);
1104 void main_window_add_mailbox(MainWindow *mainwin)
1109 path = input_dialog(_("Add mailbox"),
1110 _("Input the location of mailbox.\n"
1111 "If the existing mailbox is specified, it will be\n"
1112 "scanned automatically."),
1115 if (folder_find_from_path(path)) {
1116 alertpanel_error(_("The mailbox `%s' already exists."), path);
1120 if (!strcmp(path, "Mail"))
1121 folder = folder_new(F_MH, _("Mailbox"), path);
1123 folder = folder_new(F_MH, g_basename(path), path);
1126 if (folder->create_tree(folder) < 0) {
1127 alertpanel_error(_("Creation of the mailbox failed.\n"
1128 "Maybe some files already exist, or you don't have the permission to write there."));
1129 folder_destroy(folder);
1134 folder_set_ui_func(folder, scan_tree_func, mainwin);
1135 folder->scan_tree(folder);
1136 folder_set_ui_func(folder, NULL, NULL);
1138 folderview_set(mainwin->folderview);
1141 void main_window_add_mbox(MainWindow *mainwin)
1147 path = input_dialog(_("Add mbox mailbox"),
1148 _("Input the location of mailbox."),
1153 if (folder_find_from_path(path)) {
1154 alertpanel_error(_("The mailbox `%s' already exists."), path);
1160 if (!strcmp(path, "Mail"))
1161 folder = folder_new(F_MBOX, _("Mailbox"), path);
1165 folder = folder_new(F_MBOX, g_basename(path), path);
1168 if (folder->create_tree(folder) < 0) {
1169 alertpanel_error(_("Creation of the mailbox failed."));
1170 folder_destroy(folder);
1176 item = folder_item_new(folder->name, NULL);
1177 item->folder = folder;
1178 folder->node = g_node_new(item);
1180 folder->create_folder(folder, item, "inbox");
1181 folder->create_folder(folder, item, "outbox");
1182 folder->create_folder(folder, item, "queue");
1183 folder->create_folder(folder, item, "draft");
1184 folder->create_folder(folder, item, "trash");
1186 folderview_set(mainwin->folderview);
1191 M_UNLOCKED = 1 << 0,
1192 M_MSG_EXIST = 1 << 1,
1193 M_TARGET_EXIST = 1 << 2,
1194 M_SINGLE_TARGET_EXIST = 1 << 3,
1196 M_ALLOW_REEDIT = 1 << 5,
1197 M_HAVE_ACCOUNT = 1 << 6
1200 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1202 SensitiveCond state = 0;
1203 SummarySelection selection;
1205 selection = summary_get_selection_type(mainwin->summaryview);
1207 if (mainwin->lock_count == 0)
1208 state |= M_UNLOCKED;
1209 if (selection != SUMMARY_NONE)
1210 state |= M_MSG_EXIST;
1211 if (selection == SUMMARY_SELECTED_SINGLE ||
1212 selection == SUMMARY_SELECTED_MULTIPLE)
1213 state |= M_TARGET_EXIST;
1214 if (selection == SUMMARY_SELECTED_SINGLE)
1215 state |= M_SINGLE_TARGET_EXIST;
1216 if (mainwin->summaryview->folder_item &&
1217 mainwin->summaryview->folder_item->folder->type != F_NEWS)
1219 if (selection == SUMMARY_SELECTED_SINGLE &&
1220 (mainwin->summaryview->folder_item &&
1221 mainwin->summaryview->folder_item->stype == F_DRAFT))
1222 state |= M_ALLOW_REEDIT;
1224 state |= M_HAVE_ACCOUNT;
1229 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1231 SensitiveCond state;
1239 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1240 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1241 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1242 {mainwin->compose_news_btn, M_HAVE_ACCOUNT},
1243 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1244 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1245 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1246 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1247 /* {mainwin->prefs_btn , M_UNLOCKED},
1248 {mainwin->account_btn , M_UNLOCKED}, */
1249 {mainwin->next_btn , M_MSG_EXIST},
1250 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1251 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1255 state = main_window_get_current_state(mainwin);
1257 for (i = 0; entry[i].widget != NULL; i++) {
1258 sensitive = ((entry[i].cond & state) == entry[i].cond);
1259 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1263 void main_window_set_menu_sensitive(MainWindow *mainwin)
1265 GtkItemFactory *ifactory;
1266 SensitiveCond state;
1270 static const struct {
1274 {"/File/Add mailbox..." , M_UNLOCKED},
1275 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1276 {"/File/Update folder tree" , M_UNLOCKED},
1277 {"/File/Folder" , M_UNLOCKED},
1278 {"/File/Import mbox file..." , M_UNLOCKED},
1279 {"/File/Export to mbox file...", M_UNLOCKED},
1280 {"/File/Empty trash" , M_UNLOCKED},
1281 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1282 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1283 {"/File/Close", M_UNLOCKED},
1284 {"/File/Exit" , M_UNLOCKED},
1286 {"/Message/Get new mail" , M_UNLOCKED},
1287 {"/Message/Get from all accounts", M_UNLOCKED},
1288 {"/Message/Reply" , M_SINGLE_TARGET_EXIST},
1289 {"/Message/Reply to sender" , M_SINGLE_TARGET_EXIST},
1290 {"/Message/Follow-up and reply to", M_SINGLE_TARGET_EXIST},
1291 {"/Message/Reply to all" , M_SINGLE_TARGET_EXIST},
1292 {"/Message/Forward" , M_SINGLE_TARGET_EXIST},
1293 {"/Message/Forward as attachment", M_SINGLE_TARGET_EXIST},
1294 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1295 {"/Message/Show all header" , M_SINGLE_TARGET_EXIST},
1296 {"/Message/View source" , M_SINGLE_TARGET_EXIST},
1297 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1298 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1299 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1300 {"/Message/Mark" , M_TARGET_EXIST},
1301 {"/Message/Re-edit", M_ALLOW_REEDIT},
1303 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1304 {"/Summary/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1305 {"/Summary/Execute" , M_MSG_EXIST|M_UNLOCKED},
1306 {"/Summary/Prev message" , M_MSG_EXIST},
1307 {"/Summary/Next message" , M_MSG_EXIST},
1308 {"/Summary/Prev marked message" , M_MSG_EXIST},
1309 {"/Summary/Next marked message" , M_MSG_EXIST},
1310 {"/Summary/Prev labeled message", M_MSG_EXIST},
1311 {"/Summary/Next labeled message", M_MSG_EXIST},
1312 {"/Summary/Next unread message" , M_MSG_EXIST},
1313 {"/Summary/Sort" , M_MSG_EXIST},
1315 {"/Configuration", M_UNLOCKED},
1320 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1321 state = main_window_get_current_state(mainwin);
1323 for (i = 0; entry[i].entry != NULL; i++) {
1324 sensitive = ((entry[i].cond & state) == entry[i].cond);
1325 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1329 void main_window_popup(MainWindow *mainwin)
1335 gdk_window_get_origin(mainwin->window->window, &x, &y);
1336 sx = gdk_screen_width();
1337 sy = gdk_screen_height();
1338 x %= sx; if (x < 0) x += sx;
1339 y %= sy; if (y < 0) y += sy;
1340 gdk_window_move(mainwin->window->window, x, y);
1341 gdk_window_raise(mainwin->window->window);
1342 gdk_window_show(mainwin->window->window);
1344 debug_print("window position: x = %d, y = %d\n", x, y);
1346 switch (mainwin->type) {
1347 case SEPARATE_FOLDER:
1348 widget = mainwin->win.sep_folder.folderwin;
1349 gdk_window_get_origin(widget->window, &x, &y);
1350 x %= sx; if (x < 0) x += sx;
1351 y %= sy; if (y < 0) y += sy;
1352 gdk_window_move(widget->window, x, y);
1353 gdk_window_raise(widget->window);
1355 case SEPARATE_MESSAGE:
1356 widget = mainwin->win.sep_message.messagewin;
1357 gdk_window_get_origin(widget->window, &x, &y);
1358 x %= sx; if (x < 0) x += sx;
1359 y %= sy; if (y < 0) y += sy;
1360 gdk_window_move(widget->window, x, y);
1361 gdk_window_raise(widget->window);
1364 widget = mainwin->win.sep_both.folderwin;
1365 gdk_window_get_origin(widget->window, &x, &y);
1366 x %= sx; if (x < 0) x += sx;
1367 y %= sy; if (y < 0) y += sy;
1368 gdk_window_move(widget->window, x, y);
1369 gdk_window_raise(widget->window);
1370 widget = mainwin->win.sep_both.messagewin;
1371 gdk_window_get_origin(widget->window, &x, &y);
1372 x %= sx; if (x < 0) x += sx;
1373 y %= sy; if (y < 0) y += sy;
1374 gdk_window_move(widget->window, x, y);
1375 gdk_window_raise(widget->window);
1382 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1384 GtkWidget *folderwin = NULL;
1385 GtkWidget *messagewin = NULL;
1388 GtkWidget *vbox_body = mainwin->vbox_body;
1390 debug_print(_("Setting widgets..."));
1392 /* create separated window(s) if needed */
1393 if (type & SEPARATE_FOLDER) {
1394 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1395 gtk_window_set_policy(GTK_WINDOW(folderwin),
1397 gtk_widget_set_usize(folderwin, -1,
1398 prefs_common.mainview_height);
1399 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1401 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1402 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1405 if (type & SEPARATE_MESSAGE) {
1406 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1407 gtk_window_set_policy(GTK_WINDOW(messagewin),
1409 gtk_widget_set_usize
1410 (messagewin, prefs_common.mainview_width,
1411 prefs_common.mainview_height
1412 - prefs_common.summaryview_height
1413 + DEFAULT_HEADERVIEW_HEIGHT);
1414 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1416 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1417 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1423 hpaned = gtk_hpaned_new();
1424 gtk_widget_show(hpaned);
1425 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1426 gtk_paned_add1(GTK_PANED(hpaned),
1427 GTK_WIDGET_PTR(mainwin->folderview));
1429 vpaned = gtk_vpaned_new();
1430 if (mainwin->summaryview->msg_is_toggled_on) {
1431 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1432 gtk_paned_add1(GTK_PANED(vpaned),
1433 GTK_WIDGET_PTR(mainwin->summaryview));
1435 gtk_paned_add2(GTK_PANED(hpaned),
1436 GTK_WIDGET_PTR(mainwin->summaryview));
1437 gtk_widget_ref(vpaned);
1439 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1440 prefs_common.summaryview_width,
1441 prefs_common.summaryview_height);
1442 gtk_paned_add2(GTK_PANED(vpaned),
1443 GTK_WIDGET_PTR(mainwin->messageview));
1444 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1445 prefs_common.mainview_width, -1);
1446 gtk_widget_set_usize(mainwin->window,
1447 prefs_common.folderview_width +
1448 prefs_common.mainview_width,
1449 prefs_common.mainwin_height);
1450 gtk_widget_show_all(vpaned);
1452 mainwin->win.sep_none.hpaned = hpaned;
1453 mainwin->win.sep_none.vpaned = vpaned;
1455 case SEPARATE_FOLDER:
1456 vpaned = gtk_vpaned_new();
1457 if (mainwin->summaryview->msg_is_toggled_on) {
1458 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1460 gtk_paned_add1(GTK_PANED(vpaned),
1461 GTK_WIDGET_PTR(mainwin->summaryview));
1463 gtk_box_pack_start(GTK_BOX(vbox_body),
1464 GTK_WIDGET_PTR(mainwin->summaryview),
1466 gtk_widget_ref(vpaned);
1468 gtk_paned_add2(GTK_PANED(vpaned),
1469 GTK_WIDGET_PTR(mainwin->messageview));
1470 gtk_widget_show_all(vpaned);
1471 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1472 prefs_common.summaryview_width,
1473 prefs_common.summaryview_height);
1474 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1475 prefs_common.mainview_width, -1);
1476 gtk_widget_set_usize(mainwin->window,
1477 prefs_common.mainview_width,
1478 prefs_common.mainview_height);
1480 gtk_container_add(GTK_CONTAINER(folderwin),
1481 GTK_WIDGET_PTR(mainwin->folderview));
1483 mainwin->win.sep_folder.folderwin = folderwin;
1484 mainwin->win.sep_folder.vpaned = vpaned;
1486 gtk_widget_show_all(folderwin);
1488 case SEPARATE_MESSAGE:
1489 hpaned = gtk_hpaned_new();
1490 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1492 gtk_paned_add1(GTK_PANED(hpaned),
1493 GTK_WIDGET_PTR(mainwin->folderview));
1494 gtk_paned_add2(GTK_PANED(hpaned),
1495 GTK_WIDGET_PTR(mainwin->summaryview));
1496 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1497 prefs_common.summaryview_width,
1498 prefs_common.summaryview_height);
1499 gtk_widget_set_usize(mainwin->window,
1500 prefs_common.folderview_width +
1501 prefs_common.mainview_width,
1502 prefs_common.mainwin_height);
1503 gtk_widget_show_all(hpaned);
1504 gtk_container_add(GTK_CONTAINER(messagewin),
1505 GTK_WIDGET_PTR(mainwin->messageview));
1507 mainwin->win.sep_message.messagewin = messagewin;
1508 mainwin->win.sep_message.hpaned = hpaned;
1510 gtk_widget_show_all(messagewin);
1513 gtk_box_pack_start(GTK_BOX(vbox_body),
1514 GTK_WIDGET_PTR(mainwin->summaryview),
1516 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1517 prefs_common.summaryview_width,
1518 prefs_common.summaryview_height);
1519 gtk_widget_set_usize(mainwin->window,
1520 prefs_common.mainview_width,
1521 prefs_common.mainwin_height);
1522 gtk_container_add(GTK_CONTAINER(folderwin),
1523 GTK_WIDGET_PTR(mainwin->folderview));
1524 gtk_container_add(GTK_CONTAINER(messagewin),
1525 GTK_WIDGET_PTR(mainwin->messageview));
1527 mainwin->win.sep_both.folderwin = folderwin;
1528 mainwin->win.sep_both.messagewin = messagewin;
1530 gtk_widget_show_all(folderwin);
1531 gtk_widget_show_all(messagewin);
1535 mainwin->type = type;
1537 debug_print(_("done.\n"));
1540 #include "pixmaps/stock_mail_receive.xpm"
1541 #include "pixmaps/stock_mail_receive_all.xpm"
1542 #include "pixmaps/stock_mail_compose.xpm"
1543 #include "pixmaps/stock_news_compose.xpm"
1544 #include "pixmaps/stock_mail_reply.xpm"
1545 #include "pixmaps/stock_mail_reply_to_all.xpm"
1546 #include "pixmaps/stock_mail_reply_to_author.xpm"
1547 #include "pixmaps/stock_mail_forward.xpm"
1548 #include "pixmaps/stock_mail_send.xpm"
1549 #include "pixmaps/stock_preferences.xpm"
1550 #include "pixmaps/stock_properties.xpm"
1551 #include "pixmaps/stock_down_arrow.xpm"
1552 #include "pixmaps/stock_close.xpm"
1553 #include "pixmaps/stock_exec.xpm"
1555 #define CREATE_TOOLBAR_ICON(xpm_d) \
1557 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1558 &container->style->white, \
1560 icon_wid = gtk_pixmap_new(icon, mask); \
1563 static void main_window_toolbar_create(MainWindow *mainwin,
1564 GtkWidget *container)
1569 GtkWidget *icon_wid;
1571 GtkWidget *getall_btn;
1572 GtkWidget *compose_mail_btn;
1573 GtkWidget *compose_news_btn;
1574 GtkWidget *compose_mail_btn_plain;
1575 GtkWidget *compose_news_btn_plain;
1576 GtkWidget *reply_btn;
1577 GtkWidget *replyall_btn;
1578 GtkWidget *replysender_btn;
1580 GtkWidget *send_btn;
1582 GtkWidget *prefs_btn;
1583 GtkWidget *account_btn;
1585 GtkWidget *next_btn;
1586 GtkWidget *delete_btn;
1587 GtkWidget *exec_btn;
1588 GtkWidget *compose_type_btn;
1589 GtkWidget *compose_type_arrow;
1590 GtkWidget *compose_box;
1591 GtkWidget *compose_label;
1592 GtkTooltips *tooltips;
1594 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1596 gtk_container_add(GTK_CONTAINER(container), toolbar);
1597 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1598 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1599 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1600 GTK_TOOLBAR_SPACE_LINE);
1602 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1603 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1605 _("Get new mail from current account"),
1607 icon_wid, toolbar_inc_cb, mainwin);
1608 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1609 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1611 _("Get new mail from all accounts"),
1617 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1619 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1620 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1622 _("Send queued message(s)"),
1628 /* to implement Leandro's "combined" compose buttons, we create
1629 * two sets of compose buttons, one for normal (text + icon)
1630 * toolbar, and one for both text-only and icon-only toolbar;
1631 * we switch between those sets. */
1633 /* insert compose mail button widget */
1635 compose_mail_btn = gtk_button_new();
1636 gtk_widget_show(compose_mail_btn);
1637 tooltips = gtk_tooltips_new();
1638 gtk_tooltips_set_tip(tooltips, compose_mail_btn,
1639 _("Compose email message"),
1641 compose_box = gtk_vbox_new(0, 0);
1642 gtk_widget_show(compose_box);
1644 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1645 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1646 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1648 compose_label = gtk_label_new(_("Email"));
1649 gtk_widget_show(compose_label);
1650 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1652 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1653 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1654 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1657 /* insert compose news button widget */
1659 compose_news_btn = gtk_button_new();
1660 gtk_widget_show(compose_news_btn);
1661 tooltips = gtk_tooltips_new();
1662 gtk_tooltips_set_tip(tooltips, compose_news_btn,
1663 _("Compose news article"),
1665 compose_box = gtk_vbox_new(0, 0);
1666 gtk_widget_show(compose_box);
1668 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1669 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1670 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1672 compose_label = gtk_label_new(_("News"));
1673 gtk_widget_show(compose_label);
1674 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1676 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_news_btn), GTK_CAN_FOCUS);
1677 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1678 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1681 /* insert compose btn plain */
1683 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1684 compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1686 _("Compose an email message"),
1689 toolbar_compose_mail_cb,
1692 /* insert compose btn plain */
1694 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1695 compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1697 _("Compose a news message"),
1700 toolbar_compose_news_cb,
1703 /* insert compose button type widget */
1705 compose_type_btn = gtk_button_new();
1706 gtk_widget_show(compose_type_btn);
1708 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1709 gtk_widget_show(compose_type_arrow);
1711 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1713 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1714 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1716 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1719 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1721 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1722 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1724 _("Reply to the message"),
1729 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1730 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1735 toolbar_reply_to_all_cb,
1737 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1738 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1740 _("Reply to sender"),
1743 toolbar_reply_to_sender_cb,
1745 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1746 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1748 _("Forward the message"),
1754 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1756 CREATE_TOOLBAR_ICON(stock_close_xpm);
1757 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1759 _("Delete the message"),
1765 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1766 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1768 _("Execute marked process"),
1774 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1775 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1777 _("Next unread message"),
1780 toolbar_next_unread_cb,
1784 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1786 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1787 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1789 _("Common preference"),
1794 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1795 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1797 _("Account setting"),
1802 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1803 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1807 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1808 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1811 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1812 GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
1815 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
1816 GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
1819 mainwin->toolbar = toolbar;
1820 mainwin->get_btn = get_btn;
1821 mainwin->getall_btn = getall_btn;
1822 mainwin->compose_mail_btn = compose_mail_btn;
1823 mainwin->compose_news_btn = compose_news_btn;
1824 mainwin->compose_mail_btn_plain = compose_mail_btn_plain;
1825 mainwin->compose_news_btn_plain = compose_news_btn_plain;
1826 mainwin->reply_btn = reply_btn;
1827 mainwin->replyall_btn = replyall_btn;
1828 mainwin->replysender_btn = replysender_btn;
1829 mainwin->fwd_btn = fwd_btn;
1830 mainwin->send_btn = send_btn;
1832 mainwin->prefs_btn = prefs_btn;
1833 mainwin->account_btn = account_btn;
1835 mainwin->next_btn = next_btn;
1836 mainwin->delete_btn = delete_btn;
1837 mainwin->exec_btn = exec_btn;
1839 gtk_widget_show_all(toolbar);
1841 /* activate Leandro menu system */
1842 activate_compose_button(mainwin,
1843 prefs_common.toolbar_style,
1844 mainwin->compose_btn_type);
1847 /* callback functions */
1849 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1852 MainWindow *mainwindow = (MainWindow *) data;
1853 GtkWidget *compose_menu, *compose_item;
1855 g_return_if_fail(mainwindow != NULL);
1857 compose_menu = gtk_menu_new();
1859 compose_item = gtk_menu_item_new_with_label(_("Email message"));
1860 gtk_widget_show(compose_item);
1861 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1862 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1863 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1865 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1867 compose_item = gtk_menu_item_new_with_label(_("News article"));
1868 gtk_widget_show(compose_item);
1869 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1870 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1871 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1873 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1875 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1879 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1881 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1882 MainWindow *mainwindow = (MainWindow *) data;
1884 mainwindow->compose_btn_type = compose_type;
1886 activate_compose_button(mainwindow, prefs_common.toolbar_style, mainwindow->compose_btn_type);
1889 static void toolbar_inc_cb (GtkWidget *widget,
1892 MainWindow *mainwin = (MainWindow *)data;
1894 inc_mail_cb(mainwin, 0, NULL);
1897 static void toolbar_inc_all_cb (GtkWidget *widget,
1900 MainWindow *mainwin = (MainWindow *)data;
1902 inc_all_account_mail_cb(mainwin, 0, NULL);
1905 static void toolbar_send_cb (GtkWidget *widget,
1908 MainWindow *mainwin = (MainWindow *)data;
1910 send_queue_cb(mainwin, 0, NULL);
1913 static void toolbar_compose_cb (GtkWidget *widget,
1916 MainWindow *mainwin = (MainWindow *)data;
1918 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1919 compose_cb(mainwin, 0, NULL);
1921 compose_news_cb(mainwin, 0, NULL);
1924 static void toolbar_compose_news_cb (GtkWidget *widget,
1927 MainWindow *mainwin = (MainWindow *)data;
1929 compose_news_cb(mainwin, 0, NULL);
1932 static void toolbar_compose_mail_cb (GtkWidget *widget,
1935 MainWindow *mainwin = (MainWindow *)data;
1937 compose_mail_cb(mainwin, 0, NULL);
1940 static void toolbar_reply_cb (GtkWidget *widget,
1943 MainWindow *mainwin = (MainWindow *)data;
1945 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1948 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1951 MainWindow *mainwin = (MainWindow *)data;
1953 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1956 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1959 MainWindow *mainwin = (MainWindow *)data;
1961 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1964 static void toolbar_forward_cb (GtkWidget *widget,
1967 MainWindow *mainwin = (MainWindow *)data;
1969 if (prefs_common.forward_as_attachment)
1970 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
1972 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1975 static void toolbar_delete_cb (GtkWidget *widget,
1978 MainWindow *mainwin = (MainWindow *)data;
1980 summary_delete(mainwin->summaryview);
1983 static void toolbar_exec_cb (GtkWidget *widget,
1986 MainWindow *mainwin = (MainWindow *)data;
1988 summary_execute(mainwin->summaryview);
1991 static void toolbar_next_unread_cb (GtkWidget *widget,
1994 MainWindow *mainwin = (MainWindow *)data;
1996 next_unread_cb(mainwin, 0, NULL);
1999 static void toolbar_prefs_cb (GtkWidget *widget,
2002 prefs_common_open();
2005 static void toolbar_account_cb (GtkWidget *widget,
2008 MainWindow *mainwin = (MainWindow *)data;
2010 prefs_account_open_cb(mainwin, 0, NULL);
2013 static void toolbar_account_button_pressed(GtkWidget *widget,
2014 GdkEventButton *event,
2017 MainWindow *mainwin = (MainWindow *)data;
2020 if (event->button != 3) return;
2022 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2023 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2026 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2027 menu_button_position, widget,
2028 event->button, event->time);
2031 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2034 MainWindow *mainwin = (MainWindow *)data;
2038 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2039 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2042 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2043 menu_button_position, widget,
2044 event->button, event->time);
2047 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2049 MainWindow *mainwin = (MainWindow *)data;
2052 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2053 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2054 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2057 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2060 app_exit_cb(data, 0, widget);
2065 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2068 main_window_add_mailbox(mainwin);
2071 static void add_mbox_cb(MainWindow *mainwin, guint action,
2074 main_window_add_mbox(mainwin);
2077 static void update_folderview_cb(MainWindow *mainwin, guint action,
2080 summary_show(mainwin->summaryview, NULL, FALSE);
2081 folderview_update_all();
2084 static void new_folder_cb(MainWindow *mainwin, guint action,
2087 folderview_new_folder(mainwin->folderview);
2090 static void rename_folder_cb(MainWindow *mainwin, guint action,
2093 folderview_rename_folder(mainwin->folderview);
2096 static void delete_folder_cb(MainWindow *mainwin, guint action,
2099 folderview_delete_folder(mainwin->folderview);
2102 static void import_mbox_cb(MainWindow *mainwin, guint action,
2105 import_mbox(mainwin->summaryview->folder_item);
2108 static void export_mbox_cb(MainWindow *mainwin, guint action,
2111 export_mbox(mainwin->summaryview->folder_item);
2114 static void empty_trash_cb(MainWindow *mainwin, guint action,
2117 main_window_empty_trash(mainwin, TRUE);
2120 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2122 summary_save_as(mainwin->summaryview);
2125 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2127 summary_print(mainwin->summaryview);
2130 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2132 if (prefs_common.confirm_on_exit) {
2133 if (alertpanel(_("Exit"), _("Exit this program?"),
2134 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2136 manage_window_focus_in(mainwin->window, NULL, NULL);
2139 app_will_exit(widget, mainwin);
2142 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2145 switch (mainwin->type) {
2147 case SEPARATE_MESSAGE:
2149 case SEPARATE_FOLDER:
2150 if (GTK_CHECK_MENU_ITEM(widget)->active)
2151 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2153 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2156 if (GTK_CHECK_MENU_ITEM(widget)->active)
2157 gtk_widget_show(mainwin->win.sep_both.folderwin);
2159 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2164 static void toggle_message_cb(MainWindow *mainwin, guint action,
2167 switch (mainwin->type) {
2169 case SEPARATE_FOLDER:
2171 case SEPARATE_MESSAGE:
2172 if (GTK_CHECK_MENU_ITEM(widget)->active)
2173 gtk_widget_show(mainwin->win.sep_message.messagewin);
2175 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2178 if (GTK_CHECK_MENU_ITEM(widget)->active)
2179 gtk_widget_show(mainwin->win.sep_both.messagewin);
2181 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2186 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2189 activate_compose_button(mainwin, (ToolbarStyle)action,
2190 mainwin->compose_btn_type);
2192 switch ((ToolbarStyle)action) {
2194 gtk_widget_hide(mainwin->handlebox);
2196 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2200 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2204 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2209 if (action != TOOLBAR_NONE) {
2210 gtk_widget_show(mainwin->handlebox);
2211 gtk_widget_queue_resize(mainwin->handlebox);
2214 mainwin->toolbar_style = (ToolbarStyle)action;
2215 prefs_common.toolbar_style = (ToolbarStyle)action;
2218 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2221 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2222 gtk_widget_show(mainwin->hbox_stat);
2223 prefs_common.show_statusbar = TRUE;
2225 gtk_widget_hide(mainwin->hbox_stat);
2226 prefs_common.show_statusbar = FALSE;
2230 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2233 MainWindow *mainwin;
2236 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2237 g_return_if_fail(mainwin != NULL);
2239 type = mainwin->type ^ action;
2240 main_window_separation_change(mainwin, type);
2242 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2243 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2246 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2249 addressbook_open(NULL);
2252 static void log_window_show_cb(MainWindow *mainwin, guint action,
2255 log_window_show(mainwin->logwin);
2258 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2263 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2266 inc_all_account_mail(mainwin);
2269 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2273 if (procmsg_send_queue() < 0)
2274 alertpanel_error(_("Sending queued message failed."));
2276 statusbar_pop_all();
2278 for (list = folder_get_list(); list != NULL; list = list->next) {
2281 folder = list->data;
2282 if (folder->queue) {
2283 folder_item_scan(folder->queue);
2284 folderview_update_item(folder->queue, TRUE);
2289 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2291 if (mainwin->summaryview->folder_item) {
2292 if (mainwin->summaryview->folder_item->folder->account != NULL
2293 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2294 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2296 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2302 static void compose_mail_cb(MainWindow *mainwin, guint action,
2309 if (mainwin->summaryview->folder_item) {
2310 ac = mainwin->summaryview->folder_item->folder->account;
2311 if (ac && ac->protocol != A_NNTP) {
2312 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2317 if(cur_account && (cur_account->protocol != A_NNTP)) {
2318 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2322 list = account_get_list();
2323 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2324 ac = (PrefsAccount *) cur->data;
2325 if (ac->protocol != A_NNTP) {
2326 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2332 static void compose_news_cb(MainWindow *mainwin, guint action,
2335 PrefsAccount * ac = NULL;
2339 if (mainwin->summaryview->folder_item) {
2340 ac = mainwin->summaryview->folder_item->folder->account;
2341 if (ac && ac->protocol == A_NNTP) {
2342 compose_new_with_recipient
2343 (ac, mainwin->summaryview->folder_item->path);
2348 list = account_get_list();
2349 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2350 ac = (PrefsAccount *) cur->data;
2351 if (ac->protocol == A_NNTP) {
2358 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2360 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2363 msginfo = gtk_ctree_node_get_row_data
2364 (GTK_CTREE(mainwin->summaryview->ctree),
2365 mainwin->summaryview->selected);
2367 if (!msginfo) return;
2371 compose_reply(msginfo, prefs_common.reply_with_quote,
2374 case COMPOSE_REPLY_TO_SENDER:
2375 compose_reply(msginfo, prefs_common.reply_with_quote,
2378 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2379 compose_followup_and_reply_to(msginfo,
2380 prefs_common.reply_with_quote,
2383 case COMPOSE_REPLY_TO_ALL:
2384 compose_reply(msginfo, prefs_common.reply_with_quote,
2387 case COMPOSE_FORWARD:
2389 compose_forward(NULL, msginfo, FALSE);
2392 /* if (sel->next) FALL_THROUGH */
2393 case COMPOSE_FORWARD_AS_ATTACH:
2395 GSList *msginfo_list = NULL;
2396 for ( ; sel != NULL; sel = sel->next)
2397 msginfo_list = g_slist_append(msginfo_list,
2398 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2399 GTK_CTREE_NODE(sel->data)));
2400 compose_forward_multiple(NULL, msginfo_list);
2401 g_slist_free(msginfo_list);
2405 g_warning("reply_cb(): invalid action type: %d\n", action);
2408 summary_set_marks_selected(mainwin->summaryview);
2411 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2413 summary_move_to(mainwin->summaryview);
2416 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2418 summary_copy_to(mainwin->summaryview);
2421 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2423 summary_delete(mainwin->summaryview);
2426 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2428 summary_open_msg(mainwin->summaryview);
2431 static void view_source_cb(MainWindow *mainwin, guint action,
2434 summary_view_source(mainwin->summaryview);
2437 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2439 summary_reedit(mainwin->summaryview);
2442 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2444 summary_mark(mainwin->summaryview);
2447 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2449 summary_unmark(mainwin->summaryview);
2452 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2455 summary_mark_as_unread(mainwin->summaryview);
2458 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2461 summary_mark_as_read(mainwin->summaryview);
2464 static void set_charset_cb(MainWindow *mainwin, guint action,
2469 str = conv_get_charset_str((CharSet)action);
2470 g_free(prefs_common.force_charset);
2471 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2473 summary_redisplay_msg(mainwin->summaryview);
2475 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2478 /*void main_window_set_thread_option(MainWindow *mainwin)
2480 GtkItemFactory *ifactory;
2481 gboolean no_item = FALSE;
2483 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2485 if (mainwin->summaryview == NULL)
2487 else if (mainwin->summaryview->folder_item == NULL)
2491 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2492 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2495 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2496 menu_set_sensitive(ifactory,
2497 "/Summary/Thread view", FALSE);
2498 menu_set_sensitive(ifactory,
2499 "/Summary/Unthread view", TRUE);
2500 summary_thread_build(mainwin->summaryview, TRUE);
2503 menu_set_sensitive(ifactory,
2504 "/Summary/Thread view", TRUE);
2505 menu_set_sensitive(ifactory,
2506 "/Summary/Unthread view", FALSE);
2507 summary_unthread(mainwin->summaryview);
2509 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2513 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2515 /*mainwin->summaryview->folder_item->prefs->enable_thread =
2516 !mainwin->summaryview->folder_item->prefs->enable_thread;
2517 main_window_set_thread_option(mainwin);
2520 GtkItemFactory *ifactory;
2522 ifactory = gtk_item_factory_from_widget(widget);
2525 summary_thread_build(mainwin->summaryview, FALSE);
2526 prefs_common.enable_thread = TRUE;
2527 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2528 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2530 summary_unthread(mainwin->summaryview);
2531 prefs_common.enable_thread = FALSE;
2532 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2533 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2537 static void set_display_item_cb(MainWindow *mainwin, guint action,
2540 prefs_summary_display_item_set();
2543 static void sort_summary_cb(MainWindow *mainwin, guint action,
2546 summary_sort(mainwin->summaryview, (SummarySortType)action);
2549 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2552 summary_attract_by_subject(mainwin->summaryview);
2555 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2558 summary_delete_duplicated(mainwin->summaryview);
2561 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2563 summary_filter(mainwin->summaryview);
2566 static void execute_summary_cb(MainWindow *mainwin, guint action,
2569 summary_execute(mainwin->summaryview);
2572 static void update_summary_cb(MainWindow *mainwin, guint action,
2576 FolderView *folderview = mainwin->folderview;
2578 if (!mainwin->summaryview->folder_item) return;
2579 if (!folderview->opened) return;
2581 folder_update_op_count();
2583 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2584 folderview->opened);
2587 summary_show(mainwin->summaryview, fitem, TRUE);
2590 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2592 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2595 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2597 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2600 static void next_unread_cb(MainWindow *mainwin, guint action,
2603 summary_select_next_unread(mainwin->summaryview);
2606 static void next_marked_cb(MainWindow *mainwin, guint action,
2609 summary_select_next_marked(mainwin->summaryview);
2612 static void prev_marked_cb(MainWindow *mainwin, guint action,
2615 summary_select_prev_marked(mainwin->summaryview);
2618 static void next_labeled_cb(MainWindow *mainwin, guint action,
2621 summary_select_next_labeled(mainwin->summaryview);
2624 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2627 summary_select_prev_labeled(mainwin->summaryview);
2630 static void goto_folder_cb(MainWindow *mainwin, guint action,
2633 FolderItem *to_folder;
2635 to_folder = foldersel_folder_sel(NULL, NULL);
2638 folderview_select(mainwin->folderview, to_folder);
2641 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2643 messageview_copy_clipboard(mainwin->messageview);
2646 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2648 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2649 summary_select_all(mainwin->summaryview);
2650 else if (mainwin->summaryview->msg_is_toggled_on &&
2651 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2652 messageview_select_all(mainwin->messageview);
2655 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2658 prefs_common_open();
2661 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2664 prefs_filter_open();
2667 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2670 prefs_scoring_open(NULL);
2673 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2676 prefs_filtering_open();
2679 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2683 new_account_cb(mainwin, 0, widget);
2685 gboolean prev_default = cur_account->is_default;
2687 prefs_account_open(cur_account);
2688 if (!prev_default && cur_account->is_default)
2689 account_set_as_default(cur_account);
2690 account_save_config_all();
2692 main_window_reflect_prefs_all();
2696 static void new_account_cb(MainWindow *mainwin, guint action,
2699 account_edit_open();
2700 if (!compose_get_compose_list()) account_add();
2703 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2705 cur_account = (PrefsAccount *)data;
2706 main_window_reflect_prefs_all();
2709 static void manual_open_cb(MainWindow *mainwin, guint action,
2712 manual_open((ManualLang)action);
2715 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2717 MainWindow *mainwin = (MainWindow *)data;
2721 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2722 LOCAL_FOLDER(folder)->rootpath,
2726 str = g_strdup_printf(_("Scanning folder %s ..."),
2727 LOCAL_FOLDER(folder)->rootpath);
2729 STATUSBAR_PUSH(mainwin, str);
2730 STATUSBAR_POP(mainwin);
2734 static void activate_compose_button (MainWindow *mainwin,
2736 ComposeButtonType type)
2738 if (style == TOOLBAR_NONE)
2741 if (style == TOOLBAR_BOTH) {
2742 gtk_widget_hide(mainwin->compose_mail_btn_plain);
2743 gtk_widget_hide(mainwin->compose_news_btn_plain);
2744 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2745 : mainwin->compose_news_btn);
2746 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2747 : mainwin->compose_mail_btn);
2748 mainwin->compose_btn_type = type;
2751 gtk_widget_hide(mainwin->compose_news_btn);
2752 gtk_widget_hide(mainwin->compose_mail_btn);
2753 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn_plain
2754 : mainwin->compose_news_btn_plain);
2755 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn_plain
2756 : mainwin->compose_mail_btn_plain);
2757 mainwin->compose_btn_type = type;
2761 static void prefs_templates_open_cb(MainWindow *mainwin, guint action,
2764 prefs_templates_open();