Statistics
| Revision:

root / src / prefs_common_dialog.c @ 2164

History | View | Annotate | Download (132 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2009 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
#ifdef HAVE_CONFIG_H
21
#  include "config.h"
22
#endif
23

    
24
#include "defs.h"
25

    
26
#include <glib.h>
27
#include <glib/gi18n.h>
28
#include <gtk/gtk.h>
29
#include <gdk/gdkkeysyms.h>
30
#include <stdio.h>
31
#include <stdlib.h>
32
#include <string.h>
33
#include <unistd.h>
34
#include <sys/types.h>
35
#include <sys/stat.h>
36
#include <errno.h>
37

    
38
#include "main.h"
39
#include "prefs.h"
40
#include "prefs_ui.h"
41
#include "prefs_common.h"
42
#include "prefs_common_dialog.h"
43
#include "prefs_display_header.h"
44
#include "prefs_summary_column.h"
45
#include "mainwindow.h"
46
#include "summaryview.h"
47
#include "messageview.h"
48
#include "manage_window.h"
49
#include "foldersel.h"
50
#include "inc.h"
51
#include "menu.h"
52
#include "codeconv.h"
53
#include "utils.h"
54
#include "gtkutils.h"
55
#include "alertpanel.h"
56
#include "folder.h"
57
#include "socket.h"
58

    
59
static PrefsDialog dialog;
60

    
61
static struct Receive {
62
        GtkWidget *checkbtn_autochk;
63
        GtkWidget *spinbtn_autochk;
64
        GtkObject *spinbtn_autochk_adj;
65

    
66
        GtkWidget *checkbtn_chkonstartup;
67
        GtkWidget *checkbtn_scan_after_inc;
68
        GtkWidget *checkbtn_newmsg_notify;
69
        GtkWidget *entry_newmsg_notify;
70

    
71
#ifndef G_OS_WIN32
72
        GtkWidget *checkbtn_local;
73
        GtkWidget *checkbtn_filter_on_inc;
74
        GtkWidget *entry_spool;
75
#endif
76
} receive;
77

    
78
static struct Send {
79
        GtkWidget *checkbtn_savemsg;
80
        GtkWidget *checkbtn_filter_sent;
81

    
82
        GtkWidget *optmenu_encoding_method;
83
        GtkWidget *optmenu_mime_fencoding_method;
84

    
85
        GtkWidget *checkbtn_check_attach;
86
        GtkWidget *entry_check_attach_str;
87
        GtkWidget *checkbtn_check_recp;
88
        GtkWidget *entry_check_recp_excl;
89
} p_send;
90

    
91
static struct Compose {
92
        GtkWidget *checkbtn_autosig;
93
        GtkWidget *entry_sigsep;
94

    
95
        GtkWidget *checkbtn_autoextedit;
96
        GtkWidget *spinbtn_undolevel;
97
        GtkObject *spinbtn_undolevel_adj;
98
        GtkWidget *spinbtn_linewrap;
99
        GtkObject *spinbtn_linewrap_adj;
100
        GtkWidget *checkbtn_wrapquote;
101
        GtkWidget *checkbtn_autowrap;
102

    
103
        GtkWidget *checkbtn_autosave;
104
        GtkWidget *spinbtn_autosave;
105
        GtkObject *spinbtn_autosave_adj;
106

    
107
        GtkWidget *checkbtn_reply_account_autosel;
108
        GtkWidget *checkbtn_quote;
109
        GtkWidget *checkbtn_default_reply_list;
110
        GtkWidget *checkbtn_inherit_recipient_on_self_reply;
111
} compose;
112

    
113
static struct Quote {
114
        GtkWidget *entry_quotemark;
115
        GtkWidget *text_quotefmt;
116

    
117
        GtkWidget *entry_fw_quotemark;
118
        GtkWidget *text_fw_quotefmt;
119
} quote;
120

    
121
#if USE_GTKSPELL
122
static struct Spell {
123
        GtkWidget *chkbtn_enable_spell;
124
        GtkWidget *entry_spell_lang;
125
} spell;
126
#endif
127

    
128
static struct Display {
129
        GtkWidget *fontbtn_textfont;
130

    
131
        GtkWidget *chkbtn_folder_unread;
132
        GtkWidget *chkbtn_folder_num_cols;
133
        GtkWidget *entry_ng_abbrev_len;
134
        GtkWidget *spinbtn_ng_abbrev_len;
135
        GtkObject *spinbtn_ng_abbrev_len_adj;
136

    
137
        GtkWidget *chkbtn_swapfrom;
138
        GtkWidget *chkbtn_expand_thread;
139
        GtkWidget *entry_datefmt;
140

    
141
        GtkWidget *optmenu_dispencoding;
142
        GtkWidget *optmenu_outencoding;
143
} display;
144

    
145
static struct Message {
146
        GtkWidget *chkbtn_enablecol;
147
        GtkWidget *button_edit_col;
148
        GtkWidget *chkbtn_disphdrpane;
149
        GtkWidget *chkbtn_disphdr;
150
        GtkWidget *chkbtn_html;
151
        GtkWidget *chkbtn_htmlonly;
152
        GtkWidget *spinbtn_linespc;
153
        GtkObject *spinbtn_linespc_adj;
154

    
155
        GtkWidget *chkbtn_smoothscroll;
156
        GtkWidget *spinbtn_scrollstep;
157
        GtkObject *spinbtn_scrollstep_adj;
158
        GtkWidget *chkbtn_halfpage;
159

    
160
        GtkWidget *chkbtn_resize_image;
161
        GtkWidget *chkbtn_inline_image;
162
} message;
163

    
164
static struct JunkMail {
165
        GtkWidget *chkbtn_enable_junk;
166
        GtkWidget *entry_junk_learncmd;
167
        GtkWidget *entry_nojunk_learncmd;
168
        GtkWidget *entry_classify_cmd;
169
        GtkWidget *entry_junkfolder;
170
        GtkWidget *chkbtn_filter_on_recv;
171
        GtkWidget *chkbtn_filter_before;
172
        GtkWidget *chkbtn_delete_on_recv;
173
        GtkWidget *chkbtn_mark_as_read;
174
} junk;
175

    
176
#if USE_GPGME
177
static struct Privacy {
178
        GtkWidget *checkbtn_auto_check_signatures;
179
        GtkWidget *checkbtn_gpg_signature_popup;
180
        GtkWidget *checkbtn_store_passphrase;
181
        GtkWidget *spinbtn_store_passphrase;
182
        GtkObject *spinbtn_store_passphrase_adj;
183
#ifndef G_OS_WIN32
184
        GtkWidget *checkbtn_passphrase_grab;
185
#endif
186
        GtkWidget *checkbtn_gpg_warning;
187
} privacy;
188
#endif
189

    
190
static struct Interface {
191
        GtkWidget *checkbtn_always_show_msg;
192
        GtkWidget *checkbtn_openunread;
193
        GtkWidget *checkbtn_remember_lastsel;
194
        GtkWidget *checkbtn_mark_as_read_on_newwin;
195
        GtkWidget *checkbtn_openinbox;
196
        GtkWidget *checkbtn_openinbox_startup;
197
        GtkWidget *checkbtn_immedexec;
198
#ifndef G_OS_WIN32
199
        GtkWidget *checkbtn_comply_gnome_hig;
200
#endif
201
        GtkWidget *checkbtn_show_trayicon;
202
        GtkWidget *checkbtn_minimize_to_tray;
203
        GtkWidget *checkbtn_tray_toggle_window;
204
} interface;
205

    
206
static struct Other {
207
        GtkWidget *optmenu_recvdialog;
208
        GtkWidget *checkbtn_no_recv_err_panel;
209
        GtkWidget *checkbtn_close_recv_dialog;
210

    
211
        GtkWidget *checkbtn_addaddrbyclick;
212
        GtkWidget *checkbtn_confonexit;
213
        GtkWidget *checkbtn_cleanonexit;
214
        GtkWidget *checkbtn_askonclean;
215
        GtkWidget *checkbtn_warnqueued;
216
} other;
217

    
218
static struct Extcmd {
219
        GtkWidget *uri_combo;
220
        GtkWidget *uri_entry;
221
        GtkWidget *exteditor_combo;
222
        GtkWidget *exteditor_entry;
223

    
224
        GtkWidget *checkbtn_printcmd;
225
        GtkWidget *printcmd_entry;
226

    
227
        GtkWidget *checkbtn_incext;
228
        GtkWidget *entry_incext;
229
        GtkWidget *button_incext;
230

    
231
        GtkWidget *checkbtn_extsend;
232
        GtkWidget *entry_extsend;
233
        GtkWidget *button_extsend;
234
} extcmd;
235

    
236
static struct UpdateCheck {
237
        GtkWidget *checkbtn_autoupdate;
238
        GtkWidget *checkbtn_useproxy;
239
        GtkWidget *entry_proxyhost;
240
} update_check;
241

    
242
static struct Advanced {
243
        GtkWidget *checkbtn_strict_cache_check;
244

    
245
        GtkWidget *spinbtn_iotimeout;
246
        GtkObject *spinbtn_iotimeout_adj;
247
} advanced;
248

    
249
static struct MessageColorButtons {
250
        GtkWidget *quote_level1_btn;
251
        GtkWidget *quote_level2_btn;
252
        GtkWidget *quote_level3_btn;
253
        GtkWidget *uri_btn;
254
} color_buttons;
255

    
256
static struct KeybindDialog {
257
        GtkWidget *window;
258
        GtkWidget *combo;
259
} keybind;
260

    
261
static GtkWidget *quote_desc_win;
262
static GtkWidget *quote_color_win;
263
static GtkWidget *color_dialog;
264

    
265
static void prefs_common_charset_set_data_from_optmenu           (PrefParam *pparam);
266
static void prefs_common_charset_set_optmenu                   (PrefParam *pparam);
267
static void prefs_common_recv_dialog_set_optmenu           (PrefParam *pparam);
268
static void prefs_common_uri_set_data_from_entry           (PrefParam *pparam);
269
static void prefs_common_uri_set_entry                           (PrefParam *pparam);
270

    
271
static PrefsUIData ui_data[] = {
272
        /* Receive */
273
        {"autochk_newmail", &receive.checkbtn_autochk,
274
         prefs_set_data_from_toggle, prefs_set_toggle},
275
        {"autochk_interval", &receive.spinbtn_autochk,
276
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
277
        {"check_on_startup", &receive.checkbtn_chkonstartup,
278
         prefs_set_data_from_toggle, prefs_set_toggle},
279
        {"scan_all_after_inc", &receive.checkbtn_scan_after_inc,
280
         prefs_set_data_from_toggle, prefs_set_toggle},
281
        {"enable_newmsg_notify", &receive.checkbtn_newmsg_notify,
282
         prefs_set_data_from_toggle, prefs_set_toggle},
283
        {"newmsg_notify_command", &receive.entry_newmsg_notify,
284
         prefs_set_data_from_entry, prefs_set_entry},
285

    
286
#ifndef G_OS_WIN32
287
        {"inc_local", &receive.checkbtn_local,
288
         prefs_set_data_from_toggle, prefs_set_toggle},
289
        {"filter_on_inc_local", &receive.checkbtn_filter_on_inc,
290
         prefs_set_data_from_toggle, prefs_set_toggle},
291
        {"spool_path", &receive.entry_spool,
292
         prefs_set_data_from_entry, prefs_set_entry},
293
#endif
294

    
295
        /* Send */
296
        {"save_message", &p_send.checkbtn_savemsg,
297
         prefs_set_data_from_toggle, prefs_set_toggle},
298
        {"filter_sent_message", &p_send.checkbtn_filter_sent,
299
         prefs_set_data_from_toggle, prefs_set_toggle},
300

    
301
        {"encoding_method", &p_send.optmenu_encoding_method,
302
         prefs_set_data_from_optmenu, prefs_set_optmenu},
303
        {"mime_filename_encoding_method", &p_send.optmenu_mime_fencoding_method,
304
         prefs_set_data_from_optmenu, prefs_set_optmenu},
305
        {"check_attach", &p_send.checkbtn_check_attach,
306
         prefs_set_data_from_toggle, prefs_set_toggle},
307
        {"check_attach_str", &p_send.entry_check_attach_str,
308
         prefs_set_data_from_entry, prefs_set_entry},
309
        {"check_recipients", &p_send.checkbtn_check_recp,
310
         prefs_set_data_from_toggle, prefs_set_toggle},
311
        {"check_recp_exclude", &p_send.entry_check_recp_excl,
312
         prefs_set_data_from_entry, prefs_set_entry},
313

    
314
        /* {"allow_jisx0201_kana", NULL, NULL, NULL}, */
315

    
316
        /* Compose */
317
        {"auto_signature", &compose.checkbtn_autosig,
318
         prefs_set_data_from_toggle, prefs_set_toggle},
319
        {"signature_separator", &compose.entry_sigsep,
320
         prefs_set_data_from_entry, prefs_set_entry},
321

    
322
        {"auto_ext_editor", &compose.checkbtn_autoextedit,
323
         prefs_set_data_from_toggle, prefs_set_toggle},
324

    
325
        {"undo_level", &compose.spinbtn_undolevel,
326
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
327

    
328
        {"linewrap_length", &compose.spinbtn_linewrap,
329
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
330
        {"linewrap_quotation", &compose.checkbtn_wrapquote,
331
         prefs_set_data_from_toggle, prefs_set_toggle},
332
        {"linewrap_auto", &compose.checkbtn_autowrap,
333
         prefs_set_data_from_toggle, prefs_set_toggle},
334

    
335
        {"enable_autosave", &compose.checkbtn_autosave,
336
         prefs_set_data_from_toggle, prefs_set_toggle},
337
        {"autosave_interval", &compose.spinbtn_autosave,
338
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
339

    
340
        {"reply_with_quote", &compose.checkbtn_quote,
341
         prefs_set_data_from_toggle, prefs_set_toggle},
342
        {"reply_account_autoselect",
343
         &compose.checkbtn_reply_account_autosel,
344
         prefs_set_data_from_toggle, prefs_set_toggle},
345
        {"default_reply_list", &compose.checkbtn_default_reply_list,
346
         prefs_set_data_from_toggle, prefs_set_toggle},
347
        {"inherit_recipient_on_self_reply",
348
         &compose.checkbtn_inherit_recipient_on_self_reply,
349
         prefs_set_data_from_toggle, prefs_set_toggle},
350

    
351
        /* {"show_ruler", NULL, NULL, NULL}, */
352

    
353
        /* Quote */
354
        {"reply_quote_mark", &quote.entry_quotemark,
355
         prefs_set_data_from_entry, prefs_set_entry},
356
        {"reply_quote_format", &quote.text_quotefmt,
357
         prefs_set_data_from_text, prefs_set_text},
358

    
359
        {"forward_quote_mark", &quote.entry_fw_quotemark,
360
         prefs_set_data_from_entry, prefs_set_entry},
361
        {"forward_quote_format", &quote.text_fw_quotefmt,
362
         prefs_set_data_from_text, prefs_set_text},
363

    
364
#if USE_GTKSPELL
365
        /* Spelling */
366
        {"check_spell", &spell.chkbtn_enable_spell,
367
         prefs_set_data_from_toggle, prefs_set_toggle},
368
        {"spell_lang",  &spell.entry_spell_lang,
369
         prefs_set_data_from_entry, prefs_set_entry},
370
#endif
371

    
372
        /* Display */
373
        {"message_font_name", &display.fontbtn_textfont,
374
         prefs_set_data_from_fontbtn, prefs_set_fontbtn},
375

    
376
        {"display_folder_unread_num", &display.chkbtn_folder_unread,
377
         prefs_set_data_from_toggle, prefs_set_toggle},
378
        {"display_folder_num_columns", &display.chkbtn_folder_num_cols,
379
         prefs_set_data_from_toggle, prefs_set_toggle},
380
        {"newsgroup_abbrev_len", &display.spinbtn_ng_abbrev_len,
381
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
382

    
383
        /* Display: Summary View */
384
        {"enable_swap_from", &display.chkbtn_swapfrom,
385
         prefs_set_data_from_toggle, prefs_set_toggle},
386
        {"date_format", &display.entry_datefmt,
387
         prefs_set_data_from_entry, prefs_set_entry},
388
        {"expand_thread", &display.chkbtn_expand_thread,
389
         prefs_set_data_from_toggle, prefs_set_toggle},
390

    
391
#if 0
392
        {"enable_rules_hint", NULL, NULL, NULL},
393
#endif /* 0 */
394

    
395
        /* Message */
396
        {"enable_color", &message.chkbtn_enablecol,
397
         prefs_set_data_from_toggle, prefs_set_toggle},
398

    
399
#if 0
400
        {"convert_mb_alnum", &message.chkbtn_mbalnum,
401
         prefs_set_data_from_toggle, prefs_set_toggle},
402
#endif
403
        {"display_header_pane", &message.chkbtn_disphdrpane,
404
         prefs_set_data_from_toggle, prefs_set_toggle},
405
        {"display_header", &message.chkbtn_disphdr,
406
         prefs_set_data_from_toggle, prefs_set_toggle},
407
        {"render_html", &message.chkbtn_html,
408
         prefs_set_data_from_toggle, prefs_set_toggle},
409
        {"html_only_as_attach", &message.chkbtn_htmlonly,
410
         prefs_set_data_from_toggle, prefs_set_toggle},
411
        {"line_space", &message.spinbtn_linespc,
412
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
413

    
414
        /* {"textview_cursor_visible", NULL, NULL, NULL}, */
415

    
416
        {"enable_smooth_scroll", &message.chkbtn_smoothscroll,
417
         prefs_set_data_from_toggle, prefs_set_toggle},
418
        {"scroll_step", &message.spinbtn_scrollstep,
419
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
420
        {"scroll_half_page", &message.chkbtn_halfpage,
421
         prefs_set_data_from_toggle, prefs_set_toggle},
422

    
423
        {"resize_image", &message.chkbtn_resize_image,
424
         prefs_set_data_from_toggle, prefs_set_toggle},
425
        {"inline_image", &message.chkbtn_inline_image,
426
         prefs_set_data_from_toggle, prefs_set_toggle},
427

    
428
        /* Encoding */
429
        {"default_encoding", &display.optmenu_dispencoding,
430
         prefs_common_charset_set_data_from_optmenu,
431
         prefs_common_charset_set_optmenu},
432
        {"outgoing_charset", &display.optmenu_outencoding,
433
         prefs_common_charset_set_data_from_optmenu,
434
         prefs_common_charset_set_optmenu},
435

    
436
        /* Junk mail */
437
        {"enable_junk", &junk.chkbtn_enable_junk,
438
         prefs_set_data_from_toggle, prefs_set_toggle},
439
        {"junk_learn_command", &junk.entry_junk_learncmd,
440
         prefs_set_data_from_entry, prefs_set_entry},
441
        {"nojunk_learn_command", &junk.entry_nojunk_learncmd,
442
         prefs_set_data_from_entry, prefs_set_entry},
443
        {"junk_classify_command", &junk.entry_classify_cmd,
444
         prefs_set_data_from_entry, prefs_set_entry},
445
        {"junk_folder", &junk.entry_junkfolder,
446
         prefs_set_data_from_entry, prefs_set_entry},
447
        {"filter_junk_on_receive", &junk.chkbtn_filter_on_recv,
448
         prefs_set_data_from_toggle, prefs_set_toggle},
449
        {"filter_junk_before", &junk.chkbtn_filter_before,
450
         prefs_set_data_from_toggle, prefs_set_toggle},
451
        {"delete_junk_on_receive", &junk.chkbtn_delete_on_recv,
452
         prefs_set_data_from_toggle, prefs_set_toggle},
453
        {"mark_junk_as_read", &junk.chkbtn_mark_as_read,
454
         prefs_set_data_from_toggle, prefs_set_toggle},
455

    
456
#if USE_GPGME
457
        /* Privacy */
458
        {"auto_check_signatures",
459
         &privacy.checkbtn_auto_check_signatures,
460
         prefs_set_data_from_toggle, prefs_set_toggle},
461
        {"gpg_signature_popup", &privacy.checkbtn_gpg_signature_popup,
462
         prefs_set_data_from_toggle, prefs_set_toggle},
463
        {"store_passphrase", &privacy.checkbtn_store_passphrase,
464
         prefs_set_data_from_toggle, prefs_set_toggle},
465
        {"store_passphrase_timeout", &privacy.spinbtn_store_passphrase,
466
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
467
#ifndef G_OS_WIN32
468
        {"passphrase_grab", &privacy.checkbtn_passphrase_grab,
469
         prefs_set_data_from_toggle, prefs_set_toggle},
470
#endif /* G_OS_WIN32 */
471
        {"show_gpg_warning", &privacy.checkbtn_gpg_warning,
472
         prefs_set_data_from_toggle, prefs_set_toggle},
473
#endif /* USE_GPGME */
474

    
475
        /* Interface */
476
        {"always_show_message_when_selected",
477
         &interface.checkbtn_always_show_msg,
478
         prefs_set_data_from_toggle, prefs_set_toggle},
479
        {"open_unread_on_enter", &interface.checkbtn_openunread,
480
         prefs_set_data_from_toggle, prefs_set_toggle},
481
        {"remember_last_selected", &interface.checkbtn_remember_lastsel,
482
         prefs_set_data_from_toggle, prefs_set_toggle},
483
        {"mark_as_read_on_new_window",
484
         &interface.checkbtn_mark_as_read_on_newwin,
485
         prefs_set_data_from_toggle, prefs_set_toggle},
486
        {"open_inbox_on_inc", &interface.checkbtn_openinbox,
487
         prefs_set_data_from_toggle, prefs_set_toggle},
488
        {"open_inbox_on_startup", &interface.checkbtn_openinbox_startup,
489
         prefs_set_data_from_toggle, prefs_set_toggle},
490
        {"immediate_execution", &interface.checkbtn_immedexec,
491
         prefs_set_data_from_toggle, prefs_set_toggle},
492

    
493
#ifndef G_OS_WIN32
494
        {"comply_gnome_hig", &interface.checkbtn_comply_gnome_hig,
495
         prefs_set_data_from_toggle, prefs_set_toggle},
496
#endif
497
        {"show_trayicon", &interface.checkbtn_show_trayicon,
498
         prefs_set_data_from_toggle, prefs_set_toggle},
499
        {"minimize_to_tray", &interface.checkbtn_minimize_to_tray,
500
         prefs_set_data_from_toggle, prefs_set_toggle},
501
        {"toggle_window_on_trayicon_click",
502
         &interface.checkbtn_tray_toggle_window,
503
         prefs_set_data_from_toggle, prefs_set_toggle},
504

    
505
        /* Other */
506
        {"receive_dialog_mode", &other.optmenu_recvdialog,
507
         prefs_set_data_from_optmenu, prefs_common_recv_dialog_set_optmenu},
508
        {"no_receive_error_panel", &other.checkbtn_no_recv_err_panel,
509
         prefs_set_data_from_toggle, prefs_set_toggle},
510
        {"close_receive_dialog", &other.checkbtn_close_recv_dialog,
511
         prefs_set_data_from_toggle, prefs_set_toggle},
512

    
513
        {"add_address_by_click", &other.checkbtn_addaddrbyclick,
514
         prefs_set_data_from_toggle, prefs_set_toggle},
515

    
516
        {"confirm_on_exit", &other.checkbtn_confonexit,
517
         prefs_set_data_from_toggle, prefs_set_toggle},
518
        {"clean_trash_on_exit", &other.checkbtn_cleanonexit,
519
         prefs_set_data_from_toggle, prefs_set_toggle},
520
        {"ask_on_cleaning", &other.checkbtn_askonclean,
521
         prefs_set_data_from_toggle, prefs_set_toggle},
522
        {"warn_queued_on_exit", &other.checkbtn_warnqueued,
523
         prefs_set_data_from_toggle, prefs_set_toggle},
524

    
525
        /* {"logwindow_line_limit", NULL, NULL, NULL}, */
526

    
527
        /* External commands */
528
        {"uri_open_command", &extcmd.uri_entry,
529
         prefs_common_uri_set_data_from_entry, prefs_common_uri_set_entry},
530
        {"ext_editor_command", &extcmd.exteditor_entry,
531
         prefs_set_data_from_entry, prefs_set_entry},
532

    
533
        {"use_print_command", &extcmd.checkbtn_printcmd,
534
         prefs_set_data_from_toggle, prefs_set_toggle},
535
        {"print_command", &extcmd.printcmd_entry,
536
         prefs_set_data_from_entry, prefs_set_entry},
537

    
538
#ifndef G_OS_WIN32
539
        {"use_ext_inc", &extcmd.checkbtn_incext,
540
         prefs_set_data_from_toggle, prefs_set_toggle},
541
        {"ext_inc_path", &extcmd.entry_incext,
542
         prefs_set_data_from_entry, prefs_set_entry},
543
#endif
544
        {"use_ext_sendmail", &extcmd.checkbtn_extsend,
545
         prefs_set_data_from_toggle, prefs_set_toggle},
546
        {"ext_sendmail_cmd", &extcmd.entry_extsend,
547
         prefs_set_data_from_entry, prefs_set_entry},
548

    
549
        /* Update check */
550
        {"auto_update_check", &update_check.checkbtn_autoupdate,
551
         prefs_set_data_from_toggle, prefs_set_toggle},
552
        {"use_http_proxy", &update_check.checkbtn_useproxy,
553
         prefs_set_data_from_toggle, prefs_set_toggle},
554
        {"http_proxy_host", &update_check.entry_proxyhost,
555
         prefs_set_data_from_entry, prefs_set_entry},
556

    
557
        /* Advanced */
558
        {"strict_cache_check", &advanced.checkbtn_strict_cache_check,
559
         prefs_set_data_from_toggle, prefs_set_toggle},
560
        {"io_timeout_secs", &advanced.spinbtn_iotimeout,
561
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
562

    
563
        {NULL, NULL, NULL, NULL}
564
};
565

    
566
/* widget creating functions */
567
static void prefs_common_create                (void);
568
static void prefs_receive_create        (void);
569
static void prefs_send_create                (void);
570
static void prefs_compose_create        (void);
571
static GtkWidget *prefs_quote_create        (void);
572
#if USE_GTKSPELL
573
static GtkWidget *prefs_spell_create        (void);
574
#endif
575
static void prefs_display_create        (void);
576
static GtkWidget *prefs_message_create        (void);
577
static void prefs_junk_create                (void);
578
#if USE_GPGME
579
static void prefs_privacy_create        (void);
580
#endif
581
static void prefs_details_create        (void);
582
static GtkWidget *prefs_other_create        (void);
583
static GtkWidget *prefs_extcmd_create        (void);
584
static GtkWidget *prefs_update_create        (void);
585
static GtkWidget *prefs_advanced_create        (void);
586

    
587
static void prefs_common_set_encoding_optmenu        (GtkOptionMenu        *optmenu,
588
                                                 gboolean         outgoing);
589

    
590
static void date_format_ok_btn_clicked                (GtkButton        *button,
591
                                                 GtkWidget     **widget);
592
static void date_format_cancel_btn_clicked        (GtkButton        *button,
593
                                                 GtkWidget     **widget);
594
static gboolean date_format_key_pressed                (GtkWidget        *keywidget,
595
                                                 GdkEventKey        *event,
596
                                                 GtkWidget     **widget);
597
static gboolean date_format_on_delete                (GtkWidget        *dialogwidget,
598
                                                 GdkEventAny        *event,
599
                                                 GtkWidget     **widget);
600
static void date_format_entry_on_change                (GtkEditable        *editable,
601
                                                 GtkLabel        *example);
602
static void date_format_select_row                (GtkWidget        *date_format_list,
603
                                                 gint                 row,
604
                                                 gint                 column,
605
                                                 GdkEventButton        *event,
606
                                                 GtkWidget        *date_format);
607
static GtkWidget *date_format_create                (GtkButton        *button,
608
                                                 void                *data);
609

    
610
static void prefs_quote_description_create        (void);
611
static gboolean prefs_quote_description_key_pressed
612
                                                (GtkWidget        *widget,
613
                                                 GdkEventKey        *event,
614
                                                 gpointer         data);
615
static gboolean prefs_quote_description_deleted        (GtkWidget        *widget,
616
                                                 GdkEventAny        *event,
617
                                                 gpointer         data);
618

    
619
static void prefs_quote_colors_dialog                (void);
620
static void prefs_quote_colors_dialog_create        (void);
621
static gint prefs_quote_colors_deleted                (GtkWidget        *widget,
622
                                                 GdkEventAny        *event,
623
                                                 gpointer         data);
624
static gboolean prefs_quote_colors_key_pressed        (GtkWidget        *widget,
625
                                                 GdkEventKey        *event,
626
                                                 gpointer         data);
627
static void quote_color_set_dialog                (GtkWidget        *widget,
628
                                                 gpointer         data);
629
static void quote_colors_set_dialog_ok                (GtkWidget        *widget,
630
                                                 gpointer         data);
631
static void quote_colors_set_dialog_cancel        (GtkWidget        *widget,
632
                                                 gpointer         data);
633
static gboolean quote_colors_set_dialog_key_pressed
634
                                                (GtkWidget        *widget,
635
                                                 GdkEventKey        *event,
636
                                                 gpointer         data);
637
static void set_button_bg_color                        (GtkWidget        *widget,
638
                                                 gint                 color);
639
static void prefs_enable_message_color_toggled        (void);
640
static void prefs_recycle_colors_toggled        (GtkWidget        *widget);
641

    
642
static void prefs_keybind_select                (void);
643
static gint prefs_keybind_deleted                (GtkWidget        *widget,
644
                                                 GdkEventAny        *event,
645
                                                 gpointer         data);
646
static gboolean prefs_keybind_key_pressed        (GtkWidget        *widget,
647
                                                 GdkEventKey        *event,
648
                                                 gpointer         data);
649
static void prefs_keybind_cancel                (void);
650
static void prefs_keybind_apply_clicked                (GtkWidget        *widget);
651

    
652
static void prefs_common_dispitem_clicked        (void);
653

    
654
static void prefs_common_select_folder_cb        (GtkWidget        *widget,
655
                                                 gpointer         data);
656

    
657
static gint prefs_common_deleted                (GtkWidget        *widget,
658
                                                 GdkEventAny        *event,
659
                                                 gpointer         data);
660
static gboolean prefs_common_key_pressed        (GtkWidget        *widget,
661
                                                 GdkEventKey        *event,
662
                                                 gpointer         data);
663
static void prefs_common_ok                        (void);
664
static void prefs_common_apply                        (void);
665
static void prefs_common_cancel                        (void);
666

    
667

    
668
void prefs_common_open(void)
669
{
670
        static gboolean ui_registered = FALSE;
671

    
672
        inc_lock();
673

    
674
        if (!ui_registered) {
675
                prefs_register_ui(prefs_common_get_params(), ui_data);
676
                ui_registered = TRUE;
677
        }
678

    
679
        if (!dialog.window) {
680
                prefs_common_create();
681
        }
682

    
683
        gtkut_box_set_reverse_order(GTK_BOX(dialog.confirm_area),
684
                                    !prefs_common.comply_gnome_hig);
685
        manage_window_set_transient(GTK_WINDOW(dialog.window));
686
        gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog.notebook), 0);
687
        gtk_widget_grab_focus(dialog.ok_btn);
688

    
689
        prefs_set_dialog(prefs_common_get_params());
690

    
691
        gtk_widget_show(dialog.window);
692
}
693

    
694
static void prefs_common_create(void)
695
{
696
        gint page = 0;
697

    
698
        debug_print(_("Creating common preferences window...\n"));
699

    
700
        prefs_dialog_create(&dialog);
701
        gtk_window_set_title (GTK_WINDOW(dialog.window),
702
                              _("Common Preferences"));
703
        g_signal_connect (G_OBJECT(dialog.window), "delete_event",
704
                          G_CALLBACK(prefs_common_deleted), NULL);
705
        g_signal_connect (G_OBJECT(dialog.window), "key_press_event",
706
                          G_CALLBACK(prefs_common_key_pressed), NULL);
707
        MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
708

    
709
        g_signal_connect (G_OBJECT(dialog.ok_btn), "clicked",
710
                          G_CALLBACK(prefs_common_ok), NULL);
711
        g_signal_connect (G_OBJECT(dialog.apply_btn), "clicked",
712
                          G_CALLBACK(prefs_common_apply), NULL);
713
        g_signal_connect (G_OBJECT(dialog.cancel_btn), "clicked",
714
                          G_CALLBACK(prefs_common_cancel), NULL);
715

    
716
        /* create all widgets on notebook */
717
        prefs_receive_create();
718
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"),   page++);
719
        prefs_send_create();
720
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"),      page++);
721
        prefs_compose_create();
722
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"),   page++);
723
        prefs_display_create();
724
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Display"),   page++);
725
        prefs_junk_create();
726
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Junk mail"), page++);
727
#if USE_GPGME
728
        prefs_privacy_create();
729
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"),   page++);
730
#endif
731
        prefs_details_create();
732
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Details"), page++);
733
        //prefs_other_create();
734
        //SET_NOTEBOOK_LABEL(dialog.notebook, _("Other"),     page++);
735
        //prefs_advanced_create();
736
        //SET_NOTEBOOK_LABEL(dialog.notebook, _("Advanced"),  page++);
737

    
738
        gtk_widget_show_all(dialog.window);
739
}
740

    
741
static void prefs_receive_create(void)
742
{
743
        GtkWidget *vbox1;
744
        GtkWidget *vbox2;
745
        GtkWidget *vbox3;
746
        GtkWidget *hbox;
747

    
748
        GtkWidget *hbox_autochk;
749
        GtkWidget *checkbtn_autochk;
750
        GtkWidget *label_autochk1;
751
        GtkObject *spinbtn_autochk_adj;
752
        GtkWidget *spinbtn_autochk;
753
        GtkWidget *label_autochk2;
754
        GtkWidget *checkbtn_chkonstartup;
755
        GtkWidget *checkbtn_scan_after_inc;
756

    
757
        GtkWidget *frame_notify;
758
        GtkWidget *checkbtn_newmsg_notify;
759
        GtkWidget *label_newmsg_notify;
760
        GtkWidget *entry_newmsg_notify;
761
        GtkWidget *label_notify_cmd_desc;
762

    
763
#ifndef G_OS_WIN32
764
        GtkWidget *frame_spool;
765
        GtkWidget *checkbtn_local;
766
        GtkWidget *checkbtn_filter_on_inc;
767
        GtkWidget *label_spool;
768
        GtkWidget *entry_spool;
769
#endif
770

    
771
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
772
        gtk_widget_show (vbox1);
773
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
774
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
775

    
776
        vbox2 = gtk_vbox_new (FALSE, 0);
777
        gtk_widget_show (vbox2);
778
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
779

    
780
        /* Auto-checking */
781
        hbox_autochk = gtk_hbox_new (FALSE, 8);
782
        gtk_widget_show (hbox_autochk);
783
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
784

    
785
        PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
786
                           _("Auto-check new mail"));
787

    
788
        label_autochk1 = gtk_label_new (_("every"));
789
        gtk_widget_show (label_autochk1);
790
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
791

    
792
        spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
793
        spinbtn_autochk = gtk_spin_button_new
794
                (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
795
        gtk_widget_show (spinbtn_autochk);
796
        gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
797
        gtk_widget_set_size_request (spinbtn_autochk, 64, -1);
798
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
799

    
800
        label_autochk2 = gtk_label_new (_("minute(s)"));
801
        gtk_widget_show (label_autochk2);
802
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
803

    
804
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
805
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
806
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
807

    
808
        PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
809
                           _("Check new mail on startup"));
810
        PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
811
                           _("Update all local folders after incorporation"));
812

    
813
        /* New message notify */
814
        PACK_FRAME_WITH_CHECK_BUTTON
815
                (vbox1, frame_notify, checkbtn_newmsg_notify,
816
                 _("Execute command when new messages arrived"));
817

    
818
        vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
819
        gtk_widget_show (vbox3);
820
        gtk_container_add (GTK_CONTAINER (frame_notify), vbox3);
821
        gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
822
        SET_TOGGLE_SENSITIVITY (checkbtn_newmsg_notify, vbox3);
823

    
824
        hbox = gtk_hbox_new (FALSE, 8);
825
        gtk_widget_show (hbox);
826
        gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
827

    
828
        label_newmsg_notify = gtk_label_new (_("Command"));
829
        gtk_widget_show (label_newmsg_notify);
830
        gtk_box_pack_start (GTK_BOX (hbox), label_newmsg_notify,
831
                            FALSE, FALSE, 0);
832

    
833
        entry_newmsg_notify = gtk_entry_new ();
834
        gtk_widget_show (entry_newmsg_notify);
835
        gtk_box_pack_start (GTK_BOX (hbox), entry_newmsg_notify, TRUE, TRUE, 0);
836

    
837
        PACK_SMALL_LABEL
838
                (vbox3, label_notify_cmd_desc,
839
                 _("`%d' will be replaced with the number of new messages."));
840

    
841
#ifndef G_OS_WIN32
842
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_spool, checkbtn_local,
843
                                     _("Incorporate from local spool"));
844

    
845
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
846
        gtk_widget_show (vbox2);
847
        gtk_container_add (GTK_CONTAINER (frame_spool), vbox2);
848
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
849
        SET_TOGGLE_SENSITIVITY (checkbtn_local, vbox2);
850

    
851
        hbox = gtk_hbox_new (FALSE, 32);
852
        gtk_widget_show (hbox);
853
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
854

    
855
        PACK_CHECK_BUTTON (hbox, checkbtn_filter_on_inc,
856
                           _("Filter on incorporation"));
857

    
858
        hbox = gtk_hbox_new (FALSE, 8);
859
        gtk_widget_show (hbox);
860
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
861

    
862
        label_spool = gtk_label_new (_("Spool path"));
863
        gtk_widget_show (label_spool);
864
        gtk_box_pack_start (GTK_BOX (hbox), label_spool, FALSE, FALSE, 0);
865

    
866
        entry_spool = gtk_entry_new ();
867
        gtk_widget_show (entry_spool);
868
        gtk_box_pack_start (GTK_BOX (hbox), entry_spool, TRUE, TRUE, 0);
869
#endif /* !G_OS_WIN32 */
870

    
871
        receive.checkbtn_autochk    = checkbtn_autochk;
872
        receive.spinbtn_autochk     = spinbtn_autochk;
873
        receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
874

    
875
        receive.checkbtn_chkonstartup   = checkbtn_chkonstartup;
876
        receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
877
        receive.checkbtn_newmsg_notify  = checkbtn_newmsg_notify;
878
        receive.entry_newmsg_notify     = entry_newmsg_notify;
879

    
880
#ifndef G_OS_WIN32
881
        receive.checkbtn_local         = checkbtn_local;
882
        receive.checkbtn_filter_on_inc = checkbtn_filter_on_inc;
883
        receive.entry_spool            = entry_spool;
884
#endif
885
}
886

    
887
static void prefs_send_create(void)
888
{
889
        GtkWidget *vbox1;
890
        GtkWidget *vbox2;
891
        GtkWidget *hbox1;
892
        GtkWidget *checkbtn_savemsg;
893
        GtkWidget *checkbtn_filter_sent;
894
        GtkWidget *optmenu_trencoding;
895
        GtkWidget *optmenu_menu;
896
        GtkWidget *menuitem;
897
        GtkWidget *optmenu_fencoding;
898
        GtkWidget *label_encoding;
899
        GtkWidget *label_encoding_desc;
900
        GtkWidget *label_fencoding;
901
        GtkWidget *label_fencoding_desc;
902
        GtkWidget *label;
903
        GtkWidget *checkbtn_check_attach;
904
        GtkWidget *entry_check_attach_str;
905
        GtkWidget *checkbtn_check_recp;
906
        GtkWidget *entry_check_recp_excl;
907

    
908
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
909
        gtk_widget_show (vbox1);
910
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
911
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
912

    
913
        vbox2 = gtk_vbox_new (FALSE, 0);
914
        gtk_widget_show (vbox2);
915
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
916

    
917
        PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
918
                           _("Save sent messages to outbox"));
919
        PACK_CHECK_BUTTON (vbox2, checkbtn_filter_sent,
920
                           _("Apply filter rules to sent messages"));
921
        SET_TOGGLE_SENSITIVITY (checkbtn_savemsg, checkbtn_filter_sent);
922

    
923
        hbox1 = gtk_hbox_new (FALSE, 8);
924
        gtk_widget_show (hbox1);
925
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
926

    
927
        label_encoding = gtk_label_new (_("Transfer encoding"));
928
        gtk_widget_show (label_encoding);
929
        gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
930

    
931
        optmenu_trencoding = gtk_option_menu_new ();
932
        gtk_widget_show (optmenu_trencoding);
933
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_trencoding,
934
                            FALSE, FALSE, 0);
935

    
936
        optmenu_menu = gtk_menu_new ();
937

    
938
#define SET_MENUITEM(str, data) \
939
        MENUITEM_ADD(optmenu_menu, menuitem, str, data)
940

    
941
        SET_MENUITEM(_("Automatic"),         CTE_AUTO);
942
        SET_MENUITEM("base64",                 CTE_BASE64);
943
        SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
944
        SET_MENUITEM("8bit",                 CTE_8BIT);
945

    
946
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_trencoding),
947
                                  optmenu_menu);
948

    
949
        PACK_SMALL_LABEL (vbox1, label_encoding_desc,
950
                          _("Specify Content-Transfer-Encoding used when "
951
                            "message body contains non-ASCII characters."));
952

    
953
        hbox1 = gtk_hbox_new (FALSE, 8);
954
        gtk_widget_show (hbox1);
955
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
956

    
957
        label_fencoding = gtk_label_new (_("MIME filename encoding"));
958
        gtk_widget_show (label_fencoding);
959
        gtk_box_pack_start (GTK_BOX (hbox1), label_fencoding, FALSE, FALSE, 0);
960

    
961
        optmenu_fencoding = gtk_option_menu_new ();
962
        gtk_widget_show (optmenu_fencoding);
963
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_fencoding,
964
                            FALSE, FALSE, 0);
965

    
966
        optmenu_menu = gtk_menu_new ();
967

    
968
        SET_MENUITEM(_("MIME header"), FENC_MIME);
969
        SET_MENUITEM("RFC 2231", FENC_RFC2231);
970

    
971
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_fencoding),
972
                                  optmenu_menu);
