Statistics
| Revision:

root / src / mainwindow.c @ 3288

History | View | Annotate | Download (127 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2012 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 <glib/gi18n.h>
24
#include <gdk/gdkkeysyms.h>
25
#include <gtk/gtkmain.h>
26
#include <gtk/gtkversion.h>
27
#include <gtk/gtkwindow.h>
28
#include <gtk/gtkwidget.h>
29
#include <gtk/gtksignal.h>
30
#include <gtk/gtkvbox.h>
31
#include <gtk/gtkcontainer.h>
32
#include <gtk/gtkstatusbar.h>
33
#include <gtk/gtkprogressbar.h>
34
#include <gtk/gtkhpaned.h>
35
#include <gtk/gtkvpaned.h>
36
#include <gtk/gtkcheckmenuitem.h>
37
#include <gtk/gtkitemfactory.h>
38
#include <gtk/gtkeditable.h>
39
#include <gtk/gtkmenu.h>
40
#include <gtk/gtkmenuitem.h>
41
#include <gtk/gtktoolbar.h>
42
#include <gtk/gtktoolitem.h>
43
#include <gtk/gtktoolbutton.h>
44
#include <gtk/gtkseparatortoolitem.h>
45
#include <gtk/gtkbutton.h>
46
#include <gtk/gtktooltips.h>
47
#include <gtk/gtkarrow.h>
48
#include <gtk/gtkstock.h>
49
#include <gtk/gtkimage.h>
50
#include <string.h>
51

    
52
#include "main.h"
53
#include "mainwindow.h"
54
#include "folderview.h"
55
#include "foldersel.h"
56
#include "summaryview.h"
57
#include "quick_search.h"
58
#include "query_search.h"
59
#include "messageview.h"
60
#include "mimeview.h"
61
#include "message_search.h"
62
#include "headerview.h"
63
#include "menu.h"
64
#include "stock_pixmap.h"
65
#include "folder.h"
66
#include "inc.h"
67
#include "rpop3.h"
68
#include "compose.h"
69
#include "procmsg.h"
70
#include "send_message.h"
71
#include "import.h"
72
#include "export.h"
73
#include "prefs_common.h"
74
#include "prefs_common_dialog.h"
75
#include "prefs_filter.h"
76
#include "prefs_actions.h"
77
#include "prefs_account.h"
78
#include "prefs_summary_column.h"
79
#include "prefs_template.h"
80
#include "prefs_search_folder.h"
81
#include "prefs_toolbar.h"
82
#include "plugin_manager.h"
83
#include "action.h"
84
#include "account.h"
85
#include "account_dialog.h"
86
#include "addressbook.h"
87
#include "logwindow.h"
88
#include "manage_window.h"
89
#include "alertpanel.h"
90
#include "statusbar.h"
91
#include "inputdialog.h"
92
#include "trayicon.h"
93
#include "printing.h"
94
#include "utils.h"
95
#include "gtkutils.h"
96
#include "codeconv.h"
97
#include "about.h"
98
#include "manual.h"
99
#include "update_check.h"
100
#include "setup.h"
101
#include "version.h"
102

    
103
#define AC_LABEL_WIDTH        240
104

    
105
#define STATUSBAR_PUSH(mainwin, str) \
106
{ \
107
        gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
108
                           mainwin->mainwin_cid, str); \
109
        gtkut_widget_draw_now(mainwin->statusbar); \
110
}
111

    
112
#define STATUSBAR_POP(mainwin) \
113
{ \
114
        gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
115
                          mainwin->mainwin_cid); \
116
}
117

    
118
/* list of all instantiated MainWindow */
119
static GList *mainwin_list = NULL;
120

    
121
static GdkCursor *watch_cursor;
122

    
123
static void main_window_menu_callback_block        (MainWindow        *mainwin);
124
static void main_window_menu_callback_unblock        (MainWindow        *mainwin);
125

    
126
static void main_window_show_cur_account        (MainWindow        *mainwin);
127

    
128
static void main_window_set_toolbar_button_visibility
129
                                                (MainWindow        *mainwin);
130

    
131
static void main_window_set_widgets                (MainWindow        *mainwin,
132
                                                 LayoutType         layout,
133
                                                 SeparateType         type);
134
static GtkWidget *main_window_toolbar_create        (MainWindow        *mainwin);
135
static GtkWidget *main_window_toolbar_create_from_list
136
                                                (MainWindow        *mainwin,
137
                                                 GList                *item_list);
138
static void main_window_toolbar_toggle_menu_set_active
139
                                                (MainWindow        *mainwin,
140
                                                 ToolbarStyle         style);
141

    
142
/* callback functions */
143
static void toolbar_inc_cb                (GtkWidget        *widget,
144
                                         gpointer         data);
145
static void toolbar_inc_all_cb                (GtkWidget        *widget,
146
                                         gpointer         data);
147
static void toolbar_rpop3_cb                (GtkWidget        *widget,
148
                                         gpointer         data);
149
static void toolbar_send_cb                (GtkWidget        *widget,
150
                                         gpointer         data);
151

    
152
static void toolbar_compose_cb                (GtkWidget        *widget,
153
                                         gpointer         data);
154
static void toolbar_reply_cb                (GtkWidget        *widget,
155
                                         gpointer         data);
156
static void toolbar_reply_to_all_cb        (GtkWidget        *widget,
157
                                         gpointer         data);
158
static void toolbar_forward_cb                (GtkWidget        *widget,
159
                                         gpointer         data);
160

    
161
static void toolbar_delete_cb                (GtkWidget        *widget,
162
                                         gpointer         data);
163
static void toolbar_junk_cb                (GtkWidget        *widget,
164
                                         gpointer         data);
165
static void toolbar_notjunk_cb                (GtkWidget        *widget,
166
                                         gpointer         data);
167
static void toolbar_exec_cb                (GtkWidget        *widget,
168
                                         gpointer         data);
169

    
170
static void toolbar_next_unread_cb        (GtkWidget        *widget,
171
                                         gpointer         data);
172
static void toolbar_prev_unread_cb        (GtkWidget        *widget,
173
                                         gpointer         data);
174
static void toolbar_address_cb                (GtkWidget        *widget,
175
                                         gpointer         data);
176
static void toolbar_search_cb                (GtkWidget        *widget,
177
                                         gpointer         data);
178
static void toolbar_print_cb                (GtkWidget        *widget,
179
                                         gpointer         data);
180
static void toolbar_stop_cb                (GtkWidget        *widget,
181
                                         gpointer         data);
182
static void toolbar_prefs_common_cb        (GtkWidget        *widget,
183
                                         gpointer         data);
184
static void toolbar_prefs_account_cb        (GtkWidget        *widget,
185
                                         gpointer         data);
186

    
187
static gboolean toolbar_button_pressed        (GtkWidget        *widget,
188
                                         GdkEventButton        *event,
189
                                         gpointer         data);
190

    
191
static void online_switch_clicked                (GtkWidget        *widget,
192
                                                 gpointer         data);
193
static gboolean ac_label_button_pressed                (GtkWidget        *widget,
194
                                                 GdkEventButton        *event,
195
                                                 gpointer         data);
196
static void ac_menu_popup_closed                (GtkMenuShell        *menu_shell,
197
                                                 gpointer         data);
198

    
199
static gboolean main_window_key_pressed                (GtkWidget        *widget,
200
                                                 GdkEventKey        *event,
201
                                                 gpointer         data);
202

    
203
static gint main_window_close_cb                (GtkWidget        *widget,
204
                                                 GdkEventAny        *event,
205
                                                 gpointer         data);
206
static gint folder_window_close_cb                (GtkWidget        *widget,
207
                                                 GdkEventAny        *event,
208
                                                 gpointer         data);
209
static gint message_window_close_cb                (GtkWidget        *widget,
210
                                                 GdkEventAny        *event,
211
                                                 gpointer         data);
212

    
213
static void main_window_size_allocate_cb        (GtkWidget        *widget,
214
                                                 GtkAllocation        *allocation,
215
                                                 gpointer         data);
216
static void folder_window_size_allocate_cb        (GtkWidget        *widget,
217
                                                 GtkAllocation        *allocation,
218
                                                 gpointer         data);
219
static void message_window_size_allocate_cb        (GtkWidget        *widget,
220
                                                 GtkAllocation        *allocation,
221
                                                 gpointer         data);
222

    
223
static gboolean main_window_window_state_cb        (GtkWidget                *widget,
224
                                                 GdkEventWindowState        *event,
225
                                                 gpointer                 data);
226
static gboolean main_window_visibility_notify_cb(GtkWidget                *widget,
227
                                                 GdkEventVisibility        *event,
228
                                                 gpointer                 data);
229

    
230
static void new_folder_cb         (MainWindow        *mainwin,
231
                                  guint                 action,
232
                                  GtkWidget        *widget);
233
static void rename_folder_cb         (MainWindow        *mainwin,
234
                                  guint                 action,
235
                                  GtkWidget        *widget);
236
static void move_folder_cb         (MainWindow        *mainwin,
237
                                  guint                 action,
238
                                  GtkWidget        *widget);
239
static void delete_folder_cb         (MainWindow        *mainwin,
240
                                  guint                 action,
241
                                  GtkWidget        *widget);
242
static void update_folderview_cb (MainWindow        *mainwin,
243
                                  guint                 action,
244
                                  GtkWidget        *widget);
245

    
246
static void add_mailbox_cb         (MainWindow        *mainwin,
247
                                  guint                 action,
248
                                  GtkWidget        *widget);
249
static void remove_mailbox_cb         (MainWindow        *mainwin,
250
                                  guint                 action,
251
                                  GtkWidget        *widget);
252
static void rebuild_tree_cb         (MainWindow        *mainwin,
253
                                  guint                 action,
254
                                  GtkWidget        *widget);
255

    
256
static void import_mail_cb         (MainWindow        *mainwin,
257
                                  guint                 action,
258
                                  GtkWidget        *widget);
259
static void export_mail_cb         (MainWindow        *mainwin,
260
                                  guint                 action,
261
                                  GtkWidget        *widget);
262
static void empty_trash_cb         (MainWindow        *mainwin,
263
                                  guint                 action,
264
                                  GtkWidget        *widget);
265

    
266
static void save_as_cb                 (MainWindow        *mainwin,
267
                                  guint                 action,
268
                                  GtkWidget        *widget);
269
#if GTK_CHECK_VERSION(2, 10, 0)
270
static void page_setup_cb         (MainWindow        *mainwin,
271
                                  guint                 action,
272
                                  GtkWidget        *widget);
273
#endif
274
static void print_cb                 (MainWindow        *mainwin,
275
                                  guint                 action,
276
                                  GtkWidget        *widget);
277
static void toggle_offline_cb         (MainWindow        *mainwin,
278
                                  guint                 action,
279
                                  GtkWidget        *widget);
280
static void app_exit_cb                 (MainWindow        *mainwin,
281
                                  guint                 action,
282
                                  GtkWidget        *widget);
283

    
284
static void search_cb                 (MainWindow        *mainwin,
285
                                  guint                 action,
286
                                  GtkWidget        *widget);
287

    
288
static void toggle_folder_cb         (MainWindow        *mainwin,
289
                                  guint                 action,
290
                                  GtkWidget        *widget);
291
static void toggle_message_cb         (MainWindow        *mainwin,
292
                                  guint                 action,
293
                                  GtkWidget        *widget);
294
static void toggle_toolbar_cb         (MainWindow        *mainwin,
295
                                  guint                 action,
296
                                  GtkWidget        *widget);
297
static void toggle_searchbar_cb         (MainWindow        *mainwin,
298
                                  guint                 action,
299
                                  GtkWidget        *widget);
300
static void toggle_statusbar_cb         (MainWindow        *mainwin,
301
                                  guint                 action,
302
                                  GtkWidget        *widget);
303
static void toolbar_customize_cb (MainWindow        *mainwin,
304
                                  guint                 action,
305
                                  GtkWidget        *widget);
306
static void change_layout_cb         (MainWindow        *mainwin,
307
                                  guint                 action,
308
                                  GtkWidget        *widget);
309
static void separate_widget_cb         (MainWindow        *mainwin,
310
                                  guint                 action,
311
                                  GtkWidget        *widget);
312

    
313
static void addressbook_open_cb        (MainWindow        *mainwin,
314
                                 guint                 action,
315
                                 GtkWidget        *widget);
316
static void log_window_show_cb        (MainWindow        *mainwin,
317
                                 guint                 action,
318
                                 GtkWidget        *widget);
319

    
320
static void inc_mail_cb                        (MainWindow        *mainwin,
321
                                         guint                 action,
322
                                         GtkWidget        *widget);
323
static void inc_all_account_mail_cb        (MainWindow        *mainwin,
324
                                         guint                 action,
325
                                         GtkWidget        *widget);
326
static void inc_stop_cb                        (MainWindow        *mainwin,
327
                                         guint                 action,
328
                                         GtkWidget        *widget);
329

    
330
static void rpop3_cb                        (MainWindow        *mainwin,
331
                                         guint                 action,
332
                                         GtkWidget        *widget);
333

    
334
static void send_queue_cb                (MainWindow        *mainwin,
335
                                         guint                 action,
336
                                         GtkWidget        *widget);
337

    
338
static void compose_cb                        (MainWindow        *mainwin,
339
                                         guint                 action,
340
                                         GtkWidget        *widget);
341
static void reply_cb                        (MainWindow        *mainwin,
342
                                         guint                 action,
343
                                         GtkWidget        *widget);
344

    
345
static void open_msg_cb                        (MainWindow        *mainwin,
346
                                         guint                 action,
347
                                         GtkWidget        *widget);
348

    
349
static void view_source_cb                (MainWindow        *mainwin,
350
                                         guint                 action,
351
                                         GtkWidget        *widget);
352

    
353
static void show_all_header_cb                (MainWindow        *mainwin,
354
                                         guint                 action,
355
                                         GtkWidget        *widget);
356

    
357
static void move_to_cb                        (MainWindow        *mainwin,
358
                                         guint                 action,
359
                                         GtkWidget        *widget);
360
static void copy_to_cb                        (MainWindow        *mainwin,
361
                                         guint                 action,
362
                                         GtkWidget        *widget);
363
static void delete_cb                        (MainWindow        *mainwin,
364
                                         guint                 action,
365
                                         GtkWidget        *widget);
366

    
367
static void mark_cb                        (MainWindow        *mainwin,
368
                                         guint                 action,
369
                                         GtkWidget        *widget);
370
static void unmark_cb                        (MainWindow        *mainwin,
371
                                         guint                 action,
372
                                         GtkWidget        *widget);
373

    
374
static void mark_as_unread_cb                (MainWindow        *mainwin,
375
                                         guint                 action,
376
                                         GtkWidget        *widget);
377
static void mark_as_read_cb                (MainWindow        *mainwin,
378
                                         guint                 action,
379
                                         GtkWidget        *widget);
380
static void mark_thread_as_read_cb        (MainWindow        *mainwin,
381
                                         guint                 action,
382
                                         GtkWidget        *widget);
383
static void mark_all_read_cb                (MainWindow        *mainwin,
384
                                         guint                 action,
385
                                         GtkWidget        *widget);
386

    
387
static void junk_cb                        (MainWindow        *mainwin,
388
                                         guint                 action,
389
                                         GtkWidget        *widget);
390

    
391
static void reedit_cb                        (MainWindow        *mainwin,
392
                                         guint                 action,
393
                                         GtkWidget        *widget);
394

    
395
static void add_address_cb                (MainWindow        *mainwin,
396
                                         guint                 action,
397
                                         GtkWidget        *widget);
398

    
399
static void set_charset_cb                (MainWindow        *mainwin,
400
                                         guint                 action,
401
                                         GtkWidget        *widget);
402

    
403
static void thread_cb                 (MainWindow        *mainwin,
404
                                  guint                 action,
405
                                  GtkWidget        *widget);
406
static void expand_threads_cb         (MainWindow        *mainwin,
407
                                  guint                 action,
408
                                  GtkWidget        *widget);
409
static void collapse_threads_cb         (MainWindow        *mainwin,
410
                                  guint                 action,
411
                                  GtkWidget        *widget);
412

    
413
static void set_display_item_cb         (MainWindow        *mainwin,
414
                                  guint                 action,
415
                                  GtkWidget        *widget);
416
static void sort_summary_cb         (MainWindow        *mainwin,
417
                                  guint                 action,
418
                                  GtkWidget        *widget);
419
static void sort_summary_type_cb (MainWindow        *mainwin,
420
                                  guint                 action,
421
                                  GtkWidget        *widget);
422
static void attract_by_subject_cb(MainWindow        *mainwin,
423
                                  guint                 action,
424
                                  GtkWidget        *widget);
425

    
426
static void delete_duplicated_cb (MainWindow        *mainwin,
427
                                  guint                 action,
428
                                  GtkWidget        *widget);
429
static void concat_partial_cb         (MainWindow        *mainwin,
430
                                  guint                 action,
431
                                  GtkWidget        *widget);
432
static void filter_cb                 (MainWindow        *mainwin,
433
                                  guint                 action,
434
                                  GtkWidget        *widget);
435
static void filter_junk_cb         (MainWindow        *mainwin,
436
                                  guint                 action,
437
                                  GtkWidget        *widget);
438
static void execute_summary_cb         (MainWindow        *mainwin,
439
                                  guint                 action,
440
                                  GtkWidget        *widget);
441
static void update_summary_cb         (MainWindow        *mainwin,
442
                                  guint                 action,
443
                                  GtkWidget        *widget);
444

    
445
static void prev_cb                 (MainWindow        *mainwin,
446
                                  guint                 action,
447
                                  GtkWidget        *widget);
448
static void next_cb                 (MainWindow        *mainwin,
449
                                  guint                 action,
450
                                  GtkWidget        *widget);
451

    
452
static void prev_unread_cb         (MainWindow        *mainwin,
453
                                  guint                 action,
454
                                  GtkWidget        *widget);
455
static void next_unread_cb         (MainWindow        *mainwin,
456
                                  guint                 action,
457
                                  GtkWidget        *widget);
458
static void prev_new_cb                 (MainWindow        *mainwin,
459
                                  guint                 action,
460
                                  GtkWidget        *widget);
461
static void next_new_cb                 (MainWindow        *mainwin,
462
                                  guint                 action,
463
                                  GtkWidget        *widget);
464
static void prev_marked_cb         (MainWindow        *mainwin,
465
                                  guint                 action,
466
                                  GtkWidget        *widget);
467
static void next_marked_cb         (MainWindow        *mainwin,
468
                                  guint                 action,
469
                                  GtkWidget        *widget);
470
static void prev_labeled_cb         (MainWindow        *mainwin,
471
                                  guint                 action,
472
                                  GtkWidget        *widget);
473
static void next_labeled_cb         (MainWindow        *mainwin,
474
                                  guint                 action,
475
                                  GtkWidget        *widget);
476

    
477
static void goto_folder_cb         (MainWindow        *mainwin,
478
                                  guint                 action,
479
                                  GtkWidget        *widget);
480

    
481
static void copy_cb                 (MainWindow        *mainwin,
482
                                  guint                 action,
483
                                  GtkWidget        *widget);
484
static void allsel_cb                 (MainWindow        *mainwin,
485
                                  guint                 action,
486
                                  GtkWidget        *widget);
487
static void select_thread_cb         (MainWindow        *mainwin,
488
                                  guint                 action,
489
                                  GtkWidget        *widget);
490

    
491
static void create_filter_cb         (MainWindow        *mainwin,
492
                                  guint                 action,
493
                                  GtkWidget        *widget);
494

    
495
static void prefs_common_open_cb        (MainWindow        *mainwin,
496
                                         guint                 action,
497
                                         GtkWidget        *widget);
498
static void prefs_filter_open_cb        (MainWindow        *mainwin,
499
                                         guint                 action,
500
                                         GtkWidget        *widget);
501
static void prefs_template_open_cb        (MainWindow        *mainwin,
502
                                         guint                 action,
503
                                         GtkWidget        *widget);
504
static void plugin_manager_open_cb        (MainWindow        *mainwin,
505
                                         guint                 action,
506
                                         GtkWidget        *widget);
507
#ifndef G_OS_WIN32
508
static void prefs_actions_open_cb        (MainWindow        *mainwin,
509
                                         guint                 action,
510
                                         GtkWidget        *widget);
511
#endif
512
static void prefs_account_open_cb        (MainWindow        *mainwin,
513
                                         guint                 action,
514
                                         GtkWidget        *widget);
515

    
516
static void new_account_cb         (MainWindow        *mainwin,
517
                                  guint                 action,
518
                                  GtkWidget        *widget);
519

    
520
static void account_selector_menu_cb         (GtkMenuItem        *menuitem,
521
                                          gpointer         data);
522
static void account_receive_menu_cb         (GtkMenuItem        *menuitem,
523
                                          gpointer         data);
524

    
525
static void manual_open_cb         (MainWindow        *mainwin,
526
                                  guint                 action,
527
                                  GtkWidget        *widget);
528
static void faq_open_cb                 (MainWindow        *mainwin,
529
                                  guint                 action,
530
                                  GtkWidget        *widget);
531
static void help_cmdline_cb         (MainWindow        *mainwin,
532
                                  guint                 action,
533
                                  GtkWidget        *widget);
534
#if USE_UPDATE_CHECK
535
static void update_check_cb         (MainWindow        *mainwin,
536
                                  guint                 action,
537
                                  GtkWidget        *widget);
538
#ifdef USE_UPDATE_CHECK_PLUGIN
539
static void update_check_plugin_cb(MainWindow *mainwin, guint action,
540
                                   GtkWidget *widget);
541
#endif
542
#endif
543

    
544
static void scan_tree_func         (Folder        *folder,
545
                                  FolderItem        *item,
546
                                  gpointer         data);
