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"
67 #include "addressbook.h"
68 #include "headerwindow.h"
69 #include "logwindow.h"
70 #include "manage_window.h"
71 #include "alertpanel.h"
72 #include "statusbar.h"
73 #include "inputdialog.h"
79 #include "prefs_templates.h"
82 #define AC_LABEL_WIDTH 240
84 #define STATUSBAR_PUSH(mainwin, str) \
86 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
87 mainwin->mainwin_cid, str); \
88 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
91 #define STATUSBAR_POP(mainwin) \
93 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
94 mainwin->mainwin_cid); \
97 /* list of all instantiated MainWindow */
98 static GList *mainwin_list = NULL;
100 static GdkCursor *watch_cursor;
102 static void main_window_show_cur_account (MainWindow *mainwin);
104 static void main_window_set_widgets (MainWindow *mainwin,
106 static void main_window_toolbar_create (MainWindow *mainwin,
107 GtkWidget *container);
109 /* callback functions */
110 static void toolbar_inc_cb (GtkWidget *widget,
112 static void toolbar_inc_all_cb (GtkWidget *widget,
114 static void toolbar_send_cb (GtkWidget *widget,
117 static void toolbar_compose_cb (GtkWidget *widget,
119 static void toolbar_popup_compose_type_cb(GtkWidget *widget,
121 static void toolbar_popup_compose_type_set(GtkWidget *widget,
123 static void toolbar_compose_news_cb (GtkWidget *widget,
125 static void toolbar_compose_mail_cb (GtkWidget *widget,
127 static void toolbar_reply_cb (GtkWidget *widget,
129 static void toolbar_reply_to_all_cb (GtkWidget *widget,
131 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
133 static void toolbar_forward_cb (GtkWidget *widget,
136 static void toolbar_delete_cb (GtkWidget *widget,
138 static void toolbar_exec_cb (GtkWidget *widget,
141 static void toolbar_next_unread_cb (GtkWidget *widget,
144 static void toolbar_prefs_cb (GtkWidget *widget,
146 static void toolbar_account_cb (GtkWidget *widget,
149 static void toolbar_account_button_pressed (GtkWidget *widget,
150 GdkEventButton *event,
152 static void ac_label_button_pressed (GtkWidget *widget,
153 GdkEventButton *event,
155 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
158 static gint main_window_close_cb (GtkWidget *widget,
162 static void add_mailbox_cb (MainWindow *mainwin,
165 static void add_mbox_cb (MainWindow *mainwin,
168 static void update_folderview_cb (MainWindow *mainwin,
171 static void new_folder_cb (MainWindow *mainwin,
174 static void rename_folder_cb (MainWindow *mainwin,
177 static void delete_folder_cb (MainWindow *mainwin,
180 static void import_mbox_cb (MainWindow *mainwin,
183 static void export_mbox_cb (MainWindow *mainwin,
186 static void empty_trash_cb (MainWindow *mainwin,
190 static void save_as_cb (MainWindow *mainwin,
193 static void print_cb (MainWindow *mainwin,
196 static void app_exit_cb (MainWindow *mainwin,
200 static void search_cb (MainWindow *mainwin,
204 static void toggle_folder_cb (MainWindow *mainwin,
207 static void toggle_message_cb (MainWindow *mainwin,
210 static void toggle_toolbar_cb (MainWindow *mainwin,
213 static void toggle_statusbar_cb (MainWindow *mainwin,
216 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
220 static void addressbook_open_cb (MainWindow *mainwin,
223 static void log_window_show_cb (MainWindow *mainwin,
227 static void inc_mail_cb (MainWindow *mainwin,
230 static void inc_all_account_mail_cb (MainWindow *mainwin,
234 static void send_queue_cb (MainWindow *mainwin,
238 static void compose_cb (MainWindow *mainwin,
241 static void compose_mail_cb(MainWindow *mainwin, guint action,
243 static void compose_news_cb(MainWindow *mainwin, guint action,
245 static void reply_cb (MainWindow *mainwin,
249 static void open_msg_cb (MainWindow *mainwin,
253 static void view_source_cb (MainWindow *mainwin,
257 static void reedit_cb (MainWindow *mainwin,
261 static void move_to_cb (MainWindow *mainwin,
264 static void copy_to_cb (MainWindow *mainwin,
267 static void delete_cb (MainWindow *mainwin,
271 static void mark_cb (MainWindow *mainwin,
274 static void unmark_cb (MainWindow *mainwin,
278 static void mark_as_unread_cb (MainWindow *mainwin,
281 static void mark_as_read_cb (MainWindow *mainwin,
284 static void mark_all_read_cb (MainWindow *mainwin,
287 static void add_address_cb (MainWindow *mainwin,
291 static void set_charset_cb (MainWindow *mainwin,
295 static void thread_cb (MainWindow *mainwin,
298 static void set_display_item_cb (MainWindow *mainwin,
301 static void sort_summary_cb (MainWindow *mainwin,
304 static void attract_by_subject_cb(MainWindow *mainwin,
308 static void delete_duplicated_cb (MainWindow *mainwin,
311 static void filter_cb (MainWindow *mainwin,
314 static void execute_summary_cb (MainWindow *mainwin,
317 static void update_summary_cb (MainWindow *mainwin,
321 static void prev_cb (MainWindow *mainwin,
324 static void next_cb (MainWindow *mainwin,
328 static void prev_unread_cb (MainWindow *mainwin,
331 static void next_unread_cb (MainWindow *mainwin,
334 static void prev_marked_cb (MainWindow *mainwin,
337 static void next_marked_cb (MainWindow *mainwin,
340 static void prev_labeled_cb (MainWindow *mainwin,
343 static void next_labeled_cb (MainWindow *mainwin,
347 static void goto_folder_cb (MainWindow *mainwin,
351 static void copy_cb (MainWindow *mainwin,
354 static void allsel_cb (MainWindow *mainwin,
358 static void prefs_common_open_cb (MainWindow *mainwin,
361 static void prefs_filter_open_cb (MainWindow *mainwin,
364 static void prefs_scoring_open_cb (MainWindow *mainwin,
367 static void prefs_filtering_open_cb (MainWindow *mainwin,
370 static void prefs_account_open_cb(MainWindow *mainwin,
373 static void new_account_cb (MainWindow *mainwin,
377 static void account_menu_cb (GtkMenuItem *menuitem,
380 static void manual_open_cb (MainWindow *mainwin,
384 static void scan_tree_func (Folder *folder,
388 static void activate_compose_button (MainWindow *mainwin,
390 ComposeButtonType type);
392 static void prefs_templates_open_cb(MainWindow *mainwin,
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)},
513 #undef CODESET_SEPARATOR
514 #undef CODESET_ACTION
516 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
517 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
518 {N_("/_Message/Get from _all accounts"),
519 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
520 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_Message/Send queued messa_ges"),
522 NULL, send_queue_cb, 0, NULL},
523 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
525 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
526 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
527 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
528 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
529 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
530 {N_("/_Message/_Forward"), "<shift><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
531 {N_("/_Message/Forward as a_ttachment"),
532 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
533 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
535 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
537 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
538 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
539 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
540 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
541 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
542 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
543 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
545 {N_("/_Message/_Mark/Mark as rea_d"),
546 NULL, mark_as_read_cb, 0, NULL},
547 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
548 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
550 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
551 {N_("/_Summary/_Delete duplicated messages"),
552 NULL, delete_duplicated_cb, 0, NULL},
553 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
554 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
555 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
556 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
557 {N_("/_Summary/Go _to"), NULL, NULL, 0, "<Branch>"},
558 {N_("/_Summary/Go _to/_Prev message"), NULL, prev_cb, 0, NULL},
559 {N_("/_Summary/Go _to/_Next message"), NULL, next_cb, 0, NULL},
560 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
561 {N_("/_Summary/Go _to/P_rev unread message"),
562 NULL, prev_unread_cb, 0, NULL},
563 {N_("/_Summary/Go _to/N_ext unread message"),
564 NULL, next_unread_cb, 0, NULL},
565 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_Summary/Go _to/Prev _marked message"),
567 NULL, prev_marked_cb, 0, NULL},
568 {N_("/_Summary/Go _to/Next m_arked message"),
569 NULL, next_marked_cb, 0, NULL},
570 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
571 {N_("/_Summary/Go _to/Prev _labeled message"),
572 NULL, prev_labeled_cb, 0, NULL},
573 {N_("/_Summary/Go _to/Next la_beled message"),
574 NULL, next_labeled_cb, 0, NULL},
575 {N_("/_Summary/_Go to other folder..."),"<alt>G", goto_folder_cb, 0, NULL},
576 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
577 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
578 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
579 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
580 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
581 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
582 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
583 {N_("/_Summary/_Sort/Sort by _color label"),
584 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
585 {N_("/_Summary/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
586 {N_("/_Summary/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
587 {N_("/_Summary/_Sort/Sort by a_ttachment"),
588 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
589 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
590 {N_("/_Summary/_Sort/_Attract by subject"),
591 NULL, attract_by_subject_cb, 0, NULL},
592 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
593 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
594 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
596 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
597 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
598 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
600 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
601 {N_("/_Configuration/_Common preferences..."),
602 NULL, prefs_common_open_cb, 0, NULL},
603 {N_("/_Configuration/_Filter setting..."),
604 NULL, prefs_filter_open_cb, 0, NULL},
605 {N_("/_Configuration/_Scoring ..."),
606 NULL, prefs_scoring_open_cb, 0, NULL},
607 {N_("/_Configuration/_Filtering ..."),
608 NULL, prefs_filtering_open_cb, 0, NULL},
609 {N_("/_Configuration/_Templates ..."),
610 NULL, prefs_templates_open_cb, 0, NULL},
611 {N_("/_Configuration/_Preferences per account..."),
612 NULL, prefs_account_open_cb, 0, NULL},
613 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
614 {N_("/_Configuration/Create _new account..."),
615 NULL, new_account_cb, 0, NULL},
616 {N_("/_Configuration/_Edit accounts..."),
617 NULL, account_edit_open, 0, NULL},
618 {N_("/_Configuration/C_hange current account"),
619 NULL, NULL, 0, "<Branch>"},
621 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
622 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
623 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
624 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
625 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
626 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
629 MainWindow *main_window_create(SeparateType type)
635 GtkWidget *handlebox;
636 GtkWidget *vbox_body;
637 GtkWidget *hbox_stat;
638 GtkWidget *statusbar;
639 GtkWidget *progressbar;
640 GtkWidget *statuslabel;
641 GtkWidget *ac_button;
644 FolderView *folderview;
645 SummaryView *summaryview;
646 MessageView *messageview;
647 GdkColormap *colormap;
650 guint n_menu_entries;
651 GtkItemFactory *ifactory;
656 debug_print(_("Creating main window...\n"));
657 mainwin = g_new0(MainWindow, 1);
660 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
661 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
662 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
663 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
664 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
665 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
666 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
667 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
668 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
670 gtk_widget_realize(window);
672 gtkut_widget_set_app_icon(window);
674 vbox = gtk_vbox_new(FALSE, 0);
675 gtk_widget_show(vbox);
676 gtk_container_add(GTK_CONTAINER(window), vbox);
679 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
680 menubar = menubar_create(window, mainwin_entries,
681 n_menu_entries, "<Main>", mainwin);
682 gtk_widget_show(menubar);
683 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
685 handlebox = gtk_handle_box_new();
686 gtk_widget_show(handlebox);
687 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
689 main_window_toolbar_create(mainwin, handlebox);
691 /* vbox that contains body */
692 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
693 gtk_widget_show(vbox_body);
694 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
695 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
697 hbox_stat = gtk_hbox_new(FALSE, 2);
698 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
700 statusbar = statusbar_create();
701 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
703 progressbar = gtk_progress_bar_new();
704 gtk_widget_set_usize(progressbar, 120, 1);
705 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
707 statuslabel = gtk_label_new("");
708 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
710 ac_button = gtk_button_new();
711 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
712 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
713 gtk_widget_set_usize(ac_button, -1, 1);
714 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
715 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
716 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
718 ac_label = gtk_label_new("");
719 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
721 gtk_widget_show_all(hbox_stat);
724 mainwin->folderview = folderview = folderview_create();
725 mainwin->summaryview = summaryview = summary_create();
726 mainwin->messageview = messageview = messageview_create();
727 mainwin->headerwin = header_window_create();
728 mainwin->logwin = log_window_create();
730 folderview->mainwin = mainwin;
731 folderview->summaryview = summaryview;
733 summaryview->mainwin = mainwin;
734 summaryview->folderview = folderview;
735 summaryview->messageview = messageview;
736 summaryview->headerwin = mainwin->headerwin;
737 summaryview->window = window;
739 messageview->mainwin = mainwin;
741 mainwin->window = window;
742 mainwin->vbox = vbox;
743 mainwin->menubar = menubar;
744 mainwin->handlebox = handlebox;
745 mainwin->vbox_body = vbox_body;
746 mainwin->hbox_stat = hbox_stat;
747 mainwin->statusbar = statusbar;
748 mainwin->progressbar = progressbar;
749 mainwin->statuslabel = statuslabel;
750 mainwin->ac_button = ac_button;
751 mainwin->ac_label = ac_label;
753 /* set context IDs for status bar */
754 mainwin->mainwin_cid = gtk_statusbar_get_context_id
755 (GTK_STATUSBAR(statusbar), "Main Window");
756 mainwin->folderview_cid = gtk_statusbar_get_context_id
757 (GTK_STATUSBAR(statusbar), "Folder View");
758 mainwin->summaryview_cid = gtk_statusbar_get_context_id
759 (GTK_STATUSBAR(statusbar), "Summary View");
761 /* allocate colors for summary view and folder view */
762 summaryview->color_marked.red = summaryview->color_marked.green = 0;
763 summaryview->color_marked.blue = (guint16)65535;
765 summaryview->color_dim.red = summaryview->color_dim.green =
766 summaryview->color_dim.blue = COLOR_DIM;
768 folderview->color_new.red = (guint16)55000;
769 folderview->color_new.green = folderview->color_new.blue = 15000;
771 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
772 &folderview->color_op);
774 summaryview->color_important.red = 0;
775 summaryview->color_marked.green = 0;
776 summaryview->color_important.blue = (guint16)65535;
778 color[0] = summaryview->color_marked;
779 color[1] = summaryview->color_dim;
780 color[2] = folderview->color_new;
781 color[3] = folderview->color_op;
783 colormap = gdk_window_get_colormap(window->window);
784 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
785 for (i = 0; i < 4; i++) {
786 if (success[i] == FALSE)
787 g_warning(_("MainWindow: color allocation %d failed\n"), i);
790 debug_print(_("done.\n"));
792 main_window_set_widgets(mainwin, type);
795 ifactory = gtk_item_factory_from_widget(menubar);
796 menuitem = gtk_item_factory_get_item
797 (ifactory, "/View/Code set/Auto detect");
798 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
800 switch (prefs_common.toolbar_style) {
802 menuitem = gtk_item_factory_get_item
803 (ifactory, "/View/Toolbar/None");
806 menuitem = gtk_item_factory_get_item
807 (ifactory, "/View/Toolbar/Icon");
810 menuitem = gtk_item_factory_get_item
811 (ifactory, "/View/Toolbar/Text");
814 menuitem = gtk_item_factory_get_item
815 (ifactory, "/View/Toolbar/Icon and text");
817 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
819 gtk_widget_hide(mainwin->hbox_stat);
820 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
821 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
822 prefs_common.show_statusbar);
824 /* set the check of the SEPARATE_xxx menu items. we also need the main window
825 * as a property and pass the action type to the callback */
826 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
828 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
829 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
830 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
831 GUINT_TO_POINTER(SEPARATE_FOLDER));
833 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
835 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
836 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
837 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
838 GUINT_TO_POINTER(SEPARATE_MESSAGE));
841 menu_set_sensitive(ifactory, "/Summary/Thread view",
842 prefs_common.enable_thread ? FALSE : TRUE);
843 menu_set_sensitive(ifactory, "/Summary/Unthread view",
844 prefs_common.enable_thread ? TRUE : FALSE);
846 /*main_window_set_thread_option(mainwin);*/
849 /* set account selection menu */
850 ac_menu = gtk_item_factory_get_widget
851 (ifactory, "/Configuration/Change current account");
852 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
853 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
854 mainwin->ac_menu = ac_menu;
856 main_window_set_toolbar_sensitive(mainwin);
858 /* show main window */
859 gtk_widget_set_uposition(mainwin->window,
860 prefs_common.mainwin_x,
861 prefs_common.mainwin_y);
862 gtk_widget_set_usize(window, prefs_common.mainwin_width,
863 prefs_common.mainwin_height);
865 gtk_widget_show(mainwin->window);
867 /* initialize views */
868 folderview_init(folderview);
869 summary_init(summaryview);
870 messageview_init(messageview);
871 header_window_init(mainwin->headerwin);
872 log_window_init(mainwin->logwin);
875 mainwin->lock_count = 0;
876 mainwin->cursor_count = 0;
879 watch_cursor = gdk_cursor_new(GDK_WATCH);
881 mainwin_list = g_list_append(mainwin_list, mainwin);
886 void main_window_cursor_wait(MainWindow *mainwin)
889 if (mainwin->cursor_count == 0)
890 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
892 mainwin->cursor_count++;
897 void main_window_cursor_normal(MainWindow *mainwin)
899 if (mainwin->cursor_count)
900 mainwin->cursor_count--;
902 if (mainwin->cursor_count == 0)
903 gdk_window_set_cursor(mainwin->window->window, NULL);
908 /* lock / unlock the user-interface */
909 void main_window_lock(MainWindow *mainwin)
911 if (mainwin->lock_count == 0)
912 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
914 mainwin->lock_count++;
916 main_window_set_menu_sensitive(mainwin);
917 main_window_set_toolbar_sensitive(mainwin);
920 void main_window_unlock(MainWindow *mainwin)
922 if (mainwin->lock_count)
923 mainwin->lock_count--;
925 main_window_set_menu_sensitive(mainwin);
926 main_window_set_toolbar_sensitive(mainwin);
928 if (mainwin->lock_count == 0)
929 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
932 void main_window_reflect_prefs_all(void)
937 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
938 mainwin = (MainWindow *)cur->data;
940 main_window_show_cur_account(mainwin);
941 main_window_set_menu_sensitive(mainwin);
942 main_window_set_toolbar_sensitive(mainwin);
944 if (prefs_common.immediate_exec)
945 gtk_widget_hide(mainwin->exec_btn);
947 gtk_widget_show(mainwin->exec_btn);
949 summary_change_display_item(mainwin->summaryview);
950 summary_redisplay_msg(mainwin->summaryview);
951 headerview_set_visibility(mainwin->messageview->headerview,
952 prefs_common.display_header_pane);
956 void main_window_set_account_menu(GList *account_list)
958 GList *cur, *cur_ac, *cur_item;
961 PrefsAccount *ac_prefs;
963 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
964 mainwin = (MainWindow *)cur->data;
966 /* destroy all previous menu item */
967 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
968 while (cur_item != NULL) {
969 GList *next = cur_item->next;
970 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
974 for (cur_ac = account_list; cur_ac != NULL;
975 cur_ac = cur_ac->next) {
976 ac_prefs = (PrefsAccount *)cur_ac->data;
978 menuitem = gtk_menu_item_new_with_label
979 (ac_prefs->account_name
980 ? ac_prefs->account_name : _("Untitled"));
981 gtk_widget_show(menuitem);
982 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
983 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
984 GTK_SIGNAL_FUNC(account_menu_cb),
990 static void main_window_show_cur_account(MainWindow *mainwin)
995 ac_name = g_strdup(cur_account
996 ? (cur_account->account_name
997 ? cur_account->account_name : _("Untitled"))
1001 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1003 buf = g_strdup(PROG_VERSION);
1004 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1007 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1008 gtk_widget_queue_resize(mainwin->ac_button);
1013 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1015 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1016 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1017 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1019 if (mainwin->type == type) return;
1021 /* remove widgets from those containers */
1022 gtk_widget_ref(folder_wid);
1023 gtk_widget_ref(summary_wid);
1024 gtk_widget_ref(message_wid);
1025 gtk_container_remove
1026 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1027 gtk_container_remove
1028 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1029 gtk_container_remove
1030 (GTK_CONTAINER(message_wid->parent), message_wid);
1032 /* clean containers */
1033 switch (mainwin->type) {
1035 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1037 case SEPARATE_FOLDER:
1038 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1039 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1041 case SEPARATE_MESSAGE:
1042 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1043 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1046 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1047 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1051 gtk_widget_hide(mainwin->window);
1052 main_window_set_widgets(mainwin, type);
1053 gtk_widget_show(mainwin->window);
1055 gtk_widget_unref(folder_wid);
1056 gtk_widget_unref(summary_wid);
1057 gtk_widget_unref(message_wid);
1060 void main_window_get_size(MainWindow *mainwin)
1062 GtkAllocation *allocation;
1064 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1066 prefs_common.summaryview_width = allocation->width;
1068 if (mainwin->summaryview->msg_is_toggled_on)
1069 prefs_common.summaryview_height = allocation->height;
1071 prefs_common.mainview_width = allocation->width;
1073 allocation = &mainwin->window->allocation;
1075 prefs_common.mainview_height = allocation->height;
1076 prefs_common.mainwin_width = allocation->width;
1077 prefs_common.mainwin_height = allocation->height;
1079 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1081 prefs_common.folderview_width = allocation->width;
1082 prefs_common.folderview_height = allocation->height;
1085 void main_window_get_position(MainWindow *mainwin)
1089 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1091 prefs_common.mainview_x = x;
1092 prefs_common.mainview_y = y;
1093 prefs_common.mainwin_x = x;
1094 prefs_common.mainwin_y = y;
1096 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1099 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1104 if (alertpanel(_("Empty trash"),
1105 _("Empty all messages in trash?"),
1106 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1108 manage_window_focus_in(mainwin->window, NULL, NULL);
1111 procmsg_empty_trash();
1113 for (list = folder_get_list(); list != NULL; list = list->next) {
1116 folder = list->data;
1117 if (folder->trash) {
1118 folder_item_scan(folder->trash);
1119 folderview_update_item(folder->trash, TRUE);
1123 if (mainwin->summaryview->folder_item &&
1124 mainwin->summaryview->folder_item->stype == F_TRASH)
1125 gtk_widget_grab_focus(mainwin->folderview->ctree);
1128 void main_window_add_mailbox(MainWindow *mainwin)
1133 path = input_dialog(_("Add mailbox"),
1134 _("Input the location of mailbox.\n"
1135 "If the existing mailbox is specified, it will be\n"
1136 "scanned automatically."),
1139 if (folder_find_from_path(path)) {
1140 alertpanel_error(_("The mailbox `%s' already exists."), path);
1144 if (!strcmp(path, "Mail"))
1145 folder = folder_new(F_MH, _("Mailbox"), path);
1147 folder = folder_new(F_MH, g_basename(path), path);
1150 if (folder->create_tree(folder) < 0) {
1151 alertpanel_error(_("Creation of the mailbox failed.\n"
1152 "Maybe some files already exist, or you don't have the permission to write there."));
1153 folder_destroy(folder);
1158 folder_set_ui_func(folder, scan_tree_func, mainwin);
1159 folder->scan_tree(folder);
1160 folder_set_ui_func(folder, NULL, NULL);
1162 folderview_set(mainwin->folderview);
1165 void main_window_add_mbox(MainWindow *mainwin)
1171 path = input_dialog(_("Add mbox mailbox"),
1172 _("Input the location of mailbox."),
1177 if (folder_find_from_path(path)) {
1178 alertpanel_error(_("The mailbox `%s' already exists."), path);
1184 if (!strcmp(path, "Mail"))
1185 folder = folder_new(F_MBOX, _("Mailbox"), path);
1189 folder = folder_new(F_MBOX, g_basename(path), path);
1192 if (folder->create_tree(folder) < 0) {
1193 alertpanel_error(_("Creation of the mailbox failed."));
1194 folder_destroy(folder);
1200 item = folder_item_new(folder->name, NULL);
1201 item->folder = folder;
1202 folder->node = g_node_new(item);
1204 folder->create_folder(folder, item, "inbox");
1205 folder->create_folder(folder, item, "outbox");
1206 folder->create_folder(folder, item, "queue");
1207 folder->create_folder(folder, item, "draft");
1208 folder->create_folder(folder, item, "trash");
1210 folderview_set(mainwin->folderview);
1215 M_UNLOCKED = 1 << 0,
1216 M_MSG_EXIST = 1 << 1,
1217 M_TARGET_EXIST = 1 << 2,
1218 M_SINGLE_TARGET_EXIST = 1 << 3,
1220 M_ALLOW_REEDIT = 1 << 5,
1221 M_HAVE_ACCOUNT = 1 << 6,
1222 M_THREADED = 1 << 7,
1223 M_UNTHREADED = 1 << 8,
1227 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1229 SensitiveCond state = 0;
1230 SummarySelection selection;
1232 selection = summary_get_selection_type(mainwin->summaryview);
1234 if (mainwin->lock_count == 0)
1235 state |= M_UNLOCKED;
1236 if (selection != SUMMARY_NONE)
1237 state |= M_MSG_EXIST;
1238 if (mainwin->summaryview->folder_item) {
1239 if (mainwin->summaryview->folder_item->threaded)
1240 state |= M_THREADED;
1242 state |= M_UNTHREADED;
1244 if (selection == SUMMARY_SELECTED_SINGLE ||
1245 selection == SUMMARY_SELECTED_MULTIPLE)
1246 state |= M_TARGET_EXIST;
1247 if (selection == SUMMARY_SELECTED_SINGLE)
1248 state |= M_SINGLE_TARGET_EXIST;
1249 if (mainwin->summaryview->folder_item &&
1250 mainwin->summaryview->folder_item->folder->type != F_NEWS)
1252 if (mainwin->summaryview->folder_item &&
1253 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1255 if (selection == SUMMARY_SELECTED_SINGLE &&
1256 (mainwin->summaryview->folder_item &&
1257 (mainwin->summaryview->folder_item->stype == F_DRAFT ||
1258 mainwin->summaryview->folder_item->stype == F_OUTBOX ||
1259 mainwin->summaryview->folder_item->stype == F_QUEUE)))
1260 state |= M_ALLOW_REEDIT;
1262 state |= M_HAVE_ACCOUNT;
1267 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1269 SensitiveCond state;
1277 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1278 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1279 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1280 {mainwin->compose_news_btn, M_HAVE_ACCOUNT},
1281 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1282 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1283 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1284 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1285 /* {mainwin->prefs_btn , M_UNLOCKED},
1286 {mainwin->account_btn , M_UNLOCKED}, */
1287 {mainwin->next_btn , M_MSG_EXIST},
1288 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1289 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1293 state = main_window_get_current_state(mainwin);
1295 for (i = 0; entry[i].widget != NULL; i++) {
1296 sensitive = ((entry[i].cond & state) == entry[i].cond);
1297 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1301 void main_window_set_menu_sensitive(MainWindow *mainwin)
1303 GtkItemFactory *ifactory;
1304 SensitiveCond state;
1308 static const struct {
1312 {"/File/Add mailbox..." , M_UNLOCKED},
1313 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1314 {"/File/Rescan folder tree" , M_UNLOCKED},
1315 {"/File/Folder" , M_UNLOCKED},
1316 {"/File/Import mbox file..." , M_UNLOCKED},
1317 {"/File/Export to mbox file...", M_UNLOCKED},
1318 {"/File/Empty trash" , M_UNLOCKED},
1319 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1320 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1321 {"/File/Close", M_UNLOCKED},
1322 {"/File/Exit" , M_UNLOCKED},
1324 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1325 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1327 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1328 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1329 /* {"/Message/Compose new message" , M_HAVE_ACCOUNT}, */
1330 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1331 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1332 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1333 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1334 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1335 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1336 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1337 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1338 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1339 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1340 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1341 {"/Message/Mark" , M_TARGET_EXIST},
1342 {"/Message/Add sender to address book", M_SINGLE_TARGET_EXIST},
1344 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1345 {"/Summary/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1346 {"/Summary/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1347 {"/Summary/Go to" , M_MSG_EXIST},
1348 {"/Summary/Go to/Prev message" , M_MSG_EXIST},
1349 {"/Summary/Go to/Next message" , M_MSG_EXIST},
1350 {"/Summary/Go to/Next unread message" , M_MSG_EXIST},
1351 {"/Summary/Go to/Prev marked message" , M_MSG_EXIST},
1352 {"/Summary/Go to/Next marked message" , M_MSG_EXIST},
1353 {"/Summary/Go to/Prev labeled message", M_MSG_EXIST},
1354 {"/Summary/Go to/Next labeled message", M_MSG_EXIST},
1355 {"/Summary/Sort" , M_MSG_EXIST},
1356 {"/Summary/Thread view" , M_UNTHREADED},
1357 {"/Summary/Unthread view" , M_THREADED},
1359 {"/Configuration", M_UNLOCKED},
1364 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1365 state = main_window_get_current_state(mainwin);
1367 for (i = 0; entry[i].entry != NULL; i++) {
1368 sensitive = ((entry[i].cond & state) == entry[i].cond);
1369 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1373 void main_window_popup(MainWindow *mainwin)
1379 gdk_window_get_origin(mainwin->window->window, &x, &y);
1380 sx = gdk_screen_width();
1381 sy = gdk_screen_height();
1382 x %= sx; if (x < 0) x = 0;
1383 y %= sy; if (y < 0) y = 0;
1384 gdk_window_move(mainwin->window->window, x, y);
1385 gdk_window_raise(mainwin->window->window);
1386 gdk_window_show(mainwin->window->window);
1388 debug_print("window position: x = %d, y = %d\n", x, y);
1390 switch (mainwin->type) {
1391 case SEPARATE_FOLDER:
1392 widget = mainwin->win.sep_folder.folderwin;
1393 gdk_window_get_origin(widget->window, &x, &y);
1394 x %= sx; if (x < 0) x = 0;
1395 y %= sy; if (y < 0) y = 0;
1396 gdk_window_move(widget->window, x, y);
1397 gdk_window_raise(widget->window);
1399 case SEPARATE_MESSAGE:
1400 widget = mainwin->win.sep_message.messagewin;
1401 gdk_window_get_origin(widget->window, &x, &y);
1402 x %= sx; if (x < 0) x = 0;
1403 y %= sy; if (y < 0) y = 0;
1404 gdk_window_move(widget->window, x, y);
1405 gdk_window_raise(widget->window);
1408 widget = mainwin->win.sep_both.folderwin;
1409 gdk_window_get_origin(widget->window, &x, &y);
1410 x %= sx; if (x < 0) x = 0;
1411 y %= sy; if (y < 0) y = 0;
1412 gdk_window_move(widget->window, x, y);
1413 gdk_window_raise(widget->window);
1414 widget = mainwin->win.sep_both.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);
1426 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1428 GtkWidget *folderwin = NULL;
1429 GtkWidget *messagewin = NULL;
1432 GtkWidget *vbox_body = mainwin->vbox_body;
1434 debug_print(_("Setting widgets..."));
1436 /* create separated window(s) if needed */
1437 if (type & SEPARATE_FOLDER) {
1438 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1439 gtk_window_set_policy(GTK_WINDOW(folderwin),
1441 gtk_widget_set_usize(folderwin, -1,
1442 prefs_common.mainview_height);
1443 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1445 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1446 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1449 if (type & SEPARATE_MESSAGE) {
1450 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1451 gtk_window_set_policy(GTK_WINDOW(messagewin),
1453 gtk_widget_set_usize
1454 (messagewin, prefs_common.mainview_width,
1455 prefs_common.mainview_height
1456 - prefs_common.summaryview_height
1457 + DEFAULT_HEADERVIEW_HEIGHT);
1458 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1460 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1461 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1467 hpaned = gtk_hpaned_new();
1468 gtk_widget_show(hpaned);
1469 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1470 gtk_paned_add1(GTK_PANED(hpaned),
1471 GTK_WIDGET_PTR(mainwin->folderview));
1473 vpaned = gtk_vpaned_new();
1474 if (mainwin->summaryview->msg_is_toggled_on) {
1475 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1476 gtk_paned_add1(GTK_PANED(vpaned),
1477 GTK_WIDGET_PTR(mainwin->summaryview));
1479 gtk_paned_add2(GTK_PANED(hpaned),
1480 GTK_WIDGET_PTR(mainwin->summaryview));
1481 gtk_widget_ref(vpaned);
1483 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1484 prefs_common.summaryview_width,
1485 prefs_common.summaryview_height);
1486 gtk_paned_add2(GTK_PANED(vpaned),
1487 GTK_WIDGET_PTR(mainwin->messageview));
1488 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1489 prefs_common.mainview_width, -1);
1490 gtk_widget_set_usize(mainwin->window,
1491 prefs_common.folderview_width +
1492 prefs_common.mainview_width,
1493 prefs_common.mainwin_height);
1494 gtk_widget_show_all(vpaned);
1496 mainwin->win.sep_none.hpaned = hpaned;
1497 mainwin->win.sep_none.vpaned = vpaned;
1499 case SEPARATE_FOLDER:
1500 vpaned = gtk_vpaned_new();
1501 if (mainwin->summaryview->msg_is_toggled_on) {
1502 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1504 gtk_paned_add1(GTK_PANED(vpaned),
1505 GTK_WIDGET_PTR(mainwin->summaryview));
1507 gtk_box_pack_start(GTK_BOX(vbox_body),
1508 GTK_WIDGET_PTR(mainwin->summaryview),
1510 gtk_widget_ref(vpaned);
1512 gtk_paned_add2(GTK_PANED(vpaned),
1513 GTK_WIDGET_PTR(mainwin->messageview));
1514 gtk_widget_show_all(vpaned);
1515 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1516 prefs_common.summaryview_width,
1517 prefs_common.summaryview_height);
1518 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1519 prefs_common.mainview_width, -1);
1520 gtk_widget_set_usize(mainwin->window,
1521 prefs_common.mainview_width,
1522 prefs_common.mainview_height);
1524 gtk_container_add(GTK_CONTAINER(folderwin),
1525 GTK_WIDGET_PTR(mainwin->folderview));
1527 mainwin->win.sep_folder.folderwin = folderwin;
1528 mainwin->win.sep_folder.vpaned = vpaned;
1530 gtk_widget_show_all(folderwin);
1532 case SEPARATE_MESSAGE:
1533 hpaned = gtk_hpaned_new();
1534 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1536 gtk_paned_add1(GTK_PANED(hpaned),
1537 GTK_WIDGET_PTR(mainwin->folderview));
1538 gtk_paned_add2(GTK_PANED(hpaned),
1539 GTK_WIDGET_PTR(mainwin->summaryview));
1540 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1541 prefs_common.summaryview_width,
1542 prefs_common.summaryview_height);
1543 gtk_widget_set_usize(mainwin->window,
1544 prefs_common.folderview_width +
1545 prefs_common.mainview_width,
1546 prefs_common.mainwin_height);
1547 gtk_widget_show_all(hpaned);
1548 gtk_container_add(GTK_CONTAINER(messagewin),
1549 GTK_WIDGET_PTR(mainwin->messageview));
1551 mainwin->win.sep_message.messagewin = messagewin;
1552 mainwin->win.sep_message.hpaned = hpaned;
1554 gtk_widget_show_all(messagewin);
1557 gtk_box_pack_start(GTK_BOX(vbox_body),
1558 GTK_WIDGET_PTR(mainwin->summaryview),
1560 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1561 prefs_common.summaryview_width,
1562 prefs_common.summaryview_height);
1563 gtk_widget_set_usize(mainwin->window,
1564 prefs_common.mainview_width,
1565 prefs_common.mainwin_height);
1566 gtk_container_add(GTK_CONTAINER(folderwin),
1567 GTK_WIDGET_PTR(mainwin->folderview));
1568 gtk_container_add(GTK_CONTAINER(messagewin),
1569 GTK_WIDGET_PTR(mainwin->messageview));
1571 mainwin->win.sep_both.folderwin = folderwin;
1572 mainwin->win.sep_both.messagewin = messagewin;
1574 gtk_widget_show_all(folderwin);
1575 gtk_widget_show_all(messagewin);
1579 mainwin->type = type;
1581 debug_print(_("done.\n"));
1584 #include "pixmaps/stock_mail_receive.xpm"
1585 #include "pixmaps/stock_mail_receive_all.xpm"
1586 #include "pixmaps/stock_mail_compose.xpm"
1587 #include "pixmaps/stock_news_compose.xpm"
1588 #include "pixmaps/stock_mail_reply.xpm"
1589 #include "pixmaps/stock_mail_reply_to_all.xpm"
1590 #include "pixmaps/stock_mail_reply_to_author.xpm"
1591 #include "pixmaps/stock_mail_forward.xpm"
1592 #include "pixmaps/stock_mail_send.xpm"
1593 #include "pixmaps/stock_preferences.xpm"
1594 #include "pixmaps/stock_properties.xpm"
1595 #include "pixmaps/stock_down_arrow.xpm"
1596 #include "pixmaps/stock_close.xpm"
1597 #include "pixmaps/stock_exec.xpm"
1599 #define CREATE_TOOLBAR_ICON(xpm_d) \
1601 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1602 &container->style->white, \
1604 icon_wid = gtk_pixmap_new(icon, mask); \
1607 static void main_window_toolbar_create(MainWindow *mainwin,
1608 GtkWidget *container)
1613 GtkWidget *icon_wid;
1615 GtkWidget *getall_btn;
1616 GtkWidget *compose_mail_btn;
1617 GtkWidget *compose_news_btn;
1618 GtkWidget *compose_mail_btn_plain;
1619 GtkWidget *compose_news_btn_plain;
1620 GtkWidget *reply_btn;
1621 GtkWidget *replyall_btn;
1622 GtkWidget *replysender_btn;
1624 GtkWidget *send_btn;
1626 GtkWidget *prefs_btn;
1627 GtkWidget *account_btn;
1629 GtkWidget *next_btn;
1630 GtkWidget *delete_btn;
1631 GtkWidget *exec_btn;
1632 GtkWidget *compose_type_btn;
1633 GtkWidget *compose_type_arrow;
1634 GtkWidget *compose_box;
1635 GtkWidget *compose_label;
1636 GtkTooltips *tooltips;
1638 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1640 gtk_container_add(GTK_CONTAINER(container), toolbar);
1641 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1642 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1643 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1644 GTK_TOOLBAR_SPACE_LINE);
1646 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1647 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1649 _("Get new mail from current account"),
1651 icon_wid, toolbar_inc_cb, mainwin);
1652 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1653 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1655 _("Get new mail from all accounts"),
1661 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1663 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1664 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1666 _("Send queued message(s)"),
1672 /* to implement Leandro's "combined" compose buttons, we create
1673 * two sets of compose buttons, one for normal (text + icon)
1674 * toolbar, and one for both text-only and icon-only toolbar;
1675 * we switch between those sets. */
1677 /* insert compose mail button widget */
1679 compose_mail_btn = gtk_button_new();
1680 gtk_widget_show(compose_mail_btn);
1681 tooltips = gtk_tooltips_new();
1682 gtk_tooltips_set_tip(tooltips, compose_mail_btn,
1683 _("Compose email message"),
1685 compose_box = gtk_vbox_new(0, 0);
1686 gtk_widget_show(compose_box);
1688 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1689 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1690 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1692 compose_label = gtk_label_new(_("Email"));
1693 gtk_widget_show(compose_label);
1694 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1696 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1697 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1698 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1701 /* insert compose news button widget */
1703 compose_news_btn = gtk_button_new();
1704 gtk_widget_show(compose_news_btn);
1705 tooltips = gtk_tooltips_new();
1706 gtk_tooltips_set_tip(tooltips, compose_news_btn,
1707 _("Compose news article"),
1709 compose_box = gtk_vbox_new(0, 0);
1710 gtk_widget_show(compose_box);
1712 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1713 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1714 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1716 compose_label = gtk_label_new(_("News"));
1717 gtk_widget_show(compose_label);
1718 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1720 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_news_btn), GTK_CAN_FOCUS);
1721 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1722 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1725 /* insert compose btn plain */
1727 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1728 compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1730 _("Compose an email message"),
1733 toolbar_compose_mail_cb,
1736 /* insert compose btn plain */
1738 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1739 compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1741 _("Compose a news message"),
1744 toolbar_compose_news_cb,
1747 /* insert compose button type widget */
1749 compose_type_btn = gtk_button_new();
1750 gtk_widget_show(compose_type_btn);
1752 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1753 gtk_widget_show(compose_type_arrow);
1755 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1757 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1758 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1760 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1763 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1765 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1766 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1768 _("Reply to the message"),
1773 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1774 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1779 toolbar_reply_to_all_cb,
1781 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1782 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1784 _("Reply to sender"),
1787 toolbar_reply_to_sender_cb,
1789 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1790 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1792 _("Forward the message"),
1798 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1800 CREATE_TOOLBAR_ICON(stock_close_xpm);
1801 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1803 _("Delete the message"),
1809 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1810 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1812 _("Execute marked process"),
1818 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1819 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1821 _("Next unread message"),
1824 toolbar_next_unread_cb,
1828 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1830 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1831 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1833 _("Common preference"),
1838 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1839 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1841 _("Account setting"),
1846 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1847 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1851 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1852 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1855 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1856 GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
1859 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
1860 GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
1863 mainwin->toolbar = toolbar;
1864 mainwin->get_btn = get_btn;
1865 mainwin->getall_btn = getall_btn;
1866 mainwin->compose_mail_btn = compose_mail_btn;
1867 mainwin->compose_news_btn = compose_news_btn;
1868 mainwin->compose_mail_btn_plain = compose_mail_btn_plain;
1869 mainwin->compose_news_btn_plain = compose_news_btn_plain;
1870 mainwin->reply_btn = reply_btn;
1871 mainwin->replyall_btn = replyall_btn;
1872 mainwin->replysender_btn = replysender_btn;
1873 mainwin->fwd_btn = fwd_btn;
1874 mainwin->send_btn = send_btn;
1876 mainwin->prefs_btn = prefs_btn;
1877 mainwin->account_btn = account_btn;
1879 mainwin->next_btn = next_btn;
1880 mainwin->delete_btn = delete_btn;
1881 mainwin->exec_btn = exec_btn;
1883 gtk_widget_show_all(toolbar);
1885 /* activate Leandro menu system */
1886 activate_compose_button(mainwin,
1887 prefs_common.toolbar_style,
1888 mainwin->compose_btn_type);
1891 /* callback functions */
1893 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1896 MainWindow *mainwindow = (MainWindow *) data;
1897 GtkWidget *compose_menu, *compose_item;
1899 g_return_if_fail(mainwindow != NULL);
1901 compose_menu = gtk_menu_new();
1903 compose_item = gtk_menu_item_new_with_label(_("Email message"));
1904 gtk_widget_show(compose_item);
1905 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1906 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1907 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1909 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1911 compose_item = gtk_menu_item_new_with_label(_("News article"));
1912 gtk_widget_show(compose_item);
1913 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1914 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1915 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1917 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1919 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1923 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1925 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1926 MainWindow *mainwindow = (MainWindow *) data;
1928 mainwindow->compose_btn_type = compose_type;
1930 activate_compose_button(mainwindow, prefs_common.toolbar_style, mainwindow->compose_btn_type);
1933 static void toolbar_inc_cb (GtkWidget *widget,
1936 MainWindow *mainwin = (MainWindow *)data;
1938 inc_mail_cb(mainwin, 0, NULL);
1941 static void toolbar_inc_all_cb (GtkWidget *widget,
1944 MainWindow *mainwin = (MainWindow *)data;
1946 inc_all_account_mail_cb(mainwin, 0, NULL);
1949 static void toolbar_send_cb (GtkWidget *widget,
1952 MainWindow *mainwin = (MainWindow *)data;
1954 send_queue_cb(mainwin, 0, NULL);
1957 static void toolbar_compose_cb (GtkWidget *widget,
1960 MainWindow *mainwin = (MainWindow *)data;
1962 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1963 compose_cb(mainwin, 0, NULL);
1965 compose_news_cb(mainwin, 0, NULL);
1968 static void toolbar_compose_news_cb (GtkWidget *widget,
1971 MainWindow *mainwin = (MainWindow *)data;
1973 compose_news_cb(mainwin, 0, NULL);
1976 static void toolbar_compose_mail_cb (GtkWidget *widget,
1979 MainWindow *mainwin = (MainWindow *)data;
1981 compose_mail_cb(mainwin, 0, NULL);
1984 static void toolbar_reply_cb (GtkWidget *widget,
1987 MainWindow *mainwin = (MainWindow *)data;
1989 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1992 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1995 MainWindow *mainwin = (MainWindow *)data;
1997 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
2000 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
2003 MainWindow *mainwin = (MainWindow *)data;
2005 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
2008 static void toolbar_forward_cb (GtkWidget *widget,
2011 MainWindow *mainwin = (MainWindow *)data;
2013 if (prefs_common.forward_as_attachment)
2014 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2016 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2019 static void toolbar_delete_cb (GtkWidget *widget,
2022 MainWindow *mainwin = (MainWindow *)data;
2024 summary_delete(mainwin->summaryview);
2027 static void toolbar_exec_cb (GtkWidget *widget,
2030 MainWindow *mainwin = (MainWindow *)data;
2032 summary_execute(mainwin->summaryview);
2035 static void toolbar_next_unread_cb (GtkWidget *widget,
2038 MainWindow *mainwin = (MainWindow *)data;
2040 next_unread_cb(mainwin, 0, NULL);
2043 static void toolbar_prefs_cb (GtkWidget *widget,
2046 prefs_common_open();
2049 static void toolbar_account_cb (GtkWidget *widget,
2052 MainWindow *mainwin = (MainWindow *)data;
2054 prefs_account_open_cb(mainwin, 0, NULL);
2057 static void toolbar_account_button_pressed(GtkWidget *widget,
2058 GdkEventButton *event,
2061 MainWindow *mainwin = (MainWindow *)data;
2064 if (event->button != 3) return;
2066 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2067 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2070 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2071 menu_button_position, widget,
2072 event->button, event->time);
2075 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2078 MainWindow *mainwin = (MainWindow *)data;
2082 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2083 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2086 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2087 menu_button_position, widget,
2088 event->button, event->time);
2091 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2093 MainWindow *mainwin = (MainWindow *)data;
2096 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2097 if (!button) return;
2098 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2099 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2100 manage_window_focus_in(mainwin->window, NULL, NULL);
2103 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2106 MainWindow *mainwin = (MainWindow *)data;
2108 if (mainwin->lock_count == 0)
2109 app_exit_cb(data, 0, widget);
2114 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2117 main_window_add_mailbox(mainwin);
2120 static void add_mbox_cb(MainWindow *mainwin, guint action,
2123 main_window_add_mbox(mainwin);
2126 static void update_folderview_cb(MainWindow *mainwin, guint action,
2129 summary_show(mainwin->summaryview, NULL, FALSE);
2130 folderview_update_all();
2133 static void new_folder_cb(MainWindow *mainwin, guint action,
2136 folderview_new_folder(mainwin->folderview);
2139 static void rename_folder_cb(MainWindow *mainwin, guint action,
2142 folderview_rename_folder(mainwin->folderview);
2145 static void delete_folder_cb(MainWindow *mainwin, guint action,
2148 folderview_delete_folder(mainwin->folderview);
2151 static void import_mbox_cb(MainWindow *mainwin, guint action,
2154 import_mbox(mainwin->summaryview->folder_item);
2157 static void export_mbox_cb(MainWindow *mainwin, guint action,
2160 export_mbox(mainwin->summaryview->folder_item);
2163 static void empty_trash_cb(MainWindow *mainwin, guint action,
2166 main_window_empty_trash(mainwin, TRUE);
2169 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2171 summary_save_as(mainwin->summaryview);
2174 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2176 summary_print(mainwin->summaryview);
2179 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2181 if (prefs_common.confirm_on_exit) {
2182 if (alertpanel(_("Exit"), _("Exit this program?"),
2183 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2185 manage_window_focus_in(mainwin->window, NULL, NULL);
2188 app_will_exit(widget, mainwin);
2191 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2194 summary_search(mainwin->summaryview);
2196 message_search(mainwin->messageview);
2199 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2202 switch (mainwin->type) {
2204 case SEPARATE_MESSAGE:
2206 case SEPARATE_FOLDER:
2207 if (GTK_CHECK_MENU_ITEM(widget)->active)
2208 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2210 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2213 if (GTK_CHECK_MENU_ITEM(widget)->active)
2214 gtk_widget_show(mainwin->win.sep_both.folderwin);
2216 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2221 static void toggle_message_cb(MainWindow *mainwin, guint action,
2224 switch (mainwin->type) {
2226 case SEPARATE_FOLDER:
2228 case SEPARATE_MESSAGE:
2229 if (GTK_CHECK_MENU_ITEM(widget)->active)
2230 gtk_widget_show(mainwin->win.sep_message.messagewin);
2232 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2235 if (GTK_CHECK_MENU_ITEM(widget)->active)
2236 gtk_widget_show(mainwin->win.sep_both.messagewin);
2238 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2243 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2246 activate_compose_button(mainwin, (ToolbarStyle)action,
2247 mainwin->compose_btn_type);
2249 switch ((ToolbarStyle)action) {
2251 gtk_widget_hide(mainwin->handlebox);
2253 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2257 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2261 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2266 if (action != TOOLBAR_NONE) {
2267 gtk_widget_show(mainwin->handlebox);
2268 gtk_widget_queue_resize(mainwin->handlebox);
2271 mainwin->toolbar_style = (ToolbarStyle)action;
2272 prefs_common.toolbar_style = (ToolbarStyle)action;
2275 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2278 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2279 gtk_widget_show(mainwin->hbox_stat);
2280 prefs_common.show_statusbar = TRUE;
2282 gtk_widget_hide(mainwin->hbox_stat);
2283 prefs_common.show_statusbar = FALSE;
2287 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2290 MainWindow *mainwin;
2293 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2294 g_return_if_fail(mainwin != NULL);
2296 type = mainwin->type ^ action;
2297 main_window_separation_change(mainwin, type);
2299 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2300 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2303 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2306 addressbook_open(NULL);
2309 static void log_window_show_cb(MainWindow *mainwin, guint action,
2312 log_window_show(mainwin->logwin);
2315 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2320 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2323 inc_all_account_mail(mainwin);
2326 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2330 if (procmsg_send_queue() < 0)
2331 alertpanel_error(_("Some errors occurred while sending queued messages."));
2333 statusbar_pop_all();
2335 for (list = folder_get_list(); list != NULL; list = list->next) {
2338 folder = list->data;
2339 if (folder->queue) {
2340 folder_item_scan(folder->queue);
2341 folderview_update_item(folder->queue, TRUE);
2346 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2348 if (mainwin->summaryview->folder_item) {
2349 if (mainwin->summaryview->folder_item->folder->account != NULL
2350 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2351 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2353 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2359 static void compose_mail_cb(MainWindow *mainwin, guint action,
2366 if (mainwin->summaryview->folder_item) {
2367 ac = mainwin->summaryview->folder_item->folder->account;
2368 if (ac && ac->protocol != A_NNTP) {
2369 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2374 if(cur_account && (cur_account->protocol != A_NNTP)) {
2375 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2379 list = account_get_list();
2380 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2381 ac = (PrefsAccount *) cur->data;
2382 if (ac->protocol != A_NNTP) {
2383 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2389 static void compose_news_cb(MainWindow *mainwin, guint action,
2392 PrefsAccount * ac = NULL;
2396 if (mainwin->summaryview->folder_item) {
2397 ac = mainwin->summaryview->folder_item->folder->account;
2398 if (ac && ac->protocol == A_NNTP) {
2399 compose_new_with_recipient
2400 (ac, mainwin->summaryview->folder_item->path);
2405 list = account_get_list();
2406 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2407 ac = (PrefsAccount *) cur->data;
2408 if (ac->protocol == A_NNTP) {
2415 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2417 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2420 msginfo = gtk_ctree_node_get_row_data
2421 (GTK_CTREE(mainwin->summaryview->ctree),
2422 mainwin->summaryview->selected);
2424 if (!msginfo) return;
2428 compose_reply(msginfo, prefs_common.reply_with_quote,
2431 case COMPOSE_REPLY_TO_SENDER:
2432 compose_reply(msginfo, prefs_common.reply_with_quote,
2435 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2436 compose_followup_and_reply_to(msginfo,
2437 prefs_common.reply_with_quote,
2440 case COMPOSE_REPLY_TO_ALL:
2441 compose_reply(msginfo, prefs_common.reply_with_quote,
2444 case COMPOSE_FORWARD:
2446 compose_forward(NULL, msginfo, FALSE);
2449 /* if (sel->next) FALL_THROUGH */
2450 case COMPOSE_FORWARD_AS_ATTACH:
2452 GSList *msginfo_list = NULL;
2453 for ( ; sel != NULL; sel = sel->next)
2454 msginfo_list = g_slist_append(msginfo_list,
2455 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2456 GTK_CTREE_NODE(sel->data)));
2457 compose_forward_multiple(NULL, msginfo_list);
2458 g_slist_free(msginfo_list);
2462 g_warning("reply_cb(): invalid action type: %d\n", action);
2465 summary_set_marks_selected(mainwin->summaryview);
2468 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2470 summary_move_to(mainwin->summaryview);
2473 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2475 summary_copy_to(mainwin->summaryview);
2478 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2480 summary_delete(mainwin->summaryview);
2483 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2485 summary_open_msg(mainwin->summaryview);
2488 static void view_source_cb(MainWindow *mainwin, guint action,
2491 summary_view_source(mainwin->summaryview);
2494 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2496 summary_reedit(mainwin->summaryview);
2499 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2501 summary_mark(mainwin->summaryview);
2504 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2506 summary_unmark(mainwin->summaryview);
2509 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2512 summary_mark_as_unread(mainwin->summaryview);
2515 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2518 summary_mark_as_read(mainwin->summaryview);
2521 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2524 summary_mark_all_read(mainwin->summaryview);
2527 static void add_address_cb(MainWindow *mainwin, guint action,
2530 summary_add_address(mainwin->summaryview);
2533 static void set_charset_cb(MainWindow *mainwin, guint action,
2538 str = conv_get_charset_str((CharSet)action);
2539 g_free(prefs_common.force_charset);
2540 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2542 summary_redisplay_msg(mainwin->summaryview);
2544 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2547 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2549 GtkItemFactory *ifactory;
2551 if (!mainwin->summaryview->folder_item) return;
2553 ifactory = gtk_item_factory_from_widget(widget);
2556 summary_thread_build(mainwin->summaryview);
2557 mainwin->summaryview->folder_item->threaded = TRUE;
2558 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2559 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2561 summary_unthread(mainwin->summaryview);
2562 mainwin->summaryview->folder_item->threaded = FALSE;
2563 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2564 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2568 static void set_display_item_cb(MainWindow *mainwin, guint action,
2571 prefs_summary_display_item_set();
2574 static void sort_summary_cb(MainWindow *mainwin, guint action,
2577 summary_sort(mainwin->summaryview, (SummarySortType)action);
2580 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2583 summary_attract_by_subject(mainwin->summaryview);
2586 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2589 summary_delete_duplicated(mainwin->summaryview);
2592 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2594 summary_filter(mainwin->summaryview);
2597 static void execute_summary_cb(MainWindow *mainwin, guint action,
2600 summary_execute(mainwin->summaryview);
2603 static void update_summary_cb(MainWindow *mainwin, guint action,
2607 FolderView *folderview = mainwin->folderview;
2609 if (!mainwin->summaryview->folder_item) return;
2610 if (!folderview->opened) return;
2612 folder_update_op_count();
2614 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2615 folderview->opened);
2618 summary_show(mainwin->summaryview, fitem, TRUE);
2621 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2623 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2626 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2628 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2631 static void prev_unread_cb(MainWindow *mainwin, guint action,
2634 summary_select_prev_unread(mainwin->summaryview);
2637 static void next_unread_cb(MainWindow *mainwin, guint action,
2640 summary_select_next_unread(mainwin->summaryview);
2643 static void prev_marked_cb(MainWindow *mainwin, guint action,
2646 summary_select_prev_marked(mainwin->summaryview);
2649 static void next_marked_cb(MainWindow *mainwin, guint action,
2652 summary_select_next_marked(mainwin->summaryview);
2655 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2658 summary_select_prev_labeled(mainwin->summaryview);
2661 static void next_labeled_cb(MainWindow *mainwin, guint action,
2664 summary_select_next_labeled(mainwin->summaryview);
2667 static void goto_folder_cb(MainWindow *mainwin, guint action,
2670 FolderItem *to_folder;
2672 to_folder = foldersel_folder_sel(NULL, NULL);
2675 folderview_select(mainwin->folderview, to_folder);
2678 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2680 messageview_copy_clipboard(mainwin->messageview);
2683 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2685 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2686 summary_select_all(mainwin->summaryview);
2687 else if (mainwin->summaryview->msg_is_toggled_on &&
2688 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2689 messageview_select_all(mainwin->messageview);
2692 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2695 prefs_common_open();
2698 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2701 prefs_filter_open();
2704 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2707 prefs_scoring_open(NULL);
2710 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2713 prefs_filtering_open();
2716 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2720 new_account_cb(mainwin, 0, widget);
2722 gboolean prev_default = cur_account->is_default;
2724 prefs_account_open(cur_account);
2725 if (!prev_default && cur_account->is_default)
2726 account_set_as_default(cur_account);
2727 account_save_config_all();
2729 main_window_reflect_prefs_all();
2733 static void new_account_cb(MainWindow *mainwin, guint action,
2736 account_edit_open();
2737 if (!compose_get_compose_list()) account_add();
2740 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2742 cur_account = (PrefsAccount *)data;
2743 main_window_reflect_prefs_all();
2746 static void manual_open_cb(MainWindow *mainwin, guint action,
2749 manual_open((ManualLang)action);
2752 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2754 MainWindow *mainwin = (MainWindow *)data;
2758 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2759 LOCAL_FOLDER(folder)->rootpath,
2763 str = g_strdup_printf(_("Scanning folder %s ..."),
2764 LOCAL_FOLDER(folder)->rootpath);
2766 STATUSBAR_PUSH(mainwin, str);
2767 STATUSBAR_POP(mainwin);
2771 static void activate_compose_button (MainWindow *mainwin,
2773 ComposeButtonType type)
2775 if (style == TOOLBAR_NONE)
2778 if (style == TOOLBAR_BOTH) {
2779 gtk_widget_hide(mainwin->compose_mail_btn_plain);
2780 gtk_widget_hide(mainwin->compose_news_btn_plain);
2781 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2782 : mainwin->compose_news_btn);
2783 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2784 : mainwin->compose_mail_btn);
2785 mainwin->compose_btn_type = type;
2788 gtk_widget_hide(mainwin->compose_news_btn);
2789 gtk_widget_hide(mainwin->compose_mail_btn);
2790 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn_plain
2791 : mainwin->compose_news_btn_plain);
2792 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn_plain
2793 : mainwin->compose_mail_btn_plain);
2794 mainwin->compose_btn_type = type;
2798 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2800 if (mainwin->compose_btn_type != compose_btn_type)
2801 activate_compose_button(mainwin,
2802 prefs_common.toolbar_style,
2806 static void prefs_templates_open_cb(MainWindow *mainwin, guint action,
2809 prefs_templates_open();