973

    
974
#undef SET_MENUITEM
975

    
976
        PACK_SMALL_LABEL
977
                (vbox1, label_fencoding_desc,
978
                 _("Specify encoding method for MIME filename with "
979
                   "non-ASCII characters.\n"
980
                   "MIME header: most popular, but violates RFC 2047\n"
981
                   "RFC 2231: conforms to standard, but not popular"));
982

    
983
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
984
        gtk_widget_show (vbox2);
985
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
986

    
987
        PACK_CHECK_BUTTON (vbox2, checkbtn_check_attach,
988
                           _("Notify for missing attachments when the following strings (comma-separated) are found in the message body"));
989
        gtk_label_set_line_wrap(GTK_LABEL(GTK_BIN(checkbtn_check_attach)->child), TRUE);
990

    
991
        hbox1 = gtk_hbox_new (FALSE, 8);
992
        gtk_widget_show (hbox1);
993
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
994

    
995
        entry_check_attach_str = gtk_entry_new ();
996
        gtk_widget_show (entry_check_attach_str);
997
        gtk_box_pack_start (GTK_BOX (hbox1), entry_check_attach_str,
998
                            TRUE, TRUE, 0);
999
        label = gtk_label_new (_("(Ex: attach)"));
1000
        gtk_widget_show (label);