547

    
548
static GtkItemFactoryEntry mainwin_entries[] =
549
{
550
        {N_("/_File"),                                NULL, NULL, 0, "<Branch>"},
551
        {N_("/_File/_Folder"),                        NULL, NULL, 0, "<Branch>"},
552
        {N_("/_File/_Folder/Create _new folder..."),
553
                                                NULL, new_folder_cb, 0, NULL},
554
        {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
555
        {N_("/_File/_Folder/_Move folder..."),  NULL, move_folder_cb, 0, NULL},
556
        {N_("/_File/_Folder/_Delete folder"),        NULL, delete_folder_cb, 0, NULL},
557
        {N_("/_File/_Mailbox"),                        NULL, NULL, 0, "<Branch>"},
558
        {N_("/_File/_Mailbox/Add _mailbox..."),        NULL, add_mailbox_cb, 0, NULL},
559
        {N_("/_File/_Mailbox/_Remove mailbox"),        NULL, remove_mailbox_cb, 0, NULL},
560
        {N_("/_File/_Mailbox/---"),                NULL, NULL, 0, "<Separator>"},
561
        {N_("/_File/_Mailbox/_Check for new messages"),
562
                                                NULL, update_folderview_cb, 0, NULL},
563
        {N_("/_File/_Mailbox/Check for new messages in _all mailboxes"),
564
                                                NULL, update_folderview_cb, 1, NULL},
565
        {N_("/_File/_Mailbox/---"),                NULL, NULL, 0, "<Separator>"},
566
        {N_("/_File/_Mailbox/R_ebuild folder tree"),
567
                                                NULL, rebuild_tree_cb, 0, NULL},
568
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
569
        {N_("/_File/_Import mail data..."),        NULL, import_mail_cb, 0, NULL},
570
        {N_("/_File/_Export mail data..."),        NULL, export_mail_cb, 0, NULL},
571
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
572
        {N_("/_File/Empty all _trash"),                NULL, empty_trash_cb, 0, NULL},
573
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
574
        {N_("/_File/_Save as..."),                "<control>S", save_as_cb, 0, NULL},
575
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
576
#if GTK_CHECK_VERSION(2, 10, 0)
577
        {N_("/_File/Page set_up..."),                NULL, page_setup_cb, 0, NULL},
578
#endif
579
        {N_("/_File/_Print..."),                NULL, print_cb, 0, NULL},
580
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
581
        {N_("/_File/_Work offline"),                NULL, toggle_offline_cb, 0, "<ToggleItem>"},
582
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
583
        /* {N_("/_File/_Close"),                "<alt>W", app_exit_cb, 0, NULL}, */
584
        {N_("/_File/E_xit"),                        "<control>Q", app_exit_cb, 0, NULL},
585

    
586
        {N_("/_Edit"),                                NULL, NULL, 0, "<Branch>"},
587
        {N_("/_Edit/_Copy"),                        "<control>C", copy_cb, 0, NULL},
588
        {N_("/_Edit/Select _all"),                "<control>A", allsel_cb, 0, NULL},
589
        {N_("/_Edit/Select _thread"),                NULL, select_thread_cb, 0, NULL},
590
        {N_("/_Edit/---"),                        NULL, NULL, 0, "<Separator>"},
591
        {N_("/_Edit/_Find in current message..."),
592
                                                "<control>F", search_cb, 0, NULL},
593
        {N_("/_Edit/_Search messages..."),        "<shift><control>F", search_cb, 1, NULL},
594
        {N_("/_Edit/_Quick search"),                "<shift><control>S", search_cb, 2, NULL},
595

    
596
        {N_("/_View"),                                NULL, NULL, 0, "<Branch>"},
597
        {N_("/_View/Show or hi_de"),                NULL, NULL, 0, "<Branch>"},
598
        {N_("/_View/Show or hi_de/_Folder tree"),
599
                                                NULL, toggle_folder_cb, 0, "<ToggleItem>"},
600
        {N_("/_View/Show or hi_de/_Message view"),
601
                                                "V", toggle_message_cb, 0, "<ToggleItem>"},
602
        {N_("/_View/Show or hi_de/_Toolbar"),
603
                                                NULL, NULL, 0, "<Branch>"},
604
        {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
605
                                                NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
606
        {N_("/_View/Show or hi_de/_Toolbar/Text at the _right of icon"),
607
                                                NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Icon and text"},
608
        {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
609
                                                NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
610
        {N_("/_View/Show or hi_de/_Toolbar/_Text"),
611
                                                NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
612
        {N_("/_View/Show or hi_de/_Toolbar/_None"),
613
                                                NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
614
        {N_("/_View/Show or hi_de/_Search bar"),
615
                                                NULL, toggle_searchbar_cb, 0, "<ToggleItem>"},
616
        {N_("/_View/Show or hi_de/Status _bar"),
617
                                                NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
618
        {N_("/_View/_Customize toolbar..."),        NULL, toolbar_customize_cb, 0, NULL},
619
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
620
        {N_("/_View/Layou_t"),                        NULL, NULL, 0, "<Branch>"},
621
        {N_("/_View/Layou_t/_Normal"),                NULL, change_layout_cb, LAYOUT_NORMAL, "<RadioItem>"},
622
        {N_("/_View/Layou_t/_Vertical"),        NULL, change_layout_cb, LAYOUT_VERTICAL, "/View/Layout/Normal"},
623
        {N_("/_View/Separate f_older tree"),        NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
624
        {N_("/_View/Separate _message view"),        NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
625
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
626
        {N_("/_View/_Sort"),                        NULL, NULL, 0, "<Branch>"},
627
        {N_("/_View/_Sort/by _number"),                NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
628
        {N_("/_View/_Sort/by s_ize"),                NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
629
        {N_("/_View/_Sort/by _date"),                NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
630
        {N_("/_View/_Sort/by t_hread date"),        NULL, sort_summary_cb, SORT_BY_TDATE, "/View/Sort/by number"},
631
        {N_("/_View/_Sort/by _from"),                NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
632
        {N_("/_View/_Sort/by _recipient"),        NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
633
        {N_("/_View/_Sort/by _subject"),        NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
634
        {N_("/_View/_Sort/by _color label"),
635
                                                NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
636
        {N_("/_View/_Sort/by _mark"),                NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
637
        {N_("/_View/_Sort/by _unread"),                NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
638
        {N_("/_View/_Sort/by a_ttachment"),
639
                                                NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
640
        {N_("/_View/_Sort/D_on't sort"),        NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
641
        {N_("/_View/_Sort/---"),                NULL, NULL, 0, "<Separator>"},
642
        {N_("/_View/_Sort/Ascending"),                NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
643
        {N_("/_View/_Sort/Descending"),                NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
644
        {N_("/_View/_Sort/---"),                NULL, NULL, 0, "<Separator>"},
645
        {N_("/_View/_Sort/_Attract by subject"),
646
                                                NULL, attract_by_subject_cb, 0, NULL},
647
        {N_("/_View/Th_read view"),                "<control>T", thread_cb, 0, "<ToggleItem>"},
648
        {N_("/_View/E_xpand all threads"),        NULL, expand_threads_cb, 0, NULL},
649
        {N_("/_View/Co_llapse all threads"),        NULL, collapse_threads_cb, 0, NULL},
650
        {N_("/_View/Set display _item..."),        NULL, set_display_item_cb, 0, NULL},
651

    
652
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
653
        {N_("/_View/_Go to"),                        NULL, NULL, 0, "<Branch>"},
654
        {N_("/_View/_Go to/_Prev message"),        "P", prev_cb, 0, NULL},
655
        {N_("/_View/_Go to/_Next message"),        "N", next_cb, 0, NULL},
656
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
657
        {N_("/_View/_Go to/P_rev unread message"),
658
                                                "<shift>P", prev_unread_cb, 0, NULL},
659
        {N_("/_View/_Go to/N_ext unread message"),
660
                                                "<shift>N", next_unread_cb, 0, NULL},
661
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
662
        {N_("/_View/_Go to/Prev ne_w message"),        NULL, prev_new_cb, 0, NULL},
663
        {N_("/_View/_Go to/Ne_xt new message"),        NULL, next_new_cb, 0, NULL},
664
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
665
        {N_("/_View/_Go to/Prev _marked message"),
666
                                                NULL, prev_marked_cb, 0, NULL},
667
        {N_("/_View/_Go to/Next m_arked message"),
668
                                                NULL, next_marked_cb, 0, NULL},
669
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
670
        {N_("/_View/_Go to/Prev _labeled message"),
671
                                                NULL, prev_labeled_cb, 0, NULL},
672
        {N_("/_View/_Go to/Next la_beled message"),
673
                                                NULL, next_labeled_cb, 0, NULL},
674
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
675
        {N_("/_View/_Go to/Other _folder..."),        "G", goto_folder_cb, 0, NULL},
676
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
677

    
678
#define ENC_SEPARATOR \
679
        {N_("/_View/Character _encoding/---"),                NULL, NULL, 0, "<Separator>"}
680
#define ENC_ACTION(action) \
681
         NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
682

    
683
        {N_("/_View/Character _encoding"),                NULL, NULL, 0, "<Branch>"},
684
        {N_("/_View/Character _encoding/_Auto detect"),
685
         NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
686
        {N_("/_View/Character _encoding/---"),                NULL, NULL, 0, "<Separator>"},
687
        {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
688
         ENC_ACTION(C_US_ASCII)},
689
        {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
690
         ENC_ACTION(C_UTF_8)},
691
        ENC_SEPARATOR,
692

    
693
        {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
694
         ENC_ACTION(C_ISO_8859_1)},
695
        {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
696
         ENC_ACTION(C_ISO_8859_15)},
697
        {N_("/_View/Character _encoding/Western European (Windows-1252)"),
698
         ENC_ACTION(C_WINDOWS_1252)},
699
        ENC_SEPARATOR,
700

    
701
        {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
702
         ENC_ACTION(C_ISO_8859_2)},
703
        ENC_SEPARATOR,
704

    
705
        {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
706
         ENC_ACTION(C_ISO_8859_13)},
707
        {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
708
         ENC_ACTION(C_ISO_8859_4)},
709
        {N_("/_View/Character _encoding/Baltic (Windows-1257)"),
710
         ENC_ACTION(C_WINDOWS_1257)},
711
        ENC_SEPARATOR,
712

    
713
        {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
714
         ENC_ACTION(C_ISO_8859_7)},
715
        ENC_SEPARATOR,
716

    
717
        {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
718
         ENC_ACTION(C_ISO_8859_6)},
719
        {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
720
         ENC_ACTION(C_CP1256)},
721
        ENC_SEPARATOR,
722

    
723
        {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
724
         ENC_ACTION(C_ISO_8859_8)},
725
        {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
726
         ENC_ACTION(C_CP1255)},
727
        ENC_SEPARATOR,
728

    
729
        {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
730
         ENC_ACTION(C_ISO_8859_9)},
731
        ENC_SEPARATOR,
732

    
733
        {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
734
         ENC_ACTION(C_ISO_8859_5)},
735
        {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
736
         ENC_ACTION(C_KOI8_R)},
737
        {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
738
         ENC_ACTION(C_KOI8_U)},
739
        {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
740
         ENC_ACTION(C_CP1251)},
741
        ENC_SEPARATOR,
742

    
743
        {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
744
         ENC_ACTION(C_ISO_2022_JP)},
745
        {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
746
         ENC_ACTION(C_ISO_2022_JP_2)},
747
        {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
748
         ENC_ACTION(C_EUC_JP)},
749
        {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
750
         ENC_ACTION(C_SHIFT_JIS)},
751
        ENC_SEPARATOR,
752

    
753
        {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
754
         ENC_ACTION(C_GB2312)},
755
        {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
756
         ENC_ACTION(C_GBK)},
757
        {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
758
         ENC_ACTION(C_BIG5)},
759
        {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
760
         ENC_ACTION(C_EUC_TW)},
761
        {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
762
         ENC_ACTION(C_ISO_2022_CN)},
763
        ENC_SEPARATOR,
764

    
765
        {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
766
         ENC_ACTION(C_EUC_KR)},
767
        {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
768
         ENC_ACTION(C_ISO_2022_KR)},
769
        ENC_SEPARATOR,
770

    
771
        {N_("/_View/Character _encoding/Thai (TIS-620)"),
772
         ENC_ACTION(C_TIS_620)},
773
        {N_("/_View/Character _encoding/Thai (Windows-874)"),
774
         ENC_ACTION(C_WINDOWS_874)},
775

    
776
#undef CODESET_SEPARATOR
777
#undef CODESET_ACTION
778

    
779
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
780
        {N_("/_View/Open in new _window"),        "<control><alt>N", open_msg_cb, 0, NULL},
781
        {N_("/_View/Mess_age source"),                "<control>U", view_source_cb, 0, NULL},
782
        {N_("/_View/All _headers"),        "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
783
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
784
        {N_("/_View/_Update summary"),                "<control><alt>U", update_summary_cb,  0, NULL},
785

    
786
        {N_("/_Message"),                        NULL, NULL, 0, "<Branch>"},
787
        {N_("/_Message/Recei_ve"),                NULL, NULL, 0, "<Branch>"},
788
        {N_("/_Message/Recei_ve/Get from _current account"),
789
                                                "<control>I",        inc_mail_cb, 0, NULL},
790
        {N_("/_Message/Recei_ve/Get from _all accounts"),
791
                                                "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
792
        {N_("/_Message/Recei_ve/Stop receivin_g"),
793
                                                NULL, inc_stop_cb, 0, NULL},
794
        {N_("/_Message/Recei_ve/_Remote mailbox..."),
795
                                                NULL, rpop3_cb, 0, NULL},
796
        {N_("/_Message/Recei_ve/---"),                NULL, NULL, 0, "<Separator>"},
797
        {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
798
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
799
        {N_("/_Message/Compose _new message"),        "<control>M",        compose_cb, 0, NULL},
800
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
801
        {N_("/_Message/_Reply"),                "<control>R",         reply_cb, COMPOSE_REPLY, NULL},
802
        {N_("/_Message/Repl_y to"),                NULL, NULL, 0, "<Branch>"},
803
        {N_("/_Message/Repl_y to/_all"),        "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
804
        {N_("/_Message/Repl_y to/_sender"),        NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
805
        {N_("/_Message/Repl_y to/mailing _list"),
806
                                                "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
807
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
808
        {N_("/_Message/_Forward"),                "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
809
        {N_("/_Message/For_ward as attachment"),
810
                                                "<shift><control><alt>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
811
        {N_("/_Message/Redirec_t"),                NULL, reply_cb, COMPOSE_REDIRECT, NULL},
812
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
813
        {N_("/_Message/M_ove..."),                "<control>O", move_to_cb, 0, NULL},
814
        {N_("/_Message/_Copy..."),                "<shift><control>O", copy_to_cb, 0, NULL},
815
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
816
        {N_("/_Message/_Mark"),                        NULL, NULL, 0, "<Branch>"},
817
        {N_("/_Message/_Mark/Set _flag"),        "<shift>asterisk", mark_cb, 0, NULL},
818
        {N_("/_Message/_Mark/_Unset flag"),        "U", unmark_cb, 0, NULL},
819
        {N_("/_Message/_Mark/---"),                NULL, NULL, 0, "<Separator>"},
820
        {N_("/_Message/_Mark/Mark as unr_ead"),        "<shift>exclam", mark_as_unread_cb, 0, NULL},
821
        {N_("/_Message/_Mark/Mark as rea_d"),
822
                                                NULL, mark_as_read_cb, 0, NULL},
823
        {N_("/_Message/_Mark/Mark _thread as read"),
824
                                                NULL, mark_thread_as_read_cb, 0, NULL},
825
        {N_("/_Message/_Mark/Mark all _read"),        NULL, mark_all_read_cb, 0, NULL},
826
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
827
        {N_("/_Message/_Delete"),                "<control>D", delete_cb, 0, NULL},
828
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
829
        {N_("/_Message/Set as _junk mail"),        "<control>J", junk_cb, 0, NULL},
830
        {N_("/_Message/Set as not j_unk mail"),        "<shift><control>J", junk_cb, 1, NULL},
831
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
832
        {N_("/_Message/Re-_edit"),                NULL, reedit_cb, 0, NULL},
833

    
834
        {N_("/_Tools"),                                NULL, NULL, 0, "<Branch>"},
835
        {N_("/_Tools/_Address book"),                "<shift><control>A", addressbook_open_cb, 0, NULL},
836
        {N_("/_Tools/Add sender to address boo_k..."),
837
                                                NULL, add_address_cb, 0, NULL},
838
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
839
        {N_("/_Tools/_Filter all messages in folder"),
840
                                                NULL, filter_cb, 0, NULL},
841
        {N_("/_Tools/Filter _selected messages"),
842
                                                NULL, filter_cb, 1, NULL},
843
        {N_("/_Tools/_Create filter rule"),        NULL, NULL, 0, "<Branch>"},
844
        {N_("/_Tools/_Create filter rule/_Automatically"),
845
                                                NULL, create_filter_cb, FLT_BY_AUTO, NULL},
846
        {N_("/_Tools/_Create filter rule/by _From"),
847
                                                NULL, create_filter_cb, FLT_BY_FROM, NULL},
848
        {N_("/_Tools/_Create filter rule/by _To"),
849
                                                NULL, create_filter_cb, FLT_BY_TO, NULL},
850
        {N_("/_Tools/_Create filter rule/by _Subject"),
851
                                                NULL, create_filter_cb, FLT_BY_SUBJECT, NULL},
852
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
853
        {N_("/_Tools/Filter _junk mails in folder"),
854
                                                NULL, filter_junk_cb, 0, NULL},
855
        {N_("/_Tools/Filter junk _mails in selected messages"),
856
                                                NULL, filter_junk_cb, 1, NULL},
857
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
858
#ifndef G_OS_WIN32
859
        {N_("/_Tools/Actio_ns"),                NULL, NULL, 0, "<Branch>"},
860
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
861
#endif
862
        {N_("/_Tools/Delete du_plicated messages"),
863
                                                NULL, delete_duplicated_cb,   0, NULL},
864
        {N_("/_Tools/C_oncatenate separated messages"),
865
                                                NULL, concat_partial_cb, 0, NULL},
866
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
867
        {N_("/_Tools/E_xecute marked process"),        "X", execute_summary_cb, 0, NULL},
868
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
869
        {N_("/_Tools/_Log window"),                "<shift><control>L", log_window_show_cb, 0, NULL},
870

    
871
        {N_("/_Configuration"),                        NULL, NULL, 0, "<Branch>"},
872
        {N_("/_Configuration/_Common preferences..."),
873
                                                NULL, prefs_common_open_cb, 0, NULL},
874
        {N_("/_Configuration/_Filter settings..."),
875
                                                NULL, prefs_filter_open_cb, 0, NULL},
876
        {N_("/_Configuration/_Template..."),        NULL, prefs_template_open_cb, 0, NULL},
877
#ifndef G_OS_WIN32
878
        {N_("/_Configuration/_Actions..."),        NULL, prefs_actions_open_cb, 0, NULL},
879
#endif
880
        {N_("/_Configuration/Plug-in _manager..."),
881
                                                NULL, plugin_manager_open_cb, 0, NULL},
882
        {N_("/_Configuration/---"),                NULL, NULL, 0, "<Separator>"},
883
        {N_("/_Configuration/_Preferences for current account..."),
884
                                                NULL, prefs_account_open_cb, 0, NULL},
885
        {N_("/_Configuration/Create _new account..."),
886
                                                NULL, new_account_cb, 0, NULL},
887
        {N_("/_Configuration/_Edit accounts..."),
888
                                                NULL, account_edit_open, 0, NULL},
889
        {N_("/_Configuration/C_hange current account"),
890
                                                NULL, NULL, 0, "<Branch>"},
891

    
892
        {N_("/_Help"),                                NULL, NULL, 0, "<Branch>"},
893
        {N_("/_Help/_Manual"),                        NULL, NULL, 0, "<Branch>"},
894
        {N_("/_Help/_Manual/_English"),                NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
895
        {N_("/_Help/_Manual/_Japanese"),        NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
896
        {N_("/_Help/_FAQ"),                        NULL, NULL, 0, "<Branch>"},
897
        {N_("/_Help/_FAQ/_English"),                NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
898
        {N_("/_Help/_FAQ/_German"),                NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
899
        {N_("/_Help/_FAQ/_Spanish"),                NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
900
        {N_("/_Help/_FAQ/_French"),                NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
901
        {N_("/_Help/_FAQ/_Italian"),                NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
902
        {N_("/_Help/_Command line options"),        NULL, help_cmdline_cb, 0, NULL},
903
#if USE_UPDATE_CHECK
904
        {N_("/_Help/---"),                        NULL, NULL, 0, "<Separator>"},
905
        {N_("/_Help/_Update check..."),                NULL, update_check_cb, 0, NULL},
906
#ifdef USE_UPDATE_CHECK_PLUGIN
907
        {N_("/_Help/Update check of _plug-ins..."),
908
                                                NULL, update_check_plugin_cb, 0, NULL},
909
#endif
910
#endif
911
        {N_("/_Help/---"),                        NULL, NULL, 0, "<Separator>"},
912
        {N_("/_Help/_About"),                        NULL, about_show, 0, NULL}
913
};
914

    
915
MainWindow *main_window_create(SeparateType type)
916
{
917
        MainWindow *mainwin;
918
        GtkWidget *window;
919
        GtkWidget *vbox;
920
        GtkWidget *menubar;
921
        GtkWidget *toolbar;
922
        GtkWidget *hbox_spc;
923
        GtkWidget *vbox_body;
924
        GtkWidget *statusbar;
925
        GtkWidget *progressbar;
926
        GtkWidget *statuslabel;
927
        GtkWidget *online_hbox;
928
        GtkWidget *online_switch;
929
        GtkWidget *online_pixmap;
930
        GtkWidget *offline_pixmap;
931
        GtkTooltips *online_tip;
932
#if !GTK_CHECK_VERSION(2, 6, 0)
933
        GtkWidget *spacer_hbox;
934
#endif
935
        GtkWidget *ac_button;
936
        GtkWidget *ac_label;
937

    
938
        TrayIcon *tray_icon;
939

    
940
        FolderView *folderview;
941
        SummaryView *summaryview;
942
        MessageView *messageview;
943
        GdkColormap *colormap;
944
        GdkColor color[3];
945
        gboolean success[3];
946
        guint n_menu_entries;
947
        GtkItemFactory *ifactory;
948
        GtkWidget *ac_menu;
949
        GtkWidget *menuitem;
950
        gint i;
951

    
952
        static GdkGeometry geometry;
953

    
954
        debug_print(_("Creating main window...\n"));
955
        mainwin = g_new0(MainWindow, 1);
956

    
957
        /* main window */
958
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
959
        gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
960
        gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
961
        gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
962
        gtk_widget_add_events(window, GDK_VISIBILITY_NOTIFY_MASK);
963
        g_signal_connect(G_OBJECT(window), "key_press_event",
964
                         G_CALLBACK(main_window_key_pressed), mainwin);
965

    
966
        if (!geometry.min_height) {
967
                geometry.min_width = 320;
968
                geometry.min_height = 200;
969
        }
970
        gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
971
                                      GDK_HINT_MIN_SIZE);
972

    
973
        g_signal_connect(G_OBJECT(window), "delete_event",
974
                         G_CALLBACK(main_window_close_cb), mainwin);
975
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
976
        gtk_widget_realize(window);
977

    
978
        vbox = gtk_vbox_new(FALSE, 0);
979
        gtk_widget_show(vbox);
980
        gtk_container_add(GTK_CONTAINER(window), vbox);
981

    
982
        /* menu bar */
983
        n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
984
        menubar = menubar_create(window, mainwin_entries, 
985
                                 n_menu_entries, "<Main>", mainwin);
986
        gtk_widget_show(menubar);
987
        gtk_widget_set_size_request(menubar, 300, -1);
988
        gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
989
        ifactory = gtk_item_factory_from_widget(menubar);
990

    
991
        /* toolbar */
992
        mainwin->toolbar_tip = gtk_tooltips_new();
993
        toolbar = main_window_toolbar_create(mainwin);
994
        gtk_widget_set_size_request(toolbar, 300, -1);
995
        gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
996

    
997
        hbox_spc = gtk_hbox_new(FALSE, 0);
998
        gtk_widget_show(hbox_spc);
999
        gtk_widget_set_size_request(hbox_spc, -1, BORDER_WIDTH);
1000
        gtk_box_pack_start(GTK_BOX(vbox), hbox_spc, FALSE, FALSE, 0);
1001

    
1002
        /* vbox that contains body */
1003
        vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1004
        gtk_widget_show(vbox_body);
1005
        gtk_container_set_border_width(GTK_CONTAINER(vbox_body), 0);
1006
        gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1007

    
1008
        statusbar = statusbar_create();
1009
        gtk_box_pack_end(GTK_BOX(vbox_body), statusbar, FALSE, FALSE, 0);
1010

    
1011
        progressbar = gtk_progress_bar_new();
1012
        gtk_widget_set_size_request(progressbar, 120, 1);
1013
        gtk_box_pack_start(GTK_BOX(statusbar), progressbar, FALSE, FALSE, 0);
1014

    
1015
        statuslabel = gtk_label_new("");
1016
        gtk_box_pack_start(GTK_BOX(statusbar), statuslabel, FALSE, FALSE, 0);
1017

    
1018
        online_hbox = gtk_hbox_new(FALSE, 0);
1019

    
1020
        online_pixmap = stock_pixbuf_widget(statusbar, STOCK_PIXMAP_ONLINE);
1021
        offline_pixmap = stock_pixbuf_widget(statusbar, STOCK_PIXMAP_OFFLINE);
1022
        gtk_box_pack_start(GTK_BOX(online_hbox), online_pixmap,
1023
                           FALSE, FALSE, 0);
1024
        gtk_box_pack_start(GTK_BOX(online_hbox), offline_pixmap,
1025
                           FALSE, FALSE, 0);
1026

    
1027
        online_switch = gtk_button_new();
1028
        gtk_button_set_relief(GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1029
        GTK_WIDGET_UNSET_FLAGS(online_switch, GTK_CAN_FOCUS);
1030
#ifdef G_OS_WIN32
1031
        gtk_widget_set_size_request(online_switch, 34, 20);
1032
#else
1033
        gtk_widget_set_size_request(online_switch, 34, 24);
1034
#endif
1035
        gtk_container_add(GTK_CONTAINER(online_switch), online_hbox);
1036
        g_signal_connect(G_OBJECT(online_switch), "clicked",
1037
                         G_CALLBACK(online_switch_clicked), mainwin);
1038
        gtk_box_pack_start(GTK_BOX(statusbar), online_switch, FALSE, FALSE, 0);
1039

    
1040
        online_tip = gtk_tooltips_new();
1041

    
1042
#if !GTK_CHECK_VERSION(2, 6, 0)
1043
        spacer_hbox = gtk_hbox_new(FALSE, 0);
1044
        gtk_box_pack_end(GTK_BOX(statusbar), spacer_hbox, FALSE, FALSE, 0);
1045
#endif
1046

    
1047
        ac_button = gtk_button_new();
1048
        gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
1049
        GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1050
        gtk_widget_set_size_request(ac_button, -1, 1);
1051
        gtk_box_pack_end(GTK_BOX(statusbar), ac_button, FALSE, FALSE, 0);
1052
        g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1053
                         G_CALLBACK(ac_label_button_pressed), mainwin);
1054

    
1055
        ac_label = gtk_label_new("");
1056
        gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1057

    
1058
        gtk_widget_show_all(statusbar);
1059

    
1060
        tray_icon = trayicon_create(mainwin);
1061
        if (tray_icon && prefs_common.show_trayicon)
1062
                trayicon_show(tray_icon);
1063

    
1064
        /* create views */
1065
        mainwin->folderview  = folderview  = folderview_create();
1066
        mainwin->summaryview = summaryview = summary_create();
1067
        mainwin->messageview = messageview = messageview_create();
1068
        mainwin->logwin      = log_window_create();
1069

    
1070
        quick_search_create(summaryview);
1071

    
1072
        folderview->mainwin      = mainwin;
1073
        folderview->summaryview  = summaryview;
1074

    
1075
        summaryview->mainwin     = mainwin;
1076
        summaryview->folderview  = folderview;
1077
        summaryview->messageview = messageview;
1078
        summaryview->window      = window;
1079

    
1080
        messageview->statusbar   = statusbar;
1081
        messageview->mainwin     = mainwin;
1082

    
1083
        mainwin->window         = window;
1084
        mainwin->vbox           = vbox;
1085
        mainwin->menubar        = menubar;
1086
        mainwin->menu_factory   = ifactory;
1087
        mainwin->toolbar        = toolbar;
1088
        mainwin->vbox_body      = vbox_body;
1089
        mainwin->statusbar      = statusbar;
1090
        mainwin->progressbar    = progressbar;
1091
        mainwin->statuslabel    = statuslabel;
1092
        mainwin->online_switch  = online_switch;
1093
        mainwin->online_pixmap  = online_pixmap;
1094
        mainwin->offline_pixmap = offline_pixmap;
1095
        mainwin->online_tip     = online_tip;
1096
        mainwin->ac_button      = ac_button;
1097
        mainwin->ac_label       = ac_label;
1098

    
1099
        mainwin->tray_icon      = tray_icon;
1100

    
1101
        /* set context IDs for status bar */
1102
        mainwin->mainwin_cid = gtk_statusbar_get_context_id
1103
                (GTK_STATUSBAR(statusbar), "Main Window");
1104
        mainwin->folderview_cid = gtk_statusbar_get_context_id
1105
                (GTK_STATUSBAR(statusbar), "Folder View");
1106
        mainwin->summaryview_cid = gtk_statusbar_get_context_id
1107
                (GTK_STATUSBAR(statusbar), "Summary View");
1108
        mainwin->messageview_cid = gtk_statusbar_get_context_id
1109
                (GTK_STATUSBAR(statusbar), "Message View");
1110

    
1111
        messageview->statusbar_cid = mainwin->messageview_cid;
1112

    
1113
        /* allocate colors for summary view and folder view */
1114
        summaryview->color_marked.red = summaryview->color_marked.green = 0;
1115
        summaryview->color_marked.blue = (guint16)65535;
1116

    
1117
        summaryview->color_dim.red = summaryview->color_dim.green =
1118
                summaryview->color_dim.blue = COLOR_DIM;
1119

    
1120
        folderview->color_new.red = (guint16)55000;
1121
        folderview->color_new.green = folderview->color_new.blue = 15000;
1122

    
1123
        folderview->color_noselect.red = folderview->color_noselect.green =
1124
                folderview->color_noselect.blue = COLOR_DIM;
1125

    
1126
        color[0] = summaryview->color_marked;
1127
        color[1] = summaryview->color_dim;
1128
        color[2] = folderview->color_new;
1129

    
1130
        colormap = gdk_window_get_colormap(window->window);
1131
        gdk_colormap_alloc_colors(colormap, color, 3, FALSE, TRUE, success);
1132
        for (i = 0; i < 3; i++) {
1133
                if (success[i] == FALSE)
1134
                        g_warning(_("MainWindow: color allocation %d failed\n"), i);
1135
        }
1136

    
1137
        if (prefs_common.layout_type == LAYOUT_VERTICAL)
1138
                messageview->visible = TRUE;
1139
        else
1140
                messageview->visible = prefs_common.msgview_visible;
1141

    
1142
        main_window_set_widgets(mainwin, prefs_common.layout_type, type);
1143

    
1144
        if (prefs_common.mainwin_maximized)
1145
                gtk_window_maximize(GTK_WINDOW(window));
1146

    
1147
        g_signal_connect(G_OBJECT(window), "size_allocate",
1148
                         G_CALLBACK(main_window_size_allocate_cb), mainwin);
1149
        g_signal_connect(G_OBJECT(window), "window_state_event",
1150
                         G_CALLBACK(main_window_window_state_cb), mainwin);
1151
        g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1152
                         G_CALLBACK(main_window_visibility_notify_cb), mainwin);
1153

    
1154
        /* set menu items */
1155
        menuitem = gtk_item_factory_get_item
1156
                (ifactory, "/View/Character encoding/Auto detect");
1157
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1158

    
1159
        main_window_toolbar_toggle_menu_set_active
1160
                (mainwin, prefs_common.toolbar_style);
1161

    
1162
        gtk_widget_hide(GTK_WIDGET_PTR(summaryview->qsearch));
1163
        menuitem = gtk_item_factory_get_item
1164
                (ifactory, "/View/Show or hide/Search bar");
1165
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1166
                                       prefs_common.show_searchbar);
1167

    
1168
        gtk_widget_hide(mainwin->statusbar);
1169
        menuitem = gtk_item_factory_get_item
1170
                (ifactory, "/View/Show or hide/Status bar");
1171
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1172
                                       prefs_common.show_statusbar);
1173

    
1174
        /* set account selection menu */
1175
        ac_menu = gtk_item_factory_get_widget
1176
                (ifactory, "/Configuration/Change current account");
1177
        g_signal_connect(G_OBJECT(ac_menu), "selection_done",
1178
                         G_CALLBACK(ac_menu_popup_closed), mainwin);
1179
        mainwin->ac_menu = ac_menu;
1180

    
1181
        main_window_set_toolbar_sensitive(mainwin);
1182
        main_window_set_toolbar_button_visibility(mainwin);
1183

    
1184
        /* create actions menu */
1185
#ifndef G_OS_WIN32
1186
        action_update_mainwin_menu(ifactory, mainwin);
1187
#endif
1188

    
1189
        /* initialize online switch */
1190
        prefs_common.online_mode = !prefs_common.online_mode;
1191
        online_switch_clicked(online_switch, mainwin);
1192

    
1193
        /* show main window */
1194
        gtk_widget_show(mainwin->window);
1195

    
1196
#if !GTK_CHECK_VERSION(2, 6, 0)
1197
        {
1198
                gint w, h;
1199
                gdk_drawable_get_size
1200
                        (GDK_DRAWABLE(GTK_STATUSBAR(statusbar)->grip_window),
1201
                         &w, &h);
1202
                gtk_widget_set_size_request(spacer_hbox, w, -1);
1203
        }
1204
#endif
1205

    
1206
        /* initialize views */
1207
        folderview_init(folderview);
1208
        summary_init(summaryview);
1209
        messageview_init(messageview);
1210
        log_window_init(mainwin->logwin);
1211

    
1212
        mainwin->lock_count = 0;
1213
        mainwin->menu_lock_count = 0;
1214
        mainwin->cursor_count = 0;
1215

    
1216
        mainwin->window_hidden = FALSE;
1217
        mainwin->window_obscured = FALSE;
1218

    
1219
        if (!watch_cursor)
1220
                watch_cursor = gdk_cursor_new(GDK_WATCH);
1221

    
1222
        mainwin_list = g_list_append(mainwin_list, mainwin);
1223

    
1224
        debug_print(_("done.\n"));
1225

    
1226
        return mainwin;
1227
}
1228

    
1229
void main_window_cursor_wait(MainWindow *mainwin)
1230
{
1231

    
1232
        if (mainwin->cursor_count == 0)
1233
                gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1234

    
1235
        mainwin->cursor_count++;
1236

    
1237
        gdk_flush();
1238
}
1239

    
1240
void main_window_cursor_normal(MainWindow *mainwin)
1241
{
1242
        if (mainwin->cursor_count)
1243
                mainwin->cursor_count--;
1244

    
1245
        if (mainwin->cursor_count == 0)
1246
                gdk_window_set_cursor(mainwin->window->window, NULL);
1247

    
1248
        gdk_flush();
1249
}
1250

    
1251
/* lock / unlock the user-interface */
1252
void main_window_lock(MainWindow *mainwin)
1253
{
1254
        if (mainwin->lock_count == 0)
1255
                gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1256

    
1257
        mainwin->lock_count++;
1258

    
1259
        main_window_set_menu_sensitive(mainwin);
1260
        main_window_set_toolbar_sensitive(mainwin);
1261
}
1262

    
1263
void main_window_unlock(MainWindow *mainwin)
1264
{
1265
        if (mainwin->lock_count)
1266
                mainwin->lock_count--;
1267

    
1268
        main_window_set_menu_sensitive(mainwin);
1269
        main_window_set_toolbar_sensitive(mainwin);
1270

    
1271
        if (mainwin->lock_count == 0)
1272
                gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1273
}
1274

    
1275
static void main_window_menu_callback_block(MainWindow *mainwin)
1276
{
1277
        mainwin->menu_lock_count++;
1278
}
1279

    
1280
static void main_window_menu_callback_unblock(MainWindow *mainwin)
1281
{
1282
        if (mainwin->menu_lock_count)
1283
                mainwin->menu_lock_count--;
1284
}
1285

    
1286
void main_window_reflect_prefs_all(void)
1287
{
1288
        MainWindow *mainwin;
1289

    
1290
        mainwin = main_window_get();
1291

    
1292
        main_window_show_cur_account(mainwin);
1293
        main_window_set_menu_sensitive(mainwin);
1294
        main_window_set_toolbar_sensitive(mainwin);
1295
        main_window_set_toolbar_button_visibility(mainwin);
1296

    
1297
        if (mainwin->tray_icon) {
1298
                if (prefs_common.show_trayicon)
1299
                        trayicon_show(mainwin->tray_icon);
1300
                else {
1301
                        /* trayicon is automatically replaced by new one */
1302
                        trayicon_hide(mainwin->tray_icon);
1303
                }
1304
        }
1305

    
1306
        folderview_reflect_prefs(mainwin->folderview);
1307

    
1308
        messageview_reflect_prefs(mainwin->messageview);
1309

    
1310
        headerview_set_visibility(mainwin->messageview->headerview,
1311
                                  prefs_common.display_header_pane);
1312

    
1313
        textview_reflect_prefs(mainwin->messageview->textview);
1314
        textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1315

    
1316
        summary_redisplay_msg(mainwin->summaryview);
1317
}
1318

    
1319
void main_window_set_summary_column(void)
1320
{
1321
        summary_set_column_order(main_window_get()->summaryview);
1322
}
1323

    
1324
static void main_window_set_account_selector_menu(MainWindow *mainwin,
1325
                                                  GList *account_list)
1326
{
1327
        GList *cur_ac, *cur_item;
1328
        GtkWidget *menuitem;
1329
        PrefsAccount *ac_prefs;
1330

    
1331
        /* destroy all previous menu item */
1332
        cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1333
        while (cur_item != NULL) {
1334
                GList *next = cur_item->next;
1335
                gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1336
                cur_item = next;
1337
        }
1338

    
1339
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1340
                ac_prefs = (PrefsAccount *)cur_ac->data;
1341

    
1342
                menuitem = gtk_menu_item_new_with_label
1343
                        (ac_prefs->account_name
1344
                         ? ac_prefs->account_name : _("Untitled"));
1345
                gtk_widget_show(menuitem);
1346
                gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1347
                g_signal_connect(G_OBJECT(menuitem), "activate",
1348
                                 G_CALLBACK(account_selector_menu_cb),
1349
                                 ac_prefs);
1350
        }
1351
}
1352

    
1353
static void main_window_set_account_receive_menu(MainWindow *mainwin,
1354
                                                 GList *account_list)
1355
{
1356
        GList *cur_ac, *cur_item;
1357
        GtkWidget *menu;
1358
        GtkWidget *menuitem;
1359
        PrefsAccount *ac_prefs;
1360

    
1361
        menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1362
                                           "/Message/Receive");
1363

    
1364
        /* search for separator */
1365
        for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1366
             cur_item = cur_item->next) {
1367
                if (GTK_BIN(cur_item->data)->child == NULL) {
1368
                        cur_item = cur_item->next;
1369
                        break;
1370
                }
1371
        }
1372

    
1373
        /* destroy all previous menu item */
1374
        while (cur_item != NULL) {
1375
                GList *next = cur_item->next;
1376
                gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1377
                cur_item = next;
1378
        }
1379

    
1380
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1381
                ac_prefs = (PrefsAccount *)cur_ac->data;
1382

    
1383
                menuitem = gtk_menu_item_new_with_label
1384
                        (ac_prefs->account_name ? ac_prefs->account_name
1385
                         : _("Untitled"));
1386
                gtk_widget_show(menuitem);
1387
                gtk_menu_append(GTK_MENU(menu), menuitem);
1388
                g_signal_connect(G_OBJECT(menuitem), "activate",
1389
                                 G_CALLBACK(account_receive_menu_cb),
1390
                                 ac_prefs);
1391
        }
1392
}
1393

    
1394
void main_window_set_account_menu(GList *account_list)
1395
{
1396
        MainWindow *mainwin;
1397

    
1398
        mainwin = main_window_get();
1399
        main_window_set_account_selector_menu(mainwin, account_list);
1400
        main_window_set_account_receive_menu(mainwin, account_list);
1401
}
1402

    
1403
static void main_window_show_cur_account(MainWindow *mainwin)
1404
{
1405
        gchar *buf;
1406
        gchar *ac_name;
1407

    
1408
        ac_name = g_strdup(cur_account
1409
                           ? (cur_account->account_name
1410
                              ? cur_account->account_name : _("Untitled"))
1411
                           : _("none"));
1412

    
1413
        if (cur_account)
1414
                buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1415
        else
1416
                buf = g_strdup(PROG_VERSION);
1417
        gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1418
        g_free(buf);
1419

    
1420
        gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1421
        gtk_widget_queue_resize(mainwin->ac_button);
1422

    
1423
        g_free(ac_name);
1424
}
1425

    
1426
void main_window_change_cur_account(void)
1427
{
1428
        MainWindow *mainwin;
1429

    
1430
        mainwin = main_window_get();
1431
        main_window_show_cur_account(mainwin);
1432
        main_window_set_menu_sensitive(mainwin);
1433
        main_window_set_toolbar_sensitive(mainwin);
1434
}
1435

    
1436
MainWindow *main_window_get(void)
1437
{
1438
        if (mainwin_list)
1439
                return (MainWindow *)mainwin_list->data;
1440
        else
1441
                return NULL;
1442
}
1443

    
1444
GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1445
{
1446
        switch (mainwin->type) {
1447
        case SEPARATE_FOLDER:
1448
                return mainwin->win.sep_folder.folderwin;
1449
        case SEPARATE_BOTH:
1450
                return mainwin->win.sep_both.folderwin;
1451
        default:
1452
                return NULL;
1453
        }
1454
}
1455

    
1456
GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1457
{
1458
        switch (mainwin->type) {
1459
        case SEPARATE_MESSAGE:
1460
                return mainwin->win.sep_message.messagewin;
1461
        case SEPARATE_BOTH:
1462
                return mainwin->win.sep_both.messagewin;
1463
        default:
1464
                return NULL;
1465
        }
1466
}
1467

    
1468
void main_window_hide(MainWindow *mainwin)
1469
{
1470
        GtkWidget *folder_wid  = GTK_WIDGET_PTR(mainwin->folderview);
1471
        GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1472
        GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1473
        GtkWidget *qsearch_wid = GTK_WIDGET_PTR(mainwin->summaryview->qsearch);
1474
        GtkWidget *vbox_summary = qsearch_wid->parent;
1475

    
1476
        /* remove widgets from those containers */
1477
        gtkut_container_remove
1478
                (GTK_CONTAINER(folder_wid->parent), folder_wid);
1479
        gtkut_container_remove
1480
                (GTK_CONTAINER(summary_wid->parent), summary_wid);
1481
        gtkut_container_remove
1482
                (GTK_CONTAINER(message_wid->parent), message_wid);
1483
        gtkut_container_remove
1484
                (GTK_CONTAINER(qsearch_wid->parent), qsearch_wid);
1485

    
1486
        /* clean containers */
1487
        switch (mainwin->type) {
1488
        case SEPARATE_NONE:
1489
                if (!mainwin->win.sep_none.vpaned->parent)
1490
                        gtk_widget_destroy(mainwin->win.sep_none.vpaned);
1491
                gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1492
                mainwin->win.sep_none.hpaned = NULL;
1493
                mainwin->win.sep_none.vpaned = NULL;
1494
                break;
1495
        case SEPARATE_FOLDER:
1496
                gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1497
                if (!mainwin->win.sep_folder.vpaned->parent)
1498
                        gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1499
                gtk_widget_destroy(vbox_summary);
1500
                mainwin->win.sep_folder.folderwin = NULL;
1501
                mainwin->win.sep_folder.vpaned = NULL;
1502
                break;
1503
        case SEPARATE_MESSAGE:
1504
                gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1505
                gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1506
                mainwin->win.sep_message.messagewin = NULL;
1507
                mainwin->win.sep_message.hpaned = NULL;
1508
                break;
1509
        case SEPARATE_BOTH:
1510
                gtk_widget_destroy(vbox_summary);
1511
                gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1512
                gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1513
                mainwin->win.sep_both.folderwin = NULL;
1514
                mainwin->win.sep_both.messagewin = NULL;
1515
                break;
1516
        }
1517

    
1518
        gtk_widget_hide(mainwin->window);
1519
}
1520

    
1521
void main_window_change_layout(MainWindow *mainwin, LayoutType layout,
1522
                               SeparateType type)
1523
{
1524
        GtkWidget *folder_wid  = GTK_WIDGET_PTR(mainwin->folderview);
1525
        GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1526
        GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1527
        GtkWidget *qsearch_wid = GTK_WIDGET_PTR(mainwin->summaryview->qsearch);
1528
        GtkWidget *focus_widget;
1529

    
1530
        debug_print("Changing window layout type (layout: %d -> %d, separation: %d -> %d)\n", prefs_common.layout_type, layout, mainwin->type, type);
1531

    
1532
        if (prefs_common.layout_type == layout && mainwin->type == type)
1533
                return;
1534

    
1535
        /* keep previous focus */
1536
        focus_widget = gtk_window_get_focus(GTK_WINDOW(mainwin->window));
1537

    
1538
        gtk_widget_ref(folder_wid);
1539
        gtk_widget_ref(summary_wid);
1540
        gtk_widget_ref(message_wid);
1541
        gtk_widget_ref(qsearch_wid);
1542

    
1543
        main_window_hide(mainwin);
1544
        main_window_set_widgets(mainwin, layout, type);
1545
        gtk_widget_show(mainwin->window);
1546
        if (focus_widget)
1547
                gtk_widget_grab_focus(focus_widget);
1548

    
1549
        gtk_widget_unref(folder_wid);
1550
        gtk_widget_unref(summary_wid);
1551
        gtk_widget_unref(message_wid);
1552
        gtk_widget_unref(qsearch_wid);
1553
}
1554

    
1555
void main_window_toggle_message_view(MainWindow *mainwin)
1556
{
1557
        SummaryView *summaryview = mainwin->summaryview;
1558
        union CompositeWin *cwin = &mainwin->win;
1559
        GtkWidget *vpaned = NULL;
1560
        GtkWidget *container = NULL;
1561
        GtkWidget *msgwin = NULL;
1562
        gboolean use_vlayout = (prefs_common.layout_type == LAYOUT_VERTICAL);
1563

    
1564
        switch (mainwin->type) {
1565
        case SEPARATE_NONE:
1566
                vpaned = cwin->sep_none.vpaned;
1567
                container = GTK_WIDGET_PTR(summaryview->qsearch)->parent;
1568
                break;
1569
        case SEPARATE_FOLDER:
1570
                vpaned = cwin->sep_folder.vpaned;
1571
                container = GTK_WIDGET_PTR(summaryview->qsearch)->parent;
1572
                break;
1573
        case SEPARATE_MESSAGE:
1574
                msgwin = mainwin->win.sep_message.messagewin;
1575
                break;
1576
        case SEPARATE_BOTH:
1577
                msgwin = mainwin->win.sep_both.messagewin;
1578
                break;
1579
        }
1580

    
1581
        if (msgwin) {
1582
                /* separate message view */
1583
                if (GTK_WIDGET_VISIBLE(msgwin)) {
1584
                        gtk_widget_hide(msgwin);
1585
                        mainwin->messageview->visible = FALSE;
1586
                        summaryview->displayed = NULL;
1587
                } else {
1588
                        gtk_widget_show(msgwin);
1589
                        mainwin->messageview->visible = TRUE;
1590
                }
1591
        } else if (vpaned->parent != NULL) {
1592
                /* hide message view */
1593
                mainwin->messageview->visible = FALSE;
1594
                summaryview->displayed = NULL;
1595
                gtk_widget_ref(vpaned);
1596
                gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1597
                gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1598
                if (!use_vlayout)
1599
                        gtk_widget_hide(summaryview->hseparator);
1600
        } else {
1601
                /* show message view */
1602
                mainwin->messageview->visible = TRUE;
1603
                gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1604
                gtk_container_add(GTK_CONTAINER(container), vpaned);
1605
                gtk_widget_unref(vpaned);
1606
                if (!use_vlayout)
1607
                        gtk_widget_show(summaryview->hseparator);
1608
        }
1609

    
1610
        if (messageview_is_visible(mainwin->messageview))
1611
                gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1612
                              use_vlayout ? GTK_ARROW_RIGHT : GTK_ARROW_DOWN,
1613
                              GTK_SHADOW_OUT);
1614
        else
1615
                gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1616
                              use_vlayout ? GTK_ARROW_LEFT : GTK_ARROW_UP,
1617
                              GTK_SHADOW_OUT);
1618

    
1619
        if (mainwin->messageview->visible == FALSE)
1620
                messageview_clear(mainwin->messageview);
1621

    
1622
        main_window_set_menu_sensitive(mainwin);
1623

    
1624
        prefs_common.msgview_visible = mainwin->messageview->visible;
1625

    
1626
        gtk_widget_grab_focus(summaryview->treeview);
1627
}
1628

    
1629
void main_window_get_size(MainWindow *mainwin)
1630
{
1631
        GtkAllocation *allocation;
1632
        gboolean vlayout = (prefs_common.layout_type == LAYOUT_VERTICAL);
1633

    
1634
        allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1635
        if (allocation->width > 1 && allocation->height > 1) {
1636
                if (vlayout) {
1637
                        if (!(mainwin->type & SEPARATE_MESSAGE) &&
1638
                            messageview_is_visible(mainwin->messageview))
1639
                                prefs_common.summaryview_vwidth = allocation->width;
1640
                        prefs_common.summaryview_vheight = allocation->height;
1641
                } else {
1642
                        if (!prefs_common.mainwin_maximized) {
1643
                                prefs_common.summaryview_width = allocation->width;
1644
                                prefs_common.mainview_width = allocation->width;
1645
                        }
1646
                        if ((mainwin->type == SEPARATE_NONE ||
1647
                             mainwin->type == SEPARATE_FOLDER) &&
1648
                            messageview_is_visible(mainwin->messageview))
1649
                                prefs_common.summaryview_height = allocation->height;
1650
                }
1651
        }
1652

    
1653
        if (prefs_common.mainwin_maximized) {
1654
                allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1655
                if (allocation->width > 1 && allocation->height > 1)
1656
                        prefs_common.folderview_width  = allocation->width;
1657
                return;
1658
        }
1659

    
1660
        allocation = &mainwin->window->allocation;
1661
        if (allocation->width > 1 && allocation->height > 1) {
1662
                prefs_common.mainview_height = allocation->height;
1663
                prefs_common.mainwin_width   = allocation->width;
1664
                prefs_common.mainwin_height  = allocation->height;
1665
        }
1666

    
1667
        allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1668
        if (allocation->width > 1 && allocation->height > 1) {
1669
                prefs_common.folderview_width  = allocation->width;
1670
                prefs_common.folderview_height = allocation->height;
1671
        }
1672

    
1673
        allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1674
        if (allocation->width > 1 && allocation->height > 1) {
1675
                if (vlayout) {
1676
                        prefs_common.msgview_vwidth = allocation->width;
1677
                        prefs_common.msgview_vheight = allocation->height;
1678
                } else {
1679
                        prefs_common.msgview_width = allocation->width;
1680
                        prefs_common.msgview_height = allocation->height;
1681
                }
1682
        }
1683

    
1684
#if 0
1685
        debug_print("summaryview size: %d x %d\n",
1686
                    prefs_common.summaryview_width,
1687
                    prefs_common.summaryview_height);
1688
        debug_print("mainwin size: %d x %d\n",
1689
                    prefs_common.mainwin_width,
1690
                    prefs_common.mainwin_height);
1691
        debug_print("folderview size: %d x %d\n",
1692
                    prefs_common.folderview_width,
1693
                    prefs_common.folderview_height);
1694
        debug_print("messageview size: %d x %d\n",
1695
                    prefs_common.msgview_width,
1696
                    prefs_common.msgview_height);
1697
#endif
1698
}
1699

    
1700
void main_window_get_position(MainWindow *mainwin)
1701
{
1702
        gint x, y;
1703
        GtkWidget *window;
1704

    
1705
        if (prefs_common.mainwin_maximized || mainwin->window_hidden)
1706
                return;
1707

    
1708
        gtkut_widget_get_uposition(mainwin->window, &x, &y);
1709

    
1710
        prefs_common.mainview_x = x;
1711
        prefs_common.mainview_y = y;
1712
        prefs_common.mainwin_x = x;
1713
        prefs_common.mainwin_y = y;
1714

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

    
1717
        window = main_window_get_folder_window(mainwin);
1718
        if (window) {
1719
                gtkut_widget_get_uposition(window, &x, &y);
1720
                prefs_common.folderwin_x = x;
1721
                prefs_common.folderwin_y = y;
1722
                debug_print("folder window position: %d, %d\n", x, y);
1723
        }
1724
        window = main_window_get_message_window(mainwin);
1725
        if (window) {
1726
                gtkut_widget_get_uposition(window, &x, &y);
1727
                prefs_common.main_msgwin_x = x;
1728
                prefs_common.main_msgwin_y = y;
1729
                debug_print("message window position: %d, %d\n", x, y);
1730
        }
1731
}
1732

    
1733
void main_window_progress_on(MainWindow *mainwin)
1734
{
1735
        gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), TRUE);
1736
        gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1737
}
1738

    
1739
void main_window_progress_off(MainWindow *mainwin)
1740
{
1741
        gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), FALSE);
1742
        gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1743
        gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1744
}
1745

    
1746
void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1747
{
1748
        gchar buf[32];
1749

    
1750
        g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1751
        gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), buf);
1752
        gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar),
1753
                                (cur == 0 && total == 0) ? 0 :
1754
                                (gfloat)cur / (gfloat)total);
1755
}
1756

    
1757
void main_window_progress_show(gint cur, gint total)
1758
{
1759
        MainWindow *mainwin;
1760

    
1761
        mainwin = main_window_get();
1762

    
1763
        if (total > 0) {
1764
                gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar),
1765
                                           TRUE);
1766
                main_window_progress_set(mainwin, cur, total);
1767
        } else
1768
                main_window_progress_off(mainwin);
1769
}
1770

    
1771
void main_window_toggle_online(MainWindow *mainwin, gboolean online)
1772
{
1773
        if (prefs_common.online_mode != online)
1774
                online_switch_clicked(mainwin->online_switch, mainwin);
1775
}
1776

    
1777
gboolean main_window_toggle_online_if_offline(MainWindow *mainwin)
1778
{
1779
        if (!prefs_common.online_mode) {
1780
                if (alertpanel(_("Offline"),
1781
                               _("You are offline. Go online?"),
1782
                               GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1783
                    == G_ALERTDEFAULT)
1784
                        main_window_toggle_online(mainwin, TRUE);
1785
        }
1786

    
1787
        return prefs_common.online_mode;
1788
}
1789

    
1790
void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1791
{
1792
        GList *list;
1793

    
1794
        if (!procmsg_trash_messages_exist())
1795
                return;
1796

    
1797
        if (confirm) {
1798
                if (alertpanel(_("Empty all trash"),
1799
                               _("Delete all messages in trash folders?"),
1800
                               GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1801
                    != G_ALERTDEFAULT)
1802
                        return;
1803
                manage_window_focus_in(mainwin->window, NULL, NULL);
1804
        }
1805

    
1806
        procmsg_empty_all_trash();
1807
        statusbar_pop_all();
1808
        trayicon_set_tooltip(NULL);
1809
        trayicon_set_notify(FALSE);
1810

    
1811
        for (list = folder_get_list(); list != NULL; list = list->next) {
1812
                Folder *folder;
1813

    
1814
                folder = list->data;
1815
                if (folder->trash)
1816
                        folderview_update_item(folder->trash, TRUE);
1817
        }
1818

    
1819
        if (mainwin->summaryview->folder_item &&
1820
            mainwin->summaryview->folder_item->stype == F_TRASH)
1821
                gtk_widget_grab_focus(mainwin->folderview->treeview);
1822
}
1823

    
1824
void main_window_add_mailbox(MainWindow *mainwin)
1825
{
1826
        gchar *path;
1827
        Folder *folder;
1828

    
1829
        path = input_dialog_with_filesel
1830
                (_("Add mailbox"),
1831
                 _("Specify the location of mailbox.\n"
1832
                   "If the existing mailbox is specified, it will be\n"
1833
                   "scanned automatically."),
1834
                 "Mail", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
1835
        if (!path) return;
1836
        if (folder_find_from_path(path)) {
1837
                alertpanel_error(_("The mailbox `%s' already exists."), path);
1838
                g_free(path);
1839
                return;
1840
        }
1841
        if (!strcmp(path, "Mail"))
1842
                folder = folder_new(F_MH, _("Mailbox"), path);
1843
        else
1844
                folder = folder_new(F_MH, g_basename(path), path);
1845
        g_free(path);
1846

    
1847
        if (folder->klass->create_tree(folder) < 0) {
1848
                alertpanel_error(_("Creation of the mailbox failed.\n"
1849
                                   "Maybe some files already exist, or you don't have the permission to write there."));
1850
                folder_destroy(folder);
1851
                return;
1852
        }
1853

    
1854
        folder_add(folder);
1855
        folder_set_ui_func(folder, scan_tree_func, mainwin);
1856
        folder->klass->scan_tree(folder);
1857
        folder_set_ui_func(folder, NULL, NULL);
1858

    
1859
        folderview_set(mainwin->folderview);
1860
}
1861

    
1862
void main_window_send_queue(MainWindow *mainwin)
1863
{
1864
        GList *list;
1865

    
1866
        if (inc_is_active())
1867
                return;
1868
        if (!main_window_toggle_online_if_offline(mainwin))
1869
                return;
1870

    
1871
        for (list = folder_get_list(); list != NULL; list = list->next) {
1872
                Folder *folder = list->data;
1873

    
1874
                if (folder->queue) {
1875
                        gint ret;
1876

    
1877
                        ret = send_message_queue_all(folder->queue,
1878
                                                     prefs_common.savemsg,
1879
                                                     prefs_common.filter_sent);
1880
                        statusbar_pop_all();
1881
                        if (ret > 0)
1882
                                folder_item_scan(folder->queue);
1883
                }
1884
        }
1885

    
1886
        folderview_update_all_updated(TRUE);
1887
        main_window_set_menu_sensitive(mainwin);
1888
        main_window_set_toolbar_sensitive(mainwin);
1889
}
1890

    
1891
typedef enum
1892
{
1893
        M_UNLOCKED            = 1 << 0,
1894
        M_MSG_EXIST           = 1 << 1,
1895
        M_TARGET_EXIST        = 1 << 2,
1896
        M_SINGLE_TARGET_EXIST = 1 << 3,
1897
        M_EXEC                = 1 << 4,
1898
        M_ALLOW_REEDIT        = 1 << 5,
1899
        M_HAVE_ACCOUNT        = 1 << 6,
1900
        M_THREADED              = 1 << 7,
1901
        M_UNTHREADED              = 1 << 8,
1902
        M_ALLOW_DELETE              = 1 << 9,
1903
        M_INC_ACTIVE              = 1 << 10,
1904
        M_ENABLE_JUNK              = 1 << 11,
1905
        M_HAVE_QUEUED_MSG     = 1 << 12,
1906
        M_POP3_ACCOUNT              = 1 << 13,
1907

    
1908
        M_FOLDER_NEWOK              = 1 << 17,
1909
        M_FOLDER_RENOK              = 1 << 18,
1910
        M_FOLDER_MOVEOK              = 1 << 19,
1911
        M_FOLDER_DELOK              = 1 << 20,
1912
        M_MBOX_ADDOK              = 1 << 21,
1913
        M_MBOX_RMOK              = 1 << 22,
1914
        M_MBOX_CHKOK              = 1 << 23,
1915
        M_MBOX_CHKALLOK              = 1 << 24,
1916
        M_MBOX_REBUILDOK      = 1 << 25
1917
} SensitiveCond;
1918

    
1919
static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1920
{
1921
        SensitiveCond state = 0;
1922
        SummarySelection selection;
1923
        GList *list;
1924
        FolderItem *item = mainwin->summaryview->folder_item;
1925

    
1926
        selection = summary_get_selection_type(mainwin->summaryview);
1927

    
1928
        if (mainwin->lock_count == 0)
1929
                state |= M_UNLOCKED;
1930
        if (selection != SUMMARY_NONE)
1931
                state |= M_MSG_EXIST;
1932
        if (item && item->path && item->parent && !item->no_select) {
1933
                state |= M_EXEC;
1934
                if (item->threaded)
1935
                        state |= M_THREADED;
1936
                else
1937
                        state |= M_UNTHREADED;        
1938
                if (FOLDER_TYPE(item->folder) != F_NEWS)
1939
                        state |= M_ALLOW_DELETE;
1940
        }
1941
        if (selection == SUMMARY_SELECTED_SINGLE ||
1942
            selection == SUMMARY_SELECTED_MULTIPLE)
1943
                state |= M_TARGET_EXIST;
1944
        if (selection == SUMMARY_SELECTED_SINGLE)
1945
                state |= M_SINGLE_TARGET_EXIST;
1946
        if (selection == SUMMARY_SELECTED_SINGLE &&
1947
            FOLDER_ITEM_IS_SENT_FOLDER(item))
1948
                state |= M_ALLOW_REEDIT;
1949
        if (cur_account) {
1950
                state |= M_HAVE_ACCOUNT;
1951
                if (cur_account->protocol == A_POP3)
1952
                        state |= M_POP3_ACCOUNT;
1953
        }
1954

    
1955
        if (inc_is_active())
1956
                state |= M_INC_ACTIVE;
1957

    
1958
        if (prefs_common.enable_junk)
1959
                state |= M_ENABLE_JUNK;
1960

    
1961
        for (list = folder_get_list(); list != NULL; list = list->next) {
1962
                Folder *folder = list->data;
1963
                if (folder->queue && folder->queue->total > 0) {
1964
                        state |= M_HAVE_QUEUED_MSG;
1965
                        break;
1966
                }
1967
        }
1968

    
1969
        item = folderview_get_selected_item(mainwin->folderview);
1970
        if (item) {
1971
                state |= M_FOLDER_NEWOK;
1972
                if (item->parent == NULL) {
1973
                        state |= M_MBOX_RMOK;
1974
                        state |= M_MBOX_CHKOK;
1975
                }
1976
                if (FOLDER_IS_LOCAL(item->folder) ||
1977
                    FOLDER_TYPE(item->folder) == F_IMAP) {
1978
                        if (item->parent == NULL)
1979
                                state |= M_MBOX_REBUILDOK;
1980
                        else if (item->stype == F_NORMAL) {
1981
                                state |= M_FOLDER_RENOK;
1982
                                state |= M_FOLDER_DELOK;
1983
                                if (item->folder->klass->move_folder)
1984
                                        state |= M_FOLDER_MOVEOK;
1985
                        }
1986
                } else if (FOLDER_TYPE(item->folder) == F_NEWS) {
1987
                        if (item->parent != NULL)
1988
                                state |= M_FOLDER_DELOK;
1989
                }
1990
        }
1991
        state |= M_MBOX_ADDOK;
1992
        state |= M_MBOX_CHKALLOK;
1993

    
1994
        return state;
1995
}
1996

    
1997
void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1998
{
1999
        SensitiveCond state;
2000
        gboolean sensitive, prev_sensitive;
2001
        gint n;
2002
        gint i = 0;
2003

    
2004
        struct {
2005
                GtkWidget *widget;
2006
                SensitiveCond cond;
2007
        } entry[20];
2008

    
2009
#define SET_WIDGET_COND(w, c)        \
2010
{                                \
2011
        entry[i].widget = w;        \
2012
        entry[i].cond = c;        \
2013
        i++;                        \
2014
}
2015

    
2016
        SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2017
        SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2018
        SET_WIDGET_COND(mainwin->rpop3_btn,
2019
                        M_HAVE_ACCOUNT|M_UNLOCKED|M_POP3_ACCOUNT);
2020
        SET_WIDGET_COND(mainwin->send_btn,
2021
                        M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_QUEUED_MSG);
2022
        SET_WIDGET_COND(mainwin->compose_btn, M_HAVE_ACCOUNT);
2023
        SET_WIDGET_COND(mainwin->reply_btn,
2024
                        M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2025
        SET_WIDGET_COND(mainwin->reply_combo ?
2026
                        GTK_WIDGET_PTR(mainwin->reply_combo) : NULL,
2027
                        M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2028
        SET_WIDGET_COND(mainwin->replyall_btn,
2029
                        M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2030
        SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
2031
        SET_WIDGET_COND(mainwin->fwd_combo ? GTK_WIDGET_PTR(mainwin->fwd_combo)
2032
                        : NULL,
2033
                        M_HAVE_ACCOUNT|M_TARGET_EXIST);
2034
        SET_WIDGET_COND(mainwin->delete_btn,
2035
                        M_TARGET_EXIST|M_ALLOW_DELETE);
2036
        SET_WIDGET_COND(mainwin->junk_btn,
2037
                        M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK);
2038
        SET_WIDGET_COND(mainwin->notjunk_btn,
2039
                        M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK);
2040
        SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC);
2041
        SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
2042
        SET_WIDGET_COND(mainwin->prev_btn, M_MSG_EXIST);
2043
        SET_WIDGET_COND(mainwin->print_btn, M_TARGET_EXIST);
2044
        SET_WIDGET_COND(mainwin->stop_btn, M_INC_ACTIVE);
2045
        SET_WIDGET_COND(mainwin->prefs_common_btn, M_UNLOCKED);
2046
        SET_WIDGET_COND(mainwin->prefs_account_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2047

    
2048
#undef SET_WIDGET_COND
2049

    
2050
        state = main_window_get_current_state(mainwin);
2051

    
2052
        n = sizeof(entry) / sizeof(entry[0]);
2053
        for (i = 0; i < n; i++) {
2054
                if (entry[i].widget) {
2055
                        prev_sensitive =
2056
                                GTK_WIDGET_IS_SENSITIVE(entry[i].widget);
2057
                        sensitive = ((entry[i].cond & state) == entry[i].cond);
2058
                        if (prev_sensitive != sensitive) {
2059
                                /* workaround for GTK+ bug (#56070) */
2060
                                if (!prev_sensitive)
2061
                                        gtk_widget_hide(entry[i].widget);
2062
                                gtk_widget_set_sensitive(entry[i].widget,
2063
                                                         sensitive);
2064
                                if (!prev_sensitive)
2065
                                        gtk_widget_show(entry[i].widget);
2066
                        }
2067
                }
2068
        }
2069
}
2070

    
2071
static void main_window_set_toolbar_button_visibility(MainWindow *mainwin)
2072
{
2073
        GtkToolbarStyle style = GTK_TOOLBAR_BOTH_HORIZ;
2074

    
2075
        if (prefs_common.toolbar_style == TOOLBAR_NONE)
2076
                style = -1;
2077
        else if (prefs_common.toolbar_style == TOOLBAR_ICON)
2078
                style = GTK_TOOLBAR_ICONS;
2079
        else if (prefs_common.toolbar_style == TOOLBAR_TEXT)
2080
                style = GTK_TOOLBAR_TEXT;
2081
        else if (prefs_common.toolbar_style == TOOLBAR_BOTH)
2082
                style = GTK_TOOLBAR_BOTH;
2083
        else if (prefs_common.toolbar_style == TOOLBAR_BOTH_HORIZ)
2084
                style = GTK_TOOLBAR_BOTH_HORIZ;
2085

    
2086
        if (style != -1) {
2087
                gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar), style);
2088
                gtk_widget_show(mainwin->toolbar);
2089
                gtk_widget_queue_resize(mainwin->toolbar);
2090
        } else
2091
                gtk_widget_hide(mainwin->toolbar);
2092

    
2093
#if 0
2094
        if (mainwin->junk_btn) {
2095
                if (prefs_common.enable_junk)
2096
                        gtk_widget_show(mainwin->junk_btn);
2097
                else
2098
                        gtk_widget_hide(mainwin->junk_btn);
2099
        }
2100

2101
        if (mainwin->exec_btn) {
2102
                if (prefs_common.immediate_exec)
2103
                        gtk_widget_hide(mainwin->exec_btn);
2104
                else
2105
                        gtk_widget_show(mainwin->exec_btn);
2106
        }
2107
#endif
2108
}
2109

    
2110
void main_window_set_menu_sensitive(MainWindow *mainwin)
2111
{
2112
        GtkItemFactory *ifactory = mainwin->menu_factory;
2113
        SensitiveCond state;
2114
        gboolean sensitive;
2115
        GtkWidget *menu;
2116
        GtkWidget *menuitem;
2117
        FolderItem *item;
2118
        gchar *menu_path;
2119
        gint i;
2120
        GList *cur_item;
2121

    
2122
        static const struct {
2123
                gchar *const entry;
2124
                SensitiveCond cond;
2125
        } entry[] = {
2126
                {"/File/Folder/Create new folder...", M_UNLOCKED|M_FOLDER_NEWOK},
2127
                {"/File/Folder/Rename folder..."    , M_UNLOCKED|M_FOLDER_RENOK},
2128
                {"/File/Folder/Move folder..."      , M_UNLOCKED|M_FOLDER_MOVEOK},
2129
                {"/File/Folder/Delete folder"       , M_UNLOCKED|M_FOLDER_DELOK},
2130
                {"/File/Mailbox/Add mailbox..."     , M_UNLOCKED|M_MBOX_ADDOK},
2131
                {"/File/Mailbox/Remove mailbox"     , M_UNLOCKED|M_MBOX_RMOK},
2132
                {"/File/Mailbox/Check for new messages"
2133
                                                    , M_UNLOCKED|M_MBOX_CHKOK},
2134
                {"/File/Mailbox/Check for new messages in all mailboxes"
2135
                                                    , M_UNLOCKED|M_MBOX_CHKALLOK},
2136
                {"/File/Mailbox/Rebuild folder tree", M_UNLOCKED|M_MBOX_REBUILDOK},
2137
                {"/File/Import mail data..."        , M_UNLOCKED},
2138
                {"/File/Export mail data..."        , M_UNLOCKED},
2139
                {"/File/Empty all trash"            , M_UNLOCKED},
2140

    
2141
                {"/File/Save as..."  , M_SINGLE_TARGET_EXIST},
2142
                {"/File/Print..."    , M_TARGET_EXIST},
2143
                {"/File/Work offline", M_UNLOCKED},
2144
                /* {"/File/Close"    , M_UNLOCKED}, */
2145
                {"/File/Exit"        , M_UNLOCKED},
2146

    
2147
                {"/Edit/Select thread"             , M_SINGLE_TARGET_EXIST},
2148

    
2149
                {"/View/Sort"                      , M_EXEC},
2150
                {"/View/Thread view"               , M_EXEC},
2151
                {"/View/Expand all threads"        , M_MSG_EXIST},
2152
                {"/View/Collapse all threads"      , M_MSG_EXIST},
2153
                {"/View/Go to/Prev message"        , M_MSG_EXIST},
2154
                {"/View/Go to/Next message"        , M_MSG_EXIST},
2155
                {"/View/Go to/Prev unread message" , M_MSG_EXIST},
2156
                {"/View/Go to/Next unread message" , M_MSG_EXIST},
2157
                {"/View/Go to/Prev new message"    , M_MSG_EXIST},
2158
                {"/View/Go to/Next new message"    , M_MSG_EXIST},
2159
                {"/View/Go to/Prev marked message" , M_MSG_EXIST},
2160
                {"/View/Go to/Next marked message" , M_MSG_EXIST},
2161
                {"/View/Go to/Prev labeled message", M_MSG_EXIST},
2162
                {"/View/Go to/Next labeled message", M_MSG_EXIST},
2163
                {"/View/Open in new window"        , M_SINGLE_TARGET_EXIST},
2164
                {"/View/All headers"          , M_SINGLE_TARGET_EXIST},
2165
                {"/View/Message source"            , M_SINGLE_TARGET_EXIST},
2166

    
2167
                {"/Message/Receive/Get from current account"
2168
                                                 , M_HAVE_ACCOUNT|M_UNLOCKED},
2169
                {"/Message/Receive/Get from all accounts"
2170
                                                 , M_HAVE_ACCOUNT|M_UNLOCKED},
2171
                {"/Message/Receive/Stop receiving"
2172
                                                 , M_INC_ACTIVE},
2173
                {"/Message/Receive/Remote mailbox..."
2174
                                                 , M_HAVE_ACCOUNT|M_UNLOCKED|M_POP3_ACCOUNT},
2175
                {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_QUEUED_MSG},
2176

    
2177
                {"/Message/Compose new message"  , M_HAVE_ACCOUNT},
2178
                {"/Message/Reply"                , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
2179
                {"/Message/Reply to"             , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
2180
                {"/Message/Forward"              , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2181
                {"/Message/Forward as attachment", M_HAVE_ACCOUNT|M_TARGET_EXIST},
2182
                {"/Message/Redirect"             , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
2183
                {"/Message/Move..."              , M_TARGET_EXIST|M_ALLOW_DELETE},
2184
                {"/Message/Copy..."              , M_TARGET_EXIST|M_EXEC},
2185
                {"/Message/Delete"               , M_TARGET_EXIST|M_ALLOW_DELETE},
2186
                {"/Message/Mark"                 , M_TARGET_EXIST},
2187
                {"/Message/Set as junk mail"     , M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK},
2188
                {"/Message/Set as not junk mail" , M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK},
2189
                {"/Message/Re-edit"              , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2190

    
2191
                {"/Tools/Add sender to address book...", M_SINGLE_TARGET_EXIST},
2192
                {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2193
                {"/Tools/Filter selected messages"     , M_TARGET_EXIST|M_EXEC},
2194
                {"/Tools/Create filter rule"           , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2195
                {"/Tools/Filter junk mails in folder"  , M_MSG_EXIST|M_EXEC|M_ENABLE_JUNK},
2196
                {"/Tools/Filter junk mails in selected messages", M_TARGET_EXIST|M_EXEC|M_ENABLE_JUNK},
2197
#ifndef G_OS_WIN32
2198
                {"/Tools/Actions"                      , M_TARGET_EXIST|M_UNLOCKED},
2199
#endif
2200
                {"/Tools/Execute marked process"       , M_MSG_EXIST|M_EXEC},
2201
                {"/Tools/Delete duplicated messages"   , M_MSG_EXIST|M_ALLOW_DELETE},
2202
                {"/Tools/Concatenate separated messages"
2203
                                                       , M_TARGET_EXIST|M_UNLOCKED|M_ALLOW_DELETE},
2204

    
2205
                {"/Configuration/Common preferences...", M_UNLOCKED},
2206
                {"/Configuration/Filter settings...", M_UNLOCKED},
2207
                {"/Configuration/Preferences for current account...", M_UNLOCKED},
2208
                {"/Configuration/Create new account...", M_UNLOCKED},
2209
                {"/Configuration/Edit accounts...", M_UNLOCKED},
2210
                {"/Configuration/Change current account", M_UNLOCKED},
2211

    
2212
                {NULL, 0}
2213
        };
2214

    
2215
        state = main_window_get_current_state(mainwin);
2216

    
2217
        for (i = 0; entry[i].entry != NULL; i++) {
2218
                sensitive = ((entry[i].cond & state) == entry[i].cond);
2219
                menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2220
        }
2221

    
2222
        menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2223

    
2224
        /* search for separator */
2225
        for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2226
             cur_item = cur_item->next) {
2227
                if (GTK_BIN(cur_item->data)->child == NULL) {
2228
                        cur_item = cur_item->next;
2229
                        break;
2230
                }
2231
        }
2232

    
2233
        for (; cur_item != NULL; cur_item = cur_item->next) {
2234
                gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2235
                                         (M_UNLOCKED & state) != 0);
2236
        }
2237

    
2238
        main_window_menu_callback_block(mainwin);
2239

    
2240
#define SET_CHECK_MENU_ACTIVE(path, active) \
2241
{ \
2242
        menuitem = gtk_item_factory_get_widget(ifactory, path); \
2243
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2244
}
2245

    
2246
        SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2247
                              messageview_is_visible(mainwin->messageview));
2248

    
2249
        item = mainwin->summaryview->folder_item;
2250
        menu_path = "/View/Sort/Don't sort";
2251
        if (item) {
2252
                switch (item->sort_key) {
2253
                case SORT_BY_NUMBER:
2254
                        menu_path = "/View/Sort/by number"; break;
2255
                case SORT_BY_SIZE:
2256
                        menu_path = "/View/Sort/by size"; break;
2257
                case SORT_BY_DATE:
2258
                        menu_path = "/View/Sort/by date"; break;
2259
                case SORT_BY_TDATE:
2260
                        menu_path = "/View/Sort/by thread date"; break;
2261
                case SORT_BY_FROM:
2262
                        menu_path = "/View/Sort/by from"; break;
2263
                case SORT_BY_TO:
2264
                        menu_path = "/View/Sort/by recipient"; break;
2265
                case SORT_BY_SUBJECT:
2266
                        menu_path = "/View/Sort/by subject"; break;
2267
                case SORT_BY_LABEL:
2268
                        menu_path = "/View/Sort/by color label"; break;
2269
                case SORT_BY_MARK:
2270
                        menu_path = "/View/Sort/by mark"; break;
2271
                case SORT_BY_UNREAD:
2272
                        menu_path = "/View/Sort/by unread"; break;
2273
                case SORT_BY_MIME:
2274
                        menu_path = "/View/Sort/by attachment"; break;
2275
                case SORT_BY_NONE:
2276
                default:
2277
                        menu_path = "/View/Sort/Don't sort"; break;
2278
                }
2279
        }
2280
        SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2281

    
2282
        if (!item || item->sort_type == SORT_ASCENDING) {
2283
                SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2284
        } else {
2285
                SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2286
        }
2287

    
2288
        if (item && item->sort_key != SORT_BY_NONE) {
2289
                menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2290
                menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2291
                menu_set_sensitive(ifactory, "/View/Sort/Attract by subject",
2292
                                   FALSE);
2293
        } else {
2294
                menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2295
                menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2296
                menu_set_sensitive(ifactory, "/View/Sort/Attract by subject",
2297
                                   (item != NULL));
2298
        }
2299

    
2300
        SET_CHECK_MENU_ACTIVE("/View/All headers",
2301
                              mainwin->messageview->textview->show_all_headers);
2302
        SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2303

    
2304
#undef SET_CHECK_MENU_ACTIVE
2305

    
2306
        main_window_menu_callback_unblock(mainwin);
2307
}
2308

    
2309
void main_window_popup(MainWindow *mainwin)
2310
{
2311
        gtkut_window_popup(mainwin->window);
2312

    
2313
        switch (mainwin->type) {
2314
        case SEPARATE_FOLDER:
2315
                if (prefs_common.folderview_visible)
2316
                        gtkut_window_popup(mainwin->win.sep_folder.folderwin);
2317
                break;
2318
        case SEPARATE_MESSAGE:
2319
                if (messageview_is_visible(mainwin->messageview))
2320
                        gtkut_window_popup(mainwin->win.sep_message.messagewin);
2321
                break;
2322
        case SEPARATE_BOTH:
2323
                if (prefs_common.folderview_visible)
2324
                        gtkut_window_popup(mainwin->win.sep_both.folderwin);
2325
                if (messageview_is_visible(mainwin->messageview))
2326
                        gtkut_window_popup(mainwin->win.sep_both.messagewin);
2327
                break;
2328
        default:
2329
                break;
2330
        }
2331
}
2332

    
2333
static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout,
2334
                                    SeparateType type)
2335
{
2336
        GtkWidget *folderwin = NULL;
2337
        GtkWidget *messagewin = NULL;
2338
        GtkWidget *hpaned;
2339
        GtkWidget *vpaned;
2340
        GtkWidget *vbox_body = mainwin->vbox_body;
2341
        GtkWidget *vbox_summary;
2342
        GtkItemFactory *ifactory = mainwin->menu_factory;
2343
        GtkWidget *menuitem;
2344
        gboolean use_vlayout = (layout == LAYOUT_VERTICAL);
2345

    
2346
        debug_print("Setting main window widgets...\n");
2347

    
2348
        gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2349
                                    prefs_common.folderview_width,
2350
                                    prefs_common.folderview_height);
2351
        if (use_vlayout) {
2352
                gtk_widget_set_size_request
2353
                        (GTK_WIDGET_PTR(mainwin->summaryview),
2354
                         prefs_common.summaryview_vwidth,
2355
                         prefs_common.summaryview_vheight);
2356
                gtk_widget_set_size_request
2357
                        (GTK_WIDGET_PTR(mainwin->messageview),
2358
                         prefs_common.msgview_vwidth,
2359
                         prefs_common.msgview_vheight);
2360
        } else {
2361
                gtk_widget_set_size_request
2362
                        (GTK_WIDGET_PTR(mainwin->summaryview),
2363
                         prefs_common.summaryview_width,
2364
                         prefs_common.summaryview_height);
2365
                gtk_widget_set_size_request
2366
                        (GTK_WIDGET_PTR(mainwin->messageview),
2367
                         prefs_common.msgview_width,
2368
                         prefs_common.msgview_height);
2369
        }
2370

    
2371
        /* create separated window(s) if needed */
2372
        if (type & SEPARATE_FOLDER) {
2373
                folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2374
                gtk_window_set_title(GTK_WINDOW(folderwin),
2375
                                     _("Sylpheed - Folder View"));
2376
                gtk_window_set_wmclass(GTK_WINDOW(folderwin),
2377
                                       "folder_view", "Sylpheed");
2378
                gtk_window_set_policy(GTK_WINDOW(folderwin),
2379
                                      TRUE, TRUE, FALSE);
2380
                gtkut_window_move(GTK_WINDOW(folderwin),
2381
                                  prefs_common.folderwin_x,
2382
                                  prefs_common.folderwin_y);
2383
                gtk_container_set_border_width(GTK_CONTAINER(folderwin), 0);
2384
                g_signal_connect(G_OBJECT(folderwin), "delete_event",
2385
                                 G_CALLBACK(folder_window_close_cb), mainwin);
2386
                gtk_container_add(GTK_CONTAINER(folderwin),
2387
                                  GTK_WIDGET_PTR(mainwin->folderview));
2388
                gtk_widget_realize(folderwin);
2389
                if (prefs_common.folderview_visible)
2390
                        gtk_widget_show(folderwin);
2391
        }
2392
        if (type & SEPARATE_MESSAGE) {
2393
                messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2394
                gtk_window_set_title(GTK_WINDOW(messagewin),
2395
                                     _("Sylpheed - Message View"));
2396
                gtk_window_set_wmclass(GTK_WINDOW(messagewin),
2397
                                       "message_view", "Sylpheed");
2398
                gtk_window_set_policy(GTK_WINDOW(messagewin),
2399
                                      TRUE, TRUE, FALSE);
2400
                gtkut_window_move(GTK_WINDOW(messagewin),
2401
                                  prefs_common.main_msgwin_x,
2402
                                  prefs_common.main_msgwin_y);
2403
                gtk_container_set_border_width(GTK_CONTAINER(messagewin), 0);
2404
                g_signal_connect(G_OBJECT(messagewin), "delete_event",
2405
                                 G_CALLBACK(message_window_close_cb), mainwin);
2406
                gtk_container_add(GTK_CONTAINER(messagewin),
2407
                                  GTK_WIDGET_PTR(mainwin->messageview));
2408
                gtk_widget_realize(messagewin);
2409
                if (messageview_is_visible(mainwin->messageview))
2410
                        gtk_widget_show(messagewin);
2411
        }
2412

    
2413
        vbox_summary = gtk_vbox_new(FALSE, 1);
2414
        gtk_box_pack_start(GTK_BOX(vbox_summary),
2415
                           GTK_WIDGET_PTR(mainwin->summaryview->qsearch),
2416
                           FALSE, FALSE, 0);
2417
        gtk_widget_show(vbox_summary);
2418

    
2419
        switch (type) {
2420
        case SEPARATE_NONE:
2421
                hpaned = gtk_hpaned_new();
2422
                gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2423
                gtk_paned_add1(GTK_PANED(hpaned),
2424
                               GTK_WIDGET_PTR(mainwin->folderview));
2425
                gtk_paned_add2(GTK_PANED(hpaned), vbox_summary);
2426
                gtk_widget_show(hpaned);
2427
                gtk_widget_queue_resize(hpaned);
2428

    
2429
                if (use_vlayout) {
2430
                        vpaned = gtk_hpaned_new();
2431
                        gtk_widget_hide(mainwin->summaryview->hseparator);
2432
                } else
2433
                        vpaned = gtk_vpaned_new();
2434
                if (messageview_is_visible(mainwin->messageview)) {
2435
                        gtk_paned_add1(GTK_PANED(vpaned),
2436
                                       GTK_WIDGET_PTR(mainwin->summaryview));
2437
                        gtk_box_pack_start(GTK_BOX(vbox_summary), vpaned,
2438
                                           TRUE, TRUE, 0);
2439
                        if (!use_vlayout)
2440
                                gtk_widget_show
2441
                                        (mainwin->summaryview->hseparator);
2442
                } else {
2443
                        gtk_box_pack_start(GTK_BOX(vbox_summary),
2444
                                           GTK_WIDGET_PTR(mainwin->summaryview),
2445
                                           TRUE, TRUE, 0);
2446
                        gtk_widget_ref(vpaned);
2447
                        gtk_widget_hide(mainwin->summaryview->hseparator);
2448
                }
2449
                gtk_paned_add2(GTK_PANED(vpaned),
2450
                               GTK_WIDGET_PTR(mainwin->messageview));
2451
                gtk_widget_show(vpaned);
2452
                gtk_widget_queue_resize(vpaned);
2453

    
2454
                mainwin->win.sep_none.hpaned = hpaned;
2455
                mainwin->win.sep_none.vpaned = vpaned;
2456

    
2457
                break;
2458
        case SEPARATE_FOLDER:
2459
                gtk_box_pack_start(GTK_BOX(vbox_body), vbox_summary,
2460
                                   TRUE, TRUE, 0);
2461

    
2462
                if (use_vlayout) {
2463
                        vpaned = gtk_hpaned_new();
2464
                        gtk_widget_hide(mainwin->summaryview->hseparator);
2465
                } else
2466
                        vpaned = gtk_vpaned_new();
2467
                if (messageview_is_visible(mainwin->messageview)) {
2468
                        gtk_paned_add1(GTK_PANED(vpaned),
2469
                                       GTK_WIDGET_PTR(mainwin->summaryview));
2470
                        gtk_box_pack_start(GTK_BOX(vbox_summary), vpaned,
2471
                                           TRUE, TRUE, 0);
2472
                        if (!use_vlayout)
2473
                                gtk_widget_show
2474
                                        (mainwin->summaryview->hseparator);
2475
                } else {
2476
                        gtk_box_pack_start(GTK_BOX(vbox_summary),
2477
                                           GTK_WIDGET_PTR(mainwin->summaryview),
2478
                                           TRUE, TRUE, 0);
2479
                        gtk_widget_ref(vpaned);
2480
                        gtk_widget_hide(mainwin->summaryview->hseparator);
2481
                }
2482
                gtk_paned_add2(GTK_PANED(vpaned),
2483
                               GTK_WIDGET_PTR(mainwin->messageview));
2484
                gtk_widget_show(vpaned);
2485
                gtk_widget_queue_resize(vpaned);
2486

    
2487
                mainwin->win.sep_folder.folderwin = folderwin;
2488
                mainwin->win.sep_folder.vpaned    = vpaned;
2489

    
2490
                break;
2491
        case SEPARATE_MESSAGE:
2492
                hpaned = gtk_hpaned_new();
2493
                gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2494
                gtk_paned_add1(GTK_PANED(hpaned),
2495
                               GTK_WIDGET_PTR(mainwin->folderview));
2496
                gtk_paned_add2(GTK_PANED(hpaned), vbox_summary);
2497
                gtk_box_pack_start(GTK_BOX(vbox_summary),
2498
                                   GTK_WIDGET_PTR(mainwin->summaryview),
2499
                                   TRUE, TRUE, 0);
2500
                gtk_widget_hide(mainwin->summaryview->hseparator);
2501
                gtk_widget_show(hpaned);
2502
                gtk_widget_queue_resize(hpaned);
2503

    
2504
                mainwin->win.sep_message.messagewin = messagewin;
2505
                mainwin->win.sep_message.hpaned     = hpaned;
2506

    
2507
                break;
2508
        case SEPARATE_BOTH:
2509
                gtk_box_pack_start(GTK_BOX(vbox_body), vbox_summary,
2510
                                   TRUE, TRUE, 0);
2511
                gtk_box_pack_start(GTK_BOX(vbox_summary),
2512
                                   GTK_WIDGET_PTR(mainwin->summaryview),
2513
                                   TRUE, TRUE, 0);
2514
                gtk_widget_hide(mainwin->summaryview->hseparator);
2515

    
2516
                mainwin->win.sep_both.folderwin = folderwin;
2517
                mainwin->win.sep_both.messagewin = messagewin;
2518

    
2519
                break;
2520
        }
2521

    
2522
        if (messageview_is_visible(mainwin->messageview))
2523
                gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2524
                              use_vlayout ? GTK_ARROW_RIGHT : GTK_ARROW_DOWN,
2525
                              GTK_SHADOW_OUT);
2526
        else
2527
                gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2528
                              use_vlayout ? GTK_ARROW_LEFT : GTK_ARROW_UP,
2529
                              GTK_SHADOW_OUT);
2530

    
2531
        gtkut_window_move(GTK_WINDOW(mainwin->window), 
2532
                          prefs_common.mainwin_x, prefs_common.mainwin_y);
2533

    
2534
        gtk_widget_queue_resize(vbox_body);
2535
        gtk_widget_queue_resize(mainwin->vbox);
2536
        gtk_widget_queue_resize(mainwin->window);
2537

    
2538
        mainwin->type = type;
2539
        prefs_common.layout_type = layout;
2540

    
2541
        /* toggle menu state */
2542
        menuitem = gtk_item_factory_get_item
2543
                (ifactory, "/View/Show or hide/Folder tree");
2544
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2545
                                       (type & SEPARATE_FOLDER) == 0 ? TRUE :
2546
                                       prefs_common.folderview_visible);
2547
        gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2548
        menuitem = gtk_item_factory_get_item
2549
                (ifactory, "/View/Show or hide/Message view");
2550
        gtk_check_menu_item_set_active
2551
                (GTK_CHECK_MENU_ITEM(menuitem),
2552
                 messageview_is_visible(mainwin->messageview));
2553

    
2554
        if (layout == LAYOUT_NORMAL) {
2555
                menuitem = gtk_item_factory_get_item
2556
                        (ifactory, "/View/Layout/Normal");
2557
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2558
                                               TRUE);
2559
        } else if (layout == LAYOUT_VERTICAL) {
2560
                menuitem = gtk_item_factory_get_item
2561
                        (ifactory, "/View/Layout/Vertical");
2562
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2563
                                               TRUE);
2564
        }
2565

    
2566
        menuitem = gtk_item_factory_get_item
2567
                (ifactory, "/View/Separate folder tree");
2568
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2569
                                       ((type & SEPARATE_FOLDER) != 0));
2570
        menuitem = gtk_item_factory_get_item
2571
                (ifactory, "/View/Separate message view");
2572
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2573
                                       ((type & SEPARATE_MESSAGE) != 0));
2574

    
2575
        if (folderwin) {
2576
                g_signal_connect
2577
                        (G_OBJECT(folderwin), "size_allocate",
2578
                         G_CALLBACK(folder_window_size_allocate_cb), mainwin);
2579
        }
2580
        if (messagewin) {
2581
                g_signal_connect
2582
                        (G_OBJECT(messagewin), "size_allocate",
2583
                         G_CALLBACK(message_window_size_allocate_cb), mainwin);
2584
        }
2585

    
2586
        debug_print("done.\n");
2587
}
2588

    
2589
static GtkItemFactoryEntry reply_entries[] =
2590
{
2591
        {N_("/_Reply"),                        NULL, reply_cb, COMPOSE_REPLY, NULL},
2592
        {N_("/Reply to _all"),                NULL, reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
2593
        {N_("/Reply to _sender"),        NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
2594
        {N_("/Reply to mailing _list"),        NULL, reply_cb, COMPOSE_REPLY_TO_LIST, NULL}
2595
};
2596

    
2597
static GtkItemFactoryEntry forward_entries[] =
2598
{
2599
        {N_("/_Forward"),                NULL, reply_cb, COMPOSE_FORWARD, NULL},
2600
        {N_("/For_ward as attachment"), NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
2601
        {N_("/Redirec_t"),                NULL, reply_cb, COMPOSE_REDIRECT, NULL}
2602
};
2603

    
2604
static PrefsToolbarItem items[] =
2605
{
2606
        {T_GET,                        TRUE,        toolbar_inc_cb},
2607
        {T_GET_ALL,                TRUE,        toolbar_inc_all_cb},
2608
        {T_SEND_QUEUE,                TRUE,        toolbar_send_cb},
2609
        {T_COMPOSE,                TRUE,        toolbar_compose_cb},
2610
        {T_REPLY,                TRUE,        toolbar_reply_cb},
2611
        {T_REPLY_ALL,                TRUE,        toolbar_reply_to_all_cb},
2612
        {T_FORWARD,                TRUE,        toolbar_forward_cb},
2613
        {T_DELETE,                FALSE,        toolbar_delete_cb},
2614
        {T_JUNK,                TRUE,        toolbar_junk_cb},
2615
        {T_NOTJUNK,                FALSE,        toolbar_notjunk_cb},
2616
        {T_NEXT,                FALSE,        toolbar_next_unread_cb},
2617
        {T_PREV,                FALSE,        toolbar_prev_unread_cb},
2618
        {T_SEARCH,                FALSE,        toolbar_search_cb},
2619
        {T_PRINT,                FALSE,        toolbar_print_cb},
2620
        {T_STOP,                FALSE,        toolbar_stop_cb},
2621
        {T_ADDRESS_BOOK,        FALSE,        toolbar_address_cb},
2622
        {T_EXECUTE,                FALSE,        toolbar_exec_cb},
2623
        {T_COMMON_PREFS,        FALSE,        toolbar_prefs_common_cb},
2624
        {T_ACCOUNT_PREFS,        FALSE,        toolbar_prefs_account_cb},
2625
        {T_REMOTE_MAILBOX,        FALSE,        toolbar_rpop3_cb},
2626

    
2627
        {-1, FALSE, NULL}
2628
};
2629

    
2630
static GtkWidget *main_window_toolbar_create(MainWindow *mainwin)
2631
{
2632
        GtkWidget *toolbar;
2633
        const gchar *setting;
2634
        GList *item_list;
2635

    
2636
        if (prefs_common.main_toolbar_setting &&
2637
            *prefs_common.main_toolbar_setting != '\0')
2638
                setting = prefs_common.main_toolbar_setting;
2639
        else
2640
                setting = prefs_toolbar_get_default_main_setting_name_list();
2641

    
2642
        item_list = prefs_toolbar_get_item_list_from_name_list(setting);
2643
        toolbar = main_window_toolbar_create_from_list(mainwin, item_list);
2644
        g_list_free(item_list);
2645

    
2646
        return toolbar;
2647
}
2648

    
2649
static GtkWidget *main_window_toolbar_create_from_list(MainWindow *mainwin,
2650
                                                       GList *item_list)
2651
{
2652
        GtkWidget *toolbar;
2653
        GtkWidget *icon_wid;
2654
        GtkToolItem *toolitem;
2655
        GtkToolItem *comboitem;
2656
        ComboButton *combo;
2657
        gint n_entries;
2658
        gint i;
2659
        GList *cur;
2660

    
2661
        toolbar = gtk_toolbar_new();
2662
        gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar),
2663
                                    GTK_ORIENTATION_HORIZONTAL);
2664
        gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2665
        g_signal_connect(G_OBJECT(toolbar), "button_press_event",
2666
                         G_CALLBACK(toolbar_button_pressed), mainwin);
2667

    
2668
        items[0].data = &mainwin->get_btn;
2669
        items[1].data = &mainwin->getall_btn;
2670
        items[2].data = &mainwin->send_btn;
2671
        items[3].data = &mainwin->compose_btn;
2672
        items[4].data = &mainwin->reply_btn;
2673
        items[5].data = &mainwin->replyall_btn;
2674
        items[6].data = &mainwin->fwd_btn;
2675
        items[7].data = &mainwin->delete_btn;
2676
        items[8].data = &mainwin->junk_btn;
2677
        items[9].data = &mainwin->notjunk_btn;
2678
        items[10].data = &mainwin->next_btn;
2679
        items[11].data = &mainwin->prev_btn;
2680
        items[12].data = &mainwin->search_btn;
2681
        items[13].data = &mainwin->print_btn;
2682
        items[14].data = &mainwin->stop_btn;
2683
        items[15].data = &mainwin->address_btn;
2684
        items[16].data = &mainwin->exec_btn;
2685
        items[17].data = &mainwin->prefs_common_btn;
2686
        items[18].data = &mainwin->prefs_account_btn;
2687
        items[19].data = &mainwin->rpop3_btn;
2688
        for (i = 0; i <= 19; i++)
2689
                *(GtkWidget **)items[i].data = NULL;
2690
        mainwin->reply_combo = NULL;
2691
        mainwin->fwd_combo = NULL;
2692

    
2693
        for (cur = item_list; cur != NULL; cur = cur->next) {
2694
                const PrefsDisplayItem *ditem = cur->data;
2695
                PrefsToolbarItem *item;
2696
                gint width;
2697

    
2698
                if (ditem->id == T_SEPARATOR) {
2699
                        toolitem = gtk_separator_tool_item_new();
2700
                        gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
2701
                        continue;
2702
                }
2703

    
2704
                for (item = items; item->id != -1; item++) {
2705
                        if (ditem->id == item->id)
2706
                                break;
2707
                }
2708
                if (item->id == -1)
2709
                        continue;
2710

    
2711
                icon_wid = stock_pixbuf_widget_for_toolbar(ditem->icon);
2712
                toolitem = gtk_tool_button_new(icon_wid, gettext(ditem->label));
2713
                if (ditem->description) {
2714
                        gtk_tool_item_set_tooltip(toolitem,
2715
                                                  mainwin->toolbar_tip,
2716
                                                  gettext(ditem->description),
2717
                                                  ditem->name);
2718
                }
2719

    
2720
                gtkut_get_str_size(GTK_WIDGET(toolitem), gettext(ditem->label),
2721
                                   &width, NULL);
2722
                gtk_tool_item_set_homogeneous
2723
                        (toolitem, width < 52 ? TRUE : FALSE);
2724
                gtk_tool_item_set_is_important(toolitem, item->is_important);
2725

    
2726
                gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
2727

    
2728
                g_signal_connect(G_OBJECT(toolitem), "clicked",
2729
                                 G_CALLBACK(item->callback), mainwin);
2730
                g_signal_connect(G_OBJECT(GTK_BIN(toolitem)->child),
2731
                                 "button_press_event",
2732
                                 G_CALLBACK(toolbar_button_pressed), mainwin);
2733

    
2734
                if (ditem->id == T_REPLY) {
2735
                        n_entries = sizeof(reply_entries) /
2736
                                sizeof(reply_entries[0]);
2737
                        combo = gtkut_combo_button_create
2738
                                (GTK_WIDGET(toolitem),
2739
                                 reply_entries, n_entries, "<Reply>", mainwin);
2740
                        gtk_button_set_relief(GTK_BUTTON(combo->arrow),
2741
                                              GTK_RELIEF_NONE);
2742

    
2743
                        comboitem = gtk_tool_item_new();
2744
                        gtk_tool_item_set_homogeneous(comboitem, FALSE);
2745
                        gtk_container_add(GTK_CONTAINER(comboitem),
2746
                                          GTK_WIDGET_PTR(combo));
2747
                        if (ditem->description) {
2748
                                gtk_tool_item_set_tooltip
2749
                                        (comboitem, mainwin->toolbar_tip,
2750
                                         gettext(ditem->description),
2751
                                         ditem->name);
2752
                        }
2753

    
2754
                        gtk_toolbar_insert(GTK_TOOLBAR(toolbar), comboitem, -1);
2755

    
2756
                        mainwin->reply_combo = combo;
2757
                } else if (ditem->id == T_FORWARD) {
2758
                        n_entries = sizeof(forward_entries) /
2759
                                sizeof(forward_entries[0]);
2760
                        combo = gtkut_combo_button_create
2761
                                (GTK_WIDGET(toolitem),
2762
                                 forward_entries, n_entries, "<Forward>",
2763
                                 mainwin);
2764
                        gtk_button_set_relief(GTK_BUTTON(combo->arrow),
2765
                                              GTK_RELIEF_NONE);
2766

    
2767
                        comboitem = gtk_tool_item_new();
2768
                        gtk_tool_item_set_homogeneous(comboitem, FALSE);
2769
                        gtk_container_add(GTK_CONTAINER(comboitem),
2770
                                          GTK_WIDGET_PTR(combo));
2771
                        if (ditem->description) {
2772
                                gtk_tool_item_set_tooltip
2773
                                        (comboitem, mainwin->toolbar_tip,
2774
                                         gettext(ditem->description),
2775
                                         ditem->name);
2776
                        }
2777

    
2778
                        gtk_toolbar_insert(GTK_TOOLBAR(toolbar), comboitem, -1);
2779

    
2780
                        mainwin->fwd_combo = combo;
2781
                }
2782

    
2783
                *(GtkWidget **)item->data = GTK_WIDGET(toolitem);
2784
        }
2785

    
2786
        gtk_widget_show_all(toolbar);
2787

    
2788
        return toolbar;
2789
}
2790

    
2791
static void main_window_toolbar_toggle_menu_set_active(MainWindow *mainwin,
2792
                                                       ToolbarStyle style)
2793
{
2794
        GtkWidget *menuitem = NULL;
2795
        GtkItemFactory *ifactory = mainwin->menu_factory;
2796

    
2797
        switch (style) {
2798
        case TOOLBAR_NONE:
2799
                menuitem = gtk_item_factory_get_item
2800
                        (ifactory, "/View/Show or hide/Toolbar/None");
2801
                break;
2802
        case TOOLBAR_ICON:
2803
                menuitem = gtk_item_factory_get_item
2804
                        (ifactory, "/View/Show or hide/Toolbar/Icon");
2805
                break;
2806
        case TOOLBAR_TEXT:
2807
                menuitem = gtk_item_factory_get_item
2808
                        (ifactory, "/View/Show or hide/Toolbar/Text");
2809
                break;
2810
        case TOOLBAR_BOTH:
2811
                menuitem = gtk_item_factory_get_item
2812
                        (ifactory, "/View/Show or hide/Toolbar/Icon and text");
2813
                break;
2814
        case TOOLBAR_BOTH_HORIZ:
2815
                menuitem = gtk_item_factory_get_item
2816
                        (ifactory, "/View/Show or hide/Toolbar/Text at the right of icon");
2817
                break;
2818
        }
2819

    
2820
        if (menuitem)
2821
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2822
                                               TRUE);
2823
}
2824

    
2825
/* callback functions */
2826

    
2827
static void toolbar_inc_cb        (GtkWidget        *widget,
2828
                                 gpointer         data)
2829
{
2830
        MainWindow *mainwin = (MainWindow *)data;
2831

    
2832
        inc_mail_cb(mainwin, 0, NULL);
2833
}
2834

    
2835
static void toolbar_inc_all_cb        (GtkWidget        *widget,
2836
                                 gpointer         data)
2837
{
2838
        MainWindow *mainwin = (MainWindow *)data;
2839

    
2840
        inc_all_account_mail_cb(mainwin, 0, NULL);
2841
}
2842

    
2843
static void toolbar_rpop3_cb        (GtkWidget        *widget,
2844
                                 gpointer         data)
2845
{
2846
        MainWindow *mainwin = (MainWindow *)data;
2847

    
2848
        rpop3_cb(mainwin, 0, NULL);
2849
}
2850

    
2851
static void toolbar_send_cb        (GtkWidget        *widget,
2852
                                 gpointer         data)
2853
{
2854
        MainWindow *mainwin = (MainWindow *)data;
2855

    
2856
        send_queue_cb(mainwin, 0, NULL);
2857
}
2858

    
2859
static void toolbar_compose_cb        (GtkWidget        *widget,
2860
                                 gpointer         data)
2861
{
2862
        MainWindow *mainwin = (MainWindow *)data;
2863

    
2864
        compose_cb(mainwin, 0, NULL);
2865
}
2866

    
2867
static void toolbar_reply_cb        (GtkWidget        *widget,
2868
                                 gpointer         data)
2869
{
2870
        MainWindow *mainwin = (MainWindow *)data;
2871

    
2872
        if (prefs_common.default_reply_list)
2873
                reply_cb(mainwin, COMPOSE_REPLY_TO_LIST, NULL);
2874
        else
2875
                reply_cb(mainwin, COMPOSE_REPLY, NULL);
2876
}
2877

    
2878
static void toolbar_reply_to_all_cb        (GtkWidget        *widget,
2879
                                         gpointer         data)
2880
{
2881
        MainWindow *mainwin = (MainWindow *)data;
2882

    
2883
        reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
2884
}
2885

    
2886
static void toolbar_forward_cb        (GtkWidget        *widget,
2887
                                 gpointer         data)
2888
{
2889
        MainWindow *mainwin = (MainWindow *)data;
2890

    
2891
        reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2892
}
2893

    
2894
static void toolbar_delete_cb        (GtkWidget        *widget,
2895
                                 gpointer         data)
2896
{
2897
        MainWindow *mainwin = (MainWindow *)data;
2898

    
2899
        summary_delete(mainwin->summaryview);
2900
}
2901

    
2902
static void toolbar_junk_cb        (GtkWidget        *widget,
2903
                                 gpointer         data)
2904
{
2905
        MainWindow *mainwin = (MainWindow *)data;
2906

    
2907
        summary_junk(mainwin->summaryview);
2908
}
2909

    
2910
static void toolbar_notjunk_cb        (GtkWidget        *widget,
2911
                                 gpointer         data)
2912
{
2913
        MainWindow *mainwin = (MainWindow *)data;
2914

    
2915
        summary_not_junk(mainwin->summaryview);
2916
}
2917

    
2918
static void toolbar_exec_cb        (GtkWidget        *widget,
2919
                                 gpointer         data)
2920
{
2921
        MainWindow *mainwin = (MainWindow *)data;
2922

    
2923
        summary_execute(mainwin->summaryview);
2924
}
2925

    
2926
static void toolbar_next_unread_cb        (GtkWidget        *widget,
2927
                                         gpointer         data)
2928
{
2929
        MainWindow *mainwin = (MainWindow *)data;
2930

    
2931
        next_unread_cb(mainwin, 0, NULL);
2932
}
2933

    
2934
static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data)
2935
{
2936
        MainWindow *mainwin = (MainWindow *)data;
2937

    
2938
        prev_unread_cb(mainwin, 0, NULL);
2939
}
2940

    
2941
static void toolbar_address_cb(GtkWidget *widget, gpointer data)
2942
{
2943
        MainWindow *mainwin = (MainWindow *)data;
2944

    
2945
        addressbook_open_cb(mainwin, 0, NULL);
2946
}
2947

    
2948
static void toolbar_search_cb(GtkWidget *widget, gpointer data)
2949
{
2950
        MainWindow *mainwin = (MainWindow *)data;
2951

    
2952
        search_cb(mainwin, 1, NULL);
2953
}
2954

    
2955
static void toolbar_print_cb(GtkWidget *widget, gpointer data)
2956
{
2957
        MainWindow *mainwin = (MainWindow *)data;
2958

    
2959
        print_cb(mainwin, 0, NULL);
2960
}
2961

    
2962
static void toolbar_stop_cb(GtkWidget *widget, gpointer data)
2963
{
2964
        MainWindow *mainwin = (MainWindow *)data;
2965

    
2966
        inc_stop_cb(mainwin, 0, NULL);
2967
}
2968

    
2969
static void toolbar_prefs_common_cb(GtkWidget *widget, gpointer data)
2970
{
2971
        MainWindow *mainwin = (MainWindow *)data;
2972

    
2973
        prefs_common_open_cb(mainwin, 0, NULL);
2974
}
2975

    
2976
static void toolbar_prefs_account_cb(GtkWidget *widget, gpointer data)
2977
{
2978
        MainWindow *mainwin = (MainWindow *)data;
2979

    
2980
        prefs_account_open_cb(mainwin, 0, NULL);
2981
}
2982

    
2983
static void toolbar_toggle(GtkWidget *widget, gpointer data)
2984
{
2985
        MainWindow *mainwin = (MainWindow *)data;
2986
        ToolbarStyle style;
2987

    
2988
        if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)))
2989
                return;
2990

    
2991
        style = (ToolbarStyle)g_object_get_data(G_OBJECT(widget), MENU_VAL_ID);
2992
        main_window_toolbar_toggle_menu_set_active(mainwin, style);
2993
}
2994

    
2995
static void toolbar_customize(GtkWidget *widget, gpointer data)
2996
{
2997
        MainWindow *mainwin = (MainWindow *)data;
2998
        gint *visible_items;
2999
        GList *item_list = NULL;
3000
        GtkWidget *toolbar;
3001
        gint ret;
3002
        const gchar *setting;
3003

    
3004
        if (prefs_common.main_toolbar_setting &&
3005
            *prefs_common.main_toolbar_setting != '\0')
3006
                setting = prefs_common.main_toolbar_setting;
3007
        else
3008
                setting = prefs_toolbar_get_default_main_setting_name_list();
3009
        visible_items = prefs_toolbar_get_id_list_from_name_list(setting);
3010
        ret = prefs_toolbar_open(TOOLBAR_MAIN, visible_items, &item_list);
3011
        g_free(visible_items);
3012

    
3013
        if (ret == 0) {
3014
                gtk_widget_destroy(mainwin->toolbar);
3015
                toolbar = main_window_toolbar_create_from_list(mainwin,
3016
                                                               item_list);
3017
                gtk_widget_set_size_request(toolbar, 300, -1);
3018
                gtk_box_pack_start(GTK_BOX(mainwin->vbox), toolbar,
3019
                                   FALSE, FALSE, 0);
3020
                gtk_box_reorder_child(GTK_BOX(mainwin->vbox), toolbar, 1);
3021
                mainwin->toolbar = toolbar;
3022
                main_window_set_toolbar_sensitive(mainwin);
3023
                main_window_set_toolbar_button_visibility(mainwin);
3024
                g_free(prefs_common.main_toolbar_setting);
3025
                prefs_common.main_toolbar_setting =
3026
                        prefs_toolbar_get_name_list_from_item_list(item_list);
3027
                g_list_free(item_list);
3028
                prefs_common_write_config();
3029
        }
3030
}
3031

    
3032
static gboolean toolbar_button_pressed(GtkWidget *widget, GdkEventButton *event,
3033
                                       gpointer data)
3034
{
3035
        MainWindow *mainwin = (MainWindow *)data;
3036
        GtkWidget *menu;
3037
        GtkWidget *menuitem;
3038

    
3039
        if (!event) return FALSE;
3040
        if (event->button != 3) return FALSE;
3041

    
3042
        menu = gtk_menu_new();
3043
        gtk_widget_show(menu);
3044

    
3045
#define SET_TOOLBAR_MENU(text, style, widget)                                \
3046
{                                                                        \
3047
        MENUITEM_ADD_RADIO(menu, menuitem, widget, text, style);        \
3048
        if (prefs_common.toolbar_style == style)                        \
3049
                gtk_check_menu_item_set_active                                \
3050
                        (GTK_CHECK_MENU_ITEM(menuitem), TRUE);                \
3051
        g_signal_connect(G_OBJECT(menuitem), "activate",                \
3052
                         G_CALLBACK(toolbar_toggle), mainwin);                \
3053
}
3054

    
3055
        SET_TOOLBAR_MENU(_("Icon _and text"), TOOLBAR_BOTH, NULL);
3056
        SET_TOOLBAR_MENU(_("Text at the _right of icon"), TOOLBAR_BOTH_HORIZ,
3057
                         menuitem);
3058
        SET_TOOLBAR_MENU(_("_Icon"), TOOLBAR_ICON, menuitem);
3059
        SET_TOOLBAR_MENU(_("_Text"), TOOLBAR_TEXT, menuitem);
3060
        SET_TOOLBAR_MENU(_("_None"), TOOLBAR_NONE, menuitem);
3061
        MENUITEM_ADD(menu, menuitem, NULL, NULL);
3062
        MENUITEM_ADD_WITH_MNEMONIC(menu, menuitem, _("_Customize toolbar..."),
3063
                                   0);
3064
        g_signal_connect(G_OBJECT(menuitem), "activate",
3065
                         G_CALLBACK(toolbar_customize), mainwin);
3066

    
3067
        g_signal_connect(G_OBJECT(menu), "selection_done",
3068
                         G_CALLBACK(gtk_widget_destroy), NULL);
3069

    
3070
        gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
3071
                       event->button, event->time);
3072

    
3073
        return TRUE;
3074
}
3075

    
3076
static void online_switch_clicked(GtkWidget *widget, gpointer data)
3077
{
3078
        MainWindow *mainwin = (MainWindow *)data;
3079
        GtkWidget *menuitem;
3080

    
3081
        debug_print("Toggle online mode: %d -> %d\n", prefs_common.online_mode,
3082
                    !prefs_common.online_mode);
3083

    
3084
        menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
3085
                                             "/File/Work offline");
3086

    
3087
        if (prefs_common.online_mode == TRUE) {
3088
                if (folder_remote_folder_active_session_exist()) {
3089
                        debug_print("Active session exist. Cancelling online switch.\n");
3090
                        return;
3091
                }
3092

    
3093
                prefs_common.online_mode = FALSE;
3094
                gtk_widget_hide(mainwin->online_pixmap);
3095
                gtk_widget_show(mainwin->offline_pixmap);
3096
                gtk_tooltips_set_tip
3097
                        (mainwin->online_tip, mainwin->online_switch,
3098
                         _("You are offline. Click the icon to go online."),
3099
                         NULL);
3100
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
3101
                                               TRUE);
3102
                inc_autocheck_timer_remove();
3103
                folder_remote_folder_destroy_all_sessions();
3104
        } else {
3105
                prefs_common.online_mode = TRUE;
3106
                gtk_widget_hide(mainwin->offline_pixmap);
3107
                gtk_widget_show(mainwin->online_pixmap);
3108
                gtk_tooltips_set_tip
3109
                        (mainwin->online_tip, mainwin->online_switch,
3110
                         _("You are online. Click the icon to go offline."),
3111
                         NULL);
3112
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
3113
                                               FALSE);
3114
                inc_autocheck_timer_set();
3115
        }
3116
}
3117

    
3118
static gboolean ac_label_button_pressed(GtkWidget *widget,
3119
                                        GdkEventButton *event, gpointer data)
3120
{
3121
        MainWindow *mainwin = (MainWindow *)data;
3122

    
3123
        if (!event) return FALSE;
3124

    
3125
        gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
3126
        g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", widget);
3127

    
3128
        gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
3129
                       menu_button_position, widget,
3130
                       event->button, event->time);
3131

    
3132
        return TRUE;
3133
}
3134

    
3135
static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
3136
{
3137
        MainWindow *mainwin = (MainWindow *)data;
3138
        GtkWidget *button;
3139

    
3140
        button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
3141
        if (!button) return;
3142
        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
3143
        g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
3144
        manage_window_focus_in(mainwin->window, NULL, NULL);
3145
}
3146

    
3147
static gboolean main_window_key_pressed(GtkWidget *widget, GdkEventKey *event,
3148
                                        gpointer data)
3149
{
3150
        MainWindow *mainwin = (MainWindow *)data;
3151

    
3152
        if (!mainwin)
3153
                return FALSE;
3154

    
3155
        if (!GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->qsearch->entry))
3156
                return FALSE;
3157

    
3158
        /* g_print("keyval: %d, state: %d\n", event->keyval, event->state); */
3159
        if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0)
3160
                return FALSE;
3161
        if (event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab ||
3162
            event->keyval == GDK_ISO_Left_Tab)
3163
                return FALSE;
3164

    
3165
        gtk_window_propagate_key_event(GTK_WINDOW(widget), event);
3166

    
3167
        return TRUE;
3168
}
3169

    
3170
static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3171
                                 gpointer data)
3172
{
3173
        MainWindow *mainwin = (MainWindow *)data;
3174

    
3175
        if (mainwin->lock_count == 0)
3176
                app_exit_cb(data, 0, widget);
3177

    
3178
        return TRUE;
3179
}
3180

    
3181
static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3182
                                   gpointer data)
3183
{
3184
        MainWindow *mainwin = (MainWindow *)data;
3185
        GtkWidget *menuitem;
3186

    
3187
        menuitem = gtk_item_factory_get_item
3188
                (mainwin->menu_factory, "/View/Show or hide/Folder tree");
3189
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
3190

    
3191
        return TRUE;
3192
}
3193

    
3194
static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3195
                                    gpointer data)
3196
{
3197
        MainWindow *mainwin = (MainWindow *)data;
3198
        GtkWidget *menuitem;
3199

    
3200
        menuitem = gtk_item_factory_get_item
3201
                (mainwin->menu_factory, "/View/Show or hide/Message view");
3202
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
3203

    
3204
        return TRUE;
3205
}
3206

    
3207
static void main_window_size_allocate_cb(GtkWidget *widget,
3208
                                         GtkAllocation *allocation,
3209
                                         gpointer data)
3210
{
3211
        MainWindow *mainwin = (MainWindow *)data;
3212

    
3213
        main_window_get_size(mainwin);
3214
}
3215

    
3216
static void folder_window_size_allocate_cb(GtkWidget *widget,
3217
                                           GtkAllocation *allocation,
3218
                                           gpointer data)
3219
{
3220
        MainWindow *mainwin = (MainWindow *)data;
3221

    
3222
        main_window_get_size(mainwin);
3223
}
3224

    
3225
static void message_window_size_allocate_cb(GtkWidget *widget,
3226
                                            GtkAllocation *allocation,
3227
                                            gpointer data)
3228
{
3229
        MainWindow *mainwin = (MainWindow *)data;
3230

    
3231
        main_window_get_size(mainwin);
3232
}
3233

    
3234
static gboolean main_window_window_state_cb(GtkWidget *widget,
3235
                                            GdkEventWindowState *event,
3236
                                            gpointer data)
3237
{
3238
        MainWindow *mainwin = (MainWindow *)data;
3239

    
3240
        if ((event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) != 0) {
3241
                if ((event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
3242
                        prefs_common.mainwin_maximized = TRUE;
3243
                else
3244
                        prefs_common.mainwin_maximized = FALSE;
3245
        }
3246
        if ((event->changed_mask & GDK_WINDOW_STATE_ICONIFIED) != 0) {
3247
                if ((event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) != 0)
3248
                        mainwin->window_hidden = TRUE;
3249
                else
3250
                        mainwin->window_hidden = FALSE;
3251
        }
3252
        if ((event->changed_mask & GDK_WINDOW_STATE_WITHDRAWN) != 0) {
3253
                if ((event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) != 0)
3254
                        mainwin->window_hidden = TRUE;
3255
                else
3256
                        mainwin->window_hidden = FALSE;
3257
        }
3258

    
3259
        if (mainwin->window_hidden &&
3260
            prefs_common.show_trayicon && prefs_common.minimize_to_tray)
3261
                gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), TRUE);
3262
        else if (!mainwin->window_hidden)
3263
                gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
3264

    
3265
        return FALSE;
3266
}
3267

    
3268
static gboolean main_window_visibility_notify_cb(GtkWidget *widget,
3269
                                                 GdkEventVisibility *event,
3270
                                                 gpointer data)
3271
{
3272
        MainWindow *mainwin = (MainWindow *)data;
3273

    
3274
        mainwin->window_obscured =
3275
                (event->state == GDK_VISIBILITY_FULLY_OBSCURED ||
3276
                 event->state == GDK_VISIBILITY_PARTIAL) ? TRUE : FALSE;
3277

    
3278
        return FALSE;
3279
}
3280

    
3281
static void new_folder_cb(MainWindow *mainwin, guint action,
3282
                          GtkWidget *widget)
3283
{
3284
        folderview_new_folder(mainwin->folderview);
3285
}
3286

    
3287
static void rename_folder_cb(MainWindow *mainwin, guint action,
3288
                             GtkWidget *widget)
3289
{
3290
        folderview_rename_folder(mainwin->folderview);
3291
}
3292

    
3293
static void move_folder_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3294
{
3295
        folderview_move_folder(mainwin->folderview);
3296
}
3297

    
3298
static void delete_folder_cb(MainWindow *mainwin, guint action,
3299
                             GtkWidget *widget)
3300
{
3301
        folderview_delete_folder(mainwin->folderview);
3302
}
3303

    
3304
static void add_mailbox_cb(MainWindow *mainwin, guint action,
3305
                           GtkWidget *widget)
3306
{
3307
        main_window_add_mailbox(mainwin);
3308
}
3309

    
3310
static void remove_mailbox_cb(MainWindow *mainwin, guint action,
3311
                              GtkWidget *widget)
3312
{
3313
        folderview_remove_mailbox(mainwin->folderview);
3314
}
3315

    
3316
static void update_folderview_cb(MainWindow *mainwin, guint action,
3317
                                 GtkWidget *widget)
3318
{
3319
        if (action == 0)
3320
                folderview_check_new_selected(mainwin->folderview);
3321
        else
3322
                folderview_check_new_all();
3323
}
3324

    
3325
static void rebuild_tree_cb(MainWindow *mainwin, guint action,
3326
                            GtkWidget *widget)
3327
{
3328
        folderview_rebuild_tree(mainwin->folderview);
3329
}
3330

    
3331
static void import_mail_cb(MainWindow *mainwin, guint action,
3332
                           GtkWidget *widget)
3333
{
3334
        import_mail(mainwin->summaryview->folder_item);
3335
        main_window_popup(mainwin);
3336
}
3337

    
3338
static void export_mail_cb(MainWindow *mainwin, guint action,
3339
                           GtkWidget *widget)
3340
{
3341
        export_mail(mainwin->summaryview->folder_item);
3342
        main_window_popup(mainwin);
3343
}
3344

    
3345
static void empty_trash_cb(MainWindow *mainwin, guint action,
3346
                           GtkWidget *widget)
3347
{
3348
        main_window_empty_trash(mainwin, TRUE);
3349
}
3350

    
3351
static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3352
{
3353
        MessageView *messageview = mainwin->messageview;
3354

    
3355
        if (messageview_get_selected_mime_part(messageview) &&
3356
            GTK_WIDGET_HAS_FOCUS(messageview->mimeview->treeview))
3357
                mimeview_save_as(messageview->mimeview);
3358
        else
3359
                summary_save_as(mainwin->summaryview);
3360
}
3361

    
3362
#if GTK_CHECK_VERSION(2, 10, 0)
3363
static void page_setup_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3364
{
3365
        printing_page_setup_gtk();
3366
}
3367
#endif
3368

    
3369
static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3370
{
3371
        summary_print(mainwin->summaryview);
3372
}
3373

    
3374
static void toggle_offline_cb(MainWindow *mainwin, guint action,
3375
                              GtkWidget *widget)
3376
{
3377
        if (GTK_CHECK_MENU_ITEM(widget)->active &&
3378
            folder_remote_folder_active_session_exist()) {
3379
                debug_print("Active session exist. Cancelling online switch.\n");
3380
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget),
3381
                                               FALSE);
3382
                return;
3383
        }
3384

    
3385
        main_window_toggle_online
3386
                (mainwin, !GTK_CHECK_MENU_ITEM(widget)->active);
3387
}
3388

    
3389
static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3390
{
3391
        if (prefs_common.confirm_on_exit) {
3392
                if (alertpanel(_("Exit"), _("Exit this program?"),
3393
                               GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
3394
                    != G_ALERTDEFAULT)
3395
                        return;
3396
                manage_window_focus_in(mainwin->window, NULL, NULL);
3397
        }
3398

    
3399
        app_will_exit(FALSE);
3400
}
3401

    
3402
static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3403
{
3404
        if (action == 1) {
3405
                FolderItem *item;
3406

    
3407
                item = folderview_get_selected_item(mainwin->folderview);
3408
                if (item && item->stype == F_VIRTUAL)
3409
                        prefs_search_folder_open(item);
3410
                else
3411
                        query_search(item);
3412
        } else if (action == 2) {
3413
                if (!prefs_common.show_searchbar) {
3414
                        GtkWidget *menuitem;
3415

    
3416
                        menuitem = gtk_item_factory_get_item
3417
                                (mainwin->menu_factory,
3418
                                 "/View/Show or hide/Search bar");
3419
                        gtk_check_menu_item_set_active
3420
                                (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
3421
                }
3422
                gtk_widget_grab_focus(mainwin->summaryview->qsearch->entry);
3423
        } else
3424
                message_search(mainwin->messageview);
3425
}
3426

    
3427
static void toggle_folder_cb(MainWindow *mainwin, guint action,
3428
                             GtkWidget *widget)
3429
{
3430
        gboolean active;
3431

    
3432
        active = GTK_CHECK_MENU_ITEM(widget)->active;
3433

    
3434
        switch (mainwin->type) {
3435
        case SEPARATE_NONE:
3436
        case SEPARATE_MESSAGE:
3437
#if 0
3438
                if (active)
3439
                        gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
3440
                else
3441
                        gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
3442
#endif
3443
                break;
3444
        case SEPARATE_FOLDER:
3445
                if (active)
3446
                        gtk_widget_show(mainwin->win.sep_folder.folderwin);
3447
                else
3448
                        gtk_widget_hide(mainwin->win.sep_folder.folderwin);
3449
                break;
3450
        case SEPARATE_BOTH:
3451
                if (active)
3452
                        gtk_widget_show(mainwin->win.sep_both.folderwin);
3453
                else
3454
                        gtk_widget_hide(mainwin->win.sep_both.folderwin);
3455
                break;
3456
        }
3457

    
3458
        prefs_common.folderview_visible = active;
3459
}
3460

    
3461
static void toggle_message_cb(MainWindow *mainwin, guint action,
3462
                              GtkWidget *widget)
3463
{
3464
        gboolean active;
3465

    
3466
        active = GTK_CHECK_MENU_ITEM(widget)->active;
3467

    
3468
        if (active != messageview_is_visible(mainwin->messageview))
3469
                summary_toggle_view(mainwin->summaryview);
3470
}
3471

    
3472
static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3473
                              GtkWidget *widget)
3474
{
3475
        mainwin->toolbar_style = (ToolbarStyle)action;
3476
        prefs_common.toolbar_style = (ToolbarStyle)action;
3477

    
3478
        main_window_set_toolbar_button_visibility(mainwin);
3479
}
3480

    
3481
static void toggle_searchbar_cb(MainWindow *mainwin, guint action,
3482
                                GtkWidget *widget)
3483
{
3484
        if (GTK_CHECK_MENU_ITEM(widget)->active) {
3485
                gtk_widget_show(mainwin->summaryview->qsearch->hbox);
3486
                prefs_common.show_searchbar = TRUE;
3487
        } else {
3488
                gtk_widget_hide(mainwin->summaryview->qsearch->hbox);
3489
                summary_qsearch_reset(mainwin->summaryview);
3490
                prefs_common.show_searchbar = FALSE;
3491
        }
3492
}
3493

    
3494
static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3495
                                GtkWidget *widget)
3496
{
3497
        if (GTK_CHECK_MENU_ITEM(widget)->active) {
3498
                gtk_widget_show(mainwin->statusbar);
3499
                prefs_common.show_statusbar = TRUE;
3500
        } else {
3501
                gtk_widget_hide(mainwin->statusbar);
3502
                prefs_common.show_statusbar = FALSE;
3503
        }
3504
}
3505

    
3506
static void toolbar_customize_cb(MainWindow *mainwin, guint action,
3507
                                 GtkWidget *widget)
3508
{
3509
        toolbar_customize(widget, mainwin);
3510
}
3511

    
3512
static void change_layout_cb(MainWindow *mainwin, guint action,
3513
                             GtkWidget *widget)
3514
{
3515
        LayoutType type = action;
3516

    
3517
        if (GTK_CHECK_MENU_ITEM(widget)->active)
3518
                main_window_change_layout(mainwin, type, mainwin->type);
3519
}
3520

    
3521
static void separate_widget_cb(MainWindow *mainwin, guint action,
3522
                               GtkWidget *widget)
3523
{
3524
        SeparateType type;
3525

    
3526
        if (GTK_CHECK_MENU_ITEM(widget)->active)
3527
                type = mainwin->type | action;
3528
        else
3529
                type = mainwin->type & ~action;
3530

    
3531
        main_window_change_layout(mainwin, prefs_common.layout_type, type);
3532

    
3533
        prefs_common.sep_folder = (type & SEPARATE_FOLDER)  != 0;
3534
        prefs_common.sep_msg    = (type & SEPARATE_MESSAGE) != 0;
3535
}
3536

    
3537
static void addressbook_open_cb(MainWindow *mainwin, guint action,
3538
                                GtkWidget *widget)
3539
{
3540
        addressbook_open(NULL);
3541
}
3542

    
3543
static void log_window_show_cb(MainWindow *mainwin, guint action,
3544
                               GtkWidget *widget)
3545
{
3546
        log_window_show(mainwin->logwin);
3547
}
3548

    
3549
static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3550
{
3551
        inc_mail(mainwin);
3552
}
3553

    
3554
static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
3555
                                    GtkWidget *widget)
