Statistics
| Revision:

root / src / mainwindow.c @ 1

History | View | Annotate | Download (94.8 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2004 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/gtkprogressbar.h>
31
#include <gtk/gtkhpaned.h>
32
#include <gtk/gtkvpaned.h>
33
#include <gtk/gtkcheckmenuitem.h>
34
#include <gtk/gtkitemfactory.h>
35
#include <gtk/gtkeditable.h>
36
#include <gtk/gtkmenu.h>
37
#include <gtk/gtkmenuitem.h>
38
#include <gtk/gtkhandlebox.h>
39
#include <gtk/gtktoolbar.h>
40
#include <gtk/gtkbutton.h>
41
#include <gtk/gtktooltips.h>
42
#include <string.h>
43

    
44
#include "intl.h"
45
#include "main.h"
46
#include "mainwindow.h"
47
#include "folderview.h"
48
#include "foldersel.h"
49
#include "summaryview.h"
50
#include "summary_search.h"
51
#include "messageview.h"
52
#include "message_search.h"
53
#include "headerview.h"
54
#include "menu.h"
55
#include "stock_pixmap.h"
56
#include "folder.h"
57
#include "inc.h"
58
#include "compose.h"
59
#include "procmsg.h"
60
#include "import.h"
61
#include "export.h"
62
#include "prefs_common.h"
63
#include "prefs_filter.h"
64
#include "prefs_actions.h"
65
#include "prefs_account.h"
66
#include "prefs_summary_column.h"
67
#include "prefs_template.h"
68
#include "action.h"
69
#include "account.h"
70
#include "addressbook.h"
71
#include "logwindow.h"
72
#include "manage_window.h"
73
#include "alertpanel.h"
74
#include "statusbar.h"
75
#include "inputdialog.h"
76
#include "utils.h"
77
#include "gtkutils.h"
78
#include "codeconv.h"
79
#include "about.h"
80
#include "manual.h"
81
#include "version.h"
82

    
83
#define AC_LABEL_WIDTH        240
84

    
85
#define STATUSBAR_PUSH(mainwin, str) \
86
{ \
87
        gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
88
                           mainwin->mainwin_cid, str); \
89
        gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
90
}
91

    
92
#define STATUSBAR_POP(mainwin) \
93
{ \
94
        gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
95
                          mainwin->mainwin_cid); \
96
}
97

    
98
/* list of all instantiated MainWindow */
99
static GList *mainwin_list = NULL;
100

    
101
static GdkCursor *watch_cursor;
102

    
103
static void main_window_menu_callback_block        (MainWindow        *mainwin);
104
static void main_window_menu_callback_unblock        (MainWindow        *mainwin);
105

    
106
static void main_window_show_cur_account        (MainWindow        *mainwin);
107

    
108
static void main_window_set_widgets                (MainWindow        *mainwin,
109
                                                 SeparateType         type);
110
static void main_window_toolbar_create                (MainWindow        *mainwin,
111
                                                 GtkWidget        *container);
112

    
113
/* callback functions */
114
static void toolbar_inc_cb                (GtkWidget        *widget,
115
                                         gpointer         data);
116
static void toolbar_inc_all_cb                (GtkWidget        *widget,
117
                                         gpointer         data);
118
static void toolbar_send_cb                (GtkWidget        *widget,
119
                                         gpointer         data);
120

    
121
static void toolbar_compose_cb                (GtkWidget        *widget,
122
                                         gpointer         data);
123
static void toolbar_reply_cb                (GtkWidget        *widget,
124
                                         gpointer         data);
125
static void toolbar_reply_to_all_cb        (GtkWidget        *widget,
126
                                         gpointer         data);
127
static void toolbar_forward_cb                (GtkWidget        *widget,
128
                                         gpointer         data);
129

    
130
static void toolbar_delete_cb                (GtkWidget        *widget,
131
                                         gpointer         data);
132
static void toolbar_exec_cb                (GtkWidget        *widget,
133
                                         gpointer         data);
134

    
135
static void toolbar_next_unread_cb        (GtkWidget        *widget,
136
                                         gpointer         data);
137

    
138
#if 0
139
static void toolbar_prefs_cb                (GtkWidget        *widget,
140
                                         gpointer         data);
141
static void toolbar_account_cb                (GtkWidget        *widget,
142
                                         gpointer         data);
143

144
static void toolbar_account_button_pressed        (GtkWidget        *widget,
145
                                                 GdkEventButton        *event,
146
                                                 gpointer         data);
147
#endif
148

    
149
static void toolbar_child_attached                (GtkWidget        *widget,
150
                                                 GtkWidget        *child,
151
                                                 gpointer         data);
152
static void toolbar_child_detached                (GtkWidget        *widget,
153
                                                 GtkWidget        *child,
154
                                                 gpointer         data);
155

    
156
static void online_switch_clicked                (GtkWidget        *widget,
157
                                                 gpointer         data);
158
static void ac_label_button_pressed                (GtkWidget        *widget,
159
                                                 GdkEventButton        *event,
160
                                                 gpointer         data);
161
static void ac_menu_popup_closed                (GtkMenuShell        *menu_shell,
162
                                                 gpointer         data);
163

    
164
static gint main_window_close_cb                (GtkWidget        *widget,
165
                                                 GdkEventAny        *event,
166
                                                 gpointer         data);
167
static gint folder_window_close_cb                (GtkWidget        *widget,
168
                                                 GdkEventAny        *event,
169
                                                 gpointer         data);
170
static gint message_window_close_cb                (GtkWidget        *widget,
171
                                                 GdkEventAny        *event,
172
                                                 gpointer         data);
173

    
174
static void main_window_size_allocate_cb        (GtkWidget        *widget,
175
                                                 GtkAllocation        *allocation,
176
                                                 gpointer         data);
177
static void folder_window_size_allocate_cb        (GtkWidget        *widget,
178
                                                 GtkAllocation        *allocation,
179
                                                 gpointer         data);
180
static void message_window_size_allocate_cb        (GtkWidget        *widget,
181
                                                 GtkAllocation        *allocation,
182
                                                 gpointer         data);
183

    
184
static void new_folder_cb         (MainWindow        *mainwin,
185
                                  guint                 action,
186
                                  GtkWidget        *widget);
187
static void rename_folder_cb         (MainWindow        *mainwin,
188
                                  guint                 action,
189
                                  GtkWidget        *widget);
190
static void delete_folder_cb         (MainWindow        *mainwin,
191
                                  guint                 action,
192
                                  GtkWidget        *widget);
193
static void update_folderview_cb (MainWindow        *mainwin,
194
                                  guint                 action,
195
                                  GtkWidget        *widget);
196

    
197
static void add_mailbox_cb         (MainWindow        *mainwin,
198
                                  guint                 action,
199
                                  GtkWidget        *widget);
200
static void remove_mailbox_cb         (MainWindow        *mainwin,
201
                                  guint                 action,
202
                                  GtkWidget        *widget);
203
static void rebuild_tree_cb         (MainWindow        *mainwin,
204
                                  guint                 action,
205
                                  GtkWidget        *widget);
206

    
207
static void import_mbox_cb         (MainWindow        *mainwin,
208
                                  guint                 action,
209
                                  GtkWidget        *widget);
210
static void export_mbox_cb         (MainWindow        *mainwin,
211
                                  guint                 action,
212
                                  GtkWidget        *widget);
213
static void empty_trash_cb         (MainWindow        *mainwin,
214
                                  guint                 action,
215
                                  GtkWidget        *widget);
216

    
217
static void save_as_cb                 (MainWindow        *mainwin,
218
                                  guint                 action,
219
                                  GtkWidget        *widget);
220
static void print_cb                 (MainWindow        *mainwin,
221
                                  guint                 action,
222
                                  GtkWidget        *widget);
223
static void toggle_offline_cb         (MainWindow        *mainwin,
224
                                  guint                 action,
225
                                  GtkWidget        *widget);
226
static void app_exit_cb                 (MainWindow        *mainwin,
227
                                  guint                 action,
228
                                  GtkWidget        *widget);
229

    
230
static void search_cb                 (MainWindow        *mainwin,
231
                                  guint                 action,
232
                                  GtkWidget        *widget);
233

    
234
static void toggle_folder_cb         (MainWindow        *mainwin,
235
                                  guint                 action,
236
                                  GtkWidget        *widget);
237
static void toggle_message_cb         (MainWindow        *mainwin,
238
                                  guint                 action,
239
                                  GtkWidget        *widget);
240
static void toggle_toolbar_cb         (MainWindow        *mainwin,
241
                                  guint                 action,
242
                                  GtkWidget        *widget);
243
static void toggle_statusbar_cb         (MainWindow        *mainwin,
244
                                  guint                 action,
245
                                  GtkWidget        *widget);
246
static void separate_widget_cb         (MainWindow        *mainwin,
247
                                  guint                 action,
248
                                  GtkWidget        *widget);
249

    
250
static void addressbook_open_cb        (MainWindow        *mainwin,
251
                                 guint                 action,
252
                                 GtkWidget        *widget);
253
static void log_window_show_cb        (MainWindow        *mainwin,
254
                                 guint                 action,
255
                                 GtkWidget        *widget);
256

    
257
static void inc_mail_cb                        (MainWindow        *mainwin,
258
                                         guint                 action,
259
                                         GtkWidget        *widget);
260
static void inc_all_account_mail_cb        (MainWindow        *mainwin,
261
                                         guint                 action,
262
                                         GtkWidget        *widget);
263
static void inc_cancel_cb                (MainWindow        *mainwin,
264
                                         guint                 action,
265
                                         GtkWidget        *widget);
266

    
267
static void send_queue_cb                (MainWindow        *mainwin,
268
                                         guint                 action,
269
                                         GtkWidget        *widget);
270

    
271
static void compose_cb                        (MainWindow        *mainwin,
272
                                         guint                 action,
273
                                         GtkWidget        *widget);
274
static void reply_cb                        (MainWindow        *mainwin,
275
                                         guint                 action,
276
                                         GtkWidget        *widget);
277

    
278
static void open_msg_cb                        (MainWindow        *mainwin,
279
                                         guint                 action,
280
                                         GtkWidget        *widget);
281

    
282
static void view_source_cb                (MainWindow        *mainwin,
283
                                         guint                 action,
284
                                         GtkWidget        *widget);
285

    
286
static void show_all_header_cb                (MainWindow        *mainwin,
287
                                         guint                 action,
288
                                         GtkWidget        *widget);
289

    
290
static void move_to_cb                        (MainWindow        *mainwin,
291
                                         guint                 action,
292
                                         GtkWidget        *widget);
293
static void copy_to_cb                        (MainWindow        *mainwin,
294
                                         guint                 action,
295
                                         GtkWidget        *widget);
296
static void delete_cb                        (MainWindow        *mainwin,
297
                                         guint                 action,
298
                                         GtkWidget        *widget);
299

    
300
static void mark_cb                        (MainWindow        *mainwin,
301
                                         guint                 action,
302
                                         GtkWidget        *widget);
303
static void unmark_cb                        (MainWindow        *mainwin,
304
                                         guint                 action,
305
                                         GtkWidget        *widget);
306

    
307
static void mark_as_unread_cb                (MainWindow        *mainwin,
308
                                         guint                 action,
309
                                         GtkWidget        *widget);
310
static void mark_as_read_cb                (MainWindow        *mainwin,
311
                                         guint                 action,
312
                                         GtkWidget        *widget);
313
static void mark_all_read_cb                (MainWindow        *mainwin,
314
                                         guint                 action,
315
                                         GtkWidget        *widget);
316

    
317
static void reedit_cb                        (MainWindow        *mainwin,
318
                                         guint                 action,
319
                                         GtkWidget        *widget);
320

    
321
static void add_address_cb                (MainWindow        *mainwin,
322
                                         guint                 action,
323
                                         GtkWidget        *widget);
324

    
325
static void set_charset_cb                (MainWindow        *mainwin,
326
                                         guint                 action,
327
                                         GtkWidget        *widget);
328

    
329
static void thread_cb                 (MainWindow        *mainwin,
330
                                  guint                 action,
331
                                  GtkWidget        *widget);
332
static void expand_threads_cb         (MainWindow        *mainwin,
333
                                  guint                 action,
334
                                  GtkWidget        *widget);
335
static void collapse_threads_cb         (MainWindow        *mainwin,
336
                                  guint                 action,
337
                                  GtkWidget        *widget);
338

    
339
static void set_display_item_cb         (MainWindow        *mainwin,
340
                                  guint                 action,
341
                                  GtkWidget        *widget);
342
static void sort_summary_cb         (MainWindow        *mainwin,
343
                                  guint                 action,
344
                                  GtkWidget        *widget);
345
static void sort_summary_type_cb (MainWindow        *mainwin,
346
                                  guint                 action,
347
                                  GtkWidget        *widget);
348
static void attract_by_subject_cb(MainWindow        *mainwin,
349
                                  guint                 action,
350
                                  GtkWidget        *widget);
351

    
352
static void delete_duplicated_cb (MainWindow        *mainwin,
353
                                  guint                 action,
354
                                  GtkWidget        *widget);
355
static void filter_cb                 (MainWindow        *mainwin,
356
                                  guint                 action,
357
                                  GtkWidget        *widget);
358
static void execute_summary_cb         (MainWindow        *mainwin,
359
                                  guint                 action,
360
                                  GtkWidget        *widget);
361
static void update_summary_cb         (MainWindow        *mainwin,
362
                                  guint                 action,
363
                                  GtkWidget        *widget);
364

    
365
static void prev_cb                 (MainWindow        *mainwin,
366
                                  guint                 action,
367
                                  GtkWidget        *widget);
368
static void next_cb                 (MainWindow        *mainwin,
369
                                  guint                 action,
370
                                  GtkWidget        *widget);
371

    
372
static void prev_unread_cb         (MainWindow        *mainwin,
373
                                  guint                 action,
374
                                  GtkWidget        *widget);
375
static void next_unread_cb         (MainWindow        *mainwin,
376
                                  guint                 action,
377
                                  GtkWidget        *widget);
378
static void prev_new_cb                 (MainWindow        *mainwin,
379
                                  guint                 action,
380
                                  GtkWidget        *widget);
381
static void next_new_cb                 (MainWindow        *mainwin,
382
                                  guint                 action,
383
                                  GtkWidget        *widget);
384
static void prev_marked_cb         (MainWindow        *mainwin,
385
                                  guint                 action,
386
                                  GtkWidget        *widget);
387
static void next_marked_cb         (MainWindow        *mainwin,
388
                                  guint                 action,
389
                                  GtkWidget        *widget);
390
static void prev_labeled_cb         (MainWindow        *mainwin,
391
                                  guint                 action,
392
                                  GtkWidget        *widget);
393
static void next_labeled_cb         (MainWindow        *mainwin,
394
                                  guint                 action,
395
                                  GtkWidget        *widget);
396

    
397
static void goto_folder_cb         (MainWindow        *mainwin,
398
                                  guint                 action,
399
                                  GtkWidget        *widget);
400

    
401
static void copy_cb                 (MainWindow        *mainwin,
402
                                  guint                 action,
403
                                  GtkWidget        *widget);
404
static void allsel_cb                 (MainWindow        *mainwin,
405
                                  guint                 action,
406
                                  GtkWidget        *widget);
407
static void select_thread_cb         (MainWindow        *mainwin,
408
                                  guint                 action,
409
                                  GtkWidget        *widget);
