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 "headerview.h"
59 #include "prefs_common.h"
60 #include "prefs_filter.h"
61 #include "prefs_filtering.h"
62 #include "prefs_scoring.h"
63 #include "prefs_account.h"
64 #include "prefs_folder_item.h"
66 #include "addressbook.h"
67 #include "headerwindow.h"
68 #include "logwindow.h"
69 #include "manage_window.h"
70 #include "alertpanel.h"
71 #include "statusbar.h"
72 #include "inputdialog.h"
78 #include "prefs_templates.h"
81 #define AC_LABEL_WIDTH 240
83 #define STATUSBAR_PUSH(mainwin, str) \
85 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
86 mainwin->mainwin_cid, str); \
87 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
90 #define STATUSBAR_POP(mainwin) \
92 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
93 mainwin->mainwin_cid); \
96 /* list of all instantiated MainWindow */
97 static GList *mainwin_list = NULL;
99 static GdkCursor *watch_cursor;
101 static void main_window_show_cur_account (MainWindow *mainwin);
103 static void main_window_set_widgets (MainWindow *mainwin,
105 static void main_window_toolbar_create (MainWindow *mainwin,
106 GtkWidget *container);
108 /* callback functions */
109 static void toolbar_inc_cb (GtkWidget *widget,
111 static void toolbar_inc_all_cb (GtkWidget *widget,
113 static void toolbar_send_cb (GtkWidget *widget,
116 static void toolbar_compose_cb (GtkWidget *widget,
118 static void toolbar_popup_compose_type_cb(GtkWidget *widget,
120 static void toolbar_popup_compose_type_set(GtkWidget *widget,
122 static void toolbar_compose_news_cb (GtkWidget *widget,
124 static void toolbar_compose_mail_cb (GtkWidget *widget,
126 static void toolbar_reply_cb (GtkWidget *widget,
128 static void toolbar_reply_to_all_cb (GtkWidget *widget,
130 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
132 static void toolbar_forward_cb (GtkWidget *widget,
135 static void toolbar_delete_cb (GtkWidget *widget,
137 static void toolbar_exec_cb (GtkWidget *widget,
140 static void toolbar_next_unread_cb (GtkWidget *widget,
143 static void toolbar_prefs_cb (GtkWidget *widget,
145 static void toolbar_account_cb (GtkWidget *widget,
148 static void toolbar_account_button_pressed (GtkWidget *widget,
149 GdkEventButton *event,
151 static void ac_label_button_pressed (GtkWidget *widget,
152 GdkEventButton *event,
154 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
157 static gint main_window_close_cb (GtkWidget *widget,
161 static void add_mailbox_cb (MainWindow *mainwin,
164 static void add_mbox_cb (MainWindow *mainwin,
167 static void update_folderview_cb (MainWindow *mainwin,
170 static void new_folder_cb (MainWindow *mainwin,
173 static void rename_folder_cb (MainWindow *mainwin,
176 static void delete_folder_cb (MainWindow *mainwin,
179 static void import_mbox_cb (MainWindow *mainwin,
182 static void export_mbox_cb (MainWindow *mainwin,
185 static void empty_trash_cb (MainWindow *mainwin,
189 static void save_as_cb (MainWindow *mainwin,
192 static void print_cb (MainWindow *mainwin,
195 static void app_exit_cb (MainWindow *mainwin,
199 static void toggle_folder_cb (MainWindow *mainwin,
202 static void toggle_message_cb (MainWindow *mainwin,
205 static void toggle_toolbar_cb (MainWindow *mainwin,
208 static void toggle_statusbar_cb (MainWindow *mainwin,
211 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
215 static void addressbook_open_cb (MainWindow *mainwin,
218 static void log_window_show_cb (MainWindow *mainwin,
222 static void inc_mail_cb (MainWindow *mainwin,
225 static void inc_all_account_mail_cb (MainWindow *mainwin,
229 static void send_queue_cb (MainWindow *mainwin,
233 static void compose_cb (MainWindow *mainwin,
236 static void compose_mail_cb(MainWindow *mainwin, guint action,
238 static void compose_news_cb(MainWindow *mainwin, guint action,
240 static void reply_cb (MainWindow *mainwin,
244 static void open_msg_cb (MainWindow *mainwin,
248 static void view_source_cb (MainWindow *mainwin,
252 static void reedit_cb (MainWindow *mainwin,
256 static void move_to_cb (MainWindow *mainwin,
259 static void copy_to_cb (MainWindow *mainwin,
262 static void delete_cb (MainWindow *mainwin,
266 static void mark_cb (MainWindow *mainwin,
269 static void unmark_cb (MainWindow *mainwin,
273 static void mark_as_unread_cb (MainWindow *mainwin,
276 static void mark_as_read_cb (MainWindow *mainwin,
279 static void mark_all_read_cb (MainWindow *mainwin,
282 static void add_address_cb (MainWindow *mainwin,
286 static void set_charset_cb (MainWindow *mainwin,
290 static void thread_cb (MainWindow *mainwin,
293 static void set_display_item_cb (MainWindow *mainwin,
296 static void sort_summary_cb (MainWindow *mainwin,
299 static void attract_by_subject_cb(MainWindow *mainwin,
303 static void delete_duplicated_cb (MainWindow *mainwin,
306 static void filter_cb (MainWindow *mainwin,
309 static void execute_summary_cb (MainWindow *mainwin,
312 static void update_summary_cb (MainWindow *mainwin,
316 static void prev_cb (MainWindow *mainwin,
319 static void next_cb (MainWindow *mainwin,
323 static void prev_unread_cb (MainWindow *mainwin,
326 static void next_unread_cb (MainWindow *mainwin,
329 static void prev_marked_cb (MainWindow *mainwin,
332 static void next_marked_cb (MainWindow *mainwin,
335 static void prev_labeled_cb (MainWindow *mainwin,
338 static void next_labeled_cb (MainWindow *mainwin,
342 static void goto_folder_cb (MainWindow *mainwin,
346 static void copy_cb (MainWindow *mainwin,
349 static void allsel_cb (MainWindow *mainwin,
353 static void prefs_common_open_cb (MainWindow *mainwin,
356 static void prefs_filter_open_cb (MainWindow *mainwin,
359 static void prefs_scoring_open_cb (MainWindow *mainwin,
362 static void prefs_filtering_open_cb (MainWindow *mainwin,
365 static void prefs_account_open_cb(MainWindow *mainwin,
368 static void new_account_cb (MainWindow *mainwin,
372 static void account_menu_cb (GtkMenuItem *menuitem,
375 static void manual_open_cb (MainWindow *mainwin,
379 static void scan_tree_func (Folder *folder,
383 static void activate_compose_button (MainWindow *mainwin,
385 ComposeButtonType type);
387 static void prefs_templates_open_cb(MainWindow *mainwin,
391 #define SEPARATE_ACTION 667
393 static GtkItemFactoryEntry mainwin_entries[] =
395 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
396 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
397 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
398 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
399 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
400 {N_("/_File/_Folder/Create _new folder..."),
401 NULL, new_folder_cb, 0, NULL},
402 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
403 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
404 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
405 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
406 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
407 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
408 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
409 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
410 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
411 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
412 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
414 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
415 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
416 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
417 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
418 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
420 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
421 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
422 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
423 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
424 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
425 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
426 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
427 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
428 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
429 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
430 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
431 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
432 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
433 {N_("/_View/View _source"), "<control>U", view_source_cb, 0, NULL},
434 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
435 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
436 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
437 {N_("/_View/_Code set/_Auto detect"),
438 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
440 #define CODESET_SEPARATOR \
441 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
442 #define CODESET_ACTION(action) \
443 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
445 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
446 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
447 CODESET_ACTION(C_US_ASCII)},
450 {N_("/_View/_Code set/Unicode (_UTF-8)"),
451 CODESET_ACTION(C_UTF_8)},
454 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
455 CODESET_ACTION(C_ISO_8859_1)},
458 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
459 CODESET_ACTION(C_ISO_8859_2)},
461 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
462 CODESET_ACTION(C_ISO_8859_13)},
463 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
464 CODESET_ACTION(C_ISO_8859_4)},
466 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
467 CODESET_ACTION(C_ISO_8859_7)},
469 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
470 CODESET_ACTION(C_ISO_8859_9)},
472 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
473 CODESET_ACTION(C_ISO_8859_5)},
474 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
475 CODESET_ACTION(C_KOI8_R)},
476 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
477 CODESET_ACTION(C_CP1251)},
480 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
481 CODESET_ACTION(C_ISO_2022_JP)},
483 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
484 CODESET_ACTION(C_ISO_2022_JP_2)},
486 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
487 CODESET_ACTION(C_EUC_JP)},
488 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
489 CODESET_ACTION(C_SHIFT_JIS)},
492 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
493 CODESET_ACTION(C_GB2312)},
494 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
495 CODESET_ACTION(C_BIG5)},
496 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
497 CODESET_ACTION(C_EUC_TW)},
498 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
499 CODESET_ACTION(C_ISO_2022_CN)},
501 {N_("/_View/_Code set/Korean (EUC-_KR)"),
502 CODESET_ACTION(C_EUC_KR)},
503 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
504 CODESET_ACTION(C_ISO_2022_KR)},
507 #undef CODESET_SEPARATOR
508 #undef CODESET_ACTION
510 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
511 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
512 {N_("/_Message/Get from _all accounts"),
513 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
514 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
515 {N_("/_Message/Send queued messa_ges"),
516 NULL, send_queue_cb, 0, NULL},
517 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
519 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
520 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
521 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
522 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
523 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
524 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
525 {N_("/_Message/Forward as a_ttachment"),
526 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
527 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
528 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
529 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
530 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
531 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
532 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
533 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
536 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
537 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
539 {N_("/_Message/_Mark/Mark as rea_d"),
540 NULL, mark_as_read_cb, 0, NULL},
541 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
542 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
544 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
545 {N_("/_Summary/_Delete duplicated messages"),
546 NULL, delete_duplicated_cb, 0, NULL},
547 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
548 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
549 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
550 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
551 {N_("/_Summary/Go _to"), NULL, NULL, 0, "<Branch>"},
552 {N_("/_Summary/Go _to/_Prev message"), NULL, prev_cb, 0, NULL},
553 {N_("/_Summary/Go _to/_Next message"), NULL, next_cb, 0, NULL},
554 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
555 {N_("/_Summary/Go _to/P_rev unread message"),
556 NULL, prev_unread_cb, 0, NULL},
557 {N_("/_Summary/Go _to/N_ext unread message"),
558 NULL, next_unread_cb, 0, NULL},
559 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
560 {N_("/_Summary/Go _to/Prev _marked message"),
561 NULL, prev_marked_cb, 0, NULL},
562 {N_("/_Summary/Go _to/Next m_arked message"),
563 NULL, next_marked_cb, 0, NULL},
564 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
565 {N_("/_Summary/Go _to/Prev _labeled message"),
566 NULL, prev_labeled_cb, 0, NULL},
567 {N_("/_Summary/Go _to/Next la_beled message"),
568 NULL, next_labeled_cb, 0, NULL},
569 {N_("/_Summary/_Go to other folder..."),"<alt>G", goto_folder_cb, 0, NULL},
570 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
571 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
572 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
573 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
574 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
575 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
576 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
577 {N_("/_Summary/_Sort/Sort by _color label"),
578 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
579 {N_("/_Summary/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
580 {N_("/_Summary/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
581 {N_("/_Summary/_Sort/Sort by a_ttachment"),
582 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
583 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
584 {N_("/_Summary/_Sort/_Attract by subject"),
585 NULL, attract_by_subject_cb, 0, NULL},
586 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
587 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
588 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
590 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
591 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
592 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
594 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
595 {N_("/_Configuration/_Common preferences..."),
596 NULL, prefs_common_open_cb, 0, NULL},
597 {N_("/_Configuration/_Filter setting..."),
598 NULL, prefs_filter_open_cb, 0, NULL},
599 {N_("/_Configuration/_Scoring ..."),
600 NULL, prefs_scoring_open_cb, 0, NULL},
601 {N_("/_Configuration/_Filtering ..."),
602 NULL, prefs_filtering_open_cb, 0, NULL},
603 {N_("/_Configuration/_Templates ..."),
604 NULL, prefs_templates_open_cb, 0, NULL},
605 {N_("/_Configuration/_Preferences per account..."),
606 NULL, prefs_account_open_cb, 0, NULL},
607 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
608 {N_("/_Configuration/Create _new account..."),
609 NULL, new_account_cb, 0, NULL},
610 {N_("/_Configuration/_Edit accounts..."),
611 NULL, account_edit_open, 0, NULL},
612 {N_("/_Configuration/C_hange current account"),
613 NULL, NULL, 0, "<Branch>"},
615 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
616 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
617 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
618 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
619 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
623 MainWindow *main_window_create(SeparateType type)
629 GtkWidget *handlebox;
630 GtkWidget *vbox_body;
631 GtkWidget *hbox_stat;
632 GtkWidget *statusbar;
633 GtkWidget *progressbar;
634 GtkWidget *statuslabel;
635 GtkWidget *ac_button;
638 FolderView *folderview;
639 SummaryView *summaryview;
640 MessageView *messageview;
641 GdkColormap *colormap;
644 guint n_menu_entries;
645 GtkItemFactory *ifactory;
650 debug_print(_("Creating main window...\n"));
651 mainwin = g_new0(MainWindow, 1);
654 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
655 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
656 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
657 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
658 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
659 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
660 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
661 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
662 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
664 gtk_widget_realize(window);
666 gtkut_widget_set_app_icon(window);
668 vbox = gtk_vbox_new(FALSE, 0);
669 gtk_widget_show(vbox);
670 gtk_container_add(GTK_CONTAINER(window), vbox);
673 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
674 menubar = menubar_create(window, mainwin_entries,
675 n_menu_entries, "<Main>", mainwin);
676 gtk_widget_show(menubar);
677 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
679 handlebox = gtk_handle_box_new();
680 gtk_widget_show(handlebox);
681 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
683 main_window_toolbar_create(mainwin, handlebox);
685 /* vbox that contains body */
686 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
687 gtk_widget_show(vbox_body);
688 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
689 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
691 hbox_stat = gtk_hbox_new(FALSE, 2);
692 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
694 statusbar = statusbar_create();
695 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
697 progressbar = gtk_progress_bar_new();
698 gtk_widget_set_usize(progressbar, 120, 1);
699 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
701 statuslabel = gtk_label_new("");
702 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
704 ac_button = gtk_button_new();
705 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
706 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
707 gtk_widget_set_usize(ac_button, -1, 1);
708 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
709 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
710 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
712 ac_label = gtk_label_new("");
713 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
715 gtk_widget_show_all(hbox_stat);
718 mainwin->folderview = folderview = folderview_create();
719 mainwin->summaryview = summaryview = summary_create();
720 mainwin->messageview = messageview = messageview_create();
721 mainwin->headerwin = header_window_create();
722 mainwin->logwin = log_window_create();
724 folderview->mainwin = mainwin;
725 folderview->summaryview = summaryview;
727 summaryview->mainwin = mainwin;
728 summaryview->folderview = folderview;
729 summaryview->messageview = messageview;
730 summaryview->headerwin = mainwin->headerwin;
731 summaryview->window = window;
733 messageview->mainwin = mainwin;
735 mainwin->window = window;
736 mainwin->vbox = vbox;
737 mainwin->menubar = menubar;
738 mainwin->handlebox = handlebox;
739 mainwin->vbox_body = vbox_body;
740 mainwin->hbox_stat = hbox_stat;
741 mainwin->statusbar = statusbar;
742 mainwin->progressbar = progressbar;
743 mainwin->statuslabel = statuslabel;
744 mainwin->ac_button = ac_button;
745 mainwin->ac_label = ac_label;
747 /* set context IDs for status bar */
748 mainwin->mainwin_cid = gtk_statusbar_get_context_id
749 (GTK_STATUSBAR(statusbar), "Main Window");
750 mainwin->folderview_cid = gtk_statusbar_get_context_id
751 (GTK_STATUSBAR(statusbar), "Folder View");
752 mainwin->summaryview_cid = gtk_statusbar_get_context_id
753 (GTK_STATUSBAR(statusbar), "Summary View");
755 /* allocate colors for summary view and folder view */
756 summaryview->color_marked.red = summaryview->color_marked.green = 0;
757 summaryview->color_marked.blue = (guint16)65535;
759 summaryview->color_dim.red = summaryview->color_dim.green =
760 summaryview->color_dim.blue = COLOR_DIM;
762 folderview->color_new.red = (guint16)55000;
763 folderview->color_new.green = folderview->color_new.blue = 15000;
765 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
766 &folderview->color_op);
768 summaryview->color_important.red = 0;
769 summaryview->color_marked.green = 0;
770 summaryview->color_important.blue = (guint16)65535;
772 color[0] = summaryview->color_marked;
773 color[1] = summaryview->color_dim;
774 color[2] = folderview->color_new;
775 color[3] = folderview->color_op;
777 colormap = gdk_window_get_colormap(window->window);
778 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
779 for (i = 0; i < 4; i++) {
780 if (success[i] == FALSE)
781 g_warning(_("MainWindow: color allocation %d failed\n"), i);
784 debug_print(_("done.\n"));
786 main_window_set_widgets(mainwin, type);
789 ifactory = gtk_item_factory_from_widget(menubar);
790 menuitem = gtk_item_factory_get_item
791 (ifactory, "/View/Code set/Auto detect");
792 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
794 switch (prefs_common.toolbar_style) {
796 menuitem = gtk_item_factory_get_item
797 (ifactory, "/View/Toolbar/None");
800 menuitem = gtk_item_factory_get_item
801 (ifactory, "/View/Toolbar/Icon");
804 menuitem = gtk_item_factory_get_item
805 (ifactory, "/View/Toolbar/Text");
808 menuitem = gtk_item_factory_get_item
809 (ifactory, "/View/Toolbar/Icon and text");
811 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
813 gtk_widget_hide(mainwin->hbox_stat);
814 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
815 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
816 prefs_common.show_statusbar);
818 /* set the check of the SEPARATE_xxx menu items. we also need the main window
819 * as a property and pass the action type to the callback */
820 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
822 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
823 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
824 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
825 GUINT_TO_POINTER(SEPARATE_FOLDER));
827 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
829 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
830 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
831 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
832 GUINT_TO_POINTER(SEPARATE_MESSAGE));
835 menu_set_sensitive(ifactory, "/Summary/Thread view",
836 prefs_common.enable_thread ? FALSE : TRUE);
837 menu_set_sensitive(ifactory, "/Summary/Unthread view",
838 prefs_common.enable_thread ? TRUE : FALSE);
840 /*main_window_set_thread_option(mainwin);*/
843 /* set account selection menu */
844 ac_menu = gtk_item_factory_get_widget
845 (ifactory, "/Configuration/Change current account");
846 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
847 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
848 mainwin->ac_menu = ac_menu;
850 main_window_set_toolbar_sensitive(mainwin);
852 /* show main window */
853 gtk_widget_set_uposition(mainwin->window,
854 prefs_common.mainwin_x,
855 prefs_common.mainwin_y);
856 gtk_widget_set_usize(window, prefs_common.mainwin_width,
857 prefs_common.mainwin_height);
859 gtk_widget_show(mainwin->window);
861 /* initialize views */
862 folderview_init(folderview);
863 summary_init(summaryview);
864 messageview_init(messageview);
865 header_window_init(mainwin->headerwin);
866 log_window_init(mainwin->logwin);
869 mainwin->lock_count = 0;
870 mainwin->cursor_count = 0;
873 watch_cursor = gdk_cursor_new(GDK_WATCH);
875 mainwin_list = g_list_append(mainwin_list, mainwin);
880 void main_window_cursor_wait(MainWindow *mainwin)
883 if (mainwin->cursor_count == 0)
884 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
886 mainwin->cursor_count++;
891 void main_window_cursor_normal(MainWindow *mainwin)
893 if (mainwin->cursor_count)
894 mainwin->cursor_count--;
896 if (mainwin->cursor_count == 0)
897 gdk_window_set_cursor(mainwin->window->window, NULL);
902 /* lock / unlock the user-interface */
903 void main_window_lock(MainWindow *mainwin)
905 if (mainwin->lock_count == 0)
906 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
908 mainwin->lock_count++;
910 main_window_set_menu_sensitive(mainwin);
911 main_window_set_toolbar_sensitive(mainwin);
914 void main_window_unlock(MainWindow *mainwin)
916 if (mainwin->lock_count)
917 mainwin->lock_count--;
919 main_window_set_menu_sensitive(mainwin);
920 main_window_set_toolbar_sensitive(mainwin);
922 if (mainwin->lock_count == 0)
923 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
926 void main_window_reflect_prefs_all(void)
931 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
932 mainwin = (MainWindow *)cur->data;
934 main_window_show_cur_account(mainwin);
935 main_window_set_menu_sensitive(mainwin);
936 main_window_set_toolbar_sensitive(mainwin);
938 if (prefs_common.immediate_exec)
939 gtk_widget_hide(mainwin->exec_btn);
941 gtk_widget_show(mainwin->exec_btn);
943 summary_change_display_item(mainwin->summaryview);
944 summary_redisplay_msg(mainwin->summaryview);
945 headerview_set_visibility(mainwin->messageview->headerview,
946 prefs_common.display_header_pane);
950 void main_window_set_account_menu(GList *account_list)
952 GList *cur, *cur_ac, *cur_item;
955 PrefsAccount *ac_prefs;
957 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
958 mainwin = (MainWindow *)cur->data;
960 /* destroy all previous menu item */
961 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
962 while (cur_item != NULL) {
963 GList *next = cur_item->next;
964 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
968 for (cur_ac = account_list; cur_ac != NULL;
969 cur_ac = cur_ac->next) {
970 ac_prefs = (PrefsAccount *)cur_ac->data;
972 menuitem = gtk_menu_item_new_with_label
973 (ac_prefs->account_name
974 ? ac_prefs->account_name : _("Untitled"));
975 gtk_widget_show(menuitem);
976 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
977 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
978 GTK_SIGNAL_FUNC(account_menu_cb),
984 static void main_window_show_cur_account(MainWindow *mainwin)
989 ac_name = g_strdup(cur_account
990 ? (cur_account->account_name
991 ? cur_account->account_name : _("Untitled"))
995 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
997 buf = g_strdup(PROG_VERSION);
998 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1001 /* buf = g_strdup_printf(_("Current account: %s"), ac_name);
1002 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf); */
1003 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1004 gtk_widget_queue_resize(mainwin->ac_button);
1010 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1012 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1013 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1014 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1016 if (mainwin->type == type) return;
1018 /* remove widgets from those containers */
1019 gtk_widget_ref(folder_wid);
1020 gtk_widget_ref(summary_wid);
1021 gtk_widget_ref(message_wid);
1022 gtk_container_remove
1023 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1024 gtk_container_remove
1025 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1026 gtk_container_remove
1027 (GTK_CONTAINER(message_wid->parent), message_wid);
1029 /* clean containers */
1030 switch (mainwin->type) {
1032 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1034 case SEPARATE_FOLDER:
1035 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1036 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1038 case SEPARATE_MESSAGE:
1039 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1040 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1043 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1044 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1048 gtk_widget_hide(mainwin->window);
1049 main_window_set_widgets(mainwin, type);
1050 gtk_widget_show(mainwin->window);
1052 gtk_widget_unref(folder_wid);
1053 gtk_widget_unref(summary_wid);
1054 gtk_widget_unref(message_wid);
1057 void main_window_get_size(MainWindow *mainwin)
1059 GtkAllocation *allocation;
1061 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1063 prefs_common.summaryview_width = allocation->width;
1065 if (mainwin->summaryview->msg_is_toggled_on)
1066 prefs_common.summaryview_height = allocation->height;
1068 prefs_common.mainview_width = allocation->width;
1070 allocation = &mainwin->window->allocation;
1072 prefs_common.mainview_height = allocation->height;
1073 prefs_common.mainwin_width = allocation->width;
1074 prefs_common.mainwin_height = allocation->height;
1076 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1078 prefs_common.folderview_width = allocation->width;
1079 prefs_common.folderview_height = allocation->height;
1082 void main_window_get_position(MainWindow *mainwin)
1086 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1088 prefs_common.mainview_x = x;
1089 prefs_common.mainview_y = y;
1090 prefs_common.mainwin_x = x;
1091 prefs_common.mainwin_y = y;
1093 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1096 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1101 if (alertpanel(_("Empty trash"),
1102 _("Empty all messages in trash?"),
1103 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1105 manage_window_focus_in(mainwin->window, NULL, NULL);
1108 procmsg_empty_trash();
1110 for (list = folder_get_list(); list != NULL; list = list->next) {
1113 folder = list->data;
1114 if (folder->trash) {
1115 folder_item_scan(folder->trash);
1116 folderview_update_item(folder->trash, TRUE);
1120 if (mainwin->summaryview->folder_item &&
1121 mainwin->summaryview->folder_item->stype == F_TRASH)
1122 gtk_widget_grab_focus(mainwin->folderview->ctree);
1125 void main_window_add_mailbox(MainWindow *mainwin)
1130 path = input_dialog(_("Add mailbox"),
1131 _("Input the location of mailbox.\n"
1132 "If the existing mailbox is specified, it will be\n"
1133 "scanned automatically."),
1136 if (folder_find_from_path(path)) {
1137 alertpanel_error(_("The mailbox `%s' already exists."), path);
1141 if (!strcmp(path, "Mail"))
1142 folder = folder_new(F_MH, _("Mailbox"), path);
1144 folder = folder_new(F_MH, g_basename(path), path);
1147 if (folder->create_tree(folder) < 0) {
1148 alertpanel_error(_("Creation of the mailbox failed.\n"
1149 "Maybe some files already exist, or you don't have the permission to write there."));
1150 folder_destroy(folder);
1155 folder_set_ui_func(folder, scan_tree_func, mainwin);
1156 folder->scan_tree(folder);
1157 folder_set_ui_func(folder, NULL, NULL);
1159 folderview_set(mainwin->folderview);
1162 void main_window_add_mbox(MainWindow *mainwin)
1168 path = input_dialog(_("Add mbox mailbox"),
1169 _("Input the location of mailbox."),
1174 if (folder_find_from_path(path)) {
1175 alertpanel_error(_("The mailbox `%s' already exists."), path);
1181 if (!strcmp(path, "Mail"))
1182 folder = folder_new(F_MBOX, _("Mailbox"), path);
1186 folder = folder_new(F_MBOX, g_basename(path), path);
1189 if (folder->create_tree(folder) < 0) {
1190 alertpanel_error(_("Creation of the mailbox failed."));
1191 folder_destroy(folder);
1197 item = folder_item_new(folder->name, NULL);
1198 item->folder = folder;
1199 folder->node = g_node_new(item);
1201 folder->create_folder(folder, item, "inbox");
1202 folder->create_folder(folder, item, "outbox");
1203 folder->create_folder(folder, item, "queue");
1204 folder->create_folder(folder, item, "draft");
1205 folder->create_folder(folder, item, "trash");
1207 folderview_set(mainwin->folderview);
1212 M_UNLOCKED = 1 << 0,
1213 M_MSG_EXIST = 1 << 1,
1214 M_TARGET_EXIST = 1 << 2,
1215 M_SINGLE_TARGET_EXIST = 1 << 3,
1217 M_ALLOW_REEDIT = 1 << 5,
1218 M_HAVE_ACCOUNT = 1 << 6,
1219 M_THREADED = 1 << 7,
1220 M_UNTHREADED = 1 << 8
1223 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1225 SensitiveCond state = 0;
1226 SummarySelection selection;
1228 selection = summary_get_selection_type(mainwin->summaryview);
1230 if (mainwin->lock_count == 0)
1231 state |= M_UNLOCKED;
1232 if (selection != SUMMARY_NONE)
1233 state |= M_MSG_EXIST;
1234 if (mainwin->summaryview->folder_item) {
1235 if (mainwin->summaryview->folder_item->threaded)
1236 state |= M_THREADED;
1237 else state |= M_UNTHREADED;
1239 if (selection == SUMMARY_SELECTED_SINGLE ||
1240 selection == SUMMARY_SELECTED_MULTIPLE)
1241 state |= M_TARGET_EXIST;
1242 if (selection == SUMMARY_SELECTED_SINGLE)
1243 state |= M_SINGLE_TARGET_EXIST;
1244 if (mainwin->summaryview->folder_item &&
1245 mainwin->summaryview->folder_item->folder->type != F_NEWS)
1247 if (selection == SUMMARY_SELECTED_SINGLE &&
1248 (mainwin->summaryview->folder_item &&
1249 (mainwin->summaryview->folder_item->stype == F_DRAFT ||
1250 mainwin->summaryview->folder_item->stype == F_QUEUE)))
1251 state |= M_ALLOW_REEDIT;
1253 state |= M_HAVE_ACCOUNT;
1258 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1260 SensitiveCond state;
1268 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1269 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1270 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1271 {mainwin->compose_news_btn, M_HAVE_ACCOUNT},
1272 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1273 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1274 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1275 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1276 /* {mainwin->prefs_btn , M_UNLOCKED},
1277 {mainwin->account_btn , M_UNLOCKED}, */
1278 {mainwin->next_btn , M_MSG_EXIST},
1279 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1280 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1284 state = main_window_get_current_state(mainwin);
1286 for (i = 0; entry[i].widget != NULL; i++) {
1287 sensitive = ((entry[i].cond & state) == entry[i].cond);
1288 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1292 void main_window_set_menu_sensitive(MainWindow *mainwin)
1294 GtkItemFactory *ifactory;
1295 SensitiveCond state;
1299 static const struct {
1303 {"/File/Add mailbox..." , M_UNLOCKED},
1304 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1305 {"/File/Update folder tree" , M_UNLOCKED},
1306 {"/File/Folder" , M_UNLOCKED},
1307 {"/File/Import mbox file..." , M_UNLOCKED},
1308 {"/File/Export to mbox file...", M_UNLOCKED},
1309 {"/File/Empty trash" , M_UNLOCKED},
1310 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1311 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1312 {"/File/Close", M_UNLOCKED},
1313 {"/File/Exit" , M_UNLOCKED},
1315 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1316 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1318 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1319 {"/Message/Get from all accounts", M_HAVE_ACCOUNT|M_UNLOCKED},
1320 /* {"/Message/Compose new message" , M_HAVE_ACCOUNT}, */
1321 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1322 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1323 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1324 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1325 {"/Message/Forward as attachment", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1326 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1327 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1328 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1329 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1330 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1331 {"/Message/Mark" , M_TARGET_EXIST},
1332 {"/Message/Add sender to address book", M_SINGLE_TARGET_EXIST},
1334 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1335 {"/Summary/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1336 {"/Summary/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1337 {"/Summary/Go to" , M_MSG_EXIST},
1338 {"/Summary/Go to/Prev message" , M_MSG_EXIST},
1339 {"/Summary/Go to/Next message" , M_MSG_EXIST},
1340 {"/Summary/Go to/Next unread message" , M_MSG_EXIST},
1341 {"/Summary/Go to/Prev marked message" , M_MSG_EXIST},
1342 {"/Summary/Go to/Next marked message" , M_MSG_EXIST},
1343 {"/Summary/Go to/Prev labeled message", M_MSG_EXIST},
1344 {"/Summary/Go to/Next labeled message", M_MSG_EXIST},
1345 {"/Summary/Sort" , M_MSG_EXIST},
1346 {"/Summary/Thread view" , M_UNTHREADED | M_UNLOCKED},
1347 {"/Summary/Unthread view" , M_THREADED | M_UNLOCKED},
1349 {"/Configuration", M_UNLOCKED},
1354 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1355 state = main_window_get_current_state(mainwin);
1357 for (i = 0; entry[i].entry != NULL; i++) {
1358 sensitive = ((entry[i].cond & state) == entry[i].cond);
1359 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1363 void main_window_popup(MainWindow *mainwin)
1369 gdk_window_get_origin(mainwin->window->window, &x, &y);
1370 sx = gdk_screen_width();
1371 sy = gdk_screen_height();
1372 x %= sx; if (x < 0) x += sx;
1373 y %= sy; if (y < 0) y += sy;
1374 gdk_window_move(mainwin->window->window, x, y);
1375 gdk_window_raise(mainwin->window->window);
1376 gdk_window_show(mainwin->window->window);
1378 debug_print("window position: x = %d, y = %d\n", x, y);
1380 switch (mainwin->type) {
1381 case SEPARATE_FOLDER:
1382 widget = mainwin->win.sep_folder.folderwin;
1383 gdk_window_get_origin(widget->window, &x, &y);
1384 x %= sx; if (x < 0) x += sx;
1385 y %= sy; if (y < 0) y += sy;
1386 gdk_window_move(widget->window, x, y);
1387 gdk_window_raise(widget->window);
1389 case SEPARATE_MESSAGE:
1390 widget = mainwin->win.sep_message.messagewin;
1391 gdk_window_get_origin(widget->window, &x, &y);
1392 x %= sx; if (x < 0) x += sx;
1393 y %= sy; if (y < 0) y += sy;
1394 gdk_window_move(widget->window, x, y);
1395 gdk_window_raise(widget->window);
1398 widget = mainwin->win.sep_both.folderwin;
1399 gdk_window_get_origin(widget->window, &x, &y);
1400 x %= sx; if (x < 0) x += sx;
1401 y %= sy; if (y < 0) y += sy;
1402 gdk_window_move(widget->window, x, y);
1403 gdk_window_raise(widget->window);
1404 widget = mainwin->win.sep_both.messagewin;
1405 gdk_window_get_origin(widget->window, &x, &y);
1406 x %= sx; if (x < 0) x += sx;
1407 y %= sy; if (y < 0) y += sy;
1408 gdk_window_move(widget->window, x, y);
1409 gdk_window_raise(widget->window);
1416 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1418 GtkWidget *folderwin = NULL;
1419 GtkWidget *messagewin = NULL;
1422 GtkWidget *vbox_body = mainwin->vbox_body;
1424 debug_print(_("Setting widgets..."));
1426 /* create separated window(s) if needed */
1427 if (type & SEPARATE_FOLDER) {
1428 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1429 gtk_window_set_policy(GTK_WINDOW(folderwin),
1431 gtk_widget_set_usize(folderwin, -1,
1432 prefs_common.mainview_height);
1433 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1435 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1436 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1439 if (type & SEPARATE_MESSAGE) {
1440 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1441 gtk_window_set_policy(GTK_WINDOW(messagewin),
1443 gtk_widget_set_usize
1444 (messagewin, prefs_common.mainview_width,
1445 prefs_common.mainview_height
1446 - prefs_common.summaryview_height
1447 + DEFAULT_HEADERVIEW_HEIGHT);
1448 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1450 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1451 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1457 hpaned = gtk_hpaned_new();
1458 gtk_widget_show(hpaned);
1459 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1460 gtk_paned_add1(GTK_PANED(hpaned),
1461 GTK_WIDGET_PTR(mainwin->folderview));
1463 vpaned = gtk_vpaned_new();
1464 if (mainwin->summaryview->msg_is_toggled_on) {
1465 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1466 gtk_paned_add1(GTK_PANED(vpaned),
1467 GTK_WIDGET_PTR(mainwin->summaryview));
1469 gtk_paned_add2(GTK_PANED(hpaned),
1470 GTK_WIDGET_PTR(mainwin->summaryview));
1471 gtk_widget_ref(vpaned);
1473 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1474 prefs_common.summaryview_width,
1475 prefs_common.summaryview_height);
1476 gtk_paned_add2(GTK_PANED(vpaned),
1477 GTK_WIDGET_PTR(mainwin->messageview));
1478 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1479 prefs_common.mainview_width, -1);
1480 gtk_widget_set_usize(mainwin->window,
1481 prefs_common.folderview_width +
1482 prefs_common.mainview_width,
1483 prefs_common.mainwin_height);
1484 gtk_widget_show_all(vpaned);
1486 mainwin->win.sep_none.hpaned = hpaned;
1487 mainwin->win.sep_none.vpaned = vpaned;
1489 case SEPARATE_FOLDER:
1490 vpaned = gtk_vpaned_new();
1491 if (mainwin->summaryview->msg_is_toggled_on) {
1492 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1494 gtk_paned_add1(GTK_PANED(vpaned),
1495 GTK_WIDGET_PTR(mainwin->summaryview));
1497 gtk_box_pack_start(GTK_BOX(vbox_body),
1498 GTK_WIDGET_PTR(mainwin->summaryview),
1500 gtk_widget_ref(vpaned);
1502 gtk_paned_add2(GTK_PANED(vpaned),
1503 GTK_WIDGET_PTR(mainwin->messageview));
1504 gtk_widget_show_all(vpaned);
1505 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1506 prefs_common.summaryview_width,
1507 prefs_common.summaryview_height);
1508 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1509 prefs_common.mainview_width, -1);
1510 gtk_widget_set_usize(mainwin->window,
1511 prefs_common.mainview_width,
1512 prefs_common.mainview_height);
1514 gtk_container_add(GTK_CONTAINER(folderwin),
1515 GTK_WIDGET_PTR(mainwin->folderview));
1517 mainwin->win.sep_folder.folderwin = folderwin;
1518 mainwin->win.sep_folder.vpaned = vpaned;
1520 gtk_widget_show_all(folderwin);
1522 case SEPARATE_MESSAGE:
1523 hpaned = gtk_hpaned_new();
1524 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1526 gtk_paned_add1(GTK_PANED(hpaned),
1527 GTK_WIDGET_PTR(mainwin->folderview));
1528 gtk_paned_add2(GTK_PANED(hpaned),
1529 GTK_WIDGET_PTR(mainwin->summaryview));
1530 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1531 prefs_common.summaryview_width,
1532 prefs_common.summaryview_height);
1533 gtk_widget_set_usize(mainwin->window,
1534 prefs_common.folderview_width +
1535 prefs_common.mainview_width,
1536 prefs_common.mainwin_height);
1537 gtk_widget_show_all(hpaned);
1538 gtk_container_add(GTK_CONTAINER(messagewin),
1539 GTK_WIDGET_PTR(mainwin->messageview));
1541 mainwin->win.sep_message.messagewin = messagewin;
1542 mainwin->win.sep_message.hpaned = hpaned;
1544 gtk_widget_show_all(messagewin);
1547 gtk_box_pack_start(GTK_BOX(vbox_body),
1548 GTK_WIDGET_PTR(mainwin->summaryview),
1550 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1551 prefs_common.summaryview_width,
1552 prefs_common.summaryview_height);
1553 gtk_widget_set_usize(mainwin->window,
1554 prefs_common.mainview_width,
1555 prefs_common.mainwin_height);
1556 gtk_container_add(GTK_CONTAINER(folderwin),
1557 GTK_WIDGET_PTR(mainwin->folderview));
1558 gtk_container_add(GTK_CONTAINER(messagewin),
1559 GTK_WIDGET_PTR(mainwin->messageview));
1561 mainwin->win.sep_both.folderwin = folderwin;
1562 mainwin->win.sep_both.messagewin = messagewin;
1564 gtk_widget_show_all(folderwin);
1565 gtk_widget_show_all(messagewin);
1569 mainwin->type = type;
1571 debug_print(_("done.\n"));
1574 #include "pixmaps/stock_mail_receive.xpm"
1575 #include "pixmaps/stock_mail_receive_all.xpm"
1576 #include "pixmaps/stock_mail_compose.xpm"
1577 #include "pixmaps/stock_news_compose.xpm"
1578 #include "pixmaps/stock_mail_reply.xpm"
1579 #include "pixmaps/stock_mail_reply_to_all.xpm"
1580 #include "pixmaps/stock_mail_reply_to_author.xpm"
1581 #include "pixmaps/stock_mail_forward.xpm"
1582 #include "pixmaps/stock_mail_send.xpm"
1583 #include "pixmaps/stock_preferences.xpm"
1584 #include "pixmaps/stock_properties.xpm"
1585 #include "pixmaps/stock_down_arrow.xpm"
1586 #include "pixmaps/stock_close.xpm"
1587 #include "pixmaps/stock_exec.xpm"
1589 #define CREATE_TOOLBAR_ICON(xpm_d) \
1591 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1592 &container->style->white, \
1594 icon_wid = gtk_pixmap_new(icon, mask); \
1597 static void main_window_toolbar_create(MainWindow *mainwin,
1598 GtkWidget *container)
1603 GtkWidget *icon_wid;
1605 GtkWidget *getall_btn;
1606 GtkWidget *compose_mail_btn;
1607 GtkWidget *compose_news_btn;
1608 GtkWidget *compose_mail_btn_plain;
1609 GtkWidget *compose_news_btn_plain;
1610 GtkWidget *reply_btn;
1611 GtkWidget *replyall_btn;
1612 GtkWidget *replysender_btn;
1614 GtkWidget *send_btn;
1616 GtkWidget *prefs_btn;
1617 GtkWidget *account_btn;
1619 GtkWidget *next_btn;
1620 GtkWidget *delete_btn;
1621 GtkWidget *exec_btn;
1622 GtkWidget *compose_type_btn;
1623 GtkWidget *compose_type_arrow;
1624 GtkWidget *compose_box;
1625 GtkWidget *compose_label;
1626 GtkTooltips *tooltips;
1628 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1630 gtk_container_add(GTK_CONTAINER(container), toolbar);
1631 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1632 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1633 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1634 GTK_TOOLBAR_SPACE_LINE);
1636 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1637 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1639 _("Get new mail from current account"),
1641 icon_wid, toolbar_inc_cb, mainwin);
1642 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1643 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1645 _("Get new mail from all accounts"),
1651 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1653 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1654 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1656 _("Send queued message(s)"),
1662 /* to implement Leandro's "combined" compose buttons, we create
1663 * two sets of compose buttons, one for normal (text + icon)
1664 * toolbar, and one for both text-only and icon-only toolbar;
1665 * we switch between those sets. */
1667 /* insert compose mail button widget */
1669 compose_mail_btn = gtk_button_new();
1670 gtk_widget_show(compose_mail_btn);
1671 tooltips = gtk_tooltips_new();
1672 gtk_tooltips_set_tip(tooltips, compose_mail_btn,
1673 _("Compose email message"),
1675 compose_box = gtk_vbox_new(0, 0);
1676 gtk_widget_show(compose_box);
1678 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1679 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1680 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1682 compose_label = gtk_label_new(_("Email"));
1683 gtk_widget_show(compose_label);
1684 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1686 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1687 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1688 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1691 /* insert compose news button widget */
1693 compose_news_btn = gtk_button_new();
1694 gtk_widget_show(compose_news_btn);
1695 tooltips = gtk_tooltips_new();
1696 gtk_tooltips_set_tip(tooltips, compose_news_btn,
1697 _("Compose news article"),
1699 compose_box = gtk_vbox_new(0, 0);
1700 gtk_widget_show(compose_box);
1702 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1703 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1704 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1706 compose_label = gtk_label_new(_("News"));
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_news_btn), GTK_CAN_FOCUS);
1711 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1712 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1715 /* insert compose btn plain */
1717 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1718 compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1720 _("Compose an email message"),
1723 toolbar_compose_mail_cb,
1726 /* insert compose btn plain */
1728 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1729 compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1731 _("Compose a news message"),
1734 toolbar_compose_news_cb,
1737 /* insert compose button type widget */
1739 compose_type_btn = gtk_button_new();
1740 gtk_widget_show(compose_type_btn);
1742 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1743 gtk_widget_show(compose_type_arrow);
1745 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1747 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1748 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1750 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1753 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1755 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1756 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1758 _("Reply to the message"),
1763 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1764 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1769 toolbar_reply_to_all_cb,
1771 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1772 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1774 _("Reply to sender"),
1777 toolbar_reply_to_sender_cb,
1779 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1780 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1782 _("Forward the message"),
1788 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1790 CREATE_TOOLBAR_ICON(stock_close_xpm);
1791 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1793 _("Delete the message"),
1799 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1800 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1802 _("Execute marked process"),
1808 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1809 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1811 _("Next unread message"),
1814 toolbar_next_unread_cb,
1818 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1820 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1821 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1823 _("Common preference"),
1828 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1829 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1831 _("Account setting"),
1836 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1837 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1841 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1842 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1845 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1846 GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
1849 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
1850 GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
1853 mainwin->toolbar = toolbar;
1854 mainwin->get_btn = get_btn;
1855 mainwin->getall_btn = getall_btn;
1856 mainwin->compose_mail_btn = compose_mail_btn;
1857 mainwin->compose_news_btn = compose_news_btn;
1858 mainwin->compose_mail_btn_plain = compose_mail_btn_plain;
1859 mainwin->compose_news_btn_plain = compose_news_btn_plain;
1860 mainwin->reply_btn = reply_btn;
1861 mainwin->replyall_btn = replyall_btn;
1862 mainwin->replysender_btn = replysender_btn;
1863 mainwin->fwd_btn = fwd_btn;
1864 mainwin->send_btn = send_btn;
1866 mainwin->prefs_btn = prefs_btn;
1867 mainwin->account_btn = account_btn;
1869 mainwin->next_btn = next_btn;
1870 mainwin->delete_btn = delete_btn;
1871 mainwin->exec_btn = exec_btn;
1873 gtk_widget_show_all(toolbar);
1875 /* activate Leandro menu system */
1876 activate_compose_button(mainwin,
1877 prefs_common.toolbar_style,
1878 mainwin->compose_btn_type);
1881 /* callback functions */
1883 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1886 MainWindow *mainwindow = (MainWindow *) data;
1887 GtkWidget *compose_menu, *compose_item;
1889 g_return_if_fail(mainwindow != NULL);
1891 compose_menu = gtk_menu_new();
1893 compose_item = gtk_menu_item_new_with_label(_("Email message"));
1894 gtk_widget_show(compose_item);
1895 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1896 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1897 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1899 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1901 compose_item = gtk_menu_item_new_with_label(_("News article"));
1902 gtk_widget_show(compose_item);
1903 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1904 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1905 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1907 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1909 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1913 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1915 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1916 MainWindow *mainwindow = (MainWindow *) data;
1918 mainwindow->compose_btn_type = compose_type;
1920 activate_compose_button(mainwindow, prefs_common.toolbar_style, mainwindow->compose_btn_type);
1923 static void toolbar_inc_cb (GtkWidget *widget,
1926 MainWindow *mainwin = (MainWindow *)data;
1928 inc_mail_cb(mainwin, 0, NULL);
1931 static void toolbar_inc_all_cb (GtkWidget *widget,
1934 MainWindow *mainwin = (MainWindow *)data;
1936 inc_all_account_mail_cb(mainwin, 0, NULL);
1939 static void toolbar_send_cb (GtkWidget *widget,
1942 MainWindow *mainwin = (MainWindow *)data;
1944 send_queue_cb(mainwin, 0, NULL);
1947 static void toolbar_compose_cb (GtkWidget *widget,
1950 MainWindow *mainwin = (MainWindow *)data;
1952 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1953 compose_cb(mainwin, 0, NULL);
1955 compose_news_cb(mainwin, 0, NULL);
1958 static void toolbar_compose_news_cb (GtkWidget *widget,
1961 MainWindow *mainwin = (MainWindow *)data;
1963 compose_news_cb(mainwin, 0, NULL);
1966 static void toolbar_compose_mail_cb (GtkWidget *widget,
1969 MainWindow *mainwin = (MainWindow *)data;
1971 compose_mail_cb(mainwin, 0, NULL);
1974 static void toolbar_reply_cb (GtkWidget *widget,
1977 MainWindow *mainwin = (MainWindow *)data;
1979 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1982 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1985 MainWindow *mainwin = (MainWindow *)data;
1987 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1990 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1993 MainWindow *mainwin = (MainWindow *)data;
1995 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1998 static void toolbar_forward_cb (GtkWidget *widget,
2001 MainWindow *mainwin = (MainWindow *)data;
2003 if (prefs_common.forward_as_attachment)
2004 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2006 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2009 static void toolbar_delete_cb (GtkWidget *widget,
2012 MainWindow *mainwin = (MainWindow *)data;
2014 summary_delete(mainwin->summaryview);
2017 static void toolbar_exec_cb (GtkWidget *widget,
2020 MainWindow *mainwin = (MainWindow *)data;
2022 summary_execute(mainwin->summaryview);
2025 static void toolbar_next_unread_cb (GtkWidget *widget,
2028 MainWindow *mainwin = (MainWindow *)data;
2030 next_unread_cb(mainwin, 0, NULL);
2033 static void toolbar_prefs_cb (GtkWidget *widget,
2036 prefs_common_open();
2039 static void toolbar_account_cb (GtkWidget *widget,
2042 MainWindow *mainwin = (MainWindow *)data;
2044 prefs_account_open_cb(mainwin, 0, NULL);
2047 static void toolbar_account_button_pressed(GtkWidget *widget,
2048 GdkEventButton *event,
2051 MainWindow *mainwin = (MainWindow *)data;
2054 if (event->button != 3) return;
2056 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2057 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2060 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2061 menu_button_position, widget,
2062 event->button, event->time);
2065 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2068 MainWindow *mainwin = (MainWindow *)data;
2072 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2073 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2076 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2077 menu_button_position, widget,
2078 event->button, event->time);
2081 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2083 MainWindow *mainwin = (MainWindow *)data;
2086 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2087 if (!button) return;
2088 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2089 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2090 manage_window_focus_in(mainwin->window, NULL, NULL);
2093 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2096 MainWindow *mainwin = (MainWindow *)data;
2098 if (mainwin->lock_count == 0)
2099 app_exit_cb(data, 0, widget);
2104 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2107 main_window_add_mailbox(mainwin);
2110 static void add_mbox_cb(MainWindow *mainwin, guint action,
2113 main_window_add_mbox(mainwin);
2116 static void update_folderview_cb(MainWindow *mainwin, guint action,
2119 summary_show(mainwin->summaryview, NULL, FALSE);
2120 folderview_update_all();
2123 static void new_folder_cb(MainWindow *mainwin, guint action,
2126 folderview_new_folder(mainwin->folderview);
2129 static void rename_folder_cb(MainWindow *mainwin, guint action,
2132 folderview_rename_folder(mainwin->folderview);
2135 static void delete_folder_cb(MainWindow *mainwin, guint action,
2138 folderview_delete_folder(mainwin->folderview);
2141 static void import_mbox_cb(MainWindow *mainwin, guint action,
2144 import_mbox(mainwin->summaryview->folder_item);
2147 static void export_mbox_cb(MainWindow *mainwin, guint action,
2150 export_mbox(mainwin->summaryview->folder_item);
2153 static void empty_trash_cb(MainWindow *mainwin, guint action,
2156 main_window_empty_trash(mainwin, TRUE);
2159 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2161 summary_save_as(mainwin->summaryview);
2164 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2166 summary_print(mainwin->summaryview);
2169 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2171 if (prefs_common.confirm_on_exit) {
2172 if (alertpanel(_("Exit"), _("Exit this program?"),
2173 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2175 manage_window_focus_in(mainwin->window, NULL, NULL);
2178 app_will_exit(widget, mainwin);
2181 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2184 switch (mainwin->type) {
2186 case SEPARATE_MESSAGE:
2188 case SEPARATE_FOLDER:
2189 if (GTK_CHECK_MENU_ITEM(widget)->active)
2190 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2192 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2195 if (GTK_CHECK_MENU_ITEM(widget)->active)
2196 gtk_widget_show(mainwin->win.sep_both.folderwin);
2198 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2203 static void toggle_message_cb(MainWindow *mainwin, guint action,
2206 switch (mainwin->type) {
2208 case SEPARATE_FOLDER:
2210 case SEPARATE_MESSAGE:
2211 if (GTK_CHECK_MENU_ITEM(widget)->active)
2212 gtk_widget_show(mainwin->win.sep_message.messagewin);
2214 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2217 if (GTK_CHECK_MENU_ITEM(widget)->active)
2218 gtk_widget_show(mainwin->win.sep_both.messagewin);
2220 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2225 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2228 activate_compose_button(mainwin, (ToolbarStyle)action,
2229 mainwin->compose_btn_type);
2231 switch ((ToolbarStyle)action) {
2233 gtk_widget_hide(mainwin->handlebox);
2235 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2239 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2243 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2248 if (action != TOOLBAR_NONE) {
2249 gtk_widget_show(mainwin->handlebox);
2250 gtk_widget_queue_resize(mainwin->handlebox);
2253 mainwin->toolbar_style = (ToolbarStyle)action;
2254 prefs_common.toolbar_style = (ToolbarStyle)action;
2257 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2260 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2261 gtk_widget_show(mainwin->hbox_stat);
2262 prefs_common.show_statusbar = TRUE;
2264 gtk_widget_hide(mainwin->hbox_stat);
2265 prefs_common.show_statusbar = FALSE;
2269 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2272 MainWindow *mainwin;
2275 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2276 g_return_if_fail(mainwin != NULL);
2278 type = mainwin->type ^ action;
2279 main_window_separation_change(mainwin, type);
2281 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2282 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2285 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2288 addressbook_open(NULL);
2291 static void log_window_show_cb(MainWindow *mainwin, guint action,
2294 log_window_show(mainwin->logwin);
2297 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2302 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2305 inc_all_account_mail(mainwin);
2308 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2312 if (procmsg_send_queue() < 0)
2313 alertpanel_error(_("Some errors occurred while sending queued messages."));
2315 statusbar_pop_all();
2317 for (list = folder_get_list(); list != NULL; list = list->next) {
2320 folder = list->data;
2321 if (folder->queue) {
2322 folder_item_scan(folder->queue);
2323 folderview_update_item(folder->queue, TRUE);
2328 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2330 if (mainwin->summaryview->folder_item) {
2331 if (mainwin->summaryview->folder_item->folder->account != NULL
2332 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2333 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2335 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2341 static void compose_mail_cb(MainWindow *mainwin, guint action,
2348 if (mainwin->summaryview->folder_item) {
2349 ac = mainwin->summaryview->folder_item->folder->account;
2350 if (ac && ac->protocol != A_NNTP) {
2351 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2356 if(cur_account && (cur_account->protocol != A_NNTP)) {
2357 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2361 list = account_get_list();
2362 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2363 ac = (PrefsAccount *) cur->data;
2364 if (ac->protocol != A_NNTP) {
2365 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2371 static void compose_news_cb(MainWindow *mainwin, guint action,
2374 PrefsAccount * ac = NULL;
2378 if (mainwin->summaryview->folder_item) {
2379 ac = mainwin->summaryview->folder_item->folder->account;
2380 if (ac && ac->protocol == A_NNTP) {
2381 compose_new_with_recipient
2382 (ac, mainwin->summaryview->folder_item->path);
2387 list = account_get_list();
2388 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2389 ac = (PrefsAccount *) cur->data;
2390 if (ac->protocol == A_NNTP) {
2397 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2399 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2402 msginfo = gtk_ctree_node_get_row_data
2403 (GTK_CTREE(mainwin->summaryview->ctree),
2404 mainwin->summaryview->selected);
2406 if (!msginfo) return;
2410 compose_reply(msginfo, prefs_common.reply_with_quote,
2413 case COMPOSE_REPLY_TO_SENDER:
2414 compose_reply(msginfo, prefs_common.reply_with_quote,
2417 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2418 compose_followup_and_reply_to(msginfo,
2419 prefs_common.reply_with_quote,
2422 case COMPOSE_REPLY_TO_ALL:
2423 compose_reply(msginfo, prefs_common.reply_with_quote,
2426 case COMPOSE_FORWARD:
2428 compose_forward(NULL, msginfo, FALSE);
2431 /* if (sel->next) FALL_THROUGH */
2432 case COMPOSE_FORWARD_AS_ATTACH:
2434 GSList *msginfo_list = NULL;
2435 for ( ; sel != NULL; sel = sel->next)
2436 msginfo_list = g_slist_append(msginfo_list,
2437 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2438 GTK_CTREE_NODE(sel->data)));
2439 compose_forward_multiple(NULL, msginfo_list);
2440 g_slist_free(msginfo_list);
2444 g_warning("reply_cb(): invalid action type: %d\n", action);
2447 summary_set_marks_selected(mainwin->summaryview);
2450 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2452 summary_move_to(mainwin->summaryview);
2455 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2457 summary_copy_to(mainwin->summaryview);
2460 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2462 summary_delete(mainwin->summaryview);
2465 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2467 summary_open_msg(mainwin->summaryview);
2470 static void view_source_cb(MainWindow *mainwin, guint action,
2473 summary_view_source(mainwin->summaryview);
2476 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2478 summary_reedit(mainwin->summaryview);
2481 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2483 summary_mark(mainwin->summaryview);
2486 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2488 summary_unmark(mainwin->summaryview);
2491 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2494 summary_mark_as_unread(mainwin->summaryview);
2497 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2500 summary_mark_as_read(mainwin->summaryview);
2503 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2506 summary_mark_all_read(mainwin->summaryview);
2509 static void add_address_cb(MainWindow *mainwin, guint action,
2512 summary_add_address(mainwin->summaryview);
2515 static void set_charset_cb(MainWindow *mainwin, guint action,
2520 str = conv_get_charset_str((CharSet)action);
2521 g_free(prefs_common.force_charset);
2522 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2524 summary_redisplay_msg(mainwin->summaryview);
2526 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2529 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2531 GtkItemFactory *ifactory;
2533 ifactory = gtk_item_factory_from_widget(widget);
2535 if (mainwin->summaryview->folder_item) {
2537 summary_thread_build(mainwin->summaryview, FALSE);
2538 mainwin->summaryview->folder_item->threaded = TRUE;
2539 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2540 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2542 summary_unthread(mainwin->summaryview);
2543 mainwin->summaryview->folder_item->threaded = FALSE;
2544 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2545 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2550 static void set_display_item_cb(MainWindow *mainwin, guint action,
2553 prefs_summary_display_item_set();
2556 static void sort_summary_cb(MainWindow *mainwin, guint action,
2559 summary_sort(mainwin->summaryview, (SummarySortType)action);
2562 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2565 summary_attract_by_subject(mainwin->summaryview);
2568 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2571 summary_delete_duplicated(mainwin->summaryview);
2574 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2576 summary_filter(mainwin->summaryview);
2579 static void execute_summary_cb(MainWindow *mainwin, guint action,
2582 summary_execute(mainwin->summaryview);
2585 static void update_summary_cb(MainWindow *mainwin, guint action,
2589 FolderView *folderview = mainwin->folderview;
2591 if (!mainwin->summaryview->folder_item) return;
2592 if (!folderview->opened) return;
2594 folder_update_op_count();
2596 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2597 folderview->opened);
2600 summary_show(mainwin->summaryview, fitem, TRUE);
2603 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2605 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2608 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2610 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2613 static void prev_unread_cb(MainWindow *mainwin, guint action,
2616 summary_select_prev_unread(mainwin->summaryview);
2619 static void next_unread_cb(MainWindow *mainwin, guint action,
2622 summary_select_next_unread(mainwin->summaryview);
2625 static void prev_marked_cb(MainWindow *mainwin, guint action,
2628 summary_select_prev_marked(mainwin->summaryview);
2631 static void next_marked_cb(MainWindow *mainwin, guint action,
2634 summary_select_next_marked(mainwin->summaryview);
2637 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2640 summary_select_prev_labeled(mainwin->summaryview);
2643 static void next_labeled_cb(MainWindow *mainwin, guint action,
2646 summary_select_next_labeled(mainwin->summaryview);
2649 static void goto_folder_cb(MainWindow *mainwin, guint action,
2652 FolderItem *to_folder;
2654 to_folder = foldersel_folder_sel(NULL, NULL);
2657 folderview_select(mainwin->folderview, to_folder);
2660 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2662 messageview_copy_clipboard(mainwin->messageview);
2665 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2667 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2668 summary_select_all(mainwin->summaryview);
2669 else if (mainwin->summaryview->msg_is_toggled_on &&
2670 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2671 messageview_select_all(mainwin->messageview);
2674 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2677 prefs_common_open();
2680 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2683 prefs_filter_open();
2686 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2689 prefs_scoring_open(NULL);
2692 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2695 prefs_filtering_open();
2698 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2702 new_account_cb(mainwin, 0, widget);
2704 gboolean prev_default = cur_account->is_default;
2706 prefs_account_open(cur_account);
2707 if (!prev_default && cur_account->is_default)
2708 account_set_as_default(cur_account);
2709 account_save_config_all();
2711 main_window_reflect_prefs_all();
2715 static void new_account_cb(MainWindow *mainwin, guint action,
2718 account_edit_open();
2719 if (!compose_get_compose_list()) account_add();
2722 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2724 cur_account = (PrefsAccount *)data;
2725 main_window_reflect_prefs_all();
2728 static void manual_open_cb(MainWindow *mainwin, guint action,
2731 manual_open((ManualLang)action);
2734 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2736 MainWindow *mainwin = (MainWindow *)data;
2740 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2741 LOCAL_FOLDER(folder)->rootpath,
2745 str = g_strdup_printf(_("Scanning folder %s ..."),
2746 LOCAL_FOLDER(folder)->rootpath);
2748 STATUSBAR_PUSH(mainwin, str);
2749 STATUSBAR_POP(mainwin);
2753 static void activate_compose_button (MainWindow *mainwin,
2755 ComposeButtonType type)
2757 if (style == TOOLBAR_NONE)
2760 if (style == TOOLBAR_BOTH) {
2761 gtk_widget_hide(mainwin->compose_mail_btn_plain);
2762 gtk_widget_hide(mainwin->compose_news_btn_plain);
2763 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2764 : mainwin->compose_news_btn);
2765 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2766 : mainwin->compose_mail_btn);
2767 mainwin->compose_btn_type = type;
2770 gtk_widget_hide(mainwin->compose_news_btn);
2771 gtk_widget_hide(mainwin->compose_mail_btn);
2772 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn_plain
2773 : mainwin->compose_news_btn_plain);
2774 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn_plain
2775 : mainwin->compose_mail_btn_plain);
2776 mainwin->compose_btn_type = type;
2780 static void prefs_templates_open_cb(MainWindow *mainwin, guint action,
2783 prefs_templates_open();