3556
{
3557
        inc_all_account_mail(mainwin, FALSE);
3558
}
3559

    
3560
static void inc_stop_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3561
{
3562
        inc_cancel_all();
3563
}
3564

    
3565
static void rpop3_cb(MainWindow        *mainwin, guint action, GtkWidget *widget)
3566
{
3567
        rpop3_account(cur_account);
3568
}
3569

    
3570
static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3571
{
3572
        main_window_send_queue(mainwin);
3573
}
3574

    
3575
static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3576
{
3577
        PrefsAccount *ac = NULL;
3578
        FolderItem *item = mainwin->summaryview->folder_item;
3579

    
3580
        if (item) {
3581
                ac = account_find_from_item(item);
3582
                if (ac && ac->protocol == A_NNTP &&
3583
                    FOLDER_TYPE(item->folder) == F_NEWS) {
3584
                        compose_new(ac, item, item->path, NULL);
3585
                        return;
3586
                }
3587
        }
3588

    
3589
        compose_new(ac, item, NULL, NULL);
3590
}
3591

    
3592
static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3593
{
3594
        summary_reply(mainwin->summaryview, (ComposeMode)action);
3595
}
3596

    
3597
static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3598
{
3599
        summary_move_to(mainwin->summaryview);
3600
}
3601

    
3602
static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3603
{
3604
        summary_copy_to(mainwin->summaryview);
3605
}
3606

    
3607
static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3608
{
3609
        summary_delete(mainwin->summaryview);
3610
}
3611

    
3612
static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3613
{
3614
        summary_open_msg(mainwin->summaryview);
3615
}
3616

    
3617
static void view_source_cb(MainWindow *mainwin, guint action,
3618
                           GtkWidget *widget)