410

    
411
static void create_filter_cb         (MainWindow        *mainwin,
412
                                  guint                 action,
413
                                  GtkWidget        *widget);
414

    
415
static void prefs_common_open_cb        (MainWindow        *mainwin,
416
                                         guint                 action,
417
                                         GtkWidget        *widget);
418
static void prefs_filter_open_cb        (MainWindow        *mainwin,
419
                                         guint                 action,
420
                                         GtkWidget        *widget);
421
static void prefs_template_open_cb        (MainWindow        *mainwin,
422
                                         guint                 action,
423
                                         GtkWidget        *widget);
424
static void prefs_actions_open_cb        (MainWindow        *mainwin,
425
                                         guint                 action,
426
                                         GtkWidget        *widget);
427
static void prefs_account_open_cb        (MainWindow        *mainwin,
428
                                         guint                 action,
429
                                         GtkWidget        *widget);
430

    
431
static void new_account_cb         (MainWindow        *mainwin,
432
                                  guint                 action,
433
                                  GtkWidget        *widget);
434

    
435
static void account_selector_menu_cb         (GtkMenuItem        *menuitem,
436
                                          gpointer         data);
437
static void account_receive_menu_cb         (GtkMenuItem        *menuitem,
438
                                          gpointer         data);
439

    
440
static void manual_open_cb         (MainWindow        *mainwin,
441
                                  guint                 action,
442
                                  GtkWidget        *widget);
443
static void faq_open_cb                 (MainWindow        *mainwin,
444
                                  guint                 action,
445
                                  GtkWidget        *widget);
446

    
447
static void scan_tree_func         (Folder        *folder,
448
                                  FolderItem        *item,
449
                                  gpointer         data);
