2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gtk/gtkmain.h>
24 #include <gtk/gtkwindow.h>
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtksignal.h>
27 #include <gtk/gtkvbox.h>
28 #include <gtk/gtkcontainer.h>
29 #include <gtk/gtkstatusbar.h>
30 #include <gtk/gtkprogressbar.h>
31 #include <gtk/gtkhpaned.h>
32 #include <gtk/gtkvpaned.h>
33 #include <gtk/gtkcheckmenuitem.h>
34 #include <gtk/gtkitemfactory.h>
35 #include <gtk/gtkeditable.h>
36 #include <gtk/gtkmenu.h>
37 #include <gtk/gtkmenuitem.h>
38 #include <gtk/gtkhandlebox.h>
39 #include <gtk/gtktoolbar.h>
40 #include <gtk/gtkbutton.h>
45 #include "mainwindow.h"
46 #include "folderview.h"
47 #include "foldersel.h"
48 #include "summaryview.h"
49 #include "summary_search.h"
50 #include "messageview.h"
51 #include "message_search.h"
52 #include "headerview.h"
60 #include "prefs_common.h"
61 #include "prefs_filter.h"
62 #include "prefs_filtering.h"
63 #include "prefs_scoring.h"
64 #include "prefs_account.h"
65 #include "prefs_folder_item.h"
66 #include "prefs_summary_column.h"
67 #include "prefs_template.h"
69 #include "addressbook.h"
70 #include "headerwindow.h"
71 #include "logwindow.h"
72 #include "manage_window.h"
73 #include "alertpanel.h"
74 #include "statusbar.h"
75 #include "inputdialog.h"
83 #define AC_LABEL_WIDTH 240
85 #define STATUSBAR_PUSH(mainwin, str) \
87 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
88 mainwin->mainwin_cid, str); \
89 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
92 #define STATUSBAR_POP(mainwin) \
94 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
95 mainwin->mainwin_cid); \
98 /* list of all instantiated MainWindow */
99 static GList *mainwin_list = NULL;
101 static GdkCursor *watch_cursor;
103 static void main_window_show_cur_account (MainWindow *mainwin);
105 static void main_window_set_widgets (MainWindow *mainwin,
107 static void main_window_toolbar_create (MainWindow *mainwin,
108 GtkWidget *container);
110 /* callback functions */
111 static void toolbar_inc_cb (GtkWidget *widget,
113 static void toolbar_inc_all_cb (GtkWidget *widget,
115 static void toolbar_send_cb (GtkWidget *widget,
118 static void toolbar_compose_cb (GtkWidget *widget,
120 static void toolbar_popup_compose_type_cb(GtkWidget *widget,
122 static void toolbar_popup_compose_type_set(GtkWidget *widget,
124 static void toolbar_compose_news_cb (GtkWidget *widget,
126 static void toolbar_compose_mail_cb (GtkWidget *widget,
128 static void toolbar_reply_cb (GtkWidget *widget,
130 static void toolbar_reply_to_all_cb (GtkWidget *widget,
132 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
134 static void toolbar_forward_cb (GtkWidget *widget,
137 static void toolbar_delete_cb (GtkWidget *widget,
139 static void toolbar_exec_cb (GtkWidget *widget,
142 static void toolbar_next_unread_cb (GtkWidget *widget,
145 static void toolbar_prefs_cb (GtkWidget *widget,
147 static void toolbar_account_cb (GtkWidget *widget,
150 static void toolbar_account_button_pressed (GtkWidget *widget,
151 GdkEventButton *event,
153 static void ac_label_button_pressed (GtkWidget *widget,
154 GdkEventButton *event,
156 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
159 static gint main_window_close_cb (GtkWidget *widget,
163 static void add_mailbox_cb (MainWindow *mainwin,
166 static void add_mbox_cb (MainWindow *mainwin,
169 static void update_folderview_cb (MainWindow *mainwin,
172 static void new_folder_cb (MainWindow *mainwin,
175 static void rename_folder_cb (MainWindow *mainwin,
178 static void delete_folder_cb (MainWindow *mainwin,
181 static void import_mbox_cb (MainWindow *mainwin,
184 static void export_mbox_cb (MainWindow *mainwin,
187 static void empty_trash_cb (MainWindow *mainwin,
191 static void save_as_cb (MainWindow *mainwin,
194 static void print_cb (MainWindow *mainwin,
197 static void app_exit_cb (MainWindow *mainwin,
201 static void search_cb (MainWindow *mainwin,
205 static void toggle_folder_cb (MainWindow *mainwin,
208 static void toggle_message_cb (MainWindow *mainwin,
211 static void toggle_toolbar_cb (MainWindow *mainwin,
214 static void toggle_statusbar_cb (MainWindow *mainwin,
217 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
221 static void addressbook_open_cb (MainWindow *mainwin,
224 static void log_window_show_cb (MainWindow *mainwin,
228 static void inc_mail_cb (MainWindow *mainwin,
231 static void inc_all_account_mail_cb (MainWindow *mainwin,
235 static void send_queue_cb (MainWindow *mainwin,
239 static void compose_cb (MainWindow *mainwin,
242 static void compose_mail_cb(MainWindow *mainwin, guint action,
244 static void compose_news_cb(MainWindow *mainwin, guint action,
246 static void reply_cb (MainWindow *mainwin,
250 static void open_msg_cb (MainWindow *mainwin,
254 static void view_source_cb (MainWindow *mainwin,
258 static void reedit_cb (MainWindow *mainwin,
262 static void move_to_cb (MainWindow *mainwin,
265 static void copy_to_cb (MainWindow *mainwin,
268 static void delete_cb (MainWindow *mainwin,
272 static void mark_cb (MainWindow *mainwin,
275 static void unmark_cb (MainWindow *mainwin,
279 static void mark_as_unread_cb (MainWindow *mainwin,
282 static void mark_as_read_cb (MainWindow *mainwin,
285 static void mark_all_read_cb (MainWindow *mainwin,
288 static void add_address_cb (MainWindow *mainwin,
292 static void set_charset_cb (MainWindow *mainwin,
296 static void thread_cb (MainWindow *mainwin,
299 static void set_display_item_cb (MainWindow *mainwin,
302 static void sort_summary_cb (MainWindow *mainwin,
305 static void attract_by_subject_cb(MainWindow *mainwin,
309 static void delete_duplicated_cb (MainWindow *mainwin,
312 static void filter_cb (MainWindow *mainwin,
315 static void execute_summary_cb (MainWindow *mainwin,
318 static void update_summary_cb (MainWindow *mainwin,
322 static void prev_cb (MainWindow *mainwin,
325 static void next_cb (MainWindow *mainwin,
329 static void prev_unread_cb (MainWindow *mainwin,
332 static void next_unread_cb (MainWindow *mainwin,
335 static void prev_marked_cb (MainWindow *mainwin,
338 static void next_marked_cb (MainWindow *mainwin,
341 static void prev_labeled_cb (MainWindow *mainwin,
344 static void next_labeled_cb (MainWindow *mainwin,
348 static void goto_folder_cb (MainWindow *mainwin,
352 static void copy_cb (MainWindow *mainwin,
355 static void allsel_cb (MainWindow *mainwin,
359 static void prefs_common_open_cb (MainWindow *mainwin,
362 static void prefs_filter_open_cb (MainWindow *mainwin,
365 static void prefs_scoring_open_cb (MainWindow *mainwin,
368 static void prefs_filtering_open_cb (MainWindow *mainwin,
371 static void prefs_account_open_cb(MainWindow *mainwin,
374 static void prefs_template_open_cb (MainWindow *mainwin,
377 static void new_account_cb (MainWindow *mainwin,
381 static void account_menu_cb (GtkMenuItem *menuitem,
384 static void manual_open_cb (MainWindow *mainwin,
388 static void scan_tree_func (Folder *folder,
392 static void activate_compose_button (MainWindow *mainwin,
394 ComposeButtonType type);
396 #define SEPARATE_ACTION 667
398 static GtkItemFactoryEntry mainwin_entries[] =
400 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
401 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
402 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
403 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
404 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
405 {N_("/_File/_Folder/Create _new folder..."),
406 NULL, new_folder_cb, 0, NULL},
407 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
408 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
409 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
410 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
411 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
412 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
413 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
414 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
415 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
416 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
417 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
419 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
420 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
421 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
422 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
423 {N_("/_Edit/_Find in current message"), "<control>F", search_cb, 0, NULL},
424 {N_("/_Edit/_Search folder"), "<control>S", search_cb, 1, NULL},
426 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
427 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
428 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
429 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
430 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
431 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
432 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
433 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
434 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
435 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
436 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
437 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
438 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
439 {N_("/_View/View _source"), "<control>U", view_source_cb, 0, NULL},
440 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
441 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
442 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
443 {N_("/_View/_Code set/_Auto detect"),
444 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
446 #define CODESET_SEPARATOR \
447 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
448 #define CODESET_ACTION(action) \
449 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
451 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
452 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
453 CODESET_ACTION(C_US_ASCII)},
456 {N_("/_View/_Code set/Unicode (_UTF-8)"),
457 CODESET_ACTION(C_UTF_8)},
460 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
461 CODESET_ACTION(C_ISO_8859_1)},
464 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
465 CODESET_ACTION(C_ISO_8859_2)},
467 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
468 CODESET_ACTION(C_ISO_8859_13)},
469 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
470 CODESET_ACTION(C_ISO_8859_4)},
472 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
473 CODESET_ACTION(C_ISO_8859_7)},
475 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
476 CODESET_ACTION(C_ISO_8859_9)},
478 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
479 CODESET_ACTION(C_ISO_8859_5)},
480 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
481 CODESET_ACTION(C_KOI8_R)},
482 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
483 CODESET_ACTION(C_CP1251)},
486 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
487 CODESET_ACTION(C_ISO_2022_JP)},
489 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
490 CODESET_ACTION(C_ISO_2022_JP_2)},
492 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
493 CODESET_ACTION(C_EUC_JP)},
494 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
495 CODESET_ACTION(C_SHIFT_JIS)},
498 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
499 CODESET_ACTION(C_GB2312)},
500 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
501 CODESET_ACTION(C_BIG5)},
502 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
503 CODESET_ACTION(C_EUC_TW)},
504 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
505 CODESET_ACTION(C_ISO_2022_CN)},
507 {N_("/_View/_Code set/Korean (EUC-_KR)"),
508 CODESET_ACTION(C_EUC_KR)},
509 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
510 CODESET_ACTION(C_ISO_2022_KR)},
512 {N_("/_View/_Code set/Thai (TIS-620)"),
513 CODESET_ACTION(C_TIS_620)},
514 {N_("/_View/_Code set/Thai (Windows-874)"),
515 CODESET_ACTION(C_WINDOWS_874)},
518 #undef CODESET_SEPARATOR
519 #undef CODESET_ACTION
521 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
522 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
523 {N_("/_Message/Get from _all accounts"),
524 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
525 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_Message/Send queued messa_ges"),
527 NULL, send_queue_cb, 0, NULL},
528 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
529 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
530 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
531 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
532 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
533 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
534 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
535 {N_("/_Message/_Forward"), "<shift><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
536 {N_("/_Message/Forward as a_ttachment"),
537 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
538 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
539 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
540 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
541 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
542 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
543 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
544 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
545 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
546 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
547 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
548 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
549 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
550 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
551 {N_("/_Message/_Mark/Mark as rea_d"),
552 NULL, mark_as_read_cb, 0, NULL},
553 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
554 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
556 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
557 {N_("/_Summary/_Delete duplicated messages"),
558 NULL, delete_duplicated_cb, 0, NULL},
559 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
560 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
561 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
562 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_Summary/Go _to"), NULL, NULL, 0, "<Branch>"},
564 {N_("/_Summary/Go _to/_Prev message"), NULL, prev_cb, 0, NULL},
565 {N_("/_Summary/Go _to/_Next message"), NULL, next_cb, 0, NULL},
566 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
567 {N_("/_Summary/Go _to/P_rev unread message"),
568 NULL, prev_unread_cb, 0, NULL},
569 {N_("/_Summary/Go _to/N_ext unread message"),
570 NULL, next_unread_cb, 0, NULL},
571 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
572 {N_("/_Summary/Go _to/Prev _marked message"),
573 NULL, prev_marked_cb, 0, NULL},
574 {N_("/_Summary/Go _to/Next m_arked message"),
575 NULL, next_marked_cb, 0, NULL},
576 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
577 {N_("/_Summary/Go _to/Prev _labeled message"),
578 NULL, prev_labeled_cb, 0, NULL},
579 {N_("/_Summary/Go _to/Next la_beled message"),
580 NULL, next_labeled_cb, 0, NULL},
581 {N_("/_Summary/_Go to other folder..."),"<alt>G", goto_folder_cb, 0, NULL},
582 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
583 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
584 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
585 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
586 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
587 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
588 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
589 {N_("/_Summary/_Sort/Sort by _color label"),
590 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
591 {N_("/_Summary/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
592 {N_("/_Summary/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
593 {N_("/_Summary/_Sort/Sort by a_ttachment"),
594 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
595 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
596 {N_("/_Summary/_Sort/_Attract by subject"),
597 NULL, attract_by_subject_cb, 0, NULL},
598 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
599 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
600 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
602 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
603 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
604 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
606 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
607 {N_("/_Configuration/_Common preferences..."),
608 NULL, prefs_common_open_cb, 0, NULL},
609 {N_("/_Configuration/_Filter setting..."),
610 NULL, prefs_filter_open_cb, 0, NULL},
611 {N_("/_Configuration/_Scoring ..."),
612 NULL, prefs_scoring_open_cb, 0, NULL},
613 {N_("/_Configuration/_Filtering ..."),
614 NULL, prefs_filtering_open_cb, 0, NULL},
615 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
616 {N_("/_Configuration/_Preferences for current account..."),
617 NULL, prefs_account_open_cb, 0, NULL},
618 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
619 {N_("/_Configuration/Create _new account..."),
620 NULL, new_account_cb, 0, NULL},
621 {N_("/_Configuration/_Edit accounts..."),
622 NULL, account_edit_open, 0, NULL},
623 {N_("/_Configuration/C_hange current account"),
624 NULL, NULL, 0, "<Branch>"},
626 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
627 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
628 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
629 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
630 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
634 MainWindow *main_window_create(SeparateType type)
640 GtkWidget *handlebox;
641 GtkWidget *vbox_body;
642 GtkWidget *hbox_stat;
643 GtkWidget *statusbar;
644 GtkWidget *progressbar;
645 GtkWidget *statuslabel;
646 GtkWidget *ac_button;
649 FolderView *folderview;
650 SummaryView *summaryview;
651 MessageView *messageview;
652 GdkColormap *colormap;
655 guint n_menu_entries;
656 GtkItemFactory *ifactory;
661 debug_print(_("Creating main window...\n"));
662 mainwin = g_new0(MainWindow, 1);
665 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
666 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
667 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
668 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
669 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
670 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
671 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
672 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
673 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
675 gtk_widget_realize(window);
677 gtkut_widget_set_app_icon(window);
679 vbox = gtk_vbox_new(FALSE, 0);
680 gtk_widget_show(vbox);
681 gtk_container_add(GTK_CONTAINER(window), vbox);
684 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
685 menubar = menubar_create(window, mainwin_entries,
686 n_menu_entries, "<Main>", mainwin);
687 gtk_widget_show(menubar);
688 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
690 handlebox = gtk_handle_box_new();
691 gtk_widget_show(handlebox);
692 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
694 main_window_toolbar_create(mainwin, handlebox);
696 /* vbox that contains body */
697 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
698 gtk_widget_show(vbox_body);
699 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
700 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
702 hbox_stat = gtk_hbox_new(FALSE, 2);
703 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
705 statusbar = statusbar_create();
706 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
708 progressbar = gtk_progress_bar_new();
709 gtk_widget_set_usize(progressbar, 120, 1);
710 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
712 statuslabel = gtk_label_new("");
713 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
715 ac_button = gtk_button_new();
716 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
717 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
718 gtk_widget_set_usize(ac_button, -1, 1);
719 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
720 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
721 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
723 ac_label = gtk_label_new("");
724 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
726 gtk_widget_show_all(hbox_stat);
729 mainwin->folderview = folderview = folderview_create();
730 mainwin->summaryview = summaryview = summary_create();
731 mainwin->messageview = messageview = messageview_create();
732 mainwin->headerwin = header_window_create();
733 mainwin->logwin = log_window_create();
735 folderview->mainwin = mainwin;
736 folderview->summaryview = summaryview;
738 summaryview->mainwin = mainwin;
739 summaryview->folderview = folderview;
740 summaryview->messageview = messageview;
741 summaryview->headerwin = mainwin->headerwin;
742 summaryview->window = window;
744 messageview->mainwin = mainwin;
746 mainwin->window = window;
747 mainwin->vbox = vbox;
748 mainwin->menubar = menubar;
749 mainwin->handlebox = handlebox;
750 mainwin->vbox_body = vbox_body;
751 mainwin->hbox_stat = hbox_stat;
752 mainwin->statusbar = statusbar;
753 mainwin->progressbar = progressbar;
754 mainwin->statuslabel = statuslabel;
755 mainwin->ac_button = ac_button;
756 mainwin->ac_label = ac_label;
758 /* set context IDs for status bar */
759 mainwin->mainwin_cid = gtk_statusbar_get_context_id
760 (GTK_STATUSBAR(statusbar), "Main Window");
761 mainwin->folderview_cid = gtk_statusbar_get_context_id
762 (GTK_STATUSBAR(statusbar), "Folder View");
763 mainwin->summaryview_cid = gtk_statusbar_get_context_id
764 (GTK_STATUSBAR(statusbar), "Summary View");
766 /* allocate colors for summary view and folder view */
767 summaryview->color_marked.red = summaryview->color_marked.green = 0;
768 summaryview->color_marked.blue = (guint16)65535;
770 summaryview->color_dim.red = summaryview->color_dim.green =
771 summaryview->color_dim.blue = COLOR_DIM;
773 folderview->color_new.red = (guint16)55000;
774 folderview->color_new.green = folderview->color_new.blue = 15000;
776 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
777 &folderview->color_op);
779 summaryview->color_important.red = 0;
780 summaryview->color_marked.green = 0;
781 summaryview->color_important.blue = (guint16)65535;
783 color[0] = summaryview->color_marked;
784 color[1] = summaryview->color_dim;
785 color[2] = folderview->color_new;
786 color[3] = folderview->color_op;
788 colormap = gdk_window_get_colormap(window->window);
789 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
790 for (i = 0; i < 4; i++) {
791 if (success[i] == FALSE)
792 g_warning(_("MainWindow: color allocation %d failed\n"), i);
795 debug_print(_("done.\n"));
797 main_window_set_widgets(mainwin, type);
800 ifactory = gtk_item_factory_from_widget(menubar);
801 menuitem = gtk_item_factory_get_item
802 (ifactory, "/View/Code set/Auto detect");
803 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
805 switch (prefs_common.toolbar_style) {
807 menuitem = gtk_item_factory_get_item
808 (ifactory, "/View/Toolbar/None");
811 menuitem = gtk_item_factory_get_item
812 (ifactory, "/View/Toolbar/Icon");
815 menuitem = gtk_item_factory_get_item
816 (ifactory, "/View/Toolbar/Text");
819 menuitem = gtk_item_factory_get_item
820 (ifactory, "/View/Toolbar/Icon and text");
822 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
824 gtk_widget_hide(mainwin->hbox_stat);
825 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
826 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
827 prefs_common.show_statusbar);
829 /* set the check of the SEPARATE_xxx menu items. we also need the main window
830 * as a property and pass the action type to the callback */
831 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
833 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
834 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
835 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
836 GUINT_TO_POINTER(SEPARATE_FOLDER));
838 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
840 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
841 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
842 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
843 GUINT_TO_POINTER(SEPARATE_MESSAGE));
846 menu_set_sensitive(ifactory, "/Summary/Thread view",
847 prefs_common.enable_thread ? FALSE : TRUE);
848 menu_set_sensitive(ifactory, "/Summary/Unthread view",
849 prefs_common.enable_thread ? TRUE : FALSE);
851 /*main_window_set_thread_option(mainwin);*/
854 /* set account selection menu */
855 ac_menu = gtk_item_factory_get_widget
856 (ifactory, "/Configuration/Change current account");
857 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
858 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
859 mainwin->ac_menu = ac_menu;
861 main_window_set_toolbar_sensitive(mainwin);
863 /* show main window */
864 gtk_widget_set_uposition(mainwin->window,
865 prefs_common.mainwin_x,
866 prefs_common.mainwin_y);
867 gtk_widget_set_usize(window, prefs_common.mainwin_width,
868 prefs_common.mainwin_height);
870 gtk_widget_show(mainwin->window);
872 /* initialize views */
873 folderview_init(folderview);
874 summary_init(summaryview);
875 messageview_init(messageview);
876 header_window_init(mainwin->headerwin);
877 log_window_init(mainwin->logwin);
880 mainwin->lock_count = 0;
881 mainwin->cursor_count = 0;
884 watch_cursor = gdk_cursor_new(GDK_WATCH);
886 mainwin_list = g_list_append(mainwin_list, mainwin);
891 void main_window_cursor_wait(MainWindow *mainwin)
894 if (mainwin->cursor_count == 0)
895 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
897 mainwin->cursor_count++;
902 void main_window_cursor_normal(MainWindow *mainwin)
904 if (mainwin->cursor_count)
905 mainwin->cursor_count--;
907 if (mainwin->cursor_count == 0)
908 gdk_window_set_cursor(mainwin->window->window, NULL);
913 /* lock / unlock the user-interface */
914 void main_window_lock(MainWindow *mainwin)
916 if (mainwin->lock_count == 0)
917 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
919 mainwin->lock_count++;
921 main_window_set_menu_sensitive(mainwin);
922 main_window_set_toolbar_sensitive(mainwin);
925 void main_window_unlock(MainWindow *mainwin)
927 if (mainwin->lock_count)
928 mainwin->lock_count--;
930 main_window_set_menu_sensitive(mainwin);
931 main_window_set_toolbar_sensitive(mainwin);
933 if (mainwin->lock_count == 0)
934 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
937 void main_window_reflect_prefs_all(void)
942 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
943 mainwin = (MainWindow *)cur->data;
945 main_window_show_cur_account(mainwin);
946 main_window_set_menu_sensitive(mainwin);
947 main_window_set_toolbar_sensitive(mainwin);
949 if (prefs_common.immediate_exec)
950 gtk_widget_hide(mainwin->exec_btn);
952 gtk_widget_show(mainwin->exec_btn);
954 summary_redisplay_msg(mainwin->summaryview);
955 headerview_set_visibility(mainwin->messageview->headerview,
956 prefs_common.display_header_pane);
960 void main_window_set_summary_column(void)
965 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
966 mainwin = (MainWindow *)cur->data;
967 summary_set_column_order(mainwin->summaryview);
971 void main_window_set_account_menu(GList *account_list)
973 GList *cur, *cur_ac, *cur_item;
976 PrefsAccount *ac_prefs;
978 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
979 mainwin = (MainWindow *)cur->data;
981 /* destroy all previous menu item */
982 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
983 while (cur_item != NULL) {
984 GList *next = cur_item->next;
985 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
989 for (cur_ac = account_list; cur_ac != NULL;
990 cur_ac = cur_ac->next) {
991 ac_prefs = (PrefsAccount *)cur_ac->data;
993 menuitem = gtk_menu_item_new_with_label
994 (ac_prefs->account_name
995 ? ac_prefs->account_name : _("Untitled"));
996 gtk_widget_show(menuitem);
997 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
998 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
999 GTK_SIGNAL_FUNC(account_menu_cb),
1005 static void main_window_show_cur_account(MainWindow *mainwin)
1010 ac_name = g_strdup(cur_account
1011 ? (cur_account->account_name
1012 ? cur_account->account_name : _("Untitled"))
1016 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1018 buf = g_strdup(PROG_VERSION);
1019 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1022 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1023 gtk_widget_queue_resize(mainwin->ac_button);
1028 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1030 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1031 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1032 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1034 if (mainwin->type == type) return;
1036 /* remove widgets from those containers */
1037 gtk_widget_ref(folder_wid);
1038 gtk_widget_ref(summary_wid);
1039 gtk_widget_ref(message_wid);
1040 gtk_container_remove
1041 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1042 gtk_container_remove
1043 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1044 gtk_container_remove
1045 (GTK_CONTAINER(message_wid->parent), message_wid);
1047 /* clean containers */
1048 switch (mainwin->type) {
1050 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1052 case SEPARATE_FOLDER:
1053 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1054 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1056 case SEPARATE_MESSAGE:
1057 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1058 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1061 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1062 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1066 gtk_widget_hide(mainwin->window);
1067 main_window_set_widgets(mainwin, type);
1068 gtk_widget_show(mainwin->window);
1070 gtk_widget_unref(folder_wid);
1071 gtk_widget_unref(summary_wid);
1072 gtk_widget_unref(message_wid);
1075 void main_window_get_size(MainWindow *mainwin)
1077 GtkAllocation *allocation;
1079 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1081 prefs_common.summaryview_width = allocation->width;
1083 if (mainwin->summaryview->msg_is_toggled_on)
1084 prefs_common.summaryview_height = allocation->height;
1086 prefs_common.mainview_width = allocation->width;
1088 allocation = &mainwin->window->allocation;
1090 prefs_common.mainview_height = allocation->height;
1091 prefs_common.mainwin_width = allocation->width;
1092 prefs_common.mainwin_height = allocation->height;
1094 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1096 prefs_common.folderview_width = allocation->width;
1097 prefs_common.folderview_height = allocation->height;
1100 void main_window_get_position(MainWindow *mainwin)
1104 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1106 prefs_common.mainview_x = x;
1107 prefs_common.mainview_y = y;
1108 prefs_common.mainwin_x = x;
1109 prefs_common.mainwin_y = y;
1111 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1114 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1119 if (alertpanel(_("Empty trash"),
1120 _("Empty all messages in trash?"),
1121 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1123 manage_window_focus_in(mainwin->window, NULL, NULL);
1126 procmsg_empty_trash();
1128 for (list = folder_get_list(); list != NULL; list = list->next) {
1131 folder = list->data;
1132 if (folder->trash) {
1133 folder_item_scan(folder->trash);
1134 folderview_update_item(folder->trash, TRUE);
1138 if (mainwin->summaryview->folder_item &&
1139 mainwin->summaryview->folder_item->stype == F_TRASH)
1140 gtk_widget_grab_focus(mainwin->folderview->ctree);
1143 void main_window_add_mailbox(MainWindow *mainwin)
1148 path = input_dialog(_("Add mailbox"),
1149 _("Input the location of mailbox.\n"
1150 "If the existing mailbox is specified, it will be\n"
1151 "scanned automatically."),
1154 if (folder_find_from_path(path)) {
1155 alertpanel_error(_("The mailbox `%s' already exists."), path);
1159 if (!strcmp(path, "Mail"))
1160 folder = folder_new(F_MH, _("Mailbox"), path);
1162 folder = folder_new(F_MH, g_basename(path), path);
1165 if (folder->create_tree(folder) < 0) {
1166 alertpanel_error(_("Creation of the mailbox failed.\n"
1167 "Maybe some files already exist, or you don't have the permission to write there."));
1168 folder_destroy(folder);
1173 folder_set_ui_func(folder, scan_tree_func, mainwin);
1174 folder->scan_tree(folder);
1175 folder_set_ui_func(folder, NULL, NULL);
1177 folderview_set(mainwin->folderview);
1180 void main_window_add_mbox(MainWindow *mainwin)
1186 path = input_dialog(_("Add mbox mailbox"),
1187 _("Input the location of mailbox."),
1192 if (folder_find_from_path(path)) {
1193 alertpanel_error(_("The mailbox `%s' already exists."), path);
1199 if (!strcmp(path, "Mail"))
1200 folder = folder_new(F_MBOX, _("Mailbox"), path);
1204 folder = folder_new(F_MBOX, g_basename(path), path);
1207 if (folder->create_tree(folder) < 0) {
1208 alertpanel_error(_("Creation of the mailbox failed."));
1209 folder_destroy(folder);
1215 item = folder_item_new(folder->name, NULL);
1216 item->folder = folder;
1217 folder->node = g_node_new(item);
1219 folder->create_folder(folder, item, "inbox");
1220 folder->create_folder(folder, item, "outbox");
1221 folder->create_folder(folder, item, "queue");
1222 folder->create_folder(folder, item, "draft");
1223 folder->create_folder(folder, item, "trash");
1225 folderview_set(mainwin->folderview);
1230 M_UNLOCKED = 1 << 0,
1231 M_MSG_EXIST = 1 << 1,
1232 M_TARGET_EXIST = 1 << 2,
1233 M_SINGLE_TARGET_EXIST = 1 << 3,
1235 M_ALLOW_REEDIT = 1 << 5,
1236 M_HAVE_ACCOUNT = 1 << 6,
1237 M_THREADED = 1 << 7,
1238 M_UNTHREADED = 1 << 8,
1242 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1244 SensitiveCond state = 0;
1245 SummarySelection selection;
1246 FolderItem *item = mainwin->summaryview->folder_item;
1248 selection = summary_get_selection_type(mainwin->summaryview);
1250 if (mainwin->lock_count == 0)
1251 state |= M_UNLOCKED;
1252 if (selection != SUMMARY_NONE)
1253 state |= M_MSG_EXIST;
1256 state |= M_THREADED;
1258 state |= M_UNTHREADED;
1260 if (selection == SUMMARY_SELECTED_SINGLE ||
1261 selection == SUMMARY_SELECTED_MULTIPLE)
1262 state |= M_TARGET_EXIST;
1263 if (selection == SUMMARY_SELECTED_SINGLE)
1264 state |= M_SINGLE_TARGET_EXIST;
1265 if (item && item->folder->type != F_NEWS)
1267 if (mainwin->summaryview->folder_item &&
1268 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1270 if (selection == SUMMARY_SELECTED_SINGLE &&
1272 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1273 item->stype == F_QUEUE)))
1274 state |= M_ALLOW_REEDIT;
1276 state |= M_HAVE_ACCOUNT;
1281 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1283 SensitiveCond state;
1291 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1292 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1293 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1294 {mainwin->compose_news_btn, M_HAVE_ACCOUNT},
1295 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1296 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1297 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1298 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1299 /* {mainwin->prefs_btn , M_UNLOCKED},
1300 {mainwin->account_btn , M_UNLOCKED}, */
1301 {mainwin->next_btn , M_MSG_EXIST},
1302 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1303 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1307 state = main_window_get_current_state(mainwin);
1309 for (i = 0; entry[i].widget != NULL; i++) {
1310 sensitive = ((entry[i].cond & state) == entry[i].cond);
1311 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1315 void main_window_set_menu_sensitive(MainWindow *mainwin)
1317 GtkItemFactory *ifactory;
1318 SensitiveCond state;
1322 static const struct {
1326 {"/File/Add mailbox..." , M_UNLOCKED},
1327 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1328 {"/File/Rescan folder tree" , M_UNLOCKED},
1329 {"/File/Folder" , M_UNLOCKED},
1330 {"/File/Import mbox file..." , M_UNLOCKED},
1331 {"/File/Export to mbox file...", M_UNLOCKED},
1332 {"/File/Empty trash" , M_UNLOCKED},
1333 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1334 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1335 {"/File/Close", M_UNLOCKED},
1336 {"/File/Exit" , M_UNLOCKED},
1338 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1339 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1341 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1342 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1343 /* {"/Message/Compose new message" , M_HAVE_ACCOUNT}, */
1344 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1345 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1346 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1347 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1348 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1349 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1350 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1351 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1352 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1353 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1354 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1355 {"/Message/Mark" , M_TARGET_EXIST},
1356 {"/Message/Add sender to address book", M_SINGLE_TARGET_EXIST},
1358 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1359 {"/Summary/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1360 {"/Summary/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1361 {"/Summary/Go to" , M_MSG_EXIST},
1362 {"/Summary/Go to/Prev message" , M_MSG_EXIST},
1363 {"/Summary/Go to/Next message" , M_MSG_EXIST},
1364 {"/Summary/Go to/Next unread message" , M_MSG_EXIST},
1365 {"/Summary/Go to/Prev marked message" , M_MSG_EXIST},
1366 {"/Summary/Go to/Next marked message" , M_MSG_EXIST},
1367 {"/Summary/Go to/Prev labeled message", M_MSG_EXIST},
1368 {"/Summary/Go to/Next labeled message", M_MSG_EXIST},
1369 {"/Summary/Sort" , M_MSG_EXIST},
1370 {"/Summary/Thread view" , M_UNTHREADED},
1371 {"/Summary/Unthread view" , M_THREADED},
1373 {"/Configuration", M_UNLOCKED},
1378 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1379 state = main_window_get_current_state(mainwin);
1381 for (i = 0; entry[i].entry != NULL; i++) {
1382 sensitive = ((entry[i].cond & state) == entry[i].cond);
1383 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1387 void main_window_popup(MainWindow *mainwin)
1393 gdk_window_get_origin(mainwin->window->window, &x, &y);
1394 sx = gdk_screen_width();
1395 sy = gdk_screen_height();
1396 x %= sx; if (x < 0) x = 0;
1397 y %= sy; if (y < 0) y = 0;
1398 gdk_window_move(mainwin->window->window, x, y);
1399 gdk_window_raise(mainwin->window->window);
1400 gdk_window_show(mainwin->window->window);
1402 debug_print("window position: x = %d, y = %d\n", x, y);
1404 switch (mainwin->type) {
1405 case SEPARATE_FOLDER:
1406 widget = mainwin->win.sep_folder.folderwin;
1407 gdk_window_get_origin(widget->window, &x, &y);
1408 x %= sx; if (x < 0) x = 0;
1409 y %= sy; if (y < 0) y = 0;
1410 gdk_window_move(widget->window, x, y);
1411 gdk_window_raise(widget->window);
1413 case SEPARATE_MESSAGE:
1414 widget = mainwin->win.sep_message.messagewin;
1415 gdk_window_get_origin(widget->window, &x, &y);
1416 x %= sx; if (x < 0) x = 0;
1417 y %= sy; if (y < 0) y = 0;
1418 gdk_window_move(widget->window, x, y);
1419 gdk_window_raise(widget->window);
1422 widget = mainwin->win.sep_both.folderwin;
1423 gdk_window_get_origin(widget->window, &x, &y);
1424 x %= sx; if (x < 0) x = 0;
1425 y %= sy; if (y < 0) y = 0;
1426 gdk_window_move(widget->window, x, y);
1427 gdk_window_raise(widget->window);
1428 widget = mainwin->win.sep_both.messagewin;
1429 gdk_window_get_origin(widget->window, &x, &y);
1430 x %= sx; if (x < 0) x = 0;
1431 y %= sy; if (y < 0) y = 0;
1432 gdk_window_move(widget->window, x, y);
1433 gdk_window_raise(widget->window);
1440 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1442 GtkWidget *folderwin = NULL;
1443 GtkWidget *messagewin = NULL;
1446 GtkWidget *vbox_body = mainwin->vbox_body;
1448 debug_print(_("Setting widgets..."));
1450 /* create separated window(s) if needed */
1451 if (type & SEPARATE_FOLDER) {
1452 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1453 gtk_window_set_policy(GTK_WINDOW(folderwin),
1455 gtk_widget_set_usize(folderwin, -1,
1456 prefs_common.mainview_height);
1457 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1459 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1460 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1463 if (type & SEPARATE_MESSAGE) {
1464 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1465 gtk_window_set_policy(GTK_WINDOW(messagewin),
1467 gtk_widget_set_usize
1468 (messagewin, prefs_common.mainview_width,
1469 prefs_common.mainview_height
1470 - prefs_common.summaryview_height
1471 + DEFAULT_HEADERVIEW_HEIGHT);
1472 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1474 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1475 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1481 hpaned = gtk_hpaned_new();
1482 gtk_widget_show(hpaned);
1483 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1484 gtk_paned_add1(GTK_PANED(hpaned),
1485 GTK_WIDGET_PTR(mainwin->folderview));
1487 vpaned = gtk_vpaned_new();
1488 if (mainwin->summaryview->msg_is_toggled_on) {
1489 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1490 gtk_paned_add1(GTK_PANED(vpaned),
1491 GTK_WIDGET_PTR(mainwin->summaryview));
1493 gtk_paned_add2(GTK_PANED(hpaned),
1494 GTK_WIDGET_PTR(mainwin->summaryview));
1495 gtk_widget_ref(vpaned);
1497 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1498 prefs_common.summaryview_width,
1499 prefs_common.summaryview_height);
1500 gtk_paned_add2(GTK_PANED(vpaned),
1501 GTK_WIDGET_PTR(mainwin->messageview));
1502 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1503 prefs_common.mainview_width, -1);
1504 gtk_widget_set_usize(mainwin->window,
1505 prefs_common.folderview_width +
1506 prefs_common.mainview_width,
1507 prefs_common.mainwin_height);
1508 gtk_widget_show_all(vpaned);
1510 mainwin->win.sep_none.hpaned = hpaned;
1511 mainwin->win.sep_none.vpaned = vpaned;
1513 case SEPARATE_FOLDER:
1514 vpaned = gtk_vpaned_new();
1515 if (mainwin->summaryview->msg_is_toggled_on) {
1516 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1518 gtk_paned_add1(GTK_PANED(vpaned),
1519 GTK_WIDGET_PTR(mainwin->summaryview));
1521 gtk_box_pack_start(GTK_BOX(vbox_body),
1522 GTK_WIDGET_PTR(mainwin->summaryview),
1524 gtk_widget_ref(vpaned);
1526 gtk_paned_add2(GTK_PANED(vpaned),
1527 GTK_WIDGET_PTR(mainwin->messageview));
1528 gtk_widget_show_all(vpaned);
1529 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1530 prefs_common.summaryview_width,
1531 prefs_common.summaryview_height);
1532 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1533 prefs_common.mainview_width, -1);
1534 gtk_widget_set_usize(mainwin->window,
1535 prefs_common.mainview_width,
1536 prefs_common.mainview_height);
1538 gtk_container_add(GTK_CONTAINER(folderwin),
1539 GTK_WIDGET_PTR(mainwin->folderview));
1541 mainwin->win.sep_folder.folderwin = folderwin;
1542 mainwin->win.sep_folder.vpaned = vpaned;
1544 gtk_widget_show_all(folderwin);
1546 case SEPARATE_MESSAGE:
1547 hpaned = gtk_hpaned_new();
1548 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1550 gtk_paned_add1(GTK_PANED(hpaned),
1551 GTK_WIDGET_PTR(mainwin->folderview));
1552 gtk_paned_add2(GTK_PANED(hpaned),
1553 GTK_WIDGET_PTR(mainwin->summaryview));
1554 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1555 prefs_common.summaryview_width,
1556 prefs_common.summaryview_height);
1557 gtk_widget_set_usize(mainwin->window,
1558 prefs_common.folderview_width +
1559 prefs_common.mainview_width,
1560 prefs_common.mainwin_height);
1561 gtk_widget_show_all(hpaned);
1562 gtk_container_add(GTK_CONTAINER(messagewin),
1563 GTK_WIDGET_PTR(mainwin->messageview));
1565 mainwin->win.sep_message.messagewin = messagewin;
1566 mainwin->win.sep_message.hpaned = hpaned;
1568 gtk_widget_show_all(messagewin);
1571 gtk_box_pack_start(GTK_BOX(vbox_body),
1572 GTK_WIDGET_PTR(mainwin->summaryview),
1574 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1575 prefs_common.summaryview_width,
1576 prefs_common.summaryview_height);
1577 gtk_widget_set_usize(mainwin->window,
1578 prefs_common.mainview_width,
1579 prefs_common.mainwin_height);
1580 gtk_container_add(GTK_CONTAINER(folderwin),
1581 GTK_WIDGET_PTR(mainwin->folderview));
1582 gtk_container_add(GTK_CONTAINER(messagewin),
1583 GTK_WIDGET_PTR(mainwin->messageview));
1585 mainwin->win.sep_both.folderwin = folderwin;
1586 mainwin->win.sep_both.messagewin = messagewin;
1588 gtk_widget_show_all(folderwin);
1589 gtk_widget_show_all(messagewin);
1593 mainwin->type = type;
1595 debug_print(_("done.\n"));
1598 #include "pixmaps/stock_mail_receive.xpm"
1599 #include "pixmaps/stock_mail_receive_all.xpm"
1600 #include "pixmaps/stock_mail_compose.xpm"
1601 #include "pixmaps/stock_news_compose.xpm"
1602 #include "pixmaps/stock_mail_reply.xpm"
1603 #include "pixmaps/stock_mail_reply_to_all.xpm"
1604 #include "pixmaps/stock_mail_reply_to_author.xpm"
1605 #include "pixmaps/stock_mail_forward.xpm"
1606 #include "pixmaps/stock_mail_send.xpm"
1607 #include "pixmaps/stock_preferences.xpm"
1608 #include "pixmaps/stock_properties.xpm"
1609 #include "pixmaps/stock_down_arrow.xpm"
1610 #include "pixmaps/stock_close.xpm"
1611 #include "pixmaps/stock_exec.xpm"
1613 #define CREATE_TOOLBAR_ICON(xpm_d) \
1615 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1616 &container->style->white, \
1618 icon_wid = gtk_pixmap_new(icon, mask); \
1621 static void main_window_toolbar_create(MainWindow *mainwin,
1622 GtkWidget *container)
1627 GtkWidget *icon_wid;
1629 GtkWidget *getall_btn;
1630 GtkWidget *compose_mail_btn;
1631 GtkWidget *compose_news_btn;
1632 GtkWidget *compose_mail_btn_plain;
1633 GtkWidget *compose_news_btn_plain;
1634 GtkWidget *reply_btn;
1635 GtkWidget *replyall_btn;
1636 GtkWidget *replysender_btn;
1638 GtkWidget *send_btn;
1640 GtkWidget *prefs_btn;
1641 GtkWidget *account_btn;
1643 GtkWidget *next_btn;
1644 GtkWidget *delete_btn;
1645 GtkWidget *exec_btn;
1646 GtkWidget *compose_type_btn;
1647 GtkWidget *compose_type_arrow;
1648 GtkWidget *compose_box;
1649 GtkWidget *compose_label;
1650 GtkTooltips *tooltips;
1652 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1654 gtk_container_add(GTK_CONTAINER(container), toolbar);
1655 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1656 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1657 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1658 GTK_TOOLBAR_SPACE_LINE);
1660 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1661 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1663 _("Get new mail from current account"),
1665 icon_wid, toolbar_inc_cb, mainwin);
1666 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1667 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1669 _("Get new mail from all accounts"),
1675 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1677 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1678 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1680 _("Send queued message(s)"),
1686 /* to implement Leandro's "combined" compose buttons, we create
1687 * two sets of compose buttons, one for normal (text + icon)
1688 * toolbar, and one for both text-only and icon-only toolbar;
1689 * we switch between those sets. */
1691 /* insert compose mail button widget */
1693 compose_mail_btn = gtk_button_new();
1694 gtk_widget_show(compose_mail_btn);
1695 tooltips = gtk_tooltips_new();
1696 gtk_tooltips_set_tip(tooltips, compose_mail_btn,
1697 _("Compose email message"),
1699 compose_box = gtk_vbox_new(0, 0);
1700 gtk_widget_show(compose_box);
1702 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1703 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1704 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1706 compose_label = gtk_label_new(_("Email"));
1707 gtk_widget_show(compose_label);
1708 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1710 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1711 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1712 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1715 /* insert compose news button widget */
1717 compose_news_btn = gtk_button_new();
1718 gtk_widget_show(compose_news_btn);
1719 tooltips = gtk_tooltips_new();
1720 gtk_tooltips_set_tip(tooltips, compose_news_btn,
1721 _("Compose news article"),
1723 compose_box = gtk_vbox_new(0, 0);
1724 gtk_widget_show(compose_box);
1726 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1727 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1728 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1730 compose_label = gtk_label_new(_("News"));
1731 gtk_widget_show(compose_label);
1732 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1734 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_news_btn), GTK_CAN_FOCUS);
1735 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1736 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1739 /* insert compose btn plain */
1741 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1742 compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1744 _("Compose an email message"),
1747 toolbar_compose_mail_cb,
1750 /* insert compose btn plain */
1752 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1753 compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1755 _("Compose a news message"),
1758 toolbar_compose_news_cb,
1761 /* insert compose button type widget */
1763 compose_type_btn = gtk_button_new();
1764 gtk_widget_show(compose_type_btn);
1766 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1767 gtk_widget_show(compose_type_arrow);
1769 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1771 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1772 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1774 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1777 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1779 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1780 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1782 _("Reply to the message"),
1787 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1788 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1793 toolbar_reply_to_all_cb,
1795 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1796 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1798 _("Reply to sender"),
1801 toolbar_reply_to_sender_cb,
1803 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1804 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1806 _("Forward the message"),
1812 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1814 CREATE_TOOLBAR_ICON(stock_close_xpm);
1815 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1817 _("Delete the message"),
1823 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1824 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1826 _("Execute marked process"),
1832 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1833 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1835 _("Next unread message"),
1838 toolbar_next_unread_cb,
1842 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1844 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1845 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1847 _("Common preference"),
1852 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1853 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1855 _("Account setting"),
1860 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1861 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1865 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1866 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1869 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1870 GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
1873 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
1874 GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
1877 mainwin->toolbar = toolbar;
1878 mainwin->get_btn = get_btn;
1879 mainwin->getall_btn = getall_btn;
1880 mainwin->compose_mail_btn = compose_mail_btn;
1881 mainwin->compose_news_btn = compose_news_btn;
1882 mainwin->compose_mail_btn_plain = compose_mail_btn_plain;
1883 mainwin->compose_news_btn_plain = compose_news_btn_plain;
1884 mainwin->reply_btn = reply_btn;
1885 mainwin->replyall_btn = replyall_btn;
1886 mainwin->replysender_btn = replysender_btn;
1887 mainwin->fwd_btn = fwd_btn;
1888 mainwin->send_btn = send_btn;
1890 mainwin->prefs_btn = prefs_btn;
1891 mainwin->account_btn = account_btn;
1893 mainwin->next_btn = next_btn;
1894 mainwin->delete_btn = delete_btn;
1895 mainwin->exec_btn = exec_btn;
1897 gtk_widget_show_all(toolbar);
1899 /* activate Leandro menu system */
1900 activate_compose_button(mainwin,
1901 prefs_common.toolbar_style,
1902 mainwin->compose_btn_type);
1905 /* callback functions */
1907 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1910 MainWindow *mainwindow = (MainWindow *) data;
1911 GtkWidget *compose_menu, *compose_item;
1913 g_return_if_fail(mainwindow != NULL);
1915 compose_menu = gtk_menu_new();
1917 compose_item = gtk_menu_item_new_with_label(_("Email message"));
1918 gtk_widget_show(compose_item);
1919 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1920 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1921 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1923 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1925 compose_item = gtk_menu_item_new_with_label(_("News article"));
1926 gtk_widget_show(compose_item);
1927 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1928 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1929 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1931 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1933 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1937 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1939 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1940 MainWindow *mainwindow = (MainWindow *) data;
1942 mainwindow->compose_btn_type = compose_type;
1944 activate_compose_button(mainwindow, prefs_common.toolbar_style, mainwindow->compose_btn_type);
1947 static void toolbar_inc_cb (GtkWidget *widget,
1950 MainWindow *mainwin = (MainWindow *)data;
1952 inc_mail_cb(mainwin, 0, NULL);
1955 static void toolbar_inc_all_cb (GtkWidget *widget,
1958 MainWindow *mainwin = (MainWindow *)data;
1960 inc_all_account_mail_cb(mainwin, 0, NULL);
1963 static void toolbar_send_cb (GtkWidget *widget,
1966 MainWindow *mainwin = (MainWindow *)data;
1968 send_queue_cb(mainwin, 0, NULL);
1971 static void toolbar_compose_cb (GtkWidget *widget,
1974 MainWindow *mainwin = (MainWindow *)data;
1976 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1977 compose_cb(mainwin, 0, NULL);
1979 compose_news_cb(mainwin, 0, NULL);
1982 static void toolbar_compose_news_cb (GtkWidget *widget,
1985 MainWindow *mainwin = (MainWindow *)data;
1987 compose_news_cb(mainwin, 0, NULL);
1990 static void toolbar_compose_mail_cb (GtkWidget *widget,
1993 MainWindow *mainwin = (MainWindow *)data;
1995 compose_mail_cb(mainwin, 0, NULL);
1998 static void toolbar_reply_cb (GtkWidget *widget,
2001 MainWindow *mainwin = (MainWindow *)data;
2003 reply_cb(mainwin, COMPOSE_REPLY, NULL);
2006 static void toolbar_reply_to_all_cb (GtkWidget *widget,
2009 MainWindow *mainwin = (MainWindow *)data;
2011 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
2014 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
2017 MainWindow *mainwin = (MainWindow *)data;
2019 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
2022 static void toolbar_forward_cb (GtkWidget *widget,
2025 MainWindow *mainwin = (MainWindow *)data;
2027 if (prefs_common.forward_as_attachment)
2028 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2030 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2033 static void toolbar_delete_cb (GtkWidget *widget,
2036 MainWindow *mainwin = (MainWindow *)data;
2038 summary_delete(mainwin->summaryview);
2041 static void toolbar_exec_cb (GtkWidget *widget,
2044 MainWindow *mainwin = (MainWindow *)data;
2046 summary_execute(mainwin->summaryview);
2049 static void toolbar_next_unread_cb (GtkWidget *widget,
2052 MainWindow *mainwin = (MainWindow *)data;
2054 next_unread_cb(mainwin, 0, NULL);
2057 static void toolbar_prefs_cb (GtkWidget *widget,
2060 prefs_common_open();
2063 static void toolbar_account_cb (GtkWidget *widget,
2066 MainWindow *mainwin = (MainWindow *)data;
2068 prefs_account_open_cb(mainwin, 0, NULL);
2071 static void toolbar_account_button_pressed(GtkWidget *widget,
2072 GdkEventButton *event,
2075 MainWindow *mainwin = (MainWindow *)data;
2078 if (event->button != 3) return;
2080 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2081 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2084 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2085 menu_button_position, widget,
2086 event->button, event->time);
2089 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2092 MainWindow *mainwin = (MainWindow *)data;
2096 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2097 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2100 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2101 menu_button_position, widget,
2102 event->button, event->time);
2105 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2107 MainWindow *mainwin = (MainWindow *)data;
2110 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2111 if (!button) return;
2112 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2113 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2114 manage_window_focus_in(mainwin->window, NULL, NULL);
2117 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2120 MainWindow *mainwin = (MainWindow *)data;
2122 if (mainwin->lock_count == 0)
2123 app_exit_cb(data, 0, widget);
2128 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2131 main_window_add_mailbox(mainwin);
2134 static void add_mbox_cb(MainWindow *mainwin, guint action,
2137 main_window_add_mbox(mainwin);
2140 static void update_folderview_cb(MainWindow *mainwin, guint action,
2143 summary_show(mainwin->summaryview, NULL, FALSE);
2144 folderview_update_all();
2147 static void new_folder_cb(MainWindow *mainwin, guint action,
2150 folderview_new_folder(mainwin->folderview);
2153 static void rename_folder_cb(MainWindow *mainwin, guint action,
2156 folderview_rename_folder(mainwin->folderview);
2159 static void delete_folder_cb(MainWindow *mainwin, guint action,
2162 folderview_delete_folder(mainwin->folderview);
2165 static void import_mbox_cb(MainWindow *mainwin, guint action,
2168 import_mbox(mainwin->summaryview->folder_item);
2171 static void export_mbox_cb(MainWindow *mainwin, guint action,
2174 export_mbox(mainwin->summaryview->folder_item);
2177 static void empty_trash_cb(MainWindow *mainwin, guint action,
2180 main_window_empty_trash(mainwin, TRUE);
2183 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2185 summary_save_as(mainwin->summaryview);
2188 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2190 summary_print(mainwin->summaryview);
2193 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2195 if (prefs_common.confirm_on_exit) {
2196 if (alertpanel(_("Exit"), _("Exit this program?"),
2197 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2199 manage_window_focus_in(mainwin->window, NULL, NULL);
2202 app_will_exit(widget, mainwin);
2205 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2208 summary_search(mainwin->summaryview);
2210 message_search(mainwin->messageview);
2213 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2216 switch (mainwin->type) {
2218 case SEPARATE_MESSAGE:
2220 case SEPARATE_FOLDER:
2221 if (GTK_CHECK_MENU_ITEM(widget)->active)
2222 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2224 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2227 if (GTK_CHECK_MENU_ITEM(widget)->active)
2228 gtk_widget_show(mainwin->win.sep_both.folderwin);
2230 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2235 static void toggle_message_cb(MainWindow *mainwin, guint action,
2238 switch (mainwin->type) {
2240 case SEPARATE_FOLDER:
2242 case SEPARATE_MESSAGE:
2243 if (GTK_CHECK_MENU_ITEM(widget)->active)
2244 gtk_widget_show(mainwin->win.sep_message.messagewin);
2246 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2249 if (GTK_CHECK_MENU_ITEM(widget)->active)
2250 gtk_widget_show(mainwin->win.sep_both.messagewin);
2252 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2257 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2260 activate_compose_button(mainwin, (ToolbarStyle)action,
2261 mainwin->compose_btn_type);
2263 switch ((ToolbarStyle)action) {
2265 gtk_widget_hide(mainwin->handlebox);
2267 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2271 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2275 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2280 if (action != TOOLBAR_NONE) {
2281 gtk_widget_show(mainwin->handlebox);
2282 gtk_widget_queue_resize(mainwin->handlebox);
2285 mainwin->toolbar_style = (ToolbarStyle)action;
2286 prefs_common.toolbar_style = (ToolbarStyle)action;
2289 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2292 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2293 gtk_widget_show(mainwin->hbox_stat);
2294 prefs_common.show_statusbar = TRUE;
2296 gtk_widget_hide(mainwin->hbox_stat);
2297 prefs_common.show_statusbar = FALSE;
2301 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2304 MainWindow *mainwin;
2307 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2308 g_return_if_fail(mainwin != NULL);
2310 type = mainwin->type ^ action;
2311 main_window_separation_change(mainwin, type);
2313 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2314 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2317 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2320 addressbook_open(NULL);
2323 static void log_window_show_cb(MainWindow *mainwin, guint action,
2326 log_window_show(mainwin->logwin);
2329 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2334 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2337 inc_all_account_mail(mainwin);
2340 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2344 if (procmsg_send_queue() < 0)
2345 alertpanel_error(_("Some errors occurred while sending queued messages."));
2347 statusbar_pop_all();
2349 for (list = folder_get_list(); list != NULL; list = list->next) {
2352 folder = list->data;
2353 if (folder->queue) {
2354 folder_item_scan(folder->queue);
2355 folderview_update_item(folder->queue, TRUE);
2360 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2362 if (mainwin->summaryview->folder_item) {
2363 if (mainwin->summaryview->folder_item->folder->account != NULL
2364 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2365 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2367 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2373 static void compose_mail_cb(MainWindow *mainwin, guint action,
2380 if (mainwin->summaryview->folder_item) {
2381 ac = mainwin->summaryview->folder_item->folder->account;
2382 if (ac && ac->protocol != A_NNTP) {
2383 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2388 if(cur_account && (cur_account->protocol != A_NNTP)) {
2389 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2393 list = account_get_list();
2394 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2395 ac = (PrefsAccount *) cur->data;
2396 if (ac->protocol != A_NNTP) {
2397 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2403 static void compose_news_cb(MainWindow *mainwin, guint action,
2406 PrefsAccount * ac = NULL;
2410 if (mainwin->summaryview->folder_item) {
2411 ac = mainwin->summaryview->folder_item->folder->account;
2412 if (ac && ac->protocol == A_NNTP) {
2413 compose_new_with_recipient
2414 (ac, mainwin->summaryview->folder_item->path);
2419 list = account_get_list();
2420 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2421 ac = (PrefsAccount *) cur->data;
2422 if (ac->protocol == A_NNTP) {
2429 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2431 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2434 msginfo = gtk_ctree_node_get_row_data
2435 (GTK_CTREE(mainwin->summaryview->ctree),
2436 mainwin->summaryview->selected);
2438 if (!msginfo) return;
2442 compose_reply(msginfo, prefs_common.reply_with_quote,
2445 case COMPOSE_REPLY_TO_SENDER:
2446 compose_reply(msginfo, prefs_common.reply_with_quote,
2449 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2450 compose_followup_and_reply_to(msginfo,
2451 prefs_common.reply_with_quote,
2454 case COMPOSE_REPLY_TO_ALL:
2455 compose_reply(msginfo, prefs_common.reply_with_quote,
2458 case COMPOSE_FORWARD:
2460 compose_forward(NULL, msginfo, FALSE);
2463 /* if (sel->next) FALL_THROUGH */
2464 case COMPOSE_FORWARD_AS_ATTACH:
2466 GSList *msginfo_list = NULL;
2467 for ( ; sel != NULL; sel = sel->next)
2468 msginfo_list = g_slist_append(msginfo_list,
2469 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2470 GTK_CTREE_NODE(sel->data)));
2471 compose_forward_multiple(NULL, msginfo_list);
2472 g_slist_free(msginfo_list);
2475 case COMPOSE_BOUNCE:
2476 compose_bounce(NULL, msginfo);
2479 g_warning("reply_cb(): invalid action type: %d\n", action);
2482 summary_set_marks_selected(mainwin->summaryview);
2485 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2487 summary_move_to(mainwin->summaryview);
2490 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2492 summary_copy_to(mainwin->summaryview);
2495 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2497 summary_delete(mainwin->summaryview);
2500 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2502 summary_open_msg(mainwin->summaryview);
2505 static void view_source_cb(MainWindow *mainwin, guint action,
2508 summary_view_source(mainwin->summaryview);
2511 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2513 summary_reedit(mainwin->summaryview);
2516 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2518 summary_mark(mainwin->summaryview);
2521 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2523 summary_unmark(mainwin->summaryview);
2526 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2529 summary_mark_as_unread(mainwin->summaryview);
2532 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2535 summary_mark_as_read(mainwin->summaryview);
2538 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2541 summary_mark_all_read(mainwin->summaryview);
2544 static void add_address_cb(MainWindow *mainwin, guint action,
2547 summary_add_address(mainwin->summaryview);
2550 static void set_charset_cb(MainWindow *mainwin, guint action,
2555 str = conv_get_charset_str((CharSet)action);
2556 g_free(prefs_common.force_charset);
2557 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2559 summary_redisplay_msg(mainwin->summaryview);
2561 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2564 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2566 GtkItemFactory *ifactory;
2568 if (!mainwin->summaryview->folder_item) return;
2570 ifactory = gtk_item_factory_from_widget(widget);
2573 summary_thread_build(mainwin->summaryview);
2574 mainwin->summaryview->folder_item->threaded = TRUE;
2575 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2576 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2578 summary_unthread(mainwin->summaryview);
2579 mainwin->summaryview->folder_item->threaded = FALSE;
2580 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2581 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2585 static void set_display_item_cb(MainWindow *mainwin, guint action,
2588 prefs_summary_column_open();
2591 static void sort_summary_cb(MainWindow *mainwin, guint action,
2594 summary_sort(mainwin->summaryview, (SummarySortType)action);
2597 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2600 summary_attract_by_subject(mainwin->summaryview);
2603 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2606 summary_delete_duplicated(mainwin->summaryview);
2609 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2611 summary_filter(mainwin->summaryview);
2614 static void execute_summary_cb(MainWindow *mainwin, guint action,
2617 summary_execute(mainwin->summaryview);
2620 static void update_summary_cb(MainWindow *mainwin, guint action,
2624 FolderView *folderview = mainwin->folderview;
2626 if (!mainwin->summaryview->folder_item) return;
2627 if (!folderview->opened) return;
2629 folder_update_op_count();
2631 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2632 folderview->opened);
2635 summary_show(mainwin->summaryview, fitem, TRUE);
2638 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2640 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2643 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2645 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2648 static void prev_unread_cb(MainWindow *mainwin, guint action,
2651 summary_select_prev_unread(mainwin->summaryview);
2654 static void next_unread_cb(MainWindow *mainwin, guint action,
2657 summary_select_next_unread(mainwin->summaryview);
2660 static void prev_marked_cb(MainWindow *mainwin, guint action,
2663 summary_select_prev_marked(mainwin->summaryview);
2666 static void next_marked_cb(MainWindow *mainwin, guint action,
2669 summary_select_next_marked(mainwin->summaryview);
2672 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2675 summary_select_prev_labeled(mainwin->summaryview);
2678 static void next_labeled_cb(MainWindow *mainwin, guint action,
2681 summary_select_next_labeled(mainwin->summaryview);
2684 static void goto_folder_cb(MainWindow *mainwin, guint action,
2687 FolderItem *to_folder;
2689 to_folder = foldersel_folder_sel(NULL, NULL);
2692 folderview_select(mainwin->folderview, to_folder);
2695 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2697 messageview_copy_clipboard(mainwin->messageview);
2700 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2702 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2703 summary_select_all(mainwin->summaryview);
2704 else if (mainwin->summaryview->msg_is_toggled_on &&
2705 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2706 messageview_select_all(mainwin->messageview);
2709 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2712 prefs_common_open();
2715 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2718 prefs_filter_open();
2721 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2724 prefs_scoring_open(NULL);
2727 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2730 prefs_filtering_open(NULL);
2733 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2736 prefs_template_open();
2739 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2743 new_account_cb(mainwin, 0, widget);
2745 gboolean prev_default = cur_account->is_default;
2747 prefs_account_open(cur_account);
2748 if (!prev_default && cur_account->is_default)
2749 account_set_as_default(cur_account);
2750 account_save_config_all();
2752 main_window_reflect_prefs_all();
2756 static void new_account_cb(MainWindow *mainwin, guint action,
2759 account_edit_open();
2760 if (!compose_get_compose_list()) account_add();
2763 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2765 cur_account = (PrefsAccount *)data;
2766 main_window_reflect_prefs_all();
2769 static void manual_open_cb(MainWindow *mainwin, guint action,
2772 manual_open((ManualLang)action);
2775 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2777 MainWindow *mainwin = (MainWindow *)data;
2781 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2782 LOCAL_FOLDER(folder)->rootpath,
2786 str = g_strdup_printf(_("Scanning folder %s ..."),
2787 LOCAL_FOLDER(folder)->rootpath);
2789 STATUSBAR_PUSH(mainwin, str);
2790 STATUSBAR_POP(mainwin);
2794 static void activate_compose_button (MainWindow *mainwin,
2796 ComposeButtonType type)
2798 if (style == TOOLBAR_NONE)
2801 if (style == TOOLBAR_BOTH) {
2802 gtk_widget_hide(mainwin->compose_mail_btn_plain);
2803 gtk_widget_hide(mainwin->compose_news_btn_plain);
2804 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2805 : mainwin->compose_news_btn);
2806 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2807 : mainwin->compose_mail_btn);
2808 mainwin->compose_btn_type = type;
2811 gtk_widget_hide(mainwin->compose_news_btn);
2812 gtk_widget_hide(mainwin->compose_mail_btn);
2813 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn_plain
2814 : mainwin->compose_news_btn_plain);
2815 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn_plain
2816 : mainwin->compose_mail_btn_plain);
2817 mainwin->compose_btn_type = type;
2821 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2823 if (mainwin->compose_btn_type != compose_btn_type)
2824 activate_compose_button(mainwin,
2825 prefs_common.toolbar_style,