3619
{
3620
        summary_view_source(mainwin->summaryview);
3621
}
3622

    
3623
static void show_all_header_cb(MainWindow *mainwin, guint action,
3624
                               GtkWidget *widget)
3625
{
3626
        if (mainwin->menu_lock_count) return;
3627
        summary_display_msg_selected(mainwin->summaryview, FALSE,
3628
                                     GTK_CHECK_MENU_ITEM(widget)->active);
3629
}
3630

    
3631
static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3632
{
3633
        summary_mark(mainwin->summaryview);
3634
}
3635

    
3636
static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3637
{
3638
        summary_unmark(mainwin->summaryview);
3639
}
3640

    
3641
static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3642
                              GtkWidget *widget)
3643
{
3644
        summary_mark_as_unread(mainwin->summaryview);
3645
}
3646

    
3647
static void mark_as_read_cb(MainWindow *mainwin, guint action,
3648
                            GtkWidget *widget)
3649
{
3650
        summary_mark_as_read(mainwin->summaryview);
3651
}
3652

    
3653
static void mark_thread_as_read_cb(MainWindow *mainwin, guint action,
3654
                                   GtkWidget *widget)
3655
{
3656
        summary_mark_thread_as_read(mainwin->summaryview);
3657
}
3658

    
3659
static void mark_all_read_cb(MainWindow *mainwin, guint action,
3660
                             GtkWidget *widget)