450

    
451
static GtkItemFactoryEntry mainwin_entries[] =
452
{
453
        {N_("/_File"),                                NULL, NULL, 0, "<Branch>"},
454
        {N_("/_File/_Folder"),                        NULL, NULL, 0, "<Branch>"},
455
        {N_("/_File/_Folder/Create _new folder..."),
456
                                                NULL, new_folder_cb, 0, NULL},
457
        {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
458
        {N_("/_File/_Folder/_Delete folder"),        NULL, delete_folder_cb, 0, NULL},
459
        {N_("/_File/_Mailbox"),                        NULL, NULL, 0, "<Branch>"},
460
        {N_("/_File/_Mailbox/Add _mailbox..."),        NULL, add_mailbox_cb, 0, NULL},
461
        {N_("/_File/_Mailbox/_Remove mailbox"),        NULL, remove_mailbox_cb, 0, NULL},
462
        {N_("/_File/_Mailbox/---"),                NULL, NULL, 0, "<Separator>"},
463
        {N_("/_File/_Mailbox/_Check for new messages"),
464
                                                NULL, update_folderview_cb, 0, NULL},
465
        {N_("/_File/_Mailbox/Check for new messages in _all mailboxes"),
466
                                                NULL, update_folderview_cb, 1, NULL},
467
        {N_("/_File/_Mailbox/---"),                NULL, NULL, 0, "<Separator>"},
468
        {N_("/_File/_Mailbox/R_ebuild folder tree"),
469
                                                NULL, rebuild_tree_cb, 0, NULL},
470
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
471
        {N_("/_File/_Import mbox file..."),        NULL, import_mbox_cb, 0, NULL},
472
        {N_("/_File/_Export to mbox file..."),        NULL, export_mbox_cb, 0, NULL},
473
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
474
        {N_("/_File/Empty all _trash"),                NULL, empty_trash_cb, 0, NULL},
475
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
476
        {N_("/_File/_Save as..."),                "<control>S", save_as_cb, 0, NULL},
477
        {N_("/_File/_Print..."),                NULL, print_cb, 0, NULL},
478
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
479
        {N_("/_File/_Work offline"),                NULL, toggle_offline_cb, 0, "<ToggleItem>"},
480
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
481
        /* {N_("/_File/_Close"),                "<alt>W", app_exit_cb, 0, NULL}, */
482
        {N_("/_File/E_xit"),                        "<control>Q", app_exit_cb, 0, NULL},
483

    
484
        {N_("/_Edit"),                                NULL, NULL, 0, "<Branch>"},
485
        {N_("/_Edit/_Copy"),                        "<control>C", copy_cb, 0, NULL},
486
        {N_("/_Edit/Select _all"),                "<control>A", allsel_cb, 0, NULL},
487
        {N_("/_Edit/Select _thread"),                NULL, select_thread_cb, 0, NULL},
488
        {N_("/_Edit/---"),                        NULL, NULL, 0, "<Separator>"},
489
        {N_("/_Edit/_Find in current message..."),
490
                                                "<control>F", search_cb, 0, NULL},
491
        {N_("/_Edit/_Search messages..."),        "<shift><control>F", search_cb, 1, NULL},
492

    
493
        {N_("/_View"),                                NULL, NULL, 0, "<Branch>"},
494
        {N_("/_View/Show or hi_de"),                NULL, NULL, 0, "<Branch>"},
495
        {N_("/_View/Show or hi_de/_Folder tree"),
496
                                                NULL, toggle_folder_cb, 0, "<ToggleItem>"},
497
        {N_("/_View/Show or hi_de/_Message view"),
498
                                                "V", toggle_message_cb, 0, "<ToggleItem>"},
499
        {N_("/_View/Show or hi_de/_Toolbar"),
500
                                                NULL, NULL, 0, "<Branch>"},
501
        {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
502
                                                NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
503
        {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
504
                                                NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
505
        {N_("/_View/Show or hi_de/_Toolbar/_Text"),
506
                                                NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
507
        {N_("/_View/Show or hi_de/_Toolbar/_None"),
508
                                                NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
509
        {N_("/_View/Show or hi_de/Status _bar"),
510
                                                NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
511
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
512
        {N_("/_View/Separate f_older tree"),        NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
513
        {N_("/_View/Separate m_essage view"),        NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
514
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
515
        {N_("/_View/_Sort"),                        NULL, NULL, 0, "<Branch>"},
516
        {N_("/_View/_Sort/by _number"),                NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
517
        {N_("/_View/_Sort/by s_ize"),                NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
518
        {N_("/_View/_Sort/by _date"),                NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
519
        {N_("/_View/_Sort/by _from"),                NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
520
        {N_("/_View/_Sort/by _recipient"),        NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
521
        {N_("/_View/_Sort/by _subject"),        NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
522
        {N_("/_View/_Sort/by _color label"),
523
                                                NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
524
        {N_("/_View/_Sort/by _mark"),                NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
525
        {N_("/_View/_Sort/by _unread"),                NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
526
        {N_("/_View/_Sort/by a_ttachment"),
527
                                                NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
528
        {N_("/_View/_Sort/D_on't sort"),        NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
529
        {N_("/_View/_Sort/---"),                NULL, NULL, 0, "<Separator>"},
530
        {N_("/_View/_Sort/Ascending"),                NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
531
        {N_("/_View/_Sort/Descending"),                NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
532
        {N_("/_View/_Sort/---"),                NULL, NULL, 0, "<Separator>"},
533
        {N_("/_View/_Sort/_Attract by subject"),
534
                                                NULL, attract_by_subject_cb, 0, NULL},
535
        {N_("/_View/Th_read view"),                "<control>T", thread_cb, 0, "<ToggleItem>"},
536
        {N_("/_View/E_xpand all threads"),        NULL, expand_threads_cb, 0, NULL},
537
        {N_("/_View/Co_llapse all threads"),        NULL, collapse_threads_cb, 0, NULL},
538
        {N_("/_View/Set display _item..."),        NULL, set_display_item_cb, 0, NULL},
539

    
540
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
541
        {N_("/_View/_Go to"),                        NULL, NULL, 0, "<Branch>"},
542
        {N_("/_View/_Go to/_Prev message"),        "P", prev_cb, 0, NULL},
543
        {N_("/_View/_Go to/_Next message"),        "N", next_cb, 0, NULL},
544
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
545
        {N_("/_View/_Go to/P_rev unread message"),
546
                                                "<shift>P", prev_unread_cb, 0, NULL},
547
        {N_("/_View/_Go to/N_ext unread message"),
548
                                                "<shift>N", next_unread_cb, 0, NULL},
549
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
550
        {N_("/_View/_Go to/Prev ne_w message"),        NULL, prev_new_cb, 0, NULL},
551
        {N_("/_View/_Go to/Ne_xt new message"),        NULL, next_new_cb, 0, NULL},
552
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
553
        {N_("/_View/_Go to/Prev _marked message"),
554
                                                NULL, prev_marked_cb, 0, NULL},
555
        {N_("/_View/_Go to/Next m_arked message"),
556
                                                NULL, next_marked_cb, 0, NULL},
557
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
558
        {N_("/_View/_Go to/Prev _labeled message"),
559
                                                NULL, prev_labeled_cb, 0, NULL},
560
        {N_("/_View/_Go to/Next la_beled message"),
561
                                                NULL, next_labeled_cb, 0, NULL},
562
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
563
        {N_("/_View/_Go to/Other _folder..."),        "G", goto_folder_cb, 0, NULL},
564
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
565

    
566
#define CODESET_SEPARATOR \
567
        {N_("/_View/_Code set/---"),                NULL, NULL, 0, "<Separator>"}
568
#define CODESET_ACTION(action) \
569
         NULL, set_charset_cb, action, "/View/Code set/Auto detect"
570

    
571
        {N_("/_View/_Code set"),                NULL, NULL, 0, "<Branch>"},
572
        {N_("/_View/_Code set/_Auto detect"),
573
         NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
574
        {N_("/_View/_Code set/---"),                NULL, NULL, 0, "<Separator>"},
575
        {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
576
         CODESET_ACTION(C_US_ASCII)},
577

    
578
#if HAVE_ICONV
579
        {N_("/_View/_Code set/Unicode (_UTF-8)"),
580
         CODESET_ACTION(C_UTF_8)},
581
        CODESET_SEPARATOR,
582
#endif
583
        {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
584
         CODESET_ACTION(C_ISO_8859_1)},
585
        {N_("/_View/_Code set/Western European (ISO-8859-15)"),
586
         CODESET_ACTION(C_ISO_8859_15)},
587
        CODESET_SEPARATOR,
588
#if HAVE_ICONV
589
        {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
590
         CODESET_ACTION(C_ISO_8859_2)},
591
        CODESET_SEPARATOR,
592
        {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
593
         CODESET_ACTION(C_ISO_8859_13)},
594
        {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
595
         CODESET_ACTION(C_ISO_8859_4)},
596
        CODESET_SEPARATOR,
597
        {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
598
         CODESET_ACTION(C_ISO_8859_7)},
599
        CODESET_SEPARATOR,
600
        {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
601
         CODESET_ACTION(C_ISO_8859_9)},
602
        CODESET_SEPARATOR,
603
        {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
604
         CODESET_ACTION(C_ISO_8859_5)},
605
        {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
606
         CODESET_ACTION(C_KOI8_R)},
607
        {N_("/_View/_Code set/Cyrillic (KOI8-U)"),
608
         CODESET_ACTION(C_KOI8_U)},
609
        {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
610
         CODESET_ACTION(C_CP1251)},
611
        CODESET_SEPARATOR,
612
#endif
613
        {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
614
         CODESET_ACTION(C_ISO_2022_JP)},
615
#if HAVE_ICONV
616
        {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
617
         CODESET_ACTION(C_ISO_2022_JP_2)},
618
#endif
619
        {N_("/_View/_Code set/Japanese (_EUC-JP)"),
620
         CODESET_ACTION(C_EUC_JP)},
621
        {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
622
         CODESET_ACTION(C_SHIFT_JIS)},
623
#if HAVE_ICONV
624
        CODESET_SEPARATOR,
625
        {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
626
         CODESET_ACTION(C_GB2312)},
627
        {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
628
         CODESET_ACTION(C_BIG5)},
629
        {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
630
         CODESET_ACTION(C_EUC_TW)},
631
        {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
632
         CODESET_ACTION(C_ISO_2022_CN)},
633
        CODESET_SEPARATOR,
634
        {N_("/_View/_Code set/Korean (EUC-_KR)"),
635
         CODESET_ACTION(C_EUC_KR)},
636
        {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
637
         CODESET_ACTION(C_ISO_2022_KR)},
638
        CODESET_SEPARATOR,
639
        {N_("/_View/_Code set/Thai (TIS-620)"),
640
         CODESET_ACTION(C_TIS_620)},
641
        {N_("/_View/_Code set/Thai (Windows-874)"),
642
         CODESET_ACTION(C_WINDOWS_874)},
643
#endif
644

    
645
#undef CODESET_SEPARATOR
646
#undef CODESET_ACTION
647

    
648
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
649
        {N_("/_View/Open in new _window"),        "<control><alt>N", open_msg_cb, 0, NULL},
650
        {N_("/_View/Mess_age source"),                "<control>U", view_source_cb, 0, NULL},
651
        {N_("/_View/Show all _header"),                "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
652
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
653
        {N_("/_View/_Update summary"),                "<control><alt>U", update_summary_cb,  0, NULL},
654

    
655
        {N_("/_Message"),                        NULL, NULL, 0, "<Branch>"},
656
        {N_("/_Message/Recei_ve"),                NULL, NULL, 0, "<Branch>"},
657
        {N_("/_Message/Recei_ve/Get from _current account"),
658
                                                "<control>I",        inc_mail_cb, 0, NULL},
659
        {N_("/_Message/Recei_ve/Get from _all accounts"),
660
                                                "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
661
        {N_("/_Message/Recei_ve/Cancel receivin_g"),
662
                                                NULL, inc_cancel_cb, 0, NULL},
663
        {N_("/_Message/Recei_ve/---"),                NULL, NULL, 0, "<Separator>"},
664
        {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
665
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
666
        {N_("/_Message/Compose _new message"),        "<control>M",        compose_cb, 0, NULL},
667
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
668
        {N_("/_Message/_Reply"),                "<control>R",         reply_cb, COMPOSE_REPLY, NULL},
669
        {N_("/_Message/Repl_y to"),                NULL, NULL, 0, "<Branch>"},
670
        {N_("/_Message/Repl_y to/_all"),        "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
671
        {N_("/_Message/Repl_y to/_sender"),        NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
672
        {N_("/_Message/Repl_y to/mailing _list"),
673
                                                "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
674
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
675
        {N_("/_Message/_Forward"),                "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
676
        {N_("/_Message/For_ward as attachment"),
677
                                                "<shift><control><alt>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
678
        {N_("/_Message/Redirec_t"),                NULL, reply_cb, COMPOSE_REDIRECT, NULL},
679
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
680
        {N_("/_Message/M_ove..."),                "<control>O", move_to_cb, 0, NULL},
681
        {N_("/_Message/_Copy..."),                "<shift><control>O", copy_to_cb, 0, NULL},
682
        {N_("/_Message/_Delete"),                "<control>D", delete_cb,  0, NULL},
683
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
684
        {N_("/_Message/_Mark"),                        NULL, NULL, 0, "<Branch>"},
685
        {N_("/_Message/_Mark/_Mark"),                "<shift>asterisk", mark_cb, 0, NULL},
686
        {N_("/_Message/_Mark/_Unmark"),                "U", unmark_cb, 0, NULL},
687
        {N_("/_Message/_Mark/---"),                NULL, NULL, 0, "<Separator>"},
688
        {N_("/_Message/_Mark/Mark as unr_ead"),        "<shift>exclam", mark_as_unread_cb, 0, NULL},
689
        {N_("/_Message/_Mark/Mark as rea_d"),
690
                                                NULL, mark_as_read_cb, 0, NULL},
691
        {N_("/_Message/_Mark/Mark all _read"),        NULL, mark_all_read_cb, 0, NULL},
692
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
693
        {N_("/_Message/Re-_edit"),                NULL, reedit_cb, 0, NULL},
694

    
695
        {N_("/_Tools"),                                NULL, NULL, 0, "<Branch>"},
696
        {N_("/_Tools/_Address book"),                "<shift><control>A", addressbook_open_cb, 0, NULL},
697
        {N_("/_Tools/Add sender to address boo_k"),
698
                                                NULL, add_address_cb, 0, NULL},
699
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
700
        {N_("/_Tools/_Filter all messages in folder"),
701
                                                NULL, filter_cb, 0, NULL},
702
        {N_("/_Tools/Filter _selected messages"),
703
                                                NULL, filter_cb, 1, NULL},
704
        {N_("/_Tools/_Create filter rule"),        NULL, NULL, 0, "<Branch>"},
705
        {N_("/_Tools/_Create filter rule/_Automatically"),
706
                                                NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
707
        {N_("/_Tools/_Create filter rule/by _From"),
708
                                                NULL, create_filter_cb, FILTER_BY_FROM, NULL},
709
        {N_("/_Tools/_Create filter rule/by _To"),
710
                                                NULL, create_filter_cb, FILTER_BY_TO, NULL},
711
        {N_("/_Tools/_Create filter rule/by _Subject"),
712
                                                NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
713
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
714
        {N_("/_Tools/Actio_ns"),                NULL, NULL, 0, "<Branch>"},
715
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
716
        {N_("/_Tools/Delete du_plicated messages"),
717
                                                NULL, delete_duplicated_cb,   0, NULL},
718
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
719
        {N_("/_Tools/E_xecute"),                "X", execute_summary_cb, 0, NULL},
720
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
721
        {N_("/_Tools/_Log window"),                "<shift><control>L", log_window_show_cb, 0, NULL},
722

    
723
        {N_("/_Configuration"),                        NULL, NULL, 0, "<Branch>"},
724
        {N_("/_Configuration/_Common preferences..."),
725
                                                NULL, prefs_common_open_cb, 0, NULL},
726
        {N_("/_Configuration/_Filter setting..."),
727
                                                NULL, prefs_filter_open_cb, 0, NULL},
728
        {N_("/_Configuration/_Template..."),        NULL, prefs_template_open_cb, 0, NULL},
729
        {N_("/_Configuration/_Actions..."),        NULL, prefs_actions_open_cb, 0, NULL},
730
        {N_("/_Configuration/---"),                NULL, NULL, 0, "<Separator>"},
731
        {N_("/_Configuration/_Preferences for current account..."),
732
                                                NULL, prefs_account_open_cb, 0, NULL},
733
        {N_("/_Configuration/Create _new account..."),
734
                                                NULL, new_account_cb, 0, NULL},
735
        {N_("/_Configuration/_Edit accounts..."),
736
                                                NULL, account_edit_open, 0, NULL},
737
        {N_("/_Configuration/C_hange current account"),
738
                                                NULL, NULL, 0, "<Branch>"},
739

    
740
        {N_("/_Help"),                                NULL, NULL, 0, "<Branch>"},
741
        {N_("/_Help/_Manual"),                        NULL, NULL, 0, "<Branch>"},
742
        {N_("/_Help/_Manual/_English"),                NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
743
        {N_("/_Help/_Manual/_Japanese"),        NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
744
        {N_("/_Help/_FAQ"),                        NULL, NULL, 0, "<Branch>"},
745
        {N_("/_Help/_FAQ/_English"),                NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
746
        {N_("/_Help/_FAQ/_German"),                NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
747
        {N_("/_Help/_FAQ/_Spanish"),                NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
748
        {N_("/_Help/_FAQ/_French"),                NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
749
        {N_("/_Help/_FAQ/_Italian"),                NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
750
        {N_("/_Help/---"),                        NULL, NULL, 0, "<Separator>"},
751
        {N_("/_Help/_About"),                        NULL, about_show, 0, NULL}
752
};
753

    
754
MainWindow *main_window_create(SeparateType type)
755
{
756
        MainWindow *mainwin;
757
        GtkWidget *window;
758
        GtkWidget *vbox;
759
        GtkWidget *menubar;
760
        GtkWidget *handlebox;
761
        GtkWidget *vbox_body;
762
        GtkWidget *hbox_stat;
763
        GtkWidget *statusbar;
764
        GtkWidget *progressbar;
765
        GtkWidget *statuslabel;
766
        GtkWidget *online_hbox;
767
        GtkWidget *online_switch;
768
        GtkWidget *online_pixmap;
769
        GtkWidget *offline_pixmap;
770
        GtkTooltips *online_tip;
771
        GtkWidget *ac_button;
772
        GtkWidget *ac_label;
773

    
774
        FolderView *folderview;
775
        SummaryView *summaryview;
776
        MessageView *messageview;
777
        GdkColormap *colormap;
778
        GdkColor color[3];
779
        gboolean success[3];
780
        guint n_menu_entries;
781
        GtkItemFactory *ifactory;
782
        GtkWidget *ac_menu;
783
        GtkWidget *menuitem;
784
        gint i;
785

    
786
        static GdkGeometry geometry;
787

    
788
        debug_print(_("Creating main window...\n"));
789
        mainwin = g_new0(MainWindow, 1);
790

    
791
        /* main window */
792
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
793
        gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
794
        gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
795
        gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
796

    
797
        if (!geometry.min_height) {
798
                geometry.min_width = 320;
799
                geometry.min_height = 200;
800
        }
801
        gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
802
                                      GDK_HINT_MIN_SIZE);
803

    
804
        g_signal_connect(G_OBJECT(window), "delete_event",
805
                         G_CALLBACK(main_window_close_cb), mainwin);
806
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
807
        gtk_widget_realize(window);
808

    
809
        vbox = gtk_vbox_new(FALSE, 0);
810
        gtk_widget_show(vbox);
811
        gtk_container_add(GTK_CONTAINER(window), vbox);
812

    
813
        /* menu bar */
814
        n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
815
        menubar = menubar_create(window, mainwin_entries, 
816
                                 n_menu_entries, "<Main>", mainwin);
817
        gtk_widget_show(menubar);
818
        gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
819
        ifactory = gtk_item_factory_from_widget(menubar);
820

    
821
        handlebox = gtk_handle_box_new();
822
        gtk_widget_show(handlebox);
823
        gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
824
        g_signal_connect(G_OBJECT(handlebox), "child_attached",
825
                         G_CALLBACK(toolbar_child_attached), mainwin);
826
        g_signal_connect(G_OBJECT(handlebox), "child_detached",
827
                         G_CALLBACK(toolbar_child_detached), mainwin);
828

    
829
        main_window_toolbar_create(mainwin, handlebox);
830

    
831
        /* vbox that contains body */
832
        vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
833
        gtk_widget_show(vbox_body);
834
        gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
835
        gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
836

    
837
        hbox_stat = gtk_hbox_new(FALSE, 2);
838
        gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
839

    
840
        statusbar = statusbar_create();
841
        gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
842

    
843
        progressbar = gtk_progress_bar_new();
844
        gtk_widget_set_size_request(progressbar, 120, 1);
845
        gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
846

    
847
        statuslabel = gtk_label_new("");
848
        gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
849

    
850
        online_hbox = gtk_hbox_new(FALSE, 0);
851

    
852
        online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
853
        offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
854
        gtk_box_pack_start(GTK_BOX(online_hbox), online_pixmap,
855
                           FALSE, FALSE, 0);
856
        gtk_box_pack_start(GTK_BOX(online_hbox), offline_pixmap,
857
                           FALSE, FALSE, 0);
858

    
859
        online_switch = gtk_button_new();
860
        gtk_button_set_relief(GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
861
        GTK_WIDGET_UNSET_FLAGS(online_switch, GTK_CAN_FOCUS);
862
        gtk_container_add(GTK_CONTAINER(online_switch), online_hbox);
863
        g_signal_connect(G_OBJECT(online_switch), "clicked",
864
                         G_CALLBACK(online_switch_clicked), mainwin);
865
        gtk_box_pack_start(GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
866

    
867
        online_tip = gtk_tooltips_new();
868

    
869
        ac_button = gtk_button_new();
870
        gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
871
        GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
872
        gtk_widget_set_size_request(ac_button, -1, 1);
873
        gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
874
        g_signal_connect(G_OBJECT(ac_button), "button_press_event",
875
                         G_CALLBACK(ac_label_button_pressed), mainwin);
876

    
877
        ac_label = gtk_label_new("");
878
        gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
879

    
880
        gtk_widget_show_all(hbox_stat);
881

    
882
        /* create views */
883
        mainwin->folderview  = folderview  = folderview_create();
884
        mainwin->summaryview = summaryview = summary_create();
885
        mainwin->messageview = messageview = messageview_create();
886
        mainwin->logwin      = log_window_create();
887

    
888
        folderview->mainwin      = mainwin;
889
        folderview->summaryview  = summaryview;
890

    
891
        summaryview->mainwin     = mainwin;
892
        summaryview->folderview  = folderview;
893
        summaryview->messageview = messageview;
894
        summaryview->window      = window;
895

    
896
        messageview->statusbar   = statusbar;
897
        messageview->mainwin     = mainwin;
898

    
899
        mainwin->window         = window;
900
        mainwin->vbox           = vbox;
901
        mainwin->menubar        = menubar;
902
        mainwin->menu_factory   = ifactory;
903
        mainwin->handlebox      = handlebox;
904
        mainwin->vbox_body      = vbox_body;
905
        mainwin->hbox_stat      = hbox_stat;
906
        mainwin->statusbar      = statusbar;
907
        mainwin->progressbar    = progressbar;
908
        mainwin->statuslabel    = statuslabel;
909
        mainwin->online_switch  = online_switch;
910
        mainwin->online_pixmap  = online_pixmap;
911
        mainwin->offline_pixmap = offline_pixmap;
912
        mainwin->online_tip     = online_tip;
913
        mainwin->ac_button      = ac_button;
914
        mainwin->ac_label       = ac_label;
915

    
916
        /* set context IDs for status bar */
917
        mainwin->mainwin_cid = gtk_statusbar_get_context_id
918
                (GTK_STATUSBAR(statusbar), "Main Window");
919
        mainwin->folderview_cid = gtk_statusbar_get_context_id
920
                (GTK_STATUSBAR(statusbar), "Folder View");
921
        mainwin->summaryview_cid = gtk_statusbar_get_context_id
922
                (GTK_STATUSBAR(statusbar), "Summary View");
923
        mainwin->messageview_cid = gtk_statusbar_get_context_id
924
                (GTK_STATUSBAR(statusbar), "Message View");
925

    
926
        messageview->statusbar_cid = mainwin->messageview_cid;
927

    
928
        /* allocate colors for summary view and folder view */
929
        summaryview->color_marked.red = summaryview->color_marked.green = 0;
930
        summaryview->color_marked.blue = (guint16)65535;
931

    
932
        summaryview->color_dim.red = summaryview->color_dim.green =
933
                summaryview->color_dim.blue = COLOR_DIM;
934

    
935
        folderview->color_new.red = (guint16)55000;
936
        folderview->color_new.green = folderview->color_new.blue = 15000;
937

    
938
        folderview->color_noselect.red = folderview->color_noselect.green =
939
                folderview->color_noselect.blue = COLOR_DIM;
940

    
941
        color[0] = summaryview->color_marked;
942
        color[1] = summaryview->color_dim;
943
        color[2] = folderview->color_new;
944

    
945
        colormap = gdk_window_get_colormap(window->window);
946
        gdk_colormap_alloc_colors(colormap, color, 3, FALSE, TRUE, success);
947
        for (i = 0; i < 3; i++) {
948
                if (success[i] == FALSE)
949
                        g_warning(_("MainWindow: color allocation %d failed\n"), i);
950
        }
951

    
952
        messageview->visible = prefs_common.msgview_visible;
953

    
954
        main_window_set_widgets(mainwin, type);
955

    
956
        g_signal_connect(G_OBJECT(window), "size_allocate",
957
                         G_CALLBACK(main_window_size_allocate_cb), mainwin);
958

    
959
        /* set menu items */
960
        menuitem = gtk_item_factory_get_item
961
                (ifactory, "/View/Code set/Auto detect");
962
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
963

    
964
        switch (prefs_common.toolbar_style) {
965
        case TOOLBAR_NONE:
966
                menuitem = gtk_item_factory_get_item
967
                        (ifactory, "/View/Show or hide/Toolbar/None");
968
                break;
969
        case TOOLBAR_ICON:
970
                menuitem = gtk_item_factory_get_item
971
                        (ifactory, "/View/Show or hide/Toolbar/Icon");
972
                break;
973
        case TOOLBAR_TEXT:
974
                menuitem = gtk_item_factory_get_item
975
                        (ifactory, "/View/Show or hide/Toolbar/Text");
976
                break;
977
        case TOOLBAR_BOTH:
978
                menuitem = gtk_item_factory_get_item
979
                        (ifactory, "/View/Show or hide/Toolbar/Icon and text");
980
        }
981
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
982

    
983
        gtk_widget_hide(mainwin->hbox_stat);
984
        menuitem = gtk_item_factory_get_item
985
                (ifactory, "/View/Show or hide/Status bar");
986
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
987
                                       prefs_common.show_statusbar);
988

    
989
        /* set account selection menu */
990
        ac_menu = gtk_item_factory_get_widget
991
                (ifactory, "/Configuration/Change current account");
992
        g_signal_connect(G_OBJECT(ac_menu), "selection_done",
993
                         G_CALLBACK(ac_menu_popup_closed), mainwin);
994
        mainwin->ac_menu = ac_menu;
995

    
996
        main_window_set_toolbar_sensitive(mainwin);
997

    
998
        /* create actions menu */
999
        action_update_mainwin_menu(ifactory, mainwin);
1000

    
1001
        /* initialize online switch */
1002
        prefs_common.online_mode = !prefs_common.online_mode;
1003
        online_switch_clicked(online_switch, mainwin);
1004

    
1005
        /* show main window */
1006
        gtk_widget_show(mainwin->window);
1007

    
1008
        /* initialize views */
1009
        folderview_init(folderview);
1010
        summary_init(summaryview);
1011
        messageview_init(messageview);
1012
        log_window_init(mainwin->logwin);
1013

    
1014
        mainwin->lock_count = 0;
1015
        mainwin->menu_lock_count = 0;
1016
        mainwin->cursor_count = 0;
1017

    
1018
        if (!watch_cursor)
1019
                watch_cursor = gdk_cursor_new(GDK_WATCH);
1020

    
1021
        mainwin_list = g_list_append(mainwin_list, mainwin);
1022

    
1023
        debug_print(_("done.\n"));
1024

    
1025
        return mainwin;
1026
}
1027

    
1028
void main_window_cursor_wait(MainWindow *mainwin)
1029
{
1030

    
1031
        if (mainwin->cursor_count == 0)
1032
                gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1033

    
1034
        mainwin->cursor_count++;
1035

    
1036
        gdk_flush();
1037
}
1038

    
1039
void main_window_cursor_normal(MainWindow *mainwin)
1040
{
1041
        if (mainwin->cursor_count)
1042
                mainwin->cursor_count--;
1043

    
1044
        if (mainwin->cursor_count == 0)
1045
                gdk_window_set_cursor(mainwin->window->window, NULL);
1046

    
1047
        gdk_flush();
1048
}
1049

    
1050
/* lock / unlock the user-interface */
1051
void main_window_lock(MainWindow *mainwin)
1052
{
1053
        if (mainwin->lock_count == 0)
1054
                gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1055

    
1056
        mainwin->lock_count++;
1057

    
1058
        main_window_set_menu_sensitive(mainwin);
1059
        main_window_set_toolbar_sensitive(mainwin);
1060
}
1061

    
1062
void main_window_unlock(MainWindow *mainwin)
1063
{
1064
        if (mainwin->lock_count)
1065
                mainwin->lock_count--;
1066

    
1067
        main_window_set_menu_sensitive(mainwin);
1068
        main_window_set_toolbar_sensitive(mainwin);
1069

    
1070
        if (mainwin->lock_count == 0)
1071
                gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1072
}
1073

    
1074
static void main_window_menu_callback_block(MainWindow *mainwin)
1075
{
1076
        mainwin->menu_lock_count++;
1077
}
1078

    
1079
static void main_window_menu_callback_unblock(MainWindow *mainwin)
1080
{
1081
        if (mainwin->menu_lock_count)
1082
                mainwin->menu_lock_count--;
1083
}
1084

    
1085
void main_window_reflect_prefs_all(void)
1086
{
1087
        GList *cur;
1088
        MainWindow *mainwin;
1089

    
1090
        for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1091
                mainwin = (MainWindow *)cur->data;
1092

    
1093
                main_window_show_cur_account(mainwin);
1094
                main_window_set_menu_sensitive(mainwin);
1095
                main_window_set_toolbar_sensitive(mainwin);
1096

    
1097
                if (prefs_common.immediate_exec)
1098
                        gtk_widget_hide(mainwin->exec_btn);
1099
                else
1100
                        gtk_widget_show(mainwin->exec_btn);
1101

    
1102
                summary_redisplay_msg(mainwin->summaryview);
1103
                headerview_set_visibility(mainwin->messageview->headerview,
1104
                                          prefs_common.display_header_pane);
1105
        }
1106
}
1107

    
1108
void main_window_set_summary_column(void)
1109
{
1110
        GList *cur;
1111
        MainWindow *mainwin;
1112

    
1113
        for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1114
                mainwin = (MainWindow *)cur->data;
1115
                summary_set_column_order(mainwin->summaryview);
1116
        }
1117
}
1118

    
1119
static void main_window_set_account_selector_menu(MainWindow *mainwin,
1120
                                                  GList *account_list)
1121
{
1122
        GList *cur_ac, *cur_item;
1123
        GtkWidget *menuitem;
1124
        PrefsAccount *ac_prefs;
1125

    
1126
        /* destroy all previous menu item */
1127
        cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1128
        while (cur_item != NULL) {
1129
                GList *next = cur_item->next;
1130
                gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1131
                cur_item = next;
1132
        }
1133

    
1134
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1135
                ac_prefs = (PrefsAccount *)cur_ac->data;
1136

    
1137
                menuitem = gtk_menu_item_new_with_label
1138
                        (ac_prefs->account_name
1139
                         ? ac_prefs->account_name : _("Untitled"));
1140
                gtk_widget_show(menuitem);
1141
                gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1142
                g_signal_connect(G_OBJECT(menuitem), "activate",
1143
                                 G_CALLBACK(account_selector_menu_cb),
1144
                                 ac_prefs);
1145
        }
1146
}
1147

    
1148
static void main_window_set_account_receive_menu(MainWindow *mainwin,
1149
                                                 GList *account_list)
1150
{
1151
        GList *cur_ac, *cur_item;
1152
        GtkWidget *menu;
1153
        GtkWidget *menuitem;
1154
        PrefsAccount *ac_prefs;
1155

    
1156
        menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1157
                                           "/Message/Receive");
1158

    
1159
        /* search for separator */
1160
        for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1161
             cur_item = cur_item->next) {
1162
                if (GTK_BIN(cur_item->data)->child == NULL) {
1163
                        cur_item = cur_item->next;
1164
                        break;
1165
                }
1166
        }
1167

    
1168
        /* destroy all previous menu item */
1169
        while (cur_item != NULL) {
1170
                GList *next = cur_item->next;
1171
                gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1172
                cur_item = next;
1173
        }
1174

    
1175
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1176
                ac_prefs = (PrefsAccount *)cur_ac->data;
1177

    
1178
                menuitem = gtk_menu_item_new_with_label
1179
                        (ac_prefs->account_name ? ac_prefs->account_name
1180
                         : _("Untitled"));
1181
                gtk_widget_show(menuitem);
1182
                gtk_menu_append(GTK_MENU(menu), menuitem);
1183
                g_signal_connect(G_OBJECT(menuitem), "activate",
1184
                                 G_CALLBACK(account_receive_menu_cb),
1185
                                 ac_prefs);
1186
        }
1187
}
1188

    
1189
void main_window_set_account_menu(GList *account_list)
1190
{
1191
        GList *cur;
1192
        MainWindow *mainwin;
1193

    
1194
        for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1195
                mainwin = (MainWindow *)cur->data;
1196
                main_window_set_account_selector_menu(mainwin, account_list);
1197
                main_window_set_account_receive_menu(mainwin, account_list);
1198
        }
1199
}
1200

    
1201
static void main_window_show_cur_account(MainWindow *mainwin)
1202
{
1203
        gchar *buf;
1204
        gchar *ac_name;
1205

    
1206
        ac_name = g_strdup(cur_account
1207
                           ? (cur_account->account_name
1208
                              ? cur_account->account_name : _("Untitled"))
1209
                           : _("none"));
1210

    
1211
        if (cur_account)
1212
                buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1213
        else
1214
                buf = g_strdup(PROG_VERSION);
1215
        gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1216
        g_free(buf);
1217

    
1218
        gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1219
        gtk_widget_queue_resize(mainwin->ac_button);
1220

    
1221
        g_free(ac_name);
1222
}
1223

    
1224
MainWindow *main_window_get(void)
1225
{
1226
        return (MainWindow *)mainwin_list->data;
1227
}
1228

    
1229
GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1230
{
1231
        switch (mainwin->type) {
1232
        case SEPARATE_FOLDER:
1233
                return mainwin->win.sep_folder.folderwin;
1234
        case SEPARATE_BOTH:
1235
                return mainwin->win.sep_both.folderwin;
1236
        default:
1237
                return NULL;
1238
        }
1239
}
1240

    
1241
GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1242
{
1243
        switch (mainwin->type) {
1244
        case SEPARATE_MESSAGE:
1245
                return mainwin->win.sep_message.messagewin;
1246
        case SEPARATE_BOTH:
1247
                return mainwin->win.sep_both.messagewin;
1248
        default:
1249
                return NULL;
1250
        }
1251
}
1252

    
1253
void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1254
{
1255
        GtkWidget *folder_wid  = GTK_WIDGET_PTR(mainwin->folderview);
1256
        GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1257
        GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1258

    
1259
        debug_print(_("Changing window separation type from %d to %d\n"),
1260
                    mainwin->type, type);
1261

    
1262
        if (mainwin->type == type) return;
1263

    
1264
        /* remove widgets from those containers */
1265
        gtk_widget_ref(folder_wid);
1266
        gtk_widget_ref(summary_wid);
1267
        gtk_widget_ref(message_wid);
1268
        gtkut_container_remove
1269
                (GTK_CONTAINER(folder_wid->parent), folder_wid);
1270
        gtkut_container_remove
1271
                (GTK_CONTAINER(summary_wid->parent), summary_wid);
1272
        gtkut_container_remove
1273
                (GTK_CONTAINER(message_wid->parent), message_wid);
1274

    
1275
        /* clean containers */
1276
        switch (mainwin->type) {
1277
        case SEPARATE_NONE:
1278
                gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1279
                break;
1280
        case SEPARATE_FOLDER:
1281
                gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1282
                gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1283
                break;
1284
        case SEPARATE_MESSAGE:
1285
                gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1286
                gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1287
                break;
1288
        case SEPARATE_BOTH:
1289
                gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1290
                gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1291
                break;
1292
        }
1293

    
1294
        gtk_widget_hide(mainwin->window);
1295
        main_window_set_widgets(mainwin, type);
1296
        gtk_widget_show(mainwin->window);
1297

    
1298
        gtk_widget_unref(folder_wid);
1299
        gtk_widget_unref(summary_wid);
1300
        gtk_widget_unref(message_wid);
1301
}
1302

    
1303
void main_window_toggle_message_view(MainWindow *mainwin)
1304
{
1305
        SummaryView *summaryview = mainwin->summaryview;
1306
        union CompositeWin *cwin = &mainwin->win;
1307
        GtkWidget *vpaned = NULL;
1308
        GtkWidget *container = NULL;
1309
        GtkWidget *msgwin = NULL;
1310

    
1311
        switch (mainwin->type) {
1312
        case SEPARATE_NONE:
1313
                vpaned = cwin->sep_none.vpaned;
1314
                container = cwin->sep_none.hpaned;
1315
                break;
1316
        case SEPARATE_FOLDER:
1317
                vpaned = cwin->sep_folder.vpaned;
1318
                container = mainwin->vbox_body;
1319
                break;
1320
        case SEPARATE_MESSAGE:
1321
                msgwin = mainwin->win.sep_message.messagewin;
1322
                break;
1323
        case SEPARATE_BOTH:
1324
                msgwin = mainwin->win.sep_both.messagewin;
1325
                break;
1326
        }
1327

    
1328
        if (msgwin) {
1329
                if (GTK_WIDGET_VISIBLE(msgwin)) {
1330
                        gtk_widget_hide(msgwin);
1331
                        mainwin->messageview->visible = FALSE;
1332
                        summaryview->displayed = NULL;
1333
                } else {
1334
                        gtk_widget_show(msgwin);
1335
                        mainwin->messageview->visible = TRUE;
1336
                }
1337
        } else if (vpaned->parent != NULL) {
1338
                mainwin->messageview->visible = FALSE;
1339
                summaryview->displayed = NULL;
1340
                gtk_widget_ref(vpaned);
1341
                gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1342
                gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1343
                gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1344
                              GTK_ARROW_UP, GTK_SHADOW_OUT);
1345
        } else {
1346
                mainwin->messageview->visible = TRUE;
1347
                gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1348
                gtk_container_add(GTK_CONTAINER(container), vpaned);
1349
                gtk_widget_unref(vpaned);
1350
                gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1351
                              GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1352
        }
1353

    
1354
        if (mainwin->messageview->visible == FALSE)
1355
                messageview_clear(mainwin->messageview);
1356

    
1357
        main_window_set_menu_sensitive(mainwin);
1358

    
1359
        prefs_common.msgview_visible = mainwin->messageview->visible;
1360

    
1361
        gtk_widget_grab_focus(summaryview->ctree);
1362
}
1363

    
1364
void main_window_get_size(MainWindow *mainwin)
1365
{
1366
        GtkAllocation *allocation;
1367

    
1368
        allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1369

    
1370
        if (allocation->width > 1 && allocation->height > 1) {
1371
                prefs_common.summaryview_width = allocation->width;
1372

    
1373
                if ((mainwin->type == SEPARATE_NONE ||
1374
                     mainwin->type == SEPARATE_FOLDER) &&
1375
                    messageview_is_visible(mainwin->messageview))
1376
                        prefs_common.summaryview_height = allocation->height;
1377

    
1378
                prefs_common.mainview_width = allocation->width;
1379
        }
1380

    
1381
        allocation = &mainwin->window->allocation;
1382
        if (allocation->width > 1 && allocation->height > 1) {
1383
                prefs_common.mainview_height = allocation->height;
1384
                prefs_common.mainwin_width   = allocation->width;
1385
                prefs_common.mainwin_height  = allocation->height;
1386
        }
1387

    
1388
        allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1389
        if (allocation->width > 1 && allocation->height > 1) {
1390
                prefs_common.folderview_width  = allocation->width;
1391
                prefs_common.folderview_height = allocation->height;
1392
        }
1393

    
1394
        allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1395
        if (allocation->width > 1 && allocation->height > 1) {
1396
                prefs_common.msgview_width = allocation->width;
1397
                prefs_common.msgview_height = allocation->height;
1398
        }
1399

    
1400
#if 0
1401
        debug_print("summaryview size: %d x %d\n",
1402
                    prefs_common.summaryview_width,
1403
                    prefs_common.summaryview_height);
1404
        debug_print("folderview size: %d x %d\n",
1405
                    prefs_common.folderview_width,
1406
                    prefs_common.folderview_height);
1407
        debug_print("messageview size: %d x %d\n",
1408
                    prefs_common.msgview_width,
1409
                    prefs_common.msgview_height);
1410
#endif
1411
}
1412

    
1413
void main_window_get_position(MainWindow *mainwin)
1414
{
1415
        gint x, y;
1416
        GtkWidget *window;
1417

    
1418
        gtkut_widget_get_uposition(mainwin->window, &x, &y);
1419

    
1420
        prefs_common.mainview_x = x;
1421
        prefs_common.mainview_y = y;
1422
        prefs_common.mainwin_x = x;
1423
        prefs_common.mainwin_y = y;
1424

    
1425
        debug_print("main window position: %d, %d\n", x, y);
1426

    
1427
        window = main_window_get_folder_window(mainwin);
1428
        if (window) {
1429
                gtkut_widget_get_uposition(window, &x, &y);
1430
                prefs_common.folderwin_x = x;
1431
                prefs_common.folderwin_y = y;
1432
                debug_print("folder window position: %d, %d\n", x, y);
1433
        }
1434
        window = main_window_get_message_window(mainwin);
1435
        if (window) {
1436
                gtkut_widget_get_uposition(window, &x, &y);
1437
                prefs_common.main_msgwin_x = x;
1438
                prefs_common.main_msgwin_y = y;
1439
                debug_print("message window position: %d, %d\n", x, y);
1440
        }
1441
}
1442

    
1443
void main_window_progress_on(MainWindow *mainwin)
1444
{
1445
        gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), TRUE);
1446
        gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1447
}
1448

    
1449
void main_window_progress_off(MainWindow *mainwin)
1450
{
1451
        gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), FALSE);
1452
        gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1453
        gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1454
}
1455

    
1456
void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1457
{
1458
        gchar buf[32];
1459

    
1460
        g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1461
        gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), buf);
1462
        gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar),
1463
                                (cur == 0 && total == 0) ? 0 :
1464
                                (gfloat)cur / (gfloat)total);
1465
}
1466

    
1467
void main_window_toggle_online(MainWindow *mainwin, gboolean online)
1468
{
1469
        if (prefs_common.online_mode != online)
1470
                online_switch_clicked(mainwin->online_switch, mainwin);
1471
}
1472

    
1473
gboolean main_window_toggle_online_if_offline(MainWindow *mainwin)
1474
{
1475
        if (!prefs_common.online_mode) {
1476
                if (alertpanel(_("Offline"),
1477
                               _("You are offline. Go online?"),
1478
                               _("Yes"), _("No"), NULL) == G_ALERTDEFAULT)
1479
                        main_window_toggle_online(mainwin, TRUE);
1480
        }
1481

    
1482
        return prefs_common.online_mode;
1483
}
1484

    
1485
void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1486
{
1487
        GList *list;
1488

    
1489
        if (confirm) {
1490
                if (alertpanel(_("Empty all trash"),
1491
                               _("Empty messages in all trash?"),
1492
                               _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1493
                        return;
1494
                manage_window_focus_in(mainwin->window, NULL, NULL);
1495
        }
1496

    
1497
        procmsg_empty_all_trash();
1498
        statusbar_pop_all();
1499

    
1500
        for (list = folder_get_list(); list != NULL; list = list->next) {
1501
                Folder *folder;
1502

    
1503
                folder = list->data;
1504
                if (folder->trash)
1505
                        folderview_update_item(folder->trash, TRUE);
1506
        }
1507

    
1508
        if (mainwin->summaryview->folder_item &&
1509
            mainwin->summaryview->folder_item->stype == F_TRASH)
1510
                gtk_widget_grab_focus(mainwin->folderview->ctree);
1511
}
1512

    
1513
void main_window_add_mailbox(MainWindow *mainwin)
1514
{
1515
        gchar *path;
1516
        Folder *folder;
1517

    
1518
        path = input_dialog(_("Add mailbox"),
1519
                            _("Input the location of mailbox.\n"
1520
                              "If the existing mailbox is specified, it will be\n"
1521
                              "scanned automatically."),
1522
                            "Mail");
1523
        if (!path) return;
1524
        if (folder_find_from_path(path)) {
1525
                alertpanel_error(_("The mailbox `%s' already exists."), path);
1526
                g_free(path);
1527
                return;
1528
        }
1529
        if (!strcmp(path, "Mail"))
1530
                folder = folder_new(F_MH, _("Mailbox"), path);
1531
        else
1532
                folder = folder_new(F_MH, g_basename(path), path);
1533
        g_free(path);
1534

    
1535
        if (folder->klass->create_tree(folder) < 0) {
1536
                alertpanel_error(_("Creation of the mailbox failed.\n"
1537
                                   "Maybe some files already exist, or you don't have the permission to write there."));
1538
                folder_destroy(folder);
1539
                return;
1540
        }
1541

    
1542
        folder_add(folder);
1543
        folder_set_ui_func(folder, scan_tree_func, mainwin);
1544
        folder->klass->scan_tree(folder);
1545
        folder_set_ui_func(folder, NULL, NULL);
1546

    
1547
        folderview_set(mainwin->folderview);
1548
}
1549

    
1550
typedef enum
1551
{
1552
        M_UNLOCKED            = 1 << 0,
1553
        M_MSG_EXIST           = 1 << 1,
1554
        M_TARGET_EXIST        = 1 << 2,
1555
        M_SINGLE_TARGET_EXIST = 1 << 3,
1556
        M_EXEC                = 1 << 4,
1557
        M_ALLOW_REEDIT        = 1 << 5,
1558
        M_HAVE_ACCOUNT        = 1 << 6,
1559
        M_THREADED              = 1 << 7,
1560
        M_UNTHREADED              = 1 << 8,
1561
        M_ALLOW_DELETE              = 1 << 9,
1562
        M_INC_ACTIVE              = 1 << 10,
1563

    
1564
        M_FOLDER_NEWOK              = 1 << 11,
1565
        M_FOLDER_RENOK              = 1 << 12,
1566
        M_FOLDER_DELOK              = 1 << 13,
1567
        M_MBOX_ADDOK              = 1 << 14,
1568
        M_MBOX_RMOK              = 1 << 15,
1569
        M_MBOX_CHKOK              = 1 << 16,
1570
        M_MBOX_CHKALLOK              = 1 << 17,
1571
        M_MBOX_REBUILDOK      = 1 << 18
1572
} SensitiveCond;
1573

    
1574
static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1575
{
1576
        SensitiveCond state = 0;
1577
        SummarySelection selection;
1578
        FolderItem *item = mainwin->summaryview->folder_item;
1579

    
1580
        selection = summary_get_selection_type(mainwin->summaryview);
1581

    
1582
        if (mainwin->lock_count == 0)
1583
                state |= M_UNLOCKED;
1584
        if (selection != SUMMARY_NONE)
1585
                state |= M_MSG_EXIST;
1586
        if (item && item->path && item->parent && !item->no_select) {
1587
                state |= M_EXEC;
1588
                if (item->threaded)
1589
                        state |= M_THREADED;
1590
                else
1591
                        state |= M_UNTHREADED;        
1592
                if (FOLDER_TYPE(item->folder) != F_NEWS)
1593
                        state |= M_ALLOW_DELETE;
1594
        }
1595
        if (selection == SUMMARY_SELECTED_SINGLE ||
1596
            selection == SUMMARY_SELECTED_MULTIPLE)
1597
                state |= M_TARGET_EXIST;
1598
        if (selection == SUMMARY_SELECTED_SINGLE)
1599
                state |= M_SINGLE_TARGET_EXIST;
1600
        if (selection == SUMMARY_SELECTED_SINGLE &&
1601
            (item &&
1602
             (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1603
              item->stype == F_QUEUE)))
1604
                state |= M_ALLOW_REEDIT;
1605
        if (cur_account)
1606
                state |= M_HAVE_ACCOUNT;
1607

    
1608
        if (inc_is_active())
1609
                state |= M_INC_ACTIVE;
1610

    
1611
        item = folderview_get_selected_item(mainwin->folderview);
1612
        if (item) {
1613
                state |= M_FOLDER_NEWOK;
1614
                if (item->parent == NULL) {
1615
                        state |= M_MBOX_RMOK;
1616
                        state |= M_MBOX_CHKOK;
1617
                }
1618
                if (FOLDER_IS_LOCAL(item->folder) ||
1619
                    FOLDER_TYPE(item->folder) == F_IMAP) {
1620
                        if (item->parent == NULL)
1621
                                state |= M_MBOX_REBUILDOK;
1622
                        else if (item->stype == F_NORMAL) {
1623
                                state |= M_FOLDER_RENOK;
1624
                                state |= M_FOLDER_DELOK;
1625
                        }
1626
                } else if (FOLDER_TYPE(item->folder) == F_NEWS) {
1627
                        if (item->parent != NULL)
1628
                                state |= M_FOLDER_DELOK;
1629
                }
1630
        }
1631
        state |= M_MBOX_ADDOK;
1632
        state |= M_MBOX_CHKALLOK;
1633

    
1634
        return state;
1635
}
1636

    
1637
void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1638
{
1639
        SensitiveCond state;
1640
        gboolean sensitive;
1641
        gint i = 0;
1642

    
1643
        struct {
1644
                GtkWidget *widget;
1645
                SensitiveCond cond;
1646
        } entry[12];
1647

    
1648
#define SET_WIDGET_COND(w, c)        \
1649
{                                \
1650
        entry[i].widget = w;        \
1651
        entry[i].cond = c;        \
1652
        i++;                        \
1653
}
1654

    
1655
        SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1656
        SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1657
        SET_WIDGET_COND(mainwin->compose_btn, M_HAVE_ACCOUNT);
1658
        SET_WIDGET_COND(mainwin->reply_btn,
1659
                        M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1660
        SET_WIDGET_COND(GTK_WIDGET_PTR(mainwin->reply_combo),
1661
                        M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1662
        SET_WIDGET_COND(mainwin->replyall_btn,
1663
                        M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1664
        SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1665
        SET_WIDGET_COND(GTK_WIDGET_PTR(mainwin->fwd_combo),
1666
                        M_HAVE_ACCOUNT|M_TARGET_EXIST);
1667
#if 0
1668
        SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1669
        SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1670
#endif
1671
        SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1672
        SET_WIDGET_COND(mainwin->delete_btn,
1673
                        M_TARGET_EXIST|M_ALLOW_DELETE);
1674
        SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC);
1675
        SET_WIDGET_COND(NULL, 0);
1676

    
1677
#undef SET_WIDGET_COND
1678

    
1679
        state = main_window_get_current_state(mainwin);
1680

    
1681
        for (i = 0; entry[i].widget != NULL; i++) {
1682
                sensitive = ((entry[i].cond & state) == entry[i].cond);
1683
                gtk_widget_set_sensitive(entry[i].widget, sensitive);
1684
        }
1685
}
1686

    
1687
void main_window_set_menu_sensitive(MainWindow *mainwin)
1688
{
1689
        GtkItemFactory *ifactory = mainwin->menu_factory;
1690
        SensitiveCond state;
1691
        gboolean sensitive;
1692
        GtkWidget *menu;
1693
        GtkWidget *menuitem;
1694
        FolderItem *item;
1695
        gchar *menu_path;
1696
        gint i;
1697
        GList *cur_item;
1698

    
1699
        static const struct {
1700
                gchar *const entry;
1701
                SensitiveCond cond;
1702
        } entry[] = {
1703
                {"/File/Folder/Create new folder...", M_UNLOCKED|M_FOLDER_NEWOK},
1704
                {"/File/Folder/Rename folder..."    , M_UNLOCKED|M_FOLDER_RENOK},
1705
                {"/File/Folder/Delete folder"       , M_UNLOCKED|M_FOLDER_DELOK},
1706
                {"/File/Mailbox/Add mailbox..."     , M_UNLOCKED|M_MBOX_ADDOK},
1707
                {"/File/Mailbox/Remove mailbox"     , M_UNLOCKED|M_MBOX_RMOK},
1708
                {"/File/Mailbox/Check for new messages"
1709
                                                    , M_UNLOCKED|M_MBOX_CHKOK},
1710
                {"/File/Mailbox/Check for new messages in all mailboxes"
1711
                                                    , M_UNLOCKED|M_MBOX_CHKALLOK},
1712
                {"/File/Mailbox/Rebuild folder tree", M_UNLOCKED|M_MBOX_REBUILDOK},
1713
                {"/File/Import mbox file..."        , M_UNLOCKED},
1714
                {"/File/Export to mbox file..."     , M_UNLOCKED},
1715
                {"/File/Empty all trash"            , M_UNLOCKED},
1716

    
1717
                {"/File/Save as..."  , M_SINGLE_TARGET_EXIST},
1718
                {"/File/Print..."    , M_TARGET_EXIST},
1719
                {"/File/Work offline", M_UNLOCKED},
1720
                /* {"/File/Close"    , M_UNLOCKED}, */
1721
                {"/File/Exit"        , M_UNLOCKED},
1722

    
1723
                {"/Edit/Select thread"             , M_SINGLE_TARGET_EXIST},
1724

    
1725
                {"/View/Sort"                      , M_EXEC},
1726
                {"/View/Thread view"               , M_EXEC},
1727
                {"/View/Expand all threads"        , M_MSG_EXIST},
1728
                {"/View/Collapse all threads"      , M_MSG_EXIST},
1729
                {"/View/Go to/Prev message"        , M_MSG_EXIST},
1730
                {"/View/Go to/Next message"        , M_MSG_EXIST},
1731
                {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1732
                {"/View/Go to/Next unread message" , M_MSG_EXIST},
1733
                {"/View/Go to/Prev new message"    , M_MSG_EXIST},
1734
                {"/View/Go to/Next new message"    , M_MSG_EXIST},
1735
                {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1736
                {"/View/Go to/Next marked message" , M_MSG_EXIST},
1737
                {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1738
                {"/View/Go to/Next labeled message", M_MSG_EXIST},
1739
                {"/View/Open in new window"        , M_SINGLE_TARGET_EXIST},
1740
                {"/View/Show all header"           , M_SINGLE_TARGET_EXIST},
1741
                {"/View/Message source"            , M_SINGLE_TARGET_EXIST},
1742

    
1743
                {"/Message/Receive/Get from current account"
1744
                                                 , M_HAVE_ACCOUNT|M_UNLOCKED},
1745
                {"/Message/Receive/Get from all accounts"
1746
                                                 , M_HAVE_ACCOUNT|M_UNLOCKED},
1747
                {"/Message/Receive/Cancel receiving"
1748
                                                 , M_INC_ACTIVE},
1749

    
1750
                {"/Message/Compose new message"  , M_HAVE_ACCOUNT},
1751
                {"/Message/Reply"                , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1752
                {"/Message/Reply to"             , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1753
                {"/Message/Forward"              , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1754
                {"/Message/Forward as attachment", M_HAVE_ACCOUNT|M_TARGET_EXIST},
1755
                {"/Message/Redirect"             , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1756
                {"/Message/Move..."              , M_TARGET_EXIST|M_ALLOW_DELETE},
1757
                {"/Message/Copy..."              , M_TARGET_EXIST|M_EXEC},
1758
                {"/Message/Delete"               , M_TARGET_EXIST|M_ALLOW_DELETE},
1759
                {"/Message/Mark"                 , M_TARGET_EXIST},
1760
                {"/Message/Re-edit"              , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1761

    
1762
                {"/Tools/Add sender to address book"   , M_SINGLE_TARGET_EXIST},
1763
                {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
1764
                {"/Tools/Filter selected messages"     , M_TARGET_EXIST|M_EXEC},
1765
                {"/Tools/Create filter rule"           , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1766
                {"/Tools/Actions"                      , M_TARGET_EXIST|M_UNLOCKED},
1767
                {"/Tools/Execute"                      , M_MSG_EXIST|M_EXEC},
1768
                {"/Tools/Delete duplicated messages"   , M_MSG_EXIST|M_ALLOW_DELETE},
1769

    
1770
                {"/Configuration", M_UNLOCKED},
1771

    
1772
                {NULL, 0}
1773
        };
1774

    
1775
        state = main_window_get_current_state(mainwin);
1776

    
1777
        for (i = 0; entry[i].entry != NULL; i++) {
1778
                sensitive = ((entry[i].cond & state) == entry[i].cond);
1779
                menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1780
        }
1781

    
1782
        menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1783

    
1784
        /* search for separator */
1785
        for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1786
             cur_item = cur_item->next) {
1787
                if (GTK_BIN(cur_item->data)->child == NULL) {
1788
                        cur_item = cur_item->next;
1789
                        break;
1790
                }
1791
        }
1792

    
1793
        for (; cur_item != NULL; cur_item = cur_item->next) {
1794
                gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1795
                                         (M_UNLOCKED & state) != 0);
1796
        }
1797

    
1798
        main_window_menu_callback_block(mainwin);
1799

    
1800
#define SET_CHECK_MENU_ACTIVE(path, active) \
1801
{ \
1802
        menuitem = gtk_item_factory_get_widget(ifactory, path); \
1803
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1804
}
1805

    
1806
        SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1807
                              messageview_is_visible(mainwin->messageview));
1808

    
1809
        item = mainwin->summaryview->folder_item;
1810
        menu_path = "/View/Sort/Don't sort";
1811
        if (item) {
1812
                switch (item->sort_key) {
1813
                case SORT_BY_NUMBER:
1814
                        menu_path = "/View/Sort/by number"; break;
1815
                case SORT_BY_SIZE:
1816
                        menu_path = "/View/Sort/by size"; break;
1817
                case SORT_BY_DATE:
1818
                        menu_path = "/View/Sort/by date"; break;
1819
                case SORT_BY_FROM:
1820
                        menu_path = "/View/Sort/by from"; break;
1821
                case SORT_BY_TO:
1822
                        menu_path = "/View/Sort/by recipient"; break;
1823
                case SORT_BY_SUBJECT:
1824
                        menu_path = "/View/Sort/by subject"; break;
1825
                case SORT_BY_LABEL:
1826
                        menu_path = "/View/Sort/by color label"; break;
1827
                case SORT_BY_MARK:
1828
                        menu_path = "/View/Sort/by mark"; break;
1829
                case SORT_BY_UNREAD:
1830
                        menu_path = "/View/Sort/by unread"; break;
1831
                case SORT_BY_MIME:
1832
                        menu_path = "/View/Sort/by attachment"; break;
1833
                case SORT_BY_NONE:
1834
                default:
1835
                        menu_path = "/View/Sort/Don't sort"; break;
1836
                }
1837
        }
1838
        SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1839

    
1840
        if (!item || item->sort_type == SORT_ASCENDING) {
1841
                SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1842
        } else {
1843
                SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1844
        }
1845

    
1846
        if (item && item->sort_key != SORT_BY_NONE) {
1847
                menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1848
                menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1849
        } else {
1850
                menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1851
                menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1852
        }
1853

    
1854
        SET_CHECK_MENU_ACTIVE("/View/Show all header",
1855
                              mainwin->messageview->textview->show_all_headers);
1856
        SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1857

    
1858
#undef SET_CHECK_MENU_ACTIVE
1859

    
1860
        main_window_menu_callback_unblock(mainwin);
1861
}
1862

    
1863
void main_window_popup(MainWindow *mainwin)
1864
{
1865
        gtkut_window_popup(mainwin->window);
1866

    
1867
        switch (mainwin->type) {
1868
        case SEPARATE_FOLDER:
1869
                gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1870
                break;
1871
        case SEPARATE_MESSAGE:
1872
                gtkut_window_popup(mainwin->win.sep_message.messagewin);
1873
                break;
1874
        case SEPARATE_BOTH:
1875
                gtkut_window_popup(mainwin->win.sep_both.folderwin);
1876
                gtkut_window_popup(mainwin->win.sep_both.messagewin);
1877
                break;
1878
        default:
1879
                break;
1880
        }
1881
}
1882

    
1883
static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1884
{
1885
        GtkWidget *folderwin = NULL;
1886
        GtkWidget *messagewin = NULL;
1887
        GtkWidget *hpaned;
1888
        GtkWidget *vpaned;
1889
        GtkWidget *vbox_body = mainwin->vbox_body;
1890
        GtkItemFactory *ifactory = mainwin->menu_factory;
1891
        GtkWidget *menuitem;
1892

    
1893
        debug_print("Setting widgets... ");
1894

    
1895
        /* create separated window(s) if needed */
1896
        if (type & SEPARATE_FOLDER) {
1897
                folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1898
                gtk_window_set_title(GTK_WINDOW(folderwin),
1899
                                     _("Sylpheed - Folder View"));
1900
                gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1901
                                       "folder_view", "Sylpheed");
1902
                gtk_window_set_policy(GTK_WINDOW(folderwin),
1903
                                      TRUE, TRUE, FALSE);
1904
                gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1905
                                         prefs_common.folderwin_y);
1906
                gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1907
                                               BORDER_WIDTH);
1908
                g_signal_connect(G_OBJECT(folderwin), "delete_event",
1909
                                 G_CALLBACK(folder_window_close_cb), mainwin);
1910
                gtk_container_add(GTK_CONTAINER(folderwin),
1911
                                  GTK_WIDGET_PTR(mainwin->folderview));
1912
                gtk_widget_realize(folderwin);
1913
                if (prefs_common.folderview_visible)
1914
                        gtk_widget_show(folderwin);
1915
        }
1916
        if (type & SEPARATE_MESSAGE) {
1917
                messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1918
                gtk_window_set_title(GTK_WINDOW(messagewin),
1919
                                     _("Sylpheed - Message View"));
1920
                gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1921
                                       "message_view", "Sylpheed");
1922
                gtk_window_set_policy(GTK_WINDOW(messagewin),
1923
                                      TRUE, TRUE, FALSE);
1924
                gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
1925
                                         prefs_common.main_msgwin_y);
1926
                gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1927
                                               BORDER_WIDTH);
1928
                g_signal_connect(G_OBJECT(messagewin), "delete_event",
1929
                                 G_CALLBACK(message_window_close_cb), mainwin);
1930
                gtk_container_add(GTK_CONTAINER(messagewin),
1931
                                  GTK_WIDGET_PTR(mainwin->messageview));
1932
                gtk_widget_realize(messagewin);
1933
                if (messageview_is_visible(mainwin->messageview))
1934
                        gtk_widget_show(messagewin);
1935
        }
1936

    
1937
        gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
1938
                                    prefs_common.folderview_width,
1939
                                    prefs_common.folderview_height);
1940
        gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
1941
                                    prefs_common.summaryview_width,
1942
                                    prefs_common.summaryview_height);
1943
        gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
1944
                                    prefs_common.msgview_width,
1945
                                    prefs_common.msgview_height);
1946

    
1947
        switch (type) {
1948
        case SEPARATE_NONE:
1949
                hpaned = gtk_hpaned_new();
1950
                gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1951
                gtk_paned_add1(GTK_PANED(hpaned),
1952
                               GTK_WIDGET_PTR(mainwin->folderview));
1953
                gtk_widget_show(hpaned);
1954
                gtk_widget_queue_resize(hpaned);
1955

    
1956
                vpaned = gtk_vpaned_new();
1957
                if (messageview_is_visible(mainwin->messageview)) {
1958
                        gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1959
                        gtk_paned_add1(GTK_PANED(vpaned),
1960
                                       GTK_WIDGET_PTR(mainwin->summaryview));
1961
                } else {
1962
                        gtk_paned_add2(GTK_PANED(hpaned),
1963
                                       GTK_WIDGET_PTR(mainwin->summaryview));
1964
                        gtk_widget_ref(vpaned);
1965
                }
1966
                gtk_paned_add2(GTK_PANED(vpaned),
1967
                               GTK_WIDGET_PTR(mainwin->messageview));
1968
                gtk_widget_show(vpaned);
1969
                gtk_widget_queue_resize(vpaned);
1970

    
1971
                mainwin->win.sep_none.hpaned = hpaned;
1972
                mainwin->win.sep_none.vpaned = vpaned;
1973
                break;
1974
        case SEPARATE_FOLDER:
1975
                vpaned = gtk_vpaned_new();
1976
                if (messageview_is_visible(mainwin->messageview)) {
1977
                        gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1978
                                           TRUE, TRUE, 0);
1979
                        gtk_paned_add1(GTK_PANED(vpaned),
1980
                                       GTK_WIDGET_PTR(mainwin->summaryview));
1981
                } else {
1982
                        gtk_box_pack_start(GTK_BOX(vbox_body),
1983
                                           GTK_WIDGET_PTR(mainwin->summaryview),
1984
                                           TRUE, TRUE, 0);
1985
                        gtk_widget_ref(vpaned);
1986
                }
1987
                gtk_paned_add2(GTK_PANED(vpaned),
1988
                               GTK_WIDGET_PTR(mainwin->messageview));
1989
                gtk_widget_show(vpaned);
1990
                gtk_widget_queue_resize(vpaned);
1991

    
1992
                mainwin->win.sep_folder.folderwin = folderwin;
1993
                mainwin->win.sep_folder.vpaned    = vpaned;
1994

    
1995
                break;
1996
        case SEPARATE_MESSAGE:
1997
                hpaned = gtk_hpaned_new();
1998
                gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1999
                gtk_paned_add1(GTK_PANED(hpaned),
2000
                               GTK_WIDGET_PTR(mainwin->folderview));
2001
                gtk_paned_add2(GTK_PANED(hpaned),
2002
                               GTK_WIDGET_PTR(mainwin->summaryview));
2003
                gtk_widget_show(hpaned);
2004
                gtk_widget_queue_resize(hpaned);
2005

    
2006
                mainwin->win.sep_message.messagewin = messagewin;
2007
                mainwin->win.sep_message.hpaned     = hpaned;
2008

    
2009
                break;
2010
        case SEPARATE_BOTH:
2011
                gtk_box_pack_start(GTK_BOX(vbox_body),
2012
                                   GTK_WIDGET_PTR(mainwin->summaryview),
2013
                                   TRUE, TRUE, 0);
2014

    
2015
                mainwin->win.sep_both.folderwin = folderwin;
2016
                mainwin->win.sep_both.messagewin = messagewin;
2017

    
2018
                break;
2019
        }
2020

    
2021
        gtk_widget_set_uposition(mainwin->window,
2022
                                 prefs_common.mainwin_x,
2023
                                 prefs_common.mainwin_y);
2024

    
2025
        gtk_widget_queue_resize(vbox_body);
2026
        gtk_widget_queue_resize(mainwin->vbox);
2027
        gtk_widget_queue_resize(mainwin->window);
2028

    
2029
        mainwin->type = type;
2030

    
2031
        /* toggle menu state */
2032
        menuitem = gtk_item_factory_get_item
2033
                (ifactory, "/View/Show or hide/Folder tree");
2034
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2035
                                       (type & SEPARATE_FOLDER) == 0 ? TRUE :
2036
                                       prefs_common.folderview_visible);
2037
        gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2038
        menuitem = gtk_item_factory_get_item
2039
                (ifactory, "/View/Show or hide/Message view");
2040
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2041
                                       (type & SEPARATE_MESSAGE) == 0 ? TRUE :
2042
                                       prefs_common.msgview_visible);
2043

    
2044
        menuitem = gtk_item_factory_get_item
2045
                (ifactory, "/View/Separate folder tree");
2046
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2047
                                       ((type & SEPARATE_FOLDER) != 0));
2048
        menuitem = gtk_item_factory_get_item
2049
                (ifactory, "/View/Separate message view");
2050
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2051
                                       ((type & SEPARATE_MESSAGE) != 0));
2052

    
2053
        if (folderwin) {
2054
                g_signal_connect
2055
                        (G_OBJECT(folderwin), "size_allocate",
2056
                         G_CALLBACK(folder_window_size_allocate_cb), mainwin);
2057
        }
2058
        if (messagewin) {
2059
                g_signal_connect
2060
                        (G_OBJECT(messagewin), "size_allocate",
2061
                         G_CALLBACK(message_window_size_allocate_cb), mainwin);
2062
        }
2063

    
2064
        debug_print("done.\n");
2065
}
2066

    
2067
static GtkItemFactoryEntry reply_entries[] =
2068
{
2069
        {N_("/_Reply"),                        NULL, reply_cb, COMPOSE_REPLY, NULL},
2070
        {N_("/Reply to _all"),                NULL, reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
2071
        {N_("/Reply to _sender"),        NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
2072
        {N_("/Reply to mailing _list"),        NULL, reply_cb, COMPOSE_REPLY_TO_LIST, NULL}
2073
};
2074

    
2075
static GtkItemFactoryEntry forward_entries[] =
2076
{
2077
        {N_("/_Forward"),                NULL, reply_cb, COMPOSE_FORWARD, NULL},
2078
        {N_("/For_ward as attachment"), NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
2079
        {N_("/Redirec_t"),                NULL, reply_cb, COMPOSE_REDIRECT, NULL}
2080
};
2081

    
2082
static void main_window_toolbar_create(MainWindow *mainwin,
2083
                                       GtkWidget *container)
2084
{
2085
        GtkWidget *toolbar;
2086
        GtkWidget *icon_wid;
2087
        GtkWidget *get_btn;
2088
        GtkWidget *getall_btn;
2089
        GtkWidget *send_btn;
2090
        GtkWidget *compose_btn;
2091
        GtkWidget *reply_btn;
2092
        ComboButton *reply_combo;
2093
        GtkWidget *replyall_btn;
2094
        GtkWidget *fwd_btn;
2095
        ComboButton *fwd_combo;
2096
#if 0
2097
        GtkWidget *prefs_btn;
2098
        GtkWidget *account_btn;
2099
#endif
2100
        GtkWidget *next_btn;
2101
        GtkWidget *delete_btn;
2102
        GtkWidget *exec_btn;
2103

    
2104
        gint n_entries;
2105

    
2106
        toolbar = gtk_toolbar_new();
2107
        gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar),
2108
                                    GTK_ORIENTATION_HORIZONTAL);
2109
        gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2110
        gtk_container_add(GTK_CONTAINER(container), toolbar);
2111
        gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2112
        //gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2113
        //gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2114
        //                            GTK_TOOLBAR_SPACE_LINE);
2115
        gtk_widget_set_size_request(toolbar, 1, -1);
2116

    
2117
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
2118
        get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2119
                                          _("Get"),
2120
                                          _("Incorporate new mail"),
2121
                                          "Get",
2122
                                          icon_wid,
2123
                                          G_CALLBACK(toolbar_inc_cb),
2124
                                          mainwin);
2125
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
2126
        getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2127
                                             _("Get all"),
2128
                                             _("Incorporate new mail of all accounts"),
2129
                                             "Get all",
2130
                                             icon_wid,
2131
                                             G_CALLBACK(toolbar_inc_all_cb),
2132
                                             mainwin);
2133

    
2134
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2135

    
2136
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
2137
        send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2138
                                           _("Send"),
2139
                                           _("Send queued message(s)"),
2140
                                           "Send",
2141
                                           icon_wid,
2142
                                           G_CALLBACK(toolbar_send_cb),
2143
                                           mainwin);
2144

    
2145
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2146

    
2147
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
2148
        compose_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2149
                                              _("Compose"),
2150
                                              _("Compose new message"),
2151
                                              "New",
2152
                                              icon_wid,
2153
                                              G_CALLBACK(toolbar_compose_cb),
2154
                                              mainwin);
2155

    
2156
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2157
        reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2158
                                            _("Reply"),
2159
                                            _("Reply to the message"),
2160
                                            "Reply",
2161
                                            icon_wid,
2162
                                            G_CALLBACK(toolbar_reply_cb),
2163
                                            mainwin);
2164

    
2165
        n_entries = sizeof(reply_entries) / sizeof(reply_entries[0]);
2166
        reply_combo = gtkut_combo_button_create(reply_btn,
2167
                                                reply_entries, n_entries,
2168
                                                "<Reply>", mainwin);
2169
        gtk_button_set_relief(GTK_BUTTON(reply_combo->arrow), GTK_RELIEF_NONE);
2170
        gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
2171
                                  GTK_WIDGET_PTR(reply_combo),
2172
                                  _("Reply to the message"), "Reply");
2173

    
2174
        icon_wid = stock_pixmap_widget
2175
                (container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2176
        replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2177
                                               _("Reply all"),
2178
                                               _("Reply to all"),
2179
                                               "Reply to all",
2180
                                               icon_wid,
2181
                                               G_CALLBACK(toolbar_reply_to_all_cb),
2182
                                               mainwin);
2183

    
2184
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2185
        fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2186
                                          _("Forward"),
2187
                                          _("Forward the message"),
2188
                                          "Fwd",
2189
                                          icon_wid,
2190
                                          G_CALLBACK(toolbar_forward_cb),
2191
                                          mainwin);
2192

    
2193
        n_entries = sizeof(forward_entries) / sizeof(forward_entries[0]);
2194
        fwd_combo = gtkut_combo_button_create(fwd_btn,
2195
                                              forward_entries, n_entries,
2196
                                              "<Forward>", mainwin);
2197
        gtk_button_set_relief(GTK_BUTTON(fwd_combo->arrow), GTK_RELIEF_NONE);
2198
        gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
2199
                                  GTK_WIDGET_PTR(fwd_combo),
2200
                                  _("Forward the message"), "Fwd");
2201

    
2202
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2203

    
2204
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2205
        delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2206
                                          _("Delete"),
2207
                                          _("Delete the message"),
2208
                                          "Delete",
2209
                                          icon_wid,
2210
                                          G_CALLBACK(toolbar_delete_cb),
2211
                                          mainwin);
2212

    
2213
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2214
        exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2215
                                           _("Execute"),
2216
                                           _("Execute marked process"),
2217
                                           "Execute",
2218
                                           icon_wid,
2219
                                           G_CALLBACK(toolbar_exec_cb),
2220
                                           mainwin);
2221

    
2222
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2223
        next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2224
                                           _("Next"),
2225
                                           _("Next unread message"),
2226
                                           "Next unread",
2227
                                           icon_wid,
2228
                                           G_CALLBACK(toolbar_next_unread_cb),
2229
                                           mainwin);
2230

    
2231
#if 0
2232
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2233

2234
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2235
        prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2236
                                            _("Prefs"),
2237
                                            _("Common preferences"),
2238
                                            "Prefs",
2239
                                            icon_wid,
2240
                                            G_CALLBACK(toolbar_prefs_cb),
2241
                                            mainwin);
2242
        icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2243
        account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2244
                                              _("Account"),
2245
                                              _("Account setting"),
2246
                                              "Account",
2247
                                              icon_wid,
2248
                                              G_CALLBACK(toolbar_account_cb),
2249
                                              mainwin);
2250
        g_signal_connect(G_OBJECT(account_btn), "button_press_event",
2251
                         G_CALLBACK(toolbar_account_button_pressed), mainwin);
2252
#endif
2253

    
2254
        mainwin->toolbar      = toolbar;
2255
        mainwin->get_btn      = get_btn;
2256
        mainwin->getall_btn   = getall_btn;
2257
        mainwin->compose_btn  = compose_btn;
2258
        mainwin->reply_btn    = reply_btn;
2259
        mainwin->reply_combo  = reply_combo;
2260
        mainwin->replyall_btn = replyall_btn;
2261
        mainwin->fwd_btn      = fwd_btn;
2262
        mainwin->fwd_combo    = fwd_combo;
2263
        mainwin->send_btn     = send_btn;
2264
#if 0
2265
        mainwin->prefs_btn    = prefs_btn;
2266
        mainwin->account_btn  = account_btn;
2267
#endif
2268
        mainwin->next_btn     = next_btn;
2269
        mainwin->delete_btn   = delete_btn;
2270
        mainwin->exec_btn     = exec_btn;
2271

    
2272
        gtk_widget_show_all(toolbar);
2273
}
2274

    
2275
/* callback functions */
2276

    
2277
static void toolbar_inc_cb        (GtkWidget        *widget,
2278
                                 gpointer         data)
2279
{
2280
        MainWindow *mainwin = (MainWindow *)data;
2281

    
2282
        inc_mail_cb(mainwin, 0, NULL);
2283
}
2284

    
2285
static void toolbar_inc_all_cb        (GtkWidget        *widget,
2286
                                 gpointer         data)
2287
{
2288
        MainWindow *mainwin = (MainWindow *)data;
2289

    
2290
        inc_all_account_mail_cb(mainwin, 0, NULL);
2291
}
2292

    
2293
static void toolbar_send_cb        (GtkWidget        *widget,
2294
                                 gpointer         data)
2295
{
2296
        MainWindow *mainwin = (MainWindow *)data;
2297

    
2298
        send_queue_cb(mainwin, 0, NULL);
2299
}
2300

    
2301
static void toolbar_compose_cb        (GtkWidget        *widget,
2302
                                 gpointer         data)
2303
{
2304
        MainWindow *mainwin = (MainWindow *)data;
2305

    
2306
        compose_cb(mainwin, 0, NULL);
2307
}
2308

    
2309
static void toolbar_reply_cb        (GtkWidget        *widget,
2310
                                 gpointer         data)
2311
{
2312
        MainWindow *mainwin = (MainWindow *)data;
2313

    
2314
        if (prefs_common.default_reply_list)
2315
                reply_cb(mainwin, COMPOSE_REPLY_TO_LIST, NULL);
2316
        else
2317
                reply_cb(mainwin, COMPOSE_REPLY, NULL);
2318
}
2319

    
2320
static void toolbar_reply_to_all_cb        (GtkWidget        *widget,
2321
                                         gpointer         data)
2322
{
2323
        MainWindow *mainwin = (MainWindow *)data;
2324

    
2325
        reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
2326
}
2327

    
2328
static void toolbar_forward_cb        (GtkWidget        *widget,
2329
                                 gpointer         data)
2330
{
2331
        MainWindow *mainwin = (MainWindow *)data;
2332

    
2333
        reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2334
}
2335

    
2336
static void toolbar_delete_cb        (GtkWidget        *widget,
2337
                                 gpointer         data)
2338
{
2339
        MainWindow *mainwin = (MainWindow *)data;
2340

    
2341
        summary_delete(mainwin->summaryview);
2342
}
2343

    
2344
static void toolbar_exec_cb        (GtkWidget        *widget,
2345
                                 gpointer         data)
2346
{
2347
        MainWindow *mainwin = (MainWindow *)data;
2348

    
2349
        summary_execute(mainwin->summaryview);
2350
}
2351

    
2352
static void toolbar_next_unread_cb        (GtkWidget        *widget,
2353
                                         gpointer         data)
2354
{
2355
        MainWindow *mainwin = (MainWindow *)data;
2356

    
2357
        next_unread_cb(mainwin, 0, NULL);
2358
}
2359

    
2360
#if 0
2361
static void toolbar_prefs_cb        (GtkWidget        *widget,
2362
                                 gpointer         data)
2363
{
2364
        prefs_common_open();
2365
}
2366

2367
static void toolbar_account_cb        (GtkWidget        *widget,
2368
                                 gpointer         data)
2369
{
2370
        MainWindow *mainwin = (MainWindow *)data;
2371

2372
        prefs_account_open_cb(mainwin, 0, NULL);
2373
}
2374

2375
static void toolbar_account_button_pressed(GtkWidget *widget,
2376
                                           GdkEventButton *event,
2377
                                           gpointer data)
2378
{
2379
        MainWindow *mainwin = (MainWindow *)data;
2380

2381
        if (!event) return;
2382
        if (event->button != 3) return;
2383

2384
        gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2385
        g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", widget);
2386

2387
        gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2388
                       menu_button_position, widget,
2389
                       event->button, event->time);
2390
}
2391
#endif
2392

    
2393
static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2394
                                   gpointer data)
2395
{
2396
        gtk_widget_set_size_request(child, 1, -1);
2397
}
2398

    
2399
static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2400
                                   gpointer data)
2401
{
2402
        gtk_widget_set_size_request(child, -1, -1);
2403
}
2404

    
2405
static void online_switch_clicked(GtkWidget *widget, gpointer data)
2406
{
2407
        MainWindow *mainwin = (MainWindow *)data;
2408
        GtkWidget *menuitem;
2409

    
2410
        menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
2411
                                             "/File/Work offline");
2412

    
2413
        if (prefs_common.online_mode == TRUE) {
2414
                prefs_common.online_mode = FALSE;
2415
                gtk_widget_hide(mainwin->online_pixmap);
2416
                gtk_widget_show(mainwin->offline_pixmap);
2417
                gtk_tooltips_set_tip
2418
                        (mainwin->online_tip, mainwin->online_switch,
2419
                         _("You are offline. Click the icon to go online."),
2420
                         NULL);
2421
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2422
                                               TRUE);
2423
                inc_autocheck_timer_remove();
2424
        } else {
2425
                prefs_common.online_mode = TRUE;
2426
                gtk_widget_hide(mainwin->offline_pixmap);
2427
                gtk_widget_show(mainwin->online_pixmap);
2428
                gtk_tooltips_set_tip
2429
                        (mainwin->online_tip, mainwin->online_switch,
2430
                         _("You are online. Click the icon to go offline."),
2431
                         NULL);
2432
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2433
                                               FALSE);
2434
                inc_autocheck_timer_set();
2435
        }
2436
}
2437

    
2438
static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2439
                                    gpointer data)
2440
{
2441
        MainWindow *mainwin = (MainWindow *)data;
2442

    
2443
        if (!event) return;
2444

    
2445
        gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2446
        g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", widget);
2447

    
2448
        gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2449
                       menu_button_position, widget,
2450
                       event->button, event->time);
2451
}
2452

    
2453
static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2454
{
2455
        MainWindow *mainwin = (MainWindow *)data;
2456
        GtkWidget *button;
2457

    
2458
        button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
2459
        if (!button) return;
2460
        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2461
        g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
2462
        manage_window_focus_in(mainwin->window, NULL, NULL);
2463
}
2464

    
2465
static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2466
                                 gpointer data)
