Statistics
| Revision:

root / src / mainwindow.c @ 244

History | View | Annotate | Download (95.9 kB)

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