3661
{
3662
        summary_mark_all_read(mainwin->summaryview);
3663
}
3664

    
3665
static void junk_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3666
{
3667
        if (action == 0)
3668
                summary_junk(mainwin->summaryview);
3669
        else
3670
                summary_not_junk(mainwin->summaryview);
3671
}
3672

    
3673
static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3674
{
3675
        summary_reedit(mainwin->summaryview);
3676
}
3677

    
3678
static void add_address_cb(MainWindow *mainwin, guint action,
3679
                           GtkWidget *widget)
3680
{
3681
        summary_add_address(mainwin->summaryview);
3682
}
3683

    
3684
static void set_charset_cb(MainWindow *mainwin, guint action,
3685
                           GtkWidget *widget)
3686
{
3687
        const gchar *str;
3688

    
3689
        if (GTK_CHECK_MENU_ITEM(widget)->active) {
3690
                str = conv_get_charset_str((CharSet)action);
3691
                g_free(prefs_common.force_charset);
3692
                prefs_common.force_charset = str ? g_strdup(str) : NULL;
3693

    
3694
                summary_redisplay_msg(mainwin->summaryview);
3695

    
3696
                debug_print("forced charset: %s\n",
3697
                            str ? str : "Auto-Detect");
3698
        }
3699
}
3700

    
3701
static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3702
{
3703
        if (mainwin->menu_lock_count) return;
3704
        if (!mainwin->summaryview->folder_item) return;
3705

    
3706
        if (GTK_CHECK_MENU_ITEM(widget)->active)
3707
                summary_thread_build(mainwin->summaryview);
3708
        else
3709
                summary_unthread(mainwin->summaryview);
3710
}
3711

    
3712
static void expand_threads_cb(MainWindow *mainwin, guint action,
3713
                              GtkWidget *widget)
