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 goto_folder_cb (MainWindow *mainwin,
332 static void copy_cb (MainWindow *mainwin,
335 static void allsel_cb (MainWindow *mainwin,
339 static void prefs_common_open_cb (MainWindow *mainwin,
342 static void prefs_filter_open_cb (MainWindow *mainwin,
345 static void prefs_scoring_open_cb (MainWindow *mainwin,
348 static void prefs_filtering_open_cb (MainWindow *mainwin,
351 static void prefs_account_open_cb(MainWindow *mainwin,
354 static void new_account_cb (MainWindow *mainwin,
358 static void account_menu_cb (GtkMenuItem *menuitem,
361 static void manual_open_cb (MainWindow *mainwin,
365 static void scan_tree_func (Folder *folder,
369 static void activate_compose_button (MainWindow *mainwin,
371 ComposeButtonType type);
373 static void prefs_templates_open_cb(MainWindow *mainwin,
377 #define SEPARATE_ACTION 667
379 static GtkItemFactoryEntry mainwin_entries[] =
381 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
382 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
383 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
384 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
385 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
386 {N_("/_File/_Folder/Create _new folder..."),
387 NULL, new_folder_cb, 0, NULL},
388 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
389 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
390 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
391 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
392 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
393 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
394 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
395 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
396 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
397 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
398 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
400 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
401 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
402 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
403 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
404 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
406 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
407 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
408 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
409 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
410 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
411 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
412 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
413 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
414 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
415 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
416 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
417 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
418 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
419 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
420 {N_("/_View/_Code set/_Auto detect"),
421 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
423 #define CODESET_SEPARATOR \
424 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
425 #define CODESET_ACTION(action) \
426 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
428 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
429 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
430 CODESET_ACTION(C_US_ASCII)},
433 {N_("/_View/_Code set/Unicode (_UTF-8)"),
434 CODESET_ACTION(C_UTF_8)},
437 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
438 CODESET_ACTION(C_ISO_8859_1)},
441 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
442 CODESET_ACTION(C_ISO_8859_2)},
444 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
445 CODESET_ACTION(C_ISO_8859_13)},
446 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
447 CODESET_ACTION(C_ISO_8859_4)},
449 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
450 CODESET_ACTION(C_ISO_8859_7)},
452 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
453 CODESET_ACTION(C_ISO_8859_9)},
455 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
456 CODESET_ACTION(C_ISO_8859_5)},
457 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
458 CODESET_ACTION(C_KOI8_R)},
459 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
460 CODESET_ACTION(C_CP1251)},
463 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
464 CODESET_ACTION(C_ISO_2022_JP)},
466 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
467 CODESET_ACTION(C_ISO_2022_JP_2)},
469 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
470 CODESET_ACTION(C_EUC_JP)},
471 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
472 CODESET_ACTION(C_SHIFT_JIS)},
475 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
476 CODESET_ACTION(C_GB2312)},
477 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
478 CODESET_ACTION(C_BIG5)},
479 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
480 CODESET_ACTION(C_EUC_TW)},
481 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
482 CODESET_ACTION(C_ISO_2022_CN)},
484 {N_("/_View/_Code set/Korean (EUC-_KR)"),
485 CODESET_ACTION(C_EUC_KR)},
486 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
487 CODESET_ACTION(C_ISO_2022_KR)},
490 #undef CODESET_SEPARATOR
491 #undef CODESET_ACTION
493 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
494 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
495 {N_("/_Message/Get from _all accounts"),
496 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
497 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
498 {N_("/_Message/Send queued messa_ges"),
499 NULL, send_queue_cb, 0, NULL},
500 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
501 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
502 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
503 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
504 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
505 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
506 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
507 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
508 {N_("/_Message/Forward as a_ttachment"),
509 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
510 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
512 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
513 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
514 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
515 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
516 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
517 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
519 {N_("/_Message/_Mark/Mark as rea_d"),
520 NULL, mark_as_read_cb, 0, NULL},
521 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
522 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
523 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
524 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
525 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
527 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
528 {N_("/_Summary/_Delete duplicated messages"),
529 NULL, delete_duplicated_cb, 0, NULL},
530 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
531 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
532 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
533 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
535 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
536 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
537 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
538 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
539 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
540 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
541 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
542 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
543 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
544 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
545 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
546 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
547 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
548 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
549 {N_("/_Summary/_Sort/Sort by _label"), NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
550 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
551 {N_("/_Summary/_Sort/_Attract by subject"),
552 NULL, attract_by_subject_cb, 0, NULL},
553 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
554 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
555 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
557 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
558 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
559 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
561 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
562 {N_("/_Configuration/_Common preferences..."),
563 NULL, prefs_common_open_cb, 0, NULL},
564 {N_("/_Configuration/_Filter setting..."),
565 NULL, prefs_filter_open_cb, 0, NULL},
566 {N_("/_Configuration/_Scoring ..."),
567 NULL, prefs_scoring_open_cb, 0, NULL},
568 {N_("/_Configuration/_Filtering ..."),
569 NULL, prefs_filtering_open_cb, 0, NULL},
570 {N_("/_Configuration/_Templates ..."),
571 NULL, prefs_templates_open_cb, 0, NULL},
572 {N_("/_Configuration/_Preferences per account..."),
573 NULL, prefs_account_open_cb, 0, NULL},
574 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
575 {N_("/_Configuration/Create _new account..."),
576 NULL, new_account_cb, 0, NULL},
577 {N_("/_Configuration/_Edit accounts..."),
578 NULL, account_edit_open, 0, NULL},
579 {N_("/_Configuration/C_hange current account"),
580 NULL, NULL, 0, "<Branch>"},
582 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
583 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
584 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
585 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
586 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
587 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
590 MainWindow *main_window_create(SeparateType type)
596 GtkWidget *handlebox;
597 GtkWidget *vbox_body;
598 GtkWidget *hbox_stat;
599 GtkWidget *statusbar;
600 GtkWidget *progressbar;
601 GtkWidget *statuslabel;
602 GtkWidget *ac_button;
605 FolderView *folderview;
606 SummaryView *summaryview;
607 MessageView *messageview;
608 GdkColormap *colormap;
611 guint n_menu_entries;
612 GtkItemFactory *ifactory;
617 debug_print(_("Creating main window...\n"));
618 mainwin = g_new0(MainWindow, 1);
621 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
622 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
623 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
624 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
625 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
626 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
627 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
628 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
629 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
630 gtk_widget_realize(window);
632 vbox = gtk_vbox_new(FALSE, 0);
633 gtk_widget_show(vbox);
634 gtk_container_add(GTK_CONTAINER(window), vbox);
637 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
638 menubar = menubar_create(window, mainwin_entries,
639 n_menu_entries, "<Main>", mainwin);
640 gtk_widget_show(menubar);
641 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
643 handlebox = gtk_handle_box_new();
644 gtk_widget_show(handlebox);
645 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
647 main_window_toolbar_create(mainwin, handlebox);
649 /* vbox that contains body */
650 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
651 gtk_widget_show(vbox_body);
652 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
653 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
655 hbox_stat = gtk_hbox_new(FALSE, 2);
656 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
658 statusbar = statusbar_create();
659 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
661 progressbar = gtk_progress_bar_new();
662 gtk_widget_set_usize(progressbar, 120, -1);
663 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
665 statuslabel = gtk_label_new("");
666 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
668 ac_button = gtk_button_new();
669 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
670 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
671 gtk_widget_set_usize(ac_button, -1, 1);
672 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
673 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
674 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
676 ac_label = gtk_label_new("");
677 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
679 gtk_widget_show_all(hbox_stat);
682 mainwin->folderview = folderview = folderview_create();
683 mainwin->summaryview = summaryview = summary_create();
684 mainwin->messageview = messageview = messageview_create();
685 mainwin->headerwin = header_window_create();
686 mainwin->logwin = log_window_create();
688 folderview->mainwin = mainwin;
689 folderview->summaryview = summaryview;
691 summaryview->mainwin = mainwin;
692 summaryview->folderview = folderview;
693 summaryview->messageview = messageview;
694 summaryview->headerwin = mainwin->headerwin;
695 summaryview->window = window;
697 messageview->mainwin = mainwin;
699 mainwin->window = window;
700 mainwin->vbox = vbox;
701 mainwin->menubar = menubar;
702 mainwin->handlebox = handlebox;
703 mainwin->vbox_body = vbox_body;
704 mainwin->hbox_stat = hbox_stat;
705 mainwin->statusbar = statusbar;
706 mainwin->progressbar = progressbar;
707 mainwin->statuslabel = statuslabel;
708 mainwin->ac_button = ac_button;
709 mainwin->ac_label = ac_label;
711 /* set context IDs for status bar */
712 mainwin->mainwin_cid = gtk_statusbar_get_context_id
713 (GTK_STATUSBAR(statusbar), "Main Window");
714 mainwin->folderview_cid = gtk_statusbar_get_context_id
715 (GTK_STATUSBAR(statusbar), "Folder View");
716 mainwin->summaryview_cid = gtk_statusbar_get_context_id
717 (GTK_STATUSBAR(statusbar), "Summary View");
719 /* allocate colors for summary view and folder view */
720 summaryview->color_marked.red = summaryview->color_marked.green = 0;
721 summaryview->color_marked.blue = (guint16)65535;
723 summaryview->color_dim.red = summaryview->color_dim.green =
724 summaryview->color_dim.blue = COLOR_DIM;
726 folderview->color_new.red = (guint16)55000;
727 folderview->color_new.green = folderview->color_new.blue = 15000;
729 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
730 &folderview->color_op);
732 summaryview->color_important.red = 0;
733 summaryview->color_marked.green = 0;
734 summaryview->color_important.blue = (guint16)65535;
736 color[0] = summaryview->color_marked;
737 color[1] = summaryview->color_dim;
738 color[2] = folderview->color_new;
739 color[3] = folderview->color_op;
741 colormap = gdk_window_get_colormap(window->window);
742 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
743 for (i = 0; i < 4; i++) {
744 if (success[i] == FALSE)
745 g_warning(_("MainWindow: color allocation %d failed\n"), i);
748 debug_print(_("done.\n"));
750 main_window_set_widgets(mainwin, type);
753 ifactory = gtk_item_factory_from_widget(menubar);
754 menuitem = gtk_item_factory_get_item
755 (ifactory, "/View/Code set/Auto detect");
756 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
758 switch (prefs_common.toolbar_style) {
760 menuitem = gtk_item_factory_get_item
761 (ifactory, "/View/Toolbar/None");
764 menuitem = gtk_item_factory_get_item
765 (ifactory, "/View/Toolbar/Icon");
768 menuitem = gtk_item_factory_get_item
769 (ifactory, "/View/Toolbar/Text");
772 menuitem = gtk_item_factory_get_item
773 (ifactory, "/View/Toolbar/Icon and text");
775 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
777 gtk_widget_hide(mainwin->hbox_stat);
778 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
779 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
780 prefs_common.show_statusbar);
782 /* set the check of the SEPARATE_xxx menu items. we also need the main window
783 * as a property and pass the action type to the callback */
784 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
786 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
787 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
788 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
789 GUINT_TO_POINTER(SEPARATE_FOLDER));
791 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
793 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
794 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
795 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
796 GUINT_TO_POINTER(SEPARATE_MESSAGE));
799 menu_set_sensitive(ifactory, "/Summary/Thread view",
800 prefs_common.enable_thread ? FALSE : TRUE);
801 menu_set_sensitive(ifactory, "/Summary/Unthread view",
802 prefs_common.enable_thread ? TRUE : FALSE);
804 /*main_window_set_thread_option(mainwin);*/
807 /* set account selection menu */
808 ac_menu = gtk_item_factory_get_widget
809 (ifactory, "/Configuration/Change current account");
810 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
811 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
812 mainwin->ac_menu = ac_menu;
814 main_window_set_toolbar_sensitive(mainwin);
816 /* show main window */
817 gtk_widget_set_uposition(mainwin->window,
818 prefs_common.mainwin_x,
819 prefs_common.mainwin_y);
820 gtk_widget_set_usize(window, prefs_common.mainwin_width,
821 prefs_common.mainwin_height);
822 gtk_widget_show(mainwin->window);
824 /* initialize views */
825 folderview_init(folderview);
826 summary_init(summaryview);
827 messageview_init(messageview);
828 header_window_init(mainwin->headerwin);
829 log_window_init(mainwin->logwin);
831 mainwin->lock_count = 0;
832 mainwin->cursor_count = 0;
835 watch_cursor = gdk_cursor_new(GDK_WATCH);
837 mainwin_list = g_list_append(mainwin_list, mainwin);
842 void main_window_cursor_wait(MainWindow *mainwin)
845 if (mainwin->cursor_count == 0)
846 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
848 mainwin->cursor_count++;
853 void main_window_cursor_normal(MainWindow *mainwin)
855 if (mainwin->cursor_count)
856 mainwin->cursor_count--;
858 if (mainwin->cursor_count == 0)
859 gdk_window_set_cursor(mainwin->window->window, NULL);
864 /* lock / unlock the user-interface */
865 void main_window_lock(MainWindow *mainwin)
867 if (mainwin->lock_count == 0) {
868 gtk_widget_set_sensitive(mainwin->toolbar, FALSE);
869 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
872 mainwin->lock_count++;
874 main_window_set_menu_sensitive(mainwin);
877 void main_window_unlock(MainWindow *mainwin)
879 if (mainwin->lock_count)
880 mainwin->lock_count--;
882 main_window_set_menu_sensitive(mainwin);
884 if (mainwin->lock_count == 0) {
885 gtk_widget_set_sensitive(mainwin->toolbar, TRUE);
886 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
890 void main_window_reflect_prefs_all(void)
895 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
896 mainwin = (MainWindow *)cur->data;
898 main_window_show_cur_account(mainwin);
900 gtk_widget_set_sensitive(mainwin->get_btn, TRUE);
901 gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
903 gtk_widget_set_sensitive(mainwin->get_btn, FALSE);
904 gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
907 if (prefs_common.immediate_exec)
908 gtk_widget_hide(mainwin->exec_btn);
910 gtk_widget_show(mainwin->exec_btn);
912 summary_change_display_item(mainwin->summaryview);
913 summary_redisplay_msg(mainwin->summaryview);
914 headerview_set_visibility(mainwin->messageview->headerview,
915 prefs_common.display_header_pane);
919 void main_window_set_account_menu(GList *account_list)
921 GList *cur, *cur_ac, *cur_item;
924 PrefsAccount *ac_prefs;
926 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
927 mainwin = (MainWindow *)cur->data;
929 /* destroy all previous menu item */
930 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
931 while (cur_item != NULL) {
932 GList *next = cur_item->next;
933 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
937 for (cur_ac = account_list; cur_ac != NULL;
938 cur_ac = cur_ac->next) {
939 ac_prefs = (PrefsAccount *)cur_ac->data;
941 menuitem = gtk_menu_item_new_with_label
942 (ac_prefs->account_name
943 ? ac_prefs->account_name : _("Untitled"));
944 gtk_widget_show(menuitem);
945 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
946 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
947 GTK_SIGNAL_FUNC(account_menu_cb),
953 static void main_window_show_cur_account(MainWindow *mainwin)
958 ac_name = g_strdup(cur_account
959 ? (cur_account->account_name
960 ? cur_account->account_name : _("Untitled"))
964 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
966 buf = g_strdup(PROG_VERSION);
967 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
970 buf = g_strdup_printf(_("Current account: %s"), ac_name);
971 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
972 gtk_widget_queue_resize(mainwin->ac_button);
978 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
980 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
981 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
982 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
984 if (mainwin->type == type) return;
986 /* remove widgets from those containers */
987 gtk_widget_ref(folder_wid);
988 gtk_widget_ref(summary_wid);
989 gtk_widget_ref(message_wid);
991 (GTK_CONTAINER(folder_wid->parent), folder_wid);
993 (GTK_CONTAINER(summary_wid->parent), summary_wid);
995 (GTK_CONTAINER(message_wid->parent), message_wid);
997 /* clean containers */
998 switch (mainwin->type) {
1000 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1002 case SEPARATE_FOLDER:
1003 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1004 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1006 case SEPARATE_MESSAGE:
1007 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1008 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1011 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1012 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1016 gtk_widget_hide(mainwin->window);
1017 main_window_set_widgets(mainwin, type);
1018 gtk_widget_show(mainwin->window);
1020 gtk_widget_unref(folder_wid);
1021 gtk_widget_unref(summary_wid);
1022 gtk_widget_unref(message_wid);
1025 void main_window_get_size(MainWindow *mainwin)
1027 GtkAllocation *allocation;
1029 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1031 prefs_common.summaryview_width = allocation->width;
1033 if (mainwin->summaryview->msg_is_toggled_on)
1034 prefs_common.summaryview_height = allocation->height;
1036 prefs_common.mainview_width = allocation->width;
1038 allocation = &mainwin->window->allocation;
1040 prefs_common.mainview_height = allocation->height;
1041 prefs_common.mainwin_width = allocation->width;
1042 prefs_common.mainwin_height = allocation->height;
1044 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1046 prefs_common.folderview_width = allocation->width;
1047 prefs_common.folderview_height = allocation->height;
1050 void main_window_get_position(MainWindow *mainwin)
1054 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1056 prefs_common.mainview_x = x;
1057 prefs_common.mainview_y = y;
1058 prefs_common.mainwin_x = x;
1059 prefs_common.mainwin_y = y;
1061 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1064 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1069 if (alertpanel(_("Empty trash"),
1070 _("Empty all messages in trash?"),
1071 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1073 manage_window_focus_in(mainwin->window, NULL, NULL);
1076 procmsg_empty_trash();
1078 for (list = folder_get_list(); list != NULL; list = list->next) {
1081 folder = list->data;
1082 if (folder->trash) {
1083 folder_item_scan(folder->trash);
1084 folderview_update_item(folder->trash, TRUE);
1088 if (mainwin->summaryview->folder_item &&
1089 mainwin->summaryview->folder_item->stype == F_TRASH)
1090 gtk_widget_grab_focus(mainwin->folderview->ctree);
1093 void main_window_add_mailbox(MainWindow *mainwin)
1098 path = input_dialog(_("Add mailbox"),
1099 _("Input the location of mailbox.\n"
1100 "If the existing mailbox is specified, it will be\n"
1101 "scanned automatically."),
1104 if (folder_find_from_path(path)) {
1105 alertpanel_error(_("The mailbox `%s' already exists."), path);
1109 if (!strcmp(path, "Mail"))
1110 folder = folder_new(F_MH, _("Mailbox"), path);
1112 folder = folder_new(F_MH, g_basename(path), path);
1115 if (folder->create_tree(folder) < 0) {
1116 alertpanel_error(_("Creation of the mailbox failed.\n"
1117 "Maybe some files already exist, or you don't have the permission to write there."));
1118 folder_destroy(folder);
1123 folder_set_ui_func(folder, scan_tree_func, mainwin);
1124 folder->scan_tree(folder);
1125 folder_set_ui_func(folder, NULL, NULL);
1127 folderview_set(mainwin->folderview);
1130 void main_window_add_mbox(MainWindow *mainwin)
1136 path = input_dialog(_("Add mbox mailbox"),
1137 _("Input the location of mailbox."),
1142 if (folder_find_from_path(path)) {
1143 alertpanel_error(_("The mailbox `%s' already exists."), path);
1149 if (!strcmp(path, "Mail"))
1150 folder = folder_new(F_MBOX, _("Mailbox"), path);
1154 folder = folder_new(F_MBOX, g_basename(path), path);
1157 if (folder->create_tree(folder) < 0) {
1158 alertpanel_error(_("Creation of the mailbox failed."));
1159 folder_destroy(folder);
1165 item = folder_item_new(folder->name, NULL);
1166 item->folder = folder;
1167 folder->node = g_node_new(item);
1169 folder->create_folder(folder, item, "inbox");
1170 folder->create_folder(folder, item, "outbox");
1171 folder->create_folder(folder, item, "queue");
1172 folder->create_folder(folder, item, "draft");
1173 folder->create_folder(folder, item, "trash");
1175 folderview_set(mainwin->folderview);
1178 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1182 if (GTK_CLIST(mainwin->summaryview->ctree)->row_list)
1187 gtk_widget_set_sensitive(mainwin->reply_btn, sensitive);
1188 gtk_widget_set_sensitive(mainwin->replyall_btn, sensitive);
1189 gtk_widget_set_sensitive(mainwin->replysender_btn, sensitive);
1190 gtk_widget_set_sensitive(mainwin->fwd_btn, sensitive);
1191 gtk_widget_set_sensitive(mainwin->exec_btn, sensitive);
1192 gtk_widget_set_sensitive(mainwin->next_btn, sensitive);
1194 if (!mainwin->summaryview->folder_item ||
1195 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1196 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1198 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1203 M_UNLOCKED = 1 << 0,
1204 M_MSG_EXIST = 1 << 1,
1205 M_TARGET_EXIST = 1 << 2,
1206 M_SINGLE_TARGET_EXIST = 1 << 3,
1208 M_ALLOW_REEDIT = 1 << 5
1209 } MenuItemSensitiveCond;
1211 void main_window_set_menu_sensitive(MainWindow *mainwin)
1213 GtkItemFactory *ifactory;
1214 SummarySelection selection;
1215 MenuItemSensitiveCond state = 0;
1219 static const struct {
1221 MenuItemSensitiveCond cond;
1223 {"/File/Add mailbox..." , M_UNLOCKED},
1224 {"/File/Update folder tree" , M_UNLOCKED},
1225 {"/File/Folder" , M_UNLOCKED},
1226 {"/File/Import mbox file..." , M_UNLOCKED},
1227 {"/File/Export to mbox file...", M_UNLOCKED},
1228 {"/File/Empty trash" , M_UNLOCKED},
1229 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1230 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1231 {"/File/Close", M_UNLOCKED},
1232 {"/File/Exit" , M_UNLOCKED},
1234 {"/Message/Get new mail" , M_UNLOCKED},
1235 {"/Message/Get from all accounts", M_UNLOCKED},
1236 {"/Message/Reply" , M_SINGLE_TARGET_EXIST},
1237 {"/Message/Reply to sender" , M_SINGLE_TARGET_EXIST},
1238 {"/Message/Reply to all" , M_SINGLE_TARGET_EXIST},
1239 {"/Message/Forward" , M_SINGLE_TARGET_EXIST},
1240 {"/Message/Forward as attachment", M_SINGLE_TARGET_EXIST},
1241 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1242 {"/Message/Show all header" , M_SINGLE_TARGET_EXIST},
1243 {"/Message/View source" , M_SINGLE_TARGET_EXIST},
1244 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1245 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1246 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1247 {"/Message/Mark" , M_TARGET_EXIST},
1248 {"/Message/Re-edit", M_ALLOW_REEDIT},
1250 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1251 {"/Summary/Filter messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1252 {"/Summary/Execute" , M_MSG_EXIST|M_UNLOCKED},
1253 {"/Summary/Prev message" , M_MSG_EXIST},
1254 {"/Summary/Next message" , M_MSG_EXIST},
1255 {"/Summary/Next unread message", M_MSG_EXIST},
1256 {"/Summary/Sort" , M_MSG_EXIST},
1258 {"/Configuration", M_UNLOCKED},
1263 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1264 selection = summary_get_selection_type(mainwin->summaryview);
1266 if (mainwin->lock_count == 0)
1267 state |= M_UNLOCKED;
1268 if (selection != SUMMARY_NONE)
1269 state |= M_MSG_EXIST;
1270 if (selection == SUMMARY_SELECTED_SINGLE ||
1271 selection == SUMMARY_SELECTED_MULTIPLE)
1272 state |= M_TARGET_EXIST;
1273 if (selection == SUMMARY_SELECTED_SINGLE)
1274 state |= M_SINGLE_TARGET_EXIST;
1275 if (mainwin->summaryview->folder_item &&
1276 mainwin->summaryview->folder_item->folder->type != F_NEWS)
1278 if (selection == SUMMARY_SELECTED_SINGLE &&
1279 (mainwin->summaryview->folder_item &&
1280 mainwin->summaryview->folder_item->stype == F_DRAFT))
1281 state |= M_ALLOW_REEDIT;
1283 for (i = 0; entry[i].entry != NULL; i++) {
1284 sensitive = ((entry[i].cond & state) == entry[i].cond);
1285 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1289 void main_window_popup(MainWindow *mainwin)
1295 gdk_window_get_origin(mainwin->window->window, &x, &y);
1296 sx = gdk_screen_width();
1297 sy = gdk_screen_height();
1298 x %= sx; if (x < 0) x += sx;
1299 y %= sy; if (y < 0) y += sy;
1300 gdk_window_move(mainwin->window->window, x, y);
1301 gdk_window_raise(mainwin->window->window);
1302 gdk_window_show(mainwin->window->window);
1304 debug_print("window position: x = %d, y = %d\n", x, y);
1306 switch (mainwin->type) {
1307 case SEPARATE_FOLDER:
1308 widget = mainwin->win.sep_folder.folderwin;
1309 gdk_window_get_origin(widget->window, &x, &y);
1310 x %= sx; if (x < 0) x += sx;
1311 y %= sy; if (y < 0) y += sy;
1312 gdk_window_move(widget->window, x, y);
1313 gdk_window_raise(widget->window);
1315 case SEPARATE_MESSAGE:
1316 widget = mainwin->win.sep_message.messagewin;
1317 gdk_window_get_origin(widget->window, &x, &y);
1318 x %= sx; if (x < 0) x += sx;
1319 y %= sy; if (y < 0) y += sy;
1320 gdk_window_move(widget->window, x, y);
1321 gdk_window_raise(widget->window);
1324 widget = mainwin->win.sep_both.folderwin;
1325 gdk_window_get_origin(widget->window, &x, &y);
1326 x %= sx; if (x < 0) x += sx;
1327 y %= sy; if (y < 0) y += sy;
1328 gdk_window_move(widget->window, x, y);
1329 gdk_window_raise(widget->window);
1330 widget = mainwin->win.sep_both.messagewin;
1331 gdk_window_get_origin(widget->window, &x, &y);
1332 x %= sx; if (x < 0) x += sx;
1333 y %= sy; if (y < 0) y += sy;
1334 gdk_window_move(widget->window, x, y);
1335 gdk_window_raise(widget->window);
1342 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1344 GtkWidget *folderwin = NULL;
1345 GtkWidget *messagewin = NULL;
1348 GtkWidget *vbox_body = mainwin->vbox_body;
1350 debug_print(_("Setting widgets..."));
1352 /* create separated window(s) if needed */
1353 if (type & SEPARATE_FOLDER) {
1354 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1355 gtk_window_set_policy(GTK_WINDOW(folderwin),
1357 gtk_widget_set_usize(folderwin, -1,
1358 prefs_common.mainview_height);
1359 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1361 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1362 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1365 if (type & SEPARATE_MESSAGE) {
1366 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1367 gtk_window_set_policy(GTK_WINDOW(messagewin),
1369 gtk_widget_set_usize
1370 (messagewin, prefs_common.mainview_width,
1371 prefs_common.mainview_height
1372 - prefs_common.summaryview_height
1373 + DEFAULT_HEADERVIEW_HEIGHT);
1374 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1376 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1377 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1383 hpaned = gtk_hpaned_new();
1384 gtk_widget_show(hpaned);
1385 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1386 gtk_paned_add1(GTK_PANED(hpaned),
1387 GTK_WIDGET_PTR(mainwin->folderview));
1389 vpaned = gtk_vpaned_new();
1390 if (mainwin->summaryview->msg_is_toggled_on) {
1391 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1392 gtk_paned_add1(GTK_PANED(vpaned),
1393 GTK_WIDGET_PTR(mainwin->summaryview));
1395 gtk_paned_add2(GTK_PANED(hpaned),
1396 GTK_WIDGET_PTR(mainwin->summaryview));
1397 gtk_widget_ref(vpaned);
1399 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1400 prefs_common.summaryview_width,
1401 prefs_common.summaryview_height);
1402 gtk_paned_add2(GTK_PANED(vpaned),
1403 GTK_WIDGET_PTR(mainwin->messageview));
1404 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1405 prefs_common.mainview_width, -1);
1406 gtk_widget_set_usize(mainwin->window,
1407 prefs_common.folderview_width +
1408 prefs_common.mainview_width,
1409 prefs_common.mainwin_height);
1410 gtk_widget_show_all(vpaned);
1412 mainwin->win.sep_none.hpaned = hpaned;
1413 mainwin->win.sep_none.vpaned = vpaned;
1415 case SEPARATE_FOLDER:
1416 vpaned = gtk_vpaned_new();
1417 if (mainwin->summaryview->msg_is_toggled_on) {
1418 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1420 gtk_paned_add1(GTK_PANED(vpaned),
1421 GTK_WIDGET_PTR(mainwin->summaryview));
1423 gtk_box_pack_start(GTK_BOX(vbox_body),
1424 GTK_WIDGET_PTR(mainwin->summaryview),
1426 gtk_widget_ref(vpaned);
1428 gtk_paned_add2(GTK_PANED(vpaned),
1429 GTK_WIDGET_PTR(mainwin->messageview));
1430 gtk_widget_show_all(vpaned);
1431 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1432 prefs_common.summaryview_width,
1433 prefs_common.summaryview_height);
1434 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1435 prefs_common.mainview_width, -1);
1436 gtk_widget_set_usize(mainwin->window,
1437 prefs_common.mainview_width,
1438 prefs_common.mainview_height);
1440 gtk_container_add(GTK_CONTAINER(folderwin),
1441 GTK_WIDGET_PTR(mainwin->folderview));
1443 mainwin->win.sep_folder.folderwin = folderwin;
1444 mainwin->win.sep_folder.vpaned = vpaned;
1446 gtk_widget_show_all(folderwin);
1448 case SEPARATE_MESSAGE:
1449 hpaned = gtk_hpaned_new();
1450 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1452 gtk_paned_add1(GTK_PANED(hpaned),
1453 GTK_WIDGET_PTR(mainwin->folderview));
1454 gtk_paned_add2(GTK_PANED(hpaned),
1455 GTK_WIDGET_PTR(mainwin->summaryview));
1456 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1457 prefs_common.summaryview_width,
1458 prefs_common.summaryview_height);
1459 gtk_widget_set_usize(mainwin->window,
1460 prefs_common.folderview_width +
1461 prefs_common.mainview_width,
1462 prefs_common.mainwin_height);
1463 gtk_widget_show_all(hpaned);
1464 gtk_container_add(GTK_CONTAINER(messagewin),
1465 GTK_WIDGET_PTR(mainwin->messageview));
1467 mainwin->win.sep_message.messagewin = messagewin;
1468 mainwin->win.sep_message.hpaned = hpaned;
1470 gtk_widget_show_all(messagewin);
1473 gtk_box_pack_start(GTK_BOX(vbox_body),
1474 GTK_WIDGET_PTR(mainwin->summaryview),
1476 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1477 prefs_common.summaryview_width,
1478 prefs_common.summaryview_height);
1479 gtk_widget_set_usize(mainwin->window,
1480 prefs_common.mainview_width,
1481 prefs_common.mainwin_height);
1482 gtk_container_add(GTK_CONTAINER(folderwin),
1483 GTK_WIDGET_PTR(mainwin->folderview));
1484 gtk_container_add(GTK_CONTAINER(messagewin),
1485 GTK_WIDGET_PTR(mainwin->messageview));
1487 mainwin->win.sep_both.folderwin = folderwin;
1488 mainwin->win.sep_both.messagewin = messagewin;
1490 gtk_widget_show_all(folderwin);
1491 gtk_widget_show_all(messagewin);
1495 mainwin->type = type;
1497 debug_print(_("done.\n"));
1500 #include "pixmaps/stock_mail_receive.xpm"
1501 #include "pixmaps/stock_mail_receive_all.xpm"
1502 #include "pixmaps/stock_mail_compose.xpm"
1503 #include "pixmaps/stock_news_compose.xpm"
1504 #include "pixmaps/stock_mail_reply.xpm"
1505 #include "pixmaps/stock_mail_reply_to_all.xpm"
1506 #include "pixmaps/stock_mail_reply_to_author.xpm"
1507 #include "pixmaps/stock_mail_forward.xpm"
1508 #include "pixmaps/stock_mail_send.xpm"
1509 #include "pixmaps/stock_preferences.xpm"
1510 #include "pixmaps/stock_properties.xpm"
1511 #include "pixmaps/stock_down_arrow.xpm"
1512 #include "pixmaps/stock_close.xpm"
1513 #include "pixmaps/stock_exec.xpm"
1515 #define CREATE_TOOLBAR_ICON(xpm_d) \
1517 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1518 &container->style->white, \
1520 icon_wid = gtk_pixmap_new(icon, mask); \
1523 static void main_window_toolbar_create(MainWindow *mainwin,
1524 GtkWidget *container)
1529 GtkWidget *icon_wid;
1531 GtkWidget *getall_btn;
1532 GtkWidget *compose_mail_btn;
1533 GtkWidget *compose_news_btn;
1534 GtkWidget *compose_mail_btn_plain;
1535 GtkWidget *compose_news_btn_plain;
1536 GtkWidget *reply_btn;
1537 GtkWidget *replyall_btn;
1538 GtkWidget *replysender_btn;
1540 GtkWidget *send_btn;
1542 GtkWidget *prefs_btn;
1543 GtkWidget *account_btn;
1545 GtkWidget *next_btn;
1546 GtkWidget *delete_btn;
1547 GtkWidget *exec_btn;
1548 GtkWidget *compose_type_btn;
1549 GtkWidget *compose_type_arrow;
1550 GtkWidget *compose_box;
1551 GtkWidget *compose_label;
1552 GtkTooltips *tooltips;
1554 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1556 gtk_container_add(GTK_CONTAINER(container), toolbar);
1557 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1558 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1559 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1560 GTK_TOOLBAR_SPACE_LINE);
1562 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1563 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1565 _("Get new mail from current account"),
1567 icon_wid, toolbar_inc_cb, mainwin);
1568 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1569 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1571 _("Get new mail from all accounts"),
1577 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1579 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1580 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1582 _("Send queued message(s)"),
1588 /* to implement Leandro's "combined" compose buttons, we create
1589 * two sets of compose buttons, one for normal (text + icon)
1590 * toolbar, and one for both text-only and icon-only toolbar;
1591 * we switch between those sets. */
1593 /* insert compose mail button widget */
1595 compose_mail_btn = gtk_button_new();
1596 gtk_widget_show(compose_mail_btn);
1597 tooltips = gtk_tooltips_new();
1598 gtk_tooltips_set_tip(tooltips, compose_mail_btn,
1599 _("Compose email message"),
1601 compose_box = gtk_vbox_new(0, 0);
1602 gtk_widget_show(compose_box);
1604 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1605 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1606 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1608 compose_label = gtk_label_new(_("Email"));
1609 gtk_widget_show(compose_label);
1610 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1612 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1613 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1614 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1617 /* insert compose news button widget */
1619 compose_news_btn = gtk_button_new();
1620 gtk_widget_show(compose_news_btn);
1621 tooltips = gtk_tooltips_new();
1622 gtk_tooltips_set_tip(tooltips, compose_news_btn,
1623 _("Compose news article"),
1625 compose_box = gtk_vbox_new(0, 0);
1626 gtk_widget_show(compose_box);
1628 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1629 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1630 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1632 compose_label = gtk_label_new(_("News"));
1633 gtk_widget_show(compose_label);
1634 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1636 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_news_btn), GTK_CAN_FOCUS);
1637 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1638 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1641 /* insert compose btn plain */
1643 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1644 compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1646 _("Compose an email message"),
1649 toolbar_compose_mail_cb,
1652 /* insert compose btn plain */
1654 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1655 compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1657 _("Compose a news message"),
1660 toolbar_compose_news_cb,
1663 /* insert compose button type widget */
1665 compose_type_btn = gtk_button_new();
1666 gtk_widget_show(compose_type_btn);
1668 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1669 gtk_widget_show(compose_type_arrow);
1671 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1673 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1674 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1676 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1679 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1681 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1682 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1684 _("Reply to the message"),
1689 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1690 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1695 toolbar_reply_to_all_cb,
1697 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1698 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1700 _("Reply to sender"),
1703 toolbar_reply_to_sender_cb,
1705 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1706 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1708 _("Forward the message"),
1714 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1716 CREATE_TOOLBAR_ICON(stock_close_xpm);
1717 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1719 _("Delete the message"),
1725 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1726 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1728 _("Execute marked process"),
1734 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1735 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1737 _("Next unread message"),
1740 toolbar_next_unread_cb,
1744 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1746 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1747 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1749 _("Common preference"),
1754 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1755 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1757 _("Account setting"),
1762 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1763 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1767 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1768 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1771 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1772 GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
1775 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
1776 GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
1779 mainwin->toolbar = toolbar;
1780 mainwin->get_btn = get_btn;
1781 mainwin->getall_btn = getall_btn;
1782 mainwin->compose_mail_btn = compose_mail_btn;
1783 mainwin->compose_news_btn = compose_news_btn;
1784 mainwin->compose_mail_btn_plain = compose_mail_btn_plain;
1785 mainwin->compose_news_btn_plain = compose_news_btn_plain;
1786 mainwin->reply_btn = reply_btn;
1787 mainwin->replyall_btn = replyall_btn;
1788 mainwin->replysender_btn = replysender_btn;
1789 mainwin->fwd_btn = fwd_btn;
1790 mainwin->send_btn = send_btn;
1792 mainwin->prefs_btn = prefs_btn;
1793 mainwin->account_btn = account_btn;
1795 mainwin->next_btn = next_btn;
1796 mainwin->delete_btn = delete_btn;
1797 mainwin->exec_btn = exec_btn;
1799 gtk_widget_show_all(toolbar);
1801 /* activate Leandro menu system */
1802 activate_compose_button(mainwin,
1803 prefs_common.toolbar_style,
1804 mainwin->compose_btn_type);
1807 /* callback functions */
1809 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1812 MainWindow *mainwindow = (MainWindow *) data;
1813 GtkWidget *compose_menu, *compose_item;
1815 g_return_if_fail(mainwindow != NULL);
1817 compose_menu = gtk_menu_new();
1819 compose_item = gtk_menu_item_new_with_label(_("Email message"));
1820 gtk_widget_show(compose_item);
1821 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1822 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1823 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1825 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1827 compose_item = gtk_menu_item_new_with_label(_("News article"));
1828 gtk_widget_show(compose_item);
1829 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1830 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1831 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1833 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1835 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1839 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1841 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1842 MainWindow *mainwindow = (MainWindow *) data;
1844 mainwindow->compose_btn_type = compose_type;
1846 activate_compose_button(mainwindow, prefs_common.toolbar_style, mainwindow->compose_btn_type);
1849 static void toolbar_inc_cb (GtkWidget *widget,
1852 MainWindow *mainwin = (MainWindow *)data;
1854 inc_mail_cb(mainwin, 0, NULL);
1857 static void toolbar_inc_all_cb (GtkWidget *widget,
1860 MainWindow *mainwin = (MainWindow *)data;
1862 inc_all_account_mail_cb(mainwin, 0, NULL);
1865 static void toolbar_send_cb (GtkWidget *widget,
1868 MainWindow *mainwin = (MainWindow *)data;
1870 send_queue_cb(mainwin, 0, NULL);
1873 static void toolbar_compose_cb (GtkWidget *widget,
1876 MainWindow *mainwin = (MainWindow *)data;
1878 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1879 compose_cb(mainwin, 0, NULL);
1881 compose_news_cb(mainwin, 0, NULL);
1884 static void toolbar_compose_news_cb (GtkWidget *widget,
1887 MainWindow *mainwin = (MainWindow *)data;
1889 compose_news_cb(mainwin, 0, NULL);
1892 static void toolbar_compose_mail_cb (GtkWidget *widget,
1895 MainWindow *mainwin = (MainWindow *)data;
1897 compose_mail_cb(mainwin, 0, NULL);
1900 static void toolbar_reply_cb (GtkWidget *widget,
1903 MainWindow *mainwin = (MainWindow *)data;
1905 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1908 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1911 MainWindow *mainwin = (MainWindow *)data;
1913 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1916 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1919 MainWindow *mainwin = (MainWindow *)data;
1921 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1924 static void toolbar_forward_cb (GtkWidget *widget,
1927 MainWindow *mainwin = (MainWindow *)data;
1929 if (prefs_common.forward_as_attachment)
1930 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
1932 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1935 static void toolbar_delete_cb (GtkWidget *widget,
1938 MainWindow *mainwin = (MainWindow *)data;
1940 summary_delete(mainwin->summaryview);
1943 static void toolbar_exec_cb (GtkWidget *widget,
1946 MainWindow *mainwin = (MainWindow *)data;
1948 summary_execute(mainwin->summaryview);
1951 static void toolbar_next_unread_cb (GtkWidget *widget,
1954 MainWindow *mainwin = (MainWindow *)data;
1956 next_unread_cb(mainwin, 0, NULL);
1959 static void toolbar_prefs_cb (GtkWidget *widget,
1962 prefs_common_open();
1965 static void toolbar_account_cb (GtkWidget *widget,
1968 MainWindow *mainwin = (MainWindow *)data;
1970 prefs_account_open_cb(mainwin, 0, NULL);
1973 static void toolbar_account_button_pressed(GtkWidget *widget,
1974 GdkEventButton *event,
1977 MainWindow *mainwin = (MainWindow *)data;
1980 if (event->button != 3) return;
1982 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1983 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1986 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1987 menu_button_position, widget,
1988 event->button, event->time);
1991 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1994 MainWindow *mainwin = (MainWindow *)data;
1998 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1999 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2002 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2003 menu_button_position, widget,
2004 event->button, event->time);
2007 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2009 MainWindow *mainwin = (MainWindow *)data;
2012 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2013 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2014 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2017 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2020 app_exit_cb(data, 0, widget);
2025 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2028 main_window_add_mailbox(mainwin);
2031 static void add_mbox_cb(MainWindow *mainwin, guint action,
2034 main_window_add_mbox(mainwin);
2037 static void update_folderview_cb(MainWindow *mainwin, guint action,
2040 summary_show(mainwin->summaryview, NULL, FALSE);
2041 folderview_update_all();
2044 static void new_folder_cb(MainWindow *mainwin, guint action,
2047 folderview_new_folder(mainwin->folderview);
2050 static void rename_folder_cb(MainWindow *mainwin, guint action,
2053 folderview_rename_folder(mainwin->folderview);
2056 static void delete_folder_cb(MainWindow *mainwin, guint action,
2059 folderview_delete_folder(mainwin->folderview);
2062 static void import_mbox_cb(MainWindow *mainwin, guint action,
2065 import_mbox(mainwin->summaryview->folder_item);
2068 static void export_mbox_cb(MainWindow *mainwin, guint action,
2071 export_mbox(mainwin->summaryview->folder_item);
2074 static void empty_trash_cb(MainWindow *mainwin, guint action,
2077 main_window_empty_trash(mainwin, TRUE);
2080 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2082 summary_save_as(mainwin->summaryview);
2085 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2087 summary_print(mainwin->summaryview);
2090 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2092 if (prefs_common.confirm_on_exit) {
2093 if (alertpanel(_("Exit"), _("Exit this program?"),
2094 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2096 manage_window_focus_in(mainwin->window, NULL, NULL);
2099 app_will_exit(widget, mainwin);
2102 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2105 switch (mainwin->type) {
2107 case SEPARATE_MESSAGE:
2109 case SEPARATE_FOLDER:
2110 if (GTK_CHECK_MENU_ITEM(widget)->active)
2111 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2113 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2116 if (GTK_CHECK_MENU_ITEM(widget)->active)
2117 gtk_widget_show(mainwin->win.sep_both.folderwin);
2119 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2124 static void toggle_message_cb(MainWindow *mainwin, guint action,
2127 switch (mainwin->type) {
2129 case SEPARATE_FOLDER:
2131 case SEPARATE_MESSAGE:
2132 if (GTK_CHECK_MENU_ITEM(widget)->active)
2133 gtk_widget_show(mainwin->win.sep_message.messagewin);
2135 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2138 if (GTK_CHECK_MENU_ITEM(widget)->active)
2139 gtk_widget_show(mainwin->win.sep_both.messagewin);
2141 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2146 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2149 activate_compose_button(mainwin, (ToolbarStyle)action,
2150 mainwin->compose_btn_type);
2152 switch ((ToolbarStyle)action) {
2154 gtk_widget_hide(mainwin->handlebox);
2156 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2160 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2164 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2169 if (action != TOOLBAR_NONE) {
2170 gtk_widget_show(mainwin->handlebox);
2171 gtk_widget_queue_resize(mainwin->handlebox);
2174 mainwin->toolbar_style = (ToolbarStyle)action;
2175 prefs_common.toolbar_style = (ToolbarStyle)action;
2178 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2181 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2182 gtk_widget_show(mainwin->hbox_stat);
2183 prefs_common.show_statusbar = TRUE;
2185 gtk_widget_hide(mainwin->hbox_stat);
2186 prefs_common.show_statusbar = FALSE;
2190 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2193 MainWindow *mainwin;
2196 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2197 g_return_if_fail(mainwin != NULL);
2199 type = mainwin->type ^ action;
2200 main_window_separation_change(mainwin, type);
2202 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2203 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2206 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2209 addressbook_open(NULL);
2212 static void log_window_show_cb(MainWindow *mainwin, guint action,
2215 log_window_show(mainwin->logwin);
2218 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2223 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2226 inc_all_account_mail(mainwin);
2229 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2233 if (procmsg_send_queue() < 0)
2234 alertpanel_error(_("Sending queued message failed."));
2236 statusbar_pop_all();
2238 for (list = folder_get_list(); list != NULL; list = list->next) {
2241 folder = list->data;
2242 if (folder->queue) {
2243 folder_item_scan(folder->queue);
2244 folderview_update_item(folder->queue, TRUE);
2249 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2251 if (mainwin->summaryview->folder_item) {
2252 if (mainwin->summaryview->folder_item->folder->account != NULL
2253 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2254 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2256 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2262 static void compose_mail_cb(MainWindow *mainwin, guint action,
2269 if (mainwin->summaryview->folder_item) {
2270 ac = mainwin->summaryview->folder_item->folder->account;
2271 if (ac && ac->protocol != A_NNTP) {
2272 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2277 if(cur_account && (cur_account->protocol != A_NNTP)) {
2278 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2282 list = account_get_list();
2283 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2284 ac = (PrefsAccount *) cur->data;
2285 if (ac->protocol != A_NNTP) {
2286 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2292 static void compose_news_cb(MainWindow *mainwin, guint action,
2295 PrefsAccount * ac = NULL;
2299 if (mainwin->summaryview->folder_item) {
2300 ac = mainwin->summaryview->folder_item->folder->account;
2301 if (ac && ac->protocol == A_NNTP) {
2302 compose_new_with_recipient
2303 (ac, mainwin->summaryview->folder_item->path);
2308 list = account_get_list();
2309 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2310 ac = (PrefsAccount *) cur->data;
2311 if (ac->protocol == A_NNTP) {
2318 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2320 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2323 msginfo = gtk_ctree_node_get_row_data
2324 (GTK_CTREE(mainwin->summaryview->ctree),
2325 mainwin->summaryview->selected);
2327 if (!msginfo) return;
2331 compose_reply(msginfo, prefs_common.reply_with_quote,
2334 case COMPOSE_REPLY_TO_SENDER:
2335 compose_reply(msginfo, prefs_common.reply_with_quote,
2338 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2339 compose_followup_and_reply_to(msginfo,
2340 prefs_common.reply_with_quote,
2343 case COMPOSE_REPLY_TO_ALL:
2344 compose_reply(msginfo, prefs_common.reply_with_quote,
2347 case COMPOSE_FORWARD:
2349 compose_forward(NULL, msginfo, FALSE);
2352 /* if (sel->next) FALL_THROUGH */
2353 case COMPOSE_FORWARD_AS_ATTACH:
2355 GSList *msginfo_list = NULL;
2356 for ( ; sel != NULL; sel = sel->next)
2357 msginfo_list = g_slist_append(msginfo_list,
2358 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2359 GTK_CTREE_NODE(sel->data)));
2360 compose_forward_multiple(NULL, msginfo_list);
2361 g_slist_free(msginfo_list);
2365 g_warning("reply_cb(): invalid action type: %d\n", action);
2368 summary_set_marks_selected(mainwin->summaryview);
2371 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2373 summary_move_to(mainwin->summaryview);
2376 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2378 summary_copy_to(mainwin->summaryview);
2381 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2383 summary_delete(mainwin->summaryview);
2386 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2388 summary_open_msg(mainwin->summaryview);
2391 static void view_source_cb(MainWindow *mainwin, guint action,
2394 summary_view_source(mainwin->summaryview);
2397 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2399 summary_reedit(mainwin->summaryview);
2402 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2404 summary_mark(mainwin->summaryview);
2407 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2409 summary_unmark(mainwin->summaryview);
2412 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2415 summary_mark_as_unread(mainwin->summaryview);
2418 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2421 summary_mark_as_read(mainwin->summaryview);
2424 static void set_charset_cb(MainWindow *mainwin, guint action,
2429 str = conv_get_charset_str((CharSet)action);
2430 g_free(prefs_common.force_charset);
2431 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2433 summary_redisplay_msg(mainwin->summaryview);
2435 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2438 /*void main_window_set_thread_option(MainWindow *mainwin)
2440 GtkItemFactory *ifactory;
2441 gboolean no_item = FALSE;
2443 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2445 if (mainwin->summaryview == NULL)
2447 else if (mainwin->summaryview->folder_item == NULL)
2451 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2452 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2455 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2456 menu_set_sensitive(ifactory,
2457 "/Summary/Thread view", FALSE);
2458 menu_set_sensitive(ifactory,
2459 "/Summary/Unthread view", TRUE);
2460 summary_thread_build(mainwin->summaryview, TRUE);
2463 menu_set_sensitive(ifactory,
2464 "/Summary/Thread view", TRUE);
2465 menu_set_sensitive(ifactory,
2466 "/Summary/Unthread view", FALSE);
2467 summary_unthread(mainwin->summaryview);
2469 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2473 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2475 /*mainwin->summaryview->folder_item->prefs->enable_thread =
2476 !mainwin->summaryview->folder_item->prefs->enable_thread;
2477 main_window_set_thread_option(mainwin);
2480 GtkItemFactory *ifactory;
2482 ifactory = gtk_item_factory_from_widget(widget);
2485 summary_thread_build(mainwin->summaryview, FALSE);
2486 prefs_common.enable_thread = TRUE;
2487 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2488 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2490 summary_unthread(mainwin->summaryview);
2491 prefs_common.enable_thread = FALSE;
2492 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2493 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2497 static void set_display_item_cb(MainWindow *mainwin, guint action,
2500 prefs_summary_display_item_set();
2503 static void sort_summary_cb(MainWindow *mainwin, guint action,
2506 summary_sort(mainwin->summaryview, (SummarySortType)action);
2509 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2512 summary_attract_by_subject(mainwin->summaryview);
2515 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2518 summary_delete_duplicated(mainwin->summaryview);
2521 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2523 summary_filter(mainwin->summaryview);
2526 static void execute_summary_cb(MainWindow *mainwin, guint action,
2529 summary_execute(mainwin->summaryview);
2532 static void update_summary_cb(MainWindow *mainwin, guint action,
2536 FolderView *folderview = mainwin->folderview;
2538 if (!mainwin->summaryview->folder_item) return;
2539 if (!folderview->opened) return;
2541 folder_update_op_count();
2543 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2544 folderview->opened);
2547 summary_show(mainwin->summaryview, fitem, TRUE);
2550 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2552 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2555 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2557 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2560 static void next_unread_cb(MainWindow *mainwin, guint action,
2563 summary_select_next_unread(mainwin->summaryview);
2566 static void next_marked_cb(MainWindow *mainwin, guint action,
2569 summary_select_next_marked(mainwin->summaryview);
2572 static void prev_marked_cb(MainWindow *mainwin, guint action,
2575 summary_select_prev_marked(mainwin->summaryview);
2578 static void goto_folder_cb(MainWindow *mainwin, guint action,
2581 FolderItem *to_folder;
2583 to_folder = foldersel_folder_sel(NULL, NULL);
2586 folderview_select(mainwin->folderview, to_folder);
2589 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2591 messageview_copy_clipboard(mainwin->messageview);
2594 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2596 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2597 summary_select_all(mainwin->summaryview);
2598 else if (mainwin->summaryview->msg_is_toggled_on &&
2599 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2600 messageview_select_all(mainwin->messageview);
2603 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2606 prefs_common_open();
2609 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2612 prefs_filter_open();
2615 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2618 prefs_scoring_open(NULL);
2621 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2624 prefs_filtering_open();
2627 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2631 new_account_cb(mainwin, 0, widget);
2633 gboolean prev_default = cur_account->is_default;
2635 prefs_account_open(cur_account);
2636 if (!prev_default && cur_account->is_default)
2637 account_set_as_default(cur_account);
2638 account_save_config_all();
2640 main_window_reflect_prefs_all();
2644 static void new_account_cb(MainWindow *mainwin, guint action,
2647 account_edit_open();
2648 if (!compose_get_compose_list()) account_add();
2651 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2653 cur_account = (PrefsAccount *)data;
2654 main_window_reflect_prefs_all();
2657 static void manual_open_cb(MainWindow *mainwin, guint action,
2660 manual_open((ManualLang)action);
2663 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2665 MainWindow *mainwin = (MainWindow *)data;
2669 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2670 LOCAL_FOLDER(folder)->rootpath,
2674 str = g_strdup_printf(_("Scanning folder %s ..."),
2675 LOCAL_FOLDER(folder)->rootpath);
2677 STATUSBAR_PUSH(mainwin, str);
2678 STATUSBAR_POP(mainwin);
2682 static void activate_compose_button (MainWindow *mainwin,
2684 ComposeButtonType type)
2686 if (style == TOOLBAR_NONE)
2689 if (style == TOOLBAR_BOTH) {
2690 gtk_widget_hide(mainwin->compose_mail_btn_plain);
2691 gtk_widget_hide(mainwin->compose_news_btn_plain);
2692 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2693 : mainwin->compose_news_btn);
2694 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2695 : mainwin->compose_mail_btn);
2696 mainwin->compose_btn_type = type;
2699 gtk_widget_hide(mainwin->compose_news_btn);
2700 gtk_widget_hide(mainwin->compose_mail_btn);
2701 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn_plain
2702 : mainwin->compose_news_btn_plain);
2703 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn_plain
2704 : mainwin->compose_mail_btn_plain);
2705 mainwin->compose_btn_type = type;
2709 static void prefs_templates_open_cb(MainWindow *mainwin, guint action,
2712 prefs_templates_open();