1001
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1002

    
1003
        SET_TOGGLE_SENSITIVITY(checkbtn_check_attach, entry_check_attach_str);
1004

    
1005
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1006
        gtk_widget_show (vbox2);
1007
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1008

    
1009
        PACK_CHECK_BUTTON (vbox2, checkbtn_check_recp,
1010
                           _("Confirm recipients before sending"));
1011

    
1012
        hbox1 = gtk_hbox_new (FALSE, 8);
1013
        gtk_widget_show (hbox1);
1014
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1015
        label = gtk_label_new
1016
                (_("Excluded addresses/domains (comma-separated):"));
1017
        gtk_widget_show (label);
1018
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1019

    
1020
        entry_check_recp_excl = gtk_entry_new ();
1021
        gtk_widget_show (entry_check_recp_excl);
1022
        gtk_box_pack_start (GTK_BOX (vbox2), entry_check_recp_excl,
1023
                            FALSE, FALSE, 0);
1024

    
1025
        SET_TOGGLE_SENSITIVITY(checkbtn_check_recp, entry_check_recp_excl);
1026

    
1027
        p_send.checkbtn_savemsg     = checkbtn_savemsg;
1028
        p_send.checkbtn_filter_sent = checkbtn_filter_sent;
1029

    
1030
        p_send.optmenu_encoding_method = optmenu_trencoding;
1031
        p_send.optmenu_mime_fencoding_method = optmenu_fencoding;
1032

    
1033
        p_send.checkbtn_check_attach = checkbtn_check_attach;
1034
        p_send.entry_check_attach_str = entry_check_attach_str;
1035
        p_send.checkbtn_check_recp = checkbtn_check_recp;
1036
        p_send.entry_check_recp_excl = entry_check_recp_excl;
1037
}
1038

    
1039
static void prefs_compose_create(void)
1040
{
1041
        GtkWidget *vbox1;
1042

    
1043
        GtkWidget *notebook;
1044
        GtkWidget *vbox_tab;
1045

    
1046
        GtkWidget *hbox1;
1047
        GtkWidget *hbox2;
1048

    
1049
        GtkWidget *frame_sig;
1050
        GtkWidget *checkbtn_autosig;
1051
        GtkWidget *label_sigsep;
1052
        GtkWidget *entry_sigsep;
1053

    
1054
        GtkWidget *vbox2;
1055
        GtkWidget *checkbtn_autoextedit;
1056
        GtkWidget *vbox3;
1057
        GtkWidget *hbox3;
1058
        GtkWidget *hbox4;
1059
        GtkWidget *label_undolevel;
1060
        GtkObject *spinbtn_undolevel_adj;
1061
        GtkWidget *spinbtn_undolevel;
1062
        GtkWidget *label_linewrap;
1063
        GtkObject *spinbtn_linewrap_adj;
1064
        GtkWidget *spinbtn_linewrap;
1065
        GtkWidget *checkbtn_wrapquote;
1066
        GtkWidget *checkbtn_autowrap;
1067

    
1068
        GtkWidget *hbox_autosave;
1069
        GtkWidget *checkbtn_autosave;
1070
        GtkWidget *label_autosave1;
1071
        GtkObject *spinbtn_autosave_adj;
1072
        GtkWidget *spinbtn_autosave;
1073
        GtkWidget *label_autosave2;
1074

    
1075
        GtkWidget *frame_reply;
1076
        GtkWidget *checkbtn_reply_account_autosel;
1077
        GtkWidget *checkbtn_quote;
1078
        GtkWidget *checkbtn_default_reply_list;
1079
        GtkWidget *checkbtn_inherit_recipient_on_self_reply;
1080

    
1081
        GtkWidget *quote_wid;
1082
#if USE_GTKSPELL
1083
        GtkWidget *spell_wid;
1084
#endif
1085

    
1086
        vbox1 = gtk_vbox_new(FALSE, VSPACING);
1087
        gtk_widget_show(vbox1);
1088
        gtk_container_add(GTK_CONTAINER(dialog.notebook), vbox1);
1089
        gtk_container_set_border_width(GTK_CONTAINER(vbox1), VBOX_BORDER);
1090

    
1091
        notebook = gtk_notebook_new();
1092
        gtk_widget_show(notebook);
1093
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1094

    
1095
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1096

    
1097
        /* signature */
1098

    
1099
        PACK_FRAME(vbox_tab, frame_sig, _("Signature"));
1100

    
1101
        hbox1 = gtk_hbox_new (FALSE, 32);
1102
        gtk_widget_show (hbox1);
1103
        gtk_container_add (GTK_CONTAINER (frame_sig), hbox1);
1104
        gtk_container_set_border_width (GTK_CONTAINER (hbox1), 8);
1105

    
1106
        hbox2 = gtk_hbox_new (FALSE, 8);
1107
        gtk_widget_show (hbox2);
1108
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1109

    
1110
        label_sigsep = gtk_label_new (_("Signature separator"));
1111
        gtk_widget_show (label_sigsep);
1112
        gtk_box_pack_start (GTK_BOX (hbox2), label_sigsep, FALSE, FALSE, 0);
1113

    
1114
        entry_sigsep = gtk_entry_new ();
1115
        gtk_widget_show (entry_sigsep);
1116
        gtk_box_pack_start (GTK_BOX (hbox2), entry_sigsep, FALSE, FALSE, 0);
1117
        gtk_widget_set_size_request (entry_sigsep, 64, -1);
1118

    
1119
        PACK_CHECK_BUTTON (hbox1, checkbtn_autosig, _("Insert automatically"));
1120

    
1121
        PACK_FRAME(vbox_tab, frame_reply, _("Reply"));
1122

    
1123
        vbox2 = gtk_vbox_new (FALSE, 0);
1124
        gtk_widget_show (vbox2);
1125
        gtk_container_add (GTK_CONTAINER (frame_reply), vbox2);
1126
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1127

    
1128
        PACK_CHECK_BUTTON (vbox2, checkbtn_reply_account_autosel,
1129
                           _("Automatically select account for replies"));
1130
        PACK_CHECK_BUTTON (vbox2, checkbtn_quote,
1131
                           _("Quote message when replying"));
1132
        PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
1133
                           _("Reply button invokes mailing list reply"));
1134
        PACK_CHECK_BUTTON (vbox2, checkbtn_inherit_recipient_on_self_reply,
1135
                           _("Inherit recipients on reply to self messages"));
1136

    
1137
        /* editor */
1138

    
1139
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Editor"));
1140

    
1141
        vbox2 = gtk_vbox_new (FALSE, 0);
1142
        gtk_widget_show (vbox2);
1143
        gtk_container_add (GTK_CONTAINER (vbox_tab), vbox2);
1144

    
1145
        PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1146
                           _("Automatically launch the external editor"));
1147

    
1148
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1149

    
1150
        /* undo */
1151

    
1152
        hbox3 = gtk_hbox_new (FALSE, 8);
1153
        gtk_widget_show (hbox3);
1154
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1155

    
1156
        label_undolevel = gtk_label_new (_("Undo level"));
1157
        gtk_widget_show (label_undolevel);
1158
        gtk_box_pack_start (GTK_BOX (hbox3), label_undolevel, FALSE, FALSE, 0);
1159

    
1160
        spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 10);
1161
        spinbtn_undolevel = gtk_spin_button_new
1162
                (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1163
        gtk_widget_show (spinbtn_undolevel);
1164
        gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_undolevel, FALSE, FALSE, 0);
1165
        gtk_widget_set_size_request (spinbtn_undolevel, 64, -1);
1166
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1167

    
1168
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1169

    
1170
        /* line-wrapping */
1171

    
1172
        hbox3 = gtk_hbox_new (FALSE, 8);
1173
        gtk_widget_show (hbox3);
1174
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1175

    
1176
        label_linewrap = gtk_label_new (_("Wrap messages at"));
1177
        gtk_widget_show (label_linewrap);
1178
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1179

    
1180
        spinbtn_linewrap_adj = gtk_adjustment_new (72, 20, 1024, 1, 10, 10);
1181
        spinbtn_linewrap = gtk_spin_button_new
1182
                (GTK_ADJUSTMENT (spinbtn_linewrap_adj), 1, 0);
1183
        gtk_widget_show (spinbtn_linewrap);
1184
        gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_linewrap, FALSE, FALSE, 0);
1185
        gtk_widget_set_size_request (spinbtn_linewrap, 64, -1);
1186
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
1187

    
1188
        label_linewrap = gtk_label_new (_("characters"));
1189
        gtk_widget_show (label_linewrap);
1190
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1191

    
1192
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1193

    
1194
        hbox4 = gtk_hbox_new (FALSE, 32);
1195
        gtk_widget_show (hbox4);
1196
        gtk_box_pack_start (GTK_BOX (vbox2), hbox4, FALSE, FALSE, 0);
1197

    
1198
        PACK_CHECK_BUTTON (hbox4, checkbtn_wrapquote, _("Wrap quotation"));
1199

    
1200
        hbox4 = gtk_hbox_new (FALSE, 32);
1201
        gtk_widget_show (hbox4);
1202
        gtk_box_pack_start (GTK_BOX (vbox2), hbox4, FALSE, FALSE, 0);
1203

    
1204
        PACK_CHECK_BUTTON (hbox4, checkbtn_autowrap, _("Wrap on input"));
1205

    
1206
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1207

    
1208
        hbox_autosave = gtk_hbox_new (FALSE, 8);
1209
        gtk_widget_show (hbox_autosave);
1210
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_autosave, FALSE, FALSE, 0);
1211

    
1212
        PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
1213
                           _("Auto-save to draft"));
1214

    
1215
        label_autosave1 = gtk_label_new (_("every"));
1216
        gtk_widget_show (label_autosave1);
1217
        gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave1,
1218
                            FALSE, FALSE, 0);
1219

    
1220
        spinbtn_autosave_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
1221
        spinbtn_autosave = gtk_spin_button_new
1222
                (GTK_ADJUSTMENT (spinbtn_autosave_adj), 1, 0);
1223
        gtk_widget_show (spinbtn_autosave);
1224
        gtk_box_pack_start (GTK_BOX (hbox_autosave), spinbtn_autosave,
1225
                            FALSE, FALSE, 0);
1226
        gtk_widget_set_size_request (spinbtn_autosave, 64, -1);
1227
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autosave), TRUE);
1228

    
1229
        label_autosave2 = gtk_label_new (_("minute(s)"));
1230
        gtk_widget_show (label_autosave2);
1231
        gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave2,
1232
                            FALSE, FALSE, 0);
1233

    
1234
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, label_autosave1);
1235
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, spinbtn_autosave);
1236
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, label_autosave2);
1237

    
1238
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Format"));
1239
        quote_wid = prefs_quote_create();
1240
        gtk_box_pack_start(GTK_BOX(vbox_tab), quote_wid, FALSE, FALSE, 0);
1241

    
1242
#if USE_GTKSPELL
1243
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Spell checking"));
1244
        spell_wid = prefs_spell_create();
1245
        gtk_box_pack_start(GTK_BOX(vbox_tab), spell_wid, FALSE, FALSE, 0);
1246
#endif
1247

    
1248
        compose.checkbtn_autosig = checkbtn_autosig;
1249
        compose.entry_sigsep     = entry_sigsep;
1250

    
1251
        compose.checkbtn_autoextedit = checkbtn_autoextedit;
1252

    
1253
        compose.spinbtn_undolevel     = spinbtn_undolevel;
1254
        compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1255

    
1256
        compose.spinbtn_linewrap     = spinbtn_linewrap;
1257
        compose.spinbtn_linewrap_adj = spinbtn_linewrap_adj;
1258
        compose.checkbtn_wrapquote   = checkbtn_wrapquote;
1259
        compose.checkbtn_autowrap    = checkbtn_autowrap;
1260

    
1261
        compose.checkbtn_autosave    = checkbtn_autosave;
1262
        compose.spinbtn_autosave     = spinbtn_autosave;
1263
        compose.spinbtn_autosave_adj = spinbtn_autosave_adj;
1264

    
1265
        compose.checkbtn_quote = checkbtn_quote;
1266
        compose.checkbtn_reply_account_autosel =
1267
                checkbtn_reply_account_autosel;
1268
        compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
1269
        compose.checkbtn_inherit_recipient_on_self_reply =
1270
                checkbtn_inherit_recipient_on_self_reply;
1271
}
1272

    
1273
static GtkWidget *prefs_quote_create(void)
1274
{
1275
        GtkWidget *vbox1;
1276
        GtkWidget *frame_quote;
1277
        GtkWidget *vbox_quote;
1278
        GtkWidget *hbox1;
1279
        GtkWidget *hbox2;
1280
        GtkWidget *label_quotemark;
1281
        GtkWidget *entry_quotemark;
1282
        GtkWidget *scrolledwin_quotefmt;
1283
        GtkWidget *text_quotefmt;
1284

    
1285
        GtkWidget *entry_fw_quotemark;
1286
        GtkWidget *text_fw_quotefmt;
1287

    
1288
        GtkWidget *btn_quotedesc;
1289

    
1290
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1291
        gtk_widget_show (vbox1);
1292

    
1293
        /* reply */
1294

    
1295
        PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1296

    
1297
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1298
        gtk_widget_show (vbox_quote);
1299
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1300
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1301

    
1302
        hbox1 = gtk_hbox_new (FALSE, 32);
1303
        gtk_widget_show (hbox1);
1304
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1305

    
1306
        hbox2 = gtk_hbox_new (FALSE, 8);
1307
        gtk_widget_show (hbox2);
1308
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1309

    
1310
        label_quotemark = gtk_label_new (_("Quotation mark"));
1311
        gtk_widget_show (label_quotemark);
1312
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1313

    
1314
        entry_quotemark = gtk_entry_new ();
1315
        gtk_widget_show (entry_quotemark);
1316
        gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1317
        gtk_widget_set_size_request (entry_quotemark, 64, -1);
1318

    
1319
        scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1320
        gtk_widget_show (scrolledwin_quotefmt);
1321
        gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
1322
                            TRUE, TRUE, 0);
1323
        gtk_scrolled_window_set_policy
1324
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1325
                 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1326
        gtk_scrolled_window_set_shadow_type
1327
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
1328

    
1329
        text_quotefmt = gtk_text_view_new ();
1330
        gtk_widget_show (text_quotefmt);
1331
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1332
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_quotefmt), TRUE);
1333
        gtk_widget_set_size_request(text_quotefmt, DEFAULT_ENTRY_WIDTH, 60);
1334

    
1335
        /* forward */
1336

    
1337
        PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1338

    
1339
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1340
        gtk_widget_show (vbox_quote);
1341
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1342
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1343

    
1344
        hbox1 = gtk_hbox_new (FALSE, 32);
1345
        gtk_widget_show (hbox1);
1346
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1347

    
1348
        hbox2 = gtk_hbox_new (FALSE, 8);
1349
        gtk_widget_show (hbox2);
1350
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1351

    
1352
        label_quotemark = gtk_label_new (_("Quotation mark"));
1353
        gtk_widget_show (label_quotemark);
1354
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1355

    
1356
        entry_fw_quotemark = gtk_entry_new ();
1357
        gtk_widget_show (entry_fw_quotemark);
1358
        gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1359
                            FALSE, FALSE, 0);
1360
        gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
1361

    
1362
        scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1363
        gtk_widget_show (scrolledwin_quotefmt);
1364
        gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
1365
                            TRUE, TRUE, 0);
1366
        gtk_scrolled_window_set_policy
1367
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1368
                 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1369
        gtk_scrolled_window_set_shadow_type
1370
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
1371

    
1372
        text_fw_quotefmt = gtk_text_view_new ();
1373
        gtk_widget_show (text_fw_quotefmt);
1374
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1375
                          text_fw_quotefmt);
1376
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
1377
        gtk_widget_set_size_request (text_fw_quotefmt, DEFAULT_ENTRY_WIDTH, 60);
1378

    
1379
        hbox1 = gtk_hbox_new (FALSE, 32);
1380
        gtk_widget_show (hbox1);
1381
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1382

    
1383
        btn_quotedesc =
1384
                gtk_button_new_with_label (_(" Description of symbols "));
1385
        gtk_widget_show (btn_quotedesc);
1386
        gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
1387
        g_signal_connect(G_OBJECT(btn_quotedesc), "clicked",
1388
                         G_CALLBACK(prefs_quote_description), NULL);
1389

    
1390
        quote.entry_quotemark    = entry_quotemark;
1391
        quote.text_quotefmt      = text_quotefmt;
1392
        quote.entry_fw_quotemark = entry_fw_quotemark;
1393
        quote.text_fw_quotefmt   = text_fw_quotefmt;
1394

    
1395
        return vbox1;
1396
}
1397

    
1398
#if USE_GTKSPELL
1399
static GtkWidget *prefs_spell_create(void)
1400
{
1401
        GtkWidget *vbox1;
1402
        GtkWidget *vbox2;
1403
        GtkWidget *frame;
1404
        GtkWidget *hbox;
1405
        GtkWidget *chkbtn_enable_spell;
1406
        GtkWidget *label;
1407
        GtkWidget *entry_spell_lang;
1408
 
1409
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1410
        gtk_widget_show (vbox1);
1411
 
1412
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame, chkbtn_enable_spell,
1413
                                     _("Enable Spell checking"));
1414
 
1415
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1416
        gtk_widget_show (vbox2);
1417
        gtk_container_add (GTK_CONTAINER (frame), vbox2);
1418
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1419
        SET_TOGGLE_SENSITIVITY (chkbtn_enable_spell, vbox2);
1420
 
1421
        hbox = gtk_hbox_new (FALSE, 8);
1422
        gtk_widget_show (hbox);
1423
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1424
 
1425
        label = gtk_label_new (_("Default language:"));
1426
        gtk_widget_show (label);
1427
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1428
 
1429
        entry_spell_lang = gtk_entry_new ();
1430
        gtk_widget_show (entry_spell_lang);
1431
        gtk_box_pack_start (GTK_BOX (hbox), entry_spell_lang, TRUE, TRUE, 0);
1432
 
1433
        spell.chkbtn_enable_spell = chkbtn_enable_spell;
1434
        spell.entry_spell_lang = entry_spell_lang;
1435

    
1436
        return vbox1;
1437
}
1438
#endif /* USE_GTKSPELL */
1439

    
1440
static void prefs_display_create(void)
1441
{
1442
        GtkWidget *vbox1;
1443

    
1444
        GtkWidget *notebook;
1445
        GtkWidget *vbox_tab;
1446

    
1447
        GtkWidget *table1;
1448
        GtkWidget *label_textfont;
1449
        GtkWidget *fontbtn_textfont;
1450
        GtkWidget *frame_folder;
1451
        GtkWidget *chkbtn_folder_unread;
1452
        GtkWidget *chkbtn_folder_num_cols;
1453
        GtkWidget *hbox1;
1454
        GtkWidget *label_ng_abbrev;
1455
        GtkWidget *spinbtn_ng_abbrev_len;
1456
        GtkObject *spinbtn_ng_abbrev_len_adj;
1457
        GtkWidget *frame_summary;
1458
        GtkWidget *vbox2;
1459
        GtkWidget *chkbtn_swapfrom;
1460
        GtkWidget *chkbtn_expand_thread;
1461
        GtkWidget *vbox3;
1462
        GtkWidget *label_datefmt;
1463
        GtkWidget *button_datefmt;
1464
        GtkWidget *entry_datefmt;
1465
        GtkWidget *button_dispitem;
1466

    
1467
        GtkWidget *msg_wid;
1468

    
1469
        GtkWidget *label_dispencoding;
1470
        GtkWidget *optmenu_dispencoding;
1471
        GtkWidget *label_outencoding;
1472
        GtkWidget *optmenu_outencoding;
1473
        GtkWidget *label_encoding_desc;
1474

    
1475
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1476
        gtk_widget_show (vbox1);
1477
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1478
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1479

    
1480
        notebook = gtk_notebook_new();
1481
        gtk_widget_show(notebook);
1482
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1483

    
1484
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1485

    
1486
        table1 = gtk_table_new (1, 2, FALSE);
1487
        gtk_widget_show (table1);
1488
        gtk_box_pack_start(GTK_BOX(vbox_tab), table1, FALSE, FALSE, 0);
1489
        gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
1490
        gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
1491

    
1492
        label_textfont = gtk_label_new (_("Text font"));
1493
        gtk_widget_show (label_textfont);
1494
        gtk_table_attach (GTK_TABLE (table1), label_textfont, 0, 1, 0, 1,
1495
                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1496

    
1497
        fontbtn_textfont = gtk_font_button_new ();
1498
        gtk_widget_show (fontbtn_textfont);
1499
        gtk_table_attach (GTK_TABLE (table1), fontbtn_textfont, 1, 2, 0, 1,
1500
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
1501

    
1502
        /* ---- Folder View ---- */
1503

    
1504
        PACK_FRAME(vbox_tab, frame_folder, _("Folder View"));
1505

    
1506
        vbox2 = gtk_vbox_new (FALSE, 0);
1507
        gtk_widget_show (vbox2);
1508
        gtk_container_add (GTK_CONTAINER (frame_folder), vbox2);
1509
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1510

    
1511
        PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1512
                           _("Display unread number next to folder name"));
1513
        PACK_CHECK_BUTTON (vbox2, chkbtn_folder_num_cols,
1514
                           _("Display message number columns in the folder view"));
1515

    
1516
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1517

    
1518
        hbox1 = gtk_hbox_new (FALSE, 8);
1519
        gtk_widget_show (hbox1);
1520
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1521

    
1522
        label_ng_abbrev = gtk_label_new
1523
                (_("Abbreviate newsgroups longer than"));
1524
        gtk_widget_show (label_ng_abbrev);
1525
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1526

    
1527
        spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
1528
        spinbtn_ng_abbrev_len = gtk_spin_button_new
1529
                (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
1530
        gtk_widget_show (spinbtn_ng_abbrev_len);
1531
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
1532
                            FALSE, FALSE, 0);
1533
        gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
1534
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
1535
                                     TRUE);
1536

    
1537
        label_ng_abbrev = gtk_label_new
1538
                (_("letters"));
1539
        gtk_widget_show (label_ng_abbrev);
1540
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1541

    
1542
        /* ---- Summary ---- */
1543

    
1544
        PACK_FRAME(vbox_tab, frame_summary, _("Summary View"));
1545

    
1546
        vbox2 = gtk_vbox_new (FALSE, 0);
1547
        gtk_widget_show (vbox2);
1548
        gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1549
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1550

    
1551
        PACK_CHECK_BUTTON
1552
                (vbox2, chkbtn_swapfrom,
1553
                 _("Display recipient on `From' column if sender is yourself"));
1554
        PACK_CHECK_BUTTON
1555
                (vbox2, chkbtn_expand_thread, _("Expand threads"));
1556

    
1557
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1558

    
1559
        hbox1 = gtk_hbox_new (FALSE, 8);
1560
        gtk_widget_show (hbox1);
1561
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1562

    
1563
        label_datefmt = gtk_label_new (_("Date format"));
1564
        gtk_widget_show (label_datefmt);
1565
        gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1566

    
1567
        entry_datefmt = gtk_entry_new ();
1568
        gtk_widget_show (entry_datefmt);
1569
        gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1570

    
1571
        button_datefmt = gtk_button_new_with_label ("... ");
1572
        gtk_widget_show (button_datefmt);
1573
        gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
1574
        g_signal_connect (G_OBJECT (button_datefmt), "clicked",
1575
                          G_CALLBACK (date_format_create), NULL);
1576

    
1577
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1578

    
1579
        hbox1 = gtk_hbox_new (FALSE, 8);
1580
        gtk_widget_show (hbox1);
1581
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1582

    
1583
        button_dispitem = gtk_button_new_with_label
1584
                (_(" Set display item of summary... "));
1585
        gtk_widget_show (button_dispitem);
1586
        gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
1587
        g_signal_connect (G_OBJECT (button_dispitem), "clicked",
1588
                          G_CALLBACK (prefs_common_dispitem_clicked), NULL);
1589

    
1590
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Message"));
1591
        msg_wid = prefs_message_create();
1592
        gtk_box_pack_start(GTK_BOX(vbox_tab), msg_wid, FALSE, FALSE, 0);
1593

    
1594
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Encoding"));
1595

    
1596
        hbox1 = gtk_hbox_new (FALSE, 8);
1597
        gtk_widget_show (hbox1);
1598
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1599

    
1600
        label_dispencoding = gtk_label_new (_("Default character encoding"));
1601
        gtk_widget_show (label_dispencoding);
1602
        gtk_box_pack_start (GTK_BOX (hbox1), label_dispencoding,
1603
                            FALSE, FALSE, 0);
1604

    
1605
        optmenu_dispencoding = gtk_option_menu_new ();
1606
        gtk_widget_show (optmenu_dispencoding);
1607
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_dispencoding,
1608
                            FALSE, FALSE, 0);