3714
{
3715
        summary_expand_threads(mainwin->summaryview);
3716
}
3717

    
3718
static void collapse_threads_cb(MainWindow *mainwin, guint action,
3719
                                GtkWidget *widget)
3720
{
3721
        summary_collapse_threads(mainwin->summaryview);
3722
}
3723

    
3724
static void set_display_item_cb(MainWindow *mainwin, guint action,
3725
                                GtkWidget *widget)
3726
{
3727
        prefs_summary_column_open
3728
                (FOLDER_ITEM_IS_SENT_FOLDER(mainwin->summaryview->folder_item));
3729
}
3730

    
3731
static void sort_summary_cb(MainWindow *mainwin, guint action,
3732
                            GtkWidget *widget)
3733
{
3734
        FolderItem *item = mainwin->summaryview->folder_item;
3735
        GtkWidget *menuitem;
3736

    
3737
        if (mainwin->menu_lock_count) return;
3738

    
3739
        if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3740
                menuitem = gtk_item_factory_get_item
3741
                        (mainwin->menu_factory, "/View/Sort/Ascending");
3742
                summary_sort(mainwin->summaryview, (FolderSortKey)action,
3743
                             GTK_CHECK_MENU_ITEM(menuitem)->active
3744
                             ? SORT_ASCENDING : SORT_DESCENDING);
3745
        }
