b84a5e493e9150932af0e6b02470835d8f48751e
[claws.git] / src / mainwindow.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2001 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 <gtk/gtkmain.h>
24 #include <gtk/gtkwindow.h>
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtksignal.h>
27 #include <gtk/gtkvbox.h>
28 #include <gtk/gtkcontainer.h>
29 #include <gtk/gtkstatusbar.h>
30 #include <gtk/gtkhpaned.h>
31 #include <gtk/gtkvpaned.h>
32 #include <gtk/gtkcheckmenuitem.h>
33 #include <gtk/gtkitemfactory.h>
34 #include <gtk/gtkeditable.h>
35 #include <gtk/gtkmenu.h>
36 #include <gtk/gtkmenuitem.h>
37 #include <gtk/gtkhandlebox.h>
38 #include <gtk/gtktoolbar.h>
39 #include <gtk/gtkbutton.h>
40 #include <string.h>
41
42 #include "intl.h"
43 #include "main.h"
44 #include "mainwindow.h"
45 #include "folderview.h"
46 #include "foldersel.h"
47 #include "summaryview.h"
48 #include "summary_search.h"
49 #include "messageview.h"
50 #include "headerview.h"
51 #include "menu.h"
52 #include "folder.h"
53 #include "inc.h"
54 #include "compose.h"
55 #include "procmsg.h"
56 #include "import.h"
57 #include "export.h"
58 #include "prefs_common.h"
59 #include "prefs_filter.h"
60 #include "prefs_scoring.h"
61 #include "prefs_account.h"
62 #include "prefs_folder_item.h"
63 #include "account.h"
64 #include "addressbook.h"
65 #include "headerwindow.h"
66 #include "logwindow.h"
67 #include "manage_window.h"
68 #include "alertpanel.h"
69 #include "statusbar.h"
70 #include "inputdialog.h"
71 #include "utils.h"
72 #include "gtkutils.h"
73 #include "codeconv.h"
74 #include "about.h"
75 #include "manual.h"
76
77 #define AC_LABEL_WIDTH  240
78
79 #define STATUSBAR_PUSH(mainwin, str) \
80 { \
81         gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
82                            mainwin->mainwin_cid, str); \
83         gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
84 }
85
86 #define STATUSBAR_POP(mainwin) \
87 { \
88         gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
89                           mainwin->mainwin_cid); \
90 }
91
92 /* list of all instantiated MainWindow */
93 static GList *mainwin_list = NULL;
94
95 static GdkCursor *watch_cursor;
96
97 static void main_window_show_cur_account        (MainWindow     *mainwin);
98
99 static void main_window_set_widgets             (MainWindow     *mainwin,
100                                                  SeparateType    type);
101 static void main_window_toolbar_create          (MainWindow     *mainwin,
102                                                  GtkWidget      *container);
103
104 /* callback functions */
105 static void toolbar_inc_cb              (GtkWidget      *widget,
106                                          gpointer        data);
107 static void toolbar_inc_all_cb          (GtkWidget      *widget,
108                                          gpointer        data);
109 static void toolbar_send_cb             (GtkWidget      *widget,
110                                          gpointer        data);
111
112 static void toolbar_compose_cb          (GtkWidget      *widget,
113                                          gpointer        data);
114 static void toolbar_reply_cb            (GtkWidget      *widget,
115                                          gpointer        data);
116 static void toolbar_reply_to_all_cb     (GtkWidget      *widget,
117                                          gpointer        data);
118 static void toolbar_reply_to_author_cb  (GtkWidget      *widget,
119                                          gpointer        data);
120 static void toolbar_forward_cb          (GtkWidget      *widget,
121                                          gpointer        data);
122
123 static void toolbar_delete_cb           (GtkWidget      *widget,
124                                          gpointer        data);
125 static void toolbar_exec_cb             (GtkWidget      *widget,
126                                          gpointer        data);
127
128 static void toolbar_next_unread_cb      (GtkWidget      *widget,
129                                          gpointer        data);
130
131 static void toolbar_prefs_cb            (GtkWidget      *widget,
132                                          gpointer        data);
133 static void toolbar_account_cb          (GtkWidget      *widget,
134                                          gpointer        data);
135
136 static void toolbar_account_button_pressed      (GtkWidget      *widget,
137                                                  GdkEventButton *event,
138                                                  gpointer        data);
139 static void ac_label_button_pressed             (GtkWidget      *widget,
140                                                  GdkEventButton *event,
141                                                  gpointer        data);
142
143 static gint main_window_close_cb (GtkWidget     *widget,
144                                   GdkEventAny   *event,
145                                   gpointer       data);
146
147 static void add_mailbox_cb       (MainWindow    *mainwin,
148                                   guint          action,
149                                   GtkWidget     *widget);
150 static void add_mbox_cb          (MainWindow    *mainwin,
151                                   guint          action,
152                                   GtkWidget     *widget);
153 static void update_folderview_cb (MainWindow    *mainwin,
154                                   guint          action,
155                                   GtkWidget     *widget);
156 static void new_folder_cb        (MainWindow    *mainwin,
157                                   guint          action,
158                                   GtkWidget     *widget);
159 static void rename_folder_cb     (MainWindow    *mainwin,
160                                   guint          action,
161                                   GtkWidget     *widget);
162 static void delete_folder_cb     (MainWindow    *mainwin,
163                                   guint          action,
164                                   GtkWidget     *widget);
165 static void import_mbox_cb       (MainWindow    *mainwin,
166                                   guint          action,
167                                   GtkWidget     *widget);
168 static void export_mbox_cb       (MainWindow    *mainwin,
169                                   guint          action,
170                                   GtkWidget     *widget);
171 static void empty_trash_cb       (MainWindow    *mainwin,
172                                   guint          action,
173                                   GtkWidget     *widget);
174
175 static void save_as_cb           (MainWindow    *mainwin,
176                                   guint          action,
177                                   GtkWidget     *widget);
178 static void print_cb             (MainWindow    *mainwin,
179                                   guint          action,
180                                   GtkWidget     *widget);
181 static void app_exit_cb          (MainWindow    *mainwin,
182                                   guint          action,
183                                   GtkWidget     *widget);
184
185 static void toggle_folder_cb     (MainWindow    *mainwin,
186                                   guint          action,
187                                   GtkWidget     *widget);
188 static void toggle_message_cb    (MainWindow    *mainwin,
189                                   guint          action,
190                                   GtkWidget     *widget);
191 static void toggle_toolbar_cb    (MainWindow    *mainwin,
192                                   guint          action,
193                                   GtkWidget     *widget);
194 static void toggle_statusbar_cb  (MainWindow    *mainwin,
195                                   guint          action,
196                                   GtkWidget     *widget);
197 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action);
198
199 static void addressbook_open_cb (MainWindow     *mainwin,
200                                  guint           action,
201                                  GtkWidget      *widget);
202 static void log_window_show_cb  (MainWindow     *mainwin,
203                                  guint           action,
204                                  GtkWidget      *widget);
205
206 static void inc_mail_cb                 (MainWindow     *mainwin,
207                                          guint           action,
208                                          GtkWidget      *widget);
209 static void inc_all_account_mail_cb     (MainWindow     *mainwin,
210                                          guint           action,
211                                          GtkWidget      *widget);
212
213 static void send_queue_cb               (MainWindow     *mainwin,
214                                          guint           action,
215                                          GtkWidget      *widget);
216
217 static void compose_cb                  (MainWindow     *mainwin,
218                                          guint           action,
219                                          GtkWidget      *widget);
220 static void reply_cb                    (MainWindow     *mainwin,
221                                          guint           action,
222                                          GtkWidget      *widget);
223
224 static void open_msg_cb                 (MainWindow     *mainwin,
225                                          guint           action,
226                                          GtkWidget      *widget);
227
228 static void view_source_cb              (MainWindow     *mainwin,
229                                          guint           action,
230                                          GtkWidget      *widget);
231
232 static void reedit_cb                   (MainWindow     *mainwin,
233                                          guint           action,
234                                          GtkWidget      *widget);
235
236 static void move_to_cb                  (MainWindow     *mainwin,
237                                          guint           action,
238                                          GtkWidget      *widget);
239 static void copy_to_cb                  (MainWindow     *mainwin,
240                                          guint           action,
241                                          GtkWidget      *widget);
242 static void delete_cb                   (MainWindow     *mainwin,
243                                          guint           action,
244                                          GtkWidget      *widget);
245
246 static void mark_cb                     (MainWindow     *mainwin,
247                                          guint           action,
248                                          GtkWidget      *widget);
249 static void unmark_cb                   (MainWindow     *mainwin,
250                                          guint           action,
251                                          GtkWidget      *widget);
252
253 static void mark_as_unread_cb           (MainWindow     *mainwin,
254                                          guint           action,
255                                          GtkWidget      *widget);
256 static void mark_as_read_cb             (MainWindow     *mainwin,
257                                          guint           action,
258                                          GtkWidget      *widget);
259
260 static void set_charset_cb              (MainWindow     *mainwin,
261                                          guint           action,
262                                          GtkWidget      *widget);
263
264 static void thread_cb            (MainWindow    *mainwin,
265                                   guint          action,
266                                   GtkWidget     *widget);
267 static void set_display_item_cb  (MainWindow    *mainwin,
268                                   guint          action,
269                                   GtkWidget     *widget);
270 static void sort_summary_cb      (MainWindow    *mainwin,
271                                   guint          action,
272                                   GtkWidget     *widget);
273 static void attract_by_subject_cb(MainWindow    *mainwin,
274                                   guint          action,
275                                   GtkWidget     *widget);
276
277 static void delete_duplicated_cb (MainWindow    *mainwin,
278                                   guint          action,
279                                   GtkWidget     *widget);
280 static void filter_cb            (MainWindow    *mainwin,
281                                   guint          action,
282                                   GtkWidget     *widget);
283 static void execute_summary_cb   (MainWindow    *mainwin,
284                                   guint          action,
285                                   GtkWidget     *widget);
286 static void update_summary_cb    (MainWindow    *mainwin,
287                                   guint          action,
288                                   GtkWidget     *widget);
289
290 static void prev_cb              (MainWindow    *mainwin,
291                                   guint          action,
292                                   GtkWidget     *widget);
293 static void next_cb              (MainWindow    *mainwin,
294                                   guint          action,
295                                   GtkWidget     *widget);
296
297 static void next_unread_cb       (MainWindow    *mainwin,
298                                   guint          action,
299                                   GtkWidget     *widget);
300
301 static void next_marked_cb       (MainWindow    *mainwin,
302                                   guint          action,
303                                   GtkWidget     *widget);
304
305 static void prev_marked_cb       (MainWindow    *mainwin,
306                                   guint          action,
307                                   GtkWidget     *widget);
308
309 static void goto_folder_cb       (MainWindow    *mainwin,
310                                   guint          action,
311                                   GtkWidget     *widget);
312
313 static void copy_cb              (MainWindow    *mainwin,
314                                   guint          action,
315                                   GtkWidget     *widget);
316 static void allsel_cb            (MainWindow    *mainwin,
317                                   guint          action,
318                                   GtkWidget     *widget);
319
320 static void prefs_common_open_cb (MainWindow    *mainwin,
321                                   guint          action,
322                                   GtkWidget     *widget);
323 static void prefs_filter_open_cb (MainWindow    *mainwin,
324                                   guint          action,
325                                   GtkWidget     *widget);
326 static void prefs_scoring_open_cb (MainWindow   *mainwin,
327                                   guint          action,
328                                   GtkWidget     *widget);
329 static void prefs_filtering_open_cb (MainWindow *mainwin,
330                                   guint          action,
331                                   GtkWidget     *widget);
332 static void prefs_account_open_cb(MainWindow    *mainwin,
333                                   guint          action,
334                                   GtkWidget     *widget);
335 static void new_account_cb       (MainWindow    *mainwin,
336                                   guint          action,
337                                   GtkWidget     *widget);
338
339 static void account_menu_cb      (GtkMenuItem   *menuitem,
340                                   gpointer       data);
341
342 static void manual_open_cb       (MainWindow    *mainwin,
343                                   guint          action,
344                                   GtkWidget     *widget);
345
346 static void scan_tree_func       (Folder        *folder,
347                                   FolderItem    *item,
348                                   gpointer       data);
349
350 #define  SEPARATE_ACTION  667
351
352 static GtkItemFactoryEntry mainwin_entries[] =
353 {
354         {N_("/_File"),                          NULL, NULL, 0, "<Branch>"},
355         {N_("/_File/_Add mailbox..."),          NULL, add_mailbox_cb, 0, NULL},
356         {N_("/_File/_Add mbox mailbox..."),     NULL, add_mbox_cb, 0, NULL},
357         {N_("/_File/_Update folder tree"),      NULL, update_folderview_cb, 0, NULL},
358         {N_("/_File/_Folder"),                  NULL, NULL, 0, "<Branch>"},
359         {N_("/_File/_Folder/Create _new folder..."),
360                                                 NULL, new_folder_cb, 0, NULL},
361         {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
362         {N_("/_File/_Folder/_Delete folder"),   NULL, delete_folder_cb, 0, NULL},
363         {N_("/_File/_Import mbox file..."),     NULL, import_mbox_cb, 0, NULL},
364         {N_("/_File/_Export to mbox file..."),  NULL, export_mbox_cb, 0, NULL},
365         {N_("/_File/Empty _trash"),             NULL, empty_trash_cb, 0, NULL},
366         {N_("/_File/---"),                      NULL, NULL, 0, "<Separator>"},
367         {N_("/_File/_Save as..."),              NULL, save_as_cb, 0, NULL},
368         {N_("/_File/_Print..."),                "<alt>P", print_cb, 0, NULL},
369         {N_("/_File/---"),                      NULL, NULL, 0, "<Separator>"},
370         {N_("/_File/_Close"),                   "<alt>W", app_exit_cb, 0, NULL},
371         {N_("/_File/E_xit"),                    "<alt>Q", app_exit_cb, 0, NULL},
372
373         {N_("/_Edit"),                          NULL, NULL, 0, "<Branch>"},
374         {N_("/_Edit/_Copy"),                    "<control>C", copy_cb, 0, NULL},
375         {N_("/_Edit/Select _all"),              "<control>A", allsel_cb, 0, NULL},
376         {N_("/_Edit/---"),                      NULL, NULL, 0, "<Separator>"},
377         {N_("/_Edit/_Search"),                  "<control>S", summary_search_cb, 0, NULL},
378
379         {N_("/_View"),                          NULL, NULL, 0, "<Branch>"},
380         {N_("/_View/_Folder tree"),             NULL, toggle_folder_cb, 0, "<ToggleItem>"},
381         {N_("/_View/_Message view"),            NULL, toggle_message_cb, 0, "<ToggleItem>"},
382         {N_("/_View/_Toolbar"),                 NULL, NULL, 0, "<Branch>"},
383         {N_("/_View/_Toolbar/Icon _and text"),  NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
384         {N_("/_View/_Toolbar/_Icon"),           NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
385         {N_("/_View/_Toolbar/_Text"),           NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
386         {N_("/_View/_Toolbar/_Non-display"),    NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
387         {N_("/_View/_Status bar"),              NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
388         {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
389         {N_("/_View/Separate f_older tree"),    NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
390         {N_("/_View/Separate m_essage view"),   NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
391         {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
392         {N_("/_View/_Code set"),                NULL, NULL, 0, "<Branch>"},
393         {N_("/_View/_Code set/_Auto detect"),
394          NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
395
396 #define CODESET_SEPARATOR \
397         {N_("/_View/_Code set/---"),            NULL, NULL, 0, "<Separator>"}
398 #define CODESET_ACTION(action) \
399          NULL, set_charset_cb, action, "/View/Code set/Auto detect"
400
401         {N_("/_View/_Code set/---"),            NULL, NULL, 0, "<Separator>"},
402         {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
403          CODESET_ACTION(C_US_ASCII)},
404
405 #if HAVE_LIBJCONV
406         {N_("/_View/_Code set/Unicode (_UTF-8)"),
407          CODESET_ACTION(C_UTF_8)},
408         CODESET_SEPARATOR,
409 #endif
410         {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
411          CODESET_ACTION(C_ISO_8859_1)},
412         CODESET_SEPARATOR,
413 #if HAVE_LIBJCONV
414         {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
415          CODESET_ACTION(C_ISO_8859_2)},
416         CODESET_SEPARATOR,
417         {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
418          CODESET_ACTION(C_ISO_8859_13)},
419         {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
420          CODESET_ACTION(C_ISO_8859_4)},
421         CODESET_SEPARATOR,
422         {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
423          CODESET_ACTION(C_ISO_8859_7)},
424         CODESET_SEPARATOR,
425         {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
426          CODESET_ACTION(C_ISO_8859_9)},
427         CODESET_SEPARATOR,
428         {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
429          CODESET_ACTION(C_ISO_8859_5)},
430         {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
431          CODESET_ACTION(C_KOI8_R)},
432         {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
433          CODESET_ACTION(C_CP1251)},
434         CODESET_SEPARATOR,
435 #endif
436         {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
437          CODESET_ACTION(C_ISO_2022_JP)},
438 #if HAVE_LIBJCONV
439         {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
440          CODESET_ACTION(C_ISO_2022_JP_2)},
441 #endif
442         {N_("/_View/_Code set/Japanese (_EUC-JP)"),
443          CODESET_ACTION(C_EUC_JP)},
444         {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
445          CODESET_ACTION(C_SHIFT_JIS)},
446 #if HAVE_LIBJCONV
447         CODESET_SEPARATOR,
448         {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
449          CODESET_ACTION(C_GB2312)},
450         {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
451          CODESET_ACTION(C_BIG5)},
452         {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
453          CODESET_ACTION(C_EUC_TW)},
454         {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
455          CODESET_ACTION(C_ISO_2022_CN)},
456         CODESET_SEPARATOR,
457         {N_("/_View/_Code set/Korean (EUC-_KR)"),
458          CODESET_ACTION(C_EUC_KR)},
459         {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
460          CODESET_ACTION(C_ISO_2022_KR)},
461 #endif
462
463 #undef CODESET_SEPARATOR
464 #undef CODESET_ACTION
465
466         {N_("/_Message"),                       NULL, NULL, 0, "<Branch>"},
467         {N_("/_Message/Rece_ive new mail"),     "<alt>I",       inc_mail_cb, 0, NULL},
468         {N_("/_Message/Receive from _all accounts"),
469                                                 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
470         {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
471         {N_("/_Message/Send queued messa_ges"),
472                                                 NULL, send_queue_cb, 0, NULL},
473         {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
474         {N_("/_Message/Compose _new message"),  "<alt>N",       compose_cb, 0, NULL},
475         {N_("/_Message/_Reply"),                "<alt>R",       reply_cb, COMPOSE_REPLY, NULL},
476         {N_("/_Message/Reply to a_ll"),         "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
477         {N_("/_Message/Reply to author"),       NULL, reply_cb, COMPOSE_REPLY_TO_AUTHOR, NULL},
478         {N_("/_Message/_Forward"),              "<control>F",   reply_cb, COMPOSE_FORWARD, NULL},
479         {N_("/_Message/Forward as an a_ttachment"),
480                                                 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
481         {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
482         {N_("/_Message/M_ove..."),              "<alt>O", move_to_cb, 0, NULL},
483         {N_("/_Message/_Copy..."),              NULL, copy_to_cb, 0, NULL},
484         {N_("/_Message/_Delete"),               "<alt>D", delete_cb,  0, NULL},
485         {N_("/_Message/_Mark"),                 NULL, NULL, 0, "<Branch>"},
486         {N_("/_Message/_Mark/_Mark"),           NULL, mark_cb,   0, NULL},
487         {N_("/_Message/_Mark/_Unmark"),         NULL, unmark_cb, 0, NULL},
488         {N_("/_Message/_Mark/---"),             NULL, NULL, 0, "<Separator>"},
489         {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
490         {N_("/_Message/_Mark/Mark it as _being read"),
491                                                 NULL, mark_as_read_cb, 0, NULL},
492         {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
493         {N_("/_Message/Open in new _window"),   "<shift><control>N", open_msg_cb, 0, NULL},
494         {N_("/_Message/View _source"),          "<control>U", view_source_cb, 0, NULL},
495         {N_("/_Message/Show all _header"),      "<control>H",   header_window_show_cb,  0, NULL},
496         {N_("/_Message/Re_edit"),               NULL, reedit_cb, 0, NULL},
497
498         {N_("/_Summary"),                       NULL, NULL, 0, "<Branch>"},
499         {N_("/_Summary/_Delete duplicated messages"),
500                                                 NULL, delete_duplicated_cb,   0, NULL},
501         {N_("/_Summary/_Filter messages"),      NULL, filter_cb, 0, NULL},
502         {N_("/_Summary/E_xecute"),              "<alt>X", execute_summary_cb, 0, NULL},
503         {N_("/_Summary/_Update"),               "<alt>U", update_summary_cb,  0, NULL},
504         {N_("/_Summary/---"),                   NULL, NULL, 0, "<Separator>"},
505         {N_("/_Summary/_Prev message"),         NULL, prev_cb, 0, NULL},
506         {N_("/_Summary/_Next message"),         NULL, next_cb, 0, NULL},
507         {N_("/_Summary/N_ext unread message"),  NULL, next_unread_cb, 0, NULL},
508         {N_("/_Summary/Prev marked message"),   NULL, prev_marked_cb, 0, NULL},
509         {N_("/_Summary/Next marked message"),   NULL, next_marked_cb, 0, NULL},
510         {N_("/_Summary/---"),                   NULL, NULL, 0, "<Separator>"},
511         {N_("/_Summary/_Go to other folder"),   "<alt>G", goto_folder_cb, 0, NULL},
512         {N_("/_Summary/---"),                   NULL, NULL, 0, "<Separator>"},
513         {N_("/_Summary/_Sort"),                 NULL, NULL, 0, "<Branch>"},
514         {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
515         {N_("/_Summary/_Sort/Sort by s_ize"),   NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
516         {N_("/_Summary/_Sort/Sort by _date"),   NULL, sort_summary_cb, SORT_BY_DATE, NULL},
517         {N_("/_Summary/_Sort/Sort by _from"),   NULL, sort_summary_cb, SORT_BY_FROM, NULL},
518         {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
519         {N_("/_Summary/_Sort/Sort by sco_re"),  NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
520         {N_("/_Summary/_Sort/---"),             NULL, NULL, 0, "<Separator>"},
521         {N_("/_Summary/_Sort/_Attract by subject"),
522                                                 NULL, attract_by_subject_cb, 0, NULL},
523         {N_("/_Summary/_Thread view"),          "<control>T",        thread_cb, 0, NULL},
524         {N_("/_Summary/Unt_hread view"),        "<shift><control>T", thread_cb, 1, NULL},
525         {N_("/_Summary/Set display _item..."),  NULL, set_display_item_cb, 0, NULL},
526
527         {N_("/_Tool"),                          NULL, NULL, 0, "<Branch>"},
528         {N_("/_Tool/_Address book"),            "<alt>A", addressbook_open_cb, 0, NULL},
529         {N_("/_Tool/_Log window"),              "<alt>L", log_window_show_cb, 0, NULL},
530
531         {N_("/_Configuration"),                 NULL, NULL, 0, "<Branch>"},
532         {N_("/_Configuration/_Common preferences..."),
533                                                 NULL, prefs_common_open_cb, 0, NULL},
534         {N_("/_Configuration/_Filter setting..."),
535                                                 NULL, prefs_filter_open_cb, 0, NULL},
536         {N_("/_Configuration/_Scoring ..."),
537                                                 NULL, prefs_scoring_open_cb, 0, NULL},
538         {N_("/_Configuration/_Filtering ..."),
539                                                 NULL, prefs_filtering_open_cb, 0, NULL},
540         {N_("/_Configuration/_Preferences per account..."),
541                                                 NULL, prefs_account_open_cb, 0, NULL},
542         {N_("/_Configuration/---"),             NULL, NULL, 0, "<Separator>"},
543         {N_("/_Configuration/Create _new account..."),
544                                                 NULL, new_account_cb, 0, NULL},
545         {N_("/_Configuration/_Edit accounts..."),
546                                                 NULL, account_edit_open, 0, NULL},
547         {N_("/_Configuration/C_hange current account"),
548                                                 NULL, NULL, 0, "<Branch>"},
549
550         {N_("/_Help"),                          NULL, NULL, 0, "<LastBranch>"},
551         {N_("/_Help/_Manual"),                  NULL, NULL, 0, "<Branch>"},
552         {N_("/_Help/_Manual/_English"),         NULL, NULL, MANUAL_LANG_EN, NULL},
553         {N_("/_Help/_Manual/_Japanese"),        NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
554         {N_("/_Help/---"),                      NULL, NULL, 0, "<Separator>"},
555         {N_("/_Help/_About"),                   NULL, about_show, 0, NULL}
556 };
557
558 MainWindow *main_window_create(SeparateType type)
559 {
560         MainWindow *mainwin;
561         GtkWidget *window;
562         GtkWidget *vbox;
563         GtkWidget *menubar;
564         GtkWidget *handlebox;
565         GtkWidget *vbox_body;
566         GtkWidget *hbox_stat;
567         GtkWidget *statusbar;
568         GtkWidget *ac_button;
569         GtkWidget *ac_label;
570
571         FolderView *folderview;
572         SummaryView *summaryview;
573         MessageView *messageview;
574         GdkColormap *colormap;
575         GdkColor color[5];
576         gboolean success[5];
577         guint n_menu_entries;
578         GtkItemFactory *ifactory;
579         GtkWidget *ac_menu;
580         GtkWidget *menuitem;
581         gint i;
582
583         debug_print(_("Creating main window...\n"));
584         mainwin = g_new0(MainWindow, 1);
585
586         /* main window */
587         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
588         gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
589         gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
590         gtk_signal_connect(GTK_OBJECT(window), "delete_event",
591                            GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
592         gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
593                            GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
594         gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
595                            GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
596         gtk_widget_realize(window);
597
598         vbox = gtk_vbox_new(FALSE, 0);
599         gtk_widget_show(vbox);
600         gtk_container_add(GTK_CONTAINER(window), vbox);
601
602         /* menu bar */
603         n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
604         menubar = menubar_create(window, mainwin_entries, 
605                                  n_menu_entries, "<Main>", mainwin);
606
607         gtk_widget_show(menubar);
608         gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
609
610         handlebox = gtk_handle_box_new();
611         gtk_widget_show(handlebox);
612         gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
613
614         main_window_toolbar_create(mainwin, handlebox);
615
616         /* vbox that contains body */
617         vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
618         gtk_widget_show(vbox_body);
619         gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
620         gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
621
622         hbox_stat = gtk_hbox_new(FALSE, 2);
623         gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
624
625         statusbar = statusbar_create();
626         gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
627
628         ac_button = gtk_button_new();
629         gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
630         GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
631         gtk_widget_set_usize(ac_button, -1, 1);
632         gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
633         gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
634                            GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
635
636         ac_label = gtk_label_new("");
637         gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
638
639         gtk_widget_show_all(hbox_stat);
640
641         /* create views */
642         mainwin->folderview  = folderview  = folderview_create();
643         mainwin->summaryview = summaryview = summary_create();
644         mainwin->messageview = messageview = messageview_create();
645         mainwin->headerwin   = header_window_create();
646         mainwin->logwin      = log_window_create();
647
648         folderview->mainwin      = mainwin;
649         folderview->summaryview  = summaryview;
650
651         summaryview->mainwin     = mainwin;
652         summaryview->folderview  = folderview;
653         summaryview->messageview = messageview;
654         summaryview->headerwin   = mainwin->headerwin;
655         summaryview->window      = window;
656
657         messageview->mainwin     = mainwin;
658
659         mainwin->window    = window;
660         mainwin->vbox      = vbox;
661         mainwin->menubar   = menubar;
662         mainwin->handlebox = handlebox;
663         mainwin->vbox_body = vbox_body;
664         mainwin->hbox_stat = hbox_stat;
665         mainwin->statusbar = statusbar;
666         mainwin->ac_button = ac_button;
667         mainwin->ac_label  = ac_label;
668
669         /* set context IDs for status bar */
670         mainwin->mainwin_cid = gtk_statusbar_get_context_id
671                 (GTK_STATUSBAR(statusbar), "Main Window");
672         mainwin->folderview_cid = gtk_statusbar_get_context_id
673                 (GTK_STATUSBAR(statusbar), "Folder View");
674         mainwin->summaryview_cid = gtk_statusbar_get_context_id
675                 (GTK_STATUSBAR(statusbar), "Summary View");
676
677         /* allocate colors for summary view and folder view */
678         summaryview->color_marked.red = summaryview->color_marked.green = 0;
679         summaryview->color_marked.blue = (guint16)65535;
680
681         summaryview->color_dim.red = summaryview->color_dim.green =
682                 summaryview->color_dim.blue = COLOR_DIM;
683
684         summaryview->color_normal.red = summaryview->color_normal.green =
685                 summaryview->color_normal.blue = 0;
686
687         folderview->color_new.red = (guint16)55000;
688         folderview->color_new.green = folderview->color_new.blue = 15000;
689
690         folderview->color_normal.red = folderview->color_normal.green =
691                 folderview->color_normal.blue = 0;
692
693         color[0] = summaryview->color_marked;
694         color[1] = summaryview->color_dim;
695         color[2] = summaryview->color_normal;
696         color[3] = folderview->color_new;
697         color[4] = folderview->color_normal;
698
699         colormap = gdk_window_get_colormap(window->window);
700         gdk_colormap_alloc_colors(colormap, color, 5, FALSE, TRUE, success);
701         for (i = 0; i < 5; i++) {
702                 if (success[i] == FALSE)
703                         g_warning(_("MainWindow: color allocation %d failed\n"), i);
704         }
705
706         debug_print(_("done.\n"));
707
708         main_window_set_widgets(mainwin, type);
709
710         /* set menu items */
711         ifactory = gtk_item_factory_from_widget(menubar);
712         menuitem = gtk_item_factory_get_item
713                 (ifactory, "/View/Code set/Auto detect");
714         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
715
716         switch (prefs_common.toolbar_style) {
717         case TOOLBAR_NONE:
718                 menuitem = gtk_item_factory_get_item
719                         (ifactory, "/View/Toolbar/Non-display");
720                 break;
721         case TOOLBAR_ICON:
722                 menuitem = gtk_item_factory_get_item
723                         (ifactory, "/View/Toolbar/Icon");
724                 break;
725         case TOOLBAR_TEXT:
726                 menuitem = gtk_item_factory_get_item
727                         (ifactory, "/View/Toolbar/Text");
728                 break;
729         case TOOLBAR_BOTH:
730                 menuitem = gtk_item_factory_get_item
731                         (ifactory, "/View/Toolbar/Icon and text");
732         }
733         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
734
735         gtk_widget_hide(mainwin->hbox_stat);
736         menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
737         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
738                                        prefs_common.show_statusbar);
739
740         /* set the check of the SEPARATE_xxx menu items. we also need the main window
741          * as a property and pass the action type to the callback */
742         menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
743         g_assert(menuitem);
744         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
745         gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
746         gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb), 
747                                            GUINT_TO_POINTER(SEPARATE_FOLDER));
748
749         menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
750         g_assert(menuitem);
751         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
752         gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
753         gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb), 
754                                            GUINT_TO_POINTER(SEPARATE_MESSAGE));
755
756         menu_set_sensitive(ifactory, "/Summary/Thread view",
757                            prefs_common.enable_thread ? FALSE : TRUE);
758         menu_set_sensitive(ifactory, "/Summary/Unthread view",
759                            prefs_common.enable_thread ? TRUE : FALSE);
760         menu_set_sensitive(ifactory, "/Help/Manual/English", FALSE);
761
762         /* set account selection menu */
763         ac_menu = gtk_item_factory_get_widget
764                 (ifactory, "/Configuration/Change current account");
765         mainwin->ac_menu = ac_menu;
766
767         main_window_set_toolbar_sensitive(mainwin, FALSE);
768
769         /* show main window */
770         gtk_widget_set_uposition(mainwin->window,
771                                  prefs_common.mainwin_x,
772                                  prefs_common.mainwin_y);
773         gtk_widget_set_usize(window, prefs_common.mainwin_width,
774                              prefs_common.mainwin_height);
775         gtk_widget_show(mainwin->window);
776
777         /* initialize views */
778         folderview_init(folderview);
779         summary_init(summaryview);
780         messageview_init(messageview);
781         header_window_init(mainwin->headerwin);
782         log_window_init(mainwin->logwin);
783
784         mainwin->cursor_count = 0;
785
786         if (!watch_cursor)
787                 watch_cursor = gdk_cursor_new(GDK_WATCH);
788
789         mainwin_list = g_list_append(mainwin_list, mainwin);
790
791         return mainwin;
792 }
793
794 void main_window_cursor_wait(MainWindow *mainwin)
795 {
796         if (mainwin->cursor_count == 0)
797                 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
798
799         mainwin->cursor_count++;
800
801         gdk_flush();
802 }
803
804 void main_window_cursor_normal(MainWindow *mainwin)
805 {
806         if (mainwin->cursor_count)
807                 mainwin->cursor_count--;
808
809         if (mainwin->cursor_count == 0)
810                 gdk_window_set_cursor(mainwin->window->window, NULL);
811
812         gdk_flush();
813 }
814
815 void main_window_reflect_prefs_all(void)
816 {
817         GList *cur;
818         MainWindow *mainwin;
819
820         for (cur = mainwin_list; cur != NULL; cur = cur->next) {
821                 mainwin = (MainWindow *)cur->data;
822
823                 main_window_show_cur_account(mainwin);
824                 if (cur_account) {
825                         gtk_widget_set_sensitive(mainwin->get_btn,    TRUE);
826                         gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
827                 } else {
828                         gtk_widget_set_sensitive(mainwin->get_btn,    FALSE);
829                         gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
830                 }
831                 if (prefs_common.immediate_exec)
832                         gtk_widget_hide(mainwin->exec_btn);
833                 else
834                         gtk_widget_show(mainwin->exec_btn);
835
836                 summary_change_display_item(mainwin->summaryview);
837                 summary_redisplay_msg(mainwin->summaryview);
838                 headerview_set_visibility(mainwin->messageview->headerview,
839                                           prefs_common.display_header_pane);
840         }
841 }
842
843 void main_window_set_account_menu(GList *account_list)
844 {
845         GList *cur, *cur_ac, *cur_item;
846         GtkWidget *menuitem;
847         MainWindow *mainwin;
848         PrefsAccount *ac_prefs;
849
850         for (cur = mainwin_list; cur != NULL; cur = cur->next) {
851                 mainwin = (MainWindow *)cur->data;
852
853                 /* destroy all previous menu item */
854                 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
855                 while (cur_item != NULL) {
856                         GList *next = cur_item->next;
857                         gtk_widget_destroy(GTK_WIDGET(cur_item->data));
858                         cur_item = next;
859                 }
860
861                 for (cur_ac = account_list; cur_ac != NULL;
862                      cur_ac = cur_ac->next) {
863                         ac_prefs = (PrefsAccount *)cur_ac->data;
864
865                         menuitem = gtk_menu_item_new_with_label
866                                 (ac_prefs->account_name
867                                  ? ac_prefs->account_name : _("Untitled"));
868                         gtk_widget_show(menuitem);
869                         gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
870                         gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
871                                            GTK_SIGNAL_FUNC(account_menu_cb),
872                                            ac_prefs);
873                 }
874         }
875 }
876
877 static void main_window_show_cur_account(MainWindow *mainwin)
878 {
879         gchar *buf;
880         gchar *ac_name;
881
882         ac_name = g_strdup(cur_account
883                            ? (cur_account->account_name
884                               ? cur_account->account_name : _("Untitled"))
885                            : _("none"));
886
887         if (cur_account)
888                 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
889         else
890                 buf = g_strdup(PROG_VERSION);
891         gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
892         g_free(buf);
893
894         buf = g_strdup_printf(_("Current account: %s"), ac_name);
895         gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
896         gtk_widget_queue_resize(mainwin->ac_button);
897         g_free(buf);
898
899         g_free(ac_name);
900 }
901
902 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
903 {
904         GtkWidget *folder_wid  = GTK_WIDGET_PTR(mainwin->folderview);
905         GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
906         GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
907
908         if (mainwin->type == type) return;
909
910         /* remove widgets from those containers */
911         gtk_widget_ref(folder_wid);
912         gtk_widget_ref(summary_wid);
913         gtk_widget_ref(message_wid);
914         gtk_container_remove
915                 (GTK_CONTAINER(folder_wid->parent), folder_wid);
916         gtk_container_remove
917                 (GTK_CONTAINER(summary_wid->parent), summary_wid);
918         gtk_container_remove
919                 (GTK_CONTAINER(message_wid->parent), message_wid);
920
921         /* clean containers */
922         switch (mainwin->type) {
923         case SEPARATE_NONE:
924                 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
925                 break;
926         case SEPARATE_FOLDER:
927                 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
928                 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
929                 break;
930         case SEPARATE_MESSAGE:
931                 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
932                 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
933                 break;
934         case SEPARATE_BOTH:
935                 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
936                 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
937                 break;
938         }
939
940         gtk_widget_hide(mainwin->window);
941         main_window_set_widgets(mainwin, type);
942         gtk_widget_show(mainwin->window);
943
944         gtk_widget_unref(folder_wid);
945         gtk_widget_unref(summary_wid);
946         gtk_widget_unref(message_wid);
947 }
948
949 void main_window_get_size(MainWindow *mainwin)
950 {
951         GtkAllocation *allocation;
952
953         allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
954
955         prefs_common.summaryview_width  = allocation->width;
956
957         if (mainwin->summaryview->msg_is_toggled_on)
958                 prefs_common.summaryview_height = allocation->height;
959
960         prefs_common.mainview_width     = allocation->width;
961
962         allocation = &mainwin->window->allocation;
963
964         prefs_common.mainview_height = allocation->height;
965         prefs_common.mainwin_width   = allocation->width;
966         prefs_common.mainwin_height  = allocation->height;
967
968         allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
969
970         prefs_common.folderview_width  = allocation->width;
971         prefs_common.folderview_height = allocation->height;
972 }
973
974 void main_window_get_position(MainWindow *mainwin)
975 {
976         gint x, y;
977
978         gtkut_widget_get_uposition(mainwin->window, &x, &y);
979
980         prefs_common.mainview_x = x;
981         prefs_common.mainview_y = y;
982         prefs_common.mainwin_x = x;
983         prefs_common.mainwin_y = y;
984
985         debug_print(_("window position: x = %d, y = %d\n"), x, y);
986 }
987
988 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
989 {
990         GList *list;
991
992         if (confirm) {
993                 if (alertpanel(_("Empty trash"),
994                                _("Empty all messages in trash?"),
995                                _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
996                         return;
997                 manage_window_focus_in(mainwin->window, NULL, NULL);
998         }
999
1000         procmsg_empty_trash();
1001
1002         for (list = folder_get_list(); list != NULL; list = list->next) {
1003                 Folder *folder;
1004
1005                 folder = list->data;
1006                 if (folder->trash) {
1007                         folder_item_scan(folder->trash);
1008                         folderview_update_item(folder->trash, TRUE);
1009                 }
1010         }
1011
1012         if (mainwin->summaryview->folder_item &&
1013             mainwin->summaryview->folder_item->stype == F_TRASH)
1014                 gtk_widget_grab_focus(mainwin->folderview->ctree);
1015 }
1016
1017 void main_window_add_mailbox(MainWindow *mainwin)
1018 {
1019         gchar *path;
1020         Folder *folder;
1021
1022         path = input_dialog(_("Add mailbox"),
1023                             _("Input the location of mailbox.\n"
1024                               "If the existing mailbox is specified, it will be\n"
1025                               "scanned automatically."),
1026                             "Mail");
1027         if (!path) return;
1028         if (folder_find_from_path(path)) {
1029                 alertpanel_error(_("The mailbox `%s' already exists."), path);
1030                 g_free(path);
1031                 return;
1032         }
1033         if (!strcmp(path, "Mail"))
1034                 folder = folder_new(F_MH, _("Mailbox"), path);
1035         else
1036                 folder = folder_new(F_MH, g_basename(path), path);
1037         g_free(path);
1038
1039         if (folder->create_tree(folder) < 0) {
1040                 alertpanel_error(_("Creation of the mailbox failed.\n"
1041                                    "Maybe some files already exist, or you don't have the permission to write there."));
1042                 folder_destroy(folder);
1043                 return;
1044         }
1045
1046         folder_add(folder);
1047         folder_set_ui_func(folder, scan_tree_func, mainwin);
1048         folder->scan_tree(folder);
1049         folder_set_ui_func(folder, NULL, NULL);
1050
1051         folderview_set(mainwin->folderview);
1052 }
1053
1054 void main_window_add_mbox(MainWindow *mainwin)
1055 {
1056         gchar *path;
1057         Folder *folder;
1058         FolderItem * item;
1059
1060         path = input_dialog(_("Add mbox mailbox"),
1061                             _("Input the location of mailbox."),
1062                             "mail");
1063
1064         if (!path) return;
1065
1066         /*
1067         if (folder_find_from_path(path)) {
1068                 alertpanel_error(_("The mailbox `%s' already exists."), path);
1069                 g_free(path);
1070                 return;
1071         }
1072         */
1073
1074         /*
1075         if (!strcmp(path, "Mail"))
1076                 folder = folder_new(F_MBOX, _("Mailbox"), path);
1077                 else
1078         */
1079
1080         folder = folder_new(F_MBOX, g_basename(path), path);
1081         g_free(path);
1082
1083         if (folder->create_tree(folder) < 0) {
1084                 alertpanel_error(_("Creation of the mailbox failed."));
1085                 folder_destroy(folder);
1086                 return;
1087         }
1088
1089         folder_add(folder);
1090
1091         item = folder_item_new(folder->name, NULL);
1092         item->folder = folder;
1093         folder->node = g_node_new(item);
1094
1095         mbox_create_folder(folder, item, "inbox");
1096         mbox_create_folder(folder, item, "outbox");
1097         mbox_create_folder(folder, item, "queue");
1098         mbox_create_folder(folder, item, "draft");
1099         mbox_create_folder(folder, item, "trash");
1100
1101         folderview_set(mainwin->folderview);
1102 }
1103
1104 void main_window_set_toolbar_sensitive(MainWindow *mainwin, gboolean sensitive)
1105 {
1106         gtk_widget_set_sensitive(mainwin->reply_btn,       sensitive);
1107         gtk_widget_set_sensitive(mainwin->replyall_btn,    sensitive);
1108         gtk_widget_set_sensitive(mainwin->replyauthor_btn, sensitive);
1109         gtk_widget_set_sensitive(mainwin->fwd_btn,         sensitive);
1110         gtk_widget_set_sensitive(mainwin->exec_btn,        sensitive);
1111         gtk_widget_set_sensitive(mainwin->next_btn,        sensitive);
1112
1113         if (!mainwin->summaryview->folder_item ||
1114             mainwin->summaryview->folder_item->folder->type == F_NEWS)
1115                 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1116         else
1117                 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1118 }
1119
1120 void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
1121 {
1122         GtkItemFactory *ifactory;
1123         gboolean sens;
1124         gboolean exec;
1125
1126         ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1127
1128         if (selection == SUMMARY_SELECTED_SINGLE)
1129                 sens = TRUE;
1130         else
1131                 sens = FALSE;
1132         if (!mainwin->summaryview->folder_item ||
1133             mainwin->summaryview->folder_item->folder->type == F_NEWS)
1134                 exec = FALSE;
1135         else
1136                 exec = TRUE;
1137
1138         menu_set_sensitive(ifactory, "/File/Save as...", sens);
1139         menu_set_sensitive(ifactory, "/Message/Reply", sens);
1140         menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
1141         menu_set_sensitive(ifactory, "/Message/Reply to author", sens);
1142         menu_set_sensitive(ifactory, "/Message/Forward", sens);
1143         menu_set_sensitive(ifactory, "/Message/Forward as an attachment", sens);
1144         menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
1145         menu_set_sensitive(ifactory, "/Message/Show all header", sens);
1146         menu_set_sensitive(ifactory, "/Message/View source", sens);
1147         if (sens && (!mainwin->summaryview->folder_item ||
1148                      mainwin->summaryview->folder_item->stype != F_DRAFT))
1149                 sens = FALSE;
1150         menu_set_sensitive(ifactory, "/Message/Reedit", sens);
1151
1152         if (selection == SUMMARY_SELECTED_SINGLE ||
1153             selection == SUMMARY_SELECTED_MULTIPLE)
1154                 sens = TRUE;
1155         else
1156                 sens = FALSE;
1157
1158         menu_set_sensitive(ifactory, "/File/Print..."  , sens);
1159         menu_set_sensitive(ifactory, "/Message/Move...", sens && exec);
1160         menu_set_sensitive(ifactory, "/Message/Copy...", sens && exec);
1161         menu_set_sensitive(ifactory, "/Message/Delete" , sens && exec);
1162         menu_set_sensitive(ifactory, "/Message/Mark"   , sens);
1163
1164         if (selection != SUMMARY_NONE)
1165                 sens = TRUE;
1166         else
1167                 sens = FALSE;
1168
1169         menu_set_sensitive(ifactory, "/Summary/Delete duplicated messages", sens && exec);
1170         menu_set_sensitive(ifactory, "/Summary/Filter messages", sens && exec);
1171         menu_set_sensitive(ifactory, "/Summary/Execute", sens);
1172         menu_set_sensitive(ifactory, "/Summary/Prev message", sens);
1173         menu_set_sensitive(ifactory, "/Summary/Next message", sens);
1174         menu_set_sensitive(ifactory, "/Summary/Next unread message", sens);
1175         menu_set_sensitive(ifactory, "/Summary/Sort", sens);
1176 }
1177
1178 void main_window_popup(MainWindow *mainwin)
1179 {
1180         gint x, y;
1181         gint sx, sy;
1182         GtkWidget *widget;
1183
1184         gdk_window_get_origin(mainwin->window->window, &x, &y);
1185         sx = gdk_screen_width();
1186         sy = gdk_screen_height();
1187         x %= sx; if (x < 0) x += sx;
1188         y %= sy; if (y < 0) y += sy;
1189         gdk_window_move(mainwin->window->window, x, y);
1190         gdk_window_raise(mainwin->window->window);
1191
1192         debug_print("window position: x = %d, y = %d\n", x, y);
1193
1194         switch (mainwin->type) {
1195         case SEPARATE_FOLDER:
1196                 widget = mainwin->win.sep_folder.folderwin;
1197                 gdk_window_get_origin(widget->window, &x, &y);
1198                 x %= sx; if (x < 0) x += sx;
1199                 y %= sy; if (y < 0) y += sy;
1200                 gdk_window_move(widget->window, x, y);
1201                 gdk_window_raise(widget->window);
1202                 break;
1203         case SEPARATE_MESSAGE:
1204                 widget = mainwin->win.sep_message.messagewin;
1205                 gdk_window_get_origin(widget->window, &x, &y);
1206                 x %= sx; if (x < 0) x += sx;
1207                 y %= sy; if (y < 0) y += sy;
1208                 gdk_window_move(widget->window, x, y);
1209                 gdk_window_raise(widget->window);
1210                 break;
1211         case SEPARATE_BOTH:
1212                 widget = mainwin->win.sep_both.folderwin;
1213                 gdk_window_get_origin(widget->window, &x, &y);
1214                 x %= sx; if (x < 0) x += sx;
1215                 y %= sy; if (y < 0) y += sy;
1216                 gdk_window_move(widget->window, x, y);
1217                 gdk_window_raise(widget->window);
1218                 widget = mainwin->win.sep_both.messagewin;
1219                 gdk_window_get_origin(widget->window, &x, &y);
1220                 x %= sx; if (x < 0) x += sx;
1221                 y %= sy; if (y < 0) y += sy;
1222                 gdk_window_move(widget->window, x, y);
1223                 gdk_window_raise(widget->window);
1224                 break;
1225         default:
1226         }
1227 }
1228
1229 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1230 {
1231         GtkWidget *folderwin = NULL;
1232         GtkWidget *messagewin = NULL;
1233         GtkWidget *hpaned;
1234         GtkWidget *vpaned;
1235         GtkWidget *vbox_body = mainwin->vbox_body;
1236
1237         debug_print(_("Setting widgets..."));
1238
1239         /* create separated window(s) if needed */
1240         if (type & SEPARATE_FOLDER) {
1241                 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1242                 gtk_window_set_policy(GTK_WINDOW(folderwin),
1243                                       TRUE, TRUE, FALSE);
1244                 gtk_widget_set_usize(folderwin, -1,
1245                                      prefs_common.mainview_height);
1246                 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1247                                                BORDER_WIDTH);
1248                 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1249                                    GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1250                                    NULL);
1251         }
1252         if (type & SEPARATE_MESSAGE) {
1253                 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1254                 gtk_window_set_policy(GTK_WINDOW(messagewin),
1255                                       TRUE, TRUE, FALSE);
1256                 gtk_widget_set_usize
1257                         (messagewin, prefs_common.mainview_width,
1258                          prefs_common.mainview_height
1259                          - prefs_common.summaryview_height
1260                          + DEFAULT_HEADERVIEW_HEIGHT);
1261                 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1262                                                BORDER_WIDTH);
1263                 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1264                                    GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1265                                    NULL);
1266         }
1267
1268         switch (type) {
1269         case SEPARATE_NONE:
1270                 hpaned = gtk_hpaned_new();
1271                 gtk_widget_show(hpaned);
1272                 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1273                 gtk_paned_add1(GTK_PANED(hpaned),
1274                                GTK_WIDGET_PTR(mainwin->folderview));
1275
1276                 vpaned = gtk_vpaned_new();
1277                 if (mainwin->summaryview->msg_is_toggled_on) {
1278                         gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1279                         gtk_paned_add1(GTK_PANED(vpaned),
1280                                        GTK_WIDGET_PTR(mainwin->summaryview));
1281                 } else {
1282                         gtk_paned_add2(GTK_PANED(hpaned),
1283                                        GTK_WIDGET_PTR(mainwin->summaryview));
1284                         gtk_widget_ref(vpaned);
1285                 }
1286                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1287                                      prefs_common.summaryview_width,
1288                                      prefs_common.summaryview_height);
1289                 gtk_paned_add2(GTK_PANED(vpaned),
1290                                GTK_WIDGET_PTR(mainwin->messageview));
1291                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1292                                      prefs_common.mainview_width, -1);
1293                 gtk_widget_set_usize(mainwin->window,
1294                                      prefs_common.folderview_width +
1295                                      prefs_common.mainview_width,
1296                                      prefs_common.mainwin_height);
1297                 gtk_widget_show_all(vpaned);
1298
1299                 mainwin->win.sep_none.hpaned = hpaned;
1300                 mainwin->win.sep_none.vpaned = vpaned;
1301                 break;
1302         case SEPARATE_FOLDER:
1303                 vpaned = gtk_vpaned_new();
1304                 if (mainwin->summaryview->msg_is_toggled_on) {
1305                         gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1306                                            TRUE, TRUE, 0);
1307                         gtk_paned_add1(GTK_PANED(vpaned),
1308                                        GTK_WIDGET_PTR(mainwin->summaryview));
1309                 } else {
1310                         gtk_box_pack_start(GTK_BOX(vbox_body),
1311                                            GTK_WIDGET_PTR(mainwin->summaryview),
1312                                            TRUE, TRUE, 0);
1313                         gtk_widget_ref(vpaned);
1314                 }
1315                 gtk_paned_add2(GTK_PANED(vpaned),
1316                                GTK_WIDGET_PTR(mainwin->messageview));
1317                 gtk_widget_show_all(vpaned);
1318                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1319                                      prefs_common.summaryview_width,
1320                                      prefs_common.summaryview_height);
1321                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1322                                      prefs_common.mainview_width, -1);
1323                 gtk_widget_set_usize(mainwin->window,
1324                                      prefs_common.mainview_width,
1325                                      prefs_common.mainview_height);
1326
1327                 gtk_container_add(GTK_CONTAINER(folderwin),
1328                                   GTK_WIDGET_PTR(mainwin->folderview));
1329
1330                 mainwin->win.sep_folder.folderwin = folderwin;
1331                 mainwin->win.sep_folder.vpaned    = vpaned;
1332
1333                 gtk_widget_show_all(folderwin);
1334                 break;
1335         case SEPARATE_MESSAGE:
1336                 hpaned = gtk_hpaned_new();
1337                 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1338
1339                 gtk_paned_add1(GTK_PANED(hpaned),
1340                                GTK_WIDGET_PTR(mainwin->folderview));
1341                 gtk_paned_add2(GTK_PANED(hpaned),
1342                                GTK_WIDGET_PTR(mainwin->summaryview));
1343                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1344                                      prefs_common.summaryview_width,
1345                                      prefs_common.summaryview_height);
1346                 gtk_widget_set_usize(mainwin->window,
1347                                      prefs_common.folderview_width +
1348                                      prefs_common.mainview_width,
1349                                      prefs_common.mainwin_height);
1350                 gtk_widget_show_all(hpaned);
1351                 gtk_container_add(GTK_CONTAINER(messagewin),
1352                                   GTK_WIDGET_PTR(mainwin->messageview));
1353
1354                 mainwin->win.sep_message.messagewin = messagewin;
1355                 mainwin->win.sep_message.hpaned     = hpaned;
1356
1357                 gtk_widget_show_all(messagewin);
1358                 break;
1359         case SEPARATE_BOTH:
1360                 gtk_box_pack_start(GTK_BOX(vbox_body),
1361                                    GTK_WIDGET_PTR(mainwin->summaryview),
1362                                    TRUE, TRUE, 0);
1363                 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1364                                      prefs_common.summaryview_width,
1365                                      prefs_common.summaryview_height);
1366                 gtk_widget_set_usize(mainwin->window,
1367                                      prefs_common.mainview_width,
1368                                      prefs_common.mainwin_height);
1369                 gtk_container_add(GTK_CONTAINER(folderwin),
1370                                   GTK_WIDGET_PTR(mainwin->folderview));
1371                 gtk_container_add(GTK_CONTAINER(messagewin),
1372                                   GTK_WIDGET_PTR(mainwin->messageview));
1373
1374                 mainwin->win.sep_both.folderwin = folderwin;
1375                 mainwin->win.sep_both.messagewin = messagewin;
1376
1377                 gtk_widget_show_all(folderwin);
1378                 gtk_widget_show_all(messagewin);
1379                 break;
1380         }
1381
1382         mainwin->type = type;
1383
1384         debug_print(_("done.\n"));
1385 }
1386
1387 #include "pixmaps/stock_mail_receive.xpm"
1388 #include "pixmaps/stock_mail_receive_all.xpm"
1389 #include "pixmaps/stock_mail_compose.xpm"
1390 #include "pixmaps/stock_mail_reply.xpm"
1391 #include "pixmaps/stock_mail_reply_to_all.xpm"
1392 #include "pixmaps/stock_mail_reply_to_author.xpm"
1393 #include "pixmaps/stock_mail_forward.xpm"
1394 #include "pixmaps/stock_mail_send.xpm"
1395 #include "pixmaps/stock_preferences.xpm"
1396 #include "pixmaps/stock_properties.xpm"
1397 #include "pixmaps/stock_down_arrow.xpm"
1398 #include "pixmaps/stock_close.xpm"
1399 #include "pixmaps/stock_exec.xpm"
1400
1401 #define CREATE_TOOLBAR_ICON(xpm_d) \
1402 { \
1403         icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1404                                             &container->style->white, \
1405                                             xpm_d); \
1406         icon_wid = gtk_pixmap_new(icon, mask); \
1407 }
1408
1409 static void main_window_toolbar_create(MainWindow *mainwin,
1410                                        GtkWidget *container)
1411 {
1412         GtkWidget *toolbar;
1413         GdkPixmap *icon;
1414         GdkBitmap *mask;
1415         GtkWidget *icon_wid;
1416         GtkWidget *get_btn;
1417         GtkWidget *getall_btn;
1418         GtkWidget *compose_btn;
1419         GtkWidget *reply_btn;
1420         GtkWidget *replyall_btn;
1421         GtkWidget *replyauthor_btn;
1422         GtkWidget *fwd_btn;
1423         GtkWidget *send_btn;
1424         /*
1425         GtkWidget *prefs_btn;
1426         GtkWidget *account_btn;
1427         */
1428         GtkWidget *next_btn;
1429         GtkWidget *delete_btn;
1430         GtkWidget *exec_btn;
1431
1432         toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1433                                   GTK_TOOLBAR_BOTH);
1434         gtk_container_add(GTK_CONTAINER(container), toolbar);
1435         gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1436         gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1437         gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1438                                     GTK_TOOLBAR_SPACE_LINE);
1439
1440         CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1441         get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1442                                           _("Get"),
1443                                           _("Incorporate new mail"),
1444                                           "Get",
1445                                           icon_wid, toolbar_inc_cb, mainwin);
1446         CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1447         getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1448                                              _("Get all"),
1449                                              _("Incorporate new mail of all accounts"),
1450                                              "Get all",
1451                                              icon_wid,
1452                                              toolbar_inc_all_cb,
1453                                              mainwin);
1454
1455         gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1456
1457         CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1458         send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1459                                            _("Send"),
1460                                            _("Send queued message(s)"),
1461                                            "Send",
1462                                            icon_wid,
1463                                            toolbar_send_cb,
1464                                            mainwin);
1465
1466         gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1467
1468         CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1469         compose_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1470                                               _("Compose"),
1471                                               _("Compose new message"),
1472                                               "New",
1473                                               icon_wid,
1474                                               toolbar_compose_cb,
1475                                               mainwin);
1476         CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1477         reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1478                                             _("Reply"),
1479                                             _("Reply to the message"),
1480                                             "Reply",
1481                                             icon_wid,
1482                                             toolbar_reply_cb,
1483                                             mainwin);
1484         CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1485         replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1486                                                _("Reply all"),
1487                                                _("Reply to all"),
1488                                                "Reply to all",
1489                                                icon_wid,
1490                                                toolbar_reply_to_all_cb,
1491                                                mainwin);
1492         CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1493         replyauthor_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1494                                                   _("Reply author"),
1495                                                   _("Reply to author"),
1496                                                   "Reply to author",
1497                                                   icon_wid,
1498                                                   toolbar_reply_to_author_cb,
1499                                                   mainwin);
1500         CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1501         fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1502                                           _("Forward"),
1503                                           _("Forward the message"),
1504                                           "Fwd",
1505                                           icon_wid,
1506                                           toolbar_forward_cb,
1507                                           mainwin);
1508
1509         gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1510
1511         CREATE_TOOLBAR_ICON(stock_close_xpm);
1512         delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1513                                           _("Delete"),
1514                                           _("Delete the message"),
1515                                           "Delete",
1516                                           icon_wid,
1517                                           toolbar_delete_cb,
1518                                           mainwin);
1519
1520         CREATE_TOOLBAR_ICON(stock_exec_xpm);
1521         exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1522                                            _("Execute"),
1523                                            _("Execute marked process"),
1524                                            "Execute",
1525                                            icon_wid,
1526                                            toolbar_exec_cb,
1527                                            mainwin);
1528
1529         gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1530
1531         CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1532         next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1533                                            _("Next"),
1534                                            _("Next unread message"),
1535                                            "Next unread",
1536                                            icon_wid,
1537                                            toolbar_next_unread_cb,
1538                                            mainwin);
1539
1540         /*
1541         gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1542
1543         CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1544         prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1545                                             _("Prefs"),
1546                                             _("Common preference"),
1547                                             "Prefs",
1548                                             icon_wid,
1549                                             toolbar_prefs_cb,
1550                                             mainwin);
1551         CREATE_TOOLBAR_ICON(stock_properties_xpm);
1552         account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1553                                               _("Account"),
1554                                               _("Account setting"),
1555                                               "Account",
1556                                               icon_wid,
1557                                               toolbar_account_cb,
1558                                               mainwin);
1559         gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1560                            GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1561                            mainwin);
1562         */
1563
1564         mainwin->toolbar         = toolbar;
1565         mainwin->get_btn         = get_btn;
1566         mainwin->getall_btn      = getall_btn;
1567         mainwin->compose_btn     = compose_btn;
1568         mainwin->reply_btn       = reply_btn;
1569         mainwin->replyall_btn    = replyall_btn;
1570         mainwin->replyauthor_btn = replyauthor_btn;
1571         mainwin->fwd_btn         = fwd_btn;
1572         mainwin->send_btn        = send_btn;
1573         /*
1574         mainwin->prefs_btn       = prefs_btn;
1575         mainwin->account_btn     = account_btn;
1576         */
1577         mainwin->next_btn        = next_btn;
1578         mainwin->delete_btn      = delete_btn;
1579         mainwin->exec_btn        = exec_btn;
1580
1581         gtk_widget_show_all(toolbar);
1582 }
1583
1584 /* callback functions */
1585
1586 static void toolbar_inc_cb      (GtkWidget      *widget,
1587                                  gpointer        data)
1588 {
1589         MainWindow *mainwin = (MainWindow *)data;
1590
1591         inc_mail_cb(mainwin, 0, NULL);
1592 }
1593
1594 static void toolbar_inc_all_cb  (GtkWidget      *widget,
1595                                  gpointer        data)
1596 {
1597         MainWindow *mainwin = (MainWindow *)data;
1598
1599         inc_all_account_mail_cb(mainwin, 0, NULL);
1600 }
1601
1602 static void toolbar_send_cb     (GtkWidget      *widget,
1603                                  gpointer        data)
1604 {
1605         MainWindow *mainwin = (MainWindow *)data;
1606
1607         send_queue_cb(mainwin, 0, NULL);
1608 }
1609
1610 static void toolbar_compose_cb  (GtkWidget      *widget,
1611                                  gpointer        data)
1612 {
1613         MainWindow *mainwin = (MainWindow *)data;
1614
1615         compose_cb(mainwin, 0, NULL);
1616 }
1617
1618 static void toolbar_reply_cb    (GtkWidget      *widget,
1619                                  gpointer        data)
1620 {
1621         MainWindow *mainwin = (MainWindow *)data;
1622
1623         reply_cb(mainwin, COMPOSE_REPLY, NULL);
1624 }
1625
1626 static void toolbar_reply_to_all_cb     (GtkWidget      *widget,
1627                                          gpointer        data)
1628 {
1629         MainWindow *mainwin = (MainWindow *)data;
1630
1631         reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1632 }
1633
1634 static void toolbar_reply_to_author_cb  (GtkWidget      *widget,
1635                                          gpointer        data)
1636 {
1637         MainWindow *mainwin = (MainWindow *)data;
1638
1639         reply_cb(mainwin, COMPOSE_REPLY_TO_AUTHOR, NULL);
1640 }
1641
1642 static void toolbar_forward_cb  (GtkWidget      *widget,
1643                                  gpointer        data)
1644 {
1645         MainWindow *mainwin = (MainWindow *)data;
1646
1647         reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1648 }
1649
1650 static void toolbar_delete_cb   (GtkWidget      *widget,
1651                                  gpointer        data)
1652 {
1653         MainWindow *mainwin = (MainWindow *)data;
1654
1655         summary_delete(mainwin->summaryview);
1656 }
1657
1658 static void toolbar_exec_cb     (GtkWidget      *widget,
1659                                  gpointer        data)
1660 {
1661         MainWindow *mainwin = (MainWindow *)data;
1662
1663         summary_execute(mainwin->summaryview);
1664 }
1665
1666 static void toolbar_next_unread_cb      (GtkWidget      *widget,
1667                                          gpointer        data)
1668 {
1669         MainWindow *mainwin = (MainWindow *)data;
1670
1671         next_unread_cb(mainwin, 0, NULL);
1672 }
1673
1674 static void toolbar_prefs_cb    (GtkWidget      *widget,
1675                                  gpointer        data)
1676 {
1677         prefs_common_open();
1678 }
1679
1680 static void toolbar_account_cb  (GtkWidget      *widget,
1681                                  gpointer        data)
1682 {
1683         MainWindow *mainwin = (MainWindow *)data;
1684
1685         prefs_account_open_cb(mainwin, 0, NULL);
1686 }
1687
1688 static void toolbar_account_button_pressed(GtkWidget *widget,
1689                                            GdkEventButton *event,
1690                                            gpointer data)
1691 {
1692         MainWindow *mainwin = (MainWindow *)data;
1693
1694         if (!event) return;
1695         if (event->button != 3) return;
1696
1697         gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1698                        event->button, event->time);
1699 }
1700
1701 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1702                                     gpointer data)
1703 {
1704         MainWindow *mainwin = (MainWindow *)data;
1705
1706         if (!event) return;
1707
1708         gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, NULL, NULL,
1709                        event->button, event->time);
1710 }
1711
1712 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1713                                  gpointer data)
1714 {
1715         app_exit_cb(data, 0, widget);
1716
1717         return TRUE;
1718 }
1719
1720 static void add_mailbox_cb(MainWindow *mainwin, guint action,
1721                            GtkWidget *widget)
1722 {
1723         main_window_add_mailbox(mainwin);
1724 }
1725
1726 static void add_mbox_cb(MainWindow *mainwin, guint action,
1727                         GtkWidget *widget)
1728 {
1729         main_window_add_mbox(mainwin);
1730 }
1731
1732 static void update_folderview_cb(MainWindow *mainwin, guint action,
1733                                  GtkWidget *widget)
1734 {
1735         summary_show(mainwin->summaryview, NULL, FALSE);
1736         folderview_update_all();
1737 }
1738
1739 static void new_folder_cb(MainWindow *mainwin, guint action,
1740                           GtkWidget *widget)
1741 {
1742         folderview_new_folder(mainwin->folderview);
1743 }
1744
1745 static void rename_folder_cb(MainWindow *mainwin, guint action,
1746                              GtkWidget *widget)
1747 {
1748         folderview_rename_folder(mainwin->folderview);
1749 }
1750
1751 static void delete_folder_cb(MainWindow *mainwin, guint action,
1752                              GtkWidget *widget)
1753 {
1754         folderview_delete_folder(mainwin->folderview);
1755 }
1756
1757 static void import_mbox_cb(MainWindow *mainwin, guint action,
1758                            GtkWidget *widget)
1759 {
1760         import_mbox(mainwin->summaryview->folder_item);
1761 }
1762
1763 static void export_mbox_cb(MainWindow *mainwin, guint action,
1764                            GtkWidget *widget)
1765 {
1766         export_mbox(mainwin->summaryview->folder_item);
1767 }
1768
1769 static void empty_trash_cb(MainWindow *mainwin, guint action,
1770                            GtkWidget *widget)
1771 {
1772         main_window_empty_trash(mainwin, TRUE);
1773 }
1774
1775 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1776 {
1777         summary_save_as(mainwin->summaryview);
1778 }
1779
1780 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1781 {
1782         summary_print(mainwin->summaryview);
1783 }
1784
1785 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1786 {
1787         if (prefs_common.confirm_on_exit) {
1788                 if (alertpanel(_("Exit"), _("Exit this program?"),
1789                                _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
1790                         return;
1791                 manage_window_focus_in(mainwin->window, NULL, NULL);
1792         }
1793
1794         app_will_exit(widget, mainwin);
1795 }
1796
1797 static void toggle_folder_cb(MainWindow *mainwin, guint action,
1798                              GtkWidget *widget)
1799 {
1800         switch (mainwin->type) {
1801         case SEPARATE_NONE:
1802         case SEPARATE_MESSAGE:
1803                 break;
1804         case SEPARATE_FOLDER:
1805                 if (GTK_CHECK_MENU_ITEM(widget)->active)
1806                         gtk_widget_show(mainwin->win.sep_folder.folderwin);
1807                 else
1808                         gtk_widget_hide(mainwin->win.sep_folder.folderwin);
1809                 break;
1810         case SEPARATE_BOTH:
1811                 if (GTK_CHECK_MENU_ITEM(widget)->active)
1812                         gtk_widget_show(mainwin->win.sep_both.folderwin);
1813                 else
1814                         gtk_widget_hide(mainwin->win.sep_both.folderwin);
1815                 break;
1816         }
1817 }
1818
1819 static void toggle_message_cb(MainWindow *mainwin, guint action,
1820                               GtkWidget *widget)
1821 {
1822         switch (mainwin->type) {
1823         case SEPARATE_NONE:
1824         case SEPARATE_FOLDER:
1825                 break;
1826         case SEPARATE_MESSAGE:
1827                 if (GTK_CHECK_MENU_ITEM(widget)->active)
1828                         gtk_widget_show(mainwin->win.sep_message.messagewin);
1829                 else
1830                         gtk_widget_hide(mainwin->win.sep_message.messagewin);
1831                 break;
1832         case SEPARATE_BOTH:
1833                 if (GTK_CHECK_MENU_ITEM(widget)->active)
1834                         gtk_widget_show(mainwin->win.sep_both.messagewin);
1835                 else
1836                         gtk_widget_hide(mainwin->win.sep_both.messagewin);
1837                 break;
1838         }
1839 }
1840
1841 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
1842                               GtkWidget *widget)
1843 {
1844         switch ((ToolbarStyle)action) {
1845         case TOOLBAR_NONE:
1846                 gtk_widget_hide(mainwin->handlebox);
1847         case TOOLBAR_ICON:
1848                 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1849                                       GTK_TOOLBAR_ICONS);
1850                 break;
1851         case TOOLBAR_TEXT:
1852                 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1853                                       GTK_TOOLBAR_TEXT);
1854                 break;
1855         case TOOLBAR_BOTH:
1856                 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
1857                                       GTK_TOOLBAR_BOTH);
1858                 break;
1859         }
1860
1861         if (action != TOOLBAR_NONE) {
1862                 gtk_widget_show(mainwin->handlebox);
1863                 gtk_widget_queue_resize(mainwin->handlebox);
1864         }
1865
1866         mainwin->toolbar_style = (ToolbarStyle)action;
1867         prefs_common.toolbar_style = (ToolbarStyle)action;
1868 }
1869
1870 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
1871                                 GtkWidget *widget)
1872 {
1873         if (GTK_CHECK_MENU_ITEM(widget)->active) {
1874                 gtk_widget_show(mainwin->hbox_stat);
1875                 prefs_common.show_statusbar = TRUE;
1876         } else {
1877                 gtk_widget_hide(mainwin->hbox_stat);
1878                 prefs_common.show_statusbar = FALSE;
1879         }
1880 }
1881
1882 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action)
1883 {
1884         MainWindow *mainwin;
1885         SeparateType type;
1886
1887         mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
1888         g_return_if_fail(mainwin != NULL);
1889
1890         type = mainwin->type ^ action;
1891         main_window_separation_change(mainwin, type);
1892
1893         prefs_common.sep_folder = (type & SEPARATE_FOLDER)  != 0;
1894         prefs_common.sep_msg    = (type & SEPARATE_MESSAGE) != 0;
1895 }
1896
1897 static void addressbook_open_cb(MainWindow *mainwin, guint action,
1898                                 GtkWidget *widget)
1899 {
1900         addressbook_open(NULL);
1901 }
1902
1903 static void log_window_show_cb(MainWindow *mainwin, guint action,
1904                                GtkWidget *widget)
1905 {
1906         log_window_show(mainwin->logwin);
1907 }
1908
1909 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1910 {
1911         inc_mail(mainwin);
1912 }
1913
1914 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
1915                                     GtkWidget *widget)
1916 {
1917         inc_all_account_mail(mainwin);
1918 }
1919
1920 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1921 {
1922         GList *list;
1923
1924         if (procmsg_send_queue() < 0)
1925                 alertpanel_error(_("Sending queued message failed."));
1926
1927         statusbar_pop_all();
1928
1929         for (list = folder_get_list(); list != NULL; list = list->next) {
1930                 Folder *folder;
1931
1932                 folder = list->data;
1933                 if (folder->queue) {
1934                         folder_item_scan(folder->queue);
1935                         folderview_update_item(folder->queue, TRUE);
1936                 }
1937         }
1938 }
1939
1940 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1941 {
1942         if (mainwin->summaryview->folder_item)
1943                 compose_new(mainwin->summaryview->folder_item->folder->account);
1944         else
1945                 compose_new(NULL);
1946 }
1947
1948 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1949 {
1950         MsgInfo *msginfo;
1951
1952         msginfo = gtk_ctree_node_get_row_data
1953                 (GTK_CTREE(mainwin->summaryview->ctree),
1954                  mainwin->summaryview->selected);
1955
1956         if (!msginfo) return;
1957
1958         switch (action) {
1959         case COMPOSE_REPLY:
1960                 compose_reply(msginfo, prefs_common.reply_with_quote,
1961                               FALSE, FALSE);
1962                 break;
1963         case COMPOSE_REPLY_TO_ALL:
1964                 compose_reply(msginfo, prefs_common.reply_with_quote,
1965                               TRUE, FALSE);
1966                 break;
1967         case COMPOSE_REPLY_TO_AUTHOR:
1968                 compose_reply(msginfo, prefs_common.reply_with_quote,
1969                               FALSE, TRUE);
1970                 break;
1971         case COMPOSE_FORWARD:
1972                 compose_forward(NULL, msginfo, FALSE);
1973                 break;
1974         case COMPOSE_FORWARD_AS_ATTACH:
1975                 compose_forward(NULL, msginfo, TRUE);
1976                 break;
1977         default:
1978                 compose_reply(msginfo, prefs_common.reply_with_quote,
1979                               FALSE, FALSE);
1980         }
1981
1982         summary_set_marks_selected(mainwin->summaryview);
1983 }
1984
1985 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1986 {
1987         summary_move_to(mainwin->summaryview);
1988 }
1989
1990 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1991 {
1992         summary_copy_to(mainwin->summaryview);
1993 }
1994
1995 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
1996 {
1997         summary_delete(mainwin->summaryview);
1998 }
1999
2000 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2001 {
2002         summary_open_msg(mainwin->summaryview);
2003 }
2004
2005 static void view_source_cb(MainWindow *mainwin, guint action,
2006                            GtkWidget *widget)
2007 {
2008         summary_view_source(mainwin->summaryview);
2009 }
2010
2011 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2012 {
2013         summary_reedit(mainwin->summaryview);
2014 }
2015
2016 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2017 {
2018         summary_mark(mainwin->summaryview);
2019 }
2020
2021 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2022 {
2023         summary_unmark(mainwin->summaryview);
2024 }
2025
2026 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2027                               GtkWidget *widget)
2028 {
2029         summary_mark_as_unread(mainwin->summaryview);
2030 }
2031
2032 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2033                             GtkWidget *widget)
2034 {
2035         summary_mark_as_read(mainwin->summaryview);
2036 }
2037
2038 static void set_charset_cb(MainWindow *mainwin, guint action,
2039                            GtkWidget *widget)
2040 {
2041         const gchar *str;
2042
2043         str = conv_get_charset_str((CharSet)action);
2044         g_free(prefs_common.force_charset);
2045         prefs_common.force_charset = str ? g_strdup(str) : NULL;
2046
2047         summary_redisplay_msg(mainwin->summaryview);
2048
2049         debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2050 }
2051
2052 void main_window_set_thread_option(MainWindow *mainwin)
2053 {
2054         GtkItemFactory *ifactory;
2055
2056         ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2057
2058         if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2059                 menu_set_sensitive(ifactory, "/Summary/Thread view",   FALSE);
2060                 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2061                 summary_thread_build(mainwin->summaryview);
2062         }
2063         else {
2064                 menu_set_sensitive(ifactory, "/Summary/Thread view",   TRUE);
2065                 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2066                 summary_unthread(mainwin->summaryview);
2067         }
2068         prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2069 }
2070
2071 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2072 {
2073         /*
2074         ifactory = gtk_item_factory_from_widget(widget);
2075         */
2076         mainwin->summaryview->folder_item->prefs->enable_thread =
2077                 !mainwin->summaryview->folder_item->prefs->enable_thread;
2078         main_window_set_thread_option(mainwin);
2079
2080         /*
2081         if (0 == action) {
2082                 summary_thread_build(mainwin->summaryview);
2083                 mainwin->summaryview->folder_item->prefs->enable_thread =
2084                         TRUE;
2085                 menu_set_sensitive(ifactory, "/Summary/Thread view",   FALSE);
2086                 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2087         } else {
2088                 summary_unthread(mainwin->summaryview);
2089                 mainwin->summaryview->folder_item->prefs->enable_thread =
2090                         FALSE;
2091                 menu_set_sensitive(ifactory, "/Summary/Thread view",   TRUE);
2092                 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2093         }
2094         */
2095 }
2096
2097 static void set_display_item_cb(MainWindow *mainwin, guint action,
2098                                 GtkWidget *widget)
2099 {
2100         prefs_summary_display_item_set();
2101 }
2102
2103 static void sort_summary_cb(MainWindow *mainwin, guint action,
2104                             GtkWidget *widget)
2105 {
2106         summary_sort(mainwin->summaryview, (SummarySortType)action);
2107 }
2108
2109 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2110                                   GtkWidget *widget)
2111 {
2112         summary_attract_by_subject(mainwin->summaryview);
2113 }
2114
2115 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2116                                  GtkWidget *widget)
2117 {
2118         summary_delete_duplicated(mainwin->summaryview);
2119 }
2120
2121 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2122 {
2123         summary_filter(mainwin->summaryview);
2124 }
2125
2126 static void execute_summary_cb(MainWindow *mainwin, guint action,
2127                                GtkWidget *widget)
2128 {
2129         summary_execute(mainwin->summaryview);
2130 }
2131
2132 static void update_summary_cb(MainWindow *mainwin, guint action,
2133                               GtkWidget *widget)
2134 {
2135         FolderItem *fitem;
2136         FolderView *folderview = mainwin->folderview;
2137
2138         if (!mainwin->summaryview->folder_item) return;
2139         if (!folderview->opened) return;
2140
2141         fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2142                                             folderview->opened);
2143         if (!fitem) return;
2144
2145         summary_show(mainwin->summaryview, fitem, TRUE);
2146 }
2147
2148 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2149 {
2150         summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2151 }
2152
2153 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2154 {
2155         summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2156 }
2157
2158 static void next_unread_cb(MainWindow *mainwin, guint action,
2159                            GtkWidget *widget)
2160 {
2161         summary_select_next_unread(mainwin->summaryview);
2162 }
2163
2164 static void next_marked_cb(MainWindow *mainwin, guint action,
2165                            GtkWidget *widget)
2166 {
2167         summary_select_next_marked(mainwin->summaryview);
2168 }
2169
2170 static void prev_marked_cb(MainWindow *mainwin, guint action,
2171                            GtkWidget *widget)
2172 {
2173         summary_select_prev_marked(mainwin->summaryview);
2174 }
2175
2176 static void goto_folder_cb(MainWindow *mainwin, guint action,
2177                            GtkWidget *widget)
2178 {
2179         FolderItem *to_folder;
2180
2181         to_folder = foldersel_folder_sel(NULL);
2182
2183         if (to_folder)
2184                 folderview_select(mainwin->folderview, to_folder);
2185 }
2186
2187 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2188 {
2189         messageview_copy_clipboard(mainwin->messageview);
2190 }
2191
2192 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2193 {
2194         if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2195                 summary_select_all(mainwin->summaryview);
2196         else if (mainwin->summaryview->msg_is_toggled_on &&
2197                  GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2198                 messageview_select_all(mainwin->messageview);
2199 }
2200
2201 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2202                                  GtkWidget *widget)
2203 {
2204         prefs_common_open();
2205 }
2206
2207 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2208                                  GtkWidget *widget)
2209 {
2210         prefs_filter_open();
2211 }
2212
2213 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2214                                   GtkWidget *widget)
2215 {
2216         prefs_scoring_open();
2217 }
2218
2219 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2220                                     GtkWidget *widget)
2221 {
2222         prefs_filtering_open();
2223 }
2224
2225 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2226                                   GtkWidget *widget)
2227 {
2228         if (!cur_account) {
2229                 new_account_cb(mainwin, 0, widget);
2230         } else {
2231                 gboolean prev_default = cur_account->is_default;
2232
2233                 prefs_account_open(cur_account);
2234                 if (!prev_default && cur_account->is_default)
2235                         account_set_as_default(cur_account);
2236                 account_save_config_all();
2237                 account_set_menu();
2238                 main_window_reflect_prefs_all();
2239         }
2240 }
2241
2242 static void new_account_cb(MainWindow *mainwin, guint action,
2243                            GtkWidget *widget)
2244 {
2245         account_edit_open();
2246         if (!compose_get_compose_list()) account_add();
2247 }
2248
2249 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2250 {
2251         cur_account = (PrefsAccount *)data;
2252         main_window_reflect_prefs_all();
2253 }
2254
2255 static void manual_open_cb(MainWindow *mainwin, guint action,
2256                            GtkWidget *widget)
2257 {
2258         manual_open((ManualLang)action);
2259 }
2260
2261 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2262 {
2263         MainWindow *mainwin = (MainWindow *)data;
2264         gchar *str;
2265
2266         if (item->path)
2267                 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2268                                       LOCAL_FOLDER(folder)->rootpath,
2269                                       G_DIR_SEPARATOR,
2270                                       item->path);
2271         else
2272                 str = g_strdup_printf(_("Scanning folder %s ..."),
2273                                       LOCAL_FOLDER(folder)->rootpath);
2274
2275         STATUSBAR_PUSH(mainwin, str);
2276         STATUSBAR_POP(mainwin);
2277         g_free(str);
2278 }