2467
{
2468
        MainWindow *mainwin = (MainWindow *)data;
2469

    
2470
        if (mainwin->lock_count == 0)
2471
                app_exit_cb(data, 0, widget);
2472

    
2473
        return TRUE;
2474
}
2475

    
2476
static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2477
                                   gpointer data)
2478
{
2479
        MainWindow *mainwin = (MainWindow *)data;
2480
        GtkWidget *menuitem;
2481

    
2482
        menuitem = gtk_item_factory_get_item
2483
                (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2484
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2485

    
2486
        return TRUE;
2487
}
2488

    
2489
static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2490
                                    gpointer data)
2491
{
2492
        MainWindow *mainwin = (MainWindow *)data;
2493
        GtkWidget *menuitem;
2494

    
2495
        menuitem = gtk_item_factory_get_item
2496
                (mainwin->menu_factory, "/View/Show or hide/Message view");
2497
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2498

    
2499
        return TRUE;
2500
}
2501

    
2502
static void main_window_size_allocate_cb(GtkWidget *widget,
2503
                                         GtkAllocation *allocation,
2504
                                         gpointer data)
2505
{
2506
        MainWindow *mainwin = (MainWindow *)data;
2507

    
2508
        main_window_get_size(mainwin);
2509
}
2510

    
2511
static void folder_window_size_allocate_cb(GtkWidget *widget,
2512
                                           GtkAllocation *allocation,
2513
                                           gpointer data)