3746
}
3747

    
3748
static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3749
                                 GtkWidget *widget)
3750
{
3751
        FolderItem *item = mainwin->summaryview->folder_item;
3752

    
3753
        if (mainwin->menu_lock_count) return;
3754

    
3755
        if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3756
                summary_sort(mainwin->summaryview,
3757
                             item->sort_key, (FolderSortType)action);
3758
}
3759

    
3760
static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3761
                                  GtkWidget *widget)
3762
{
3763
        summary_attract_by_subject(mainwin->summaryview);
3764
}
3765

    
3766
static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3767
                                 GtkWidget *widget)
3768
{
3769
        summary_delete_duplicated(mainwin->summaryview);
3770
}
3771

    
3772
static void concat_partial_cb(MainWindow *mainwin, guint action,
3773
                              GtkWidget *widget)
3774
{
3775
        GSList *mlist;
3776
        gchar *file;
3777
        FolderItem *item;
3778

    
3779
        if (summary_is_locked(mainwin->summaryview))
3780
                return;
3781

    
3782
        item = mainwin->summaryview->folder_item;
3783
        if (!item)
3784
                return;
3785
        mlist = summary_get_selected_msg_list(mainwin->summaryview);
3786
        if (!mlist)
3787
                return;
3788

    
3789
        file = get_tmp_file();
3790
        if (procmsg_concat_partial_messages(mlist, file) == 0) {
3791
                folder_item_add_msg(item, file, NULL, TRUE);
3792
                summary_show_queued_msgs(mainwin->summaryview);
3793
        } else {
3794
                alertpanel_error
3795
                        (_("The selected messages could not be combined."));
3796
        }
3797
        g_free(file);
3798

    
3799
        g_slist_free(mlist);
3800
}
3801

    
3802
static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3803
{
3804
        summary_filter(mainwin->summaryview, (gboolean)action);
3805
}
3806

    
3807
static void filter_junk_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3808
{
3809
        summary_filter_junk(mainwin->summaryview, (gboolean)action);
3810
}
3811

    
3812
static void execute_summary_cb(MainWindow *mainwin, guint action,
3813
                               GtkWidget *widget)