1609

    
1610
        prefs_common_set_encoding_optmenu
1611
                (GTK_OPTION_MENU (optmenu_dispencoding), FALSE);
1612

    
1613
        PACK_SMALL_LABEL (vbox_tab, label_encoding_desc,
1614
                          _("This is used when displaying messages with missing character encoding."));
1615

    
1616
        hbox1 = gtk_hbox_new (FALSE, 8);
1617
        gtk_widget_show (hbox1);
1618
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1619

    
1620
        label_outencoding = gtk_label_new (_("Outgoing character encoding"));
1621
        gtk_widget_show (label_outencoding);
1622
        gtk_box_pack_start (GTK_BOX (hbox1), label_outencoding,
1623
                            FALSE, FALSE, 0);
1624

    
1625
        optmenu_outencoding = gtk_option_menu_new ();
1626
        gtk_widget_show (optmenu_outencoding);
1627
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_outencoding,
1628
                            FALSE, FALSE, 0);
1629

    
1630
        prefs_common_set_encoding_optmenu
1631
                (GTK_OPTION_MENU (optmenu_outencoding), TRUE);
1632

    
1633
        PACK_SMALL_LABEL (vbox_tab, label_encoding_desc,
1634
                          _("If `Automatic' is selected, the optimal encoding "
1635
                            "for the current locale will be used."));
1636

    
1637
        display.fontbtn_textfont = fontbtn_textfont;
1638

    
1639
        display.chkbtn_folder_unread      = chkbtn_folder_unread;
1640
        display.chkbtn_folder_num_cols    = chkbtn_folder_num_cols;
1641
        display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
1642
        display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
1643

    
1644
        display.chkbtn_swapfrom      = chkbtn_swapfrom;
1645
        display.chkbtn_expand_thread = chkbtn_expand_thread;
1646
        display.entry_datefmt        = entry_datefmt;
1647

    
1648
        display.optmenu_dispencoding = optmenu_dispencoding;
1649
        display.optmenu_outencoding  = optmenu_outencoding;
1650
}
1651

    
1652
static GtkWidget *prefs_message_create(void)
1653
{
1654
        GtkWidget *vbox1;
1655
        GtkWidget *vbox2;
1656
        GtkWidget *vbox3;
1657
        GtkWidget *hbox1;
1658
        GtkWidget *chkbtn_enablecol;
1659
        GtkWidget *button_edit_col;
1660
        GtkWidget *chkbtn_disphdrpane;
1661
        GtkWidget *chkbtn_disphdr;
1662
        GtkWidget *button_edit_disphdr;
1663
        GtkWidget *chkbtn_html;
1664
        GtkWidget *chkbtn_htmlonly;
1665
        GtkWidget *hbox_linespc;
1666
        GtkWidget *label_linespc;
1667
        GtkObject *spinbtn_linespc_adj;
1668
        GtkWidget *spinbtn_linespc;
1669

    
1670
        GtkWidget *frame_scr;
1671
        GtkWidget *vbox_scr;
1672
        GtkWidget *chkbtn_smoothscroll;
1673
        GtkWidget *hbox_scr;
1674
        GtkWidget *label_scr;
1675
        GtkObject *spinbtn_scrollstep_adj;
1676
        GtkWidget *spinbtn_scrollstep;
1677
        GtkWidget *chkbtn_halfpage;
1678

    
1679
        GtkWidget *frame_image;
1680
        GtkWidget *vbox_image;
1681
        GtkWidget *chkbtn_resize_image;
1682
        GtkWidget *chkbtn_inline_image;
1683

    
1684
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1685
        gtk_widget_show (vbox1);
1686

    
1687
        vbox2 = gtk_vbox_new (FALSE, 0);
1688
        gtk_widget_show (vbox2);
1689
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1690

    
1691
        hbox1 = gtk_hbox_new (FALSE, 8);
1692
        gtk_widget_show (hbox1);
1693
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1694

    
1695
        PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
1696
                           _("Enable coloration of message"));
1697
        g_signal_connect(G_OBJECT(chkbtn_enablecol), "toggled",
1698
                         G_CALLBACK(prefs_enable_message_color_toggled), NULL);
1699

    
1700
        button_edit_col = gtk_button_new_with_label (_(" Edit... "));
1701
        gtk_widget_show (button_edit_col);
1702
        gtk_box_pack_end (GTK_BOX (hbox1), button_edit_col, FALSE, TRUE, 0);
1703
        g_signal_connect (G_OBJECT (button_edit_col), "clicked",
1704
                          G_CALLBACK (prefs_quote_colors_dialog), NULL);
1705

    
1706
        SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
1707

    
1708
#if 0
1709
        PACK_CHECK_BUTTON
1710
                (vbox2, chkbtn_mbalnum,
1711
                 _("Display multi-byte alphabet and numeric as\n"
1712
                   "ASCII character (Japanese only)"));
1713
        gtk_label_set_justify (GTK_LABEL (GTK_BIN(chkbtn_mbalnum)->child),
1714
                               GTK_JUSTIFY_LEFT);
1715
#endif
1716

    
1717
        PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1718
                          _("Display header pane above message view"));
1719

    
1720
        hbox1 = gtk_hbox_new (FALSE, 8);
1721
        gtk_widget_show (hbox1);
1722
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1723

    
1724
        PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1725
                          _("Display short headers on message view"));
1726

    
1727
        button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
1728
        gtk_widget_show (button_edit_disphdr);
1729
        gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
1730
                          FALSE, TRUE, 0);
1731
        g_signal_connect (G_OBJECT (button_edit_disphdr), "clicked",
1732
                          G_CALLBACK (prefs_display_header_open), NULL);
1733

    
1734
        SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1735

    
1736
        PACK_CHECK_BUTTON(vbox2, chkbtn_html,
1737
                          _("Render HTML messages as text"));
1738
        PACK_CHECK_BUTTON(vbox2, chkbtn_htmlonly,
1739
                          _("Treat HTML only messages as attachment"));
1740

    
1741
#if 0
1742
        PACK_CHECK_BUTTON(vbox2, chkbtn_cursor,
1743
                          _("Display cursor in message view"));
1744
#endif
1745

    
1746
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1747

    
1748
        hbox1 = gtk_hbox_new (FALSE, 32);
1749
        gtk_widget_show (hbox1);
1750
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1751

    
1752
        hbox_linespc = gtk_hbox_new (FALSE, 8);
1753
        gtk_widget_show (hbox1);
1754
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
1755

    
1756
        label_linespc = gtk_label_new (_("Line space"));
1757
        gtk_widget_show (label_linespc);
1758
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1759
                            FALSE, FALSE, 0);
1760

    
1761
        spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
1762
        spinbtn_linespc = gtk_spin_button_new
1763
                (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
1764
        gtk_widget_show (spinbtn_linespc);
1765
        gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
1766
                            FALSE, FALSE, 0);
1767
        gtk_widget_set_size_request (spinbtn_linespc, 64, -1);
1768
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
1769

    
1770
        label_linespc = gtk_label_new (_("pixel(s)"));
1771
        gtk_widget_show (label_linespc);
1772
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1773
                            FALSE, FALSE, 0);
1774

    
1775
        PACK_FRAME(vbox1, frame_scr, _("Scroll"));
1776

    
1777
        vbox_scr = gtk_vbox_new (FALSE, 0);
1778
        gtk_widget_show (vbox_scr);
1779
        gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
1780
        gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
1781

    
1782
        PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
1783

    
1784
        hbox1 = gtk_hbox_new (FALSE, 32);
1785
        gtk_widget_show (hbox1);
1786
        gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
1787

    
1788
        PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
1789

    
1790
        hbox_scr = gtk_hbox_new (FALSE, 8);
1791
        gtk_widget_show (hbox_scr);
1792
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
1793

    
1794
        label_scr = gtk_label_new (_("Step"));
1795
        gtk_widget_show (label_scr);
1796
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1797

    
1798
        spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
1799
        spinbtn_scrollstep = gtk_spin_button_new
1800
                (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
1801
        gtk_widget_show (spinbtn_scrollstep);
1802
        gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
1803
                            FALSE, FALSE, 0);
1804
        gtk_widget_set_size_request (spinbtn_scrollstep, 64, -1);
1805
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
1806
                                     TRUE);
1807

    
1808
        label_scr = gtk_label_new (_("pixel(s)"));
1809
        gtk_widget_show (label_scr);
1810
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1811

    
1812
        SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
1813

    
1814
        PACK_FRAME(vbox1, frame_image, _("Images"));
1815

    
1816
        vbox_image = gtk_vbox_new (FALSE, 0);
1817
        gtk_widget_show (vbox_image);
1818
        gtk_container_add (GTK_CONTAINER (frame_image), vbox_image);
1819
        gtk_container_set_border_width (GTK_CONTAINER (vbox_image), 8);
1820

    
1821
        PACK_CHECK_BUTTON(vbox_image, chkbtn_resize_image,
1822
                          _("Resize attached large images to fit in the window"));
1823
        PACK_CHECK_BUTTON(vbox_image, chkbtn_inline_image,
1824
                          _("Display images as inline"));
1825

    
1826
        message.chkbtn_enablecol   = chkbtn_enablecol;
1827
        message.button_edit_col    = button_edit_col;
1828
        message.chkbtn_disphdrpane = chkbtn_disphdrpane;
1829
        message.chkbtn_disphdr     = chkbtn_disphdr;
1830
        message.chkbtn_html        = chkbtn_html;
1831
        message.chkbtn_htmlonly    = chkbtn_htmlonly;
1832
        message.spinbtn_linespc    = spinbtn_linespc;
1833

    
1834
        message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
1835
        message.spinbtn_scrollstep     = spinbtn_scrollstep;
1836
        message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
1837
        message.chkbtn_halfpage        = chkbtn_halfpage;
1838

    
1839
        message.chkbtn_resize_image = chkbtn_resize_image;
1840
        message.chkbtn_inline_image = chkbtn_inline_image;
1841

    
1842
        return vbox1;
1843
}
1844

    
1845
static const struct {
1846
        gchar *junk_cmd;
1847
        gchar *nojunk_cmd;
1848
        gchar *classify_cmd;
1849
} junk_presets[] = {
1850
#ifdef G_OS_WIN32
1851
        {"bogofilter -N -s -I", "bogofilter -n -S -I", "bogofilter -I"},
1852
        {"bsfilterw -C -s -u", "bsfilterw -c -S -u", "bsfilterw"}
1853
#else
1854
        {"bogofilter -N -s -I", "bogofilter -n -S -I", "bogofilter -I"},
1855
        {"bsfilter -C -s -u", "bsfilter -c -S -u", "bsfilter"}
1856
#endif
1857
};
1858

    
1859
enum
1860
{
1861
        JUNK_NONE,
1862
        JUNK_BOGOFILTER,
1863
        JUNK_BSFILTER
1864
};
1865

    
1866
static void prefs_junk_preset_activated(GtkMenuItem *menuitem, gpointer data)
1867
{
1868
        gint i;
1869

    
1870
        i = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1871
        if (i > 0) {
1872
                i--;
1873
                gtk_entry_set_text(GTK_ENTRY(junk.entry_junk_learncmd),
1874
                                   junk_presets[i].junk_cmd); 
1875
                gtk_entry_set_text(GTK_ENTRY(junk.entry_nojunk_learncmd),
1876
                                   junk_presets[i].nojunk_cmd); 
1877
                gtk_entry_set_text(GTK_ENTRY(junk.entry_classify_cmd),
1878
                                   junk_presets[i].classify_cmd); 
1879
        }
1880
}
1881

    
1882
static void prefs_junk_create(void)
1883
{
1884
        GtkWidget *vbox1;
1885
        GtkWidget *vbox2;
1886
        GtkWidget *frame;
1887
        GtkWidget *hbox;
1888
        GtkWidget *chkbtn_enable_junk;
1889
        GtkWidget *label;
1890
        GtkWidget *optmenu_preset;
1891
        GtkWidget *menu;
1892
        GtkWidget *menuitem;
1893
        GtkWidget *entry_junk_learncmd;
1894
        GtkWidget *entry_nojunk_learncmd;
1895
        GtkWidget *entry_classify_cmd;
1896
        GtkWidget *vbox3;
1897
        GtkWidget *entry_junkfolder;
1898
        GtkWidget *btn_folder;
1899
        GtkWidget *chkbtn_filter_on_recv;
1900
        GtkWidget *chkbtn_filter_before;
1901
        GtkWidget *chkbtn_delete_on_recv;
1902
        GtkWidget *chkbtn_mark_as_read;
1903

    
1904
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1905
        gtk_widget_show (vbox1);
1906
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1907
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1908

    
1909
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame, chkbtn_enable_junk,
1910
                                     _("Enable Junk mail control"));
1911

    
1912
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1913
        gtk_widget_show (vbox2);
1914
        gtk_container_add (GTK_CONTAINER (frame), vbox2);
1915
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1916
        SET_TOGGLE_SENSITIVITY (chkbtn_enable_junk, vbox2);
1917

    
1918
        hbox = gtk_hbox_new (FALSE, 8);
1919
        gtk_widget_show (hbox);
1920
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1921

    
1922
        label = gtk_label_new (_("Learning command:"));
1923
        gtk_widget_show (label);
1924
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1925

    
1926
        optmenu_preset = gtk_option_menu_new ();
1927
        gtk_widget_show (optmenu_preset);
1928
        gtk_box_pack_end (GTK_BOX (hbox), optmenu_preset, FALSE, FALSE, 0);
1929

    
1930
        menu = gtk_menu_new ();
1931
        MENUITEM_ADD (menu, menuitem, _("(Select preset)"), 0);
1932
        MENUITEM_ADD (menu, menuitem, "bogofilter", JUNK_BOGOFILTER);
1933
        g_signal_connect (G_OBJECT (menuitem), "activate",
1934
                          G_CALLBACK (prefs_junk_preset_activated), NULL);
1935
        MENUITEM_ADD (menu, menuitem, "bsfilter", JUNK_BSFILTER);
1936
        g_signal_connect (G_OBJECT (menuitem), "activate",
1937
                          G_CALLBACK (prefs_junk_preset_activated), NULL);
1938
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_preset), menu);
1939

    
1940
        hbox = gtk_hbox_new (FALSE, 8);
1941
        gtk_widget_show (hbox);
1942
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1943

    
1944
        label = gtk_label_new (_("Junk"));
1945
        gtk_widget_show (label);
1946
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1947

    
1948
        entry_junk_learncmd = gtk_entry_new ();
1949
        gtk_widget_show (entry_junk_learncmd);
1950
        gtk_box_pack_start (GTK_BOX (hbox), entry_junk_learncmd, TRUE, TRUE, 0);
1951

    
1952
        hbox = gtk_hbox_new (FALSE, 8);
1953
        gtk_widget_show (hbox);
1954
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1955

    
1956
        label = gtk_label_new (_("Not Junk"));
1957
        gtk_widget_show (label);
1958
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1959

    
1960
        entry_nojunk_learncmd = gtk_entry_new ();
1961
        gtk_widget_show (entry_nojunk_learncmd);
1962
        gtk_box_pack_start (GTK_BOX (hbox), entry_nojunk_learncmd,
1963
                            TRUE, TRUE, 0);
1964

    
1965
        PACK_VSPACER(vbox2, vbox3, 0);
1966

    
1967
        hbox = gtk_hbox_new (FALSE, 8);
1968
        gtk_widget_show (hbox);
1969
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1970

    
1971
        label = gtk_label_new (_("Classifying command"));
1972
        gtk_widget_show (label);
1973
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1974

    
1975
        entry_classify_cmd = gtk_entry_new ();
1976
        gtk_widget_show (entry_classify_cmd);
1977
        gtk_box_pack_start (GTK_BOX (hbox), entry_classify_cmd, TRUE, TRUE, 0);
1978

    
1979
        PACK_VSPACER(vbox2, vbox3, 0);
1980

    
1981
        PACK_SMALL_LABEL (vbox2, label,
1982
                          _("To classify junk mails automatically, both junk "
1983
                            "and not junk mails must be learned manually to "
1984
                            "a certain extent."));
1985

    
1986
        PACK_VSPACER(vbox2, vbox3, 0);
1987

    
1988
        hbox = gtk_hbox_new (FALSE, 8);
1989
        gtk_widget_show (hbox);
1990
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1991

    
1992
        label = gtk_label_new (_("Junk folder"));
1993
        gtk_widget_show (label);
1994
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1995

    
1996
        entry_junkfolder = gtk_entry_new ();
1997
        gtk_widget_show (entry_junkfolder);
1998
        gtk_box_pack_start (GTK_BOX (hbox), entry_junkfolder, TRUE, TRUE, 0);
1999

    
2000
        btn_folder = gtk_button_new_with_label (_(" ... "));
2001
        gtk_widget_show (btn_folder);
2002
        gtk_box_pack_start (GTK_BOX (hbox), btn_folder, FALSE, FALSE, 0);
2003
        g_signal_connect (G_OBJECT (btn_folder), "clicked",
2004
                          G_CALLBACK (prefs_common_select_folder_cb),
2005
                          entry_junkfolder);
2006

    
2007
        PACK_VSPACER(vbox2, vbox3, 0);
2008

    
2009
        PACK_SMALL_LABEL (vbox2, label,
2010
                          _("The messages which are set as junk mail "
2011
                            "will be moved to this folder."));
2012

    
2013
        PACK_VSPACER(vbox2, vbox3, 0);
2014

    
2015
        vbox3 = gtk_vbox_new (FALSE, 0);
2016
        gtk_widget_show (vbox3);
2017
        gtk_box_pack_start (GTK_BOX(vbox2), vbox3, FALSE, FALSE, 0);
2018

    
2019
        PACK_CHECK_BUTTON
2020
                (vbox3, chkbtn_filter_on_recv,
2021
                 _("Filter messages classified as junk on receiving"));
2022
        PACK_CHECK_BUTTON
2023
                (vbox3, chkbtn_filter_before,
2024
                 _("Filter junk mails before normal filtering"));
2025
        PACK_CHECK_BUTTON
2026
                (vbox3, chkbtn_delete_on_recv,
2027
                 _("Delete junk mails from server on receiving"));
2028
        SET_TOGGLE_SENSITIVITY (chkbtn_filter_on_recv, chkbtn_filter_before);
2029
        SET_TOGGLE_SENSITIVITY (chkbtn_filter_on_recv, chkbtn_delete_on_recv);
2030

    
2031
        PACK_CHECK_BUTTON (vbox3, chkbtn_mark_as_read,
2032
                           _("Mark filtered junk mails as read"));
2033

    
2034
        junk.chkbtn_enable_junk    = chkbtn_enable_junk;
2035
        junk.entry_junk_learncmd   = entry_junk_learncmd;
2036
        junk.entry_nojunk_learncmd = entry_nojunk_learncmd;
2037
        junk.entry_classify_cmd    = entry_classify_cmd;
2038
        junk.entry_junkfolder      = entry_junkfolder;