2514
{
2515
        MainWindow *mainwin = (MainWindow *)data;
2516

    
2517
        main_window_get_size(mainwin);
2518
}
2519

    
2520
static void message_window_size_allocate_cb(GtkWidget *widget,
2521
                                            GtkAllocation *allocation,
2522
                                            gpointer data)
2523
{
2524
        MainWindow *mainwin = (MainWindow *)data;
2525

    
2526
        main_window_get_size(mainwin);
2527
}
2528

    
2529
static void new_folder_cb(MainWindow *mainwin, guint action,
2530
                          GtkWidget *widget)
2531
{
2532
        folderview_new_folder(mainwin->folderview);
2533
}
2534

    
2535
static void rename_folder_cb(MainWindow *mainwin, guint action,
2536
                             GtkWidget *widget)
2537
{
2538
        folderview_rename_folder(mainwin->folderview);
2539
}
2540

    
2541
static void delete_folder_cb(MainWindow *mainwin, guint action,
2542
                             GtkWidget *widget)
2543
{
2544
        folderview_delete_folder(mainwin->folderview);
2545
}
2546

    
2547
static void add_mailbox_cb(MainWindow *mainwin, guint action,
2548
                           GtkWidget *widget)
2549
{
2550
        main_window_add_mailbox(mainwin);
2551
}
2552

    
2553
static void remove_mailbox_cb(MainWindow *mainwin, guint action,
2554
                              GtkWidget *widget)