3814
{
3815
        summary_execute(mainwin->summaryview);
3816
}
3817

    
3818
static void update_summary_cb(MainWindow *mainwin, guint action,
3819
                              GtkWidget *widget)
3820
{
3821
        if (!mainwin->summaryview->folder_item) return;
3822

    
3823
        summary_show(mainwin->summaryview, mainwin->summaryview->folder_item,
3824
                     TRUE);
3825
}
3826

    
3827
static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3828
{
3829
        MessageView *messageview = mainwin->messageview;
3830

    
3831
        if (messageview_get_selected_mime_part(messageview) &&
3832
            GTK_WIDGET_HAS_FOCUS(messageview->mimeview->treeview) &&
3833
            mimeview_step(messageview->mimeview, GTK_SCROLL_STEP_BACKWARD))
3834
                return;
3835

    
3836
        if (summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD))
3837
                summary_mark_displayed_read(mainwin->summaryview, NULL);
3838
}
3839

    
3840
static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3841
{
3842
        MessageView *messageview = mainwin->messageview;
3843

    
3844
        if (messageview_get_selected_mime_part(messageview) &&
3845
            GTK_WIDGET_HAS_FOCUS(messageview->mimeview->treeview) &&
3846
            mimeview_step(messageview->mimeview, GTK_SCROLL_STEP_FORWARD))
3847
                return;
3848

    
3849
        if (summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD))
3850
                summary_mark_displayed_read(mainwin->summaryview, NULL);
3851
}
3852

    
3853
static void prev_unread_cb(MainWindow *mainwin, guint action,
3854
                           GtkWidget *widget)
3855
{
3856
        summary_select_prev_unread(mainwin->summaryview);
3857
}
3858

    
3859
static void next_unread_cb(MainWindow *mainwin, guint action,
3860
                           GtkWidget *widget)
3861
{
3862
        summary_select_next_unread(mainwin->summaryview);
3863
}
3864

    
3865
static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3866
{
3867
        summary_select_prev_new(mainwin->summaryview);
3868
}
3869

    
3870
static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3871
{
3872
        summary_select_next_new(mainwin->summaryview);
3873
}
3874

    
3875
static void prev_marked_cb(MainWindow *mainwin, guint action,
3876
                           GtkWidget *widget)
3877
{
3878
        summary_select_prev_marked(mainwin->summaryview);
3879
}
3880

    
3881
static void next_marked_cb(MainWindow *mainwin, guint action,
3882
                           GtkWidget *widget)
3883
{
3884
        summary_select_next_marked(mainwin->summaryview);
3885
}
3886

    
3887
static void prev_labeled_cb(MainWindow *mainwin, guint action,
3888
                            GtkWidget *widget)
3889
{
3890
        summary_select_prev_labeled(mainwin->summaryview);
3891
}
3892

    
3893
static void next_labeled_cb(MainWindow *mainwin, guint action,
3894
                            GtkWidget *widget)
3895
{
3896
        summary_select_next_labeled(mainwin->summaryview);
3897
}
3898

    
3899
static void goto_folder_cb(MainWindow *mainwin, guint action,
3900
                           GtkWidget *widget)
3901
{
3902
        FolderItem *to_folder;
3903

    
3904
        to_folder = foldersel_folder_sel_full(NULL, FOLDER_SEL_ALL, NULL,
3905
                                              _("Select folder to open"));
3906

    
3907
        if (to_folder)
3908
                folderview_select(mainwin->folderview, to_folder);
3909
}
3910

    
3911
static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3912
{
3913
        messageview_copy_clipboard(mainwin->messageview);
3914
}
3915

    
3916
static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3917
{
3918
        MessageView *msgview = mainwin->messageview;
3919

    
3920
        if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->treeview))
3921
                summary_select_all(mainwin->summaryview);
3922
        else if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->qsearch->entry))
3923
                gtk_editable_select_region
3924
                        (GTK_EDITABLE(mainwin->summaryview->qsearch->entry),
3925
                         0, -1);
3926
        else if (messageview_is_visible(msgview) &&
3927
                 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3928
                  GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3929
                messageview_select_all(msgview);
3930
}
3931

    
3932
static void select_thread_cb(MainWindow *mainwin, guint action,
3933
                             GtkWidget *widget)
3934
{
3935
        summary_select_thread(mainwin->summaryview);
3936
}
3937

    
3938
static void create_filter_cb(MainWindow *mainwin, guint action,
3939
                             GtkWidget *widget)
3940
{
3941
        summary_filter_open(mainwin->summaryview, (FilterCreateType)action);
3942
}
3943

    
3944
static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3945
                                 GtkWidget *widget)
3946
{
3947
        prefs_common_open();
3948
}
3949

    
3950
static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3951
                                 GtkWidget *widget)
3952
{
3953
        prefs_filter_open(NULL, NULL, NULL);
3954
}
3955

    
3956
static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3957
                                   GtkWidget *widget)
3958
{
3959
        prefs_template_open();
3960
}
3961

    
3962
static void plugin_manager_open_cb(MainWindow *mainwin, guint action,
3963
                                   GtkWidget *widget)
3964
{
3965
        plugin_manager_open();
3966
}
3967

    
3968
#ifndef G_OS_WIN32
3969
static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3970
                                  GtkWidget *widget)
3971
{
3972
        prefs_actions_open(mainwin);
3973
}
3974
#endif
3975

    
3976
static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3977
                                  GtkWidget *widget)
3978
{
3979
        if (!cur_account) {
3980
                new_account_cb(mainwin, 0, widget);
3981
        } else {
3982
                account_open(cur_account);
3983
        }
3984
}
3985

    
3986
static void new_account_cb(MainWindow *mainwin, guint action,
3987
                           GtkWidget *widget)
3988
{
3989
        PrefsAccount *ac;
3990

    
3991
        if (compose_get_compose_list()) {
3992
                alertpanel_notice(_("Some composing windows are open.\n"
3993
                                    "Please close all the composing windows before editing the accounts."));
3994
                return;
3995
        }
3996

    
3997
        if ((ac = setup_account())) {
3998
                account_set_menu();
3999
                main_window_reflect_prefs_all();
4000
                account_set_missing_folder();
4001
                folderview_set(mainwin->folderview);
4002
                if (ac->folder)
4003
                        folder_write_list();
4004
        }
4005
}
4006

    
4007
static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
4008
{
4009
        cur_account = (PrefsAccount *)data;
4010
        main_window_change_cur_account();
4011
}
4012

    
4013
static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
4014
{
4015
        PrefsAccount *account = (PrefsAccount *)data;
4016

    
4017
        inc_account_mail(main_window_get(), account);
4018
}
4019

    
4020
static void manual_open_cb(MainWindow *mainwin, guint action,
4021
                           GtkWidget *widget)
4022
{
4023
        manual_open((ManualLang)action);
4024
}
4025

    
4026
static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4027
{
4028
        faq_open((ManualLang)action);
4029
}
4030

    
4031
static GtkWidget *help_cmdline_window;
4032

    
4033
static void help_cmdline_ok(GtkWidget *button)
4034
{
4035
        gtk_widget_destroy(gtk_widget_get_toplevel(button));
4036
}
4037

    
4038
static gboolean help_cmdline_key_pressed(GtkWidget *widget, GdkEventKey *event,
4039
                                         gpointer data)
4040
{
4041
        if (event && event->keyval == GDK_Escape) {
4042
                gtk_widget_destroy(widget);
4043
                return TRUE;
4044
        }
4045
        return FALSE;
4046
}
4047

    
4048
static gboolean help_cmdline_deleted(GtkWidget *widget, GdkEventAny *event,
4049
                                     gpointer data)
4050
{
4051
        return FALSE;
4052
}
4053

    
4054
static void help_cmdline_destroyed(GtkWidget *widget, gpointer data)
4055
{
4056
        help_cmdline_window = NULL;
4057
}
4058

    
4059
static void help_command_line_show(void)
4060
{
4061
        GtkWidget *window;
4062
        GtkWidget *vbox;
4063
        GtkWidget *vbox2;
4064
        GtkWidget *hbox;
4065
        GtkWidget *label;
4066
        GtkWidget *hbbox;
4067
        GtkWidget *ok_btn;
4068

    
4069
        if (help_cmdline_window) {
4070
                gtk_window_present(GTK_WINDOW(help_cmdline_window));
4071
                return;
4072
        }
4073

    
4074
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
4075
        gtk_window_set_title(GTK_WINDOW(window), _("Command line options"));
4076
        gtk_container_set_border_width(GTK_CONTAINER(window), 8);
4077
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
4078
        gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
4079
        help_cmdline_window = window;
4080

    
4081
        vbox = gtk_vbox_new(FALSE, 8);
4082
        gtk_container_add(GTK_CONTAINER(window), vbox);
4083

    
4084
        vbox2 = gtk_vbox_new(FALSE, 8);
4085
        gtk_container_set_border_width(GTK_CONTAINER(vbox2), 8);
4086
        gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0);
4087

    
4088
        label = gtk_label_new(_("Usage: sylpheed [OPTION]..."));
4089
        gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
4090
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
4091
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
4092

    
4093
        hbox = gtk_hbox_new(FALSE, 16);
4094
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
4095

    
4096
        label = gtk_label_new(_("--compose [address]\n"
4097
                                "--attach file1 [file2]...\n"
4098
                                "--receive\n"
4099
                                "--receive-all\n"
4100
                                "--send\n"
4101
                                "--status [folder]...\n"
4102
                                "--status-full [folder]...\n"
4103
                                "--open folderid/msgnum\n"
4104
                                "--open <file URL>\n"
4105
                                "--configdir dirname\n"
4106
                                "--exit\n"
4107
                                "--debug\n"
4108
                                "--safe-mode\n"
4109
                                "--help\n"
4110
                                "--version"));
4111
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
4112
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
4113
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
4114

    
4115
        label = gtk_label_new(_("open composition window\n"
4116
                                "open composition window with specified files attached\n"
4117
                                "receive new messages\n"
4118
                                "receive new messages of all accounts\n"
4119
                                "send all queued messages\n"
4120
                                "show the total number of messages\n"
4121
                                "show the status of each folder\n"
4122
                                "open message in new window\n"
4123
                                "open an rfc822 message file in a new window\n"
4124
                                "specify directory which stores configuration files\n"
4125
                                "exit Sylpheed\n"
4126
                                "debug mode\n"
4127
                                "safe mode\n"
4128
                                "display this help and exit\n"
4129
                                "output version information and exit"));
4130
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
4131
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
4132
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
4133

    
4134
#ifdef G_OS_WIN32
4135
        label = gtk_label_new(_("Windows-only option:"));
4136
        gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
4137
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
4138
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
4139

    
4140
        hbox = gtk_hbox_new(FALSE, 32);
4141
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
4142

    
4143
        label = gtk_label_new(_("--ipcport portnum"));
4144
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
4145
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
4146
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
4147

    
4148
        label = gtk_label_new(_("specify port for IPC remote commands"));
4149
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
4150
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
4151
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
4152
#endif
4153

    
4154
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
4155
                                      NULL, NULL, NULL, NULL);
4156
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
4157
        gtk_widget_grab_default(ok_btn);
4158

    
4159
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
4160
                         G_CALLBACK(help_cmdline_ok), NULL);
4161
        g_signal_connect(G_OBJECT(window), "key_press_event",
4162
                         G_CALLBACK(help_cmdline_key_pressed), NULL);
4163
        g_signal_connect(G_OBJECT(window), "delete_event",
4164
                         G_CALLBACK(help_cmdline_deleted), NULL);
4165
        g_signal_connect(G_OBJECT(window), "destroy",
4166
                         G_CALLBACK(help_cmdline_destroyed), NULL);
4167

    
4168
        gtk_widget_show_all(window);
4169
}
4170

    
4171
static void help_cmdline_cb(MainWindow *mainwin, guint action,
4172
                            GtkWidget *widget)
4173
{
4174
        help_command_line_show();
4175
}
4176

    
4177
#if USE_UPDATE_CHECK
4178
static void update_check_cb(MainWindow *mainwin, guint action,
4179
                            GtkWidget *widget)
4180
{
4181
        update_check(TRUE);
4182
}
4183

    
4184
#ifdef USE_UPDATE_CHECK_PLUGIN
4185
static void update_check_plugin_cb(MainWindow *mainwin, guint action,
4186
                                   GtkWidget *widget)
4187
{
4188
        update_check_plugin(TRUE);
4189
}
4190
#endif
4191
#endif
4192

    
4193
static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
4194
{
4195
        MainWindow *mainwin = (MainWindow *)data;
4196
        gchar *str;
4197

    
4198
        if (item->path)
4199
                str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
4200
                                      LOCAL_FOLDER(folder)->rootpath,
4201
                                      G_DIR_SEPARATOR,
4202
                                      item->path);
4203
        else
4204
                str = g_strdup_printf(_("Scanning folder %s ..."),
4205
                                      LOCAL_FOLDER(folder)->rootpath);
4206

    
4207
        STATUSBAR_PUSH(mainwin, str);
4208
        STATUSBAR_POP(mainwin);
4209
        g_free(str);
4210
}