2039
        junk.chkbtn_filter_on_recv = chkbtn_filter_on_recv;
2040
        junk.chkbtn_filter_before  = chkbtn_filter_before;
2041
        junk.chkbtn_delete_on_recv = chkbtn_delete_on_recv;
2042
        junk.chkbtn_mark_as_read   = chkbtn_mark_as_read;
2043
}
2044

    
2045
#if USE_GPGME
2046
static void prefs_privacy_create(void)
2047
{
2048
        GtkWidget *vbox1;
2049
        GtkWidget *vbox2;
2050
        GtkWidget *vbox3;
2051
        GtkWidget *hbox1;
2052
        GtkWidget *hbox_spc;
2053
        GtkWidget *label;
2054
        GtkWidget *checkbtn_auto_check_signatures;
2055
        GtkWidget *checkbtn_gpg_signature_popup;
2056
        GtkWidget *checkbtn_store_passphrase;
2057
        GtkObject *spinbtn_store_passphrase_adj;
2058
        GtkWidget *spinbtn_store_passphrase;
2059
#ifndef G_OS_WIN32
2060
        GtkWidget *checkbtn_passphrase_grab;
2061
#endif
2062
        GtkWidget *checkbtn_gpg_warning;
2063

    
2064
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2065
        gtk_widget_show (vbox1);
2066
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2067
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2068

    
2069
        vbox2 = gtk_vbox_new (FALSE, 0);
2070
        gtk_widget_show (vbox2);
2071
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2072

    
2073
        PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
2074
                           _("Automatically check signatures"));
2075

    
2076
        PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup,
2077
                           _("Show signature check result in a popup window"));
2078

    
2079
        PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
2080
                           _("Store passphrase in memory temporarily"));
2081

    
2082
        vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2083
        gtk_widget_show (vbox3);
2084
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2085

    
2086
        hbox1 = gtk_hbox_new (FALSE, 8);
2087
        gtk_widget_show (hbox1);
2088
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2089

    
2090
        hbox_spc = gtk_hbox_new (FALSE, 0);
2091
        gtk_widget_show (hbox_spc);
2092
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2093
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2094

    
2095
        label = gtk_label_new (_("Expired after"));
2096
        gtk_widget_show (label);
2097
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2098

    
2099
        spinbtn_store_passphrase_adj = gtk_adjustment_new (0, 0, 1440, 1, 5, 5);
2100
        spinbtn_store_passphrase = gtk_spin_button_new
2101
                (GTK_ADJUSTMENT (spinbtn_store_passphrase_adj), 1, 0);
2102
        gtk_widget_show (spinbtn_store_passphrase);
2103
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_store_passphrase, FALSE, FALSE, 0);
2104
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_store_passphrase),
2105
                                     TRUE);
2106
        gtk_widget_set_size_request (spinbtn_store_passphrase, 64, -1);
2107

    
2108
        label = gtk_label_new (_("minute(s) "));
2109
        gtk_widget_show (label);
2110
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2111

    
2112
        hbox1 = gtk_hbox_new (FALSE, 8);
2113
        gtk_widget_show (hbox1);
2114
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2115

    
2116
        hbox_spc = gtk_hbox_new (FALSE, 0);
2117
        gtk_widget_show (hbox_spc);
2118
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2119
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2120

    
2121
        PACK_SMALL_LABEL (hbox1, label,
2122
                          _("Setting to '0' will store the passphrase "
2123
                            "for the whole session."));
2124

    
2125
        SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, vbox3);
2126

    
2127
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
2128

    
2129
#ifndef G_OS_WIN32
2130
        PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
2131
                           _("Grab input while entering a passphrase"));
2132
#endif
2133

    
2134
        PACK_CHECK_BUTTON
2135
                (vbox2, checkbtn_gpg_warning,
2136
                 _("Display warning on startup if GnuPG doesn't work"));
2137

    
2138
        hbox1 = gtk_hbox_new (FALSE, 8);
2139
        gtk_widget_show (hbox1);
2140
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2141

    
2142
        privacy.checkbtn_auto_check_signatures
2143
                                             = checkbtn_auto_check_signatures;
2144
        privacy.checkbtn_gpg_signature_popup
2145
                                             = checkbtn_gpg_signature_popup;
2146
        privacy.checkbtn_store_passphrase    = checkbtn_store_passphrase;
2147
        privacy.spinbtn_store_passphrase     = spinbtn_store_passphrase;
2148
        privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
2149
#ifndef G_OS_WIN32
2150
        privacy.checkbtn_passphrase_grab     = checkbtn_passphrase_grab;
2151
#endif
2152
        privacy.checkbtn_gpg_warning         = checkbtn_gpg_warning;
2153
}
2154
#endif /* USE_GPGME */
2155

    
2156
static void prefs_details_create(void)
2157
{
2158
        GtkWidget *vbox1;
2159

    
2160
        GtkWidget *notebook;
2161
        GtkWidget *vbox_tab;
2162

    
2163
        GtkWidget *vbox2;
2164
        GtkWidget *vbox3;
2165
        GtkWidget *checkbtn_always_show_msg;
2166
        GtkWidget *checkbtn_openunread;
2167
        GtkWidget *checkbtn_remember_lastsel;
2168
        GtkWidget *checkbtn_mark_as_read_on_newwin;
2169
        GtkWidget *checkbtn_openinbox;
2170
        GtkWidget *checkbtn_openinbox_startup;
2171
        GtkWidget *checkbtn_immedexec;
2172
        GtkWidget *hbox1;
2173
        GtkWidget *hbox_spc;
2174
        GtkWidget *label;
2175
#ifndef G_OS_WIN32
2176
        GtkWidget *checkbtn_comply_gnome_hig;
2177
#endif
2178
        GtkWidget *checkbtn_show_trayicon;
2179
        GtkWidget *checkbtn_minimize_to_tray;
2180
        GtkWidget *checkbtn_tray_toggle_window;
2181

    
2182
        GtkWidget *button_keybind;
2183

    
2184
        GtkWidget *other_wid;
2185
        GtkWidget *extcmd_wid;
2186
        GtkWidget *update_wid;
2187
        GtkWidget *advanced_wid;
2188

    
2189
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2190
        gtk_widget_show (vbox1);
2191
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2192
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2193

    
2194
        notebook = gtk_notebook_new();
2195
        gtk_widget_show(notebook);
2196
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
2197

    
2198
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Interface"));
2199

    
2200
        vbox2 = gtk_vbox_new (FALSE, 0);
2201
        gtk_widget_show (vbox2);
2202
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
2203

    
2204
        PACK_CHECK_BUTTON
2205
                (vbox2, checkbtn_always_show_msg,
2206
                 _("Always open messages in summary when selected"));
2207

    
2208
        PACK_CHECK_BUTTON
2209
                (vbox2, checkbtn_openunread,
2210
                 _("Open first unread message when a folder is opened"));
2211

    
2212
        SET_TOGGLE_SENSITIVITY_REV
2213
                (checkbtn_always_show_msg, checkbtn_openunread);
2214

    
2215
        PACK_CHECK_BUTTON
2216
                (vbox2, checkbtn_remember_lastsel,
2217
                 _("Remember last selected message"));
2218

    
2219
        PACK_CHECK_BUTTON
2220
                (vbox2, checkbtn_mark_as_read_on_newwin,
2221
                 _("Only mark message as read when opened in new window"));
2222

    
2223
        PACK_CHECK_BUTTON
2224
                (vbox2, checkbtn_openinbox,
2225
                 _("Open inbox after receiving new mail"));
2226
        PACK_CHECK_BUTTON
2227
                (vbox2, checkbtn_openinbox_startup, _("Open inbox on startup"));
2228

    
2229
        vbox3 = gtk_vbox_new (FALSE, 0);
2230
        gtk_widget_show (vbox3);
2231
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2232

    
2233
        PACK_CHECK_BUTTON
2234
                (vbox3, checkbtn_immedexec,
2235
                 _("Execute immediately when moving or deleting messages"));
2236

    
2237
        hbox1 = gtk_hbox_new (FALSE, 8);
2238
        gtk_widget_show (hbox1);
2239
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2240

    
2241
        hbox_spc = gtk_hbox_new (FALSE, 0);
2242
        gtk_widget_show (hbox_spc);
2243
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2244
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2245

    
2246
        PACK_SMALL_LABEL (hbox1, label,
2247
                          _("Messages will be marked until execution "
2248
                            "if this is turned off."));
2249

    
2250
        vbox2 = gtk_vbox_new (FALSE, 0);
2251
        gtk_widget_show (vbox2);
2252
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
2253

    
2254
#ifndef G_OS_WIN32
2255
        PACK_CHECK_BUTTON (vbox2, checkbtn_comply_gnome_hig,
2256
                           _("Make the order of buttons comply with GNOME HIG"));
2257
#endif
2258
        PACK_CHECK_BUTTON (vbox2, checkbtn_show_trayicon,
2259
                           _("Display tray icon"));
2260
        PACK_CHECK_BUTTON (vbox2, checkbtn_minimize_to_tray,
2261
                           _("Minimize to tray icon"));
2262
        PACK_CHECK_BUTTON (vbox2, checkbtn_tray_toggle_window,
2263
                           _("Toggle window on trayicon click"));
2264
        SET_TOGGLE_SENSITIVITY (checkbtn_show_trayicon,
2265
                                checkbtn_minimize_to_tray);
2266
        SET_TOGGLE_SENSITIVITY (checkbtn_show_trayicon,
2267
                                checkbtn_tray_toggle_window);
2268

    
2269
        hbox1 = gtk_hbox_new (FALSE, 8);
2270
        gtk_widget_show (hbox1);
2271
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
2272

    
2273
        button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2274
        gtk_widget_show (button_keybind);
2275
        gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2276
        g_signal_connect (G_OBJECT (button_keybind), "clicked",
2277
                          G_CALLBACK (prefs_keybind_select), NULL);
2278

    
2279
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Other"));
2280
        other_wid = prefs_other_create();
2281
        gtk_box_pack_start(GTK_BOX(vbox_tab), other_wid, FALSE, FALSE, 0);
2282

    
2283
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("External commands"));
2284
        extcmd_wid = prefs_extcmd_create();
2285
        gtk_box_pack_start(GTK_BOX(vbox_tab), extcmd_wid, FALSE, FALSE, 0);
2286

    
2287
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Update"));
2288
        update_wid = prefs_update_create();
2289
        gtk_box_pack_start(GTK_BOX(vbox_tab), update_wid, FALSE, FALSE, 0);
2290

    
2291
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Advanced"));
2292
        advanced_wid = prefs_advanced_create();
2293
        gtk_box_pack_start(GTK_BOX(vbox_tab), advanced_wid, FALSE, FALSE, 0);
2294

    
2295
        interface.checkbtn_always_show_msg   = checkbtn_always_show_msg;
2296
        interface.checkbtn_openunread        = checkbtn_openunread;
2297
        interface.checkbtn_remember_lastsel  = checkbtn_remember_lastsel;
2298
        interface.checkbtn_mark_as_read_on_newwin
2299
                                             = checkbtn_mark_as_read_on_newwin;
2300
        interface.checkbtn_openinbox         = checkbtn_openinbox;
2301
        interface.checkbtn_openinbox_startup = checkbtn_openinbox_startup;
2302
        interface.checkbtn_immedexec         = checkbtn_immedexec;
2303

    
2304
#ifndef G_OS_WIN32
2305
        interface.checkbtn_comply_gnome_hig  = checkbtn_comply_gnome_hig;
2306
#endif
2307
        interface.checkbtn_show_trayicon      = checkbtn_show_trayicon;
2308
        interface.checkbtn_minimize_to_tray   = checkbtn_minimize_to_tray;
2309
        interface.checkbtn_tray_toggle_window = checkbtn_tray_toggle_window;
2310
}
2311

    
2312
static GtkWidget *prefs_other_create(void)
2313
{
2314
        GtkWidget *vbox1;
2315

    
2316
        GtkWidget *frame_recv;
2317
        GtkWidget *vbox_recv;
2318
        GtkWidget *hbox1;
2319
        GtkWidget *label;
2320
        GtkWidget *optmenu_recvdialog;
2321
        GtkWidget *menu;
2322
        GtkWidget *menuitem;
2323
        GtkWidget *checkbtn_no_recv_err_panel;
2324
        GtkWidget *checkbtn_close_recv_dialog;
2325

    
2326
        GtkWidget *frame_addr;
2327
        GtkWidget *vbox_addr;
2328
        GtkWidget *checkbtn_addaddrbyclick;
2329

    
2330
        GtkWidget *frame_exit;
2331
        GtkWidget *vbox_exit;
2332
        GtkWidget *checkbtn_confonexit;
2333
        GtkWidget *checkbtn_cleanonexit;
2334
        GtkWidget *checkbtn_askonclean;
2335
        GtkWidget *checkbtn_warnqueued;
2336

    
2337
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2338
        gtk_widget_show (vbox1);
2339

    
2340
        PACK_FRAME (vbox1, frame_recv, _("Receive dialog"));
2341
        vbox_recv = gtk_vbox_new (FALSE, 0);
2342
        gtk_widget_show (vbox_recv);
2343
        gtk_container_add (GTK_CONTAINER (frame_recv), vbox_recv);
2344
        gtk_container_set_border_width (GTK_CONTAINER (vbox_recv), 8);
2345

    
2346
        hbox1 = gtk_hbox_new (FALSE, 8);
2347
        gtk_widget_show (hbox1);
2348
        gtk_box_pack_start (GTK_BOX (vbox_recv), hbox1, FALSE, FALSE, 0);
2349

    
2350
        label = gtk_label_new (_("Show receive dialog"));
2351
        gtk_widget_show (label);
2352
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2353

    
2354
        optmenu_recvdialog = gtk_option_menu_new ();
2355
        gtk_widget_show (optmenu_recvdialog);
2356
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_recvdialog,
2357
                            FALSE, FALSE, 0);
2358

    
2359
        menu = gtk_menu_new ();
2360
        MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
2361
        MENUITEM_ADD (menu, menuitem, _("Only on manual receiving"),
2362
                      RECV_DIALOG_MANUAL);
2363
        MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
2364

    
2365
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
2366

    
2367
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_no_recv_err_panel,
2368
                           _("Don't popup error dialog on receive error"));
2369

    
2370
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_close_recv_dialog,
2371
                           _("Close receive dialog when finished"));
2372

    
2373
        PACK_FRAME (vbox1, frame_addr, _("Address book"));
2374

    
2375
        vbox_addr = gtk_vbox_new (FALSE, 0);
2376
        gtk_widget_show (vbox_addr);
2377
        gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2378
        gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2379

    
2380
        PACK_CHECK_BUTTON
2381
                (vbox_addr, checkbtn_addaddrbyclick,
2382
                 _("Add address to destination when double-clicked"));
2383

    
2384
        PACK_FRAME (vbox1, frame_exit, _("On exit"));
2385

    
2386
        vbox_exit = gtk_vbox_new (FALSE, 0);
2387
        gtk_widget_show (vbox_exit);
2388
        gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2389
        gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2390

    
2391
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2392
                           _("Confirm on exit"));
2393

    
2394
        hbox1 = gtk_hbox_new (FALSE, 32);
2395
        gtk_widget_show (hbox1);
2396
        gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2397

    
2398
        PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2399
                           _("Empty trash on exit"));
2400
        PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2401
                           _("Ask before emptying"));
2402
        SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2403

    
2404
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2405
                           _("Warn if there are queued messages"));
2406

    
2407
        other.optmenu_recvdialog         = optmenu_recvdialog;
2408
        other.checkbtn_no_recv_err_panel = checkbtn_no_recv_err_panel;
2409
        other.checkbtn_close_recv_dialog = checkbtn_close_recv_dialog;
2410

    
2411
        other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
2412

    
2413
        other.checkbtn_confonexit  = checkbtn_confonexit;
2414
        other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2415
        other.checkbtn_askonclean  = checkbtn_askonclean;
2416
        other.checkbtn_warnqueued  = checkbtn_warnqueued;
2417

    
2418
        return vbox1;