2555
{
2556
        folderview_remove_mailbox(mainwin->folderview);
2557
}
2558

    
2559
static void update_folderview_cb(MainWindow *mainwin, guint action,
2560
                                 GtkWidget *widget)
2561
{
2562
        if (action == 0)
2563
                folderview_check_new_selected(mainwin->folderview);
2564
        else
2565
                folderview_check_new_all();
2566
}
2567

    
2568
static void rebuild_tree_cb(MainWindow *mainwin, guint action,
2569
                            GtkWidget *widget)
2570
{
2571
        folderview_rebuild_tree(mainwin->folderview);
2572
}
2573

    
2574
static void import_mbox_cb(MainWindow *mainwin, guint action,
2575
                           GtkWidget *widget)
2576
{
2577
        import_mbox(mainwin->summaryview->folder_item);
2578
}
2579

    
2580
static void export_mbox_cb(MainWindow *mainwin, guint action,
2581
                           GtkWidget *widget)
2582
{
2583
        export_mbox(mainwin->summaryview->folder_item);
2584
}
2585

    
2586
static void empty_trash_cb(MainWindow *mainwin, guint action,
2587
                           GtkWidget *widget)
2588
{
2589
        main_window_empty_trash(mainwin, TRUE);
2590
}
2591

    
2592
static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2593
{
2594
        summary_save_as(mainwin->summaryview);
2595
}
2596

    
2597
static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2598
{
2599
        summary_print(mainwin->summaryview);
2600
}
2601

    
2602
static void toggle_offline_cb(MainWindow *mainwin, guint action,
2603
                              GtkWidget *widget)
