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