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"
81 #define AC_LABEL_WIDTH 240
83 #define STATUSBAR_PUSH(mainwin, str) \
85 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
86 mainwin->mainwin_cid, str); \
87 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
90 #define STATUSBAR_POP(mainwin) \
92 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
93 mainwin->mainwin_cid); \
96 /* list of all instantiated MainWindow */
97 static GList *mainwin_list = NULL;
99 static GdkCursor *watch_cursor;
101 static void main_window_show_cur_account (MainWindow *mainwin);
103 static void main_window_set_widgets (MainWindow *mainwin,
105 static void main_window_toolbar_create (MainWindow *mainwin,
106 GtkWidget *container);
108 /* callback functions */
109 static void toolbar_inc_cb (GtkWidget *widget,
111 static void toolbar_inc_all_cb (GtkWidget *widget,
113 static void toolbar_send_cb (GtkWidget *widget,
116 static void toolbar_compose_cb (GtkWidget *widget,
118 static void toolbar_popup_compose_type_cb(GtkWidget *widget,
120 static void toolbar_popup_compose_type_set(GtkWidget *widget,
122 static void toolbar_compose_news_cb (GtkWidget *widget,
124 static void toolbar_compose_mail_cb (GtkWidget *widget,
126 static void toolbar_reply_cb (GtkWidget *widget,
128 static void toolbar_reply_to_all_cb (GtkWidget *widget,
130 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
132 static void toolbar_forward_cb (GtkWidget *widget,
135 static void toolbar_delete_cb (GtkWidget *widget,
137 static void toolbar_exec_cb (GtkWidget *widget,
140 static void toolbar_next_unread_cb (GtkWidget *widget,
143 static void toolbar_prefs_cb (GtkWidget *widget,
145 static void toolbar_account_cb (GtkWidget *widget,
148 static void toolbar_account_button_pressed (GtkWidget *widget,
149 GdkEventButton *event,
151 static void ac_label_button_pressed (GtkWidget *widget,
152 GdkEventButton *event,
154 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
157 static gint main_window_close_cb (GtkWidget *widget,
161 static void add_mailbox_cb (MainWindow *mainwin,
164 static void add_mbox_cb (MainWindow *mainwin,
167 static void update_folderview_cb (MainWindow *mainwin,
170 static void new_folder_cb (MainWindow *mainwin,
173 static void rename_folder_cb (MainWindow *mainwin,
176 static void delete_folder_cb (MainWindow *mainwin,
179 static void import_mbox_cb (MainWindow *mainwin,
182 static void export_mbox_cb (MainWindow *mainwin,
185 static void empty_trash_cb (MainWindow *mainwin,
189 static void save_as_cb (MainWindow *mainwin,
192 static void print_cb (MainWindow *mainwin,
195 static void app_exit_cb (MainWindow *mainwin,
199 static void toggle_folder_cb (MainWindow *mainwin,
202 static void toggle_message_cb (MainWindow *mainwin,
205 static void toggle_toolbar_cb (MainWindow *mainwin,
208 static void toggle_statusbar_cb (MainWindow *mainwin,
211 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
215 static void addressbook_open_cb (MainWindow *mainwin,
218 static void log_window_show_cb (MainWindow *mainwin,
222 static void inc_mail_cb (MainWindow *mainwin,
225 static void inc_all_account_mail_cb (MainWindow *mainwin,
229 static void send_queue_cb (MainWindow *mainwin,
233 static void compose_cb (MainWindow *mainwin,
236 static void compose_mail_cb(MainWindow *mainwin, guint action,
238 static void compose_news_cb(MainWindow *mainwin, guint action,
240 static void reply_cb (MainWindow *mainwin,
244 static void open_msg_cb (MainWindow *mainwin,
248 static void view_source_cb (MainWindow *mainwin,
252 static void reedit_cb (MainWindow *mainwin,
256 static void move_to_cb (MainWindow *mainwin,
259 static void copy_to_cb (MainWindow *mainwin,
262 static void delete_cb (MainWindow *mainwin,
266 static void mark_cb (MainWindow *mainwin,
269 static void unmark_cb (MainWindow *mainwin,
273 static void mark_as_unread_cb (MainWindow *mainwin,
276 static void mark_as_read_cb (MainWindow *mainwin,
280 static void set_charset_cb (MainWindow *mainwin,
284 static void thread_cb (MainWindow *mainwin,
287 static void set_display_item_cb (MainWindow *mainwin,
290 static void sort_summary_cb (MainWindow *mainwin,
293 static void attract_by_subject_cb(MainWindow *mainwin,
297 static void delete_duplicated_cb (MainWindow *mainwin,
300 static void filter_cb (MainWindow *mainwin,
303 static void execute_summary_cb (MainWindow *mainwin,
306 static void update_summary_cb (MainWindow *mainwin,
310 static void prev_cb (MainWindow *mainwin,
313 static void next_cb (MainWindow *mainwin,
317 static void next_unread_cb (MainWindow *mainwin,
321 static void next_marked_cb (MainWindow *mainwin,
325 static void prev_marked_cb (MainWindow *mainwin,
329 static void next_labeled_cb (MainWindow *mainwin,
334 static void prev_labeled_cb (MainWindow *mainwin,
339 static void goto_folder_cb (MainWindow *mainwin,
343 static void copy_cb (MainWindow *mainwin,
346 static void allsel_cb (MainWindow *mainwin,
350 static void prefs_common_open_cb (MainWindow *mainwin,
353 static void prefs_filter_open_cb (MainWindow *mainwin,
356 static void prefs_scoring_open_cb (MainWindow *mainwin,
359 static void prefs_filtering_open_cb (MainWindow *mainwin,
362 static void prefs_account_open_cb(MainWindow *mainwin,
365 static void new_account_cb (MainWindow *mainwin,
369 static void account_menu_cb (GtkMenuItem *menuitem,
372 static void manual_open_cb (MainWindow *mainwin,
376 static void scan_tree_func (Folder *folder,
380 static void activate_compose_button (MainWindow *mainwin,
382 ComposeButtonType type);
384 static void prefs_templates_open_cb(MainWindow *mainwin,
388 #define SEPARATE_ACTION 667
390 static GtkItemFactoryEntry mainwin_entries[] =
392 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
393 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
394 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
395 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
396 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
397 {N_("/_File/_Folder/Create _new folder..."),
398 NULL, new_folder_cb, 0, NULL},
399 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
400 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
401 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
402 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
403 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
404 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
405 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
406 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
407 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
408 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
409 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
411 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
412 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
413 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
414 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
415 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
417 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
418 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
419 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
420 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
421 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
422 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
423 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
424 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
425 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
426 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
427 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
428 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
429 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
430 {N_("/_View/View _source"), "<control>U", view_source_cb, 0, NULL},
431 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
432 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
433 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
434 {N_("/_View/_Code set/_Auto detect"),
435 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
437 #define CODESET_SEPARATOR \
438 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
439 #define CODESET_ACTION(action) \
440 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
442 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
443 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
444 CODESET_ACTION(C_US_ASCII)},
447 {N_("/_View/_Code set/Unicode (_UTF-8)"),
448 CODESET_ACTION(C_UTF_8)},
451 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
452 CODESET_ACTION(C_ISO_8859_1)},
455 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
456 CODESET_ACTION(C_ISO_8859_2)},
458 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
459 CODESET_ACTION(C_ISO_8859_13)},
460 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
461 CODESET_ACTION(C_ISO_8859_4)},
463 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
464 CODESET_ACTION(C_ISO_8859_7)},
466 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
467 CODESET_ACTION(C_ISO_8859_9)},
469 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
470 CODESET_ACTION(C_ISO_8859_5)},
471 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
472 CODESET_ACTION(C_KOI8_R)},
473 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
474 CODESET_ACTION(C_CP1251)},
477 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
478 CODESET_ACTION(C_ISO_2022_JP)},
480 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
481 CODESET_ACTION(C_ISO_2022_JP_2)},
483 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
484 CODESET_ACTION(C_EUC_JP)},
485 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
486 CODESET_ACTION(C_SHIFT_JIS)},
489 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
490 CODESET_ACTION(C_GB2312)},
491 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
492 CODESET_ACTION(C_BIG5)},
493 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
494 CODESET_ACTION(C_EUC_TW)},
495 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
496 CODESET_ACTION(C_ISO_2022_CN)},
498 {N_("/_View/_Code set/Korean (EUC-_KR)"),
499 CODESET_ACTION(C_EUC_KR)},
500 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
501 CODESET_ACTION(C_ISO_2022_KR)},
504 #undef CODESET_SEPARATOR
505 #undef CODESET_ACTION
507 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
508 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
509 {N_("/_Message/Get from _all accounts"),
510 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
511 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_Message/Send queued messa_ges"),
513 NULL, send_queue_cb, 0, NULL},
514 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
515 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
516 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
517 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
518 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
519 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
520 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
521 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
522 {N_("/_Message/Forward as a_ttachment"),
523 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
524 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
525 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
526 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
527 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
528 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
529 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
530 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
531 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
532 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
533 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
534 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
535 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
536 {N_("/_Message/_Mark/Mark as rea_d"),
537 NULL, mark_as_read_cb, 0, NULL},
538 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
541 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
542 {N_("/_Summary/_Delete duplicated messages"),
543 NULL, delete_duplicated_cb, 0, NULL},
544 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
545 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
546 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
547 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
548 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
549 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
550 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
551 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
552 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
553 {N_("/_Summary/Prev labeled message"), NULL, prev_labeled_cb, 0, NULL},
554 {N_("/_Summary/Next labeled message"), NULL, next_labeled_cb, 0, NULL},
555 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
557 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
558 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
559 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
560 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
561 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
562 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
563 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
564 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
565 {N_("/_Summary/_Sort/Sort by _label"), NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
566 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
567 {N_("/_Summary/_Sort/_Attract by subject"),
568 NULL, attract_by_subject_cb, 0, NULL},
569 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
570 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
571 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
573 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
574 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
575 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
577 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
578 {N_("/_Configuration/_Common preferences..."),
579 NULL, prefs_common_open_cb, 0, NULL},
580 {N_("/_Configuration/_Filter setting..."),
581 NULL, prefs_filter_open_cb, 0, NULL},
582 {N_("/_Configuration/_Scoring ..."),
583 NULL, prefs_scoring_open_cb, 0, NULL},
584 {N_("/_Configuration/_Filtering ..."),
585 NULL, prefs_filtering_open_cb, 0, NULL},
586 {N_("/_Configuration/_Templates ..."),
587 NULL, prefs_templates_open_cb, 0, NULL},
588 {N_("/_Configuration/_Preferences per account..."),
589 NULL, prefs_account_open_cb, 0, NULL},
590 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
591 {N_("/_Configuration/Create _new account..."),
592 NULL, new_account_cb, 0, NULL},
593 {N_("/_Configuration/_Edit accounts..."),
594 NULL, account_edit_open, 0, NULL},
595 {N_("/_Configuration/C_hange current account"),
596 NULL, NULL, 0, "<Branch>"},
598 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
599 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
600 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
601 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
602 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
603 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
606 MainWindow *main_window_create(SeparateType type)
612 GtkWidget *handlebox;
613 GtkWidget *vbox_body;
614 GtkWidget *hbox_stat;
615 GtkWidget *statusbar;
616 GtkWidget *progressbar;
617 GtkWidget *statuslabel;
618 GtkWidget *ac_button;
621 FolderView *folderview;
622 SummaryView *summaryview;
623 MessageView *messageview;
624 GdkColormap *colormap;
627 guint n_menu_entries;
628 GtkItemFactory *ifactory;
633 debug_print(_("Creating main window...\n"));
634 mainwin = g_new0(MainWindow, 1);
637 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
638 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
639 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
640 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
641 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
642 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
643 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
644 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
645 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
647 gtk_widget_realize(window);
649 gtkut_widget_set_app_icon(window);
651 vbox = gtk_vbox_new(FALSE, 0);
652 gtk_widget_show(vbox);
653 gtk_container_add(GTK_CONTAINER(window), vbox);
656 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
657 menubar = menubar_create(window, mainwin_entries,
658 n_menu_entries, "<Main>", mainwin);
659 gtk_widget_show(menubar);
660 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
662 handlebox = gtk_handle_box_new();
663 gtk_widget_show(handlebox);
664 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
666 main_window_toolbar_create(mainwin, handlebox);
668 /* vbox that contains body */
669 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
670 gtk_widget_show(vbox_body);
671 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
672 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
674 hbox_stat = gtk_hbox_new(FALSE, 2);
675 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
677 statusbar = statusbar_create();
678 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
680 progressbar = gtk_progress_bar_new();
681 gtk_widget_set_usize(progressbar, 120, 1);
682 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
684 statuslabel = gtk_label_new("");
685 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
687 ac_button = gtk_button_new();
688 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
689 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
690 gtk_widget_set_usize(ac_button, -1, 1);
691 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
692 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
693 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
695 ac_label = gtk_label_new("");
696 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
698 gtk_widget_show_all(hbox_stat);
701 mainwin->folderview = folderview = folderview_create();
702 mainwin->summaryview = summaryview = summary_create();
703 mainwin->messageview = messageview = messageview_create();
704 mainwin->headerwin = header_window_create();
705 mainwin->logwin = log_window_create();
707 folderview->mainwin = mainwin;
708 folderview->summaryview = summaryview;
710 summaryview->mainwin = mainwin;
711 summaryview->folderview = folderview;
712 summaryview->messageview = messageview;
713 summaryview->headerwin = mainwin->headerwin;
714 summaryview->window = window;
716 messageview->mainwin = mainwin;
718 mainwin->window = window;
719 mainwin->vbox = vbox;
720 mainwin->menubar = menubar;
721 mainwin->handlebox = handlebox;
722 mainwin->vbox_body = vbox_body;
723 mainwin->hbox_stat = hbox_stat;
724 mainwin->statusbar = statusbar;
725 mainwin->progressbar = progressbar;
726 mainwin->statuslabel = statuslabel;
727 mainwin->ac_button = ac_button;
728 mainwin->ac_label = ac_label;
730 /* set context IDs for status bar */
731 mainwin->mainwin_cid = gtk_statusbar_get_context_id
732 (GTK_STATUSBAR(statusbar), "Main Window");
733 mainwin->folderview_cid = gtk_statusbar_get_context_id
734 (GTK_STATUSBAR(statusbar), "Folder View");
735 mainwin->summaryview_cid = gtk_statusbar_get_context_id
736 (GTK_STATUSBAR(statusbar), "Summary View");
738 /* allocate colors for summary view and folder view */
739 summaryview->color_marked.red = summaryview->color_marked.green = 0;
740 summaryview->color_marked.blue = (guint16)65535;
742 summaryview->color_dim.red = summaryview->color_dim.green =
743 summaryview->color_dim.blue = COLOR_DIM;
745 folderview->color_new.red = (guint16)55000;
746 folderview->color_new.green = folderview->color_new.blue = 15000;
748 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
749 &folderview->color_op);
751 summaryview->color_important.red = 0;
752 summaryview->color_marked.green = 0;
753 summaryview->color_important.blue = (guint16)65535;
755 color[0] = summaryview->color_marked;
756 color[1] = summaryview->color_dim;
757 color[2] = folderview->color_new;
758 color[3] = folderview->color_op;
760 colormap = gdk_window_get_colormap(window->window);
761 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
762 for (i = 0; i < 4; i++) {
763 if (success[i] == FALSE)
764 g_warning(_("MainWindow: color allocation %d failed\n"), i);
767 debug_print(_("done.\n"));
769 main_window_set_widgets(mainwin, type);
772 ifactory = gtk_item_factory_from_widget(menubar);
773 menuitem = gtk_item_factory_get_item
774 (ifactory, "/View/Code set/Auto detect");
775 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
777 switch (prefs_common.toolbar_style) {
779 menuitem = gtk_item_factory_get_item
780 (ifactory, "/View/Toolbar/None");
783 menuitem = gtk_item_factory_get_item
784 (ifactory, "/View/Toolbar/Icon");
787 menuitem = gtk_item_factory_get_item
788 (ifactory, "/View/Toolbar/Text");
791 menuitem = gtk_item_factory_get_item
792 (ifactory, "/View/Toolbar/Icon and text");
794 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
796 gtk_widget_hide(mainwin->hbox_stat);
797 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
798 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
799 prefs_common.show_statusbar);
801 /* set the check of the SEPARATE_xxx menu items. we also need the main window
802 * as a property and pass the action type to the callback */
803 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
805 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
806 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
807 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
808 GUINT_TO_POINTER(SEPARATE_FOLDER));
810 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
812 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
813 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
814 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
815 GUINT_TO_POINTER(SEPARATE_MESSAGE));
818 menu_set_sensitive(ifactory, "/Summary/Thread view",
819 prefs_common.enable_thread ? FALSE : TRUE);
820 menu_set_sensitive(ifactory, "/Summary/Unthread view",
821 prefs_common.enable_thread ? TRUE : FALSE);
823 /*main_window_set_thread_option(mainwin);*/
826 /* set account selection menu */
827 ac_menu = gtk_item_factory_get_widget
828 (ifactory, "/Configuration/Change current account");
829 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
830 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
831 mainwin->ac_menu = ac_menu;
833 main_window_set_toolbar_sensitive(mainwin);
835 /* show main window */
836 gtk_widget_set_uposition(mainwin->window,
837 prefs_common.mainwin_x,
838 prefs_common.mainwin_y);
839 gtk_widget_set_usize(window, prefs_common.mainwin_width,
840 prefs_common.mainwin_height);
842 gtk_widget_show(mainwin->window);
844 /* initialize views */
845 folderview_init(folderview);
846 summary_init(summaryview);
847 messageview_init(messageview);
848 header_window_init(mainwin->headerwin);
849 log_window_init(mainwin->logwin);
852 mainwin->lock_count = 0;
853 mainwin->cursor_count = 0;
856 watch_cursor = gdk_cursor_new(GDK_WATCH);
858 mainwin_list = g_list_append(mainwin_list, mainwin);
863 void main_window_cursor_wait(MainWindow *mainwin)
866 if (mainwin->cursor_count == 0)
867 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
869 mainwin->cursor_count++;
874 void main_window_cursor_normal(MainWindow *mainwin)
876 if (mainwin->cursor_count)
877 mainwin->cursor_count--;
879 if (mainwin->cursor_count == 0)
880 gdk_window_set_cursor(mainwin->window->window, NULL);
885 /* lock / unlock the user-interface */
886 void main_window_lock(MainWindow *mainwin)
888 if (mainwin->lock_count == 0)
889 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
891 mainwin->lock_count++;
893 main_window_set_menu_sensitive(mainwin);
894 main_window_set_toolbar_sensitive(mainwin);
897 void main_window_unlock(MainWindow *mainwin)
899 if (mainwin->lock_count)
900 mainwin->lock_count--;
902 main_window_set_menu_sensitive(mainwin);
903 main_window_set_toolbar_sensitive(mainwin);
905 if (mainwin->lock_count == 0)
906 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
909 void main_window_reflect_prefs_all(void)
914 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
915 mainwin = (MainWindow *)cur->data;
917 main_window_show_cur_account(mainwin);
918 main_window_set_menu_sensitive(mainwin);
919 main_window_set_toolbar_sensitive(mainwin);
921 if (prefs_common.immediate_exec)
922 gtk_widget_hide(mainwin->exec_btn);
924 gtk_widget_show(mainwin->exec_btn);
926 summary_change_display_item(mainwin->summaryview);
927 summary_redisplay_msg(mainwin->summaryview);
928 headerview_set_visibility(mainwin->messageview->headerview,
929 prefs_common.display_header_pane);
933 void main_window_set_account_menu(GList *account_list)
935 GList *cur, *cur_ac, *cur_item;
938 PrefsAccount *ac_prefs;
940 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
941 mainwin = (MainWindow *)cur->data;
943 /* destroy all previous menu item */
944 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
945 while (cur_item != NULL) {
946 GList *next = cur_item->next;
947 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
951 for (cur_ac = account_list; cur_ac != NULL;
952 cur_ac = cur_ac->next) {
953 ac_prefs = (PrefsAccount *)cur_ac->data;
955 menuitem = gtk_menu_item_new_with_label
956 (ac_prefs->account_name
957 ? ac_prefs->account_name : _("Untitled"));
958 gtk_widget_show(menuitem);
959 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
960 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
961 GTK_SIGNAL_FUNC(account_menu_cb),
967 static void main_window_show_cur_account(MainWindow *mainwin)
972 ac_name = g_strdup(cur_account
973 ? (cur_account->account_name
974 ? cur_account->account_name : _("Untitled"))
978 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
980 buf = g_strdup(PROG_VERSION);
981 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
984 /* buf = g_strdup_printf(_("Current account: %s"), ac_name);
985 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf); */
986 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
987 gtk_widget_queue_resize(mainwin->ac_button);
993 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
995 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
996 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
997 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
999 if (mainwin->type == type) return;
1001 /* remove widgets from those containers */
1002 gtk_widget_ref(folder_wid);
1003 gtk_widget_ref(summary_wid);
1004 gtk_widget_ref(message_wid);
1005 gtk_container_remove
1006 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1007 gtk_container_remove
1008 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1009 gtk_container_remove
1010 (GTK_CONTAINER(message_wid->parent), message_wid);
1012 /* clean containers */
1013 switch (mainwin->type) {
1015 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1017 case SEPARATE_FOLDER:
1018 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1019 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1021 case SEPARATE_MESSAGE:
1022 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1023 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1026 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1027 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1031 gtk_widget_hide(mainwin->window);
1032 main_window_set_widgets(mainwin, type);
1033 gtk_widget_show(mainwin->window);
1035 gtk_widget_unref(folder_wid);
1036 gtk_widget_unref(summary_wid);
1037 gtk_widget_unref(message_wid);
1040 void main_window_get_size(MainWindow *mainwin)
1042 GtkAllocation *allocation;
1044 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1046 prefs_common.summaryview_width = allocation->width;
1048 if (mainwin->summaryview->msg_is_toggled_on)
1049 prefs_common.summaryview_height = allocation->height;
1051 prefs_common.mainview_width = allocation->width;
1053 allocation = &mainwin->window->allocation;
1055 prefs_common.mainview_height = allocation->height;
1056 prefs_common.mainwin_width = allocation->width;
1057 prefs_common.mainwin_height = allocation->height;
1059 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1061 prefs_common.folderview_width = allocation->width;
1062 prefs_common.folderview_height = allocation->height;
1065 void main_window_get_position(MainWindow *mainwin)
1069 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1071 prefs_common.mainview_x = x;
1072 prefs_common.mainview_y = y;
1073 prefs_common.mainwin_x = x;
1074 prefs_common.mainwin_y = y;
1076 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1079 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1084 if (alertpanel(_("Empty trash"),
1085 _("Empty all messages in trash?"),
1086 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1088 manage_window_focus_in(mainwin->window, NULL, NULL);
1091 procmsg_empty_trash();
1093 for (list = folder_get_list(); list != NULL; list = list->next) {
1096 folder = list->data;
1097 if (folder->trash) {
1098 folder_item_scan(folder->trash);
1099 folderview_update_item(folder->trash, TRUE);
1103 if (mainwin->summaryview->folder_item &&
1104 mainwin->summaryview->folder_item->stype == F_TRASH)
1105 gtk_widget_grab_focus(mainwin->folderview->ctree);
1108 void main_window_add_mailbox(MainWindow *mainwin)
1113 path = input_dialog(_("Add mailbox"),
1114 _("Input the location of mailbox.\n"
1115 "If the existing mailbox is specified, it will be\n"
1116 "scanned automatically."),
1119 if (folder_find_from_path(path)) {
1120 alertpanel_error(_("The mailbox `%s' already exists."), path);
1124 if (!strcmp(path, "Mail"))
1125 folder = folder_new(F_MH, _("Mailbox"), path);
1127 folder = folder_new(F_MH, g_basename(path), path);
1130 if (folder->create_tree(folder) < 0) {
1131 alertpanel_error(_("Creation of the mailbox failed.\n"
1132 "Maybe some files already exist, or you don't have the permission to write there."));
1133 folder_destroy(folder);
1138 folder_set_ui_func(folder, scan_tree_func, mainwin);
1139 folder->scan_tree(folder);
1140 folder_set_ui_func(folder, NULL, NULL);
1142 folderview_set(mainwin->folderview);
1145 void main_window_add_mbox(MainWindow *mainwin)
1151 path = input_dialog(_("Add mbox mailbox"),
1152 _("Input the location of mailbox."),
1157 if (folder_find_from_path(path)) {
1158 alertpanel_error(_("The mailbox `%s' already exists."), path);
1164 if (!strcmp(path, "Mail"))
1165 folder = folder_new(F_MBOX, _("Mailbox"), path);
1169 folder = folder_new(F_MBOX, g_basename(path), path);
1172 if (folder->create_tree(folder) < 0) {
1173 alertpanel_error(_("Creation of the mailbox failed."));
1174 folder_destroy(folder);
1180 item = folder_item_new(folder->name, NULL);
1181 item->folder = folder;
1182 folder->node = g_node_new(item);
1184 folder->create_folder(folder, item, "inbox");
1185 folder->create_folder(folder, item, "outbox");
1186 folder->create_folder(folder, item, "queue");
1187 folder->create_folder(folder, item, "draft");
1188 folder->create_folder(folder, item, "trash");
1190 folderview_set(mainwin->folderview);
1195 M_UNLOCKED = 1 << 0,
1196 M_MSG_EXIST = 1 << 1,
1197 M_TARGET_EXIST = 1 << 2,
1198 M_SINGLE_TARGET_EXIST = 1 << 3,
1200 M_ALLOW_REEDIT = 1 << 5,
1201 M_HAVE_ACCOUNT = 1 << 6
1204 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1206 SensitiveCond state = 0;
1207 SummarySelection selection;
1209 selection = summary_get_selection_type(mainwin->summaryview);
1211 if (mainwin->lock_count == 0)
1212 state |= M_UNLOCKED;
1213 if (selection != SUMMARY_NONE)
1214 state |= M_MSG_EXIST;
1215 if (selection == SUMMARY_SELECTED_SINGLE ||
1216 selection == SUMMARY_SELECTED_MULTIPLE)
1217 state |= M_TARGET_EXIST;
1218 if (selection == SUMMARY_SELECTED_SINGLE)
1219 state |= M_SINGLE_TARGET_EXIST;
1220 if (mainwin->summaryview->folder_item &&
1221 mainwin->summaryview->folder_item->folder->type != F_NEWS)
1223 if (selection == SUMMARY_SELECTED_SINGLE &&
1224 (mainwin->summaryview->folder_item &&
1225 (mainwin->summaryview->folder_item->stype == F_DRAFT ||
1226 mainwin->summaryview->folder_item->stype == F_QUEUE)))
1227 state |= M_ALLOW_REEDIT;
1229 state |= M_HAVE_ACCOUNT;
1234 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1236 SensitiveCond state;
1244 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1245 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1246 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1247 {mainwin->compose_news_btn, M_HAVE_ACCOUNT},
1248 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1249 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1250 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1251 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1252 /* {mainwin->prefs_btn , M_UNLOCKED},
1253 {mainwin->account_btn , M_UNLOCKED}, */
1254 {mainwin->next_btn , M_MSG_EXIST},
1255 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1256 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1260 state = main_window_get_current_state(mainwin);
1262 for (i = 0; entry[i].widget != NULL; i++) {
1263 sensitive = ((entry[i].cond & state) == entry[i].cond);
1264 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1268 void main_window_set_menu_sensitive(MainWindow *mainwin)
1270 GtkItemFactory *ifactory;
1271 SensitiveCond state;
1275 static const struct {
1279 {"/File/Add mailbox..." , M_UNLOCKED},
1280 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1281 {"/File/Update folder tree" , M_UNLOCKED},
1282 {"/File/Folder" , M_UNLOCKED},
1283 {"/File/Import mbox file..." , M_UNLOCKED},
1284 {"/File/Export to mbox file...", M_UNLOCKED},
1285 {"/File/Empty trash" , M_UNLOCKED},
1286 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1287 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1288 {"/File/Close", M_UNLOCKED},
1289 {"/File/Exit" , M_UNLOCKED},
1291 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1292 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1294 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1295 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1296 {"/Message/Compose new message" , M_HAVE_ACCOUNT},
1297 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1298 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1299 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1300 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1301 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1302 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1303 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1304 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1305 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1306 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1307 {"/Message/Mark" , M_TARGET_EXIST},
1308 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1310 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1311 {"/Summary/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1312 {"/Summary/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1313 {"/Summary/Prev message" , M_MSG_EXIST},
1314 {"/Summary/Next message" , M_MSG_EXIST},
1315 {"/Summary/Next unread message", M_MSG_EXIST},
1316 {"/Summary/Sort" , M_MSG_EXIST},
1318 {"/Configuration", M_UNLOCKED},
1323 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1324 state = main_window_get_current_state(mainwin);
1326 for (i = 0; entry[i].entry != NULL; i++) {
1327 sensitive = ((entry[i].cond & state) == entry[i].cond);
1328 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1332 void main_window_popup(MainWindow *mainwin)
1338 gdk_window_get_origin(mainwin->window->window, &x, &y);
1339 sx = gdk_screen_width();
1340 sy = gdk_screen_height();
1341 x %= sx; if (x < 0) x += sx;
1342 y %= sy; if (y < 0) y += sy;
1343 gdk_window_move(mainwin->window->window, x, y);
1344 gdk_window_raise(mainwin->window->window);
1345 gdk_window_show(mainwin->window->window);
1347 debug_print("window position: x = %d, y = %d\n", x, y);
1349 switch (mainwin->type) {
1350 case SEPARATE_FOLDER:
1351 widget = mainwin->win.sep_folder.folderwin;
1352 gdk_window_get_origin(widget->window, &x, &y);
1353 x %= sx; if (x < 0) x += sx;
1354 y %= sy; if (y < 0) y += sy;
1355 gdk_window_move(widget->window, x, y);
1356 gdk_window_raise(widget->window);
1358 case SEPARATE_MESSAGE:
1359 widget = mainwin->win.sep_message.messagewin;
1360 gdk_window_get_origin(widget->window, &x, &y);
1361 x %= sx; if (x < 0) x += sx;
1362 y %= sy; if (y < 0) y += sy;
1363 gdk_window_move(widget->window, x, y);
1364 gdk_window_raise(widget->window);
1367 widget = mainwin->win.sep_both.folderwin;
1368 gdk_window_get_origin(widget->window, &x, &y);
1369 x %= sx; if (x < 0) x += sx;
1370 y %= sy; if (y < 0) y += sy;
1371 gdk_window_move(widget->window, x, y);
1372 gdk_window_raise(widget->window);
1373 widget = mainwin->win.sep_both.messagewin;
1374 gdk_window_get_origin(widget->window, &x, &y);
1375 x %= sx; if (x < 0) x += sx;
1376 y %= sy; if (y < 0) y += sy;
1377 gdk_window_move(widget->window, x, y);
1378 gdk_window_raise(widget->window);
1385 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1387 GtkWidget *folderwin = NULL;
1388 GtkWidget *messagewin = NULL;
1391 GtkWidget *vbox_body = mainwin->vbox_body;
1393 debug_print(_("Setting widgets..."));
1395 /* create separated window(s) if needed */
1396 if (type & SEPARATE_FOLDER) {
1397 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1398 gtk_window_set_policy(GTK_WINDOW(folderwin),
1400 gtk_widget_set_usize(folderwin, -1,
1401 prefs_common.mainview_height);
1402 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1404 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1405 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1408 if (type & SEPARATE_MESSAGE) {
1409 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1410 gtk_window_set_policy(GTK_WINDOW(messagewin),
1412 gtk_widget_set_usize
1413 (messagewin, prefs_common.mainview_width,
1414 prefs_common.mainview_height
1415 - prefs_common.summaryview_height
1416 + DEFAULT_HEADERVIEW_HEIGHT);
1417 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1419 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1420 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1426 hpaned = gtk_hpaned_new();
1427 gtk_widget_show(hpaned);
1428 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1429 gtk_paned_add1(GTK_PANED(hpaned),
1430 GTK_WIDGET_PTR(mainwin->folderview));
1432 vpaned = gtk_vpaned_new();
1433 if (mainwin->summaryview->msg_is_toggled_on) {
1434 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1435 gtk_paned_add1(GTK_PANED(vpaned),
1436 GTK_WIDGET_PTR(mainwin->summaryview));
1438 gtk_paned_add2(GTK_PANED(hpaned),
1439 GTK_WIDGET_PTR(mainwin->summaryview));
1440 gtk_widget_ref(vpaned);
1442 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1443 prefs_common.summaryview_width,
1444 prefs_common.summaryview_height);
1445 gtk_paned_add2(GTK_PANED(vpaned),
1446 GTK_WIDGET_PTR(mainwin->messageview));
1447 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1448 prefs_common.mainview_width, -1);
1449 gtk_widget_set_usize(mainwin->window,
1450 prefs_common.folderview_width +
1451 prefs_common.mainview_width,
1452 prefs_common.mainwin_height);
1453 gtk_widget_show_all(vpaned);
1455 mainwin->win.sep_none.hpaned = hpaned;
1456 mainwin->win.sep_none.vpaned = vpaned;
1458 case SEPARATE_FOLDER:
1459 vpaned = gtk_vpaned_new();
1460 if (mainwin->summaryview->msg_is_toggled_on) {
1461 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1463 gtk_paned_add1(GTK_PANED(vpaned),
1464 GTK_WIDGET_PTR(mainwin->summaryview));
1466 gtk_box_pack_start(GTK_BOX(vbox_body),
1467 GTK_WIDGET_PTR(mainwin->summaryview),
1469 gtk_widget_ref(vpaned);
1471 gtk_paned_add2(GTK_PANED(vpaned),
1472 GTK_WIDGET_PTR(mainwin->messageview));
1473 gtk_widget_show_all(vpaned);
1474 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1475 prefs_common.summaryview_width,
1476 prefs_common.summaryview_height);
1477 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1478 prefs_common.mainview_width, -1);
1479 gtk_widget_set_usize(mainwin->window,
1480 prefs_common.mainview_width,
1481 prefs_common.mainview_height);
1483 gtk_container_add(GTK_CONTAINER(folderwin),
1484 GTK_WIDGET_PTR(mainwin->folderview));
1486 mainwin->win.sep_folder.folderwin = folderwin;
1487 mainwin->win.sep_folder.vpaned = vpaned;
1489 gtk_widget_show_all(folderwin);
1491 case SEPARATE_MESSAGE:
1492 hpaned = gtk_hpaned_new();
1493 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1495 gtk_paned_add1(GTK_PANED(hpaned),
1496 GTK_WIDGET_PTR(mainwin->folderview));
1497 gtk_paned_add2(GTK_PANED(hpaned),
1498 GTK_WIDGET_PTR(mainwin->summaryview));
1499 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1500 prefs_common.summaryview_width,
1501 prefs_common.summaryview_height);
1502 gtk_widget_set_usize(mainwin->window,
1503 prefs_common.folderview_width +
1504 prefs_common.mainview_width,
1505 prefs_common.mainwin_height);
1506 gtk_widget_show_all(hpaned);
1507 gtk_container_add(GTK_CONTAINER(messagewin),
1508 GTK_WIDGET_PTR(mainwin->messageview));
1510 mainwin->win.sep_message.messagewin = messagewin;
1511 mainwin->win.sep_message.hpaned = hpaned;
1513 gtk_widget_show_all(messagewin);
1516 gtk_box_pack_start(GTK_BOX(vbox_body),
1517 GTK_WIDGET_PTR(mainwin->summaryview),
1519 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1520 prefs_common.summaryview_width,
1521 prefs_common.summaryview_height);
1522 gtk_widget_set_usize(mainwin->window,
1523 prefs_common.mainview_width,
1524 prefs_common.mainwin_height);
1525 gtk_container_add(GTK_CONTAINER(folderwin),
1526 GTK_WIDGET_PTR(mainwin->folderview));
1527 gtk_container_add(GTK_CONTAINER(messagewin),
1528 GTK_WIDGET_PTR(mainwin->messageview));
1530 mainwin->win.sep_both.folderwin = folderwin;
1531 mainwin->win.sep_both.messagewin = messagewin;
1533 gtk_widget_show_all(folderwin);
1534 gtk_widget_show_all(messagewin);
1538 mainwin->type = type;
1540 debug_print(_("done.\n"));
1543 #include "pixmaps/stock_mail_receive.xpm"
1544 #include "pixmaps/stock_mail_receive_all.xpm"
1545 #include "pixmaps/stock_mail_compose.xpm"
1546 #include "pixmaps/stock_news_compose.xpm"
1547 #include "pixmaps/stock_mail_reply.xpm"
1548 #include "pixmaps/stock_mail_reply_to_all.xpm"
1549 #include "pixmaps/stock_mail_reply_to_author.xpm"
1550 #include "pixmaps/stock_mail_forward.xpm"
1551 #include "pixmaps/stock_mail_send.xpm"
1552 #include "pixmaps/stock_preferences.xpm"
1553 #include "pixmaps/stock_properties.xpm"
1554 #include "pixmaps/stock_down_arrow.xpm"
1555 #include "pixmaps/stock_close.xpm"
1556 #include "pixmaps/stock_exec.xpm"
1558 #define CREATE_TOOLBAR_ICON(xpm_d) \
1560 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1561 &container->style->white, \
1563 icon_wid = gtk_pixmap_new(icon, mask); \
1566 static void main_window_toolbar_create(MainWindow *mainwin,
1567 GtkWidget *container)
1572 GtkWidget *icon_wid;
1574 GtkWidget *getall_btn;
1575 GtkWidget *compose_mail_btn;
1576 GtkWidget *compose_news_btn;
1577 GtkWidget *compose_mail_btn_plain;
1578 GtkWidget *compose_news_btn_plain;
1579 GtkWidget *reply_btn;
1580 GtkWidget *replyall_btn;
1581 GtkWidget *replysender_btn;
1583 GtkWidget *send_btn;
1585 GtkWidget *prefs_btn;
1586 GtkWidget *account_btn;
1588 GtkWidget *next_btn;
1589 GtkWidget *delete_btn;
1590 GtkWidget *exec_btn;
1591 GtkWidget *compose_type_btn;
1592 GtkWidget *compose_type_arrow;
1593 GtkWidget *compose_box;
1594 GtkWidget *compose_label;
1595 GtkTooltips *tooltips;
1597 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1599 gtk_container_add(GTK_CONTAINER(container), toolbar);
1600 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1601 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1602 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1603 GTK_TOOLBAR_SPACE_LINE);
1605 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1606 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1608 _("Get new mail from current account"),
1610 icon_wid, toolbar_inc_cb, mainwin);
1611 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1612 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1614 _("Get new mail from all accounts"),
1620 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1622 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1623 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1625 _("Send queued message(s)"),
1631 /* to implement Leandro's "combined" compose buttons, we create
1632 * two sets of compose buttons, one for normal (text + icon)
1633 * toolbar, and one for both text-only and icon-only toolbar;
1634 * we switch between those sets. */
1636 /* insert compose mail button widget */
1638 compose_mail_btn = gtk_button_new();
1639 gtk_widget_show(compose_mail_btn);
1640 tooltips = gtk_tooltips_new();
1641 gtk_tooltips_set_tip(tooltips, compose_mail_btn,
1642 _("Compose email message"),
1644 compose_box = gtk_vbox_new(0, 0);
1645 gtk_widget_show(compose_box);
1647 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1648 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1649 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1651 compose_label = gtk_label_new(_("Email"));
1652 gtk_widget_show(compose_label);
1653 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1655 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1656 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1657 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1660 /* insert compose news button widget */
1662 compose_news_btn = gtk_button_new();
1663 gtk_widget_show(compose_news_btn);
1664 tooltips = gtk_tooltips_new();
1665 gtk_tooltips_set_tip(tooltips, compose_news_btn,
1666 _("Compose news article"),
1668 compose_box = gtk_vbox_new(0, 0);
1669 gtk_widget_show(compose_box);
1671 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1672 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1673 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1675 compose_label = gtk_label_new(_("News"));
1676 gtk_widget_show(compose_label);
1677 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1679 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_news_btn), GTK_CAN_FOCUS);
1680 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1681 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1684 /* insert compose btn plain */
1686 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1687 compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1689 _("Compose an email message"),
1692 toolbar_compose_mail_cb,
1695 /* insert compose btn plain */
1697 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1698 compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1700 _("Compose a news message"),
1703 toolbar_compose_news_cb,
1706 /* insert compose button type widget */
1708 compose_type_btn = gtk_button_new();
1709 gtk_widget_show(compose_type_btn);
1711 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1712 gtk_widget_show(compose_type_arrow);
1714 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1716 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1717 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1719 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1722 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1724 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1725 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1727 _("Reply to the message"),
1732 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1733 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1738 toolbar_reply_to_all_cb,
1740 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1741 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1743 _("Reply to sender"),
1746 toolbar_reply_to_sender_cb,
1748 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1749 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1751 _("Forward the message"),
1757 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1759 CREATE_TOOLBAR_ICON(stock_close_xpm);
1760 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1762 _("Delete the message"),
1768 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1769 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1771 _("Execute marked process"),
1777 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1778 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1780 _("Next unread message"),
1783 toolbar_next_unread_cb,
1787 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1789 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1790 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1792 _("Common preference"),
1797 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1798 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1800 _("Account setting"),
1805 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1806 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1810 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1811 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1814 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1815 GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
1818 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
1819 GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
1822 mainwin->toolbar = toolbar;
1823 mainwin->get_btn = get_btn;
1824 mainwin->getall_btn = getall_btn;
1825 mainwin->compose_mail_btn = compose_mail_btn;
1826 mainwin->compose_news_btn = compose_news_btn;
1827 mainwin->compose_mail_btn_plain = compose_mail_btn_plain;
1828 mainwin->compose_news_btn_plain = compose_news_btn_plain;
1829 mainwin->reply_btn = reply_btn;
1830 mainwin->replyall_btn = replyall_btn;
1831 mainwin->replysender_btn = replysender_btn;
1832 mainwin->fwd_btn = fwd_btn;
1833 mainwin->send_btn = send_btn;
1835 mainwin->prefs_btn = prefs_btn;
1836 mainwin->account_btn = account_btn;
1838 mainwin->next_btn = next_btn;
1839 mainwin->delete_btn = delete_btn;
1840 mainwin->exec_btn = exec_btn;
1842 gtk_widget_show_all(toolbar);
1844 /* activate Leandro menu system */
1845 activate_compose_button(mainwin,
1846 prefs_common.toolbar_style,
1847 mainwin->compose_btn_type);
1850 /* callback functions */
1852 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1855 MainWindow *mainwindow = (MainWindow *) data;
1856 GtkWidget *compose_menu, *compose_item;
1858 g_return_if_fail(mainwindow != NULL);
1860 compose_menu = gtk_menu_new();
1862 compose_item = gtk_menu_item_new_with_label(_("Email message"));
1863 gtk_widget_show(compose_item);
1864 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1865 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1866 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1868 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1870 compose_item = gtk_menu_item_new_with_label(_("News article"));
1871 gtk_widget_show(compose_item);
1872 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1873 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1874 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1876 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1878 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1882 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1884 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1885 MainWindow *mainwindow = (MainWindow *) data;
1887 mainwindow->compose_btn_type = compose_type;
1889 activate_compose_button(mainwindow, prefs_common.toolbar_style, mainwindow->compose_btn_type);
1892 static void toolbar_inc_cb (GtkWidget *widget,
1895 MainWindow *mainwin = (MainWindow *)data;
1897 inc_mail_cb(mainwin, 0, NULL);
1900 static void toolbar_inc_all_cb (GtkWidget *widget,
1903 MainWindow *mainwin = (MainWindow *)data;
1905 inc_all_account_mail_cb(mainwin, 0, NULL);
1908 static void toolbar_send_cb (GtkWidget *widget,
1911 MainWindow *mainwin = (MainWindow *)data;
1913 send_queue_cb(mainwin, 0, NULL);
1916 static void toolbar_compose_cb (GtkWidget *widget,
1919 MainWindow *mainwin = (MainWindow *)data;
1921 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1922 compose_cb(mainwin, 0, NULL);
1924 compose_news_cb(mainwin, 0, NULL);
1927 static void toolbar_compose_news_cb (GtkWidget *widget,
1930 MainWindow *mainwin = (MainWindow *)data;
1932 compose_news_cb(mainwin, 0, NULL);
1935 static void toolbar_compose_mail_cb (GtkWidget *widget,
1938 MainWindow *mainwin = (MainWindow *)data;
1940 compose_mail_cb(mainwin, 0, NULL);
1943 static void toolbar_reply_cb (GtkWidget *widget,
1946 MainWindow *mainwin = (MainWindow *)data;
1948 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1951 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1954 MainWindow *mainwin = (MainWindow *)data;
1956 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1959 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1962 MainWindow *mainwin = (MainWindow *)data;
1964 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1967 static void toolbar_forward_cb (GtkWidget *widget,
1970 MainWindow *mainwin = (MainWindow *)data;
1972 if (prefs_common.forward_as_attachment)
1973 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
1975 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1978 static void toolbar_delete_cb (GtkWidget *widget,
1981 MainWindow *mainwin = (MainWindow *)data;
1983 summary_delete(mainwin->summaryview);
1986 static void toolbar_exec_cb (GtkWidget *widget,
1989 MainWindow *mainwin = (MainWindow *)data;
1991 summary_execute(mainwin->summaryview);
1994 static void toolbar_next_unread_cb (GtkWidget *widget,
1997 MainWindow *mainwin = (MainWindow *)data;
1999 next_unread_cb(mainwin, 0, NULL);
2002 static void toolbar_prefs_cb (GtkWidget *widget,
2005 prefs_common_open();
2008 static void toolbar_account_cb (GtkWidget *widget,
2011 MainWindow *mainwin = (MainWindow *)data;
2013 prefs_account_open_cb(mainwin, 0, NULL);
2016 static void toolbar_account_button_pressed(GtkWidget *widget,
2017 GdkEventButton *event,
2020 MainWindow *mainwin = (MainWindow *)data;
2023 if (event->button != 3) return;
2025 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2026 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2029 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2030 menu_button_position, widget,
2031 event->button, event->time);
2034 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2037 MainWindow *mainwin = (MainWindow *)data;
2041 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2042 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2045 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2046 menu_button_position, widget,
2047 event->button, event->time);
2050 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2052 MainWindow *mainwin = (MainWindow *)data;
2055 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2056 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2057 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2058 manage_window_focus_in(mainwin->window, NULL, NULL);
2061 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2064 MainWindow *mainwin = (MainWindow *)data;
2066 if (mainwin->lock_count == 0)
2067 app_exit_cb(data, 0, widget);
2072 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2075 main_window_add_mailbox(mainwin);
2078 static void add_mbox_cb(MainWindow *mainwin, guint action,
2081 main_window_add_mbox(mainwin);
2084 static void update_folderview_cb(MainWindow *mainwin, guint action,
2087 summary_show(mainwin->summaryview, NULL, FALSE);
2088 folderview_update_all();
2091 static void new_folder_cb(MainWindow *mainwin, guint action,
2094 folderview_new_folder(mainwin->folderview);
2097 static void rename_folder_cb(MainWindow *mainwin, guint action,
2100 folderview_rename_folder(mainwin->folderview);
2103 static void delete_folder_cb(MainWindow *mainwin, guint action,
2106 folderview_delete_folder(mainwin->folderview);
2109 static void import_mbox_cb(MainWindow *mainwin, guint action,
2112 import_mbox(mainwin->summaryview->folder_item);
2115 static void export_mbox_cb(MainWindow *mainwin, guint action,
2118 export_mbox(mainwin->summaryview->folder_item);
2121 static void empty_trash_cb(MainWindow *mainwin, guint action,
2124 main_window_empty_trash(mainwin, TRUE);
2127 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2129 summary_save_as(mainwin->summaryview);
2132 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2134 summary_print(mainwin->summaryview);
2137 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2139 if (prefs_common.confirm_on_exit) {
2140 if (alertpanel(_("Exit"), _("Exit this program?"),
2141 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2143 manage_window_focus_in(mainwin->window, NULL, NULL);
2146 app_will_exit(widget, mainwin);
2149 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2152 switch (mainwin->type) {
2154 case SEPARATE_MESSAGE:
2156 case SEPARATE_FOLDER:
2157 if (GTK_CHECK_MENU_ITEM(widget)->active)
2158 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2160 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2163 if (GTK_CHECK_MENU_ITEM(widget)->active)
2164 gtk_widget_show(mainwin->win.sep_both.folderwin);
2166 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2171 static void toggle_message_cb(MainWindow *mainwin, guint action,
2174 switch (mainwin->type) {
2176 case SEPARATE_FOLDER:
2178 case SEPARATE_MESSAGE:
2179 if (GTK_CHECK_MENU_ITEM(widget)->active)
2180 gtk_widget_show(mainwin->win.sep_message.messagewin);
2182 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2185 if (GTK_CHECK_MENU_ITEM(widget)->active)
2186 gtk_widget_show(mainwin->win.sep_both.messagewin);
2188 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2193 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2196 activate_compose_button(mainwin, (ToolbarStyle)action,
2197 mainwin->compose_btn_type);
2199 switch ((ToolbarStyle)action) {
2201 gtk_widget_hide(mainwin->handlebox);
2203 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2207 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2211 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2216 if (action != TOOLBAR_NONE) {
2217 gtk_widget_show(mainwin->handlebox);
2218 gtk_widget_queue_resize(mainwin->handlebox);
2221 mainwin->toolbar_style = (ToolbarStyle)action;
2222 prefs_common.toolbar_style = (ToolbarStyle)action;
2225 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2228 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2229 gtk_widget_show(mainwin->hbox_stat);
2230 prefs_common.show_statusbar = TRUE;
2232 gtk_widget_hide(mainwin->hbox_stat);
2233 prefs_common.show_statusbar = FALSE;
2237 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2240 MainWindow *mainwin;
2243 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2244 g_return_if_fail(mainwin != NULL);
2246 type = mainwin->type ^ action;
2247 main_window_separation_change(mainwin, type);
2249 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2250 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2253 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2256 addressbook_open(NULL);
2259 static void log_window_show_cb(MainWindow *mainwin, guint action,
2262 log_window_show(mainwin->logwin);
2265 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2270 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2273 inc_all_account_mail(mainwin);
2276 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2280 if (procmsg_send_queue() < 0)
2281 alertpanel_error(_("Some errors occurred while sending queued messages."));
2283 statusbar_pop_all();
2285 for (list = folder_get_list(); list != NULL; list = list->next) {
2288 folder = list->data;
2289 if (folder->queue) {
2290 folder_item_scan(folder->queue);
2291 folderview_update_item(folder->queue, TRUE);
2296 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2298 if (mainwin->summaryview->folder_item) {
2299 if (mainwin->summaryview->folder_item->folder->account != NULL
2300 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2301 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2303 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2309 static void compose_mail_cb(MainWindow *mainwin, guint action,
2316 if (mainwin->summaryview->folder_item) {
2317 ac = mainwin->summaryview->folder_item->folder->account;
2318 if (ac && ac->protocol != A_NNTP) {
2319 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2324 if(cur_account && (cur_account->protocol != A_NNTP)) {
2325 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2329 list = account_get_list();
2330 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2331 ac = (PrefsAccount *) cur->data;
2332 if (ac->protocol != A_NNTP) {
2333 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2339 static void compose_news_cb(MainWindow *mainwin, guint action,
2342 PrefsAccount * ac = NULL;
2346 if (mainwin->summaryview->folder_item) {
2347 ac = mainwin->summaryview->folder_item->folder->account;
2348 if (ac && ac->protocol == A_NNTP) {
2349 compose_new_with_recipient
2350 (ac, mainwin->summaryview->folder_item->path);
2355 list = account_get_list();
2356 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2357 ac = (PrefsAccount *) cur->data;
2358 if (ac->protocol == A_NNTP) {
2365 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2367 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2370 msginfo = gtk_ctree_node_get_row_data
2371 (GTK_CTREE(mainwin->summaryview->ctree),
2372 mainwin->summaryview->selected);
2374 if (!msginfo) return;
2378 compose_reply(msginfo, prefs_common.reply_with_quote,
2381 case COMPOSE_REPLY_TO_SENDER:
2382 compose_reply(msginfo, prefs_common.reply_with_quote,
2385 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2386 compose_followup_and_reply_to(msginfo,
2387 prefs_common.reply_with_quote,
2390 case COMPOSE_REPLY_TO_ALL:
2391 compose_reply(msginfo, prefs_common.reply_with_quote,
2394 case COMPOSE_FORWARD:
2396 compose_forward(NULL, msginfo, FALSE);
2399 /* if (sel->next) FALL_THROUGH */
2400 case COMPOSE_FORWARD_AS_ATTACH:
2402 GSList *msginfo_list = NULL;
2403 for ( ; sel != NULL; sel = sel->next)
2404 msginfo_list = g_slist_append(msginfo_list,
2405 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2406 GTK_CTREE_NODE(sel->data)));
2407 compose_forward_multiple(NULL, msginfo_list);
2408 g_slist_free(msginfo_list);
2412 g_warning("reply_cb(): invalid action type: %d\n", action);
2415 summary_set_marks_selected(mainwin->summaryview);
2418 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2420 summary_move_to(mainwin->summaryview);
2423 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2425 summary_copy_to(mainwin->summaryview);
2428 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2430 summary_delete(mainwin->summaryview);
2433 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2435 summary_open_msg(mainwin->summaryview);
2438 static void view_source_cb(MainWindow *mainwin, guint action,
2441 summary_view_source(mainwin->summaryview);
2444 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2446 summary_reedit(mainwin->summaryview);
2449 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2451 summary_mark(mainwin->summaryview);
2454 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2456 summary_unmark(mainwin->summaryview);
2459 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2462 summary_mark_as_unread(mainwin->summaryview);
2465 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2468 summary_mark_as_read(mainwin->summaryview);
2471 static void set_charset_cb(MainWindow *mainwin, guint action,
2476 str = conv_get_charset_str((CharSet)action);
2477 g_free(prefs_common.force_charset);
2478 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2480 summary_redisplay_msg(mainwin->summaryview);
2482 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2485 /*void main_window_set_thread_option(MainWindow *mainwin)
2487 GtkItemFactory *ifactory;
2488 gboolean no_item = FALSE;
2490 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2492 if (mainwin->summaryview == NULL)
2494 else if (mainwin->summaryview->folder_item == NULL)
2498 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2499 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2502 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2503 menu_set_sensitive(ifactory,
2504 "/Summary/Thread view", FALSE);
2505 menu_set_sensitive(ifactory,
2506 "/Summary/Unthread view", TRUE);
2507 summary_thread_build(mainwin->summaryview, TRUE);
2510 menu_set_sensitive(ifactory,
2511 "/Summary/Thread view", TRUE);
2512 menu_set_sensitive(ifactory,
2513 "/Summary/Unthread view", FALSE);
2514 summary_unthread(mainwin->summaryview);
2516 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2520 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2522 /*mainwin->summaryview->folder_item->prefs->enable_thread =
2523 !mainwin->summaryview->folder_item->prefs->enable_thread;
2524 main_window_set_thread_option(mainwin);
2527 GtkItemFactory *ifactory;
2529 ifactory = gtk_item_factory_from_widget(widget);
2532 summary_thread_build(mainwin->summaryview, FALSE);
2533 prefs_common.enable_thread = TRUE;
2534 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2535 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2537 summary_unthread(mainwin->summaryview);
2538 prefs_common.enable_thread = FALSE;
2539 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2540 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2544 static void set_display_item_cb(MainWindow *mainwin, guint action,
2547 prefs_summary_display_item_set();
2550 static void sort_summary_cb(MainWindow *mainwin, guint action,
2553 summary_sort(mainwin->summaryview, (SummarySortType)action);
2556 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2559 summary_attract_by_subject(mainwin->summaryview);
2562 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2565 summary_delete_duplicated(mainwin->summaryview);
2568 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2570 summary_filter(mainwin->summaryview);
2573 static void execute_summary_cb(MainWindow *mainwin, guint action,
2576 summary_execute(mainwin->summaryview);
2579 static void update_summary_cb(MainWindow *mainwin, guint action,
2583 FolderView *folderview = mainwin->folderview;
2585 if (!mainwin->summaryview->folder_item) return;
2586 if (!folderview->opened) return;
2588 folder_update_op_count();
2590 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2591 folderview->opened);
2594 summary_show(mainwin->summaryview, fitem, TRUE);
2597 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2599 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2602 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2604 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2607 static void next_unread_cb(MainWindow *mainwin, guint action,
2610 summary_select_next_unread(mainwin->summaryview);
2613 static void next_marked_cb(MainWindow *mainwin, guint action,
2616 summary_select_next_marked(mainwin->summaryview);
2619 static void prev_marked_cb(MainWindow *mainwin, guint action,
2622 summary_select_prev_marked(mainwin->summaryview);
2625 static void next_labeled_cb(MainWindow *mainwin, guint action,
2628 summary_select_next_labeled(mainwin->summaryview);
2631 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2634 summary_select_prev_labeled(mainwin->summaryview);
2637 static void goto_folder_cb(MainWindow *mainwin, guint action,
2640 FolderItem *to_folder;
2642 to_folder = foldersel_folder_sel(NULL, NULL);
2645 folderview_select(mainwin->folderview, to_folder);
2648 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2650 messageview_copy_clipboard(mainwin->messageview);
2653 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2655 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2656 summary_select_all(mainwin->summaryview);
2657 else if (mainwin->summaryview->msg_is_toggled_on &&
2658 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2659 messageview_select_all(mainwin->messageview);
2662 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2665 prefs_common_open();
2668 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2671 prefs_filter_open();
2674 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2677 prefs_scoring_open(NULL);
2680 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2683 prefs_filtering_open();
2686 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2690 new_account_cb(mainwin, 0, widget);
2692 gboolean prev_default = cur_account->is_default;
2694 prefs_account_open(cur_account);
2695 if (!prev_default && cur_account->is_default)
2696 account_set_as_default(cur_account);
2697 account_save_config_all();
2699 main_window_reflect_prefs_all();
2703 static void new_account_cb(MainWindow *mainwin, guint action,
2706 account_edit_open();
2707 if (!compose_get_compose_list()) account_add();
2710 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2712 cur_account = (PrefsAccount *)data;
2713 main_window_reflect_prefs_all();
2716 static void manual_open_cb(MainWindow *mainwin, guint action,
2719 manual_open((ManualLang)action);
2722 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2724 MainWindow *mainwin = (MainWindow *)data;
2728 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2729 LOCAL_FOLDER(folder)->rootpath,
2733 str = g_strdup_printf(_("Scanning folder %s ..."),
2734 LOCAL_FOLDER(folder)->rootpath);
2736 STATUSBAR_PUSH(mainwin, str);
2737 STATUSBAR_POP(mainwin);
2741 static void activate_compose_button (MainWindow *mainwin,
2743 ComposeButtonType type)
2745 if (style == TOOLBAR_NONE)
2748 if (style == TOOLBAR_BOTH) {
2749 gtk_widget_hide(mainwin->compose_mail_btn_plain);
2750 gtk_widget_hide(mainwin->compose_news_btn_plain);
2751 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2752 : mainwin->compose_news_btn);
2753 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2754 : mainwin->compose_mail_btn);
2755 mainwin->compose_btn_type = type;
2758 gtk_widget_hide(mainwin->compose_news_btn);
2759 gtk_widget_hide(mainwin->compose_mail_btn);
2760 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn_plain
2761 : mainwin->compose_news_btn_plain);
2762 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn_plain
2763 : mainwin->compose_mail_btn_plain);
2764 mainwin->compose_btn_type = type;
2768 static void prefs_templates_open_cb(MainWindow *mainwin, guint action,
2771 prefs_templates_open();