2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gtk/gtkmain.h>
24 #include <gtk/gtkwindow.h>
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtksignal.h>
27 #include <gtk/gtkvbox.h>
28 #include <gtk/gtkcontainer.h>
29 #include <gtk/gtkstatusbar.h>
30 #include <gtk/gtkhpaned.h>
31 #include <gtk/gtkvpaned.h>
32 #include <gtk/gtkcheckmenuitem.h>
33 #include <gtk/gtkitemfactory.h>
34 #include <gtk/gtkeditable.h>
35 #include <gtk/gtkmenu.h>
36 #include <gtk/gtkmenuitem.h>
37 #include <gtk/gtkhandlebox.h>
38 #include <gtk/gtktoolbar.h>
39 #include <gtk/gtkbutton.h>
44 #include "mainwindow.h"
45 #include "folderview.h"
46 #include "foldersel.h"
47 #include "summaryview.h"
48 #include "summary_search.h"
49 #include "messageview.h"
50 #include "headerview.h"
58 #include "prefs_common.h"
59 #include "prefs_filter.h"
60 #include "prefs_filtering.h"
61 #include "prefs_scoring.h"
62 #include "prefs_account.h"
63 #include "prefs_folder_item.h"
65 #include "addressbook.h"
66 #include "headerwindow.h"
67 #include "logwindow.h"
68 #include "manage_window.h"
69 #include "alertpanel.h"
70 #include "statusbar.h"
71 #include "inputdialog.h"
78 #define AC_LABEL_WIDTH 240
80 #define STATUSBAR_PUSH(mainwin, str) \
82 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
83 mainwin->mainwin_cid, str); \
84 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
87 #define STATUSBAR_POP(mainwin) \
89 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
90 mainwin->mainwin_cid); \
93 /* list of all instantiated MainWindow */
94 static GList *mainwin_list = NULL;
96 static GdkCursor *watch_cursor;
98 static void main_window_show_cur_account (MainWindow *mainwin);
100 static void main_window_set_widgets (MainWindow *mainwin,
102 static void main_window_toolbar_create (MainWindow *mainwin,
103 GtkWidget *container);
105 /* callback functions */
106 static void toolbar_inc_cb (GtkWidget *widget,
108 static void toolbar_inc_all_cb (GtkWidget *widget,
110 static void toolbar_send_cb (GtkWidget *widget,
113 static void toolbar_compose_cb (GtkWidget *widget,
115 static void toolbar_compose_news_cb (GtkWidget *widget,
117 static void toolbar_compose_mail_cb (GtkWidget *widget,
119 static void toolbar_reply_cb (GtkWidget *widget,
121 static void toolbar_reply_to_all_cb (GtkWidget *widget,
123 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
125 static void toolbar_forward_cb (GtkWidget *widget,
128 static void toolbar_delete_cb (GtkWidget *widget,
130 static void toolbar_exec_cb (GtkWidget *widget,
133 static void toolbar_next_unread_cb (GtkWidget *widget,
136 static void toolbar_prefs_cb (GtkWidget *widget,
138 static void toolbar_account_cb (GtkWidget *widget,
141 static void toolbar_account_button_pressed (GtkWidget *widget,
142 GdkEventButton *event,
144 static void ac_label_button_pressed (GtkWidget *widget,
145 GdkEventButton *event,
148 static gint main_window_close_cb (GtkWidget *widget,
152 static void add_mailbox_cb (MainWindow *mainwin,
155 static void add_mbox_cb (MainWindow *mainwin,
158 static void update_folderview_cb (MainWindow *mainwin,
161 static void new_folder_cb (MainWindow *mainwin,
164 static void rename_folder_cb (MainWindow *mainwin,
167 static void delete_folder_cb (MainWindow *mainwin,
170 static void import_mbox_cb (MainWindow *mainwin,
173 static void export_mbox_cb (MainWindow *mainwin,
176 static void empty_trash_cb (MainWindow *mainwin,
180 static void save_as_cb (MainWindow *mainwin,
183 static void print_cb (MainWindow *mainwin,
186 static void app_exit_cb (MainWindow *mainwin,
190 static void toggle_folder_cb (MainWindow *mainwin,
193 static void toggle_message_cb (MainWindow *mainwin,
196 static void toggle_toolbar_cb (MainWindow *mainwin,
199 static void toggle_statusbar_cb (MainWindow *mainwin,
202 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action);
204 static void addressbook_open_cb (MainWindow *mainwin,
207 static void log_window_show_cb (MainWindow *mainwin,
211 static void inc_mail_cb (MainWindow *mainwin,
214 static void inc_all_account_mail_cb (MainWindow *mainwin,
218 static void send_queue_cb (MainWindow *mainwin,
222 static void compose_cb (MainWindow *mainwin,
225 static void compose_mail_cb(MainWindow *mainwin, guint action,
227 static void compose_news_cb(MainWindow *mainwin, guint action,
229 static void reply_cb (MainWindow *mainwin,
233 static void open_msg_cb (MainWindow *mainwin,
237 static void view_source_cb (MainWindow *mainwin,
241 static void reedit_cb (MainWindow *mainwin,
245 static void move_to_cb (MainWindow *mainwin,
248 static void copy_to_cb (MainWindow *mainwin,
251 static void delete_cb (MainWindow *mainwin,
255 static void mark_cb (MainWindow *mainwin,
258 static void unmark_cb (MainWindow *mainwin,
262 static void mark_as_unread_cb (MainWindow *mainwin,
265 static void mark_as_read_cb (MainWindow *mainwin,
269 static void set_charset_cb (MainWindow *mainwin,
273 static void thread_cb (MainWindow *mainwin,
276 static void set_display_item_cb (MainWindow *mainwin,
279 static void sort_summary_cb (MainWindow *mainwin,
282 static void attract_by_subject_cb(MainWindow *mainwin,
286 static void delete_duplicated_cb (MainWindow *mainwin,
289 static void filter_cb (MainWindow *mainwin,
292 static void execute_summary_cb (MainWindow *mainwin,
295 static void update_summary_cb (MainWindow *mainwin,
299 static void prev_cb (MainWindow *mainwin,
302 static void next_cb (MainWindow *mainwin,
306 static void next_unread_cb (MainWindow *mainwin,
310 static void next_marked_cb (MainWindow *mainwin,
314 static void prev_marked_cb (MainWindow *mainwin,
318 static void goto_folder_cb (MainWindow *mainwin,
322 static void copy_cb (MainWindow *mainwin,
325 static void allsel_cb (MainWindow *mainwin,
329 static void prefs_common_open_cb (MainWindow *mainwin,
332 static void prefs_filter_open_cb (MainWindow *mainwin,
335 static void prefs_scoring_open_cb (MainWindow *mainwin,
338 static void prefs_filtering_open_cb (MainWindow *mainwin,
341 static void prefs_account_open_cb(MainWindow *mainwin,
344 static void new_account_cb (MainWindow *mainwin,
348 static void account_menu_cb (GtkMenuItem *menuitem,
351 static void manual_open_cb (MainWindow *mainwin,
355 static void scan_tree_func (Folder *folder,
359 #define SEPARATE_ACTION 667
361 static GtkItemFactoryEntry mainwin_entries[] =
363 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
364 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
365 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
366 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
367 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
368 {N_("/_File/_Folder/Create _new folder..."),
369 NULL, new_folder_cb, 0, NULL},
370 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
371 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
372 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
373 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
374 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
375 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
376 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
377 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
378 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
379 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
380 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
382 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
383 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
384 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
385 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
386 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
388 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
389 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
390 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
391 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
392 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
393 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
394 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
395 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
396 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
397 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
398 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
399 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
400 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
401 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
402 {N_("/_View/_Code set/_Auto detect"),
403 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
405 #define CODESET_SEPARATOR \
406 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
407 #define CODESET_ACTION(action) \
408 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
410 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
411 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
412 CODESET_ACTION(C_US_ASCII)},
415 {N_("/_View/_Code set/Unicode (_UTF-8)"),
416 CODESET_ACTION(C_UTF_8)},
419 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
420 CODESET_ACTION(C_ISO_8859_1)},
423 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
424 CODESET_ACTION(C_ISO_8859_2)},
426 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
427 CODESET_ACTION(C_ISO_8859_13)},
428 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
429 CODESET_ACTION(C_ISO_8859_4)},
431 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
432 CODESET_ACTION(C_ISO_8859_7)},
434 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
435 CODESET_ACTION(C_ISO_8859_9)},
437 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
438 CODESET_ACTION(C_ISO_8859_5)},
439 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
440 CODESET_ACTION(C_KOI8_R)},
441 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
442 CODESET_ACTION(C_CP1251)},
445 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
446 CODESET_ACTION(C_ISO_2022_JP)},
448 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
449 CODESET_ACTION(C_ISO_2022_JP_2)},
451 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
452 CODESET_ACTION(C_EUC_JP)},
453 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
454 CODESET_ACTION(C_SHIFT_JIS)},
457 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
458 CODESET_ACTION(C_GB2312)},
459 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
460 CODESET_ACTION(C_BIG5)},
461 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
462 CODESET_ACTION(C_EUC_TW)},
463 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
464 CODESET_ACTION(C_ISO_2022_CN)},
466 {N_("/_View/_Code set/Korean (EUC-_KR)"),
467 CODESET_ACTION(C_EUC_KR)},
468 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
469 CODESET_ACTION(C_ISO_2022_KR)},
472 #undef CODESET_SEPARATOR
473 #undef CODESET_ACTION
475 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
476 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
477 {N_("/_Message/Get from _all accounts"),
478 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
479 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
480 {N_("/_Message/Send queued messa_ges"),
481 NULL, send_queue_cb, 0, NULL},
482 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
483 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
484 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
485 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
486 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
487 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
488 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
489 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
490 {N_("/_Message/Forward as a_ttachment"),
491 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
492 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
493 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
494 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
495 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
496 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
497 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
498 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
499 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
500 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
501 {N_("/_Message/_Mark/Mark as rea_d"),
502 NULL, mark_as_read_cb, 0, NULL},
503 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
504 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
505 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
506 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
507 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
509 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
510 {N_("/_Summary/_Delete duplicated messages"),
511 NULL, delete_duplicated_cb, 0, NULL},
512 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
513 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
514 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
515 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
516 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
517 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
518 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
519 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
520 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
521 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
522 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
523 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
525 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
526 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
527 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
528 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
529 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
530 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
531 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
532 {N_("/_Summary/_Sort/_Attract by subject"),
533 NULL, attract_by_subject_cb, 0, NULL},
534 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
535 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
536 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
538 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
539 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
540 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
542 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
543 {N_("/_Configuration/_Common preferences..."),
544 NULL, prefs_common_open_cb, 0, NULL},
545 {N_("/_Configuration/_Filter setting..."),
546 NULL, prefs_filter_open_cb, 0, NULL},
547 {N_("/_Configuration/_Scoring ..."),
548 NULL, prefs_scoring_open_cb, 0, NULL},
549 {N_("/_Configuration/_Filtering ..."),
550 NULL, prefs_filtering_open_cb, 0, NULL},
551 {N_("/_Configuration/_Preferences per account..."),
552 NULL, prefs_account_open_cb, 0, NULL},
553 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
554 {N_("/_Configuration/Create _new account..."),
555 NULL, new_account_cb, 0, NULL},
556 {N_("/_Configuration/_Edit accounts..."),
557 NULL, account_edit_open, 0, NULL},
558 {N_("/_Configuration/C_hange current account"),
559 NULL, NULL, 0, "<Branch>"},
561 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
562 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
563 {N_("/_Help/_Manual/_English"), NULL, NULL, MANUAL_LANG_EN, NULL},
564 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
565 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
569 MainWindow *main_window_create(SeparateType type)
575 GtkWidget *handlebox;
576 GtkWidget *vbox_body;
577 GtkWidget *hbox_stat;
578 GtkWidget *statusbar;
579 GtkWidget *ac_button;
582 FolderView *folderview;
583 SummaryView *summaryview;
584 MessageView *messageview;
585 GdkColormap *colormap;
588 guint n_menu_entries;
589 GtkItemFactory *ifactory;
594 debug_print(_("Creating main window...\n"));
595 mainwin = g_new0(MainWindow, 1);
598 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
599 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
600 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
601 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
602 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
603 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
604 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
605 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
606 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
607 gtk_widget_realize(window);
609 vbox = gtk_vbox_new(FALSE, 0);
610 gtk_widget_show(vbox);
611 gtk_container_add(GTK_CONTAINER(window), vbox);
614 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
615 menubar = menubar_create(window, mainwin_entries,
616 n_menu_entries, "<Main>", mainwin);
617 gtk_widget_show(menubar);
618 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
620 handlebox = gtk_handle_box_new();
621 gtk_widget_show(handlebox);
622 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
624 main_window_toolbar_create(mainwin, handlebox);
626 /* vbox that contains body */
627 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
628 gtk_widget_show(vbox_body);
629 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
630 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
632 hbox_stat = gtk_hbox_new(FALSE, 2);
633 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
635 statusbar = statusbar_create();
636 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
638 ac_button = gtk_button_new();
639 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
640 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
641 gtk_widget_set_usize(ac_button, -1, 1);
642 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
643 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
644 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
646 ac_label = gtk_label_new("");
647 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
649 gtk_widget_show_all(hbox_stat);
652 mainwin->folderview = folderview = folderview_create();
653 mainwin->summaryview = summaryview = summary_create();
654 mainwin->messageview = messageview = messageview_create();
655 mainwin->headerwin = header_window_create();
656 mainwin->logwin = log_window_create();
658 folderview->mainwin = mainwin;
659 folderview->summaryview = summaryview;
661 summaryview->mainwin = mainwin;
662 summaryview->folderview = folderview;
663 summaryview->messageview = messageview;
664 summaryview->headerwin = mainwin->headerwin;
665 summaryview->window = window;
667 messageview->mainwin = mainwin;
669 mainwin->window = window;
670 mainwin->vbox = vbox;
671 mainwin->menubar = menubar;
672 mainwin->handlebox = handlebox;
673 mainwin->vbox_body = vbox_body;
674 mainwin->hbox_stat = hbox_stat;
675 mainwin->statusbar = statusbar;
676 mainwin->ac_button = ac_button;
677 mainwin->ac_label = ac_label;
679 /* set context IDs for status bar */
680 mainwin->mainwin_cid = gtk_statusbar_get_context_id
681 (GTK_STATUSBAR(statusbar), "Main Window");
682 mainwin->folderview_cid = gtk_statusbar_get_context_id
683 (GTK_STATUSBAR(statusbar), "Folder View");
684 mainwin->summaryview_cid = gtk_statusbar_get_context_id
685 (GTK_STATUSBAR(statusbar), "Summary View");
687 /* allocate colors for summary view and folder view */
688 summaryview->color_marked.red = summaryview->color_marked.green = 0;
689 summaryview->color_marked.blue = (guint16)65535;
691 summaryview->color_dim.red = summaryview->color_dim.green =
692 summaryview->color_dim.blue = COLOR_DIM;
694 summaryview->color_normal.red = summaryview->color_normal.green =
695 summaryview->color_normal.blue = 0;
697 folderview->color_new.red = (guint16)55000;
698 folderview->color_new.green = folderview->color_new.blue = 15000;
700 folderview->color_normal.red = folderview->color_normal.green =
701 folderview->color_normal.blue = 0;
703 summaryview->color_important.red = 0;
704 summaryview->color_marked.green = 0;
705 summaryview->color_important.blue = (guint16)65535;
707 color[0] = summaryview->color_marked;
708 color[1] = summaryview->color_dim;
709 color[2] = summaryview->color_normal;
710 color[3] = folderview->color_new;
711 color[4] = folderview->color_normal;
713 colormap = gdk_window_get_colormap(window->window);
714 gdk_colormap_alloc_colors(colormap, color, 5, FALSE, TRUE, success);
715 for (i = 0; i < 5; i++) {
716 if (success[i] == FALSE)
717 g_warning(_("MainWindow: color allocation %d failed\n"), i);
720 debug_print(_("done.\n"));
722 main_window_set_widgets(mainwin, type);
725 ifactory = gtk_item_factory_from_widget(menubar);
726 menuitem = gtk_item_factory_get_item
727 (ifactory, "/View/Code set/Auto detect");
728 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
730 switch (prefs_common.toolbar_style) {
732 menuitem = gtk_item_factory_get_item
733 (ifactory, "/View/Toolbar/None");
736 menuitem = gtk_item_factory_get_item
737 (ifactory, "/View/Toolbar/Icon");
740 menuitem = gtk_item_factory_get_item
741 (ifactory, "/View/Toolbar/Text");
744 menuitem = gtk_item_factory_get_item
745 (ifactory, "/View/Toolbar/Icon and text");
747 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
749 gtk_widget_hide(mainwin->hbox_stat);
750 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
751 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
752 prefs_common.show_statusbar);
754 /* set the check of the SEPARATE_xxx menu items. we also need the main window
755 * as a property and pass the action type to the callback */
756 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
758 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
759 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
760 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
761 GUINT_TO_POINTER(SEPARATE_FOLDER));
763 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
765 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
766 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
767 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
768 GUINT_TO_POINTER(SEPARATE_MESSAGE));
771 menu_set_sensitive(ifactory, "/Summary/Thread view",
772 prefs_common.enable_thread ? FALSE : TRUE);
773 menu_set_sensitive(ifactory, "/Summary/Unthread view",
774 prefs_common.enable_thread ? TRUE : FALSE);
776 main_window_set_thread_option(mainwin);
778 menu_set_sensitive(ifactory, "/Help/Manual/English", FALSE);
780 /* set account selection menu */
781 ac_menu = gtk_item_factory_get_widget
782 (ifactory, "/Configuration/Change current account");
783 mainwin->ac_menu = ac_menu;
785 main_window_set_toolbar_sensitive(mainwin, FALSE);
787 /* show main window */
788 gtk_widget_set_uposition(mainwin->window,
789 prefs_common.mainwin_x,
790 prefs_common.mainwin_y);
791 gtk_widget_set_usize(window, prefs_common.mainwin_width,
792 prefs_common.mainwin_height);
793 gtk_widget_show(mainwin->window);
795 /* initialize views */
796 folderview_init(folderview);
797 summary_init(summaryview);
798 messageview_init(messageview);
799 header_window_init(mainwin->headerwin);
800 log_window_init(mainwin->logwin);
802 mainwin->cursor_count = 0;
805 watch_cursor = gdk_cursor_new(GDK_WATCH);
807 mainwin_list = g_list_append(mainwin_list, mainwin);
812 void main_window_cursor_wait(MainWindow *mainwin)
814 if (mainwin->cursor_count == 0)
815 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
817 mainwin->cursor_count++;
822 void main_window_cursor_normal(MainWindow *mainwin)
824 if (mainwin->cursor_count)
825 mainwin->cursor_count--;
827 if (mainwin->cursor_count == 0)
828 gdk_window_set_cursor(mainwin->window->window, NULL);
833 void main_window_reflect_prefs_all(void)
838 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
839 mainwin = (MainWindow *)cur->data;
841 main_window_show_cur_account(mainwin);
843 gtk_widget_set_sensitive(mainwin->get_btn, TRUE);
844 gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
846 gtk_widget_set_sensitive(mainwin->get_btn, FALSE);
847 gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
850 if (prefs_common.immediate_exec)
851 gtk_widget_hide(mainwin->exec_btn);
853 gtk_widget_show(mainwin->exec_btn);
855 summary_change_display_item(mainwin->summaryview);
856 summary_redisplay_msg(mainwin->summaryview);
857 headerview_set_visibility(mainwin->messageview->headerview,
858 prefs_common.display_header_pane);
862 void main_window_set_account_menu(GList *account_list)
864 GList *cur, *cur_ac, *cur_item;
867 PrefsAccount *ac_prefs;
869 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
870 mainwin = (MainWindow *)cur->data;
872 /* destroy all previous menu item */
873 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
874 while (cur_item != NULL) {
875 GList *next = cur_item->next;
876 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
880 for (cur_ac = account_list; cur_ac != NULL;
881 cur_ac = cur_ac->next) {
882 ac_prefs = (PrefsAccount *)cur_ac->data;
884 menuitem = gtk_menu_item_new_with_label
885 (ac_prefs->account_name
886 ? ac_prefs->account_name : _("Untitled"));
887 gtk_widget_show(menuitem);
888 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
889 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
890 GTK_SIGNAL_FUNC(account_menu_cb),
896 static void main_window_show_cur_account(MainWindow *mainwin)
901 ac_name = g_strdup(cur_account
902 ? (cur_account->account_name
903 ? cur_account->account_name : _("Untitled"))
907 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
909 buf = g_strdup(PROG_VERSION);
910 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
913 buf = g_strdup_printf(_("Current account: %s"), ac_name);
914 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
915 gtk_widget_queue_resize(mainwin->ac_button);
921 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
923 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
924 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
925 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
927 if (mainwin->type == type) return;
929 /* remove widgets from those containers */
930 gtk_widget_ref(folder_wid);
931 gtk_widget_ref(summary_wid);
932 gtk_widget_ref(message_wid);
934 (GTK_CONTAINER(folder_wid->parent), folder_wid);
936 (GTK_CONTAINER(summary_wid->parent), summary_wid);
938 (GTK_CONTAINER(message_wid->parent), message_wid);
940 /* clean containers */
941 switch (mainwin->type) {
943 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
945 case SEPARATE_FOLDER:
946 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
947 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
949 case SEPARATE_MESSAGE:
950 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
951 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
954 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
955 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
959 gtk_widget_hide(mainwin->window);
960 main_window_set_widgets(mainwin, type);
961 gtk_widget_show(mainwin->window);
963 gtk_widget_unref(folder_wid);
964 gtk_widget_unref(summary_wid);
965 gtk_widget_unref(message_wid);
968 void main_window_get_size(MainWindow *mainwin)
970 GtkAllocation *allocation;
972 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
974 prefs_common.summaryview_width = allocation->width;
976 if (mainwin->summaryview->msg_is_toggled_on)
977 prefs_common.summaryview_height = allocation->height;
979 prefs_common.mainview_width = allocation->width;
981 allocation = &mainwin->window->allocation;
983 prefs_common.mainview_height = allocation->height;
984 prefs_common.mainwin_width = allocation->width;
985 prefs_common.mainwin_height = allocation->height;
987 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
989 prefs_common.folderview_width = allocation->width;
990 prefs_common.folderview_height = allocation->height;
993 void main_window_get_position(MainWindow *mainwin)
997 gtkut_widget_get_uposition(mainwin->window, &x, &y);
999 prefs_common.mainview_x = x;
1000 prefs_common.mainview_y = y;
1001 prefs_common.mainwin_x = x;
1002 prefs_common.mainwin_y = y;
1004 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1007 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1012 if (alertpanel(_("Empty trash"),
1013 _("Empty all messages in trash?"),
1014 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1016 manage_window_focus_in(mainwin->window, NULL, NULL);
1019 procmsg_empty_trash();
1021 for (list = folder_get_list(); list != NULL; list = list->next) {
1024 folder = list->data;
1025 if (folder->trash) {
1026 folder_item_scan(folder->trash);
1027 folderview_update_item(folder->trash, TRUE);
1031 if (mainwin->summaryview->folder_item &&
1032 mainwin->summaryview->folder_item->stype == F_TRASH)
1033 gtk_widget_grab_focus(mainwin->folderview->ctree);
1036 void main_window_add_mailbox(MainWindow *mainwin)
1041 path = input_dialog(_("Add mailbox"),
1042 _("Input the location of mailbox.\n"
1043 "If the existing mailbox is specified, it will be\n"
1044 "scanned automatically."),
1047 if (folder_find_from_path(path)) {
1048 alertpanel_error(_("The mailbox `%s' already exists."), path);
1053 if (!strcmp(path, "Mail"))
1054 folder = folder_new(F_MH, _("Mailbox"), path);
1056 folder = folder_new(F_MH, g_basename(path), path);
1060 if (folder->create_tree(folder) < 0) {
1061 alertpanel_error(_("Creation of the mailbox failed.\n"
1062 "Maybe some files already exist, or you don't have the permission to write there."));
1063 folder_destroy(folder);
1068 folder_set_ui_func(folder, scan_tree_func, mainwin);
1069 folder->scan_tree(folder);
1070 folder_set_ui_func(folder, NULL, NULL);
1072 folderview_set(mainwin->folderview);
1075 void main_window_add_mbox(MainWindow *mainwin)
1081 path = input_dialog(_("Add mbox mailbox"),
1082 _("Input the location of mailbox."),
1087 if (folder_find_from_path(path)) {
1088 alertpanel_error(_("The mailbox `%s' already exists."), path);
1094 if (!strcmp(path, "Mail"))
1095 folder = folder_new(F_MBOX, _("Mailbox"), path);
1099 folder = folder_new(F_MBOX, g_basename(path), path);
1102 if (folder->create_tree(folder) < 0) {
1103 alertpanel_error(_("Creation of the mailbox failed."));
1104 folder_destroy(folder);
1110 item = folder_item_new(folder->name, NULL);
1111 item->folder = folder;
1112 folder->node = g_node_new(item);
1114 folder->create_folder(folder, item, "inbox");
1115 folder->create_folder(folder, item, "outbox");
1116 folder->create_folder(folder, item, "queue");
1117 folder->create_folder(folder, item, "draft");
1118 folder->create_folder(folder, item, "trash");
1120 folderview_set(mainwin->folderview);
1123 void main_window_set_toolbar_sensitive(MainWindow *mainwin, gboolean sensitive)
1125 gtk_widget_set_sensitive(mainwin->reply_btn, sensitive);
1126 gtk_widget_set_sensitive(mainwin->replyall_btn, sensitive);
1127 gtk_widget_set_sensitive(mainwin->replysender_btn, sensitive);
1128 gtk_widget_set_sensitive(mainwin->fwd_btn, sensitive);
1129 gtk_widget_set_sensitive(mainwin->exec_btn, sensitive);
1130 gtk_widget_set_sensitive(mainwin->next_btn, sensitive);
1132 if (!mainwin->summaryview->folder_item ||
1133 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1134 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1136 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1139 void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
1141 GtkItemFactory *ifactory;
1145 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1147 if (selection == SUMMARY_SELECTED_SINGLE)
1151 if (!mainwin->summaryview->folder_item ||
1152 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1157 menu_set_sensitive(ifactory, "/File/Save as...", sens);
1158 menu_set_sensitive(ifactory, "/Message/Reply", sens);
1159 menu_set_sensitive(ifactory, "/Message/Reply to sender", sens);
1160 menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
1161 menu_set_sensitive(ifactory, "/Message/Forward", sens);
1162 menu_set_sensitive(ifactory, "/Message/Forward as attachment", sens);
1163 menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
1164 menu_set_sensitive(ifactory, "/Message/Show all header", sens);
1165 menu_set_sensitive(ifactory, "/Message/View source", sens);
1166 if (sens && (!mainwin->summaryview->folder_item ||
1167 mainwin->summaryview->folder_item->stype != F_DRAFT))
1169 menu_set_sensitive(ifactory, "/Message/Re-edit", sens);
1171 if (selection == SUMMARY_SELECTED_SINGLE ||
1172 selection == SUMMARY_SELECTED_MULTIPLE)
1177 menu_set_sensitive(ifactory, "/File/Print..." , sens);
1178 menu_set_sensitive(ifactory, "/Message/Move...", sens && exec);
1179 menu_set_sensitive(ifactory, "/Message/Copy...", sens && exec);
1180 menu_set_sensitive(ifactory, "/Message/Delete" , sens && exec);
1181 menu_set_sensitive(ifactory, "/Message/Mark" , sens);
1183 if (selection != SUMMARY_NONE)
1188 menu_set_sensitive(ifactory, "/Summary/Delete duplicated messages", sens && exec);
1189 menu_set_sensitive(ifactory, "/Summary/Filter messages", sens && exec);
1190 menu_set_sensitive(ifactory, "/Summary/Execute", sens);
1191 menu_set_sensitive(ifactory, "/Summary/Prev message", sens);
1192 menu_set_sensitive(ifactory, "/Summary/Next message", sens);
1193 menu_set_sensitive(ifactory, "/Summary/Next unread message", sens);
1194 menu_set_sensitive(ifactory, "/Summary/Sort", sens);
1196 if (mainwin->summaryview->folder_item &&
1197 mainwin->summaryview->folder_item->folder->account)
1198 sens = mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP;
1201 menu_set_sensitive(ifactory, "/Message/Follow-up and reply to", sens);
1204 void main_window_popup(MainWindow *mainwin)
1210 gdk_window_get_origin(mainwin->window->window, &x, &y);
1211 sx = gdk_screen_width();
1212 sy = gdk_screen_height();
1213 x %= sx; if (x < 0) x += sx;
1214 y %= sy; if (y < 0) y += sy;
1215 gdk_window_move(mainwin->window->window, x, y);
1216 gdk_window_raise(mainwin->window->window);
1218 debug_print("window position: x = %d, y = %d\n", x, y);
1220 switch (mainwin->type) {
1221 case SEPARATE_FOLDER:
1222 widget = mainwin->win.sep_folder.folderwin;
1223 gdk_window_get_origin(widget->window, &x, &y);
1224 x %= sx; if (x < 0) x += sx;
1225 y %= sy; if (y < 0) y += sy;
1226 gdk_window_move(widget->window, x, y);
1227 gdk_window_raise(widget->window);
1229 case SEPARATE_MESSAGE:
1230 widget = mainwin->win.sep_message.messagewin;
1231 gdk_window_get_origin(widget->window, &x, &y);
1232 x %= sx; if (x < 0) x += sx;
1233 y %= sy; if (y < 0) y += sy;
1234 gdk_window_move(widget->window, x, y);
1235 gdk_window_raise(widget->window);
1238 widget = mainwin->win.sep_both.folderwin;
1239 gdk_window_get_origin(widget->window, &x, &y);
1240 x %= sx; if (x < 0) x += sx;
1241 y %= sy; if (y < 0) y += sy;
1242 gdk_window_move(widget->window, x, y);
1243 gdk_window_raise(widget->window);
1244 widget = mainwin->win.sep_both.messagewin;
1245 gdk_window_get_origin(widget->window, &x, &y);
1246 x %= sx; if (x < 0) x += sx;
1247 y %= sy; if (y < 0) y += sy;
1248 gdk_window_move(widget->window, x, y);
1249 gdk_window_raise(widget->window);
1255 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1257 GtkWidget *folderwin = NULL;
1258 GtkWidget *messagewin = NULL;
1261 GtkWidget *vbox_body = mainwin->vbox_body;
1263 debug_print(_("Setting widgets..."));
1265 /* create separated window(s) if needed */
1266 if (type & SEPARATE_FOLDER) {
1267 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1268 gtk_window_set_policy(GTK_WINDOW(folderwin),
1270 gtk_widget_set_usize(folderwin, -1,
1271 prefs_common.mainview_height);
1272 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1274 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1275 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1278 if (type & SEPARATE_MESSAGE) {
1279 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1280 gtk_window_set_policy(GTK_WINDOW(messagewin),
1282 gtk_widget_set_usize
1283 (messagewin, prefs_common.mainview_width,
1284 prefs_common.mainview_height
1285 - prefs_common.summaryview_height
1286 + DEFAULT_HEADERVIEW_HEIGHT);
1287 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1289 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1290 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1296 hpaned = gtk_hpaned_new();
1297 gtk_widget_show(hpaned);
1298 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1299 gtk_paned_add1(GTK_PANED(hpaned),
1300 GTK_WIDGET_PTR(mainwin->folderview));
1302 vpaned = gtk_vpaned_new();
1303 if (mainwin->summaryview->msg_is_toggled_on) {
1304 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1305 gtk_paned_add1(GTK_PANED(vpaned),
1306 GTK_WIDGET_PTR(mainwin->summaryview));
1308 gtk_paned_add2(GTK_PANED(hpaned),
1309 GTK_WIDGET_PTR(mainwin->summaryview));
1310 gtk_widget_ref(vpaned);
1312 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1313 prefs_common.summaryview_width,
1314 prefs_common.summaryview_height);
1315 gtk_paned_add2(GTK_PANED(vpaned),
1316 GTK_WIDGET_PTR(mainwin->messageview));
1317 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1318 prefs_common.mainview_width, -1);
1319 gtk_widget_set_usize(mainwin->window,
1320 prefs_common.folderview_width +
1321 prefs_common.mainview_width,
1322 prefs_common.mainwin_height);
1323 gtk_widget_show_all(vpaned);
1325 mainwin->win.sep_none.hpaned = hpaned;
1326 mainwin->win.sep_none.vpaned = vpaned;
1328 case SEPARATE_FOLDER:
1329 vpaned = gtk_vpaned_new();
1330 if (mainwin->summaryview->msg_is_toggled_on) {
1331 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1333 gtk_paned_add1(GTK_PANED(vpaned),
1334 GTK_WIDGET_PTR(mainwin->summaryview));
1336 gtk_box_pack_start(GTK_BOX(vbox_body),
1337 GTK_WIDGET_PTR(mainwin->summaryview),
1339 gtk_widget_ref(vpaned);
1341 gtk_paned_add2(GTK_PANED(vpaned),
1342 GTK_WIDGET_PTR(mainwin->messageview));
1343 gtk_widget_show_all(vpaned);
1344 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1345 prefs_common.summaryview_width,
1346 prefs_common.summaryview_height);
1347 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1348 prefs_common.mainview_width, -1);
1349 gtk_widget_set_usize(mainwin->window,
1350 prefs_common.mainview_width,
1351 prefs_common.mainview_height);
1353 gtk_container_add(GTK_CONTAINER(folderwin),
1354 GTK_WIDGET_PTR(mainwin->folderview));
1356 mainwin->win.sep_folder.folderwin = folderwin;
1357 mainwin->win.sep_folder.vpaned = vpaned;
1359 gtk_widget_show_all(folderwin);
1361 case SEPARATE_MESSAGE:
1362 hpaned = gtk_hpaned_new();
1363 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1365 gtk_paned_add1(GTK_PANED(hpaned),
1366 GTK_WIDGET_PTR(mainwin->folderview));
1367 gtk_paned_add2(GTK_PANED(hpaned),
1368 GTK_WIDGET_PTR(mainwin->summaryview));
1369 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1370 prefs_common.summaryview_width,
1371 prefs_common.summaryview_height);
1372 gtk_widget_set_usize(mainwin->window,
1373 prefs_common.folderview_width +
1374 prefs_common.mainview_width,
1375 prefs_common.mainwin_height);
1376 gtk_widget_show_all(hpaned);
1377 gtk_container_add(GTK_CONTAINER(messagewin),
1378 GTK_WIDGET_PTR(mainwin->messageview));
1380 mainwin->win.sep_message.messagewin = messagewin;
1381 mainwin->win.sep_message.hpaned = hpaned;
1383 gtk_widget_show_all(messagewin);
1386 gtk_box_pack_start(GTK_BOX(vbox_body),
1387 GTK_WIDGET_PTR(mainwin->summaryview),
1389 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1390 prefs_common.summaryview_width,
1391 prefs_common.summaryview_height);
1392 gtk_widget_set_usize(mainwin->window,
1393 prefs_common.mainview_width,
1394 prefs_common.mainwin_height);
1395 gtk_container_add(GTK_CONTAINER(folderwin),
1396 GTK_WIDGET_PTR(mainwin->folderview));
1397 gtk_container_add(GTK_CONTAINER(messagewin),
1398 GTK_WIDGET_PTR(mainwin->messageview));
1400 mainwin->win.sep_both.folderwin = folderwin;
1401 mainwin->win.sep_both.messagewin = messagewin;
1403 gtk_widget_show_all(folderwin);
1404 gtk_widget_show_all(messagewin);
1408 mainwin->type = type;
1410 debug_print(_("done.\n"));
1413 #include "pixmaps/stock_mail_receive.xpm"
1414 #include "pixmaps/stock_mail_receive_all.xpm"
1415 #include "pixmaps/stock_mail_compose.xpm"
1416 #include "pixmaps/stock_news_compose.xpm"
1417 #include "pixmaps/stock_mail_reply.xpm"
1418 #include "pixmaps/stock_mail_reply_to_all.xpm"
1419 #include "pixmaps/stock_mail_reply_to_author.xpm"
1420 #include "pixmaps/stock_mail_forward.xpm"
1421 #include "pixmaps/stock_mail_send.xpm"
1422 #include "pixmaps/stock_preferences.xpm"
1423 #include "pixmaps/stock_properties.xpm"
1424 #include "pixmaps/stock_down_arrow.xpm"
1425 #include "pixmaps/stock_close.xpm"
1426 #include "pixmaps/stock_exec.xpm"
1428 #define CREATE_TOOLBAR_ICON(xpm_d) \
1430 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1431 &container->style->white, \
1433 icon_wid = gtk_pixmap_new(icon, mask); \
1436 static void main_window_toolbar_create(MainWindow *mainwin,
1437 GtkWidget *container)
1442 GtkWidget *icon_wid;
1444 GtkWidget *getall_btn;
1445 GtkWidget *compose_btn;
1446 GtkWidget *reply_btn;
1447 GtkWidget *replyall_btn;
1448 GtkWidget *replysender_btn;
1450 GtkWidget *send_btn;
1452 GtkWidget *prefs_btn;
1453 GtkWidget *account_btn;
1455 GtkWidget *next_btn;
1456 GtkWidget *delete_btn;
1457 GtkWidget *exec_btn;
1459 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1461 gtk_container_add(GTK_CONTAINER(container), toolbar);
1462 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1463 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1464 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1465 GTK_TOOLBAR_SPACE_LINE);
1467 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1468 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1470 _("Get new mail from current account"),
1472 icon_wid, toolbar_inc_cb, mainwin);
1473 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1474 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1476 _("Get new mail from all accounts"),
1482 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1484 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1485 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1487 _("Send queued message(s)"),
1493 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1495 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1496 compose_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1498 _("Compose an email message"),
1501 toolbar_compose_mail_cb,
1503 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1504 compose_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1506 _("Compose a news message"),
1509 toolbar_compose_news_cb,
1511 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1512 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1514 _("Reply to the message"),
1519 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1520 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1525 toolbar_reply_to_all_cb,
1527 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1528 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1530 _("Reply to sender"),
1533 toolbar_reply_to_sender_cb,
1535 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1536 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1538 _("Forward the message"),
1544 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1546 CREATE_TOOLBAR_ICON(stock_close_xpm);
1547 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1549 _("Delete the message"),
1555 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1556 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1558 _("Execute marked process"),
1564 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1565 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1567 _("Next unread message"),
1570 toolbar_next_unread_cb,
1574 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1576 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1577 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1579 _("Common preference"),
1584 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1585 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1587 _("Account setting"),
1592 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1593 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1597 mainwin->toolbar = toolbar;
1598 mainwin->get_btn = get_btn;
1599 mainwin->getall_btn = getall_btn;
1600 mainwin->compose_btn = compose_btn;
1601 mainwin->reply_btn = reply_btn;
1602 mainwin->replyall_btn = replyall_btn;
1603 mainwin->replysender_btn = replysender_btn;
1604 mainwin->fwd_btn = fwd_btn;
1605 mainwin->send_btn = send_btn;
1607 mainwin->prefs_btn = prefs_btn;
1608 mainwin->account_btn = account_btn;
1610 mainwin->next_btn = next_btn;
1611 mainwin->delete_btn = delete_btn;
1612 mainwin->exec_btn = exec_btn;
1614 gtk_widget_show_all(toolbar);
1617 /* callback functions */
1619 static void toolbar_inc_cb (GtkWidget *widget,
1622 MainWindow *mainwin = (MainWindow *)data;
1624 inc_mail_cb(mainwin, 0, NULL);
1627 static void toolbar_inc_all_cb (GtkWidget *widget,
1630 MainWindow *mainwin = (MainWindow *)data;
1632 inc_all_account_mail_cb(mainwin, 0, NULL);
1635 static void toolbar_send_cb (GtkWidget *widget,
1638 MainWindow *mainwin = (MainWindow *)data;
1640 send_queue_cb(mainwin, 0, NULL);
1643 static void toolbar_compose_cb (GtkWidget *widget,
1646 MainWindow *mainwin = (MainWindow *)data;
1648 compose_cb(mainwin, 0, NULL);
1651 static void toolbar_compose_news_cb (GtkWidget *widget,
1654 MainWindow *mainwin = (MainWindow *)data;
1656 compose_news_cb(mainwin, 0, NULL);
1659 static void toolbar_compose_mail_cb (GtkWidget *widget,
1662 MainWindow *mainwin = (MainWindow *)data;
1664 compose_mail_cb(mainwin, 0, NULL);
1667 static void toolbar_reply_cb (GtkWidget *widget,
1670 MainWindow *mainwin = (MainWindow *)data;
1672 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1675 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1678 MainWindow *mainwin = (MainWindow *)data;
1680 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1683 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1686 MainWindow *mainwin = (MainWindow *)data;
1688 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1691 static void toolbar_forward_cb (GtkWidget *widget,
1694 MainWindow *mainwin = (MainWindow *)data;
1696 if (prefs_common.forward_as_attachment)
1697 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
1699 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1702 static void toolbar_delete_cb (GtkWidget *widget,
1705 MainWindow *mainwin = (MainWindow *)data;
1707 summary_delete(mainwin->summaryview);
1710 static void toolbar_exec_cb (GtkWidget *widget,
1713 MainWindow *mainwin = (MainWindow *)data;
1715 summary_execute(mainwin->summaryview);
1718 static void toolbar_next_unread_cb (GtkWidget *widget,
1721 MainWindow *mainwin = (MainWindow *)data;
1723 next_unread_cb(mainwin, 0, NULL);
1726 static void toolbar_prefs_cb (GtkWidget *widget,
1729 prefs_common_open();
1732 static void toolbar_account_cb (GtkWidget *widget,
1735 MainWindow *mainwin = (MainWindow *)data;
1737 prefs_account_open_cb(mainwin, 0, NULL);
1740 static void toolbar_account_button_pressed(GtkWidget *widget,
1741 GdkEventButton *event,
1744 MainWindow *mainwin = (MainWindow *)data;
1747 if (event->button != 3) return;
1749 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1750 event->button, event->time);
1753 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1756 MainWindow *mainwin = (MainWindow *)data;
1760 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1761 event->button, event->time);
1764 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1767 app_exit_cb(data, 0, widget);
1772 static void add_mailbox_cb(MainWindow *mainwin, guint action,
1775 main_window_add_mailbox(mainwin);
1778 static void add_mbox_cb(MainWindow *mainwin, guint action,
1781 main_window_add_mbox(mainwin);
1784 static void update_folderview_cb(MainWindow *mainwin, guint action,
1787 summary_show(mainwin->summaryview, NULL, FALSE);
1788 folderview_update_all();
1791 static void new_folder_cb(MainWindow *mainwin, guint action,
1794 folderview_new_folder(mainwin->folderview);
1797 static void rename_folder_cb(MainWindow *mainwin, guint action,
1800 folderview_rename_folder(mainwin->folderview);
1803 static void delete_folder_cb(MainWindow *mainwin, guint action,
1806 folderview_delete_folder(mainwin->folderview);
1809 static void import_mbox_cb(MainWindow *mainwin, guint action,
1812 import_mbox(mainwin->summaryview->folder_item);
1815 static void export_mbox_cb(MainWindow *mainwin, guint action,
1818 export_mbox(mainwin->summaryview->folder_item);
1821 static void empty_trash_cb(MainWindow *mainwin, guint action,
1824 main_window_empty_trash(mainwin, TRUE);
1827 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1829 summary_save_as(mainwin->summaryview);
1832 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1834 summary_print(mainwin->summaryview);
1837 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1839 if (prefs_common.confirm_on_exit) {
1840 if (alertpanel(_("Exit"), _("Exit this program?"),
1841 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
1843 manage_window_focus_in(mainwin->window, NULL, NULL);
1846 app_will_exit(widget, mainwin);
1849 static void toggle_folder_cb(MainWindow *mainwin, guint action,
1852 switch (mainwin->type) {
1854 case SEPARATE_MESSAGE:
1856 case SEPARATE_FOLDER:
1857 if (GTK_CHECK_MENU_ITEM(widget)->active)
1858 gtk_widget_show(mainwin->win.sep_folder.folderwin);
1860 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1863 if (GTK_CHECK_MENU_ITEM(widget)->active)
1864 gtk_widget_show(mainwin->win.sep_both.folderwin);
1866 gtk_widget_hide(mainwin->win.sep_both.folderwin);
1871 static void toggle_message_cb(MainWindow *mainwin, guint action,
1874 switch (mainwin->type) {
1876 case SEPARATE_FOLDER:
1878 case SEPARATE_MESSAGE:
1879 if (GTK_CHECK_MENU_ITEM(widget)->active)
1880 gtk_widget_show(mainwin->win.sep_message.messagewin);
1882 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1885 if (GTK_CHECK_MENU_ITEM(widget)->active)
1886 gtk_widget_show(mainwin->win.sep_both.messagewin);
1888 gtk_widget_hide(mainwin->win.sep_both.messagewin);
1893 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
1896 switch ((ToolbarStyle)action) {
1898 gtk_widget_hide(mainwin->handlebox);
1900 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1904 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1908 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1913 if (action != TOOLBAR_NONE) {
1914 gtk_widget_show(mainwin->handlebox);
1915 gtk_widget_queue_resize(mainwin->handlebox);
1918 mainwin->toolbar_style = (ToolbarStyle)action;
1919 prefs_common.toolbar_style = (ToolbarStyle)action;
1922 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
1925 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1926 gtk_widget_show(mainwin->hbox_stat);
1927 prefs_common.show_statusbar = TRUE;
1929 gtk_widget_hide(mainwin->hbox_stat);
1930 prefs_common.show_statusbar = FALSE;
1934 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action)
1936 MainWindow *mainwin;
1939 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
1940 g_return_if_fail(mainwin != NULL);
1942 type = mainwin->type ^ action;
1943 main_window_separation_change(mainwin, type);
1945 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
1946 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
1949 static void addressbook_open_cb(MainWindow *mainwin, guint action,
1952 addressbook_open(NULL);
1955 static void log_window_show_cb(MainWindow *mainwin, guint action,
1958 log_window_show(mainwin->logwin);
1961 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1966 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
1969 inc_all_account_mail(mainwin);
1972 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1976 if (procmsg_send_queue() < 0)
1977 alertpanel_error(_("Sending queued message failed."));
1979 statusbar_pop_all();
1981 for (list = folder_get_list(); list != NULL; list = list->next) {
1984 folder = list->data;
1985 if (folder->queue) {
1986 folder_item_scan(folder->queue);
1987 folderview_update_item(folder->queue, TRUE);
1992 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1994 if (mainwin->summaryview->folder_item) {
1995 if (mainwin->summaryview->folder_item->folder->account != NULL
1996 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
1997 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
1999 compose_new(mainwin->summaryview->folder_item->folder->account);
2005 static void compose_mail_cb(MainWindow *mainwin, guint action,
2012 if (mainwin->summaryview->folder_item) {
2013 ac = mainwin->summaryview->folder_item->folder->account;
2014 if (ac && ac->protocol != A_NNTP) {
2020 list = account_get_list();
2021 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2022 ac = (PrefsAccount *) cur->data;
2023 if (ac->protocol != A_NNTP) {
2030 static void compose_news_cb(MainWindow *mainwin, guint action,
2033 PrefsAccount * ac = NULL;
2037 if (mainwin->summaryview->folder_item) {
2038 ac = mainwin->summaryview->folder_item->folder->account;
2039 if (ac && ac->protocol == A_NNTP) {
2040 compose_new_with_recipient
2041 (ac, mainwin->summaryview->folder_item->path);
2046 list = account_get_list();
2047 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2048 ac = (PrefsAccount *) cur->data;
2049 if (ac->protocol == A_NNTP) {
2056 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2060 msginfo = gtk_ctree_node_get_row_data
2061 (GTK_CTREE(mainwin->summaryview->ctree),
2062 mainwin->summaryview->selected);
2064 if (!msginfo) return;
2068 compose_reply(msginfo, prefs_common.reply_with_quote,
2071 case COMPOSE_REPLY_TO_SENDER:
2072 compose_reply(msginfo, prefs_common.reply_with_quote,
2075 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2076 compose_followup_and_reply_to(msginfo,
2077 prefs_common.reply_with_quote,
2080 case COMPOSE_REPLY_TO_ALL:
2081 compose_reply(msginfo, prefs_common.reply_with_quote,
2084 case COMPOSE_FORWARD:
2085 compose_forward(NULL, msginfo, FALSE);
2087 case COMPOSE_FORWARD_AS_ATTACH:
2088 compose_forward(NULL, msginfo, TRUE);
2091 g_warning("reply_cb(): invalid action type: %d\n", action);
2094 summary_set_marks_selected(mainwin->summaryview);
2097 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2099 summary_move_to(mainwin->summaryview);
2102 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2104 summary_copy_to(mainwin->summaryview);
2107 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2109 summary_delete(mainwin->summaryview);
2112 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2114 summary_open_msg(mainwin->summaryview);
2117 static void view_source_cb(MainWindow *mainwin, guint action,
2120 summary_view_source(mainwin->summaryview);
2123 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2125 summary_reedit(mainwin->summaryview);
2128 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2130 summary_mark(mainwin->summaryview);
2133 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2135 summary_unmark(mainwin->summaryview);
2138 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2141 summary_mark_as_unread(mainwin->summaryview);
2144 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2147 summary_mark_as_read(mainwin->summaryview);
2150 static void set_charset_cb(MainWindow *mainwin, guint action,
2155 str = conv_get_charset_str((CharSet)action);
2156 g_free(prefs_common.force_charset);
2157 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2159 summary_redisplay_msg(mainwin->summaryview);
2161 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2164 void main_window_set_thread_option(MainWindow *mainwin)
2166 GtkItemFactory *ifactory;
2167 gboolean no_item = FALSE;
2169 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2171 if (mainwin->summaryview == NULL)
2173 else if (mainwin->summaryview->folder_item == NULL)
2177 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2178 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2181 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2182 menu_set_sensitive(ifactory,
2183 "/Summary/Thread view", FALSE);
2184 menu_set_sensitive(ifactory,
2185 "/Summary/Unthread view", TRUE);
2186 summary_thread_build(mainwin->summaryview);
2189 menu_set_sensitive(ifactory,
2190 "/Summary/Thread view", TRUE);
2191 menu_set_sensitive(ifactory,
2192 "/Summary/Unthread view", FALSE);
2193 summary_unthread(mainwin->summaryview);
2195 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2199 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2201 mainwin->summaryview->folder_item->prefs->enable_thread =
2202 !mainwin->summaryview->folder_item->prefs->enable_thread;
2203 main_window_set_thread_option(mainwin);
2207 summary_thread_build(mainwin->summaryview);
2208 mainwin->summaryview->folder_item->prefs->enable_thread =
2210 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2211 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2213 summary_unthread(mainwin->summaryview);
2214 mainwin->summaryview->folder_item->prefs->enable_thread =
2216 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2217 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2222 static void set_display_item_cb(MainWindow *mainwin, guint action,
2225 prefs_summary_display_item_set();
2228 static void sort_summary_cb(MainWindow *mainwin, guint action,
2231 summary_sort(mainwin->summaryview, (SummarySortType)action);
2234 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2237 summary_attract_by_subject(mainwin->summaryview);
2240 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2243 summary_delete_duplicated(mainwin->summaryview);
2246 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2248 summary_filter(mainwin->summaryview);
2251 static void execute_summary_cb(MainWindow *mainwin, guint action,
2254 summary_execute(mainwin->summaryview);
2257 static void update_summary_cb(MainWindow *mainwin, guint action,
2261 FolderView *folderview = mainwin->folderview;
2263 if (!mainwin->summaryview->folder_item) return;
2264 if (!folderview->opened) return;
2266 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2267 folderview->opened);
2270 summary_show(mainwin->summaryview, fitem, TRUE);
2273 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2275 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2278 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2280 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2283 static void next_unread_cb(MainWindow *mainwin, guint action,
2286 summary_select_next_unread(mainwin->summaryview);
2289 static void next_marked_cb(MainWindow *mainwin, guint action,
2292 summary_select_next_marked(mainwin->summaryview);
2295 static void prev_marked_cb(MainWindow *mainwin, guint action,
2298 summary_select_prev_marked(mainwin->summaryview);
2301 static void goto_folder_cb(MainWindow *mainwin, guint action,
2304 FolderItem *to_folder;
2306 to_folder = foldersel_folder_sel(NULL);
2309 folderview_select(mainwin->folderview, to_folder);
2312 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2314 messageview_copy_clipboard(mainwin->messageview);
2317 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2319 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2320 summary_select_all(mainwin->summaryview);
2321 else if (mainwin->summaryview->msg_is_toggled_on &&
2322 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2323 messageview_select_all(mainwin->messageview);
2326 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2329 prefs_common_open();
2332 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2335 prefs_filter_open();
2338 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2341 prefs_scoring_open(NULL);
2344 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2347 prefs_filtering_open();
2350 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2354 new_account_cb(mainwin, 0, widget);
2356 gboolean prev_default = cur_account->is_default;
2358 prefs_account_open(cur_account);
2359 if (!prev_default && cur_account->is_default)
2360 account_set_as_default(cur_account);
2361 account_save_config_all();
2363 main_window_reflect_prefs_all();
2367 static void new_account_cb(MainWindow *mainwin, guint action,
2370 account_edit_open();
2371 if (!compose_get_compose_list()) account_add();
2374 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2376 cur_account = (PrefsAccount *)data;
2377 main_window_reflect_prefs_all();
2380 static void manual_open_cb(MainWindow *mainwin, guint action,
2383 manual_open((ManualLang)action);
2386 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2388 MainWindow *mainwin = (MainWindow *)data;
2392 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2393 LOCAL_FOLDER(folder)->rootpath,
2397 str = g_strdup_printf(_("Scanning folder %s ..."),
2398 LOCAL_FOLDER(folder)->rootpath);
2400 STATUSBAR_PUSH(mainwin, str);
2401 STATUSBAR_POP(mainwin);