sync with 0.7.6cvs4
[claws.git] / src / mainwindow.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2002 Hiroyuki Yamamoto
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 #include "defs.h"
21
22 #include <glib.h>
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
42 #include <string.h>
43
44 #include "intl.h"
45 #include "main.h"
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
54 #include "menu.h"
55 #include "stock_pixmap.h"
56 #include "folder.h"
57 #include "inc.h"
58 #include "compose.h"
59 #include "procmsg.h"
60 #include "import.h"
61 #include "export.h"
62 #include "prefs_common.h"
63 #include "prefs_filter.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_scoring.h"
67 #include "prefs_account.h"
68 #include "prefs_folder_item.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_template.h"
71 #include "account.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
78 #include "utils.h"
79 #include "gtkutils.h"
80 #include "codeconv.h"
81 #include "about.h"
82 #include "manual.h"
83 #include "version.h"
84 #include "selective_download.h"
85
86 #define AC_LABEL_WIDTH  240
87
88 #define STATUSBAR_PUSH(mainwin, str) \
89 { \
90         gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
91                            mainwin->mainwin_cid, str); \
92         gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
93 }
94
95 #define STATUSBAR_POP(mainwin) \
96 { \
97         gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
98                           mainwin->mainwin_cid); \
99 }
100
101 /* list of all instantiated MainWindow */
102 static GList *mainwin_list = NULL;
103
104 static GdkCursor *watch_cursor;
105
106 static void main_window_menu_callback_block     (MainWindow     *mainwin);
107 static void main_window_menu_callback_unblock   (MainWindow     *mainwin);
108
109 static void main_window_show_cur_account        (MainWindow     *mainwin);
110
111 static void main_window_set_widgets             (MainWindow     *mainwin,
112                                                  SeparateType    type);
113 static void main_window_toolbar_create          (MainWindow     *mainwin,
114                                                  GtkWidget      *container);
115
116 /* callback functions */
117 static void toolbar_inc_cb              (GtkWidget      *widget,
118                                          gpointer        data);
119 static void toolbar_inc_all_cb          (GtkWidget      *widget,
120                                          gpointer        data);
121 static void toolbar_send_cb             (GtkWidget      *widget,
122                                          gpointer        data);
123
124 static void toolbar_compose_cb          (GtkWidget      *widget,
125                                          gpointer        data);
126 static void toolbar_compose_news_cb     (GtkWidget      *widget,
127                                          gpointer        data);
128 static void toolbar_compose_mail_cb     (GtkWidget      *widget,
129                                          gpointer        data);
130 static void toolbar_reply_cb            (GtkWidget      *widget,
131                                          gpointer        data);
132 static void toolbar_reply_popup_cb      (GtkWidget      *widget,
133                                          GdkEventButton *event,
134                                          gpointer        data);
135 static void toolbar_reply_popup_closed_cb(GtkMenuShell  *menu_shell,
136                                          gpointer        data);
137 static void toolbar_reply_to_all_cb     (GtkWidget      *widget,
138                                          gpointer        data);
139 static void toolbar_reply_to_all_popup_cb(GtkWidget     *widget,
140                                          GdkEventButton *event,
141                                          gpointer        data);
142 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell   *menu_shell,
143                                          gpointer        data);
144 static void toolbar_reply_to_sender_cb  (GtkWidget      *widget,
145                                          gpointer        data);
146 static void toolbar_reply_to_sender_popup_cb(GtkWidget  *widget,
147                                          GdkEventButton *event,
148                                          gpointer        data);
149 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell        *menu_shell,
150                                          gpointer        data);
151 static void toolbar_forward_cb          (GtkWidget      *widget,
152                                          gpointer        data);
153 static void toolbar_forward_popup_cb    (GtkWidget      *widget,
154                                          GdkEventButton *event,
155                                          gpointer        data);
156 static void toolbar_forward_popup_closed_cb(GtkMenuShell        *menu_shell,
157                                          gpointer        data);
158
159 static void toolbar_delete_cb           (GtkWidget      *widget,
160                                          gpointer        data);
161 static void toolbar_exec_cb             (GtkWidget      *widget,
162                                          gpointer        data);
163
164 static void toolbar_next_unread_cb      (GtkWidget      *widget,
165                                          gpointer        data);
166
167 static void toolbar_prefs_cb            (GtkWidget      *widget,
168                                          gpointer        data);
169 static void toolbar_account_cb          (GtkWidget      *widget,
170                                          gpointer        data);
171
172 #if 0
173 static void toolbar_account_button_pressed      (GtkWidget      *widget,
174                                                  GdkEventButton *event,
175                                                  gpointer        data);
176 #endif
177 static void ac_label_button_pressed             (GtkWidget      *widget,
178                                                  GdkEventButton *event,
179                                                  gpointer        data);
180 static void ac_menu_popup_closed                (GtkMenuShell   *menu_shell,
181                                                  gpointer        data);
182
183 static gint main_window_close_cb (GtkWidget     *widget,
184                                   GdkEventAny   *event,
185                                   gpointer       data);
186
187 static void add_mailbox_cb       (MainWindow    *mainwin,
188                                   guint          action,
189                                   GtkWidget     *widget);
190 static void add_mbox_cb          (MainWindow    *mainwin,
191                                   guint          action,
192                                   GtkWidget     *widget);
193 static void update_folderview_cb (MainWindow    *mainwin,
194                                   guint          action,
195                                   GtkWidget     *widget);
196 static void new_folder_cb        (MainWindow    *mainwin,
197                                   guint          action,
198                                   GtkWidget     *widget);
199 static void rename_folder_cb     (MainWindow    *mainwin,
200                                   guint          action,
201                                   GtkWidget     *widget);
202 static void delete_folder_cb     (MainWindow    *mainwin,
203                                   guint          action,
204                                   GtkWidget     *widget);
205 static void import_mbox_cb       (MainWindow    *mainwin,
206                                   guint          action,
207                                   GtkWidget     *widget);
208 static void export_mbox_cb       (MainWindow    *mainwin,
209                                   guint          action,
210                                   GtkWidget     *widget);
211 static void empty_trash_cb       (MainWindow    *mainwin,
212                                   guint          action,
213                                   GtkWidget     *widget);
214
215 static void save_as_cb           (MainWindow    *mainwin,
216                                   guint          action,
217                                   GtkWidget     *widget);
218 static void print_cb             (MainWindow    *mainwin,
219                                   guint          action,
220                                   GtkWidget     *widget);
221 static void app_exit_cb          (MainWindow    *mainwin,
222                                   guint          action,
223                                   GtkWidget     *widget);
224
225 static void search_cb            (MainWindow    *mainwin,
226                                   guint          action,
227                                   GtkWidget     *widget);
228
229 static void toggle_folder_cb     (MainWindow    *mainwin,
230                                   guint          action,
231                                   GtkWidget     *widget);
232 static void toggle_message_cb    (MainWindow    *mainwin,
233                                   guint          action,
234                                   GtkWidget     *widget);
235 static void toggle_toolbar_cb    (MainWindow    *mainwin,
236                                   guint          action,
237                                   GtkWidget     *widget);
238 static void toggle_statusbar_cb  (MainWindow    *mainwin,
239                                   guint          action,
240                                   GtkWidget     *widget);
241 static void toggle_expand_summaryview_cb         (MainWindow    *mainwin,
242                                   guint          action,
243                                   GtkWidget     *widget);
244 static void toggle_expand_messageview_cb         (MainWindow    *mainwin,
245                                   guint          action,
246                                   GtkWidget     *widget);
247 static void toggle_work_offline_cb       (MainWindow    *mainwin,
248                                   guint          action,
249                                   GtkWidget     *widget);
250 static void separate_widget_cb  (GtkCheckMenuItem *checkitem,
251                                  guint action,
252                                  GtkWidget *widget);
253
254 static void addressbook_open_cb (MainWindow     *mainwin,
255                                  guint           action,
256                                  GtkWidget      *widget);
257 static void log_window_show_cb  (MainWindow     *mainwin,
258                                  guint           action,
259                                  GtkWidget      *widget);
260 static void sel_download_cb     (MainWindow *mainwin, 
261                                  guint action,
262                                  GtkWidget *widget);
263
264 static void inc_mail_cb                 (MainWindow     *mainwin,
265                                          guint           action,
266                                          GtkWidget      *widget);
267 static void inc_all_account_mail_cb     (MainWindow     *mainwin,
268                                          guint           action,
269                                          GtkWidget      *widget);
270 static void inc_cancel_cb               (MainWindow     *mainwin,
271                                          guint           action,
272                                          GtkWidget      *widget);
273
274 static void send_queue_cb               (MainWindow     *mainwin,
275                                          guint           action,
276                                          GtkWidget      *widget);
277
278 static void compose_cb                  (MainWindow     *mainwin,
279                                          guint           action,
280                                          GtkWidget      *widget);
281 static void compose_mail_cb(MainWindow *mainwin, guint action,
282                             GtkWidget *widget);
283 static void compose_news_cb(MainWindow *mainwin, guint action,
284                             GtkWidget *widget);
285 static void reply_cb                    (MainWindow     *mainwin,
286                                          guint           action,
287                                          GtkWidget      *widget);
288
289 static void open_msg_cb                 (MainWindow     *mainwin,
290                                          guint           action,
291                                          GtkWidget      *widget);
292
293 static void view_source_cb              (MainWindow     *mainwin,
294                                          guint           action,
295                                          GtkWidget      *widget);
296
297 static void show_all_header_cb          (MainWindow     *mainwin,
298                                          guint           action,
299                                          GtkWidget      *widget);
300
301 static void reedit_cb                   (MainWindow     *mainwin,
302                                          guint           action,
303                                          GtkWidget      *widget);
304
305 static void move_to_cb                  (MainWindow     *mainwin,
306                                          guint           action,
307                                          GtkWidget      *widget);
308 static void copy_to_cb                  (MainWindow     *mainwin,
309                                          guint           action,
310                                          GtkWidget      *widget);
311 static void delete_cb                   (MainWindow     *mainwin,
312                                          guint           action,
313                                          GtkWidget      *widget);
314
315 static void mark_cb                     (MainWindow     *mainwin,
316                                          guint           action,
317                                          GtkWidget      *widget);
318 static void unmark_cb                   (MainWindow     *mainwin,
319                                          guint           action,
320                                          GtkWidget      *widget);
321
322 static void mark_as_unread_cb           (MainWindow     *mainwin,
323                                          guint           action,
324                                          GtkWidget      *widget);
325 static void mark_as_read_cb             (MainWindow     *mainwin,
326                                          guint           action,
327                                          GtkWidget      *widget);
328 static void mark_all_read_cb            (MainWindow     *mainwin,
329                                          guint           action,
330                                          GtkWidget      *widget);
331 static void add_address_cb              (MainWindow     *mainwin,
332                                          guint           action,
333                                          GtkWidget      *widget);
334
335 static void set_charset_cb              (MainWindow     *mainwin,
336                                          guint           action,
337                                          GtkWidget      *widget);
338
339 static void hide_read_messages   (MainWindow    *mainwin,
340                                   guint          action,
341                                   GtkWidget     *widget);
342
343 static void thread_cb            (MainWindow    *mainwin,
344                                   guint          action,
345                                   GtkWidget     *widget);
346 static void set_display_item_cb  (MainWindow    *mainwin,
347                                   guint          action,
348                                   GtkWidget     *widget);
349 static void sort_summary_cb      (MainWindow    *mainwin,
350                                   guint          action,
351                                   GtkWidget     *widget);
352 static void attract_by_subject_cb(MainWindow    *mainwin,
353                                   guint          action,
354                                   GtkWidget     *widget);
355
356 static void delete_duplicated_cb (MainWindow    *mainwin,
357                                   guint          action,
358                                   GtkWidget     *widget);
359 static void filter_cb            (MainWindow    *mainwin,
360                                   guint          action,
361                                   GtkWidget     *widget);
362 static void execute_summary_cb   (MainWindow    *mainwin,
363                                   guint          action,
364                                   GtkWidget     *widget);
365 static void update_summary_cb    (MainWindow    *mainwin,
366                                   guint          action,
367                                   GtkWidget     *widget);
368
369 static void prev_cb              (MainWindow    *mainwin,
370                                   guint          action,
371                                   GtkWidget     *widget);
372 static void next_cb              (MainWindow    *mainwin,
373                                   guint          action,
374                                   GtkWidget     *widget);
375
376 static void prev_unread_cb       (MainWindow    *mainwin,
377                                   guint          action,
378                                   GtkWidget     *widget);
379 static void next_unread_cb       (MainWindow    *mainwin,
380                                   guint          action,
381                                   GtkWidget     *widget);
382 static void prev_marked_cb       (MainWindow    *mainwin,
383                                   guint          action,
384                                   GtkWidget     *widget);
385 static void next_marked_cb       (MainWindow    *mainwin,
386                                   guint          action,
387                                   GtkWidget     *widget);
388 static void prev_labeled_cb      (MainWindow    *mainwin,
389                                   guint          action,
390                                   GtkWidget     *widget);
391 static void next_labeled_cb      (MainWindow    *mainwin,
392                                   guint          action,
393                                   GtkWidget     *widget);
394
395 static void goto_folder_cb       (MainWindow    *mainwin,
396                                   guint          action,
397                                   GtkWidget     *widget);
398
399 static void copy_cb              (MainWindow    *mainwin,
400                                   guint          action,
401                                   GtkWidget     *widget);
402 static void allsel_cb            (MainWindow    *mainwin,
403                                   guint          action,
404                                   GtkWidget     *widget);
405 static void selthread_cb         (MainWindow    *mainwin,
406                                   guint          action,
407                                   GtkWidget     *widget);
408 static void create_filter_cb     (MainWindow    *mainwin,
409                                   guint          action,
410                                   GtkWidget     *widget);
411
412 static void prefs_common_open_cb (MainWindow    *mainwin,
413                                   guint          action,
414                                   GtkWidget     *widget);
415 static void prefs_filter_open_cb (MainWindow    *mainwin,
416                                   guint          action,
417                                   GtkWidget     *widget);
418 static void prefs_scoring_open_cb (MainWindow   *mainwin,
419                                   guint          action,
420                                   GtkWidget     *widget);
421 static void prefs_filtering_open_cb (MainWindow *mainwin,
422                                   guint          action,
423                                   GtkWidget     *widget);
424 static void prefs_account_open_cb(MainWindow    *mainwin,
425                                   guint          action,
426                                   GtkWidget     *widget);
427 static void prefs_template_open_cb      (MainWindow     *mainwin,
428                                          guint           action,
429                                          GtkWidget      *widget);
430 static void prefs_actions_open_cb       (MainWindow     *mainwin,
431                                          guint           action,
432                                          GtkWidget      *widget);
433 static void new_account_cb       (MainWindow    *mainwin,
434                                   guint          action,
435                                   GtkWidget     *widget);
436
437 static void account_menu_cb      (GtkMenuItem   *menuitem,
438                                   gpointer       data);
439
440 static void online_switch_clicked(GtkButton     *btn, 
441                                   gpointer data);
442
443 static void manual_open_cb       (MainWindow    *mainwin,
444                                   guint          action,
445                                   GtkWidget     *widget);
446 static void faq_open_cb          (MainWindow    *mainwin,
447                                   guint          action,
448                                   GtkWidget     *widget);
449
450 static void scan_tree_func       (Folder        *folder,
451                                   FolderItem    *item,
452                                   gpointer       data);
453                                   
454 static void activate_compose_button (MainWindow *mainwin,
455                                 ToolbarStyle      style,
456                                 ComposeButtonType type);
457
458 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
459                                 GtkStateType state,
460                                 gpointer data);
461
462 static void key_pressed (GtkWidget *widget, 
463                                 GdkEventKey *event,
464                                 gpointer data);
465
466 static void set_toolbar_style(MainWindow *mainwin);
467
468 static void addr_harvest_cb      ( MainWindow  *mainwin,
469                                    guint       action,
470                                    GtkWidget   *widget );
471
472 static void addr_harvest_msg_cb  ( MainWindow  *mainwin,
473                                    guint       action,
474                                    GtkWidget   *widget );
475
476 #define  SEPARATE_ACTION  667
477
478 static GtkItemFactoryEntry mainwin_entries[] =
479 {
480         {N_("/_File"),                          NULL, NULL, 0, "<Branch>"},
481         {N_("/_File/_Add mailbox..."),          NULL, add_mailbox_cb, 0, NULL},
482         {N_("/_File/_Add mbox mailbox..."),     NULL, add_mbox_cb, 0, NULL},
483         {N_("/_File/_Rescan folder tree"),      NULL, update_folderview_cb, 0, NULL},
484         {N_("/_File/_Folder"),                  NULL, NULL, 0, "<Branch>"},
485         {N_("/_File/_Folder/Create _new folder..."),
486                                                 NULL, new_folder_cb, 0, NULL},
487         {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
488         {N_("/_File/_Folder/_Delete folder"),   NULL, delete_folder_cb, 0, NULL},
489         {N_("/_File/_Import mbox file..."),     NULL, import_mbox_cb, 0, NULL},
490         {N_("/_File/_Export to mbox file..."),  NULL, export_mbox_cb, 0, NULL},
491         {N_("/_File/Empty _trash"),             "<shift>D", empty_trash_cb, 0, NULL},
492         {N_("/_File/_Work offline"),            "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},                                               
493         {N_("/_File/---"),                      NULL, NULL, 0, "<Separator>"},
494         {N_("/_File/_Save as..."),              "<control>S", save_as_cb, 0, NULL},
495         {N_("/_File/_Print..."),                NULL, print_cb, 0, NULL},
496         {N_("/_File/---"),                      NULL, NULL, 0, "<Separator>"},
497         {N_("/_File/E_xit"),                    "<control>Q", app_exit_cb, 0, NULL},
498
499         {N_("/_Edit"),                          NULL, NULL, 0, "<Branch>"},
500         {N_("/_Edit/_Copy"),                    "<control>C", copy_cb, 0, NULL},
501         {N_("/_Edit/Select _all"),              "<control>A", allsel_cb, 0, NULL},
502         {N_("/_Edit/Select thread"),            "<control>Z", selthread_cb, 0, NULL},
503         {N_("/_Edit/---"),                      NULL, NULL, 0, "<Separator>"},
504         {N_("/_Edit/_Find in current message..."),
505                                                 "<control>F", search_cb, 0, NULL},
506         {N_("/_Edit/_Search folder..."),        "<shift><control>F", search_cb, 1, NULL},
507         {N_("/_View"),                          NULL, NULL, 0, "<Branch>"},
508         {N_("/_View/Show or hi_de"),            NULL, NULL, 0, "<Branch>"},
509         {N_("/_View/Show or hi_de/_Toolbar"),
510                                                 NULL, NULL, 0, "<Branch>"},
511         {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
512                                                 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
513         {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
514                                                 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
515         {N_("/_View/Show or hi_de/_Toolbar/_Text"),
516                                                 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
517         {N_("/_View/Show or hi_de/_Toolbar/_None"),
518                                                 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
519         {N_("/_View/Show or hi_de/Status _bar"),
520                                                 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
521         {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
522         {N_("/_View/Separate _Folder Tree"),    NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER,  "<ToggleItem>"},
523         {N_("/_View/Separate _Message View"),   NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
524         {N_("/_View/E_xpand Summary View"),     "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
525         {N_("/_View/Ex_pand Message View"),     "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
526         {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
527         {N_("/_View/_Sort"),                    NULL, NULL, 0, "<Branch>"},
528         {N_("/_View/_Sort/Sort by _number"),    NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
529         {N_("/_View/_Sort/Sort by s_ize"),      NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
530         {N_("/_View/_Sort/Sort by _date"),      NULL, sort_summary_cb, SORT_BY_DATE, NULL},
531         {N_("/_View/_Sort/Sort by _from"),      NULL, sort_summary_cb, SORT_BY_FROM, NULL},
532         {N_("/_View/_Sort/Sort by _subject"),   NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
533         {N_("/_View/_Sort/Sort by _color label"),
534                                                 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
535         {N_("/_View/_Sort/Sort by _mark"),      NULL, sort_summary_cb, SORT_BY_MARK, NULL},
536         {N_("/_View/_Sort/Sort by _unread"),    NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
537         {N_("/_View/_Sort/Sort by a_ttachment"),
538                                                 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
539         {N_("/_View/_Sort/---"),                NULL, NULL, 0, "<Separator>"},
540         {N_("/_View/_Sort/_Attract by subject"),
541                                                 NULL, attract_by_subject_cb, 0, NULL},
542         {N_("/_View/Th_read view"),             "<control>T",        thread_cb, 0, "<ToggleItem>"},
543         {N_("/_View/_Hide read messages"),      NULL, hide_read_messages, 0, "<ToggleItem>"},
544         {N_("/_View/Set display _item..."),     NULL, set_display_item_cb, 0, NULL},
545
546         {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
547         {N_("/_View/_Go to"),                   NULL, NULL, 0, "<Branch>"},
548         {N_("/_View/_Go to/_Prev message"),     "P", prev_cb, 0, NULL},
549         {N_("/_View/_Go to/_Next message"),     "N", next_cb, 0, NULL},
550         {N_("/_View/_Go to/---"),               NULL, NULL, 0, "<Separator>"},
551         {N_("/_View/_Go to/P_rev unread message"),
552                                                 "<shift>P", prev_unread_cb, 0, NULL},
553         {N_("/_View/_Go to/N_ext unread message"),
554                                                 "<shift>N", next_unread_cb, 0, NULL},
555         {N_("/_View/_Go to/---"),               NULL, NULL, 0, "<Separator>"},
556         {N_("/_View/_Go to/Prev _marked message"),
557                                                 NULL, prev_marked_cb, 0, NULL},
558         {N_("/_View/_Go to/Next m_arked message"),
559                                                 NULL, next_marked_cb, 0, NULL},
560         {N_("/_View/_Go to/---"),               NULL, NULL, 0, "<Separator>"},
561         {N_("/_View/_Go to/Prev _labeled message"),
562                                                 NULL, prev_labeled_cb, 0, NULL},
563         {N_("/_View/_Go to/Next la_beled message"),
564                                                 NULL, next_labeled_cb, 0, NULL},
565         {N_("/_View/_Go to/---"),               NULL, NULL, 0, "<Separator>"},
566         {N_("/_View/_Go to/Other _folder..."),  "G", goto_folder_cb, 0, NULL},
567         {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
568
569 #define CODESET_SEPARATOR \
570         {N_("/_View/_Code set/---"),            NULL, NULL, 0, "<Separator>"}
571 #define CODESET_ACTION(action) \
572          NULL, set_charset_cb, action, "/View/Code set/Auto detect"
573
574         {N_("/_View/_Code set"),                NULL, NULL, 0, "<Branch>"},
575         {N_("/_View/_Code set/_Auto detect"),
576          NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
577         {N_("/_View/_Code set/---"),            NULL, NULL, 0, "<Separator>"},
578         {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
579          CODESET_ACTION(C_US_ASCII)},
580
581 #if HAVE_LIBJCONV
582         {N_("/_View/_Code set/Unicode (_UTF-8)"),
583          CODESET_ACTION(C_UTF_8)},
584         CODESET_SEPARATOR,
585 #endif
586         {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
587          CODESET_ACTION(C_ISO_8859_1)},
588         {N_("/_View/_Code set/Western European (ISO-8859-15)"),
589          CODESET_ACTION(C_ISO_8859_15)},
590         CODESET_SEPARATOR,
591 #if HAVE_LIBJCONV
592         {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
593          CODESET_ACTION(C_ISO_8859_2)},
594         CODESET_SEPARATOR,
595         {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
596          CODESET_ACTION(C_ISO_8859_13)},
597         {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
598          CODESET_ACTION(C_ISO_8859_4)},
599         CODESET_SEPARATOR,
600         {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
601          CODESET_ACTION(C_ISO_8859_7)},
602         CODESET_SEPARATOR,
603         {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
604          CODESET_ACTION(C_ISO_8859_9)},
605         CODESET_SEPARATOR,
606         {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
607          CODESET_ACTION(C_ISO_8859_5)},
608         {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
609          CODESET_ACTION(C_KOI8_R)},
610         {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
611          CODESET_ACTION(C_WINDOWS_1251)},
612         CODESET_SEPARATOR,
613 #endif
614         {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
615          CODESET_ACTION(C_ISO_2022_JP)},
616 #if HAVE_LIBJCONV
617         {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
618          CODESET_ACTION(C_ISO_2022_JP_2)},
619 #endif
620         {N_("/_View/_Code set/Japanese (_EUC-JP)"),
621          CODESET_ACTION(C_EUC_JP)},
622         {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
623          CODESET_ACTION(C_SHIFT_JIS)},
624 #if HAVE_LIBJCONV
625         CODESET_SEPARATOR,
626         {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
627          CODESET_ACTION(C_GB2312)},
628         {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
629          CODESET_ACTION(C_BIG5)},
630         {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
631          CODESET_ACTION(C_EUC_TW)},
632         {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
633          CODESET_ACTION(C_ISO_2022_CN)},
634         CODESET_SEPARATOR,
635         {N_("/_View/_Code set/Korean (EUC-_KR)"),
636          CODESET_ACTION(C_EUC_KR)},
637         {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
638          CODESET_ACTION(C_ISO_2022_KR)},
639         CODESET_SEPARATOR,
640         {N_("/_View/_Code set/Thai (TIS-620)"),
641          CODESET_ACTION(C_TIS_620)},
642         {N_("/_View/_Code set/Thai (Windows-874)"),
643          CODESET_ACTION(C_WINDOWS_874)},
644 #endif
645
646 #undef CODESET_SEPARATOR
647 #undef CODESET_ACTION
648
649         {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
650         {N_("/_View/Open in new _window"),      "<control><alt>N", open_msg_cb, 0, NULL},
651         {N_("/_View/Mess_age source"),          "<control>U", view_source_cb, 0, NULL},
652         {N_("/_View/Show all _header"),         "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
653         {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
654         {N_("/_View/_Update"),                  "<control><alt>U", update_summary_cb,  0, NULL},
655
656         {N_("/_Message"),                       NULL, NULL, 0, "<Branch>"},
657         {N_("/_Message/Get new ma_il"),         "<control>I",   inc_mail_cb, 0, NULL},
658         {N_("/_Message/Get from _all accounts"),
659                                                 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
660         {N_("/_Message/Cancel receivin_g"),     NULL, inc_cancel_cb, 0, NULL},
661         {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
662         {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
663         {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
664         {N_("/_Message/Compose a_n email message"),     "<control>M", compose_mail_cb, 0, NULL},
665         {N_("/_Message/Compose a news message"),        NULL,   compose_news_cb, 0, NULL},
666         {N_("/_Message/_Reply"),                "<control>R",   reply_cb, COMPOSE_REPLY, NULL},
667         {N_("/_Message/Repl_y to sender"),      "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
668         {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
669         {N_("/_Message/Reply to a_ll"),         "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
670         {N_("/_Message/_Forward"),              "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
671         {N_("/_Message/Bounce"),                NULL, reply_cb, COMPOSE_BOUNCE, NULL},
672         {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
673         {N_("/_Message/Re-_edit"),              NULL, reedit_cb, 0, NULL},
674         {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
675         {N_("/_Message/M_ove..."),              "<control>O", move_to_cb, 0, NULL},
676         {N_("/_Message/_Copy..."),              "<shift><control>O", copy_to_cb, 0, NULL},
677         {N_("/_Message/_Delete"),               "<control>D", delete_cb,  0, NULL},
678         {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
679         {N_("/_Message/_Mark"),                 NULL, NULL, 0, "<Branch>"},
680         {N_("/_Message/_Mark/_Mark"),           "<shift>asterisk", mark_cb, 0, NULL},
681         {N_("/_Message/_Mark/_Unmark"),         "U", unmark_cb, 0, NULL},
682         {N_("/_Message/_Mark/---"),             NULL, NULL, 0, "<Separator>"},
683         {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
684         {N_("/_Message/_Mark/Mark as rea_d"),
685                                                 NULL, mark_as_read_cb, 0, NULL},
686         {N_("/_Message/_Mark/Mark all _read"),  NULL, mark_all_read_cb, 0, NULL},
687
688         {N_("/_Tools"),                         NULL, NULL, 0, "<Branch>"},
689         {N_("/_Tools/_Selective download..."),  "<alt>S", sel_download_cb, 0, NULL},
690         {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
691         {N_("/_Tools/_Address book..."),        "<shift><control>A", addressbook_open_cb, 0, NULL},
692         {N_("/_Tools/Add sender to address boo_k"),
693                                                 NULL, add_address_cb, 0, NULL},
694         {N_("/_Tools/_Harvest addresses"),      NULL, NULL, 0, "<Branch>"},
695         {N_("/_Tools/_Harvest addresses/from _Folder..."),
696                                                 NULL, addr_harvest_cb, 0, NULL},
697         {N_("/_Tools/_Harvest addresses/from _Messages..."),
698                                                 NULL, addr_harvest_msg_cb, 0, NULL},
699         {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
700         {N_("/_Tools/_Filter messages"),                NULL, filter_cb, 0, NULL},
701         {N_("/_Tools/_Create filter rule"),     NULL, NULL, 0, "<Branch>"},
702         {N_("/_Tools/_Create filter rule/_Automatically"),
703                                                 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
704         {N_("/_Tools/_Create filter rule/by _From"),
705                                                 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
706         {N_("/_Tools/_Create filter rule/by _To"),
707                                                 NULL, create_filter_cb, FILTER_BY_TO, NULL},
708         {N_("/_Tools/_Create filter rule/by _Subject"),
709                                                 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
710         {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
711         {N_("/_Tools/Actio_ns"),                        NULL, NULL, 0, "<Branch>"},
712         {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
713         {N_("/_Tools/E_xecute"),                        "X", execute_summary_cb, 0, NULL},
714         {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
715         {N_("/_Tools/Delete du_plicated messages"),
716                                                 NULL, delete_duplicated_cb,   0, NULL},
717         {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
718         {N_("/_Tools/_Log window"),             "<control>L", log_window_show_cb, 0, NULL},
719
720         {N_("/_Configuration"),                 NULL, NULL, 0, "<Branch>"},
721         {N_("/_Configuration/_Common preferences..."),
722                                                 NULL, prefs_common_open_cb, 0, NULL},
723         {N_("/_Configuration/_Filter setting..."),
724                                                 NULL, prefs_filter_open_cb, 0, NULL},
725         {N_("/_Configuration/_Scoring..."),
726                                                 NULL, prefs_scoring_open_cb, 0, NULL},
727         {N_("/_Configuration/_Filtering..."),
728                                                 NULL, prefs_filtering_open_cb, 0, NULL},
729         {N_("/_Configuration/_Template..."),    NULL, prefs_template_open_cb, 0, NULL},
730         {N_("/_Configuration/_Actions..."),     NULL, prefs_actions_open_cb, 0, NULL},
731         {N_("/_Configuration/---"),             NULL, NULL, 0, "<Separator>"},
732         {N_("/_Configuration/_Preferences for current account..."),
733                                                 NULL, prefs_account_open_cb, 0, NULL},
734         {N_("/_Configuration/Create _new account..."),
735                                                 NULL, new_account_cb, 0, NULL},
736         {N_("/_Configuration/_Edit accounts..."),
737                                                 NULL, account_edit_open, 0, NULL},
738         {N_("/_Configuration/C_hange current account"),
739                                                 NULL, NULL, 0, "<Branch>"},
740
741         {N_("/_Help"),                          NULL, NULL, 0, "<Branch>"},
742         {N_("/_Help/_Manual"),                  NULL, NULL, 0, "<Branch>"},
743         {N_("/_Help/_Manual/_English"),         NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
744         {N_("/_Help/_Manual/_German"),          NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
745         {N_("/_Help/_Manual/_Spanish"),         NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
746         {N_("/_Help/_Manual/_French"),          NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
747         {N_("/_Help/_Manual/_Japanese"),        NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
748         {N_("/_Help/_FAQ"),                     NULL, NULL, 0, "<Branch>"},
749         {N_("/_Help/_FAQ/_English"),            NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
750         {N_("/_Help/_FAQ/_German"),             NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
751         {N_("/_Help/_FAQ/_Spanish"),            NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
752         {N_("/_Help/_FAQ/_French"),             NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
753         {N_("/_Help/_FAQ/_Italian"),            NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
754         {N_("/_Help/---"),                      NULL, NULL, 0, "<Separator>"},
755         {N_("/_Help/_About"),                   NULL, about_show, 0, NULL}
756 };
757 static GtkItemFactoryEntry reply_popup_entries[] =
758 {
759         {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
760         {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
761 };
762 static GtkItemFactoryEntry replyall_popup_entries[] =
763 {
764         {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
765         {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
766 };
767 static GtkItemFactoryEntry replysender_popup_entries[] =
768 {
769         {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
770         {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
771 };
772 static GtkItemFactoryEntry fwd_popup_entries[] =
773 {
774         {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
775         {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
776 };
777
778 MainWindow *main_window_create(SeparateType type)
779 {
780         MainWindow *mainwin;
781         GtkWidget *window;
782         GtkWidget *vbox;
783         GtkWidget *menubar;
784         GtkWidget *handlebox;
785         GtkWidget *vbox_body;
786         GtkWidget *hbox_stat;
787         GtkWidget *statusbar;
788         GtkWidget *progressbar;
789         GtkWidget *statuslabel;
790         GtkWidget *ac_button;
791         GtkWidget *ac_label;
792         GtkWidget *online_status;
793         GtkWidget *offline_status;
794         GtkWidget *online_switch;
795         GtkWidget *offline_switch;
796
797         FolderView *folderview;
798         SummaryView *summaryview;
799         MessageView *messageview;
800         GdkColormap *colormap;
801         GdkColor color[4];
802         gboolean success[4];
803         guint n_menu_entries;
804         GtkItemFactory *ifactory;
805         GtkWidget *ac_menu;
806         GtkWidget *menuitem;
807         GtkWidget *compose_popup;
808         GtkWidget *reply_popup;
809         GtkWidget *replyall_popup;
810         GtkWidget *replysender_popup;
811         GtkWidget *fwd_popup;
812         gint i;
813
814         static GdkGeometry geometry;
815
816         debug_print(_("Creating main window...\n"));
817         mainwin = g_new0(MainWindow, 1);
818
819         /* main window */
820         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
821         gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
822         gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
823         gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
824
825         if (!geometry.min_height) {
826                 geometry.min_width = 320;
827                 geometry.min_height = 200;
828         }
829         gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
830                                       GDK_HINT_MIN_SIZE);
831
832         gtk_signal_connect(GTK_OBJECT(window), "delete_event",
833                            GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
834         MANAGE_WINDOW_SIGNALS_CONNECT(window);
835         gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
836                                 GTK_SIGNAL_FUNC(key_pressed), mainwin);
837
838         gtk_widget_realize(window);
839         gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
840         
841
842         gtkut_widget_set_app_icon(window);
843
844         vbox = gtk_vbox_new(FALSE, 0);
845         gtk_widget_show(vbox);
846         gtk_container_add(GTK_CONTAINER(window), vbox);
847
848         /* menu bar */
849         n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
850         menubar = menubar_create(window, mainwin_entries, 
851                                  n_menu_entries, "<Main>", mainwin);
852         gtk_widget_show(menubar);
853         gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
854
855         handlebox = gtk_handle_box_new();
856         gtk_widget_show(handlebox);
857         gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
858
859         /* create the popup menus for the reply buttons specials */
860         n_menu_entries = sizeof(reply_popup_entries) /
861                         sizeof(reply_popup_entries[0]);
862         reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
863                                       "<ReplyPopup>", mainwin);
864         gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
865                            GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
866         n_menu_entries = sizeof(replyall_popup_entries) /
867                         sizeof(replyall_popup_entries[0]);
868         replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
869                                       "<ReplyAllPopup>", mainwin);
870         gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
871                            GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
872         n_menu_entries = sizeof(replysender_popup_entries) /
873                         sizeof(replysender_popup_entries[0]);
874         replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
875                                       "<ReplySenderPopup>", mainwin);
876         gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
877                            GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
878         /* create the popup menu for the forward button */
879         n_menu_entries = sizeof(fwd_popup_entries) /
880                         sizeof(fwd_popup_entries[0]);
881         fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
882                                       "<ForwardPopup>", mainwin);
883         gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
884                            GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
885                            
886         main_window_toolbar_create(mainwin, handlebox);
887
888         /* vbox that contains body */
889         vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
890         gtk_widget_show(vbox_body);
891         gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
892         gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
893
894         hbox_stat = gtk_hbox_new(FALSE, 2);
895         gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
896
897         statusbar = statusbar_create();
898         gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
899
900         progressbar = gtk_progress_bar_new();
901         gtk_widget_set_usize(progressbar, 120, 1);
902         gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
903
904         online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
905         offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
906         online_switch = gtk_button_new ();
907         offline_switch = gtk_button_new ();
908         gtk_container_add (GTK_CONTAINER(online_switch), online_status);
909         gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
910         gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
911         gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
912         gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
913         gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
914         gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
915         gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
916         
917         statuslabel = gtk_label_new("");
918         gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
919
920         ac_button = gtk_button_new();
921         gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
922         GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
923         gtk_widget_set_usize(ac_button, -1, 1);
924         gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
925         gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
926                            GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
927
928         ac_label = gtk_label_new("");
929         gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
930
931         gtk_widget_show_all(hbox_stat);
932
933         gtk_widget_hide(offline_switch);
934         /* create views */
935         mainwin->folderview  = folderview  = folderview_create();
936         mainwin->summaryview = summaryview = summary_create();
937         mainwin->messageview = messageview = messageview_create();
938         mainwin->logwin      = log_window_create();
939
940         folderview->mainwin      = mainwin;
941         folderview->summaryview  = summaryview;
942
943         summaryview->mainwin     = mainwin;
944         summaryview->folderview  = folderview;
945         summaryview->messageview = messageview;
946         summaryview->window      = window;
947
948         messageview->mainwin     = mainwin;
949
950         mainwin->window      = window;
951         mainwin->vbox        = vbox;
952         mainwin->menubar     = menubar;
953         mainwin->handlebox   = handlebox;
954         mainwin->vbox_body   = vbox_body;
955         mainwin->hbox_stat   = hbox_stat;
956         mainwin->statusbar   = statusbar;
957         mainwin->progressbar = progressbar;
958         mainwin->statuslabel = statuslabel;
959         mainwin->ac_button   = ac_button;
960         mainwin->ac_label    = ac_label;
961         mainwin->reply_popup = reply_popup;
962         mainwin->replyall_popup = replyall_popup;
963         mainwin->replysender_popup = replysender_popup;
964         mainwin->fwd_popup = fwd_popup;
965         mainwin->online_switch = online_switch;
966         mainwin->offline_switch = offline_switch;
967         
968         /* set context IDs for status bar */
969         mainwin->mainwin_cid = gtk_statusbar_get_context_id
970                 (GTK_STATUSBAR(statusbar), "Main Window");
971         mainwin->folderview_cid = gtk_statusbar_get_context_id
972                 (GTK_STATUSBAR(statusbar), "Folder View");
973         mainwin->summaryview_cid = gtk_statusbar_get_context_id
974                 (GTK_STATUSBAR(statusbar), "Summary View");
975
976         /* allocate colors for summary view and folder view */
977         summaryview->color_marked.red = summaryview->color_marked.green = 0;
978         summaryview->color_marked.blue = (guint16)65535;
979
980         summaryview->color_dim.red = summaryview->color_dim.green =
981                 summaryview->color_dim.blue = COLOR_DIM;
982
983         folderview->color_new.red = (guint16)55000;
984         folderview->color_new.green = folderview->color_new.blue = 15000;
985
986         gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
987                                        &folderview->color_op);
988
989         summaryview->color_important.red = 0;
990         summaryview->color_important.green = 0;
991         summaryview->color_important.blue = (guint16)65535;
992
993         color[0] = summaryview->color_marked;
994         color[1] = summaryview->color_dim;
995         color[2] = folderview->color_new;
996         color[3] = folderview->color_op;
997
998         colormap = gdk_window_get_colormap(window->window);
999         gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1000         for (i = 0; i < 4; i++) {
1001                 if (success[i] == FALSE)
1002                         g_warning(_("MainWindow: color allocation %d failed\n"), i);
1003         }
1004
1005         debug_print(_("done.\n"));
1006
1007         main_window_set_widgets(mainwin, type);
1008
1009         /* set menu items */
1010         ifactory = gtk_item_factory_from_widget(menubar);
1011         menuitem = gtk_item_factory_get_item
1012                 (ifactory, "/View/Code set/Auto detect");
1013         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1014
1015         switch (prefs_common.toolbar_style) {
1016         case TOOLBAR_NONE:
1017                 menuitem = gtk_item_factory_get_item
1018                         (ifactory, "/View/Show or hide/Toolbar/None");
1019                 break;
1020         case TOOLBAR_ICON:
1021                 menuitem = gtk_item_factory_get_item
1022                         (ifactory, "/View/Show or hide/Toolbar/Icon");
1023                 break;
1024         case TOOLBAR_TEXT:
1025                 menuitem = gtk_item_factory_get_item
1026                         (ifactory, "/View/Show or hide/Toolbar/Text");
1027                 break;
1028         case TOOLBAR_BOTH:
1029                 menuitem = gtk_item_factory_get_item
1030                         (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1031         }
1032         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1033
1034         gtk_widget_hide(mainwin->hbox_stat);
1035         menuitem = gtk_item_factory_get_item
1036                 (ifactory, "/View/Show or hide/Status bar");
1037         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1038                                        prefs_common.show_statusbar);
1039 #if 0 /* FIXED SEPARATE WINDOWS */
1040         /* Message view and Folder tree are always shown at startup
1041          * make that in the menu visible */
1042         menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Message View");
1043         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1044         menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Folder Tree");
1045         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1046 #endif  
1047         /* set the check of the SEPARATE_xxx menu items. we also need the main window
1048          * as a property and pass the action type to the callback */
1049         menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
1050         g_assert(menuitem);
1051         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
1052         gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1053         gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb), 
1054                                            GUINT_TO_POINTER(SEPARATE_FOLDER));
1055
1056         menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
1057         g_assert(menuitem);
1058         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
1059         gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1060         gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb), 
1061                                            GUINT_TO_POINTER(SEPARATE_MESSAGE));
1062         
1063         menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
1064         gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
1065                                                 mainwin);
1066
1067         /* set account selection menu */
1068         ac_menu = gtk_item_factory_get_widget
1069                 (ifactory, "/Configuration/Change current account");
1070         gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1071                            GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1072         mainwin->ac_menu = ac_menu;
1073
1074         main_window_set_toolbar_sensitive(mainwin);
1075
1076         /* Create actions menu */
1077         update_mainwin_actions_menu(ifactory, mainwin);
1078
1079         /* show main window */
1080         gtk_widget_set_uposition(mainwin->window,
1081                                  prefs_common.mainwin_x,
1082                                  prefs_common.mainwin_y);
1083         gtk_widget_set_usize(window, prefs_common.mainwin_width,
1084                              prefs_common.mainwin_height);
1085         gtk_widget_show(mainwin->window);
1086
1087         /* initialize views */
1088         folderview_init(folderview);
1089         summary_init(summaryview);
1090         messageview_init(messageview);
1091         log_window_init(mainwin->logwin);
1092
1093         mainwin->lock_count = 0;
1094         mainwin->menu_lock_count = 0;
1095         mainwin->cursor_count = 0;
1096
1097         if (!watch_cursor)
1098                 watch_cursor = gdk_cursor_new(GDK_WATCH);
1099
1100         mainwin_list = g_list_append(mainwin_list, mainwin);
1101
1102         /* init work_offline */
1103         if (prefs_common.work_offline)
1104                 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1105
1106         return mainwin;
1107 }
1108
1109 void main_window_cursor_wait(MainWindow *mainwin)
1110 {
1111
1112         if (mainwin->cursor_count == 0)
1113                 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1114
1115         mainwin->cursor_count++;
1116
1117         gdk_flush();
1118 }
1119
1120 void main_window_cursor_normal(MainWindow *mainwin)
1121 {
1122         if (mainwin->cursor_count)
1123                 mainwin->cursor_count--;
1124
1125         if (mainwin->cursor_count == 0)
1126                 gdk_window_set_cursor(mainwin->window->window, NULL);
1127
1128         gdk_flush();
1129 }
1130
1131 /* lock / unlock the user-interface */
1132 void main_window_lock(MainWindow *mainwin)
1133 {
1134         if (mainwin->lock_count == 0)
1135                 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1136
1137         mainwin->lock_count++;
1138
1139         main_window_set_menu_sensitive(mainwin);
1140         main_window_set_toolbar_sensitive(mainwin);
1141 }
1142
1143 void main_window_unlock(MainWindow *mainwin)
1144 {
1145         if (mainwin->lock_count)
1146                 mainwin->lock_count--;
1147
1148         main_window_set_menu_sensitive(mainwin);
1149         main_window_set_toolbar_sensitive(mainwin);
1150
1151         if (mainwin->lock_count == 0)
1152                 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1153 }
1154
1155 static void main_window_menu_callback_block(MainWindow *mainwin)
1156 {
1157         mainwin->menu_lock_count++;
1158 }
1159
1160 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1161 {
1162         if (mainwin->menu_lock_count)
1163                 mainwin->menu_lock_count--;
1164 }
1165
1166 void main_window_reflect_prefs_all(void)
1167 {
1168         main_window_reflect_prefs_all_real(FALSE);
1169 }
1170
1171 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1172 {
1173         GList *cur;
1174         MainWindow *mainwin;
1175
1176         for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1177                 mainwin = (MainWindow *)cur->data;
1178
1179                 main_window_show_cur_account(mainwin);
1180                 main_window_set_menu_sensitive(mainwin);
1181                 main_window_set_toolbar_sensitive(mainwin);
1182
1183                 /* pixmap themes */
1184                 if (pixmap_theme_changed)
1185                 {
1186                         gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1187                         mainwin->toolbar = NULL;
1188                         main_window_toolbar_create(mainwin, mainwin->handlebox);
1189                         set_toolbar_style(mainwin);
1190                         activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1191                         folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1192                         summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1193                 }
1194                 
1195                 summary_redisplay_msg(mainwin->summaryview);
1196                 headerview_set_visibility(mainwin->messageview->headerview,
1197                                           prefs_common.display_header_pane);
1198         }
1199 }
1200
1201 void main_window_set_summary_column(void)
1202 {
1203         GList *cur;
1204         MainWindow *mainwin;
1205
1206         for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1207                 mainwin = (MainWindow *)cur->data;
1208                 summary_set_column_order(mainwin->summaryview);
1209         }
1210 }
1211
1212 void main_window_set_account_menu(GList *account_list)
1213 {
1214         GList *cur, *cur_ac, *cur_item;
1215         GtkWidget *menuitem;
1216         MainWindow *mainwin;
1217         PrefsAccount *ac_prefs;
1218
1219         for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1220                 mainwin = (MainWindow *)cur->data;
1221
1222                 /* destroy all previous menu item */
1223                 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1224                 while (cur_item != NULL) {
1225                         GList *next = cur_item->next;
1226                         gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1227                         cur_item = next;
1228                 }
1229
1230                 for (cur_ac = account_list; cur_ac != NULL;
1231                      cur_ac = cur_ac->next) {
1232                         ac_prefs = (PrefsAccount *)cur_ac->data;
1233
1234                         menuitem = gtk_menu_item_new_with_label
1235                                 (ac_prefs->account_name
1236                                  ? ac_prefs->account_name : _("Untitled"));
1237                         gtk_widget_show(menuitem);
1238                         gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1239                         gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1240                                            GTK_SIGNAL_FUNC(account_menu_cb),
1241                                            ac_prefs);
1242                 }
1243         }
1244 }
1245
1246 static void main_window_show_cur_account(MainWindow *mainwin)
1247 {
1248         gchar *buf;
1249         gchar *ac_name;
1250
1251         ac_name = g_strdup(cur_account
1252                            ? (cur_account->account_name
1253                               ? cur_account->account_name : _("Untitled"))
1254                            : _("none"));
1255
1256         if (cur_account)
1257                 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1258         else
1259                 buf = g_strdup(PROG_VERSION);
1260         gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1261         g_free(buf);
1262
1263         gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1264         gtk_widget_queue_resize(mainwin->ac_button);
1265
1266         g_free(ac_name);
1267 }
1268
1269 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1270 {
1271         GtkWidget *folder_wid  = GTK_WIDGET_PTR(mainwin->folderview);
1272         GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1273         GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1274
1275         if (mainwin->type == type) return;
1276
1277         /* remove widgets from those containers */
1278         gtk_widget_ref(folder_wid);
1279         gtk_widget_ref(summary_wid);
1280         gtk_widget_ref(message_wid);
1281         gtkut_container_remove
1282                 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1283         gtkut_container_remove
1284                 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1285         gtkut_container_remove
1286                 (GTK_CONTAINER(message_wid->parent), message_wid);
1287
1288         /* clean containers */
1289         switch (mainwin->type) {
1290         case SEPARATE_NONE:
1291                 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1292                 break;
1293         case SEPARATE_FOLDER:
1294                 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1295                 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1296                 break;
1297         case SEPARATE_MESSAGE:
1298                 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1299                 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1300                 break;
1301         case SEPARATE_BOTH:
1302                 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1303                 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1304                 break;
1305         }
1306
1307         gtk_widget_hide(mainwin->window);
1308         main_window_set_widgets(mainwin, type);
1309         gtk_widget_show(mainwin->window);
1310
1311         gtk_widget_unref(folder_wid);
1312         gtk_widget_unref(summary_wid);
1313         gtk_widget_unref(message_wid);
1314 }
1315
1316 void main_window_get_size(MainWindow *mainwin)
1317 {
1318         GtkAllocation *allocation;
1319
1320         allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1321
1322         prefs_common.summaryview_width  = allocation->width;
1323
1324         if (mainwin->summaryview->msg_is_toggled_on)
1325                 prefs_common.summaryview_height = allocation->height;
1326
1327         prefs_common.mainview_width     = allocation->width;
1328
1329         allocation = &mainwin->window->allocation;
1330
1331         prefs_common.mainview_height = allocation->height;
1332         prefs_common.mainwin_width   = allocation->width;
1333         prefs_common.mainwin_height  = allocation->height;
1334
1335         allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1336
1337         prefs_common.folderview_width  = allocation->width;
1338         prefs_common.folderview_height = allocation->height;
1339 }
1340
1341 void main_window_get_position(MainWindow *mainwin)
1342 {
1343         gint x, y;
1344
1345         gtkut_widget_get_uposition(mainwin->window, &x, &y);
1346
1347         prefs_common.mainview_x = x;
1348         prefs_common.mainview_y = y;
1349         prefs_common.mainwin_x = x;
1350         prefs_common.mainwin_y = y;
1351
1352         debug_print(_("window position: x = %d, y = %d\n"), x, y);
1353 }
1354
1355 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1356 {
1357         GList *list;
1358         guint has_trash;
1359         Folder *folder;
1360
1361         for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1362                 folder = FOLDER(list->data);
1363                 if (folder && folder->trash && folder->trash->total > 0)
1364                         has_trash++;
1365         }
1366
1367         if (!has_trash) return;
1368         
1369         if (confirm) {
1370                 if (alertpanel(_("Empty trash"),
1371                                _("Empty all messages in trash?"),
1372                                _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1373                         return;
1374                 manage_window_focus_in(mainwin->window, NULL, NULL);
1375         }
1376
1377         procmsg_empty_trash();
1378
1379         for (list = folder_get_list(); list != NULL; list = list->next) {
1380                 folder = list->data;
1381                 if (folder && folder->trash && folder->trash->total != 0) {
1382                         folder_item_scan(folder->trash);
1383                         folderview_update_item(folder->trash, TRUE);
1384                 }
1385         }
1386
1387         if (mainwin->summaryview->folder_item &&
1388             mainwin->summaryview->folder_item->stype == F_TRASH)
1389                 gtk_widget_grab_focus(mainwin->folderview->ctree);
1390 }
1391
1392 void main_window_add_mailbox(MainWindow *mainwin)
1393 {
1394         gchar *path;
1395         Folder *folder;
1396
1397         path = input_dialog(_("Add mailbox"),
1398                             _("Input the location of mailbox.\n"
1399                               "If the existing mailbox is specified, it will be\n"
1400                               "scanned automatically."),
1401                             "Mail");
1402         if (!path) return;
1403         if (folder_find_from_path(path)) {
1404                 alertpanel_error(_("The mailbox `%s' already exists."), path);
1405                 g_free(path);
1406                 return;
1407         }
1408         if (!strcmp(path, "Mail"))
1409                 folder = folder_new(F_MH, _("Mailbox"), path);
1410         else
1411                 folder = folder_new(F_MH, g_basename(path), path);
1412         g_free(path);
1413
1414         if (folder->create_tree(folder) < 0) {
1415                 alertpanel_error(_("Creation of the mailbox failed.\n"
1416                                    "Maybe some files already exist, or you don't have the permission to write there."));
1417                 folder_destroy(folder);
1418                 return;
1419         }
1420
1421         folder_add(folder);
1422         folder_set_ui_func(folder, scan_tree_func, mainwin);
1423         folder->scan_tree(folder);
1424         folder_set_ui_func(folder, NULL, NULL);
1425
1426         folderview_set(mainwin->folderview);
1427 }
1428
1429 void main_window_add_mbox(MainWindow *mainwin)
1430 {
1431         gchar *path;
1432         Folder *folder;
1433         FolderItem * item;
1434
1435         path = input_dialog(_("Add mbox mailbox"),
1436                             _("Input the location of mailbox."),
1437                             "mail");
1438
1439         if (!path) return;
1440
1441         if (folder_find_from_path(path)) {
1442                 alertpanel_error(_("The mailbox `%s' already exists."), path);
1443                 g_free(path);
1444                 return;
1445         }
1446
1447         /*
1448         if (!strcmp(path, "Mail"))
1449                 folder = folder_new(F_MBOX, _("Mailbox"), path);
1450                 else
1451         */
1452
1453         folder = folder_new(F_MBOX, g_basename(path), path);
1454         g_free(path);
1455
1456         if (folder->create_tree(folder) < 0) {
1457                 alertpanel_error(_("Creation of the mailbox failed."));
1458                 folder_destroy(folder);
1459                 return;
1460         }
1461
1462         folder_add(folder);
1463
1464         item = folder_item_new(folder->name, NULL);
1465         item->folder = folder;
1466         folder->node = g_node_new(item);
1467
1468         folder->create_folder(folder, item, "inbox");
1469         folder->create_folder(folder, item, "outbox");
1470         folder->create_folder(folder, item, "queue");
1471         folder->create_folder(folder, item, "draft");
1472         folder->create_folder(folder, item, "trash");
1473
1474         folderview_set(mainwin->folderview);
1475 }
1476
1477 typedef enum
1478 {
1479         M_UNLOCKED            = 1 << 0,
1480         M_MSG_EXIST           = 1 << 1,
1481         M_TARGET_EXIST        = 1 << 2,
1482         M_SINGLE_TARGET_EXIST = 1 << 3,
1483         M_EXEC                = 1 << 4,
1484         M_ALLOW_REEDIT        = 1 << 5,
1485         M_HAVE_ACCOUNT        = 1 << 6,
1486         M_THREADED            = 1 << 7,
1487         M_UNTHREADED          = 1 << 8,
1488         M_ALLOW_DELETE        = 1 << 9,
1489         M_INC_ACTIVE          = 1 << 10,
1490         M_NEWS                = 1 << 11,
1491         M_HAVE_NEWS_ACCOUNT   = 1 << 12,
1492         M_HIDE_READ_MSG       = 1 << 13
1493 } SensitiveCond;
1494
1495 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1496 {
1497         SensitiveCond state = 0;
1498         SummarySelection selection;
1499         FolderItem *item = mainwin->summaryview->folder_item;
1500         GList *account_list = account_get_list();
1501         
1502         selection = summary_get_selection_type(mainwin->summaryview);
1503
1504         if (mainwin->lock_count == 0)
1505                 state |= M_UNLOCKED;
1506         if (selection != SUMMARY_NONE)
1507                 state |= M_MSG_EXIST;
1508         if (item) {
1509                 state |= M_EXEC;
1510                 if (item->threaded)
1511                         state |= M_THREADED;
1512                 else
1513                         state |= M_UNTHREADED;  
1514                 /*              if (item->folder->type != F_NEWS) */
1515                 state |= M_ALLOW_DELETE;
1516
1517                 if (selection == SUMMARY_NONE && item->hide_read_msgs
1518                     || selection != SUMMARY_NONE)
1519                         state |= M_HIDE_READ_MSG;       
1520         }               
1521         if (selection == SUMMARY_SELECTED_SINGLE ||
1522             selection == SUMMARY_SELECTED_MULTIPLE)
1523                 state |= M_TARGET_EXIST;
1524         if (selection == SUMMARY_SELECTED_SINGLE)
1525                 state |= M_SINGLE_TARGET_EXIST;
1526         if (mainwin->summaryview->folder_item &&
1527             mainwin->summaryview->folder_item->folder->type == F_NEWS)
1528                 state |= M_NEWS;
1529         if (selection == SUMMARY_SELECTED_SINGLE &&
1530             (item &&
1531              (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1532               item->stype == F_QUEUE)))
1533                 state |= M_ALLOW_REEDIT;
1534         if (cur_account)
1535                 state |= M_HAVE_ACCOUNT;
1536         
1537         for ( ; account_list != NULL; account_list = account_list->next) {
1538                 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1539                         state |= M_HAVE_NEWS_ACCOUNT;
1540                         break;
1541                 }
1542         }
1543
1544         if (inc_is_active())
1545                 state |= M_INC_ACTIVE;
1546
1547         return state;
1548 }
1549
1550 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1551 {
1552         SensitiveCond state;
1553         gboolean sensitive;
1554         gint i = 0;
1555
1556         struct {
1557                 GtkWidget *widget;
1558                 SensitiveCond cond;
1559         } entry[11];
1560
1561 #define SET_WIDGET_COND(w, c)   \
1562 {                               \
1563         entry[i].widget = w;    \
1564         entry[i].cond = c;      \
1565         i++;                    \
1566 }
1567
1568         SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1569         SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1570         SET_WIDGET_COND(mainwin->compose_news_btn, M_HAVE_ACCOUNT);
1571         SET_WIDGET_COND(mainwin->reply_btn,
1572                         M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1573         SET_WIDGET_COND(mainwin->replyall_btn,
1574                         M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1575         SET_WIDGET_COND(mainwin->replysender_btn,
1576                         M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1577         SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1578 #if 0
1579         SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1580         SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1581 #endif
1582         SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1583         SET_WIDGET_COND(mainwin->delete_btn,
1584                         M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
1585         SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC|M_UNLOCKED);
1586         SET_WIDGET_COND(NULL, 0);
1587
1588 #undef SET_WIDGET_COND
1589
1590         state = main_window_get_current_state(mainwin);
1591
1592         for (i = 0; entry[i].widget != NULL; i++) {
1593                 sensitive = ((entry[i].cond & state) == entry[i].cond);
1594                 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1595         }
1596
1597         activate_compose_button(mainwin, 
1598                         prefs_common.toolbar_style,
1599                         mainwin->compose_btn_type);
1600 }
1601
1602 void main_window_set_menu_sensitive(MainWindow *mainwin)
1603 {
1604         GtkItemFactory *ifactory;
1605         SensitiveCond state;
1606         gboolean sensitive;
1607         GtkWidget *menuitem;
1608         gint i;
1609
1610         static const struct {
1611                 gchar *const entry;
1612                 SensitiveCond cond;
1613         } entry[] = {
1614                 {"/File/Add mailbox..."        , M_UNLOCKED},
1615                 {"/File/Add mbox mailbox..."   , M_UNLOCKED},
1616                 {"/File/Rescan folder tree"    , M_UNLOCKED},
1617                 {"/File/Folder"                , M_UNLOCKED},
1618                 {"/File/Import mbox file..."   , M_UNLOCKED},
1619                 {"/File/Export to mbox file...", M_UNLOCKED},
1620                 {"/File/Empty trash"           , M_UNLOCKED},
1621                 {"/File/Work offline"          , M_UNLOCKED},
1622                 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1623                 {"/File/Print..."  , M_TARGET_EXIST|M_UNLOCKED},
1624                 /* {"/File/Close", M_UNLOCKED}, */
1625                 {"/File/Exit" , M_UNLOCKED},
1626
1627                 {"/Edit/Select thread"             , M_SINGLE_TARGET_EXIST},
1628                 {"/View/Sort"                      , M_MSG_EXIST},
1629                 {"/View/Thread view"               , M_EXEC},
1630                 {"/View/Hide read messages"        , M_HIDE_READ_MSG},
1631                 {"/View/Go to/Prev message"        , M_MSG_EXIST},
1632                 {"/View/Go to/Next message"        , M_MSG_EXIST},
1633                 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1634                 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1635                 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1636                 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1637                 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1638                 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1639                 {"/View/Open in new window"        , M_SINGLE_TARGET_EXIST},
1640                 {"/View/Show all header"           , M_SINGLE_TARGET_EXIST},
1641                 {"/View/Message source"            , M_SINGLE_TARGET_EXIST},
1642
1643                 {"/Message/Get new mail"          , M_HAVE_ACCOUNT|M_UNLOCKED},
1644                 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1645                 {"/Message/Cancel receiving"      , M_INC_ACTIVE},
1646                 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1647                 {"/Message/Reply"                 , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1648                 {"/Message/Reply to sender"       , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1649                 {"/Message/Reply to all"          , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1650                 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1651                 {"/Message/Forward"               , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1652                 {"/Message/Bounce"                , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1653                 {"/Message/Re-edit"               , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1654                 {"/Message/Move..."               , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1655                 {"/Message/Copy..."               , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1656                 {"/Message/Delete"                , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1657                 {"/Message/Mark"                  , M_TARGET_EXIST},
1658
1659                 {"/Tools/Selective download..."     , M_HAVE_ACCOUNT|M_UNLOCKED},
1660                 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1661                 {"/Tools/Harvest addresses"         , M_UNLOCKED},
1662                 {"/Tools/Filter messages"           , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1663                 {"/Tools/Create filter rule"        , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1664                 {"/Tools/Execute"                   , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1665                 {"/Tools/Actions"                   , M_MSG_EXIST},
1666                 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1667
1668                 {"/Configuration", M_UNLOCKED},
1669
1670                 {NULL, 0}
1671         };
1672
1673         ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1674         state = main_window_get_current_state(mainwin);
1675
1676         for (i = 0; entry[i].entry != NULL; i++) {
1677                 sensitive = ((entry[i].cond & state) == entry[i].cond);
1678                 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1679         }
1680
1681         main_window_menu_callback_block(mainwin);
1682         menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1683         gtk_check_menu_item_set_active
1684                 (GTK_CHECK_MENU_ITEM(menuitem),
1685                  mainwin->messageview->textview->show_all_headers);
1686         menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1687         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1688                                        (state & M_THREADED) != 0);
1689         main_window_menu_callback_unblock(mainwin);
1690 }
1691
1692 void main_window_popup(MainWindow *mainwin)
1693 {
1694         gint x, y;
1695         gint sx, sy;
1696         GtkWidget *widget;
1697
1698         gdk_window_get_origin(mainwin->window->window, &x, &y);
1699         sx = gdk_screen_width();
1700         sy = gdk_screen_height();
1701         x %= sx; if (x < 0) x = 0;
1702         y %= sy; if (y < 0) y = 0;
1703         gdk_window_move(mainwin->window->window, x, y);
1704         gdk_window_raise(mainwin->window->window);
1705         gdk_window_show(mainwin->window->window);
1706
1707         debug_print("window position: x = %d, y = %d\n", x, y);
1708
1709         switch (mainwin->type) {
1710         case SEPARATE_FOLDER:
1711                 widget = mainwin->win.sep_folder.folderwin;
1712                 gdk_window_get_origin(widget->window, &x, &y);
1713                 x %= sx; if (x < 0) x = 0;
1714                 y %= sy; if (y < 0) y = 0;
1715                 gdk_window_move(widget->window, x, y);
1716                 gdk_window_raise(widget->window);
1717                 break;
1718         case SEPARATE_MESSAGE:
1719                 widget = mainwin->win.sep_message.messagewin;
1720                 gdk_window_get_origin(widget->window, &x, &y);
1721                 x %= sx; if (x < 0) x = 0;
1722                 y %= sy; if (y < 0) y = 0;
1723                 gdk_window_move(widget->window, x, y);
1724                 gdk_window_raise(widget->window);
1725                 break;
1726         case SEPARATE_BOTH:
1727                 widget = mainwin->win.sep_both.folderwin;
1728                 gdk_window_get_origin(widget->window, &x, &y);
1729                 x %= sx; if (x < 0) x = 0;
1730                 y %= sy; if (y < 0) y = 0;
1731                 gdk_window_move(widget->window, x, y);
1732                 gdk_window_raise(widget->window);
1733                 widget = mainwin->win.sep_both.messagewin;
1734                 gdk_window_get_origin(widget->window, &x, &y);
1735                 x %= sx; if (x < 0) x = 0;
1736                 y %= sy; if (y < 0) y = 0;
1737                 gdk_window_move(widget->window, x, y);
1738                 gdk_window_raise(widget->window);
1739                 break;
1740         default:
1741                 break;
1742         }
1743 }
1744
1745 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1746 {
1747         GtkWidget *folderwin = NULL;
1748         GtkWidget *messagewin = NULL;
1749         GtkWidget *hpaned;
1750         GtkWidget *vpaned;
1751         GtkWidget *vbox_body = mainwin->vbox_body;
1752         GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1753         GtkWidget *menuitem;
1754
1755         debug_print(_("Setting widgets..."));
1756
1757         /* create separated window(s) if needed */
1758         if (type & SEPARATE_FOLDER) {
1759                 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1760                 gtk_window_set_title(GTK_WINDOW(folderwin),
1761                                      _("Sylpheed - Folder View"));
1762                 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1763                                        "folder_view", "Sylpheed");
1764                 gtk_window_set_policy(GTK_WINDOW(folderwin),
1765                                       TRUE, TRUE, FALSE);
1766                 gtk_widget_set_usize(folderwin, -1,
1767                                      prefs_common.mainview_height);
1768                 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1769                                                BORDER_WIDTH);
1770                 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1771                                    GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1772                                    NULL);
1773         }
1774         if (type & SEPARATE_MESSAGE) {
1775                 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1776                 gtk_window_set_title(GTK_WINDOW(messagewin),
1777                                      _("Sylpheed - Message View"));
1778                 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1779                                        "message_view", "Sylpheed");
1780                 gtk_window_set_policy(GTK_WINDOW(messagewin),
1781                                       TRUE, TRUE, FALSE);
1782                 gtk_widget_set_usize
1783                         (messagewin, prefs_common.mainview_width,
1784                          prefs_common.mainview_height
1785                          - prefs_common.summaryview_height
1786                          + DEFAULT_HEADERVIEW_HEIGHT);
1787                 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1788                                                BORDER_WIDTH);
1789                 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1790                                    GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1791                                    NULL);
1792         }
1793
1794         switch (type) {
1795         case SEPARATE_NONE:
1796                 hpaned = gtk_hpaned_new();
1797                 gtk_widget_show(hpaned);
1798                 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1799                 gtk_paned_add1(GTK_PANED(hpaned),
1800                                GTK_WIDGET_PTR(mainwin->folderview));
1801
1802                 vpaned = gtk_vpaned_new();
1803                 if (mainwin->summaryview->msg_is_toggled_on) {
1804                         gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1805                         gtk_paned_add1(GTK_PANED(vpaned),
1806                                        GTK_WIDGET_PTR(mainwin->summaryview));
1807                 } else {
1808                         gtk_paned_add2(GTK_PANED(hpaned),
1809                                        GTK_WIDGET_PTR(mainwin->summaryview));
1810                         gtk_widget_ref(vpaned);
1811                 }
1812                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1813                                      prefs_common.summaryview_width,
1814                                      prefs_common.summaryview_height);
1815                 gtk_paned_add2(GTK_PANED(vpaned),
1816                                GTK_WIDGET_PTR(mainwin->messageview));
1817                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1818                                      prefs_common.mainview_width, -1);
1819                 gtk_widget_set_usize(mainwin->window,
1820                                      prefs_common.folderview_width +
1821                                      prefs_common.mainview_width,
1822                                      prefs_common.mainwin_height);
1823                 gtk_widget_show_all(vpaned);
1824
1825                 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1826                 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1827                 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1828                 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1829                 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1830                 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1831                 
1832                 mainwin->win.sep_none.hpaned = hpaned;
1833                 mainwin->win.sep_none.vpaned = vpaned;
1834                 break;
1835         case SEPARATE_FOLDER:
1836                 vpaned = gtk_vpaned_new();
1837                 if (mainwin->summaryview->msg_is_toggled_on) {
1838                         gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1839                                            TRUE, TRUE, 0);
1840                         gtk_paned_add1(GTK_PANED(vpaned),
1841                                        GTK_WIDGET_PTR(mainwin->summaryview));
1842                 } else {
1843                         gtk_box_pack_start(GTK_BOX(vbox_body),
1844                                            GTK_WIDGET_PTR(mainwin->summaryview),
1845                                            TRUE, TRUE, 0);
1846                         gtk_widget_ref(vpaned);
1847                 }
1848                 gtk_paned_add2(GTK_PANED(vpaned),
1849                                GTK_WIDGET_PTR(mainwin->messageview));
1850                 gtk_widget_show_all(vpaned);
1851                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1852                                      prefs_common.summaryview_width,
1853                                      prefs_common.summaryview_height);
1854                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1855                                      prefs_common.mainview_width, -1);
1856                 gtk_widget_set_usize(mainwin->window,
1857                                      prefs_common.mainview_width,
1858                                      prefs_common.mainview_height);
1859
1860                 gtk_container_add(GTK_CONTAINER(folderwin),
1861                                   GTK_WIDGET_PTR(mainwin->folderview));
1862
1863                 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1864                 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1865                 
1866                 mainwin->win.sep_folder.folderwin = folderwin;
1867                 mainwin->win.sep_folder.vpaned    = vpaned;
1868
1869                 gtk_widget_show_all(folderwin);
1870                 break;
1871         case SEPARATE_MESSAGE:
1872                 hpaned = gtk_hpaned_new();
1873                 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1874
1875                 gtk_paned_add1(GTK_PANED(hpaned),
1876                                GTK_WIDGET_PTR(mainwin->folderview));
1877                 gtk_paned_add2(GTK_PANED(hpaned),
1878                                GTK_WIDGET_PTR(mainwin->summaryview));
1879                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1880                                      prefs_common.summaryview_width,
1881                                      prefs_common.summaryview_height);
1882                 gtk_widget_set_usize(mainwin->window,
1883                                      prefs_common.folderview_width +
1884                                      prefs_common.mainview_width,
1885                                      prefs_common.mainwin_height);
1886                 gtk_widget_show_all(hpaned);
1887                 gtk_container_add(GTK_CONTAINER(messagewin),
1888                                   GTK_WIDGET_PTR(mainwin->messageview));
1889         
1890                 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1891                 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1892                 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1893                 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1894                 
1895                 mainwin->win.sep_message.messagewin = messagewin;
1896                 mainwin->win.sep_message.hpaned     = hpaned;
1897
1898                 gtk_widget_show_all(messagewin);
1899                 break;
1900         case SEPARATE_BOTH:
1901                 gtk_box_pack_start(GTK_BOX(vbox_body),
1902                                    GTK_WIDGET_PTR(mainwin->summaryview),
1903                                    TRUE, TRUE, 0);
1904                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1905                                      prefs_common.summaryview_width,
1906                                      prefs_common.summaryview_height);
1907                 gtk_widget_set_usize(mainwin->window,
1908                                      prefs_common.mainview_width,
1909                                      prefs_common.mainwin_height);
1910                 gtk_container_add(GTK_CONTAINER(folderwin),
1911                                   GTK_WIDGET_PTR(mainwin->folderview));
1912                 gtk_container_add(GTK_CONTAINER(messagewin),
1913                                   GTK_WIDGET_PTR(mainwin->messageview));
1914
1915                 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1916                 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1917         
1918                 mainwin->win.sep_both.folderwin = folderwin;
1919                 mainwin->win.sep_both.messagewin = messagewin;
1920
1921                 gtk_widget_show_all(folderwin);
1922                 gtk_widget_show_all(messagewin);
1923                 break;
1924         }
1925
1926         mainwin->type = type;
1927
1928         debug_print(_("done.\n"));
1929 }
1930
1931 static void main_window_toolbar_create(MainWindow *mainwin,
1932                                        GtkWidget *container)
1933 {
1934         GtkWidget *toolbar;
1935         GtkWidget *icon_wid;
1936         GtkWidget *get_btn;
1937         GtkWidget *getall_btn;
1938         GtkWidget *compose_mail_btn;
1939         GtkWidget *compose_news_btn;
1940         GtkWidget *reply_btn;
1941         GtkWidget *replyall_btn;
1942         GtkWidget *replysender_btn;
1943         GtkWidget *fwd_btn;
1944         GtkWidget *send_btn;
1945 #if 0
1946         GtkWidget *prefs_btn;
1947         GtkWidget *account_btn;
1948 #endif
1949         GtkWidget *next_btn;
1950         GtkWidget *delete_btn;
1951         GtkWidget *exec_btn;
1952         
1953         GtkTooltips *tooltips;
1954
1955         toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1956                                   GTK_TOOLBAR_BOTH);
1957         gtk_container_add(GTK_CONTAINER(container), toolbar);
1958         gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1959         gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1960         gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1961                                     GTK_TOOLBAR_SPACE_LINE);
1962
1963         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1964         get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1965                                           _("Get"),
1966                                           _("Get new mail from current account"),
1967                                           "Get",
1968                                           icon_wid, toolbar_inc_cb, mainwin);
1969         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1970         getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1971                                              _("Get all"),
1972                                              _("Get new mail from all accounts"),
1973                                              "Get all",
1974                                              icon_wid,
1975                                              toolbar_inc_all_cb,
1976                                              mainwin);
1977
1978         gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1979
1980         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1981         send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1982                                            _("Send"),
1983                                            _("Send queued message(s)"),
1984                                            "Send",
1985                                            icon_wid,
1986                                            toolbar_send_cb,
1987                                            mainwin);
1988
1989         /* insert compose mail button widget */                                    
1990         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1991         compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1992                                               _("Email"),
1993                                               _("Compose an email message"),
1994                                               "New",
1995                                               icon_wid,
1996                                               toolbar_compose_mail_cb,
1997                                               mainwin);
1998
1999         /* insert compose news button widget */
2000         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2001         compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2002                                               _("News"),
2003                                               _("Compose a news message"),
2004                                               "New",
2005                                               icon_wid,
2006                                               toolbar_compose_news_cb,
2007                                               mainwin);
2008
2009         gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2010         
2011         /* reply button */
2012         
2013         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2014         reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2015                                             _("Reply"),
2016                                             _("Reply to the message - Right button: more options"),
2017                                             "Reply",
2018                                             icon_wid,
2019                                             toolbar_reply_cb,
2020                                             mainwin);
2021
2022         /* replyall button */
2023
2024         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2025         replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2026                                                _("All"),
2027                                                _("Reply to all - Right button: more options"),
2028                                                "Reply to all",
2029                                                icon_wid,
2030                                                toolbar_reply_to_all_cb,
2031                                                mainwin);
2032
2033         /* reply to sender button */
2034         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2035         replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2036                                                   _("Sender"),
2037                                                   _("Reply to sender - Right button: more options"),
2038                                                   "Reply to sender",
2039                                                   icon_wid,
2040                                                   toolbar_reply_to_sender_cb,
2041                                                   mainwin);
2042
2043         /* forward button */
2044         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2045         fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2046                                           _("Forward"),
2047                                           _("Forward the message - Right button: more options"),
2048                                           "Fwd",
2049                                           icon_wid,
2050                                           toolbar_forward_cb,
2051                                           mainwin);
2052
2053         gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2054
2055         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2056         delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2057                                           _("Delete"),
2058                                           _("Delete the message"),
2059                                           "Delete",
2060                                           icon_wid,
2061                                           toolbar_delete_cb,
2062                                           mainwin);
2063
2064         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2065         exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2066                                            _("Execute"),
2067                                            _("Execute marked process"),
2068                                            "Execute",
2069                                            icon_wid,
2070                                            toolbar_exec_cb,
2071                                            mainwin);
2072
2073         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2074         next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2075                                            _("Next"),
2076                                            _("Next unread message"),
2077                                            "Next unread",
2078                                            icon_wid,
2079                                            toolbar_next_unread_cb,
2080                                            mainwin);
2081
2082 #if 0
2083         gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2084
2085         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2086         prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2087                                             _("Prefs"),
2088                                             _("Common preferences"),
2089                                             "Prefs",
2090                                             icon_wid,
2091                                             toolbar_prefs_cb,
2092                                             mainwin);
2093         icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2094         account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2095                                               _("Account"),
2096                                               _("Account setting"),
2097                                               "Account",
2098                                               icon_wid,
2099                                               toolbar_account_cb,
2100                                               mainwin);
2101         gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2102                            GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2103                            mainwin);
2104 #endif
2105
2106         gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2107                 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2108                 mainwin);
2109         
2110         gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2111                 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2112                 mainwin);
2113         
2114         gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2115                 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2116                 mainwin);
2117         
2118         gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2119                 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2120                 mainwin);
2121         
2122
2123         mainwin->toolbar                = toolbar;
2124         mainwin->get_btn                = get_btn;
2125         mainwin->getall_btn             = getall_btn;
2126         mainwin->compose_mail_btn       = compose_mail_btn;
2127         mainwin->compose_news_btn       = compose_news_btn;
2128         mainwin->reply_btn              = reply_btn;
2129         mainwin->replyall_btn           = replyall_btn;
2130         mainwin->replysender_btn        = replysender_btn;
2131         mainwin->fwd_btn                = fwd_btn;
2132         mainwin->send_btn               = send_btn;
2133         #if 0
2134         mainwin->prefs_btn              = prefs_btn;
2135         mainwin->account_btn            = account_btn;
2136         #endif
2137         mainwin->next_btn               = next_btn;
2138         mainwin->delete_btn             = delete_btn;
2139         mainwin->exec_btn               = exec_btn;
2140
2141         gtk_widget_show_all(toolbar);
2142 }
2143
2144 /* callback functions */
2145 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2146 {
2147         MainWindow *mainwindow = (MainWindow *) data;
2148         
2149         if (!event) return;
2150
2151         if (event->button == 3) {
2152                 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2153                 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2154                        menu_button_position, widget,
2155                        event->button, event->time);
2156         }
2157 }
2158
2159 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2160 {
2161         MainWindow *mainwin = (MainWindow *)data;
2162
2163         gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2164         manage_window_focus_in(mainwin->window, NULL, NULL);
2165 }
2166
2167 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2168 {
2169         MainWindow *mainwindow = (MainWindow *) data;
2170         
2171         if (!event) return;
2172
2173         if (event->button == 3) {
2174                 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2175                 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2176                        menu_button_position, widget,
2177                        event->button, event->time);
2178         }
2179 }
2180
2181 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2182 {
2183         MainWindow *mainwin = (MainWindow *)data;
2184
2185         gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2186         manage_window_focus_in(mainwin->window, NULL, NULL);
2187 }
2188
2189 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2190 {
2191         MainWindow *mainwindow = (MainWindow *) data;
2192         GtkWidget *replysender_menu, *replysender_item;
2193
2194         if (!event) return;
2195
2196         if (event->button == 3) {
2197                 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2198                 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2199                        menu_button_position, widget,
2200                        event->button, event->time);
2201         }
2202 }
2203
2204 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2205 {
2206         MainWindow *mainwin = (MainWindow *)data;
2207
2208         gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2209         manage_window_focus_in(mainwin->window, NULL, NULL);
2210 }
2211
2212 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2213 {
2214         MainWindow *mainwindow = (MainWindow *) data;
2215         
2216         if (!event) return;
2217
2218         if (event->button == 3) {
2219                 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2220                 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2221                        menu_button_position, widget,
2222                        event->button, event->time);
2223         }
2224 }
2225
2226 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2227 {
2228         MainWindow *mainwin = (MainWindow *)data;
2229
2230         gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2231         manage_window_focus_in(mainwin->window, NULL, NULL);
2232 }
2233
2234 static void toolbar_inc_cb      (GtkWidget      *widget,
2235                                  gpointer        data)
2236 {
2237         MainWindow *mainwin = (MainWindow *)data;
2238
2239         inc_mail_cb(mainwin, 0, NULL);
2240 }
2241
2242 static void toolbar_inc_all_cb  (GtkWidget      *widget,
2243                                  gpointer        data)
2244 {
2245         MainWindow *mainwin = (MainWindow *)data;
2246
2247         inc_all_account_mail_cb(mainwin, 0, NULL);
2248 }
2249
2250 static void toolbar_send_cb     (GtkWidget      *widget,
2251                                  gpointer        data)
2252 {
2253         MainWindow *mainwin = (MainWindow *)data;
2254
2255         send_queue_cb(mainwin, 0, NULL);
2256 }
2257
2258 static void toolbar_compose_cb  (GtkWidget      *widget,
2259                                  gpointer        data)
2260 {
2261         MainWindow *mainwin = (MainWindow *)data;
2262
2263         if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2264                 compose_cb(mainwin, 0, NULL);
2265         else
2266                 compose_news_cb(mainwin, 0, NULL);
2267 }
2268
2269 static void toolbar_compose_news_cb     (GtkWidget      *widget,
2270                                  gpointer        data)
2271 {
2272         MainWindow *mainwin = (MainWindow *)data;
2273
2274         compose_news_cb(mainwin, 0, NULL);
2275 }
2276
2277 static void toolbar_compose_mail_cb     (GtkWidget      *widget,
2278                                  gpointer        data)
2279 {
2280         MainWindow *mainwin = (MainWindow *)data;
2281
2282         compose_mail_cb(mainwin, 0, NULL);
2283 }
2284
2285 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2286 {
2287         MainWindow *mainwin = (MainWindow *)data;
2288
2289         reply_cb(mainwin, 
2290                  prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE 
2291                  : COMPOSE_REPLY_WITHOUT_QUOTE,
2292                  NULL);
2293 }
2294
2295 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2296 {
2297         MainWindow *mainwin = (MainWindow *)data;
2298
2299         reply_cb(mainwin, 
2300                  prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE 
2301                  : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, 
2302                  NULL);
2303 }
2304
2305
2306 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2307 {
2308         MainWindow *mainwin = (MainWindow *)data;
2309
2310         reply_cb(mainwin, 
2311                  prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE 
2312                  : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, 
2313                  NULL);
2314 }
2315
2316 static void toolbar_forward_cb  (GtkWidget      *widget,
2317                                  gpointer        data)
2318 {
2319         MainWindow *mainwin = (MainWindow *)data;
2320
2321         if (prefs_common.forward_as_attachment)
2322                 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2323         else
2324                 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2325 }
2326
2327 static void toolbar_delete_cb   (GtkWidget      *widget,
2328                                  gpointer        data)
2329 {
2330         MainWindow *mainwin = (MainWindow *)data;
2331
2332         summary_delete(mainwin->summaryview);
2333 }
2334
2335 static void toolbar_exec_cb     (GtkWidget      *widget,
2336                                  gpointer        data)
2337 {
2338         MainWindow *mainwin = (MainWindow *)data;
2339
2340         summary_execute(mainwin->summaryview);
2341 }
2342
2343 static void toolbar_next_unread_cb      (GtkWidget      *widget,
2344                                          gpointer        data)
2345 {
2346         MainWindow *mainwin = (MainWindow *)data;
2347
2348         next_unread_cb(mainwin, 0, NULL);
2349 }
2350
2351 static void toolbar_prefs_cb    (GtkWidget      *widget,
2352                                  gpointer        data)
2353 {
2354         prefs_common_open();
2355 }
2356
2357 static void toolbar_account_cb  (GtkWidget      *widget,
2358                                  gpointer        data)
2359 {
2360         MainWindow *mainwin = (MainWindow *)data;
2361
2362         prefs_account_open_cb(mainwin, 0, NULL);
2363 }
2364
2365 #if 0
2366 static void toolbar_account_button_pressed(GtkWidget *widget,
2367                                            GdkEventButton *event,
2368                                            gpointer data)
2369 {
2370         MainWindow *mainwin = (MainWindow *)data;
2371
2372         if (!event) return;
2373         if (event->button != 3) return;
2374
2375         gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2376         gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2377                             widget);
2378
2379         gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2380                        menu_button_position, widget,
2381                        event->button, event->time);
2382 }
2383 #endif
2384
2385 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2386                                     gpointer data)
2387 {
2388         MainWindow *mainwin = (MainWindow *)data;
2389
2390         if (!event) return;
2391
2392         gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2393         gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2394                             widget);
2395
2396         gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2397                        menu_button_position, widget,
2398                        event->button, event->time);
2399 }
2400
2401 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2402 {
2403         MainWindow *mainwin = (MainWindow *)data;
2404         GtkWidget *button;
2405
2406         button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2407         if (!button) return;
2408         gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2409         gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2410         manage_window_focus_in(mainwin->window, NULL, NULL);
2411 }
2412
2413 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2414                                  gpointer data)
2415 {
2416         MainWindow *mainwin = (MainWindow *)data;
2417
2418         if (mainwin->lock_count == 0)
2419                 app_exit_cb(data, 0, widget);
2420
2421         return TRUE;
2422 }
2423
2424 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2425                            GtkWidget *widget)
2426 {
2427         main_window_add_mailbox(mainwin);
2428 }
2429
2430 static void add_mbox_cb(MainWindow *mainwin, guint action,
2431                         GtkWidget *widget)
2432 {
2433         main_window_add_mbox(mainwin);
2434 }
2435
2436 static void update_folderview_cb(MainWindow *mainwin, guint action,
2437                                  GtkWidget *widget)
2438 {
2439         summary_show(mainwin->summaryview, NULL, FALSE);
2440         folderview_rescan_all();
2441 }
2442
2443 static void new_folder_cb(MainWindow *mainwin, guint action,
2444                           GtkWidget *widget)
2445 {
2446         folderview_new_folder(mainwin->folderview);
2447 }
2448
2449 static void rename_folder_cb(MainWindow *mainwin, guint action,
2450                              GtkWidget *widget)
2451 {
2452         folderview_rename_folder(mainwin->folderview);
2453 }
2454
2455 static void delete_folder_cb(MainWindow *mainwin, guint action,
2456                              GtkWidget *widget)
2457 {
2458         folderview_delete_folder(mainwin->folderview);
2459 }
2460
2461 static void import_mbox_cb(MainWindow *mainwin, guint action,
2462                            GtkWidget *widget)
2463 {
2464         import_mbox(mainwin->summaryview->folder_item);
2465 }
2466
2467 static void export_mbox_cb(MainWindow *mainwin, guint action,
2468                            GtkWidget *widget)
2469 {
2470         export_mbox(mainwin->summaryview->folder_item);
2471 }
2472
2473 static void empty_trash_cb(MainWindow *mainwin, guint action,
2474                            GtkWidget *widget)
2475 {
2476         main_window_empty_trash(mainwin, TRUE);
2477 }
2478
2479 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2480 {
2481         summary_save_as(mainwin->summaryview);
2482 }
2483
2484 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2485 {
2486         summary_print(mainwin->summaryview);
2487 }
2488
2489 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2490 {
2491         if (prefs_common.confirm_on_exit) {
2492                 if (alertpanel(_("Exit"), _("Exit this program?"),
2493                                _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2494                         return;
2495                 manage_window_focus_in(mainwin->window, NULL, NULL);
2496         }
2497
2498         app_will_exit(widget, mainwin);
2499 }
2500
2501 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2502 {
2503         if (action == 1)
2504                 summary_search(mainwin->summaryview);
2505         else
2506                 message_search(mainwin->messageview);
2507 }
2508
2509 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2510                              GtkWidget *widget)
2511 {
2512         switch (mainwin->type) {
2513         case SEPARATE_NONE:
2514         case SEPARATE_MESSAGE:
2515                 break;
2516         case SEPARATE_FOLDER:
2517                 if (GTK_CHECK_MENU_ITEM(widget)->active)
2518                         gtk_widget_show(mainwin->win.sep_folder.folderwin);
2519                 else
2520                         gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2521                 break;
2522         case SEPARATE_BOTH:
2523                 if (GTK_CHECK_MENU_ITEM(widget)->active)
2524                         gtk_widget_show(mainwin->win.sep_both.folderwin);
2525                 else
2526                         gtk_widget_hide(mainwin->win.sep_both.folderwin);
2527                 break;
2528         }
2529 }
2530
2531 static void toggle_message_cb(MainWindow *mainwin, guint action,
2532                               GtkWidget *widget)
2533 {
2534         switch (mainwin->type) {
2535         case SEPARATE_NONE:
2536         case SEPARATE_FOLDER:
2537                 break;
2538         case SEPARATE_MESSAGE:
2539                 if (GTK_CHECK_MENU_ITEM(widget)->active)
2540                         gtk_widget_show(mainwin->win.sep_message.messagewin);
2541                 else
2542                         gtk_widget_hide(mainwin->win.sep_message.messagewin);
2543                 break;
2544         case SEPARATE_BOTH:
2545                 if (GTK_CHECK_MENU_ITEM(widget)->active)
2546                         gtk_widget_show(mainwin->win.sep_both.messagewin);
2547                 else
2548                         gtk_widget_hide(mainwin->win.sep_both.messagewin);
2549                 break;
2550         }
2551 }
2552
2553 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2554                               GtkWidget *widget)
2555 {
2556 /*      activate_compose_button(mainwin, (ToolbarStyle)action, 
2557                         mainwin->compose_btn_type);
2558         set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2559         set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2560         set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2561         set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2562         
2563         mainwin->toolbar_style = (ToolbarStyle)action;
2564         prefs_common.toolbar_style = (ToolbarStyle)action;
2565         
2566         set_toolbar_style(mainwin);
2567 }
2568
2569 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2570                                 GtkWidget *widget)
2571 {
2572         if (GTK_CHECK_MENU_ITEM(widget)->active) {
2573                 gtk_widget_show(mainwin->hbox_stat);
2574                 prefs_common.show_statusbar = TRUE;
2575         } else {
2576                 gtk_widget_hide(mainwin->hbox_stat);
2577                 prefs_common.show_statusbar = FALSE;
2578         }
2579 }
2580
2581 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action,     GtkWidget *widget)
2582 {
2583         summary_toggle_view_real(mainwin->summaryview);
2584 }
2585
2586 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2587 {
2588         messageview_toggle_view_real(mainwin->messageview);
2589 }
2590
2591 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2592 {
2593         if (GTK_CHECK_MENU_ITEM(widget)->active) {
2594                 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2595         } else {
2596                 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);           
2597         }
2598 }
2599
2600 static void online_switch_clicked (GtkButton *btn, gpointer data) 
2601 {
2602         MainWindow *mainwin;
2603         GtkItemFactory *ifactory;
2604         GtkCheckMenuItem *menuitem;
2605
2606         mainwin = (MainWindow *) data;
2607         
2608         ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2609         menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2610         
2611         g_return_if_fail(mainwin != NULL);
2612         g_return_if_fail(menuitem != NULL);
2613         
2614         if (btn == GTK_BUTTON(mainwin->online_switch)) {
2615                 /* go offline */
2616                 gtk_widget_hide (mainwin->online_switch);
2617                 gtk_widget_show (mainwin->offline_switch);
2618                 menuitem->active = TRUE;
2619                 prefs_common.work_offline = TRUE;
2620                 inc_autocheck_timer_remove();           
2621         } else {
2622                 /*go online */
2623                 gtk_widget_hide (mainwin->offline_switch);
2624                 gtk_widget_show (mainwin->online_switch);
2625                 menuitem->active = FALSE;
2626                 prefs_common.work_offline = FALSE;
2627                 inc_autocheck_timer_set();
2628         }
2629 }
2630
2631 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2632 {
2633         MainWindow *mainwin;
2634         SeparateType type;
2635
2636         mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2637         g_return_if_fail(mainwin != NULL);
2638
2639         type = mainwin->type ^ action;
2640         main_window_separation_change(mainwin, type);
2641
2642         prefs_common.sep_folder = (type & SEPARATE_FOLDER)  != 0;
2643         prefs_common.sep_msg    = (type & SEPARATE_MESSAGE) != 0;
2644 }
2645
2646 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2647                                 GtkWidget *widget)
2648 {
2649         addressbook_open(NULL);
2650 }
2651
2652 static void log_window_show_cb(MainWindow *mainwin, guint action,
2653                                GtkWidget *widget)
2654 {
2655         log_window_show(mainwin->logwin);
2656 }
2657
2658 static void sel_download_cb(MainWindow *mainwin, guint action,
2659                                GtkWidget *widget)
2660 {
2661         selective_download(mainwin);
2662 }
2663
2664 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2665 {
2666         inc_mail(mainwin, prefs_common.newmail_notify_manu);
2667 }
2668
2669 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2670                                     GtkWidget *widget)
2671 {
2672         inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2673 }
2674
2675 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2676 {
2677         inc_cancel_all();
2678 }
2679
2680 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2681 {
2682         GList *list;
2683
2684         if (prefs_common.work_offline)
2685                 if (alertpanel(_("Offline warning"), 
2686                                _("You're working offline. Override?"),
2687                                _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2688                 return;
2689
2690         for (list = folder_get_list(); list != NULL; list = list->next) {
2691                 Folder *folder = list->data;
2692
2693                 if (folder->queue) {
2694                         if (procmsg_send_queue
2695                                 (folder->queue, prefs_common.savemsg) < 0)
2696                                 alertpanel_error(_("Some errors occurred while sending queued messages."));
2697                         statusbar_pop_all();
2698                         folder_item_scan(folder->queue);
2699                         folderview_update_item(folder->queue, TRUE);
2700                 }
2701         }
2702 }
2703
2704 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2705 {
2706         if (mainwin->summaryview->folder_item) {
2707                 if (mainwin->summaryview->folder_item->folder->account != NULL
2708                     && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2709                         compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2710                 else
2711                         compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2712         }
2713         else
2714                 compose_new(NULL);
2715 }
2716
2717 static void compose_mail_cb(MainWindow *mainwin, guint action,
2718                             GtkWidget *widget)
2719 {
2720         PrefsAccount * ac;
2721         GList * list;
2722         GList * cur;
2723
2724         if (mainwin->summaryview->folder_item) {
2725                 ac = mainwin->summaryview->folder_item->folder->account;
2726                 if (ac && ac->protocol != A_NNTP) {
2727                         compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2728                         return;
2729                 }
2730         }
2731
2732         if(cur_account && (cur_account->protocol != A_NNTP)) {
2733                 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2734                 return;
2735         }
2736
2737         list = account_get_list();
2738         for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2739                 ac = (PrefsAccount *) cur->data;
2740                 if (ac->protocol != A_NNTP) {
2741                         compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2742                         return;
2743                 }
2744         }
2745 }
2746
2747 static void compose_news_cb(MainWindow *mainwin, guint action,
2748                             GtkWidget *widget)
2749 {
2750         PrefsAccount * ac = NULL;
2751         GList * list;
2752         GList * cur;
2753
2754         if (mainwin->summaryview->folder_item) {
2755                 ac = mainwin->summaryview->folder_item->folder->account;
2756                 if (ac && ac->protocol == A_NNTP) {
2757                         compose_new_with_recipient
2758                                 (ac, mainwin->summaryview->folder_item->path);
2759                         return;
2760                 }
2761         }
2762
2763         list = account_get_list();
2764         for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2765                 ac = (PrefsAccount *) cur->data;
2766                 if (ac->protocol == A_NNTP) {
2767                         compose_new(ac);
2768                         return;
2769                 }
2770         }
2771 }
2772
2773 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2774 {
2775         summary_reply(mainwin->summaryview, (ComposeMode)action);
2776 }
2777
2778 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2779 {
2780         summary_move_to(mainwin->summaryview);
2781 }
2782
2783 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2784 {
2785         summary_copy_to(mainwin->summaryview);
2786 }
2787
2788 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2789 {
2790         summary_delete(mainwin->summaryview);
2791 }
2792
2793 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2794 {
2795         summary_open_msg(mainwin->summaryview);
2796 }
2797
2798 static void view_source_cb(MainWindow *mainwin, guint action,
2799                            GtkWidget *widget)
2800 {
2801         summary_view_source(mainwin->summaryview);
2802 }
2803
2804 static void show_all_header_cb(MainWindow *mainwin, guint action,
2805                                GtkWidget *widget)
2806 {
2807         if (mainwin->menu_lock_count) return;
2808         summary_display_msg_selected(mainwin->summaryview,
2809                                      GTK_CHECK_MENU_ITEM(widget)->active);
2810 }
2811
2812 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2813 {
2814         summary_reedit(mainwin->summaryview);
2815 }
2816
2817 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2818 {
2819         summary_mark(mainwin->summaryview);
2820 }
2821
2822 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2823 {
2824         summary_unmark(mainwin->summaryview);
2825 }
2826
2827 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2828                               GtkWidget *widget)
2829 {
2830         summary_mark_as_unread(mainwin->summaryview);
2831 }
2832
2833 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2834                             GtkWidget *widget)
2835 {
2836         summary_mark_as_read(mainwin->summaryview);
2837 }
2838
2839 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2840                              GtkWidget *widget)
2841 {
2842         summary_mark_all_read(mainwin->summaryview);
2843 }
2844
2845 static void add_address_cb(MainWindow *mainwin, guint action,
2846                            GtkWidget *widget)
2847 {
2848         summary_add_address(mainwin->summaryview);
2849 }
2850
2851 static void set_charset_cb(MainWindow *mainwin, guint action,
2852                            GtkWidget *widget)
2853 {
2854         const gchar *str;
2855
2856         str = conv_get_charset_str((CharSet)action);
2857         g_free(prefs_common.force_charset);
2858         prefs_common.force_charset = str ? g_strdup(str) : NULL;
2859
2860         summary_redisplay_msg(mainwin->summaryview);
2861
2862         debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2863 }
2864
2865 static void hide_read_messages (MainWindow *mainwin, guint action,
2866                                 GtkWidget *widget)
2867 {
2868         if (!mainwin->summaryview->folder_item
2869             || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2870                 return;
2871         summary_toggle_show_read_messages(mainwin->summaryview);
2872 }
2873
2874 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2875 {
2876         GtkItemFactory *ifactory;
2877
2878         if (mainwin->menu_lock_count) return;
2879         if (!mainwin->summaryview->folder_item) return;
2880
2881         ifactory = gtk_item_factory_from_widget(widget);
2882
2883         if (GTK_CHECK_MENU_ITEM(widget)->active) {
2884                 summary_thread_build(mainwin->summaryview);
2885                 mainwin->summaryview->folder_item->threaded = TRUE;
2886         } else {
2887                 summary_unthread(mainwin->summaryview);
2888                 mainwin->summaryview->folder_item->threaded = FALSE;
2889         }
2890 }
2891
2892 static void set_display_item_cb(MainWindow *mainwin, guint action,
2893                                 GtkWidget *widget)
2894 {
2895         prefs_summary_column_open();
2896 }
2897
2898 static void sort_summary_cb(MainWindow *mainwin, guint action,
2899                             GtkWidget *widget)
2900 {
2901         summary_sort(mainwin->summaryview, (SummarySortType)action);
2902 }
2903
2904 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2905                                   GtkWidget *widget)
2906 {
2907         summary_attract_by_subject(mainwin->summaryview);
2908 }
2909
2910 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2911                                  GtkWidget *widget)
2912 {
2913         summary_delete_duplicated(mainwin->summaryview);
2914 }
2915
2916 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2917 {
2918         summary_filter(mainwin->summaryview);
2919 }
2920
2921 static void execute_summary_cb(MainWindow *mainwin, guint action,
2922                                GtkWidget *widget)
2923 {
2924         summary_execute(mainwin->summaryview);
2925 }
2926
2927 static void update_summary_cb(MainWindow *mainwin, guint action,
2928                               GtkWidget *widget)
2929 {
2930         FolderItem *fitem;
2931         FolderView *folderview = mainwin->folderview;
2932
2933         if (!mainwin->summaryview->folder_item) return;
2934         if (!folderview->opened) return;
2935
2936         folder_update_op_count();
2937
2938         fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2939                                             folderview->opened);
2940         if (!fitem) return;
2941
2942         summary_show(mainwin->summaryview, fitem, TRUE);
2943 }
2944
2945 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2946 {
2947         summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2948 }
2949
2950 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2951 {
2952         summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2953 }
2954
2955 static void prev_unread_cb(MainWindow *mainwin, guint action,
2956                            GtkWidget *widget)
2957 {
2958         summary_select_prev_unread(mainwin->summaryview);
2959 }
2960
2961 static void next_unread_cb(MainWindow *mainwin, guint action,
2962                            GtkWidget *widget)
2963 {
2964         summary_select_next_unread(mainwin->summaryview);
2965 }
2966
2967 static void prev_marked_cb(MainWindow *mainwin, guint action,
2968                            GtkWidget *widget)
2969 {
2970         summary_select_prev_marked(mainwin->summaryview);
2971 }
2972
2973 static void next_marked_cb(MainWindow *mainwin, guint action,
2974                            GtkWidget *widget)
2975 {
2976         summary_select_next_marked(mainwin->summaryview);
2977 }
2978
2979 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2980                             GtkWidget *widget)
2981 {
2982         summary_select_prev_labeled(mainwin->summaryview);
2983 }
2984
2985 static void next_labeled_cb(MainWindow *mainwin, guint action,
2986                             GtkWidget *widget)
2987 {
2988         summary_select_next_labeled(mainwin->summaryview);
2989 }
2990
2991 static void goto_folder_cb(MainWindow *mainwin, guint action,
2992                            GtkWidget *widget)
2993 {
2994         FolderItem *to_folder;
2995
2996         to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2997
2998         if (to_folder)
2999                 folderview_select(mainwin->folderview, to_folder);
3000 }
3001
3002 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3003 {
3004         messageview_copy_clipboard(mainwin->messageview);
3005 }
3006
3007 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3008 {
3009         if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3010                 summary_select_all(mainwin->summaryview);
3011         else if (mainwin->summaryview->msg_is_toggled_on && (
3012                  GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text) ||
3013                  GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->ctree) ||
3014                  GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->notebook) ||
3015                  GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->textview->text)))
3016                 messageview_select_all(mainwin->messageview);
3017 }
3018
3019 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3020 {
3021         if (mainwin->summaryview->msg_is_toggled_on)
3022                 summary_select_thread(mainwin->summaryview);
3023 }
3024
3025 static void create_filter_cb(MainWindow *mainwin, guint action,
3026                              GtkWidget *widget)
3027 {
3028         summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3029 }
3030
3031 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3032                                  GtkWidget *widget)
3033 {
3034         prefs_common_open();
3035 }
3036
3037 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3038                                  GtkWidget *widget)
3039 {
3040         prefs_filter_open(NULL, NULL);
3041 }
3042
3043 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3044                                   GtkWidget *widget)
3045 {
3046         prefs_scoring_open(NULL);
3047 }
3048
3049 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3050                                     GtkWidget *widget)
3051 {
3052         prefs_filtering_open(NULL, NULL, NULL);
3053 }
3054
3055 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3056                                    GtkWidget *widget)
3057 {
3058         prefs_template_open();
3059 }
3060
3061 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3062                                   GtkWidget *widget)
3063 {
3064         prefs_actions_open(mainwin);
3065 }
3066
3067 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3068                                   GtkWidget *widget)
3069 {
3070         if (!cur_account) {
3071                 new_account_cb(mainwin, 0, widget);
3072         } else {
3073                 gboolean prev_default = cur_account->is_default;
3074
3075                 prefs_account_open(cur_account);
3076                 if (!prev_default && cur_account->is_default)
3077                         account_set_as_default(cur_account);
3078                 account_save_config_all();
3079                 account_set_menu();
3080                 main_window_reflect_prefs_all();
3081         }
3082 }
3083
3084 static void new_account_cb(MainWindow *mainwin, guint action,
3085                            GtkWidget *widget)
3086 {
3087         account_edit_open();
3088         if (!compose_get_compose_list()) account_add();
3089 }
3090
3091 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3092 {
3093         cur_account = (PrefsAccount *)data;
3094         main_window_reflect_prefs_all();
3095 }
3096
3097 static void manual_open_cb(MainWindow *mainwin, guint action,
3098                            GtkWidget *widget)
3099 {
3100         manual_open((ManualLang)action);
3101 }
3102
3103 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3104 {
3105         faq_open((ManualLang)action);
3106 }
3107
3108 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3109 {
3110         MainWindow *mainwin = (MainWindow *)data;
3111         gchar *str;
3112
3113         if (item->path)
3114                 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3115                                       LOCAL_FOLDER(folder)->rootpath,
3116                                       G_DIR_SEPARATOR,
3117                                       item->path);
3118         else
3119                 str = g_strdup_printf(_("Scanning folder %s ..."),
3120                                       LOCAL_FOLDER(folder)->rootpath);
3121
3122         STATUSBAR_PUSH(mainwin, str);
3123         STATUSBAR_POP(mainwin);
3124         g_free(str);
3125 }
3126
3127 static void activate_compose_button (MainWindow *mainwin,
3128                                 ToolbarStyle style,
3129                                 ComposeButtonType type)
3130 {
3131         SensitiveCond state = main_window_get_current_state(mainwin);
3132
3133         if (style == TOOLBAR_NONE) 
3134                 return;
3135
3136         gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn 
3137                 : mainwin->compose_news_btn);
3138         gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3139                 : mainwin->compose_mail_btn);
3140         mainwin->compose_btn_type = type;       
3141 }
3142
3143 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3144 {
3145         if (mainwin->compose_btn_type != compose_btn_type)
3146                 activate_compose_button(mainwin, 
3147                                         prefs_common.toolbar_style,
3148                                         compose_btn_type);
3149 }
3150
3151 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3152 {
3153         MainWindow *mainwin = (MainWindow*) data;
3154         
3155         if (!mainwin) return;
3156                 
3157         gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3158 }
3159
3160 #define BREAK_ON_MODIFIER_KEY() \
3161         if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3162
3163 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3164 {
3165         MainWindow *mainwin = (MainWindow*) data;
3166         
3167         if (!mainwin || !event) return;
3168                 
3169         switch (event->keyval) {
3170         case GDK_Q:             /* Quit */
3171                 BREAK_ON_MODIFIER_KEY();
3172
3173                 app_exit_cb(mainwin, 0, NULL);
3174                 return;
3175         default:
3176                 break;
3177         }
3178 }
3179
3180 #undef BREAK_ON_MODIFIER_KEY
3181
3182 static void set_toolbar_style(MainWindow *mainwin)
3183 {
3184         switch (prefs_common.toolbar_style) {
3185         case TOOLBAR_NONE:
3186                 gtk_widget_hide(mainwin->handlebox);
3187                 break;
3188         case TOOLBAR_ICON:
3189                 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3190                                       GTK_TOOLBAR_ICONS);
3191                 break;
3192         case TOOLBAR_TEXT:
3193                 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3194                                       GTK_TOOLBAR_TEXT);
3195                 break;
3196         case TOOLBAR_BOTH:
3197                 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3198                                       GTK_TOOLBAR_BOTH);
3199                 break;
3200         }
3201         
3202         if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3203                 gtk_widget_show(mainwin->handlebox);
3204                 gtk_widget_queue_resize(mainwin->handlebox);
3205
3206                 if (prefs_common.immediate_exec)
3207                         gtk_widget_hide(mainwin->exec_btn);
3208                 else
3209                         gtk_widget_show(mainwin->exec_btn);
3210         }
3211 }
3212
3213 /*
3214  * Harvest addresses for selected folder.
3215  */
3216 static void addr_harvest_cb( MainWindow *mainwin,
3217                             guint action,
3218                             GtkWidget *widget )
3219 {
3220         addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3221 }
3222
3223 /*
3224  * Harvest addresses for selected messages in summary view.
3225  */
3226 static void addr_harvest_msg_cb( MainWindow *mainwin,
3227                             guint action,
3228                             GtkWidget *widget )
3229 {
3230         summary_harvest_address( mainwin->summaryview );
3231 }
3232
3233 /*
3234 * End of Source.
3235 */
3236