2604
{
2605
        main_window_toggle_online
2606
                (mainwin, !GTK_CHECK_MENU_ITEM(widget)->active);
2607
}
2608

    
2609
static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2610
{
2611
        if (prefs_common.confirm_on_exit) {
2612
                if (alertpanel(_("Exit"), _("Exit this program?"),
2613
                               _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2614
                        return;
2615
                manage_window_focus_in(mainwin->window, NULL, NULL);
2616
        }
2617

    
2618
        app_will_exit(widget, mainwin);
2619
}
2620

    
2621
static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2622
{
2623
        if (action == 1)
2624
                summary_search(mainwin->summaryview);
2625
        else
2626
                message_search(mainwin->messageview);
2627
}
2628

    
2629
static void toggle_folder_cb(MainWindow *mainwin, guint action,
2630
                             GtkWidget *widget)
2631
{
2632
        gboolean active;
2633

    
2634
        active = GTK_CHECK_MENU_ITEM(widget)->active;
2635

    
2636
        switch (mainwin->type) {
2637
        case SEPARATE_NONE:
2638
        case SEPARATE_MESSAGE:
2639
#if 0
2640
                if (active)
2641
                        gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2642
                else
2643
                        gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2644
#endif
2645
                break;
2646
        case SEPARATE_FOLDER:
2647
                if (active)
2648
                        gtk_widget_show(mainwin->win.sep_folder.folderwin);
2649
                else
2650
                        gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2651
                break;
2652
        case SEPARATE_BOTH:
2653
                if (active)
2654
                        gtk_widget_show(mainwin->win.sep_both.folderwin);
2655
                else
2656
                        gtk_widget_hide(mainwin->win.sep_both.folderwin);
2657
                break;
2658
        }
2659

    
2660
        prefs_common.folderview_visible = active;
2661
}
2662

    
2663
static void toggle_message_cb(MainWindow *mainwin, guint action,
2664
                              GtkWidget *widget)
2665
{
2666
        gboolean active;
2667

    
2668
        active = GTK_CHECK_MENU_ITEM(widget)->active;
2669

    
2670
        if (active != messageview_is_visible(mainwin->messageview))
2671
                summary_toggle_view(mainwin->summaryview);
2672
}
2673

    
2674
static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2675
                              GtkWidget *widget)
2676
{
2677
        switch ((ToolbarStyle)action) {
2678
        case TOOLBAR_NONE:
2679
                gtk_widget_hide(mainwin->handlebox);
2680
        case TOOLBAR_ICON:
2681
                gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2682
                                      GTK_TOOLBAR_ICONS);
2683
                break;
2684
        case TOOLBAR_TEXT:
2685
                gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2686
                                      GTK_TOOLBAR_TEXT);
2687
                break;
2688
        case TOOLBAR_BOTH:
2689
                gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2690
                                      GTK_TOOLBAR_BOTH);
