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_reply_cb (GtkWidget *widget,
117 static void toolbar_reply_to_all_cb (GtkWidget *widget,
119 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
121 static void toolbar_forward_cb (GtkWidget *widget,
124 static void toolbar_delete_cb (GtkWidget *widget,
126 static void toolbar_exec_cb (GtkWidget *widget,
129 static void toolbar_next_unread_cb (GtkWidget *widget,
132 static void toolbar_prefs_cb (GtkWidget *widget,
134 static void toolbar_account_cb (GtkWidget *widget,
137 static void toolbar_account_button_pressed (GtkWidget *widget,
138 GdkEventButton *event,
140 static void ac_label_button_pressed (GtkWidget *widget,
141 GdkEventButton *event,
144 static gint main_window_close_cb (GtkWidget *widget,
148 static void add_mailbox_cb (MainWindow *mainwin,
151 static void add_mbox_cb (MainWindow *mainwin,
154 static void update_folderview_cb (MainWindow *mainwin,
157 static void new_folder_cb (MainWindow *mainwin,
160 static void rename_folder_cb (MainWindow *mainwin,
163 static void delete_folder_cb (MainWindow *mainwin,
166 static void import_mbox_cb (MainWindow *mainwin,
169 static void export_mbox_cb (MainWindow *mainwin,
172 static void empty_trash_cb (MainWindow *mainwin,
176 static void save_as_cb (MainWindow *mainwin,
179 static void print_cb (MainWindow *mainwin,
182 static void app_exit_cb (MainWindow *mainwin,
186 static void toggle_folder_cb (MainWindow *mainwin,
189 static void toggle_message_cb (MainWindow *mainwin,
192 static void toggle_toolbar_cb (MainWindow *mainwin,
195 static void toggle_statusbar_cb (MainWindow *mainwin,
198 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action);
200 static void addressbook_open_cb (MainWindow *mainwin,
203 static void log_window_show_cb (MainWindow *mainwin,
207 static void inc_mail_cb (MainWindow *mainwin,
210 static void inc_all_account_mail_cb (MainWindow *mainwin,
214 static void send_queue_cb (MainWindow *mainwin,
218 static void compose_cb (MainWindow *mainwin,
221 static void reply_cb (MainWindow *mainwin,
225 static void open_msg_cb (MainWindow *mainwin,
229 static void view_source_cb (MainWindow *mainwin,
233 static void reedit_cb (MainWindow *mainwin,
237 static void move_to_cb (MainWindow *mainwin,
240 static void copy_to_cb (MainWindow *mainwin,
243 static void delete_cb (MainWindow *mainwin,
247 static void mark_cb (MainWindow *mainwin,
250 static void unmark_cb (MainWindow *mainwin,
254 static void mark_as_unread_cb (MainWindow *mainwin,
257 static void mark_as_read_cb (MainWindow *mainwin,
261 static void set_charset_cb (MainWindow *mainwin,
265 static void thread_cb (MainWindow *mainwin,
268 static void set_display_item_cb (MainWindow *mainwin,
271 static void sort_summary_cb (MainWindow *mainwin,
274 static void attract_by_subject_cb(MainWindow *mainwin,
278 static void delete_duplicated_cb (MainWindow *mainwin,
281 static void filter_cb (MainWindow *mainwin,
284 static void execute_summary_cb (MainWindow *mainwin,
287 static void update_summary_cb (MainWindow *mainwin,
291 static void prev_cb (MainWindow *mainwin,
294 static void next_cb (MainWindow *mainwin,
298 static void next_unread_cb (MainWindow *mainwin,
302 static void next_marked_cb (MainWindow *mainwin,
306 static void prev_marked_cb (MainWindow *mainwin,
310 static void goto_folder_cb (MainWindow *mainwin,
314 static void copy_cb (MainWindow *mainwin,
317 static void allsel_cb (MainWindow *mainwin,
321 static void prefs_common_open_cb (MainWindow *mainwin,
324 static void prefs_filter_open_cb (MainWindow *mainwin,
327 static void prefs_scoring_open_cb (MainWindow *mainwin,
330 static void prefs_filtering_open_cb (MainWindow *mainwin,
333 static void prefs_account_open_cb(MainWindow *mainwin,
336 static void new_account_cb (MainWindow *mainwin,
340 static void account_menu_cb (GtkMenuItem *menuitem,
343 static void manual_open_cb (MainWindow *mainwin,
347 static void scan_tree_func (Folder *folder,
351 #define SEPARATE_ACTION 667
353 static GtkItemFactoryEntry mainwin_entries[] =
355 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
356 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
357 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
358 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
359 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
360 {N_("/_File/_Folder/Create _new folder..."),
361 NULL, new_folder_cb, 0, NULL},
362 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
363 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
364 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
365 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
366 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
367 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
368 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
369 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
370 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
371 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
372 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
374 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
375 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
376 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
377 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
378 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
380 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
381 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
382 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
383 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
384 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
385 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
386 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
387 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
388 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
389 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
390 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
391 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
392 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
393 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
394 {N_("/_View/_Code set/_Auto detect"),
395 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
397 #define CODESET_SEPARATOR \
398 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
399 #define CODESET_ACTION(action) \
400 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
402 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
403 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
404 CODESET_ACTION(C_US_ASCII)},
407 {N_("/_View/_Code set/Unicode (_UTF-8)"),
408 CODESET_ACTION(C_UTF_8)},
411 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
412 CODESET_ACTION(C_ISO_8859_1)},
415 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
416 CODESET_ACTION(C_ISO_8859_2)},
418 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
419 CODESET_ACTION(C_ISO_8859_13)},
420 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
421 CODESET_ACTION(C_ISO_8859_4)},
423 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
424 CODESET_ACTION(C_ISO_8859_7)},
426 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
427 CODESET_ACTION(C_ISO_8859_9)},
429 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
430 CODESET_ACTION(C_ISO_8859_5)},
431 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
432 CODESET_ACTION(C_KOI8_R)},
433 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
434 CODESET_ACTION(C_CP1251)},
437 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
438 CODESET_ACTION(C_ISO_2022_JP)},
440 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
441 CODESET_ACTION(C_ISO_2022_JP_2)},
443 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
444 CODESET_ACTION(C_EUC_JP)},
445 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
446 CODESET_ACTION(C_SHIFT_JIS)},
449 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
450 CODESET_ACTION(C_GB2312)},
451 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
452 CODESET_ACTION(C_BIG5)},
453 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
454 CODESET_ACTION(C_EUC_TW)},
455 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
456 CODESET_ACTION(C_ISO_2022_CN)},
458 {N_("/_View/_Code set/Korean (EUC-_KR)"),
459 CODESET_ACTION(C_EUC_KR)},
460 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
461 CODESET_ACTION(C_ISO_2022_KR)},
464 #undef CODESET_SEPARATOR
465 #undef CODESET_ACTION
467 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
468 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
469 {N_("/_Message/Get from _all accounts"),
470 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
471 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
472 {N_("/_Message/Send queued messa_ges"),
473 NULL, send_queue_cb, 0, NULL},
474 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
475 {N_("/_Message/Compose _new message"), "<alt>N", compose_cb, 0, NULL},
476 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
477 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
478 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
479 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
480 {N_("/_Message/Forward as a_ttachment"),
481 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
482 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
483 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
484 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
485 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
486 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
487 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
488 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
489 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
490 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
491 {N_("/_Message/_Mark/Mark as rea_d"),
492 NULL, mark_as_read_cb, 0, NULL},
493 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
494 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
495 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
496 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
497 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
499 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_Summary/_Delete duplicated messages"),
501 NULL, delete_duplicated_cb, 0, NULL},
502 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
503 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
504 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
505 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
506 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
507 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
508 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
509 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
510 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
511 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
513 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
514 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
515 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
516 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
517 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
518 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
519 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
520 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
521 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
522 {N_("/_Summary/_Sort/_Attract by subject"),
523 NULL, attract_by_subject_cb, 0, NULL},
524 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
525 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
526 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
528 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
529 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
530 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
532 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
533 {N_("/_Configuration/_Common preferences..."),
534 NULL, prefs_common_open_cb, 0, NULL},
535 {N_("/_Configuration/_Filter setting..."),
536 NULL, prefs_filter_open_cb, 0, NULL},
537 {N_("/_Configuration/_Scoring ..."),
538 NULL, prefs_scoring_open_cb, 0, NULL},
539 {N_("/_Configuration/_Filtering ..."),
540 NULL, prefs_filtering_open_cb, 0, NULL},
541 {N_("/_Configuration/_Preferences per account..."),
542 NULL, prefs_account_open_cb, 0, NULL},
543 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_Configuration/Create _new account..."),
545 NULL, new_account_cb, 0, NULL},
546 {N_("/_Configuration/_Edit accounts..."),
547 NULL, account_edit_open, 0, NULL},
548 {N_("/_Configuration/C_hange current account"),
549 NULL, NULL, 0, "<Branch>"},
551 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
552 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
553 {N_("/_Help/_Manual/_English"), NULL, NULL, MANUAL_LANG_EN, NULL},
554 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
555 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
559 MainWindow *main_window_create(SeparateType type)
565 GtkWidget *handlebox;
566 GtkWidget *vbox_body;
567 GtkWidget *hbox_stat;
568 GtkWidget *statusbar;
569 GtkWidget *ac_button;
572 FolderView *folderview;
573 SummaryView *summaryview;
574 MessageView *messageview;
575 GdkColormap *colormap;
578 guint n_menu_entries;
579 GtkItemFactory *ifactory;
584 debug_print(_("Creating main window...\n"));
585 mainwin = g_new0(MainWindow, 1);
588 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
589 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
590 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
591 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
592 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
593 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
594 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
595 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
596 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
597 gtk_widget_realize(window);
599 vbox = gtk_vbox_new(FALSE, 0);
600 gtk_widget_show(vbox);
601 gtk_container_add(GTK_CONTAINER(window), vbox);
604 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
605 menubar = menubar_create(window, mainwin_entries,
606 n_menu_entries, "<Main>", mainwin);
607 gtk_widget_show(menubar);
608 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
610 handlebox = gtk_handle_box_new();
611 gtk_widget_show(handlebox);
612 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
614 main_window_toolbar_create(mainwin, handlebox);
616 /* vbox that contains body */
617 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
618 gtk_widget_show(vbox_body);
619 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
620 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
622 hbox_stat = gtk_hbox_new(FALSE, 2);
623 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
625 statusbar = statusbar_create();
626 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
628 ac_button = gtk_button_new();
629 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
630 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
631 gtk_widget_set_usize(ac_button, -1, 1);
632 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
633 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
634 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
636 ac_label = gtk_label_new("");
637 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
639 gtk_widget_show_all(hbox_stat);
642 mainwin->folderview = folderview = folderview_create();
643 mainwin->summaryview = summaryview = summary_create();
644 mainwin->messageview = messageview = messageview_create();
645 mainwin->headerwin = header_window_create();
646 mainwin->logwin = log_window_create();
648 folderview->mainwin = mainwin;
649 folderview->summaryview = summaryview;
651 summaryview->mainwin = mainwin;
652 summaryview->folderview = folderview;
653 summaryview->messageview = messageview;
654 summaryview->headerwin = mainwin->headerwin;
655 summaryview->window = window;
657 messageview->mainwin = mainwin;
659 mainwin->window = window;
660 mainwin->vbox = vbox;
661 mainwin->menubar = menubar;
662 mainwin->handlebox = handlebox;
663 mainwin->vbox_body = vbox_body;
664 mainwin->hbox_stat = hbox_stat;
665 mainwin->statusbar = statusbar;
666 mainwin->ac_button = ac_button;
667 mainwin->ac_label = ac_label;
669 /* set context IDs for status bar */
670 mainwin->mainwin_cid = gtk_statusbar_get_context_id
671 (GTK_STATUSBAR(statusbar), "Main Window");
672 mainwin->folderview_cid = gtk_statusbar_get_context_id
673 (GTK_STATUSBAR(statusbar), "Folder View");
674 mainwin->summaryview_cid = gtk_statusbar_get_context_id
675 (GTK_STATUSBAR(statusbar), "Summary View");
677 /* allocate colors for summary view and folder view */
678 summaryview->color_marked.red = summaryview->color_marked.green = 0;
679 summaryview->color_marked.blue = (guint16)65535;
681 summaryview->color_dim.red = summaryview->color_dim.green =
682 summaryview->color_dim.blue = COLOR_DIM;
684 summaryview->color_normal.red = summaryview->color_normal.green =
685 summaryview->color_normal.blue = 0;
687 folderview->color_new.red = (guint16)55000;
688 folderview->color_new.green = folderview->color_new.blue = 15000;
690 folderview->color_normal.red = folderview->color_normal.green =
691 folderview->color_normal.blue = 0;
693 summaryview->color_important.red = 0;
694 summaryview->color_marked.green = 0;
695 summaryview->color_important.blue = (guint16)65535;
697 color[0] = summaryview->color_marked;
698 color[1] = summaryview->color_dim;
699 color[2] = summaryview->color_normal;
700 color[3] = folderview->color_new;
701 color[4] = folderview->color_normal;
703 colormap = gdk_window_get_colormap(window->window);
704 gdk_colormap_alloc_colors(colormap, color, 5, FALSE, TRUE, success);
705 for (i = 0; i < 5; i++) {
706 if (success[i] == FALSE)
707 g_warning(_("MainWindow: color allocation %d failed\n"), i);
710 debug_print(_("done.\n"));
712 main_window_set_widgets(mainwin, type);
715 ifactory = gtk_item_factory_from_widget(menubar);
716 menuitem = gtk_item_factory_get_item
717 (ifactory, "/View/Code set/Auto detect");
718 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
720 switch (prefs_common.toolbar_style) {
722 menuitem = gtk_item_factory_get_item
723 (ifactory, "/View/Toolbar/None");
726 menuitem = gtk_item_factory_get_item
727 (ifactory, "/View/Toolbar/Icon");
730 menuitem = gtk_item_factory_get_item
731 (ifactory, "/View/Toolbar/Text");
734 menuitem = gtk_item_factory_get_item
735 (ifactory, "/View/Toolbar/Icon and text");
737 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
739 gtk_widget_hide(mainwin->hbox_stat);
740 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
741 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
742 prefs_common.show_statusbar);
744 /* set the check of the SEPARATE_xxx menu items. we also need the main window
745 * as a property and pass the action type to the callback */
746 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
748 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
749 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
750 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
751 GUINT_TO_POINTER(SEPARATE_FOLDER));
753 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
755 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
756 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
757 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
758 GUINT_TO_POINTER(SEPARATE_MESSAGE));
761 menu_set_sensitive(ifactory, "/Summary/Thread view",
762 prefs_common.enable_thread ? FALSE : TRUE);
763 menu_set_sensitive(ifactory, "/Summary/Unthread view",
764 prefs_common.enable_thread ? TRUE : FALSE);
766 main_window_set_thread_option(mainwin);
768 menu_set_sensitive(ifactory, "/Help/Manual/English", FALSE);
770 /* set account selection menu */
771 ac_menu = gtk_item_factory_get_widget
772 (ifactory, "/Configuration/Change current account");
773 mainwin->ac_menu = ac_menu;
775 main_window_set_toolbar_sensitive(mainwin, FALSE);
777 /* show main window */
778 gtk_widget_set_uposition(mainwin->window,
779 prefs_common.mainwin_x,
780 prefs_common.mainwin_y);
781 gtk_widget_set_usize(window, prefs_common.mainwin_width,
782 prefs_common.mainwin_height);
783 gtk_widget_show(mainwin->window);
785 /* initialize views */
786 folderview_init(folderview);
787 summary_init(summaryview);
788 messageview_init(messageview);
789 header_window_init(mainwin->headerwin);
790 log_window_init(mainwin->logwin);
792 mainwin->cursor_count = 0;
795 watch_cursor = gdk_cursor_new(GDK_WATCH);
797 mainwin_list = g_list_append(mainwin_list, mainwin);
802 void main_window_cursor_wait(MainWindow *mainwin)
804 if (mainwin->cursor_count == 0)
805 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
807 mainwin->cursor_count++;
812 void main_window_cursor_normal(MainWindow *mainwin)
814 if (mainwin->cursor_count)
815 mainwin->cursor_count--;
817 if (mainwin->cursor_count == 0)
818 gdk_window_set_cursor(mainwin->window->window, NULL);
823 void main_window_reflect_prefs_all(void)
828 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
829 mainwin = (MainWindow *)cur->data;
831 main_window_show_cur_account(mainwin);
833 gtk_widget_set_sensitive(mainwin->get_btn, TRUE);
834 gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
836 gtk_widget_set_sensitive(mainwin->get_btn, FALSE);
837 gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
840 if (prefs_common.immediate_exec)
841 gtk_widget_hide(mainwin->exec_btn);
843 gtk_widget_show(mainwin->exec_btn);
845 summary_change_display_item(mainwin->summaryview);
846 summary_redisplay_msg(mainwin->summaryview);
847 headerview_set_visibility(mainwin->messageview->headerview,
848 prefs_common.display_header_pane);
852 void main_window_set_account_menu(GList *account_list)
854 GList *cur, *cur_ac, *cur_item;
857 PrefsAccount *ac_prefs;
859 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
860 mainwin = (MainWindow *)cur->data;
862 /* destroy all previous menu item */
863 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
864 while (cur_item != NULL) {
865 GList *next = cur_item->next;
866 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
870 for (cur_ac = account_list; cur_ac != NULL;
871 cur_ac = cur_ac->next) {
872 ac_prefs = (PrefsAccount *)cur_ac->data;
874 menuitem = gtk_menu_item_new_with_label
875 (ac_prefs->account_name
876 ? ac_prefs->account_name : _("Untitled"));
877 gtk_widget_show(menuitem);
878 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
879 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
880 GTK_SIGNAL_FUNC(account_menu_cb),
886 static void main_window_show_cur_account(MainWindow *mainwin)
891 ac_name = g_strdup(cur_account
892 ? (cur_account->account_name
893 ? cur_account->account_name : _("Untitled"))
897 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
899 buf = g_strdup(PROG_VERSION);
900 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
903 buf = g_strdup_printf(_("Current account: %s"), ac_name);
904 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
905 gtk_widget_queue_resize(mainwin->ac_button);
911 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
913 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
914 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
915 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
917 if (mainwin->type == type) return;
919 /* remove widgets from those containers */
920 gtk_widget_ref(folder_wid);
921 gtk_widget_ref(summary_wid);
922 gtk_widget_ref(message_wid);
924 (GTK_CONTAINER(folder_wid->parent), folder_wid);
926 (GTK_CONTAINER(summary_wid->parent), summary_wid);
928 (GTK_CONTAINER(message_wid->parent), message_wid);
930 /* clean containers */
931 switch (mainwin->type) {
933 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
935 case SEPARATE_FOLDER:
936 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
937 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
939 case SEPARATE_MESSAGE:
940 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
941 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
944 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
945 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
949 gtk_widget_hide(mainwin->window);
950 main_window_set_widgets(mainwin, type);
951 gtk_widget_show(mainwin->window);
953 gtk_widget_unref(folder_wid);
954 gtk_widget_unref(summary_wid);
955 gtk_widget_unref(message_wid);
958 void main_window_get_size(MainWindow *mainwin)
960 GtkAllocation *allocation;
962 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
964 prefs_common.summaryview_width = allocation->width;
966 if (mainwin->summaryview->msg_is_toggled_on)
967 prefs_common.summaryview_height = allocation->height;
969 prefs_common.mainview_width = allocation->width;
971 allocation = &mainwin->window->allocation;
973 prefs_common.mainview_height = allocation->height;
974 prefs_common.mainwin_width = allocation->width;
975 prefs_common.mainwin_height = allocation->height;
977 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
979 prefs_common.folderview_width = allocation->width;
980 prefs_common.folderview_height = allocation->height;
983 void main_window_get_position(MainWindow *mainwin)
987 gtkut_widget_get_uposition(mainwin->window, &x, &y);
989 prefs_common.mainview_x = x;
990 prefs_common.mainview_y = y;
991 prefs_common.mainwin_x = x;
992 prefs_common.mainwin_y = y;
994 debug_print(_("window position: x = %d, y = %d\n"), x, y);
997 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1002 if (alertpanel(_("Empty trash"),
1003 _("Empty all messages in trash?"),
1004 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1006 manage_window_focus_in(mainwin->window, NULL, NULL);
1009 procmsg_empty_trash();
1011 for (list = folder_get_list(); list != NULL; list = list->next) {
1014 folder = list->data;
1015 if (folder->trash) {
1016 folder_item_scan(folder->trash);
1017 folderview_update_item(folder->trash, TRUE);
1021 if (mainwin->summaryview->folder_item &&
1022 mainwin->summaryview->folder_item->stype == F_TRASH)
1023 gtk_widget_grab_focus(mainwin->folderview->ctree);
1026 void main_window_add_mailbox(MainWindow *mainwin)
1031 path = input_dialog(_("Add mailbox"),
1032 _("Input the location of mailbox.\n"
1033 "If the existing mailbox is specified, it will be\n"
1034 "scanned automatically."),
1037 if (folder_find_from_path(path)) {
1038 alertpanel_error(_("The mailbox `%s' already exists."), path);
1043 if (!strcmp(path, "Mail"))
1044 folder = folder_new(F_MH, _("Mailbox"), path);
1046 folder = folder_new(F_MH, g_basename(path), path);
1050 if (folder->create_tree(folder) < 0) {
1051 alertpanel_error(_("Creation of the mailbox failed.\n"
1052 "Maybe some files already exist, or you don't have the permission to write there."));
1053 folder_destroy(folder);
1058 folder_set_ui_func(folder, scan_tree_func, mainwin);
1059 folder->scan_tree(folder);
1060 folder_set_ui_func(folder, NULL, NULL);
1062 folderview_set(mainwin->folderview);
1065 void main_window_add_mbox(MainWindow *mainwin)
1071 path = input_dialog(_("Add mbox mailbox"),
1072 _("Input the location of mailbox."),
1077 if (folder_find_from_path(path)) {
1078 alertpanel_error(_("The mailbox `%s' already exists."), path);
1084 if (!strcmp(path, "Mail"))
1085 folder = folder_new(F_MBOX, _("Mailbox"), path);
1089 folder = folder_new(F_MBOX, g_basename(path), path);
1092 if (folder->create_tree(folder) < 0) {
1093 alertpanel_error(_("Creation of the mailbox failed."));
1094 folder_destroy(folder);
1100 item = folder_item_new(folder->name, NULL);
1101 item->folder = folder;
1102 folder->node = g_node_new(item);
1104 folder->create_folder(folder, item, "inbox");
1105 folder->create_folder(folder, item, "outbox");
1106 folder->create_folder(folder, item, "queue");
1107 folder->create_folder(folder, item, "draft");
1108 folder->create_folder(folder, item, "trash");
1110 folderview_set(mainwin->folderview);
1113 void main_window_set_toolbar_sensitive(MainWindow *mainwin, gboolean sensitive)
1115 gtk_widget_set_sensitive(mainwin->reply_btn, sensitive);
1116 gtk_widget_set_sensitive(mainwin->replyall_btn, sensitive);
1117 gtk_widget_set_sensitive(mainwin->replysender_btn, sensitive);
1118 gtk_widget_set_sensitive(mainwin->fwd_btn, sensitive);
1119 gtk_widget_set_sensitive(mainwin->exec_btn, sensitive);
1120 gtk_widget_set_sensitive(mainwin->next_btn, sensitive);
1122 if (!mainwin->summaryview->folder_item ||
1123 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1124 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1126 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1129 void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
1131 GtkItemFactory *ifactory;
1135 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1137 if (selection == SUMMARY_SELECTED_SINGLE)
1141 if (!mainwin->summaryview->folder_item ||
1142 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1147 menu_set_sensitive(ifactory, "/File/Save as...", sens);
1148 menu_set_sensitive(ifactory, "/Message/Reply", sens);
1149 menu_set_sensitive(ifactory, "/Message/Reply to sender", sens);
1150 menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
1151 menu_set_sensitive(ifactory, "/Message/Forward", sens);
1152 menu_set_sensitive(ifactory, "/Message/Forward an attachment", sens);
1153 menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
1154 menu_set_sensitive(ifactory, "/Message/Show all header", sens);
1155 menu_set_sensitive(ifactory, "/Message/View source", sens);
1156 if (sens && (!mainwin->summaryview->folder_item ||
1157 mainwin->summaryview->folder_item->stype != F_DRAFT))
1159 menu_set_sensitive(ifactory, "/Message/Re-edit", sens);
1161 if (selection == SUMMARY_SELECTED_SINGLE ||
1162 selection == SUMMARY_SELECTED_MULTIPLE)
1167 menu_set_sensitive(ifactory, "/File/Print..." , sens);
1168 menu_set_sensitive(ifactory, "/Message/Move...", sens && exec);
1169 menu_set_sensitive(ifactory, "/Message/Copy...", sens && exec);
1170 menu_set_sensitive(ifactory, "/Message/Delete" , sens && exec);
1171 menu_set_sensitive(ifactory, "/Message/Mark" , sens);
1173 if (selection != SUMMARY_NONE)
1178 menu_set_sensitive(ifactory, "/Summary/Delete duplicated messages", sens && exec);
1179 menu_set_sensitive(ifactory, "/Summary/Filter messages", sens && exec);
1180 menu_set_sensitive(ifactory, "/Summary/Execute", sens);
1181 menu_set_sensitive(ifactory, "/Summary/Prev message", sens);
1182 menu_set_sensitive(ifactory, "/Summary/Next message", sens);
1183 menu_set_sensitive(ifactory, "/Summary/Next unread message", sens);
1184 menu_set_sensitive(ifactory, "/Summary/Sort", sens);
1187 void main_window_popup(MainWindow *mainwin)
1193 gdk_window_get_origin(mainwin->window->window, &x, &y);
1194 sx = gdk_screen_width();
1195 sy = gdk_screen_height();
1196 x %= sx; if (x < 0) x += sx;
1197 y %= sy; if (y < 0) y += sy;
1198 gdk_window_move(mainwin->window->window, x, y);
1199 gdk_window_raise(mainwin->window->window);
1201 debug_print("window position: x = %d, y = %d\n", x, y);
1203 switch (mainwin->type) {
1204 case SEPARATE_FOLDER:
1205 widget = mainwin->win.sep_folder.folderwin;
1206 gdk_window_get_origin(widget->window, &x, &y);
1207 x %= sx; if (x < 0) x += sx;
1208 y %= sy; if (y < 0) y += sy;
1209 gdk_window_move(widget->window, x, y);
1210 gdk_window_raise(widget->window);
1212 case SEPARATE_MESSAGE:
1213 widget = mainwin->win.sep_message.messagewin;
1214 gdk_window_get_origin(widget->window, &x, &y);
1215 x %= sx; if (x < 0) x += sx;
1216 y %= sy; if (y < 0) y += sy;
1217 gdk_window_move(widget->window, x, y);
1218 gdk_window_raise(widget->window);
1221 widget = mainwin->win.sep_both.folderwin;
1222 gdk_window_get_origin(widget->window, &x, &y);
1223 x %= sx; if (x < 0) x += sx;
1224 y %= sy; if (y < 0) y += sy;
1225 gdk_window_move(widget->window, x, y);
1226 gdk_window_raise(widget->window);
1227 widget = mainwin->win.sep_both.messagewin;
1228 gdk_window_get_origin(widget->window, &x, &y);
1229 x %= sx; if (x < 0) x += sx;
1230 y %= sy; if (y < 0) y += sy;
1231 gdk_window_move(widget->window, x, y);
1232 gdk_window_raise(widget->window);
1238 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1240 GtkWidget *folderwin = NULL;
1241 GtkWidget *messagewin = NULL;
1244 GtkWidget *vbox_body = mainwin->vbox_body;
1246 debug_print(_("Setting widgets..."));
1248 /* create separated window(s) if needed */
1249 if (type & SEPARATE_FOLDER) {
1250 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1251 gtk_window_set_policy(GTK_WINDOW(folderwin),
1253 gtk_widget_set_usize(folderwin, -1,
1254 prefs_common.mainview_height);
1255 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1257 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1258 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1261 if (type & SEPARATE_MESSAGE) {
1262 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1263 gtk_window_set_policy(GTK_WINDOW(messagewin),
1265 gtk_widget_set_usize
1266 (messagewin, prefs_common.mainview_width,
1267 prefs_common.mainview_height
1268 - prefs_common.summaryview_height
1269 + DEFAULT_HEADERVIEW_HEIGHT);
1270 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1272 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1273 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1279 hpaned = gtk_hpaned_new();
1280 gtk_widget_show(hpaned);
1281 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1282 gtk_paned_add1(GTK_PANED(hpaned),
1283 GTK_WIDGET_PTR(mainwin->folderview));
1285 vpaned = gtk_vpaned_new();
1286 if (mainwin->summaryview->msg_is_toggled_on) {
1287 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1288 gtk_paned_add1(GTK_PANED(vpaned),
1289 GTK_WIDGET_PTR(mainwin->summaryview));
1291 gtk_paned_add2(GTK_PANED(hpaned),
1292 GTK_WIDGET_PTR(mainwin->summaryview));
1293 gtk_widget_ref(vpaned);
1295 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1296 prefs_common.summaryview_width,
1297 prefs_common.summaryview_height);
1298 gtk_paned_add2(GTK_PANED(vpaned),
1299 GTK_WIDGET_PTR(mainwin->messageview));
1300 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1301 prefs_common.mainview_width, -1);
1302 gtk_widget_set_usize(mainwin->window,
1303 prefs_common.folderview_width +
1304 prefs_common.mainview_width,
1305 prefs_common.mainwin_height);
1306 gtk_widget_show_all(vpaned);
1308 mainwin->win.sep_none.hpaned = hpaned;
1309 mainwin->win.sep_none.vpaned = vpaned;
1311 case SEPARATE_FOLDER:
1312 vpaned = gtk_vpaned_new();
1313 if (mainwin->summaryview->msg_is_toggled_on) {
1314 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1316 gtk_paned_add1(GTK_PANED(vpaned),
1317 GTK_WIDGET_PTR(mainwin->summaryview));
1319 gtk_box_pack_start(GTK_BOX(vbox_body),
1320 GTK_WIDGET_PTR(mainwin->summaryview),
1322 gtk_widget_ref(vpaned);
1324 gtk_paned_add2(GTK_PANED(vpaned),
1325 GTK_WIDGET_PTR(mainwin->messageview));
1326 gtk_widget_show_all(vpaned);
1327 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1328 prefs_common.summaryview_width,
1329 prefs_common.summaryview_height);
1330 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1331 prefs_common.mainview_width, -1);
1332 gtk_widget_set_usize(mainwin->window,
1333 prefs_common.mainview_width,
1334 prefs_common.mainview_height);
1336 gtk_container_add(GTK_CONTAINER(folderwin),
1337 GTK_WIDGET_PTR(mainwin->folderview));
1339 mainwin->win.sep_folder.folderwin = folderwin;
1340 mainwin->win.sep_folder.vpaned = vpaned;
1342 gtk_widget_show_all(folderwin);
1344 case SEPARATE_MESSAGE:
1345 hpaned = gtk_hpaned_new();
1346 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1348 gtk_paned_add1(GTK_PANED(hpaned),
1349 GTK_WIDGET_PTR(mainwin->folderview));
1350 gtk_paned_add2(GTK_PANED(hpaned),
1351 GTK_WIDGET_PTR(mainwin->summaryview));
1352 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1353 prefs_common.summaryview_width,
1354 prefs_common.summaryview_height);
1355 gtk_widget_set_usize(mainwin->window,
1356 prefs_common.folderview_width +
1357 prefs_common.mainview_width,
1358 prefs_common.mainwin_height);
1359 gtk_widget_show_all(hpaned);
1360 gtk_container_add(GTK_CONTAINER(messagewin),
1361 GTK_WIDGET_PTR(mainwin->messageview));
1363 mainwin->win.sep_message.messagewin = messagewin;
1364 mainwin->win.sep_message.hpaned = hpaned;
1366 gtk_widget_show_all(messagewin);
1369 gtk_box_pack_start(GTK_BOX(vbox_body),
1370 GTK_WIDGET_PTR(mainwin->summaryview),
1372 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1373 prefs_common.summaryview_width,
1374 prefs_common.summaryview_height);
1375 gtk_widget_set_usize(mainwin->window,
1376 prefs_common.mainview_width,
1377 prefs_common.mainwin_height);
1378 gtk_container_add(GTK_CONTAINER(folderwin),
1379 GTK_WIDGET_PTR(mainwin->folderview));
1380 gtk_container_add(GTK_CONTAINER(messagewin),
1381 GTK_WIDGET_PTR(mainwin->messageview));
1383 mainwin->win.sep_both.folderwin = folderwin;
1384 mainwin->win.sep_both.messagewin = messagewin;
1386 gtk_widget_show_all(folderwin);
1387 gtk_widget_show_all(messagewin);
1391 mainwin->type = type;
1393 debug_print(_("done.\n"));
1396 #include "pixmaps/stock_mail_receive.xpm"
1397 #include "pixmaps/stock_mail_receive_all.xpm"
1398 #include "pixmaps/stock_mail_compose.xpm"
1399 #include "pixmaps/stock_mail_reply.xpm"
1400 #include "pixmaps/stock_mail_reply_to_all.xpm"
1401 #include "pixmaps/stock_mail_reply_to_author.xpm"
1402 #include "pixmaps/stock_mail_forward.xpm"
1403 #include "pixmaps/stock_mail_send.xpm"
1404 #include "pixmaps/stock_preferences.xpm"
1405 #include "pixmaps/stock_properties.xpm"
1406 #include "pixmaps/stock_down_arrow.xpm"
1407 #include "pixmaps/stock_close.xpm"
1408 #include "pixmaps/stock_exec.xpm"
1410 #define CREATE_TOOLBAR_ICON(xpm_d) \
1412 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1413 &container->style->white, \
1415 icon_wid = gtk_pixmap_new(icon, mask); \
1418 static void main_window_toolbar_create(MainWindow *mainwin,
1419 GtkWidget *container)
1424 GtkWidget *icon_wid;
1426 GtkWidget *getall_btn;
1427 GtkWidget *compose_btn;
1428 GtkWidget *reply_btn;
1429 GtkWidget *replyall_btn;
1430 GtkWidget *replysender_btn;
1432 GtkWidget *send_btn;
1434 GtkWidget *prefs_btn;
1435 GtkWidget *account_btn;
1437 GtkWidget *next_btn;
1438 GtkWidget *delete_btn;
1439 GtkWidget *exec_btn;
1441 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1443 gtk_container_add(GTK_CONTAINER(container), toolbar);
1444 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1445 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1446 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1447 GTK_TOOLBAR_SPACE_LINE);
1449 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1450 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1452 _("Incorporate new mail"),
1454 icon_wid, toolbar_inc_cb, mainwin);
1455 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1456 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1458 _("Incorporate new mail of all accounts"),
1464 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1466 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1467 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1469 _("Send queued message(s)"),
1475 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1477 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1478 compose_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1480 _("Compose new message"),
1485 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1486 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1488 _("Reply to the message"),
1493 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1494 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1499 toolbar_reply_to_all_cb,
1501 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1502 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1504 _("Reply to sender"),
1507 toolbar_reply_to_sender_cb,
1509 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1510 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1512 _("Forward the message"),
1518 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1520 CREATE_TOOLBAR_ICON(stock_close_xpm);
1521 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1523 _("Delete the message"),
1529 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1530 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1532 _("Execute marked process"),
1538 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1539 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1541 _("Next unread message"),
1544 toolbar_next_unread_cb,
1548 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1550 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1551 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1553 _("Common preference"),
1558 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1559 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1561 _("Account setting"),
1566 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1567 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1571 mainwin->toolbar = toolbar;
1572 mainwin->get_btn = get_btn;
1573 mainwin->getall_btn = getall_btn;
1574 mainwin->compose_btn = compose_btn;
1575 mainwin->reply_btn = reply_btn;
1576 mainwin->replyall_btn = replyall_btn;
1577 mainwin->replysender_btn = replysender_btn;
1578 mainwin->fwd_btn = fwd_btn;
1579 mainwin->send_btn = send_btn;
1581 mainwin->prefs_btn = prefs_btn;
1582 mainwin->account_btn = account_btn;
1584 mainwin->next_btn = next_btn;
1585 mainwin->delete_btn = delete_btn;
1586 mainwin->exec_btn = exec_btn;
1588 gtk_widget_show_all(toolbar);
1591 /* callback functions */
1593 static void toolbar_inc_cb (GtkWidget *widget,
1596 MainWindow *mainwin = (MainWindow *)data;
1598 inc_mail_cb(mainwin, 0, NULL);
1601 static void toolbar_inc_all_cb (GtkWidget *widget,
1604 MainWindow *mainwin = (MainWindow *)data;
1606 inc_all_account_mail_cb(mainwin, 0, NULL);
1609 static void toolbar_send_cb (GtkWidget *widget,
1612 MainWindow *mainwin = (MainWindow *)data;
1614 send_queue_cb(mainwin, 0, NULL);
1617 static void toolbar_compose_cb (GtkWidget *widget,
1620 MainWindow *mainwin = (MainWindow *)data;
1622 compose_cb(mainwin, 0, NULL);
1625 static void toolbar_reply_cb (GtkWidget *widget,
1628 MainWindow *mainwin = (MainWindow *)data;
1630 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1633 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1636 MainWindow *mainwin = (MainWindow *)data;
1638 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1641 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1644 MainWindow *mainwin = (MainWindow *)data;
1646 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1649 static void toolbar_forward_cb (GtkWidget *widget,
1652 MainWindow *mainwin = (MainWindow *)data;
1654 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1657 static void toolbar_delete_cb (GtkWidget *widget,
1660 MainWindow *mainwin = (MainWindow *)data;
1662 summary_delete(mainwin->summaryview);
1665 static void toolbar_exec_cb (GtkWidget *widget,
1668 MainWindow *mainwin = (MainWindow *)data;
1670 summary_execute(mainwin->summaryview);
1673 static void toolbar_next_unread_cb (GtkWidget *widget,
1676 MainWindow *mainwin = (MainWindow *)data;
1678 next_unread_cb(mainwin, 0, NULL);
1681 static void toolbar_prefs_cb (GtkWidget *widget,
1684 prefs_common_open();
1687 static void toolbar_account_cb (GtkWidget *widget,
1690 MainWindow *mainwin = (MainWindow *)data;
1692 prefs_account_open_cb(mainwin, 0, NULL);
1695 static void toolbar_account_button_pressed(GtkWidget *widget,
1696 GdkEventButton *event,
1699 MainWindow *mainwin = (MainWindow *)data;
1702 if (event->button != 3) return;
1704 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1705 event->button, event->time);
1708 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1711 MainWindow *mainwin = (MainWindow *)data;
1715 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1716 event->button, event->time);
1719 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1722 app_exit_cb(data, 0, widget);
1727 static void add_mailbox_cb(MainWindow *mainwin, guint action,
1730 main_window_add_mailbox(mainwin);
1733 static void add_mbox_cb(MainWindow *mainwin, guint action,
1736 main_window_add_mbox(mainwin);
1739 static void update_folderview_cb(MainWindow *mainwin, guint action,
1742 summary_show(mainwin->summaryview, NULL, FALSE);
1743 folderview_update_all();
1746 static void new_folder_cb(MainWindow *mainwin, guint action,
1749 folderview_new_folder(mainwin->folderview);
1752 static void rename_folder_cb(MainWindow *mainwin, guint action,
1755 folderview_rename_folder(mainwin->folderview);
1758 static void delete_folder_cb(MainWindow *mainwin, guint action,
1761 folderview_delete_folder(mainwin->folderview);
1764 static void import_mbox_cb(MainWindow *mainwin, guint action,
1767 import_mbox(mainwin->summaryview->folder_item);
1770 static void export_mbox_cb(MainWindow *mainwin, guint action,
1773 export_mbox(mainwin->summaryview->folder_item);
1776 static void empty_trash_cb(MainWindow *mainwin, guint action,
1779 main_window_empty_trash(mainwin, TRUE);
1782 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1784 summary_save_as(mainwin->summaryview);
1787 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1789 summary_print(mainwin->summaryview);
1792 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1794 if (prefs_common.confirm_on_exit) {
1795 if (alertpanel(_("Exit"), _("Exit this program?"),
1796 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
1798 manage_window_focus_in(mainwin->window, NULL, NULL);
1801 app_will_exit(widget, mainwin);
1804 static void toggle_folder_cb(MainWindow *mainwin, guint action,
1807 switch (mainwin->type) {
1809 case SEPARATE_MESSAGE:
1811 case SEPARATE_FOLDER:
1812 if (GTK_CHECK_MENU_ITEM(widget)->active)
1813 gtk_widget_show(mainwin->win.sep_folder.folderwin);
1815 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1818 if (GTK_CHECK_MENU_ITEM(widget)->active)
1819 gtk_widget_show(mainwin->win.sep_both.folderwin);
1821 gtk_widget_hide(mainwin->win.sep_both.folderwin);
1826 static void toggle_message_cb(MainWindow *mainwin, guint action,
1829 switch (mainwin->type) {
1831 case SEPARATE_FOLDER:
1833 case SEPARATE_MESSAGE:
1834 if (GTK_CHECK_MENU_ITEM(widget)->active)
1835 gtk_widget_show(mainwin->win.sep_message.messagewin);
1837 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1840 if (GTK_CHECK_MENU_ITEM(widget)->active)
1841 gtk_widget_show(mainwin->win.sep_both.messagewin);
1843 gtk_widget_hide(mainwin->win.sep_both.messagewin);
1848 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
1851 switch ((ToolbarStyle)action) {
1853 gtk_widget_hide(mainwin->handlebox);
1855 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1859 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1863 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1868 if (action != TOOLBAR_NONE) {
1869 gtk_widget_show(mainwin->handlebox);
1870 gtk_widget_queue_resize(mainwin->handlebox);
1873 mainwin->toolbar_style = (ToolbarStyle)action;
1874 prefs_common.toolbar_style = (ToolbarStyle)action;
1877 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
1880 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1881 gtk_widget_show(mainwin->hbox_stat);
1882 prefs_common.show_statusbar = TRUE;
1884 gtk_widget_hide(mainwin->hbox_stat);
1885 prefs_common.show_statusbar = FALSE;
1889 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action)
1891 MainWindow *mainwin;
1894 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
1895 g_return_if_fail(mainwin != NULL);
1897 type = mainwin->type ^ action;
1898 main_window_separation_change(mainwin, type);
1900 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
1901 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
1904 static void addressbook_open_cb(MainWindow *mainwin, guint action,
1907 addressbook_open(NULL);
1910 static void log_window_show_cb(MainWindow *mainwin, guint action,
1913 log_window_show(mainwin->logwin);
1916 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1921 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
1924 inc_all_account_mail(mainwin);
1927 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1931 if (procmsg_send_queue() < 0)
1932 alertpanel_error(_("Sending queued message failed."));
1934 statusbar_pop_all();
1936 for (list = folder_get_list(); list != NULL; list = list->next) {
1939 folder = list->data;
1940 if (folder->queue) {
1941 folder_item_scan(folder->queue);
1942 folderview_update_item(folder->queue, TRUE);
1947 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1949 if (mainwin->summaryview->folder_item) {
1950 if (mainwin->summaryview->folder_item->folder->account != NULL
1951 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
1952 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
1954 compose_new(mainwin->summaryview->folder_item->folder->account);
1960 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1964 msginfo = gtk_ctree_node_get_row_data
1965 (GTK_CTREE(mainwin->summaryview->ctree),
1966 mainwin->summaryview->selected);
1968 if (!msginfo) return;
1972 compose_reply(msginfo, prefs_common.reply_with_quote,
1975 case COMPOSE_REPLY_TO_SENDER:
1976 compose_reply(msginfo, prefs_common.reply_with_quote,
1979 case COMPOSE_REPLY_TO_ALL:
1980 compose_reply(msginfo, prefs_common.reply_with_quote,
1983 case COMPOSE_FORWARD:
1984 compose_forward(NULL, msginfo, FALSE);
1986 case COMPOSE_FORWARD_AS_ATTACH:
1987 compose_forward(NULL, msginfo, TRUE);
1990 g_warning("reply_cb(): invalid action type: %d\n", action);
1993 summary_set_marks_selected(mainwin->summaryview);
1996 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1998 summary_move_to(mainwin->summaryview);
2001 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2003 summary_copy_to(mainwin->summaryview);
2006 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2008 summary_delete(mainwin->summaryview);
2011 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2013 summary_open_msg(mainwin->summaryview);
2016 static void view_source_cb(MainWindow *mainwin, guint action,
2019 summary_view_source(mainwin->summaryview);
2022 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2024 summary_reedit(mainwin->summaryview);
2027 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2029 summary_mark(mainwin->summaryview);
2032 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2034 summary_unmark(mainwin->summaryview);
2037 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2040 summary_mark_as_unread(mainwin->summaryview);
2043 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2046 summary_mark_as_read(mainwin->summaryview);
2049 static void set_charset_cb(MainWindow *mainwin, guint action,
2054 str = conv_get_charset_str((CharSet)action);
2055 g_free(prefs_common.force_charset);
2056 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2058 summary_redisplay_msg(mainwin->summaryview);
2060 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2063 void main_window_set_thread_option(MainWindow *mainwin)
2065 GtkItemFactory *ifactory;
2066 gboolean no_item = FALSE;
2068 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2070 if (mainwin->summaryview == NULL)
2072 else if (mainwin->summaryview->folder_item == NULL)
2076 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2077 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2080 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2081 menu_set_sensitive(ifactory,
2082 "/Summary/Thread view", FALSE);
2083 menu_set_sensitive(ifactory,
2084 "/Summary/Unthread view", TRUE);
2085 summary_thread_build(mainwin->summaryview);
2088 menu_set_sensitive(ifactory,
2089 "/Summary/Thread view", TRUE);
2090 menu_set_sensitive(ifactory,
2091 "/Summary/Unthread view", FALSE);
2092 summary_unthread(mainwin->summaryview);
2094 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2098 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2100 mainwin->summaryview->folder_item->prefs->enable_thread =
2101 !mainwin->summaryview->folder_item->prefs->enable_thread;
2102 main_window_set_thread_option(mainwin);
2106 summary_thread_build(mainwin->summaryview);
2107 mainwin->summaryview->folder_item->prefs->enable_thread =
2109 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2110 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2112 summary_unthread(mainwin->summaryview);
2113 mainwin->summaryview->folder_item->prefs->enable_thread =
2115 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2116 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2121 static void set_display_item_cb(MainWindow *mainwin, guint action,
2124 prefs_summary_display_item_set();
2127 static void sort_summary_cb(MainWindow *mainwin, guint action,
2130 summary_sort(mainwin->summaryview, (SummarySortType)action);
2133 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2136 summary_attract_by_subject(mainwin->summaryview);
2139 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2142 summary_delete_duplicated(mainwin->summaryview);
2145 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2147 summary_filter(mainwin->summaryview);
2150 static void execute_summary_cb(MainWindow *mainwin, guint action,
2153 summary_execute(mainwin->summaryview);
2156 static void update_summary_cb(MainWindow *mainwin, guint action,
2160 FolderView *folderview = mainwin->folderview;
2162 if (!mainwin->summaryview->folder_item) return;
2163 if (!folderview->opened) return;
2165 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2166 folderview->opened);
2169 summary_show(mainwin->summaryview, fitem, TRUE);
2172 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2174 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2177 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2179 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2182 static void next_unread_cb(MainWindow *mainwin, guint action,
2185 summary_select_next_unread(mainwin->summaryview);
2188 static void next_marked_cb(MainWindow *mainwin, guint action,
2191 summary_select_next_marked(mainwin->summaryview);
2194 static void prev_marked_cb(MainWindow *mainwin, guint action,
2197 summary_select_prev_marked(mainwin->summaryview);
2200 static void goto_folder_cb(MainWindow *mainwin, guint action,
2203 FolderItem *to_folder;
2205 to_folder = foldersel_folder_sel(NULL);
2208 folderview_select(mainwin->folderview, to_folder);
2211 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2213 messageview_copy_clipboard(mainwin->messageview);
2216 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2218 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2219 summary_select_all(mainwin->summaryview);
2220 else if (mainwin->summaryview->msg_is_toggled_on &&
2221 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2222 messageview_select_all(mainwin->messageview);
2225 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2228 prefs_common_open();
2231 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2234 prefs_filter_open();
2237 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2240 prefs_scoring_open(NULL);
2243 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2246 prefs_filtering_open();
2249 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2253 new_account_cb(mainwin, 0, widget);
2255 gboolean prev_default = cur_account->is_default;
2257 prefs_account_open(cur_account);
2258 if (!prev_default && cur_account->is_default)
2259 account_set_as_default(cur_account);
2260 account_save_config_all();
2262 main_window_reflect_prefs_all();
2266 static void new_account_cb(MainWindow *mainwin, guint action,
2269 account_edit_open();
2270 if (!compose_get_compose_list()) account_add();
2273 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2275 cur_account = (PrefsAccount *)data;
2276 main_window_reflect_prefs_all();
2279 static void manual_open_cb(MainWindow *mainwin, guint action,
2282 manual_open((ManualLang)action);
2285 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2287 MainWindow *mainwin = (MainWindow *)data;
2291 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2292 LOCAL_FOLDER(folder)->rootpath,
2296 str = g_strdup_printf(_("Scanning folder %s ..."),
2297 LOCAL_FOLDER(folder)->rootpath);
2299 STATUSBAR_PUSH(mainwin, str);
2300 STATUSBAR_POP(mainwin);