2419
}
2420

    
2421
static GtkWidget *prefs_extcmd_create(void)
2422
{
2423
        GtkWidget *vbox1;
2424
        GtkWidget *hbox1;
2425

    
2426
        GtkWidget *ext_frame;
2427
        GtkWidget *ext_table;
2428

    
2429
        GtkWidget *uri_label;
2430
        GtkWidget *uri_combo;
2431
        GtkWidget *uri_entry;
2432

    
2433
        GtkWidget *exteditor_label;
2434
        GtkWidget *exteditor_combo;
2435
        GtkWidget *exteditor_entry;
2436

    
2437
        GtkWidget *frame_printcmd;
2438
        GtkWidget *vbox_printcmd;
2439
        GtkWidget *checkbtn_printcmd;
2440
        GtkWidget *printcmd_label;
2441
        GtkWidget *printcmd_entry;
2442

    
2443
#ifndef G_OS_WIN32
2444
        GtkWidget *vbox2;
2445
        GtkWidget *frame_incext;
2446
        GtkWidget *checkbtn_incext;
2447
        GtkWidget *label_incext;
2448
        GtkWidget *entry_incext;
2449
#endif
2450
        GtkWidget *frame_extsend;
2451
        GtkWidget *vbox_extsend;
2452
        GtkWidget *checkbtn_extsend;
2453
        GtkWidget *label_extsend;
2454
        GtkWidget *entry_extsend;
2455

    
2456
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2457
        gtk_widget_show (vbox1);
2458

    
2459
        PACK_FRAME(vbox1, ext_frame,
2460
                   _("External commands (%s will be replaced with file name / URI)"));
2461

    
2462
        ext_table = gtk_table_new (2, 2, FALSE);
2463
        gtk_widget_show (ext_table);
2464
        gtk_container_add (GTK_CONTAINER (ext_frame), ext_table);
2465
        gtk_container_set_border_width (GTK_CONTAINER (ext_table), 8);
2466
        gtk_table_set_row_spacings (GTK_TABLE (ext_table), VSPACING_NARROW);
2467
        gtk_table_set_col_spacings (GTK_TABLE (ext_table), 8);
2468

    
2469
        uri_label = gtk_label_new (_("Web browser"));
2470
        gtk_widget_show(uri_label);
2471
        gtk_table_attach (GTK_TABLE (ext_table), uri_label, 0, 1, 0, 1,
2472
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2473
        gtk_misc_set_alignment (GTK_MISC (uri_label), 1, 0.5);
2474

    
2475
        uri_combo = gtk_combo_new ();
2476
        gtk_widget_show (uri_combo);
2477
        gtk_table_attach (GTK_TABLE (ext_table), uri_combo, 1, 2, 0, 1,
2478
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
2479
        gtkut_combo_set_items (GTK_COMBO (uri_combo),
2480
#ifdef G_OS_WIN32
2481
                               _("(Default browser)"),
2482
#else
2483
                               DEFAULT_BROWSER_CMD,
2484
                               "mozilla-firefox '%s'",
2485
                               "firefox '%s'",
2486
                               "mozilla -remote 'openURL(%s,new-window)'",
2487
                               "mozilla '%s'",
2488
                               "netscape -remote 'openURL(%s,new-window)'",
2489
                               "netscape '%s'",
2490
                               "gnome-moz-remote --newwin '%s'",
2491
                               "rxvt -e w3m '%s'",
2492
                               "rxvt -e lynx '%s'",
2493
#endif
2494
                               NULL);
2495
        uri_entry = GTK_COMBO (uri_combo)->entry;
2496

    
2497
        exteditor_label = gtk_label_new (_("Editor"));
2498
        gtk_widget_show (exteditor_label);
2499
        gtk_table_attach (GTK_TABLE (ext_table), exteditor_label, 0, 1, 1, 2,
2500
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2501
        gtk_misc_set_alignment (GTK_MISC (exteditor_label), 1, 0.5);
2502

    
2503
        exteditor_combo = gtk_combo_new ();
2504
        gtk_widget_show (exteditor_combo);
2505
        gtk_table_attach (GTK_TABLE (ext_table), exteditor_combo, 1, 2, 1, 2,
2506
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
2507
        gtkut_combo_set_items (GTK_COMBO (exteditor_combo),
2508
#ifdef G_OS_WIN32
2509
                               "notepad '%s'",
2510
#else
2511
                               "gedit %s",
2512
                               "kedit %s",
2513
                               "emacs %s",
2514
                               "xemacs %s",
2515
                               "rxvt -e jed %s",
2516
                               "rxvt -e vi %s",
2517
#endif
2518
                               NULL);
2519
        exteditor_entry = GTK_COMBO (exteditor_combo)->entry;
2520

    
2521
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_printcmd, checkbtn_printcmd,
2522
                                     _("Use external program for printing"));
2523

    
2524
        vbox_printcmd = gtk_vbox_new (FALSE, VSPACING_NARROW);
2525
        gtk_widget_show (vbox_printcmd);
2526
        gtk_container_add (GTK_CONTAINER (frame_printcmd), vbox_printcmd);
2527
        gtk_container_set_border_width (GTK_CONTAINER (vbox_printcmd), 8);
2528
        SET_TOGGLE_SENSITIVITY (checkbtn_printcmd, vbox_printcmd);
2529

    
2530
        hbox1 = gtk_hbox_new (FALSE, 8);
2531
        gtk_widget_show (hbox1);
2532
        gtk_box_pack_start (GTK_BOX (vbox_printcmd), hbox1, FALSE, FALSE, 0);
2533

    
2534
        printcmd_label = gtk_label_new (_("Command"));
2535
        gtk_widget_show (printcmd_label);
2536
        gtk_box_pack_start (GTK_BOX (hbox1), printcmd_label, FALSE, FALSE, 0);
2537

    
2538
        printcmd_entry = gtk_entry_new ();
2539
        gtk_widget_show (printcmd_entry);
2540
        gtk_box_pack_start (GTK_BOX (hbox1), printcmd_entry, TRUE, TRUE, 0);
2541

    
2542
#ifndef G_OS_WIN32
2543
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_incext, checkbtn_incext,
2544
                                     _("Use external program for incorporation"));
2545

    
2546
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2547
        gtk_widget_show (vbox2);
2548
        gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
2549
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2550
        SET_TOGGLE_SENSITIVITY (checkbtn_incext, vbox2);
2551

    
2552
        hbox1 = gtk_hbox_new (FALSE, 8);
2553
        gtk_widget_show (hbox1);
2554
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2555

    
2556
        label_incext = gtk_label_new (_("Command"));
2557
        gtk_widget_show (label_incext);
2558
        gtk_box_pack_start (GTK_BOX (hbox1), label_incext, FALSE, FALSE, 0);
2559

    
2560
        entry_incext = gtk_entry_new ();
2561
        gtk_widget_show (entry_incext);
2562
        gtk_box_pack_start (GTK_BOX (hbox1), entry_incext, TRUE, TRUE, 0);
2563
#endif /* !G_OS_WIN32 */
2564

    
2565
        PACK_FRAME_WITH_CHECK_BUTTON (vbox1, frame_extsend, checkbtn_extsend,
2566
                                      _("Use external program for sending"));
2567

    
2568
        vbox_extsend = gtk_vbox_new (FALSE, VSPACING_NARROW);
2569
        gtk_widget_show (vbox_extsend);
2570
        gtk_container_add (GTK_CONTAINER (frame_extsend), vbox_extsend);
2571
        gtk_container_set_border_width (GTK_CONTAINER (vbox_extsend), 8);
2572
        SET_TOGGLE_SENSITIVITY(checkbtn_extsend, vbox_extsend);
2573

    
2574
        hbox1 = gtk_hbox_new (FALSE, 8);
2575
        gtk_widget_show (hbox1);
2576
        gtk_box_pack_start (GTK_BOX (vbox_extsend), hbox1, FALSE, FALSE, 0);
2577

    
2578
        label_extsend = gtk_label_new (_("Command"));
2579
        gtk_widget_show (label_extsend);
2580
        gtk_box_pack_start (GTK_BOX (hbox1), label_extsend, FALSE, FALSE, 0);
2581

    
2582
        entry_extsend = gtk_entry_new ();
2583
        gtk_widget_show (entry_extsend);
2584
        gtk_box_pack_start (GTK_BOX (hbox1), entry_extsend, TRUE, TRUE, 0);
2585

    
2586
        extcmd.uri_combo = uri_combo;
2587
        extcmd.uri_entry = uri_entry;
2588
        extcmd.checkbtn_printcmd = checkbtn_printcmd;
2589
        extcmd.printcmd_entry = printcmd_entry;
2590

    
2591
        extcmd.exteditor_combo = exteditor_combo;
2592
        extcmd.exteditor_entry = exteditor_entry;
2593

    
2594
#ifndef G_OS_WIN32
2595
        extcmd.checkbtn_incext = checkbtn_incext;
2596
        extcmd.entry_incext    = entry_incext;
2597
#endif
2598
        extcmd.checkbtn_extsend = checkbtn_extsend;
2599
        extcmd.entry_extsend    = entry_extsend;
2600

    
2601
        return vbox1;
2602
}
2603

    
2604
static GtkWidget *prefs_update_create(void)
2605
{
2606
        GtkWidget *vbox1;
2607
        GtkWidget *vbox2;
2608
        GtkWidget *checkbtn_autoupdate;
2609
        GtkWidget *checkbtn_useproxy;
2610
        GtkWidget *label;
2611
        GtkWidget *entry_proxyhost;
2612

    
2613
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2614
        gtk_widget_show (vbox1);
2615

    
2616
#ifndef G_OS_WIN32
2617
        label = gtk_label_new (_("Update check requires 'curl' command."));
2618
        gtk_widget_show (label);
2619
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2620
        gtk_box_pack_start (GTK_BOX (vbox1), label, FALSE, FALSE, 0);
2621
#endif
2622

    
2623
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2624
        gtk_widget_show (vbox2);
2625
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2626

    
2627
        PACK_CHECK_BUTTON (vbox2, checkbtn_autoupdate,
2628
                           _("Enable auto update check"));
2629
        PACK_CHECK_BUTTON (vbox2, checkbtn_useproxy,
2630
                           _("Use HTTP proxy"));
2631

    
2632
        label = gtk_label_new (_("HTTP proxy host (hostname:port):"));
2633
        gtk_widget_show (label);
2634
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2635
        gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0);
2636

    
2637
        entry_proxyhost = gtk_entry_new ();
2638
        gtk_widget_show (entry_proxyhost);
2639
        gtk_box_pack_start (GTK_BOX (vbox2), entry_proxyhost, FALSE, FALSE, 0);
2640

    
2641
        SET_TOGGLE_SENSITIVITY(checkbtn_useproxy, label);
2642
        SET_TOGGLE_SENSITIVITY(checkbtn_useproxy, entry_proxyhost);
2643

    
2644
        update_check.checkbtn_autoupdate = checkbtn_autoupdate;
2645
        update_check.checkbtn_useproxy = checkbtn_useproxy;
2646
        update_check.entry_proxyhost = entry_proxyhost;
2647

    
2648
        return vbox1;
2649
}
2650

    
2651
static GtkWidget *prefs_advanced_create(void)
2652
{
2653
        GtkWidget *vbox1;
2654

    
2655
        GtkWidget *vbox2;
2656
        GtkWidget *checkbtn_strict_cache_check;
2657
        GtkWidget *label;
2658

    
2659
        GtkWidget *hbox1;
2660
        GtkWidget *label_iotimeout;
2661
        GtkWidget *spinbtn_iotimeout;
2662
        GtkObject *spinbtn_iotimeout_adj;
2663

    
2664
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2665
        gtk_widget_show (vbox1);
2666

    
2667
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2668
        gtk_widget_show (vbox2);
2669
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2670

    
2671
        PACK_CHECK_BUTTON (vbox2, checkbtn_strict_cache_check,
2672
                           _("Enable strict checking of the integrity of summary caches"));
2673
        PACK_SMALL_LABEL
2674
                (vbox2, label,
2675
                 _("Enable this if the contents of folders have the possibility of modification by other applications.\n"
2676
                   "This option will degrade the performance of displaying summary."));
2677

    
2678
        hbox1 = gtk_hbox_new (FALSE, 8);
2679
        gtk_widget_show (hbox1);
2680
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2681

    
2682
        label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
2683
        gtk_widget_show (label_iotimeout);
2684
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2685

    
2686
        spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
2687
        spinbtn_iotimeout = gtk_spin_button_new
2688
                (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
2689
        gtk_widget_show (spinbtn_iotimeout);
2690
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
2691
                            FALSE, FALSE, 0);
2692
        gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
2693
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
2694

    
2695
        label_iotimeout = gtk_label_new (_("second(s)"));
2696
        gtk_widget_show (label_iotimeout);
2697
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2698

    
2699
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2700
        gtk_widget_show (vbox2);
2701
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2702

    
2703
        advanced.checkbtn_strict_cache_check = checkbtn_strict_cache_check;
2704

    
2705
        advanced.spinbtn_iotimeout     = spinbtn_iotimeout;
2706
        advanced.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
2707

    
2708
        return vbox1;
2709
}
2710

    
2711
static void prefs_common_set_encoding_optmenu(GtkOptionMenu *optmenu,
2712
                                              gboolean outgoing)
2713
{
2714
        GtkWidget *menu;
2715
        GtkWidget *menuitem;
2716

    
2717
        menu = gtk_menu_new();
2718

    
2719
#define SET_MENUITEM(str, data) \
2720
        MENUITEM_ADD(menu, menuitem, str, data)
2721

    
2722
        if (outgoing) {
2723
                SET_MENUITEM(_("Automatic (Recommended)"), NULL);
2724
        } else {
2725
                SET_MENUITEM(_("Automatic"), NULL);
2726
        }
2727
        SET_MENUITEM(NULL, NULL);
2728
        SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
2729
        SET_MENUITEM(NULL, NULL);
2730
        SET_MENUITEM(_("Unicode (UTF-8)"),                 CS_UTF_8);
2731
        SET_MENUITEM(NULL, NULL);
2732
        SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
2733
        SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
2734
        if (!outgoing) {
2735
                SET_MENUITEM(_("Western European (Windows-1252)"),
2736
                             CS_WINDOWS_1252);
2737
        }
2738
        SET_MENUITEM(NULL, NULL);
2739
        SET_MENUITEM(_("Central European (ISO-8859-2)"), CS_ISO_8859_2);
2740
        SET_MENUITEM(NULL, NULL);
2741
        SET_MENUITEM(_("Baltic (ISO-8859-13)"),                 CS_ISO_8859_13);
2742
        SET_MENUITEM(_("Baltic (ISO-8859-4)"),                 CS_ISO_8859_4);
2743
        SET_MENUITEM(_("Baltic (Windows-1257)"),         CS_WINDOWS_1257);
2744
        SET_MENUITEM(NULL, NULL);
2745
        SET_MENUITEM(_("Greek (ISO-8859-7)"),                 CS_ISO_8859_7);
2746
        SET_MENUITEM(NULL, NULL);
2747
        SET_MENUITEM(_("Arabic (ISO-8859-6)"),                 CS_ISO_8859_6);
2748
        SET_MENUITEM(_("Arabic (Windows-1256)"),         CS_WINDOWS_1256);
2749
        SET_MENUITEM(NULL, NULL);
2750
        SET_MENUITEM(_("Hebrew (ISO-8859-8)"),                 CS_ISO_8859_8);
2751
        SET_MENUITEM(_("Hebrew (Windows-1255)"),         CS_WINDOWS_1255);
2752
        SET_MENUITEM(NULL, NULL);
2753
        SET_MENUITEM(_("Turkish (ISO-8859-9)"),                 CS_ISO_8859_9);
2754
        SET_MENUITEM(NULL, NULL);
2755
        SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),         CS_ISO_8859_5);
2756
        SET_MENUITEM(_("Cyrillic (KOI8-R)"),                 CS_KOI8_R);
2757
        SET_MENUITEM(_("Cyrillic (KOI8-U)"),                 CS_KOI8_U);
2758
        SET_MENUITEM(_("Cyrillic (Windows-1251)"),         CS_WINDOWS_1251);
2759
        SET_MENUITEM(NULL, NULL);
2760
        SET_MENUITEM(_("Japanese (ISO-2022-JP)"),         CS_ISO_2022_JP);
2761
        if (!outgoing) {
2762
                SET_MENUITEM(_("Japanese (EUC-JP)"),         CS_EUC_JP);
2763
                SET_MENUITEM(_("Japanese (Shift_JIS)"),         CS_SHIFT_JIS);
2764
        }
2765
        SET_MENUITEM(NULL, NULL);
2766
        SET_MENUITEM(_("Simplified Chinese (GB2312)"),         CS_GB2312);
2767
        SET_MENUITEM(_("Simplified Chinese (GBK)"),         CS_GBK);
2768
        SET_MENUITEM(_("Traditional Chinese (Big5)"),         CS_BIG5);
2769
        if (!outgoing) {
2770
                SET_MENUITEM(_("Traditional Chinese (EUC-TW)"), CS_EUC_TW);
2771
                SET_MENUITEM(_("Chinese (ISO-2022-CN)"),        CS_ISO_2022_CN);
2772
        }
2773
        SET_MENUITEM(NULL, NULL);
2774
        SET_MENUITEM(_("Korean (EUC-KR)"),                 CS_EUC_KR);
2775
        SET_MENUITEM(NULL, NULL);
2776
        SET_MENUITEM(_("Thai (TIS-620)"),                 CS_TIS_620);
2777
        SET_MENUITEM(_("Thai (Windows-874)"),                 CS_WINDOWS_874);
2778

    
2779
#undef SET_MENUITEM
2780

    
2781
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
2782
}
2783

    
2784
static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
2785
{
2786
        GtkWidget *datefmt_sample = NULL;
2787
        gchar *text;
2788

    
2789
        g_return_if_fail(widget != NULL);
2790
        g_return_if_fail(*widget != NULL);
2791
        g_return_if_fail(display.entry_datefmt != NULL);
2792

    
2793
        datefmt_sample = GTK_WIDGET(g_object_get_data
2794
                                    (G_OBJECT(*widget), "datefmt_sample"));
2795
        g_return_if_fail(datefmt_sample != NULL);
2796

    
2797
        text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
2798
        g_free(prefs_common.date_format);
2799
        prefs_common.date_format = text;
2800
        gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
2801

    
2802
        gtk_widget_destroy(*widget);
2803
        *widget = NULL;
2804
}
2805

    
2806
static void date_format_cancel_btn_clicked(GtkButton *button,
2807
                                           GtkWidget **widget)
2808
{
2809
        g_return_if_fail(widget != NULL);
2810
        g_return_if_fail(*widget != NULL);
2811

    
2812
        gtk_widget_destroy(*widget);
2813
        *widget = NULL;
2814
}
2815

    
2816
static gboolean date_format_key_pressed(GtkWidget *keywidget,
2817
                                        GdkEventKey *event,
2818
                                        GtkWidget **widget)
2819
{
2820
        if (event && event->keyval == GDK_Escape)
2821
                date_format_cancel_btn_clicked(NULL, widget);
2822
        return FALSE;
2823
}
2824

    
2825
static gboolean date_format_on_delete(GtkWidget *dialogwidget,
2826
                                      GdkEventAny *event, GtkWidget **widget)
2827
{
2828
        g_return_val_if_fail(widget != NULL, FALSE);
2829
        g_return_val_if_fail(*widget != NULL, FALSE);
2830

    
2831
        *widget = NULL;
2832
        return FALSE;
2833
}
2834

    
2835
static void date_format_entry_on_change(GtkEditable *editable,
2836
                                        GtkLabel *example)
2837
{
2838
        time_t cur_time;
2839
        struct tm *cal_time;
2840
        gchar buffer[100];
2841
        gchar *text;
2842

    
2843
        cur_time = time(NULL);
2844
        cal_time = localtime(&cur_time);
2845
        buffer[0] = 0;
2846
        text = gtk_editable_get_chars(editable, 0, -1);
2847
        if (text)
2848
                strftime(buffer, sizeof buffer, text, cal_time); 
2849
        g_free(text);
2850

    
2851
        text = conv_codeset_strdup(buffer, conv_get_locale_charset_str(),
2852
                                   CS_UTF_8);
2853
        if (!text)
2854
                text = g_strdup(buffer);
2855
        gtk_label_set_text(example, text);
2856
        g_free(text);
2857
}
2858

    
2859
static void date_format_select_row(GtkWidget *date_format_list, gint row,
2860
                                   gint column, GdkEventButton *event,
2861
                                   GtkWidget *date_format)
2862
{
2863
        gint cur_pos;
2864
        gchar *format;
2865
        const gchar *old_format;
2866
        gchar *new_format;
2867
        GtkWidget *datefmt_sample;
2868

    
2869
        /* only on double click */
2870
        if (!event || event->type != GDK_2BUTTON_PRESS) return;
2871

    
2872
        datefmt_sample = GTK_WIDGET(g_object_get_data
2873
                                    (G_OBJECT(date_format), "datefmt_sample"));
2874

    
2875
        g_return_if_fail(date_format_list != NULL);
2876
        g_return_if_fail(date_format != NULL);
2877
        g_return_if_fail(datefmt_sample != NULL);
2878

    
2879
        /* get format from clist */
2880
        gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
2881

    
2882
        cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
2883
        old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
2884

    
2885
        /* insert the format into the text entry */
2886
        new_format = g_malloc(strlen(old_format) + 3);
2887

    
2888
        strncpy(new_format, old_format, cur_pos);
2889
        new_format[cur_pos] = '\0';
2890
        strcat(new_format, format);
2891
        strcat(new_format, &old_format[cur_pos]);
2892

    
2893
        gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
2894
        gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
2895

    
2896
        g_free(new_format);
2897
}
2898

    
2899
static GtkWidget *date_format_create(GtkButton *button, void *data)
2900
{
2901
        static GtkWidget *datefmt_win = NULL;
2902
        GtkWidget *vbox1;
2903
        GtkWidget *scrolledwindow1;
2904
        GtkWidget *datefmt_clist;
2905
        GtkWidget *table;
2906
        GtkWidget *label1;
2907
        GtkWidget *label2;
2908
        GtkWidget *label3;
2909
        GtkWidget *confirm_area;
2910
        GtkWidget *ok_btn;
2911
        GtkWidget *cancel_btn;
2912
        GtkWidget *datefmt_entry;
2913

    
2914
        struct {
2915
                gchar *fmt;
2916
                gchar *txt;
2917
        } time_format[] = {
2918
                { "%a", NULL },
2919
                { "%A", NULL },
2920
                { "%b", NULL },
2921
                { "%B", NULL },
2922
                { "%c", NULL },
2923
                { "%C", NULL },
2924
                { "%d", NULL },
2925
                { "%H", NULL },
2926
                { "%I", NULL },
2927
                { "%j", NULL },
2928
                { "%m", NULL },
2929
                { "%M", NULL },
2930
                { "%p", NULL },
2931
                { "%S", NULL },
2932
                { "%w", NULL },
2933
                { "%x", NULL },
2934
                { "%y", NULL },
2935
                { "%Y", NULL },
2936
                { "%Z", NULL }
2937
        };
2938

    
2939
        gchar *titles[2];
2940
        gint i;
2941
        const gint TIME_FORMAT_ELEMS =
2942
                sizeof time_format / sizeof time_format[0];
2943

    
2944
        time_format[0].txt  = _("the full abbreviated weekday name");
2945
        time_format[1].txt  = _("the full weekday name");
2946
        time_format[2].txt  = _("the abbreviated month name");
2947
        time_format[3].txt  = _("the full month name");
2948
        time_format[4].txt  = _("the preferred date and time for the current locale");
2949
        time_format[5].txt  = _("the century number (year/100)");
2950
        time_format[6].txt  = _("the day of the month as a decimal number");
2951
        time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
2952
        time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
2953
        time_format[9].txt  = _("the day of the year as a decimal number");
2954
        time_format[10].txt = _("the month as a decimal number");
2955
        time_format[11].txt = _("the minute as a decimal number");
2956
        time_format[12].txt = _("either AM or PM");
2957
        time_format[13].txt = _("the second as a decimal number");
2958
        time_format[14].txt = _("the day of the week as a decimal number");
2959
        time_format[15].txt = _("the preferred date for the current locale");
2960
        time_format[16].txt = _("the last two digits of a year");
2961
        time_format[17].txt = _("the year as a decimal number");
2962
        time_format[18].txt = _("the time zone or name or abbreviation");
2963

    
2964
        if (datefmt_win) return datefmt_win;
2965

    
2966
        datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2967
        gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
2968
        gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
2969
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2970
        gtk_widget_set_size_request(datefmt_win, 440, 280);
2971

    
2972
        vbox1 = gtk_vbox_new(FALSE, 10);
2973
        gtk_widget_show(vbox1);
2974
        gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
2975

    
2976
        scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
2977
        gtk_scrolled_window_set_policy
2978
                (GTK_SCROLLED_WINDOW(scrolledwindow1),
2979
                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
2980
        gtk_widget_show(scrolledwindow1);
2981
        gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
2982

    
2983
        titles[0] = _("Specifier");
2984
        titles[1] = _("Description");
2985
        datefmt_clist = gtk_clist_new_with_titles(2, titles);
2986
        gtk_widget_show(datefmt_clist);
2987
        gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
2988
        /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
2989
        gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
2990
                                     GTK_SELECTION_BROWSE);
2991

    
2992
        for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
2993
                gchar *text[2];
2994
                /* phoney casting necessary because of gtk... */
2995
                text[0] = (gchar *)time_format[i].fmt;
2996
                text[1] = (gchar *)time_format[i].txt;
2997
                gtk_clist_append(GTK_CLIST(datefmt_clist), text);
2998
        }
2999

    
3000
        table = gtk_table_new(2, 2, FALSE);
3001
        gtk_widget_show(table);
3002
        gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
3003
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
3004
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
3005

    
3006
        label1 = gtk_label_new(_("Date format"));
3007
        gtk_widget_show(label1);
3008
        gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
3009
                         GTK_FILL, 0, 0, 0);
3010
        gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
3011
        gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
3012

    
3013
        datefmt_entry = gtk_entry_new();
3014
        gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
3015
        gtk_widget_show(datefmt_entry);
3016
        gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
3017
                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3018

    
3019
        /* we need the "sample" entry box; add it as data so callbacks can
3020
         * get the entry box */
3021
        g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
3022
                          datefmt_entry);
3023

    
3024
        label2 = gtk_label_new(_("Example"));
3025
        gtk_widget_show(label2);
3026
        gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
3027
                         GTK_FILL, 0, 0, 0);
3028
        gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
3029
        gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
3030

    
3031
        label3 = gtk_label_new("");
3032
        gtk_widget_show(label3);
3033
        gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
3034
                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3035
        gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
3036
        gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
3037

    
3038
        gtkut_stock_button_set_create(&confirm_area, &ok_btn, GTK_STOCK_OK,
3039
                                &cancel_btn, GTK_STOCK_CANCEL, NULL, NULL);
3040

    
3041
        gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
3042
        gtk_widget_show(confirm_area);
3043
        gtk_widget_grab_default(ok_btn);
3044

    
3045
        /* set the current format */
3046
        gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
3047
        date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
3048
                                    GTK_LABEL(label3));
3049

    
3050
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3051
                         G_CALLBACK(date_format_ok_btn_clicked), &datefmt_win);
3052
        g_signal_connect(G_OBJECT(cancel_btn), "clicked",
3053
                         G_CALLBACK(date_format_cancel_btn_clicked),
3054
                         &datefmt_win);
3055
        g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
3056
                         G_CALLBACK(date_format_key_pressed), &datefmt_win);
3057
        g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
3058
                         G_CALLBACK(date_format_on_delete), &datefmt_win);