2691
                break;
2692
        }
2693

    
2694
        if (action != TOOLBAR_NONE) {
2695
                gtk_widget_show(mainwin->handlebox);
2696
                gtk_widget_queue_resize(mainwin->handlebox);
2697
        }
2698

    
2699
        mainwin->toolbar_style = (ToolbarStyle)action;
2700
        prefs_common.toolbar_style = (ToolbarStyle)action;
2701
}
2702

    
2703
static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2704
                                GtkWidget *widget)
2705
{
2706
        if (GTK_CHECK_MENU_ITEM(widget)->active) {
2707
                gtk_widget_show(mainwin->hbox_stat);
2708
                prefs_common.show_statusbar = TRUE;
2709
        } else {
2710
                gtk_widget_hide(mainwin->hbox_stat);
2711
                prefs_common.show_statusbar = FALSE;
2712
        }
2713
}
2714

    
2715
static void separate_widget_cb(MainWindow *mainwin, guint action,
2716
                               GtkWidget *widget)
2717
{
2718
        SeparateType type;
2719

    
2720
        if (GTK_CHECK_MENU_ITEM(widget)->active)
2721
                type = mainwin->type | action;
2722
        else
2723
                type = mainwin->type & ~action;
2724

    
2725
        main_window_separation_change(mainwin, type);
2726

    
2727
        prefs_common.sep_folder = (type & SEPARATE_FOLDER)  != 0;
2728
        prefs_common.sep_msg    = (type & SEPARATE_MESSAGE) != 0;
2729
}
2730

    
2731
static void addressbook_open_cb(MainWindow *mainwin, guint action,
2732
                                GtkWidget *widget)
2733
{
2734
        addressbook_open(NULL);
2735
}
2736

    
2737
static void log_window_show_cb(MainWindow *mainwin, guint action,
2738
                               GtkWidget *widget)
2739
{
2740
        log_window_show(mainwin->logwin);
2741
}
2742

    
2743
static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2744
{
2745
        inc_mail(mainwin);
2746
}
2747

    
2748
static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2749
                                    GtkWidget *widget)
2750
{
2751
        inc_all_account_mail(mainwin, FALSE);
2752
}
2753

    
2754
static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2755
{
2756
        inc_cancel_all();
2757
}
2758

    
2759
static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2760
{
2761
        GList *list;
2762

    
2763
        if (!main_window_toggle_online_if_offline(mainwin))
2764
                return;
2765

    
2766
        for (list = folder_get_list(); list != NULL; list = list->next) {
2767
                Folder *folder = list->data;
2768

    
2769
                if (folder->queue) {
2770
                        gint ret;
2771

    
2772
                        ret = procmsg_send_queue(folder->queue,
2773
                                                 prefs_common.savemsg);
2774
                        statusbar_pop_all();
2775
                        if (ret > 0)
2776
                                folder_item_scan(folder->queue);
2777
                }
2778
        }
2779

    
2780
        folderview_update_all_updated(TRUE);
2781
}
2782

    
2783
static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2784
{
2785
        PrefsAccount *ac = NULL;
2786
        FolderItem *item = mainwin->summaryview->folder_item;
2787

    
2788
        if (item) {
2789
                ac = account_find_from_item(item);
2790
                if (ac && ac->protocol == A_NNTP &&
2791
                    FOLDER_TYPE(item->folder) == F_NEWS) {
2792
                        compose_new(ac, item, item->path, NULL);
2793
                        return;
2794
                }
2795
        }
2796

    
2797
        compose_new(ac, item, NULL, NULL);
2798
}
2799

    
2800
static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2801
{
2802
        summary_reply(mainwin->summaryview, (ComposeMode)action);
2803
}
2804

    
2805
static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2806
{
2807
        summary_move_to(mainwin->summaryview);
2808
}
2809

    
2810
static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2811
{
2812
        summary_copy_to(mainwin->summaryview);
2813
}
2814

    
2815
static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2816
{
2817
        summary_delete(mainwin->summaryview);
2818
}
2819

    
2820
static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2821
{
2822
        summary_open_msg(mainwin->summaryview);
2823
}
2824

    
2825
static void view_source_cb(MainWindow *mainwin, guint action,
2826
                           GtkWidget *widget)
2827
{
2828
        summary_view_source(mainwin->summaryview);
2829
}
2830

    
2831
static void show_all_header_cb(MainWindow *mainwin, guint action,
2832
                               GtkWidget *widget)
2833
{
2834
        if (mainwin->menu_lock_count) return;
2835
        summary_display_msg_selected(mainwin->summaryview,
2836
                                     GTK_CHECK_MENU_ITEM(widget)->active);
2837
}
2838

    
2839
static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2840
{
2841
        summary_mark(mainwin->summaryview);
2842
}
2843

    
2844
static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2845
{
2846
        summary_unmark(mainwin->summaryview);
2847
}
2848

    
2849
static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2850
                              GtkWidget *widget)
2851
{
2852
        summary_mark_as_unread(mainwin->summaryview);
2853
}
2854

    
2855
static void mark_as_read_cb(MainWindow *mainwin, guint action,
2856
                            GtkWidget *widget)
2857
{
2858
        summary_mark_as_read(mainwin->summaryview);
2859
}
2860

    
2861
static void mark_all_read_cb(MainWindow *mainwin, guint action,
2862
                             GtkWidget *widget)
2863
{
2864
        summary_mark_all_read(mainwin->summaryview);
2865
}
2866

    
2867
static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2868
{
2869
        summary_reedit(mainwin->summaryview);
2870
}
2871

    
2872
static void add_address_cb(MainWindow *mainwin, guint action,
2873
                           GtkWidget *widget)
2874
{
2875
        summary_add_address(mainwin->summaryview);
2876
}
2877

    
2878
static void set_charset_cb(MainWindow *mainwin, guint action,
2879
                           GtkWidget *widget)
2880
{
2881
        const gchar *str;
2882

    
2883
        if (GTK_CHECK_MENU_ITEM(widget)->active) {
2884
                str = conv_get_charset_str((CharSet)action);
2885
                g_free(prefs_common.force_charset);
2886
                prefs_common.force_charset = str ? g_strdup(str) : NULL;
2887

    
2888
                summary_redisplay_msg(mainwin->summaryview);
2889

    
2890
                debug_print("forced charset: %s\n",
2891
                            str ? str : "Auto-Detect");
2892
        }
2893
}
2894

    
2895
static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2896
{
2897
        if (mainwin->menu_lock_count) return;
2898
        if (!mainwin->summaryview->folder_item) return;
2899

    
2900
        if (GTK_CHECK_MENU_ITEM(widget)->active) {
2901
                summary_thread_build(mainwin->summaryview);
2902
                mainwin->summaryview->folder_item->threaded = TRUE;
2903
        } else {
2904
                summary_unthread(mainwin->summaryview);
2905
                mainwin->summaryview->folder_item->threaded = FALSE;
2906
        }
2907
}
2908

    
2909
static void expand_threads_cb(MainWindow *mainwin, guint action,
2910
                              GtkWidget *widget)
2911
{
2912
        summary_expand_threads(mainwin->summaryview);
2913
}
2914

    
2915
static void collapse_threads_cb(MainWindow *mainwin, guint action,
2916
                                GtkWidget *widget)
2917
{
2918
        summary_collapse_threads(mainwin->summaryview);
2919
}
2920

    
2921
static void set_display_item_cb(MainWindow *mainwin, guint action,
2922
                                GtkWidget *widget)
2923
{
2924
        prefs_summary_column_open();
2925
}
2926

    
2927
static void sort_summary_cb(MainWindow *mainwin, guint action,
2928
                            GtkWidget *widget)
2929
{
2930
        FolderItem *item = mainwin->summaryview->folder_item;
2931
        GtkWidget *menuitem;
2932

    
2933
        if (mainwin->menu_lock_count) return;
2934

    
2935
        if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2936
                menuitem = gtk_item_factory_get_item
2937
                        (mainwin->menu_factory, "/View/Sort/Ascending");
2938
                summary_sort(mainwin->summaryview, (FolderSortKey)action,
2939
                             GTK_CHECK_MENU_ITEM(menuitem)->active
2940
                             ? SORT_ASCENDING : SORT_DESCENDING);
2941
        }
2942
}
2943

    
2944
static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2945
                                 GtkWidget *widget)
2946
{
2947
        FolderItem *item = mainwin->summaryview->folder_item;
2948

    
2949
        if (mainwin->menu_lock_count) return;
2950

    
2951
        if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2952
                summary_sort(mainwin->summaryview,
2953
                             item->sort_key, (FolderSortType)action);
2954
}
2955

    
2956
static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2957
                                  GtkWidget *widget)
2958
{
2959
        summary_attract_by_subject(mainwin->summaryview);
2960
}
2961

    
2962
static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2963
                                 GtkWidget *widget)
2964
{
2965
        summary_delete_duplicated(mainwin->summaryview);
2966
}
2967

    
2968
static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2969
{
2970
        summary_filter(mainwin->summaryview, (gboolean)action);
2971
}
2972

    
2973
static void execute_summary_cb(MainWindow *mainwin, guint action,
2974
                               GtkWidget *widget)
2975
{
2976
        summary_execute(mainwin->summaryview);
2977
}
2978

    
2979
static void update_summary_cb(MainWindow *mainwin, guint action,
2980
                              GtkWidget *widget)
2981
{
2982
        FolderItem *fitem;
2983
        FolderView *folderview = mainwin->folderview;
2984

    
2985
        if (!mainwin->summaryview->folder_item) return;
2986
        if (!folderview->opened) return;
2987

    
2988
        fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2989
                                            folderview->opened);
2990
        if (!fitem) return;
2991

    
2992
        summary_show(mainwin->summaryview, fitem, TRUE);
2993
}
2994

    
2995
static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2996
{
2997
        summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2998
}
2999

    
3000
static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3001
{
3002
        summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3003
}
3004

    
3005
static void prev_unread_cb(MainWindow *mainwin, guint action,
3006
                           GtkWidget *widget)
3007
{
3008
        summary_select_prev_unread(mainwin->summaryview);
3009
}
3010

    
3011
static void next_unread_cb(MainWindow *mainwin, guint action,
3012
                           GtkWidget *widget)
3013
{
3014
        summary_select_next_unread(mainwin->summaryview);
3015
}
3016

    
3017
static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3018
{
3019
        summary_select_prev_new(mainwin->summaryview);
3020
}
3021

    
3022
static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3023
{
3024
        summary_select_next_new(mainwin->summaryview);
3025
}
3026

    
3027
static void prev_marked_cb(MainWindow *mainwin, guint action,
3028
                           GtkWidget *widget)
3029
{
3030
        summary_select_prev_marked(mainwin->summaryview);
3031
}
3032

    
3033
static void next_marked_cb(MainWindow *mainwin, guint action,
3034
                           GtkWidget *widget)
3035
{
3036
        summary_select_next_marked(mainwin->summaryview);
3037
}
3038

    
3039
static void prev_labeled_cb(MainWindow *mainwin, guint action,
3040
                            GtkWidget *widget)
3041
{
3042
        summary_select_prev_labeled(mainwin->summaryview);
3043
}
3044

    
3045
static void next_labeled_cb(MainWindow *mainwin, guint action,
3046
                            GtkWidget *widget)
3047
{
3048
        summary_select_next_labeled(mainwin->summaryview);
3049
}
3050

    
3051
static void goto_folder_cb(MainWindow *mainwin, guint action,
3052
                           GtkWidget *widget)
3053
{
3054
        FolderItem *to_folder;
3055

    
3056
        to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3057

    
3058
        if (to_folder)
3059
                folderview_select(mainwin->folderview, to_folder);
3060
}
3061

    
3062
static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3063
{
3064
        messageview_copy_clipboard(mainwin->messageview);
3065
}
3066

    
3067
static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3068
{
3069
        MessageView *msgview = mainwin->messageview;
3070

    
3071
        if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3072
                summary_select_all(mainwin->summaryview);
3073
        else if (messageview_is_visible(msgview) &&
3074
                 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3075
                  GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3076
                messageview_select_all(msgview);
3077
}
3078

    
3079
static void select_thread_cb(MainWindow *mainwin, guint action,
3080
                             GtkWidget *widget)
3081
{
3082
        summary_select_thread(mainwin->summaryview);
3083
}
3084

    
3085
static void create_filter_cb(MainWindow *mainwin, guint action,
3086
                             GtkWidget *widget)
3087
{
3088
        summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3089
}
3090

    
3091
static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3092
                                 GtkWidget *widget)
3093
{
3094
        prefs_common_open();
3095
}
3096

    
3097
static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3098
                                 GtkWidget *widget)
3099
{
3100
        prefs_filter_open(NULL, NULL);
3101
}
3102

    
3103
static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3104
                                   GtkWidget *widget)
3105
{
3106
        prefs_template_open();
3107
}
3108

    
3109
static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3110
                                  GtkWidget *widget)
3111
{
3112
        prefs_actions_open(mainwin);
3113
}
3114

    
3115
static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3116
                                  GtkWidget *widget)
3117
{
3118
        if (!cur_account) {
3119
                new_account_cb(mainwin, 0, widget);
3120
        } else {
3121
                account_open(cur_account);
3122
        }
3123
}
3124

    
3125
static void new_account_cb(MainWindow *mainwin, guint action,
3126
                           GtkWidget *widget)
3127
{
3128
        account_edit_open();
3129
        if (!compose_get_compose_list()) account_add();
3130
}
3131

    
3132
static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3133
{
3134
        cur_account = (PrefsAccount *)data;
3135
        main_window_reflect_prefs_all();
3136
}
3137

    
3138
static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3139
{
3140
        MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3141
        PrefsAccount *account = (PrefsAccount *)data;
3142

    
3143
        inc_account_mail(mainwin, account);
3144
}
3145

    
3146
static void manual_open_cb(MainWindow *mainwin, guint action,
3147
                           GtkWidget *widget)
3148
{
3149
        manual_open((ManualLang)action);
3150
}
3151

    
3152
static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3153
{
3154
        faq_open((ManualLang)action);
3155
}
3156

    
3157
static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3158
{
3159
        MainWindow *mainwin = (MainWindow *)data;
3160
        gchar *str;
3161

    
3162
        if (item->path)
3163
                str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3164
                                      LOCAL_FOLDER(folder)->rootpath,
3165
                                      G_DIR_SEPARATOR,
3166
                                      item->path);
3167
        else
3168
                str = g_strdup_printf(_("Scanning folder %s ..."),
3169
                                      LOCAL_FOLDER(folder)->rootpath);
3170

    
3171
        STATUSBAR_PUSH(mainwin, str);
3172
        STATUSBAR_POP(mainwin);
3173
        g_free(str);
3174
}