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_scoring.h"
61 #include "prefs_account.h"
62 #include "prefs_folder_item.h"
64 #include "addressbook.h"
65 #include "headerwindow.h"
66 #include "logwindow.h"
67 #include "manage_window.h"
68 #include "alertpanel.h"
69 #include "statusbar.h"
70 #include "inputdialog.h"
77 #define AC_LABEL_WIDTH 240
79 #define STATUSBAR_PUSH(mainwin, str) \
81 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
82 mainwin->mainwin_cid, str); \
83 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
86 #define STATUSBAR_POP(mainwin) \
88 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
89 mainwin->mainwin_cid); \
92 /* list of all instantiated MainWindow */
93 static GList *mainwin_list = NULL;
95 static GdkCursor *watch_cursor;
97 static void main_window_show_cur_account (MainWindow *mainwin);
99 static void main_window_set_widgets (MainWindow *mainwin,
101 static void main_window_toolbar_create (MainWindow *mainwin,
102 GtkWidget *container);
104 /* callback functions */
105 static void toolbar_inc_cb (GtkWidget *widget,
107 static void toolbar_inc_all_cb (GtkWidget *widget,
109 static void toolbar_send_cb (GtkWidget *widget,
112 static void toolbar_compose_cb (GtkWidget *widget,
114 static void toolbar_reply_cb (GtkWidget *widget,
116 static void toolbar_reply_to_all_cb (GtkWidget *widget,
118 static void toolbar_reply_to_author_cb (GtkWidget *widget,
120 static void toolbar_forward_cb (GtkWidget *widget,
123 static void toolbar_delete_cb (GtkWidget *widget,
125 static void toolbar_exec_cb (GtkWidget *widget,
128 static void toolbar_next_unread_cb (GtkWidget *widget,
131 static void toolbar_prefs_cb (GtkWidget *widget,
133 static void toolbar_account_cb (GtkWidget *widget,
136 static void toolbar_account_button_pressed (GtkWidget *widget,
137 GdkEventButton *event,
139 static void ac_label_button_pressed (GtkWidget *widget,
140 GdkEventButton *event,
143 static gint main_window_close_cb (GtkWidget *widget,
147 static void add_mailbox_cb (MainWindow *mainwin,
150 static void update_folderview_cb (MainWindow *mainwin,
153 static void new_folder_cb (MainWindow *mainwin,
156 static void rename_folder_cb (MainWindow *mainwin,
159 static void delete_folder_cb (MainWindow *mainwin,
162 static void import_mbox_cb (MainWindow *mainwin,
165 static void export_mbox_cb (MainWindow *mainwin,
168 static void empty_trash_cb (MainWindow *mainwin,
172 static void save_as_cb (MainWindow *mainwin,
175 static void print_cb (MainWindow *mainwin,
178 static void app_exit_cb (MainWindow *mainwin,
182 static void toggle_folder_cb (MainWindow *mainwin,
185 static void toggle_message_cb (MainWindow *mainwin,
188 static void toggle_toolbar_cb (MainWindow *mainwin,
191 static void toggle_statusbar_cb (MainWindow *mainwin,
194 static void separate_widget_cb (MainWindow *mainwin,
198 static void addressbook_open_cb (MainWindow *mainwin,
201 static void log_window_show_cb (MainWindow *mainwin,
205 static void inc_mail_cb (MainWindow *mainwin,
208 static void inc_all_account_mail_cb (MainWindow *mainwin,
212 static void send_queue_cb (MainWindow *mainwin,
216 static void compose_cb (MainWindow *mainwin,
219 static void reply_cb (MainWindow *mainwin,
223 static void open_msg_cb (MainWindow *mainwin,
227 static void view_source_cb (MainWindow *mainwin,
231 static void reedit_cb (MainWindow *mainwin,
235 static void move_to_cb (MainWindow *mainwin,
238 static void copy_to_cb (MainWindow *mainwin,
241 static void delete_cb (MainWindow *mainwin,
245 static void mark_cb (MainWindow *mainwin,
248 static void unmark_cb (MainWindow *mainwin,
252 static void mark_as_unread_cb (MainWindow *mainwin,
255 static void mark_as_read_cb (MainWindow *mainwin,
259 static void set_charset_cb (MainWindow *mainwin,
263 static void thread_cb (MainWindow *mainwin,
266 static void set_display_item_cb (MainWindow *mainwin,
269 static void sort_summary_cb (MainWindow *mainwin,
272 static void attract_by_subject_cb(MainWindow *mainwin,
276 static void delete_duplicated_cb (MainWindow *mainwin,
279 static void filter_cb (MainWindow *mainwin,
282 static void execute_summary_cb (MainWindow *mainwin,
285 static void update_summary_cb (MainWindow *mainwin,
289 static void prev_cb (MainWindow *mainwin,
292 static void next_cb (MainWindow *mainwin,
296 static void next_unread_cb (MainWindow *mainwin,
300 static void next_marked_cb (MainWindow *mainwin,
304 static void prev_marked_cb (MainWindow *mainwin,
308 static void goto_folder_cb (MainWindow *mainwin,
312 static void copy_cb (MainWindow *mainwin,
315 static void allsel_cb (MainWindow *mainwin,
319 static void prefs_common_open_cb (MainWindow *mainwin,
322 static void prefs_filter_open_cb (MainWindow *mainwin,
325 static void prefs_scoring_open_cb (MainWindow *mainwin,
328 static void prefs_filtering_open_cb (MainWindow *mainwin,
331 static void prefs_account_open_cb(MainWindow *mainwin,
334 static void new_account_cb (MainWindow *mainwin,
338 static void account_menu_cb (GtkMenuItem *menuitem,
341 static void manual_open_cb (MainWindow *mainwin,
345 static void scan_tree_func (Folder *folder,
349 static GtkItemFactoryEntry mainwin_entries[] =
351 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
352 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
353 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
354 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
355 {N_("/_File/_Folder/Create _new folder..."),
356 NULL, new_folder_cb, 0, NULL},
357 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
358 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
359 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
360 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
361 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
362 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
363 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
364 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
365 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
366 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
367 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
369 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
370 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
371 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
372 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
373 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
375 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
376 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
377 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
378 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
379 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
380 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
381 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
382 {N_("/_View/_Toolbar/_Non-display"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
383 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
384 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
385 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
386 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
387 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
388 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
389 {N_("/_View/_Code set/_Auto detect"),
390 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
392 #define CODESET_SEPARATOR \
393 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
394 #define CODESET_ACTION(action) \
395 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
397 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
398 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
399 CODESET_ACTION(C_US_ASCII)},
402 {N_("/_View/_Code set/Unicode (_UTF-8)"),
403 CODESET_ACTION(C_UTF_8)},
406 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
407 CODESET_ACTION(C_ISO_8859_1)},
410 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
411 CODESET_ACTION(C_ISO_8859_2)},
413 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
414 CODESET_ACTION(C_ISO_8859_13)},
415 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
416 CODESET_ACTION(C_ISO_8859_4)},
418 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
419 CODESET_ACTION(C_ISO_8859_7)},
421 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
422 CODESET_ACTION(C_ISO_8859_9)},
424 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
425 CODESET_ACTION(C_ISO_8859_5)},
426 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
427 CODESET_ACTION(C_KOI8_R)},
428 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
429 CODESET_ACTION(C_CP1251)},
432 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
433 CODESET_ACTION(C_ISO_2022_JP)},
435 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
436 CODESET_ACTION(C_ISO_2022_JP_2)},
438 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
439 CODESET_ACTION(C_EUC_JP)},
440 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
441 CODESET_ACTION(C_SHIFT_JIS)},
444 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
445 CODESET_ACTION(C_GB2312)},
446 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
447 CODESET_ACTION(C_BIG5)},
448 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
449 CODESET_ACTION(C_EUC_TW)},
450 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
451 CODESET_ACTION(C_ISO_2022_CN)},
453 {N_("/_View/_Code set/Korean (EUC-_KR)"),
454 CODESET_ACTION(C_EUC_KR)},
455 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
456 CODESET_ACTION(C_ISO_2022_KR)},
459 #undef CODESET_SEPARATOR
460 #undef CODESET_ACTION
462 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
463 {N_("/_Message/Rece_ive new mail"), "<alt>I", inc_mail_cb, 0, NULL},
464 {N_("/_Message/Receive from _all accounts"),
465 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
466 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
467 {N_("/_Message/Send queued messa_ges"),
468 NULL, send_queue_cb, 0, NULL},
469 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
470 {N_("/_Message/Compose _new message"), "<alt>N", compose_cb, 0, NULL},
471 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
472 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
473 {N_("/_Message/Reply to author"), NULL, reply_cb, COMPOSE_REPLY_TO_AUTHOR, NULL},
474 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
475 {N_("/_Message/Forward as an a_ttachment"),
476 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
477 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
479 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
480 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
481 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
482 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
483 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
484 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
486 {N_("/_Message/_Mark/Mark it as _being read"),
487 NULL, mark_as_read_cb, 0, NULL},
488 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
489 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
490 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
491 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
492 {N_("/_Message/Re_edit"), NULL, reedit_cb, 0, NULL},
494 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
495 {N_("/_Summary/_Delete duplicated messages"),
496 NULL, delete_duplicated_cb, 0, NULL},
497 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
498 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
499 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
500 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
501 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
502 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
503 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
504 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
505 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
506 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
507 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
508 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
509 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
510 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
511 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
512 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
513 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
514 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
515 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
516 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
517 {N_("/_Summary/_Sort/_Attract by subject"),
518 NULL, attract_by_subject_cb, 0, NULL},
519 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
520 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
521 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
523 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
524 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
525 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
527 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
528 {N_("/_Configuration/_Common preferences..."),
529 NULL, prefs_common_open_cb, 0, NULL},
530 {N_("/_Configuration/_Filter setting..."),
531 NULL, prefs_filter_open_cb, 0, NULL},
532 {N_("/_Configuration/_Scoring ..."),
533 NULL, prefs_scoring_open_cb, 0, NULL},
534 {N_("/_Configuration/_Filtering ..."),
535 NULL, prefs_filtering_open_cb, 0, NULL},
536 {N_("/_Configuration/_Preferences per account..."),
537 NULL, prefs_account_open_cb, 0, NULL},
538 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_Configuration/Create _new account..."),
540 NULL, new_account_cb, 0, NULL},
541 {N_("/_Configuration/_Edit accounts..."),
542 NULL, account_edit_open, 0, NULL},
543 {N_("/_Configuration/C_hange current account"),
544 NULL, NULL, 0, "<Branch>"},
546 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
547 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
548 {N_("/_Help/_Manual/_English"), NULL, NULL, MANUAL_LANG_EN, NULL},
549 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
550 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
551 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
554 MainWindow *main_window_create(SeparateType type)
560 GtkWidget *handlebox;
561 GtkWidget *vbox_body;
562 GtkWidget *hbox_stat;
563 GtkWidget *statusbar;
564 GtkWidget *ac_button;
567 FolderView *folderview;
568 SummaryView *summaryview;
569 MessageView *messageview;
570 GdkColormap *colormap;
573 guint n_menu_entries;
574 GtkItemFactory *ifactory;
579 debug_print(_("Creating main window...\n"));
580 mainwin = g_new0(MainWindow, 1);
583 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
584 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
585 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
586 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
587 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
588 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
589 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
590 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
591 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
592 gtk_widget_realize(window);
594 vbox = gtk_vbox_new(FALSE, 0);
595 gtk_widget_show(vbox);
596 gtk_container_add(GTK_CONTAINER(window), vbox);
599 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
600 menubar = menubar_create(window, mainwin_entries,
601 n_menu_entries, "<Main>", mainwin);
602 gtk_widget_show(menubar);
603 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
605 handlebox = gtk_handle_box_new();
606 gtk_widget_show(handlebox);
607 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
609 main_window_toolbar_create(mainwin, handlebox);
611 /* vbox that contains body */
612 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
613 gtk_widget_show(vbox_body);
614 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
615 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
617 hbox_stat = gtk_hbox_new(FALSE, 2);
618 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
620 statusbar = statusbar_create();
621 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
623 ac_button = gtk_button_new();
624 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
625 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
626 gtk_widget_set_usize(ac_button, -1, 1);
627 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
628 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
629 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
631 ac_label = gtk_label_new("");
632 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
634 gtk_widget_show_all(hbox_stat);
637 mainwin->folderview = folderview = folderview_create();
638 mainwin->summaryview = summaryview = summary_create();
639 mainwin->messageview = messageview = messageview_create();
640 mainwin->headerwin = header_window_create();
641 mainwin->logwin = log_window_create();
643 folderview->mainwin = mainwin;
644 folderview->summaryview = summaryview;
646 summaryview->mainwin = mainwin;
647 summaryview->folderview = folderview;
648 summaryview->messageview = messageview;
649 summaryview->headerwin = mainwin->headerwin;
650 summaryview->window = window;
652 messageview->mainwin = mainwin;
654 mainwin->window = window;
655 mainwin->vbox = vbox;
656 mainwin->menubar = menubar;
657 mainwin->handlebox = handlebox;
658 mainwin->vbox_body = vbox_body;
659 mainwin->hbox_stat = hbox_stat;
660 mainwin->statusbar = statusbar;
661 mainwin->ac_button = ac_button;
662 mainwin->ac_label = ac_label;
664 /* set context IDs for status bar */
665 mainwin->mainwin_cid = gtk_statusbar_get_context_id
666 (GTK_STATUSBAR(statusbar), "Main Window");
667 mainwin->folderview_cid = gtk_statusbar_get_context_id
668 (GTK_STATUSBAR(statusbar), "Folder View");
669 mainwin->summaryview_cid = gtk_statusbar_get_context_id
670 (GTK_STATUSBAR(statusbar), "Summary View");
672 /* allocate colors for summary view and folder view */
673 summaryview->color_marked.red = summaryview->color_marked.green = 0;
674 summaryview->color_marked.blue = (guint16)65535;
676 summaryview->color_dim.red = summaryview->color_dim.green =
677 summaryview->color_dim.blue = COLOR_DIM;
679 summaryview->color_normal.red = summaryview->color_normal.green =
680 summaryview->color_normal.blue = 0;
682 folderview->color_new.red = (guint16)55000;
683 folderview->color_new.green = folderview->color_new.blue = 15000;
685 folderview->color_normal.red = folderview->color_normal.green =
686 folderview->color_normal.blue = 0;
688 color[0] = summaryview->color_marked;
689 color[1] = summaryview->color_dim;
690 color[2] = summaryview->color_normal;
691 color[3] = folderview->color_new;
692 color[4] = folderview->color_normal;
694 colormap = gdk_window_get_colormap(window->window);
695 gdk_colormap_alloc_colors(colormap, color, 5, FALSE, TRUE, success);
696 for (i = 0; i < 5; i++) {
697 if (success[i] == FALSE)
698 g_warning(_("MainWindow: color allocation %d failed\n"), i);
701 debug_print(_("done.\n"));
703 main_window_set_widgets(mainwin, type);
706 ifactory = gtk_item_factory_from_widget(menubar);
707 menuitem = gtk_item_factory_get_item
708 (ifactory, "/View/Code set/Auto detect");
709 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
711 switch (prefs_common.toolbar_style) {
713 menuitem = gtk_item_factory_get_item
714 (ifactory, "/View/Toolbar/Non-display");
717 menuitem = gtk_item_factory_get_item
718 (ifactory, "/View/Toolbar/Icon");
721 menuitem = gtk_item_factory_get_item
722 (ifactory, "/View/Toolbar/Text");
725 menuitem = gtk_item_factory_get_item
726 (ifactory, "/View/Toolbar/Icon and text");
728 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
730 gtk_widget_hide(mainwin->hbox_stat);
731 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
732 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
733 prefs_common.show_statusbar);
735 menu_set_sensitive(ifactory, "/Summary/Thread view",
736 prefs_common.enable_thread ? FALSE : TRUE);
737 menu_set_sensitive(ifactory, "/Summary/Unthread view",
738 prefs_common.enable_thread ? TRUE : FALSE);
739 menu_set_sensitive(ifactory, "/Help/Manual/English", FALSE);
741 /* set account selection menu */
742 ac_menu = gtk_item_factory_get_widget
743 (ifactory, "/Configuration/Change current account");
744 mainwin->ac_menu = ac_menu;
746 main_window_set_toolbar_sensitive(mainwin, FALSE);
748 /* show main window */
749 gtk_widget_set_uposition(mainwin->window,
750 prefs_common.mainwin_x,
751 prefs_common.mainwin_y);
752 gtk_widget_set_usize(window, prefs_common.mainwin_width,
753 prefs_common.mainwin_height);
754 gtk_widget_show(mainwin->window);
756 /* initialize views */
757 folderview_init(folderview);
758 summary_init(summaryview);
759 messageview_init(messageview);
760 header_window_init(mainwin->headerwin);
761 log_window_init(mainwin->logwin);
763 mainwin->cursor_count = 0;
766 watch_cursor = gdk_cursor_new(GDK_WATCH);
768 mainwin_list = g_list_append(mainwin_list, mainwin);
773 void main_window_cursor_wait(MainWindow *mainwin)
775 if (mainwin->cursor_count == 0)
776 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
778 mainwin->cursor_count++;
783 void main_window_cursor_normal(MainWindow *mainwin)
785 if (mainwin->cursor_count)
786 mainwin->cursor_count--;
788 if (mainwin->cursor_count == 0)
789 gdk_window_set_cursor(mainwin->window->window, NULL);
794 void main_window_reflect_prefs_all(void)
799 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
800 mainwin = (MainWindow *)cur->data;
802 main_window_show_cur_account(mainwin);
804 gtk_widget_set_sensitive(mainwin->get_btn, TRUE);
805 gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
807 gtk_widget_set_sensitive(mainwin->get_btn, FALSE);
808 gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
810 if (prefs_common.immediate_exec)
811 gtk_widget_hide(mainwin->exec_btn);
813 gtk_widget_show(mainwin->exec_btn);
815 summary_change_display_item(mainwin->summaryview);
816 summary_redisplay_msg(mainwin->summaryview);
817 headerview_set_visibility(mainwin->messageview->headerview,
818 prefs_common.display_header_pane);
822 void main_window_set_account_menu(GList *account_list)
824 GList *cur, *cur_ac, *cur_item;
827 PrefsAccount *ac_prefs;
829 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
830 mainwin = (MainWindow *)cur->data;
832 /* destroy all previous menu item */
833 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
834 while (cur_item != NULL) {
835 GList *next = cur_item->next;
836 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
840 for (cur_ac = account_list; cur_ac != NULL;
841 cur_ac = cur_ac->next) {
842 ac_prefs = (PrefsAccount *)cur_ac->data;
844 menuitem = gtk_menu_item_new_with_label
845 (ac_prefs->account_name
846 ? ac_prefs->account_name : _("Untitled"));
847 gtk_widget_show(menuitem);
848 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
849 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
850 GTK_SIGNAL_FUNC(account_menu_cb),
856 static void main_window_show_cur_account(MainWindow *mainwin)
861 ac_name = g_strdup(cur_account
862 ? (cur_account->account_name
863 ? cur_account->account_name : _("Untitled"))
867 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
869 buf = g_strdup(PROG_VERSION);
870 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
873 buf = g_strdup_printf(_("Current account: %s"), ac_name);
874 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
875 gtk_widget_queue_resize(mainwin->ac_button);
881 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
883 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
884 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
885 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
887 if (mainwin->type == type) return;
889 /* remove widgets from those containers */
890 gtk_widget_ref(folder_wid);
891 gtk_widget_ref(summary_wid);
892 gtk_widget_ref(message_wid);
894 (GTK_CONTAINER(folder_wid->parent), folder_wid);
896 (GTK_CONTAINER(summary_wid->parent), summary_wid);
898 (GTK_CONTAINER(message_wid->parent), message_wid);
900 /* clean containers */
901 switch (mainwin->type) {
903 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
905 case SEPARATE_FOLDER:
906 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
907 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
909 case SEPARATE_MESSAGE:
910 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
911 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
914 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
915 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
919 gtk_widget_hide(mainwin->window);
920 main_window_set_widgets(mainwin, type);
921 gtk_widget_show(mainwin->window);
923 gtk_widget_unref(folder_wid);
924 gtk_widget_unref(summary_wid);
925 gtk_widget_unref(message_wid);
928 void main_window_get_size(MainWindow *mainwin)
930 GtkAllocation *allocation;
932 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
934 prefs_common.summaryview_width = allocation->width;
936 if (mainwin->summaryview->msg_is_toggled_on)
937 prefs_common.summaryview_height = allocation->height;
939 prefs_common.mainview_width = allocation->width;
941 allocation = &mainwin->window->allocation;
943 prefs_common.mainview_height = allocation->height;
944 prefs_common.mainwin_width = allocation->width;
945 prefs_common.mainwin_height = allocation->height;
947 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
949 prefs_common.folderview_width = allocation->width;
950 prefs_common.folderview_height = allocation->height;
953 void main_window_get_position(MainWindow *mainwin)
957 gtkut_widget_get_uposition(mainwin->window, &x, &y);
959 prefs_common.mainview_x = x;
960 prefs_common.mainview_y = y;
961 prefs_common.mainwin_x = x;
962 prefs_common.mainwin_y = y;
964 debug_print(_("window position: x = %d, y = %d\n"), x, y);
967 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
972 if (alertpanel(_("Empty trash"),
973 _("Empty all messages in trash?"),
974 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
976 manage_window_focus_in(mainwin->window, NULL, NULL);
979 procmsg_empty_trash();
981 for (list = folder_get_list(); list != NULL; list = list->next) {
986 folder_item_scan(folder->trash);
987 folderview_update_item(folder->trash, TRUE);
991 if (mainwin->summaryview->folder_item &&
992 mainwin->summaryview->folder_item->stype == F_TRASH)
993 gtk_widget_grab_focus(mainwin->folderview->ctree);
996 void main_window_add_mailbox(MainWindow *mainwin)
1001 path = input_dialog(_("Add mailbox"),
1002 _("Input the location of mailbox.\n"
1003 "If the existing mailbox is specified, it will be\n"
1004 "scanned automatically."),
1007 if (folder_find_from_path(path)) {
1008 alertpanel_error(_("The mailbox `%s' already exists."), path);
1012 if (!strcmp(path, "Mail"))
1013 folder = folder_new(F_MH, _("Mailbox"), path);
1015 folder = folder_new(F_MH, g_basename(path), path);
1018 if (folder->create_tree(folder) < 0) {
1019 alertpanel_error(_("Creation of the mailbox failed.\n"
1020 "Maybe some files already exist, or you don't have the permission to write there."));
1021 folder_destroy(folder);
1026 folder_set_ui_func(folder, scan_tree_func, mainwin);
1027 folder->scan_tree(folder);
1028 folder_set_ui_func(folder, NULL, NULL);
1030 folderview_set(mainwin->folderview);
1033 void main_window_set_toolbar_sensitive(MainWindow *mainwin, gboolean sensitive)
1035 gtk_widget_set_sensitive(mainwin->reply_btn, sensitive);
1036 gtk_widget_set_sensitive(mainwin->replyall_btn, sensitive);
1037 gtk_widget_set_sensitive(mainwin->replyauthor_btn, sensitive);
1038 gtk_widget_set_sensitive(mainwin->fwd_btn, sensitive);
1039 gtk_widget_set_sensitive(mainwin->exec_btn, sensitive);
1040 gtk_widget_set_sensitive(mainwin->next_btn, sensitive);
1042 if (!mainwin->summaryview->folder_item ||
1043 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1044 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1046 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1049 void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
1051 GtkItemFactory *ifactory;
1055 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1057 if (selection == SUMMARY_SELECTED_SINGLE)
1061 if (!mainwin->summaryview->folder_item ||
1062 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1067 menu_set_sensitive(ifactory, "/File/Save as...", sens);
1068 menu_set_sensitive(ifactory, "/Message/Reply", sens);
1069 menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
1070 menu_set_sensitive(ifactory, "/Message/Reply to author", sens);
1071 menu_set_sensitive(ifactory, "/Message/Forward", sens);
1072 menu_set_sensitive(ifactory, "/Message/Forward as an attachment", sens);
1073 menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
1074 menu_set_sensitive(ifactory, "/Message/Show all header", sens);
1075 menu_set_sensitive(ifactory, "/Message/View source", sens);
1076 if (sens && (!mainwin->summaryview->folder_item ||
1077 mainwin->summaryview->folder_item->stype != F_DRAFT))
1079 menu_set_sensitive(ifactory, "/Message/Reedit", sens);
1081 if (selection == SUMMARY_SELECTED_SINGLE ||
1082 selection == SUMMARY_SELECTED_MULTIPLE)
1087 menu_set_sensitive(ifactory, "/File/Print..." , sens);
1088 menu_set_sensitive(ifactory, "/Message/Move...", sens && exec);
1089 menu_set_sensitive(ifactory, "/Message/Copy...", sens && exec);
1090 menu_set_sensitive(ifactory, "/Message/Delete" , sens && exec);
1091 menu_set_sensitive(ifactory, "/Message/Mark" , sens);
1093 if (selection != SUMMARY_NONE)
1098 menu_set_sensitive(ifactory, "/Summary/Delete duplicated messages", sens && exec);
1099 menu_set_sensitive(ifactory, "/Summary/Filter messages", sens && exec);
1100 menu_set_sensitive(ifactory, "/Summary/Execute", sens);
1101 menu_set_sensitive(ifactory, "/Summary/Prev message", sens);
1102 menu_set_sensitive(ifactory, "/Summary/Next message", sens);
1103 menu_set_sensitive(ifactory, "/Summary/Next unread message", sens);
1104 menu_set_sensitive(ifactory, "/Summary/Sort", sens);
1107 void main_window_popup(MainWindow *mainwin)
1113 gdk_window_get_origin(mainwin->window->window, &x, &y);
1114 sx = gdk_screen_width();
1115 sy = gdk_screen_height();
1116 x %= sx; if (x < 0) x += sx;
1117 y %= sy; if (y < 0) y += sy;
1118 gdk_window_move(mainwin->window->window, x, y);
1119 gdk_window_raise(mainwin->window->window);
1121 debug_print("window position: x = %d, y = %d\n", x, y);
1123 switch (mainwin->type) {
1124 case SEPARATE_FOLDER:
1125 widget = mainwin->win.sep_folder.folderwin;
1126 gdk_window_get_origin(widget->window, &x, &y);
1127 x %= sx; if (x < 0) x += sx;
1128 y %= sy; if (y < 0) y += sy;
1129 gdk_window_move(widget->window, x, y);
1130 gdk_window_raise(widget->window);
1132 case SEPARATE_MESSAGE:
1133 widget = mainwin->win.sep_message.messagewin;
1134 gdk_window_get_origin(widget->window, &x, &y);
1135 x %= sx; if (x < 0) x += sx;
1136 y %= sy; if (y < 0) y += sy;
1137 gdk_window_move(widget->window, x, y);
1138 gdk_window_raise(widget->window);
1141 widget = mainwin->win.sep_both.folderwin;
1142 gdk_window_get_origin(widget->window, &x, &y);
1143 x %= sx; if (x < 0) x += sx;
1144 y %= sy; if (y < 0) y += sy;
1145 gdk_window_move(widget->window, x, y);
1146 gdk_window_raise(widget->window);
1147 widget = mainwin->win.sep_both.messagewin;
1148 gdk_window_get_origin(widget->window, &x, &y);
1149 x %= sx; if (x < 0) x += sx;
1150 y %= sy; if (y < 0) y += sy;
1151 gdk_window_move(widget->window, x, y);
1152 gdk_window_raise(widget->window);
1158 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1160 GtkWidget *folderwin = NULL;
1161 GtkWidget *messagewin = NULL;
1164 GtkWidget *vbox_body = mainwin->vbox_body;
1166 debug_print(_("Setting widgets..."));
1168 /* create separated window(s) if needed */
1169 if (type & SEPARATE_FOLDER) {
1170 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1171 gtk_window_set_policy(GTK_WINDOW(folderwin),
1173 gtk_widget_set_usize(folderwin, -1,
1174 prefs_common.mainview_height);
1175 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1177 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1178 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1181 if (type & SEPARATE_MESSAGE) {
1182 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1183 gtk_window_set_policy(GTK_WINDOW(messagewin),
1185 gtk_widget_set_usize
1186 (messagewin, prefs_common.mainview_width,
1187 prefs_common.mainview_height
1188 - prefs_common.summaryview_height
1189 + DEFAULT_HEADERVIEW_HEIGHT);
1190 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1192 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1193 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1199 hpaned = gtk_hpaned_new();
1200 gtk_widget_show(hpaned);
1201 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1202 gtk_paned_add1(GTK_PANED(hpaned),
1203 GTK_WIDGET_PTR(mainwin->folderview));
1205 vpaned = gtk_vpaned_new();
1206 if (mainwin->summaryview->msg_is_toggled_on) {
1207 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1208 gtk_paned_add1(GTK_PANED(vpaned),
1209 GTK_WIDGET_PTR(mainwin->summaryview));
1211 gtk_paned_add2(GTK_PANED(hpaned),
1212 GTK_WIDGET_PTR(mainwin->summaryview));
1213 gtk_widget_ref(vpaned);
1215 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1216 prefs_common.summaryview_width,
1217 prefs_common.summaryview_height);
1218 gtk_paned_add2(GTK_PANED(vpaned),
1219 GTK_WIDGET_PTR(mainwin->messageview));
1220 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1221 prefs_common.mainview_width, -1);
1222 gtk_widget_set_usize(mainwin->window,
1223 prefs_common.folderview_width +
1224 prefs_common.mainview_width,
1225 prefs_common.mainwin_height);
1226 gtk_widget_show_all(vpaned);
1228 mainwin->win.sep_none.hpaned = hpaned;
1229 mainwin->win.sep_none.vpaned = vpaned;
1231 case SEPARATE_FOLDER:
1232 vpaned = gtk_vpaned_new();
1233 if (mainwin->summaryview->msg_is_toggled_on) {
1234 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1236 gtk_paned_add1(GTK_PANED(vpaned),
1237 GTK_WIDGET_PTR(mainwin->summaryview));
1239 gtk_box_pack_start(GTK_BOX(vbox_body),
1240 GTK_WIDGET_PTR(mainwin->summaryview),
1242 gtk_widget_ref(vpaned);
1244 gtk_paned_add2(GTK_PANED(vpaned),
1245 GTK_WIDGET_PTR(mainwin->messageview));
1246 gtk_widget_show_all(vpaned);
1247 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1248 prefs_common.summaryview_width,
1249 prefs_common.summaryview_height);
1250 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1251 prefs_common.mainview_width, -1);
1252 gtk_widget_set_usize(mainwin->window,
1253 prefs_common.mainview_width,
1254 prefs_common.mainview_height);
1256 gtk_container_add(GTK_CONTAINER(folderwin),
1257 GTK_WIDGET_PTR(mainwin->folderview));
1259 mainwin->win.sep_folder.folderwin = folderwin;
1260 mainwin->win.sep_folder.vpaned = vpaned;
1262 gtk_widget_show_all(folderwin);
1264 case SEPARATE_MESSAGE:
1265 hpaned = gtk_hpaned_new();
1266 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1268 gtk_paned_add1(GTK_PANED(hpaned),
1269 GTK_WIDGET_PTR(mainwin->folderview));
1270 gtk_paned_add2(GTK_PANED(hpaned),
1271 GTK_WIDGET_PTR(mainwin->summaryview));
1272 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1273 prefs_common.summaryview_width,
1274 prefs_common.summaryview_height);
1275 gtk_widget_set_usize(mainwin->window,
1276 prefs_common.folderview_width +
1277 prefs_common.mainview_width,
1278 prefs_common.mainwin_height);
1279 gtk_widget_show_all(hpaned);
1280 gtk_container_add(GTK_CONTAINER(messagewin),
1281 GTK_WIDGET_PTR(mainwin->messageview));
1283 mainwin->win.sep_message.messagewin = messagewin;
1284 mainwin->win.sep_message.hpaned = hpaned;
1286 gtk_widget_show_all(messagewin);
1289 gtk_box_pack_start(GTK_BOX(vbox_body),
1290 GTK_WIDGET_PTR(mainwin->summaryview),
1292 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1293 prefs_common.summaryview_width,
1294 prefs_common.summaryview_height);
1295 gtk_widget_set_usize(mainwin->window,
1296 prefs_common.mainview_width,
1297 prefs_common.mainwin_height);
1298 gtk_container_add(GTK_CONTAINER(folderwin),
1299 GTK_WIDGET_PTR(mainwin->folderview));
1300 gtk_container_add(GTK_CONTAINER(messagewin),
1301 GTK_WIDGET_PTR(mainwin->messageview));
1303 mainwin->win.sep_both.folderwin = folderwin;
1304 mainwin->win.sep_both.messagewin = messagewin;
1306 gtk_widget_show_all(folderwin);
1307 gtk_widget_show_all(messagewin);
1311 mainwin->type = type;
1313 debug_print(_("done.\n"));
1316 #include "pixmaps/stock_mail_receive.xpm"
1317 #include "pixmaps/stock_mail_receive_all.xpm"
1318 #include "pixmaps/stock_mail_compose.xpm"
1319 #include "pixmaps/stock_mail_reply.xpm"
1320 #include "pixmaps/stock_mail_reply_to_all.xpm"
1321 #include "pixmaps/stock_mail_reply_to_author.xpm"
1322 #include "pixmaps/stock_mail_forward.xpm"
1323 #include "pixmaps/stock_mail_send.xpm"
1324 #include "pixmaps/stock_preferences.xpm"
1325 #include "pixmaps/stock_properties.xpm"
1326 #include "pixmaps/stock_down_arrow.xpm"
1327 #include "pixmaps/stock_close.xpm"
1328 #include "pixmaps/stock_exec.xpm"
1330 #define CREATE_TOOLBAR_ICON(xpm_d) \
1332 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1333 &container->style->white, \
1335 icon_wid = gtk_pixmap_new(icon, mask); \
1338 static void main_window_toolbar_create(MainWindow *mainwin,
1339 GtkWidget *container)
1344 GtkWidget *icon_wid;
1346 GtkWidget *getall_btn;
1347 GtkWidget *compose_btn;
1348 GtkWidget *reply_btn;
1349 GtkWidget *replyall_btn;
1350 GtkWidget *replyauthor_btn;
1352 GtkWidget *send_btn;
1354 GtkWidget *prefs_btn;
1355 GtkWidget *account_btn;
1357 GtkWidget *next_btn;
1358 GtkWidget *delete_btn;
1359 GtkWidget *exec_btn;
1361 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1363 gtk_container_add(GTK_CONTAINER(container), toolbar);
1364 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1365 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1366 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1367 GTK_TOOLBAR_SPACE_LINE);
1369 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1370 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1372 _("Incorporate new mail"),
1374 icon_wid, toolbar_inc_cb, mainwin);
1375 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1376 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1378 _("Incorporate new mail of all accounts"),
1384 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1386 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1387 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1389 _("Send queued message(s)"),
1395 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1397 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1398 compose_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1400 _("Compose new message"),
1405 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1406 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1408 _("Reply to the message"),
1413 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1414 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1419 toolbar_reply_to_all_cb,
1421 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1422 replyauthor_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1424 _("Reply to author"),
1427 toolbar_reply_to_author_cb,
1429 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1430 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1432 _("Forward the message"),
1438 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1440 CREATE_TOOLBAR_ICON(stock_close_xpm);
1441 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1443 _("Delete the message"),
1449 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1450 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1452 _("Execute marked process"),
1458 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1460 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1461 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1463 _("Next unread message"),
1466 toolbar_next_unread_cb,
1470 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1472 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1473 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1475 _("Common preference"),
1480 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1481 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1483 _("Account setting"),
1488 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1489 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1493 mainwin->toolbar = toolbar;
1494 mainwin->get_btn = get_btn;
1495 mainwin->getall_btn = getall_btn;
1496 mainwin->compose_btn = compose_btn;
1497 mainwin->reply_btn = reply_btn;
1498 mainwin->replyall_btn = replyall_btn;
1499 mainwin->replyauthor_btn = replyauthor_btn;
1500 mainwin->fwd_btn = fwd_btn;
1501 mainwin->send_btn = send_btn;
1503 mainwin->prefs_btn = prefs_btn;
1504 mainwin->account_btn = account_btn;
1506 mainwin->next_btn = next_btn;
1507 mainwin->delete_btn = delete_btn;
1508 mainwin->exec_btn = exec_btn;
1510 gtk_widget_show_all(toolbar);
1513 /* callback functions */
1515 static void toolbar_inc_cb (GtkWidget *widget,
1518 MainWindow *mainwin = (MainWindow *)data;
1520 inc_mail_cb(mainwin, 0, NULL);
1523 static void toolbar_inc_all_cb (GtkWidget *widget,
1526 MainWindow *mainwin = (MainWindow *)data;
1528 inc_all_account_mail_cb(mainwin, 0, NULL);
1531 static void toolbar_send_cb (GtkWidget *widget,
1534 MainWindow *mainwin = (MainWindow *)data;
1536 send_queue_cb(mainwin, 0, NULL);
1539 static void toolbar_compose_cb (GtkWidget *widget,
1542 MainWindow *mainwin = (MainWindow *)data;
1544 compose_cb(mainwin, 0, NULL);
1547 static void toolbar_reply_cb (GtkWidget *widget,
1550 MainWindow *mainwin = (MainWindow *)data;
1552 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1555 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1558 MainWindow *mainwin = (MainWindow *)data;
1560 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1563 static void toolbar_reply_to_author_cb (GtkWidget *widget,
1566 MainWindow *mainwin = (MainWindow *)data;
1568 reply_cb(mainwin, COMPOSE_REPLY_TO_AUTHOR, NULL);
1571 static void toolbar_forward_cb (GtkWidget *widget,
1574 MainWindow *mainwin = (MainWindow *)data;
1576 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1579 static void toolbar_delete_cb (GtkWidget *widget,
1582 MainWindow *mainwin = (MainWindow *)data;
1584 summary_delete(mainwin->summaryview);
1587 static void toolbar_exec_cb (GtkWidget *widget,
1590 MainWindow *mainwin = (MainWindow *)data;
1592 summary_execute(mainwin->summaryview);
1595 static void toolbar_next_unread_cb (GtkWidget *widget,
1598 MainWindow *mainwin = (MainWindow *)data;
1600 next_unread_cb(mainwin, 0, NULL);
1603 static void toolbar_prefs_cb (GtkWidget *widget,
1606 prefs_common_open();
1609 static void toolbar_account_cb (GtkWidget *widget,
1612 MainWindow *mainwin = (MainWindow *)data;
1614 prefs_account_open_cb(mainwin, 0, NULL);
1617 static void toolbar_account_button_pressed(GtkWidget *widget,
1618 GdkEventButton *event,
1621 MainWindow *mainwin = (MainWindow *)data;
1624 if (event->button != 3) return;
1626 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1627 event->button, event->time);
1630 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1633 MainWindow *mainwin = (MainWindow *)data;
1637 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1638 event->button, event->time);
1641 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1644 app_exit_cb(data, 0, widget);
1649 static void add_mailbox_cb(MainWindow *mainwin, guint action,
1652 main_window_add_mailbox(mainwin);
1655 static void update_folderview_cb(MainWindow *mainwin, guint action,
1658 summary_show(mainwin->summaryview, NULL, FALSE);
1659 folderview_update_all();
1662 static void new_folder_cb(MainWindow *mainwin, guint action,
1665 folderview_new_folder(mainwin->folderview);
1668 static void rename_folder_cb(MainWindow *mainwin, guint action,
1671 folderview_rename_folder(mainwin->folderview);
1674 static void delete_folder_cb(MainWindow *mainwin, guint action,
1677 folderview_delete_folder(mainwin->folderview);
1680 static void import_mbox_cb(MainWindow *mainwin, guint action,
1683 import_mbox(mainwin->summaryview->folder_item);
1686 static void export_mbox_cb(MainWindow *mainwin, guint action,
1689 export_mbox(mainwin->summaryview->folder_item);
1692 static void empty_trash_cb(MainWindow *mainwin, guint action,
1695 main_window_empty_trash(mainwin, TRUE);
1698 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1700 summary_save_as(mainwin->summaryview);
1703 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1705 summary_print(mainwin->summaryview);
1708 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1710 if (prefs_common.confirm_on_exit) {
1711 if (alertpanel(_("Exit"), _("Exit this program?"),
1712 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
1714 manage_window_focus_in(mainwin->window, NULL, NULL);
1717 app_will_exit(widget, mainwin);
1720 static void toggle_folder_cb(MainWindow *mainwin, guint action,
1723 switch (mainwin->type) {
1725 case SEPARATE_MESSAGE:
1727 case SEPARATE_FOLDER:
1728 if (GTK_CHECK_MENU_ITEM(widget)->active)
1729 gtk_widget_show(mainwin->win.sep_folder.folderwin);
1731 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1734 if (GTK_CHECK_MENU_ITEM(widget)->active)
1735 gtk_widget_show(mainwin->win.sep_both.folderwin);
1737 gtk_widget_hide(mainwin->win.sep_both.folderwin);
1742 static void toggle_message_cb(MainWindow *mainwin, guint action,
1745 switch (mainwin->type) {
1747 case SEPARATE_FOLDER:
1749 case SEPARATE_MESSAGE:
1750 if (GTK_CHECK_MENU_ITEM(widget)->active)
1751 gtk_widget_show(mainwin->win.sep_message.messagewin);
1753 gtk_widget_hide(mainwin->win.sep_message.messagewin);
1756 if (GTK_CHECK_MENU_ITEM(widget)->active)
1757 gtk_widget_show(mainwin->win.sep_both.messagewin);
1759 gtk_widget_hide(mainwin->win.sep_both.messagewin);
1764 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
1767 switch ((ToolbarStyle)action) {
1769 gtk_widget_hide(mainwin->handlebox);
1771 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1775 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1779 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1784 if (action != TOOLBAR_NONE) {
1785 gtk_widget_show(mainwin->handlebox);
1786 gtk_widget_queue_resize(mainwin->handlebox);
1789 mainwin->toolbar_style = (ToolbarStyle)action;
1790 prefs_common.toolbar_style = (ToolbarStyle)action;
1793 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
1796 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1797 gtk_widget_show(mainwin->hbox_stat);
1798 prefs_common.show_statusbar = TRUE;
1800 gtk_widget_hide(mainwin->hbox_stat);
1801 prefs_common.show_statusbar = FALSE;
1805 static void separate_widget_cb(MainWindow *mainwin, guint action,
1810 type = mainwin->type ^ action;
1811 main_window_separation_change(mainwin, type);
1813 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
1814 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
1817 static void addressbook_open_cb(MainWindow *mainwin, guint action,
1820 addressbook_open(NULL);
1823 static void log_window_show_cb(MainWindow *mainwin, guint action,
1826 log_window_show(mainwin->logwin);
1829 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1834 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
1837 inc_all_account_mail(mainwin);
1840 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1844 if (procmsg_send_queue() < 0)
1845 alertpanel_error(_("Sending queued message failed."));
1847 statusbar_pop_all();
1849 for (list = folder_get_list(); list != NULL; list = list->next) {
1852 folder = list->data;
1853 if (folder->queue) {
1854 folder_item_scan(folder->queue);
1855 folderview_update_item(folder->queue, TRUE);
1860 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1862 if (mainwin->summaryview->folder_item)
1863 compose_new(mainwin->summaryview->folder_item->folder->account);
1868 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1872 msginfo = gtk_ctree_node_get_row_data
1873 (GTK_CTREE(mainwin->summaryview->ctree),
1874 mainwin->summaryview->selected);
1876 if (!msginfo) return;
1880 compose_reply(msginfo, prefs_common.reply_with_quote,
1883 case COMPOSE_REPLY_TO_ALL:
1884 compose_reply(msginfo, prefs_common.reply_with_quote,
1887 case COMPOSE_REPLY_TO_AUTHOR:
1888 compose_reply(msginfo, prefs_common.reply_with_quote,
1891 case COMPOSE_FORWARD:
1892 compose_forward(NULL, msginfo, FALSE);
1894 case COMPOSE_FORWARD_AS_ATTACH:
1895 compose_forward(NULL, msginfo, TRUE);
1898 compose_reply(msginfo, prefs_common.reply_with_quote,
1902 summary_set_marks_selected(mainwin->summaryview);
1905 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1907 summary_move_to(mainwin->summaryview);
1910 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1912 summary_copy_to(mainwin->summaryview);
1915 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1917 summary_delete(mainwin->summaryview);
1920 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1922 summary_open_msg(mainwin->summaryview);
1925 static void view_source_cb(MainWindow *mainwin, guint action,
1928 summary_view_source(mainwin->summaryview);
1931 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1933 summary_reedit(mainwin->summaryview);
1936 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1938 summary_mark(mainwin->summaryview);
1941 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1943 summary_unmark(mainwin->summaryview);
1946 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
1949 summary_mark_as_unread(mainwin->summaryview);
1952 static void mark_as_read_cb(MainWindow *mainwin, guint action,
1955 summary_mark_as_read(mainwin->summaryview);
1958 static void set_charset_cb(MainWindow *mainwin, guint action,
1963 str = conv_get_charset_str((CharSet)action);
1964 g_free(prefs_common.force_charset);
1965 prefs_common.force_charset = str ? g_strdup(str) : NULL;
1967 summary_redisplay_msg(mainwin->summaryview);
1969 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
1972 void main_window_set_thread_option(MainWindow *mainwin)
1974 GtkItemFactory *ifactory;
1976 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1978 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
1979 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
1980 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
1981 summary_thread_build(mainwin->summaryview);
1984 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
1985 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
1986 summary_unthread(mainwin->summaryview);
1988 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
1991 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1994 ifactory = gtk_item_factory_from_widget(widget);
1996 mainwin->summaryview->folder_item->prefs->enable_thread =
1997 !mainwin->summaryview->folder_item->prefs->enable_thread;
1998 main_window_set_thread_option(mainwin);
2002 summary_thread_build(mainwin->summaryview);
2003 mainwin->summaryview->folder_item->prefs->enable_thread =
2005 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2006 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2008 summary_unthread(mainwin->summaryview);
2009 mainwin->summaryview->folder_item->prefs->enable_thread =
2011 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2012 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2017 static void set_display_item_cb(MainWindow *mainwin, guint action,
2020 prefs_summary_display_item_set();
2023 static void sort_summary_cb(MainWindow *mainwin, guint action,
2026 summary_sort(mainwin->summaryview, (SummarySortType)action);
2029 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2032 summary_attract_by_subject(mainwin->summaryview);
2035 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2038 summary_delete_duplicated(mainwin->summaryview);
2041 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2043 summary_filter(mainwin->summaryview);
2046 static void execute_summary_cb(MainWindow *mainwin, guint action,
2049 summary_execute(mainwin->summaryview);
2052 static void update_summary_cb(MainWindow *mainwin, guint action,
2056 FolderView *folderview = mainwin->folderview;
2058 if (!mainwin->summaryview->folder_item) return;
2059 if (!folderview->opened) return;
2061 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2062 folderview->opened);
2065 summary_show(mainwin->summaryview, fitem, TRUE);
2068 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2070 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2073 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2075 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2078 static void next_unread_cb(MainWindow *mainwin, guint action,
2081 summary_select_next_unread(mainwin->summaryview);
2084 static void next_marked_cb(MainWindow *mainwin, guint action,
2087 summary_select_next_marked(mainwin->summaryview);
2090 static void prev_marked_cb(MainWindow *mainwin, guint action,
2093 summary_select_prev_marked(mainwin->summaryview);
2096 static void goto_folder_cb(MainWindow *mainwin, guint action,
2099 FolderItem *to_folder;
2101 to_folder = foldersel_folder_sel(NULL);
2104 folderview_select(mainwin->folderview, to_folder);
2107 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2109 messageview_copy_clipboard(mainwin->messageview);
2112 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2114 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2115 summary_select_all(mainwin->summaryview);
2116 else if (mainwin->summaryview->msg_is_toggled_on &&
2117 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2118 messageview_select_all(mainwin->messageview);
2121 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2124 prefs_common_open();
2127 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2130 prefs_filter_open();
2133 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2136 prefs_scoring_open();
2139 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2142 prefs_filtering_open();
2145 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2149 new_account_cb(mainwin, 0, widget);
2151 gboolean prev_default = cur_account->is_default;
2153 prefs_account_open(cur_account);
2154 if (!prev_default && cur_account->is_default)
2155 account_set_as_default(cur_account);
2156 account_save_config_all();
2158 main_window_reflect_prefs_all();
2162 static void new_account_cb(MainWindow *mainwin, guint action,
2165 account_edit_open();
2166 if (!compose_get_compose_list()) account_add();
2169 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2171 cur_account = (PrefsAccount *)data;
2172 main_window_reflect_prefs_all();
2175 static void manual_open_cb(MainWindow *mainwin, guint action,
2178 manual_open((ManualLang)action);
2181 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2183 MainWindow *mainwin = (MainWindow *)data;
2187 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2188 LOCAL_FOLDER(folder)->rootpath,
2192 str = g_strdup_printf(_("Scanning folder %s ..."),
2193 LOCAL_FOLDER(folder)->rootpath);
2195 STATUSBAR_PUSH(mainwin, str);
2196 STATUSBAR_POP(mainwin);