3059
        g_signal_connect(G_OBJECT(datefmt_entry), "changed",
3060
                         G_CALLBACK(date_format_entry_on_change), label3);
3061
        g_signal_connect(G_OBJECT(datefmt_clist), "select_row",
3062
                         G_CALLBACK(date_format_select_row), datefmt_win);
3063

    
3064
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3065
        gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
3066

    
3067
        gtk_widget_show(datefmt_win);
3068
        manage_window_set_transient(GTK_WINDOW(datefmt_win));
3069

    
3070
        gtk_widget_grab_focus(ok_btn);
3071

    
3072
        return datefmt_win;
3073
}
3074

    
3075
void prefs_quote_colors_dialog(void)
3076
{
3077
        if (!quote_color_win)
3078
                prefs_quote_colors_dialog_create();
3079
        gtk_widget_show(quote_color_win);
3080
        manage_window_set_transient(GTK_WINDOW(quote_color_win));
3081

    
3082
        gtk_main();
3083
        gtk_widget_hide(quote_color_win);
3084
        gtk_window_present(GTK_WINDOW(dialog.window));
3085

    
3086
        main_window_reflect_prefs_all();
3087
}
3088

    
3089
static void prefs_quote_colors_dialog_create(void)
3090
{
3091
        GtkWidget *window;
3092
        GtkWidget *vbox;
3093
        GtkWidget *table;
3094
        GtkWidget *quotelevel1_label;
3095
        GtkWidget *quotelevel2_label;
3096
        GtkWidget *quotelevel3_label;
3097
        GtkWidget *uri_label;
3098
        GtkWidget *hbbox;
3099
        GtkWidget *ok_btn;
3100
        GtkWidget *recycle_colors_btn;
3101
        GtkWidget *frame_colors;
3102

    
3103
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3104
        gtk_container_set_border_width(GTK_CONTAINER(window), 2);
3105
        gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
3106
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
3107
        gtk_window_set_modal(GTK_WINDOW(window), TRUE);
3108
        gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
3109

    
3110
        vbox = gtk_vbox_new (FALSE, VSPACING);
3111
        gtk_container_add (GTK_CONTAINER (window), vbox);
3112
        gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
3113
        PACK_FRAME(vbox, frame_colors, _("Colors"));
3114

    
3115
        table = gtk_table_new (4, 2, FALSE);
3116
        gtk_container_add (GTK_CONTAINER (frame_colors), table);
3117
        gtk_container_set_border_width (GTK_CONTAINER (table), 8);
3118
        gtk_table_set_row_spacings (GTK_TABLE (table), 2);
3119
        gtk_table_set_col_spacings (GTK_TABLE (table), 4);
3120

    
3121
        color_buttons.quote_level1_btn = gtk_button_new();
3122
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level1_btn,
3123
                          0, 1, 0, 1, 0, 0, 0, 0);
3124
        gtk_widget_set_size_request (color_buttons.quote_level1_btn, 40, 30);
3125
        gtk_container_set_border_width
3126
                (GTK_CONTAINER (color_buttons.quote_level1_btn), 5);
3127

    
3128
        color_buttons.quote_level2_btn = gtk_button_new();
3129
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level2_btn,
3130
                          0, 1, 1, 2, 0, 0, 0, 0);
3131
        gtk_widget_set_size_request (color_buttons.quote_level2_btn, 40, 30);
3132
        gtk_container_set_border_width (GTK_CONTAINER (color_buttons.quote_level2_btn), 5);
3133

    
3134
        color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
3135
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
3136
                          0, 1, 2, 3, 0, 0, 0, 0);
3137
        gtk_widget_set_size_request (color_buttons.quote_level3_btn, 40, 30);
3138
        gtk_container_set_border_width
3139
                (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
3140

    
3141
        color_buttons.uri_btn = gtk_button_new_with_label ("");
3142
        gtk_table_attach (GTK_TABLE (table), color_buttons.uri_btn,
3143
                          0, 1, 3, 4, 0, 0, 0, 0);
3144
        gtk_widget_set_size_request (color_buttons.uri_btn, 40, 30);
3145
        gtk_container_set_border_width (GTK_CONTAINER (color_buttons.uri_btn), 5);
3146

    
3147
        quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
3148
        gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
3149
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3150
        gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
3151
        gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
3152

    
3153
        quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
3154
        gtk_table_attach (GTK_TABLE (table), quotelevel2_label, 1, 2, 1, 2,
3155
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3156
        gtk_label_set_justify (GTK_LABEL (quotelevel2_label), GTK_JUSTIFY_LEFT);
3157
        gtk_misc_set_alignment (GTK_MISC (quotelevel2_label), 0, 0.5);
3158

    
3159
        quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
3160
        gtk_table_attach (GTK_TABLE (table), quotelevel3_label, 1, 2, 2, 3,
3161
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3162
        gtk_label_set_justify (GTK_LABEL (quotelevel3_label), GTK_JUSTIFY_LEFT);
3163
        gtk_misc_set_alignment (GTK_MISC (quotelevel3_label), 0, 0.5);
3164

    
3165
        uri_label = gtk_label_new (_("URI link"));
3166
        gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
3167
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3168
        gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
3169
        gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
3170

    
3171
        PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
3172
                           _("Recycle quote colors"));
3173

    
3174
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
3175
                                      NULL, NULL, NULL, NULL);
3176
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3177

    
3178
        gtk_widget_grab_default(ok_btn);
3179
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
3180
        g_signal_connect (G_OBJECT (window), "delete_event",
3181
                          G_CALLBACK (prefs_quote_colors_deleted), NULL);
3182
        g_signal_connect(G_OBJECT(window), "key_press_event",
3183
                         G_CALLBACK(prefs_quote_colors_key_pressed), NULL);
3184

    
3185
        g_signal_connect(G_OBJECT(color_buttons.quote_level1_btn), "clicked",
3186
                         G_CALLBACK(quote_color_set_dialog), "LEVEL1");
3187
        g_signal_connect(G_OBJECT(color_buttons.quote_level2_btn), "clicked",
3188
                         G_CALLBACK(quote_color_set_dialog), "LEVEL2");
3189
        g_signal_connect(G_OBJECT(color_buttons.quote_level3_btn), "clicked",
3190
                         G_CALLBACK(quote_color_set_dialog), "LEVEL3");
3191
        g_signal_connect(G_OBJECT(color_buttons.uri_btn), "clicked",
3192
                         G_CALLBACK(quote_color_set_dialog), "URI");
3193
        g_signal_connect(G_OBJECT(recycle_colors_btn), "toggled",
3194
                         G_CALLBACK(prefs_recycle_colors_toggled), NULL);
3195
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3196
                         G_CALLBACK(gtk_main_quit), NULL);
3197

    
3198
        /* show message button colors and recycle options */
3199
        set_button_bg_color(color_buttons.quote_level1_btn,
3200
                            prefs_common.quote_level1_col);
3201
        set_button_bg_color(color_buttons.quote_level2_btn,
3202
                            prefs_common.quote_level2_col);
3203
        set_button_bg_color(color_buttons.quote_level3_btn,
3204
                            prefs_common.quote_level3_col);
3205
        set_button_bg_color(color_buttons.uri_btn,
3206
                            prefs_common.uri_col);
3207
        gtk_toggle_button_set_active((GtkToggleButton *)recycle_colors_btn,
3208
                                     prefs_common.recycle_quote_colors);
3209

    
3210
        gtk_widget_show_all(vbox);
3211
        quote_color_win = window;
3212
}
3213

    
3214
static gint prefs_quote_colors_deleted(GtkWidget *widet, GdkEventAny *event,
3215
                                       gpointer data)
3216
{
3217
        gtk_main_quit();
3218
        return TRUE;
3219
}
3220

    
3221
static gboolean prefs_quote_colors_key_pressed(GtkWidget *widget,
3222
                                               GdkEventKey *event,
3223
                                               gpointer data)
3224
{
3225
        if (event && event->keyval == GDK_Escape)
3226
                gtk_main_quit();
3227
        return FALSE;
3228
}
3229

    
3230
static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
3231
{
3232
        gchar *type = (gchar *)data;
3233
        gchar *title = NULL;
3234
        gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
3235
        gint rgbvalue = 0;
3236
        GtkColorSelectionDialog *dialog;
3237

    
3238
        if(g_ascii_strcasecmp(type, "LEVEL1") == 0) {
3239
                title = _("Pick color for quotation level 1");
3240
                rgbvalue = prefs_common.quote_level1_col;
3241
        } else if(g_ascii_strcasecmp(type, "LEVEL2") == 0) {
3242
                title = _("Pick color for quotation level 2");
3243
                rgbvalue = prefs_common.quote_level2_col;
3244
        } else if(g_ascii_strcasecmp(type, "LEVEL3") == 0) {
3245
                title = _("Pick color for quotation level 3");
3246
                rgbvalue = prefs_common.quote_level3_col;
3247
        } else if(g_ascii_strcasecmp(type, "URI") == 0) {
3248
                title = _("Pick color for URI");
3249
                rgbvalue = prefs_common.uri_col;
3250
        } else {   /* Should never be called */
3251
                g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
3252
                return;
3253
        }
3254

    
3255
        color_dialog = gtk_color_selection_dialog_new(title);
3256
        gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
3257
        gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
3258
        gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
3259
        manage_window_set_transient(GTK_WINDOW(color_dialog));
3260

    
3261
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
3262
                         "clicked", G_CALLBACK(quote_colors_set_dialog_ok), data);
3263
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
3264
                         "clicked", G_CALLBACK(quote_colors_set_dialog_cancel), data);
3265
        g_signal_connect(G_OBJECT(color_dialog), "key_press_event",
3266
                         G_CALLBACK(quote_colors_set_dialog_key_pressed), data);
3267

    
3268
        /* preselect the previous color in the color selection dialog */
3269
        color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
3270
        color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
3271
        color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
3272
        dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
3273
        gtk_color_selection_set_color
3274
                (GTK_COLOR_SELECTION(dialog->colorsel), color);
3275

    
3276
        gtk_widget_show(color_dialog);
3277
}
3278

    
3279
static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
3280
{
3281
        GtkColorSelection *colorsel = (GtkColorSelection *)
3282
                                                ((GtkColorSelectionDialog *)color_dialog)->colorsel;
3283
        gdouble color[4];
3284
        gint red, green, blue, rgbvalue;
3285
        gchar *type = (gchar *)data;
3286

    
3287
        gtk_color_selection_get_color(colorsel, color);
3288

    
3289
        red      = (gint) (color[0] * 255.0);
3290
        green    = (gint) (color[1] * 255.0);
3291
        blue     = (gint) (color[2] * 255.0);
3292
        rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
3293

    
3294
#if 0
3295
        fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
3296
        fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
3297
        fprintf(stderr, "Color is %x\n", rgbvalue);
3298
#endif
3299

    
3300
        if (g_ascii_strcasecmp(type, "LEVEL1") == 0) {
3301
                prefs_common.quote_level1_col = rgbvalue;
3302
                set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
3303
        } else if (g_ascii_strcasecmp(type, "LEVEL2") == 0) {
3304
                prefs_common.quote_level2_col = rgbvalue;
3305
                set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
3306
        } else if (g_ascii_strcasecmp(type, "LEVEL3") == 0) {
3307
                prefs_common.quote_level3_col = rgbvalue;
3308
                set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
3309
        } else if (g_ascii_strcasecmp(type, "URI") == 0) {
3310
                prefs_common.uri_col = rgbvalue;
3311
                set_button_bg_color(color_buttons.uri_btn, rgbvalue);
3312
        } else
3313
                fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
3314

    
3315
        gtk_widget_destroy(color_dialog);
3316
}
3317

    
3318
static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
3319
{
3320
        gtk_widget_destroy(color_dialog);
3321
}
3322

    
3323
static gboolean quote_colors_set_dialog_key_pressed(GtkWidget *widget,
3324
                                                    GdkEventKey *event,
3325
                                                    gpointer data)
3326
{
3327
        if (event && event->keyval == GDK_Escape) {
3328
                gtk_widget_destroy(color_dialog);
3329
                return TRUE;
3330
        }
3331
        return FALSE;
3332
}
3333

    
3334
static void set_button_bg_color(GtkWidget *widget, gint rgbvalue)
3335
{
3336
        GtkStyle *newstyle;
3337
        GdkColor color;
3338

    
3339
        gtkut_convert_int_to_gdk_color(rgbvalue, &color);
3340
        newstyle = gtk_style_copy(gtk_widget_get_default_style());
3341
        newstyle->bg[GTK_STATE_NORMAL]   = color;
3342
        newstyle->bg[GTK_STATE_PRELIGHT] = color;
3343
        newstyle->bg[GTK_STATE_ACTIVE]   = color;
3344

    
3345
        gtk_widget_set_style(GTK_WIDGET(widget), newstyle);
3346
}
3347

    
3348
static void prefs_enable_message_color_toggled(void)
3349
{
3350
        gboolean is_active;
3351

    
3352
        is_active = gtk_toggle_button_get_active
3353
                (GTK_TOGGLE_BUTTON(message.chkbtn_enablecol));
3354
        gtk_widget_set_sensitive(message.button_edit_col, is_active);
3355
        prefs_common.enable_color = is_active;
3356
}
3357

    
3358
static void prefs_recycle_colors_toggled(GtkWidget *widget)
3359
{
3360
        gboolean is_active;
3361

    
3362
        is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3363
        prefs_common.recycle_quote_colors = is_active;
3364
}
3365

    
3366
void prefs_quote_description(void)
3367
{
3368
        if (!quote_desc_win)
3369
                prefs_quote_description_create();
3370

    
3371
        manage_window_set_transient(GTK_WINDOW(quote_desc_win));
3372
        gtk_widget_show(quote_desc_win);
3373
        gtk_main();
3374
        gtk_widget_hide(quote_desc_win);
3375
}
3376

    
3377
static void prefs_quote_description_create(void)
3378
{
3379
        GtkWidget *vbox;
3380
        GtkWidget *hbox;
3381
        GtkWidget *vbox2;
3382
        GtkWidget *label;
3383
        GtkWidget *hbbox;
3384
        GtkWidget *ok_btn;
3385

    
3386
        quote_desc_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3387
        gtk_window_set_title(GTK_WINDOW(quote_desc_win),
3388
                             _("Description of symbols"));
3389
        gtk_container_set_border_width(GTK_CONTAINER(quote_desc_win), 8);
3390
        gtk_window_set_position(GTK_WINDOW(quote_desc_win), GTK_WIN_POS_CENTER);
3391
        gtk_window_set_modal(GTK_WINDOW(quote_desc_win), TRUE);
3392
        gtk_window_set_policy(GTK_WINDOW(quote_desc_win), FALSE, FALSE, FALSE);
3393

    
3394
        vbox = gtk_vbox_new(FALSE, 8);
3395
        gtk_container_add(GTK_CONTAINER(quote_desc_win), vbox);
3396

    
3397
        hbox = gtk_hbox_new(FALSE, 8);
3398
        gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
3399

    
3400
        vbox2 = gtk_vbox_new(FALSE, 8);
3401
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
3402

    
3403
#define PACK_LABEL() \
3404
        gtk_box_pack_start(GTK_BOX(vbox2), label, TRUE, TRUE, 0); \
3405
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); \
3406
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
3407

    
3408
        label = gtk_label_new
3409
                ("%d\n"                /* date */
3410
                 "%f\n"                /* from */
3411
                 "%N\n"                /* full name of sender */
3412
                 "%F\n"                /* first name of sender */
3413
                 "%I\n"                /* initial of sender */
3414
                 "%s\n"                /* subject */
3415
                 "%t\n"                /* to */
3416
                 "%c\n"                /* cc */
3417
                 "%n\n"                /* newsgroups */
3418
                 "%i");                /* message id */
3419
        PACK_LABEL();
3420

    
3421
        label = gtk_label_new
3422
                ("?x{expr}");        /* condition */
3423
        PACK_LABEL();
3424

    
3425
        label = gtk_label_new
3426
                ("%M\n"                /* message body */
3427
                 "%Q\n"                /* quoted message body */
3428
                 "%m\n"                /* message body without signature */
3429
                 "%q\n"                /* quoted message body without signature */
3430
                 "%%");                /* literal percent */
3431
        PACK_LABEL();
3432

    
3433
        label = gtk_label_new
3434
                ("\\\\\n"        /* literal backslash */
3435
                 "\\?\n"        /* literal question mark */
3436
                 "\\{\n"        /* literal opening curly brace */
3437
                 "\\}");        /* literal closing curly brace */
3438
        PACK_LABEL();
3439

    
3440
        vbox2 = gtk_vbox_new(FALSE, 8);
3441
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
3442

    
3443
        label = gtk_label_new
3444
                (_("Date\n"
3445
                   "From\n"
3446
                   "Full Name of Sender\n"
3447
                   "First Name of Sender\n"
3448
                   "Initial of Sender\n"
3449
                   "Subject\n"
3450
                   "To\n"
3451
                   "Cc\n"
3452
                   "Newsgroups\n"
3453
                   "Message-ID"));
3454
        PACK_LABEL();
3455

    
3456
        label = gtk_label_new
3457
                (_("If x is set, displays expr"));
3458
        PACK_LABEL();
3459

    
3460
        label = gtk_label_new
3461
                (_("Message body\n"
3462
                   "Quoted message body\n"
3463
                   "Message body without signature\n"
3464
                   "Quoted message body without signature\n"
3465
                   "Literal %"));
3466
        PACK_LABEL();
3467

    
3468
        label = gtk_label_new
3469
                (_("Literal backslash\n"
3470
                   "Literal question mark\n"
3471
                   "Literal opening curly brace\n"
3472
                   "Literal closing curly brace"));
3473
        PACK_LABEL();
3474

    
3475
#undef PACK_LABEL
3476

    
3477
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
3478
                                      NULL, NULL, NULL, NULL);
3479
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3480

    
3481
        gtk_widget_grab_default(ok_btn);
3482
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3483
                         G_CALLBACK(gtk_main_quit), NULL);
3484
        g_signal_connect
3485
                (G_OBJECT(quote_desc_win), "key_press_event",
3486
                 G_CALLBACK(prefs_quote_description_key_pressed), NULL);
3487
        g_signal_connect(G_OBJECT(quote_desc_win), "delete_event",
3488
                         G_CALLBACK(prefs_quote_description_deleted), NULL);
3489

    
3490
        gtk_widget_show_all(vbox);
3491
}
3492

    
3493
static gboolean prefs_quote_description_key_pressed(GtkWidget *widget,
3494
                                                    GdkEventKey *event,
3495
                                                    gpointer data)
3496
{
3497
        if (event && event->keyval == GDK_Escape)
3498
                gtk_main_quit();
3499
        return FALSE;
3500
}
3501

    
3502
static gboolean prefs_quote_description_deleted(GtkWidget *widget,
3503
                                                GdkEventAny *event,
3504
                                                gpointer data)
3505
{
3506
        gtk_main_quit();
3507
        return TRUE;
3508
}
3509

    
3510
static void prefs_keybind_select(void)
3511
{
3512
        GtkWidget *window;
3513
        GtkWidget *vbox1;
3514
        GtkWidget *hbox1;
3515
        GtkWidget *label;
3516
        GtkWidget *combo;
3517
        GtkWidget *confirm_area;
3518
        GtkWidget *ok_btn;
3519
        GtkWidget *cancel_btn;
3520

    
3521
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3522
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
3523
        gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
3524
        gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
3525
        gtk_window_set_modal (GTK_WINDOW (window), TRUE);
3526
        gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, FALSE);
3527
        manage_window_set_transient (GTK_WINDOW (window));
3528

    
3529
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3530
        gtk_container_add (GTK_CONTAINER (window), vbox1);
3531
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
3532

    
3533
        hbox1 = gtk_hbox_new (FALSE, 8);
3534
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3535

    
3536
        label = gtk_label_new(_("Select the preset of key bindings."));
3537
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
3538
        gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3539

    
3540
        hbox1 = gtk_hbox_new (FALSE, 8);
3541
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3542

    
3543
        combo = gtk_combo_new ();
3544
        gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
3545
        gtkut_combo_set_items (GTK_COMBO (combo),
3546
                               _("Default"),
3547
                               "Mew / Wanderlust",
3548
                               "Mutt",
3549
                               _("Old Sylpheed"),
3550
                               NULL);
3551
        gtk_editable_set_editable
3552
                (GTK_EDITABLE (GTK_COMBO (combo)->entry), FALSE);
3553

    
3554
        hbox1 = gtk_hbox_new (FALSE, 8);
3555
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3556

    
3557
        gtkut_stock_button_set_create (&confirm_area, &ok_btn, GTK_STOCK_OK,
3558
                                       &cancel_btn, GTK_STOCK_CANCEL,
3559
                                       NULL, NULL);
3560
        gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
3561
        gtk_widget_grab_default (ok_btn);
3562

    
3563
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
3564
        g_signal_connect (G_OBJECT (window), "delete_event",
3565
                          G_CALLBACK (prefs_keybind_deleted), NULL);
3566
        g_signal_connect (G_OBJECT (window), "key_press_event",
3567
                          G_CALLBACK (prefs_keybind_key_pressed), NULL);
3568
        g_signal_connect (G_OBJECT (ok_btn), "clicked",
3569
                          G_CALLBACK (prefs_keybind_apply_clicked), NULL);
3570
        g_signal_connect (G_OBJECT (cancel_btn), "clicked",
3571
                          G_CALLBACK (prefs_keybind_cancel), NULL);
3572

    
3573
        gtk_widget_show_all(window);
3574

    
3575
        keybind.window = window;
3576
        keybind.combo = combo;
3577
}
3578

    
3579
static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
3580
                                          gpointer data)
3581
{
3582
        if (event && event->keyval == GDK_Escape)
3583
                prefs_keybind_cancel();
3584
        return FALSE;
3585
}
3586

    
3587
static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
3588
                                  gpointer data)
3589
{
3590
        prefs_keybind_cancel();
3591
        return TRUE;
3592
}
3593

    
3594
static void prefs_keybind_cancel(void)
3595
{
3596
        gtk_widget_destroy(keybind.window);
3597
        keybind.window = NULL;
3598
        keybind.combo = NULL;
3599
}
3600

    
3601
struct KeyBind {
3602
        const gchar *accel_path;
3603
        const gchar *accel_key;
3604
};
3605

    
3606
static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
3607
{
3608
        gint i;
3609
        guint key;
3610
        GdkModifierType mods;
3611

    
3612
        for (i = 0; i < num; i++) {
3613
                const gchar *accel_key =
3614
                        keybind[i].accel_key ? keybind[i].accel_key : "";
3615
                gtk_accelerator_parse(accel_key, &key, &mods);
3616
                gtk_accel_map_change_entry(keybind[i].accel_path,
3617
                                           key, mods, TRUE);
3618
        }
3619
}
3620

    
3621
static void prefs_keybind_apply_clicked(GtkWidget *widget)
3622
{
3623
        GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
3624
        const gchar *text;
3625
        struct KeyBind *menurc;
3626
        gint n_menurc;
3627

    
3628
        static struct KeyBind default_menurc[] = {
3629
                {"<Main>/File/Empty all trash",                        ""},
3630
                {"<Main>/File/Save as...",                        "<control>S"},
3631
                {"<Main>/File/Print...",                        ""},
3632
                {"<Main>/File/Exit",                                "<control>Q"},
3633

    
3634
                {"<Main>/Edit/Copy",                                "<control>C"},
3635
                {"<Main>/Edit/Select all",                        "<control>A"},
3636
                {"<Main>/Edit/Find in current message...",        "<control>F"},
3637
                {"<Main>/Edit/Search messages...",                "<shift><control>F"},
3638

    
3639
                {"<Main>/View/Show or hide/Message view",        "V"},
3640
                {"<Main>/View/Thread view",                        "<control>T"},
3641
                {"<Main>/View/Go to/Prev message",                "P"},
3642
                {"<Main>/View/Go to/Next message",                "N"},
3643
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
3644
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
3645
                {"<Main>/View/Go to/Other folder...",                "G"},
3646
                {"<Main>/View/Open in new window",                "<control><alt>N"},
3647
                {"<Main>/View/View source",                        "<control>U"},
3648
                {"<Main>/View/Show all headers",                "<control>H"},
3649
                {"<Main>/View/Update",                                "<control><alt>U"},
3650

    
3651
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
3652
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
3653
                {"<Main>/Message/Compose new message",                "<control>M"},
3654
                {"<Main>/Message/Reply",                        "<control>R"},
3655
                {"<Main>/Message/Reply to/all",                        "<shift><control>R"},
3656
                {"<Main>/Message/Reply to/sender",                ""},
3657
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
3658
                {"<Main>/Message/Forward",                        "<control><alt>F"},
3659
                {"<Main>/Message/Forward as attachment",        ""},
3660
                {"<Main>/Message/Move...",                        "<control>O"},
3661
                {"<Main>/Message/Copy...",                        "<shift><control>O"},
3662
                {"<Main>/Message/Delete",                        "<control>D"},
3663
                {"<Main>/Message/Mark/Mark",                        "<shift>asterisk"},
3664
                {"<Main>/Message/Mark/Unmark",                        "U"},
3665
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
3666
                {"<Main>/Message/Mark/Mark as read",                ""},
3667

    
3668
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
3669
                {"<Main>/Tools/Execute",                        "X"},
3670
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
3671

    
3672
                {"<Compose>/File/Close",                        "<control>W"},
3673
                {"<Compose>/Edit/Select all",                        "<control>A"},
3674
        };
3675

    
3676
        static struct KeyBind mew_wl_menurc[] = {
3677
                {"<Main>/File/Empty all trash",                        "<shift>D"},
3678
                {"<Main>/File/Save as...",                        "Y"},
3679
                {"<Main>/File/Print...",                        "<shift>numbersign"},
3680
                {"<Main>/File/Exit",                                "<shift>Q"},
3681

    
3682
                {"<Main>/Edit/Copy",                                "<control>C"},
3683
                {"<Main>/Edit/Select all",                        "<control>A"},
3684
                {"<Main>/Edit/Find in current message...",        "<control>F"},
3685
                {"<Main>/Edit/Search messages...",                "<control>S"},
3686

    
3687
                {"<Main>/View/Show or hide/Message view",        "V"},
3688
                {"<Main>/View/Thread view",                        "<shift>T"},
3689
                {"<Main>/View/Go to/Prev message",                "P"},
3690
                {"<Main>/View/Go to/Next message",                "N"},
3691
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
3692
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
3693
                {"<Main>/View/Go to/Other folder...",                "G"},
3694
                {"<Main>/View/Open in new window",                "<control><alt>N"},
3695
                {"<Main>/View/View source",                        "<control>U"},
3696
                {"<Main>/View/Show all headers",                "<shift>H"},
3697
                {"<Main>/View/Update",                                "<shift>S"},
3698

    
3699
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
3700
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
3701
                {"<Main>/Message/Compose new message",                "W"},
3702
                {"<Main>/Message/Reply",                        "<control>R"},
3703
                {"<Main>/Message/Reply to/all",                        "<shift>A"},
3704
                {"<Main>/Message/Reply to/sender",                ""},
3705
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
3706
                {"<Main>/Message/Forward",                        "F"},
3707
                {"<Main>/Message/Forward as attachment",        "<shift>F"},
3708
                {"<Main>/Message/Move...",                        "O"},
3709
                {"<Main>/Message/Copy...",                        "<shift>O"},
3710
                {"<Main>/Message/Delete",                        "D"},
3711
                {"<Main>/Message/Mark/Mark",                        "<shift>asterisk"},
3712
                {"<Main>/Message/Mark/Unmark",                        "U"},
3713
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
3714
                {"<Main>/Message/Mark/Mark as read",                "<shift>R"},
3715

    
3716
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
3717
                {"<Main>/Tools/Execute",                        "X"},
3718
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
3719

    
3720
                {"<Compose>/File/Close",                        "<alt>W"},
3721
                {"<Compose>/Edit/Select all",                        ""},
3722
        };
3723

    
3724
        static struct KeyBind mutt_menurc[] = {
3725
                {"<Main>/File/Empty all trash",                        ""},
3726
                {"<Main>/File/Save as...",                        "S"},
3727
                {"<Main>/File/Print...",                        "P"},
3728
                {"<Main>/File/Exit",                                "Q"},
3729

    
3730
                {"<Main>/Edit/Copy",                                "<control>C"},
3731
                {"<Main>/Edit/Select all",                        "<control>A"},
3732
                {"<Main>/Edit/Find in current message...",        "<control>F"},
3733
                {"<Main>/Edit/Search messages...",                "slash"},
3734

    
3735
                {"<Main>/View/Show or hide/Message view",        "V"},
3736
                {"<Main>/View/Thread view",                        "<control>T"},
3737
                {"<Main>/View/Go to/Prev message",                ""},
3738
                {"<Main>/View/Go to/Next message",                ""},
3739
                {"<Main>/View/Go to/Prev unread message",        ""},
3740
                {"<Main>/View/Go to/Next unread message",        ""},
3741
                {"<Main>/View/Go to/Other folder...",                "C"},
3742
                {"<Main>/View/Open in new window",                "<control><alt>N"},
3743
                {"<Main>/View/View source",                        "<control>U"},
3744
                {"<Main>/View/Show all headers",                "<control>H"},
3745
                {"<Main>/View/Update",                                "<control><alt>U"},
3746

    
3747
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
3748
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
3749
                {"<Main>/Message/Compose new message",                "M"},
3750
                {"<Main>/Message/Reply",                        "R"},
3751
                {"<Main>/Message/Reply to/all",                        "G"},
3752
                {"<Main>/Message/Reply to/sender",                ""},
3753
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
3754
                {"<Main>/Message/Forward",                        "F"},
3755
                {"<Main>/Message/Forward as attachment",        ""},
3756
                {"<Main>/Message/Move...",                        "<control>O"},
3757
                {"<Main>/Message/Copy...",                        "<shift>C"},
3758
                {"<Main>/Message/Delete",                        "D"},
3759
                {"<Main>/Message/Mark/Mark",                        "<shift>F"},
3760
                {"<Main>/Message/Mark/Unmark",                        "U"},
3761
                {"<Main>/Message/Mark/Mark as unread",                "<shift>N"},
3762
                {"<Main>/Message/Mark/Mark as read",                ""},
3763

    
3764
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
3765
                {"<Main>/Tools/Execute",                        "X"},
3766
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
3767

    
3768
                {"<Compose>/File/Close",                        "<alt>W"},
3769
                {"<Compose>/Edit/Select all",                        ""},
3770
        };
3771

    
3772
        static struct KeyBind old_sylpheed_menurc[] = {
3773
                {"<Main>/File/Empty all trash",                        ""},
3774
                {"<Main>/File/Save as...",                        ""},
3775
                {"<Main>/File/Print...",                        "<alt>P"},
3776
                {"<Main>/File/Exit",                                "<alt>Q"},
3777

    
3778
                {"<Main>/Edit/Copy",                                "<control>C"},
3779
                {"<Main>/Edit/Select all",                        "<control>A"},
3780
                {"<Main>/Edit/Find in current message...",        "<control>F"},
3781
                {"<Main>/Edit/Search messages...",                "<control>S"},
3782

    
3783
                {"<Main>/View/Show or hide/Message view",        "V"},
3784
                {"<Main>/View/Thread view",                        "<control>T"},
3785
                {"<Main>/View/Go to/Prev message",                "P"},
3786
                {"<Main>/View/Go to/Next message",                "N"},
3787
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
3788
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
3789
                {"<Main>/View/Go to/Other folder...",                "<alt>G"},
3790
                {"<Main>/View/Open in new window",                "<shift><control>N"},
3791
                {"<Main>/View/View source",                        "<control>U"},
3792
                {"<Main>/View/Show all headers",                "<control>H"},
3793
                {"<Main>/View/Update",                                "<alt>U"},
3794

    
3795
                {"<Main>/Message/Receive/Get new mail",                        "<alt>I"},
3796
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><alt>I"},
3797
                {"<Main>/Message/Compose new message",                "<alt>N"},
3798
                {"<Main>/Message/Reply",                        "<alt>R"},
3799
                {"<Main>/Message/Reply to/all",                        "<shift><alt>R"},
3800
                {"<Main>/Message/Reply to/sender",                "<control><alt>R"},
3801
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
3802
                {"<Main>/Message/Forward",                        "<shift><alt>F"},
3803
                {"<Main>/Message/Forward as attachment",        "<shift><control>F"},
3804
                {"<Main>/Message/Move...",                        "<alt>O"},
3805
                {"<Main>/Message/Copy...",                        ""},
3806
                {"<Main>/Message/Delete",                        "<alt>D"},
3807
                {"<Main>/Message/Mark/Mark",                        "<shift>asterisk"},
3808
                {"<Main>/Message/Mark/Unmark",                        "U"},
3809
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
3810
                {"<Main>/Message/Mark/Mark as read",                ""},
3811

    
3812
                {"<Main>/Tools/Address book",                        "<alt>A"},
3813
                {"<Main>/Tools/Execute",                        "<alt>X"},
3814
                {"<Main>/Tools/Log window",                        "<alt>L"},
3815

    
3816
                {"<Compose>/File/Close",                        "<alt>W"},
3817
                {"<Compose>/Edit/Select all",                        ""},
3818
        };
3819

    
3820
        static struct KeyBind empty_menurc[] = {
3821
                {"<Main>/File/Empty all trash",                        ""},
3822
                {"<Main>/File/Save as...",                        ""},
3823
                {"<Main>/File/Print...",                        ""},
3824
                {"<Main>/File/Exit",                                ""},
3825

    
3826
                {"<Main>/Edit/Copy",                                ""},
3827
                {"<Main>/Edit/Select all",                        ""},
3828
                {"<Main>/Edit/Find in current message...",        ""},
3829
                {"<Main>/Edit/Search messages...",                ""},
3830

    
3831
                {"<Main>/View/Show or hide/Message view",        ""},
3832
                {"<Main>/View/Thread view",                        ""},
3833
                {"<Main>/View/Go to/Prev message",                ""},
3834
                {"<Main>/View/Go to/Next message",                ""},
3835
                {"<Main>/View/Go to/Prev unread message",        ""},
3836
                {"<Main>/View/Go to/Next unread message",        ""},
3837
                {"<Main>/View/Go to/Other folder...",                ""},
3838
                {"<Main>/View/Open in new window",                ""},
3839
                {"<Main>/View/View source",                        ""},
3840
                {"<Main>/View/Show all headers",                ""},
3841
                {"<Main>/View/Update",                                ""},
3842

    
3843
                {"<Main>/Message/Receive/Get new mail",                        ""},
3844
                {"<Main>/Message/Receive/Get from all accounts",        ""},
3845
                {"<Main>/Message/Compose new message",                ""},
3846
                {"<Main>/Message/Reply",                        ""},
3847
                {"<Main>/Message/Reply to/all",                        ""},
3848
                {"<Main>/Message/Reply to/sender",                ""},
3849
                {"<Main>/Message/Reply to/mailing list",        ""},
3850
                {"<Main>/Message/Forward",                        ""},
3851
                {"<Main>/Message/Forward as attachment",        ""},
3852
                {"<Main>/Message/Move...",                        ""},
3853
                {"<Main>/Message/Copy...",                        ""},
3854
                {"<Main>/Message/Delete",                        ""},
3855
                {"<Main>/Message/Mark/Mark",                        ""},
3856
                {"<Main>/Message/Mark/Unmark",                        ""},
3857
                {"<Main>/Message/Mark/Mark as unread",                ""},
3858
                {"<Main>/Message/Mark/Mark as read",                ""},
3859

    
3860
                {"<Main>/Tools/Address book",                        ""},
3861
                {"<Main>/Tools/Execute",                        ""},
3862
                {"<Main>/Tools/Log window",                        ""},
3863

    
3864
                {"<Compose>/File/Close",                        ""},
3865
                {"<Compose>/Edit/Select all",                        ""},
3866
        };
3867

    
3868
        text = gtk_entry_get_text(entry);
3869

    
3870
        if (!strcmp(text, _("Default"))) {
3871
                menurc = default_menurc;
3872
                n_menurc = G_N_ELEMENTS(default_menurc);
3873
        } else if (!strcmp(text, "Mew / Wanderlust")) {
3874
                menurc = mew_wl_menurc;
3875
                n_menurc = G_N_ELEMENTS(mew_wl_menurc);
3876
        } else if (!strcmp(text, "Mutt")) {
3877
                menurc = mutt_menurc;
3878
                n_menurc = G_N_ELEMENTS(mutt_menurc);
3879
        } else if (!strcmp(text, _("Old Sylpheed"))) {
3880
                menurc = old_sylpheed_menurc;
3881
                n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
3882
        } else
3883
                return;
3884

    
3885
        prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc));
3886
        prefs_keybind_apply(menurc, n_menurc);
3887

    
3888
        gtk_widget_destroy(keybind.window);
3889
        keybind.window = NULL;
3890
        keybind.combo = NULL;
3891
}
3892

    
3893
static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
3894
{
3895
        PrefsUIData *ui_data;
3896
        GtkWidget *menu;
3897
        GtkWidget *menuitem;
3898
        gchar *charset;
3899

    
3900
        ui_data = (PrefsUIData *)pparam->ui_data;
3901
        g_return_if_fail(ui_data != NULL);
3902
        g_return_if_fail(*ui_data->widget != NULL);
3903

    
3904
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*ui_data->widget));
3905
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
3906
        charset = g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
3907
        g_free(*((gchar **)pparam->data));
3908
        *((gchar **)pparam->data) = g_strdup(charset);
3909
}
3910

    
3911
static void prefs_common_charset_set_optmenu(PrefParam *pparam)
3912
{
3913
        PrefsUIData *ui_data;
3914
        GtkOptionMenu *optmenu;
3915
        gint index;
3916

    
3917
        ui_data = (PrefsUIData *)pparam->ui_data;
3918
        g_return_if_fail(ui_data != NULL);
3919
        g_return_if_fail(*ui_data->widget != NULL);
3920

    
3921
        optmenu = GTK_OPTION_MENU(*ui_data->widget);
3922
        g_return_if_fail(optmenu != NULL);
3923

    
3924
        index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
3925
                                            (GCompareFunc)strcmp2);
3926
        if (index >= 0)
3927
                gtk_option_menu_set_history(optmenu, index);
3928
        else {
3929
                gtk_option_menu_set_history(optmenu, 0);
3930
                prefs_common_charset_set_data_from_optmenu(pparam);
3931
        }
3932
}
3933

    
3934
static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
3935
{
3936
        PrefsUIData *ui_data;
3937
        RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
3938
        GtkOptionMenu *optmenu;
3939
        GtkWidget *menu;
3940
        GtkWidget *menuitem;
3941
        gint index;
3942

    
3943
        ui_data = (PrefsUIData *)pparam->ui_data;
3944
        g_return_if_fail(ui_data != NULL);
3945
        g_return_if_fail(*ui_data->widget != NULL);
3946

    
3947
        optmenu = GTK_OPTION_MENU(*ui_data->widget);
3948
        g_return_if_fail(optmenu != NULL);
3949

    
3950
        index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(mode),
3951
                                            NULL);
3952
        if (index >= 0)
3953
                gtk_option_menu_set_history(optmenu, index);
3954
        else {
3955
                gtk_option_menu_set_history(optmenu, 0);
3956
                prefs_set_data_from_optmenu(pparam);
3957
        }
3958

    
3959
        menu = gtk_option_menu_get_menu(optmenu);
3960
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
3961
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3962
}
3963

    
3964
static void prefs_common_uri_set_data_from_entry(PrefParam *pparam)
3965
{
3966
        PrefsUIData *ui_data;
3967
        gchar **str;
3968
        const gchar *entry_str;
3969

    
3970
        ui_data = (PrefsUIData *)pparam->ui_data;
3971
        g_return_if_fail(ui_data != NULL);
3972
        g_return_if_fail(*ui_data->widget != NULL);
3973

    
3974
        entry_str = gtk_entry_get_text(GTK_ENTRY(*ui_data->widget));
3975

    
3976
        if (pparam->type == P_STRING) {
3977
                str = (gchar **)pparam->data;
3978
                g_free(*str);
3979

    
3980
                if (entry_str[0] == '\0' ||
3981
                    !strcmp(_("(Default browser)"), entry_str))
3982
                        *str = NULL;
3983
                else
3984
                        *str = g_strdup(entry_str);
3985
        } else {
3986
                g_warning("Invalid type for URI setting\n");
3987
        }
3988
}
3989

    
3990
static void prefs_common_uri_set_entry(PrefParam *pparam)
3991
{
3992
        PrefsUIData *ui_data;
3993
        gchar **str;
3994

    
3995
        ui_data = (PrefsUIData *)pparam->ui_data;
3996
        g_return_if_fail(ui_data != NULL);
3997
        g_return_if_fail(*ui_data->widget != NULL);
3998

    
3999
        if (pparam->type == P_STRING) {
4000
                str = (gchar **)pparam->data;
4001
                gtk_entry_set_text(GTK_ENTRY(*ui_data->widget),
4002
                                   *str ? *str : _("(Default browser)"));
4003
        } else {
4004
                g_warning("Invalid type for URI setting\n");
4005
        }
4006
}
4007

    
4008
static void prefs_common_dispitem_clicked(void)
4009
{
4010
        prefs_summary_column_open(FOLDER_ITEM_IS_SENT_FOLDER
4011
                (main_window_get()->summaryview->folder_item));
4012
}
4013

    
4014
static void prefs_common_select_folder_cb(GtkWidget *widget, gpointer data)
4015
{
4016
        FolderItem *item;
4017
        gchar *id;
4018

    
4019
        item = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
4020
        if (item && item->path) {
4021
                id = folder_item_get_identifier(item);
4022
                if (id) {
4023
                        gtk_entry_set_text(GTK_ENTRY(data), id);
4024
                        g_free(id);
4025
                }
4026
        }
4027
}
4028

    
4029
static gint prefs_common_deleted(GtkWidget *widget, GdkEventAny *event,
4030
                                 gpointer data)
4031
{
4032
        prefs_common_cancel();
4033
        return TRUE;
4034
}
4035

    
4036
static gboolean prefs_common_key_pressed(GtkWidget *widget, GdkEventKey *event,
4037
                                         gpointer data)
4038
{
4039
        if (event && event->keyval == GDK_Escape)
4040
                prefs_common_cancel();
4041
        return FALSE;
4042
}
4043

    
4044
static void prefs_common_ok(void)
4045
{
4046
        prefs_common_apply();
4047
        gtk_widget_hide(dialog.window);
4048
        if (quote_desc_win && GTK_WIDGET_VISIBLE(quote_desc_win))
4049
                gtk_widget_hide(quote_desc_win);
4050

    
4051
        main_window_popup(main_window_get());
4052
        inc_unlock();
4053
}
4054

    
4055
static void prefs_common_apply(void)
4056
{
4057
        prefs_set_data_from_dialog(prefs_common_get_params());
4058
        prefs_common_junk_filter_list_set();
4059
        gtkut_stock_button_set_set_reverse(!prefs_common.comply_gnome_hig);
4060
        main_window_reflect_prefs_all();
4061
        compose_reflect_prefs_all();
4062
        sock_set_io_timeout(prefs_common.io_timeout_secs);
4063
        prefs_common_write_config();
4064

    
4065
        inc_autocheck_timer_remove();
4066
        inc_autocheck_timer_set();
4067
}
4068

    
4069
static void prefs_common_cancel(void)
4070
{
4071
        gtk_widget_hide(dialog.window);
4072
        main_window_popup(main_window_get());
4073
        inc_unlock();
4074
}