Statistics
| Revision:

root / src / prefs_common_dialog.c @ 3212

History | View | Annotate | Download (149 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2013 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 "filesel.h"
51
#include "inc.h"
52
#include "menu.h"
53
#include "colorlabel.h"
54
#include "codeconv.h"
55
#include "utils.h"
56
#include "gtkutils.h"
57
#include "alertpanel.h"
58
#include "folder.h"
59
#include "socket.h"
60
#include "plugin.h"
61

    
62
static PrefsDialog dialog;
63

    
64
static struct Receive {
65
        GtkWidget *checkbtn_autochk;
66
        GtkWidget *spinbtn_autochk;
67
        GtkObject *spinbtn_autochk_adj;
68

    
69
        GtkWidget *checkbtn_chkonstartup;
70
        GtkWidget *checkbtn_scan_after_inc;
71

    
72
        GtkWidget *checkbtn_newmsg_notify_window;
73
#ifdef G_OS_WIN32
74
        GtkWidget *checkbtn_newmsg_sound;
75
        GtkWidget *entry_newmsg_sound;
76
#endif
77
        GtkWidget *checkbtn_newmsg_notify;
78
        GtkWidget *entry_newmsg_notify;
79

    
80
#ifndef G_OS_WIN32
81
        GtkWidget *checkbtn_local;
82
        GtkWidget *checkbtn_filter_on_inc;
83
        GtkWidget *entry_spool;
84
#endif
85
} receive;
86

    
87
static struct Send {
88
        GtkWidget *checkbtn_savemsg;
89
        GtkWidget *checkbtn_filter_sent;
90
        GtkWidget *checkbtn_recipients_autoreg;
91
        GtkWidget *checkbtn_show_send_dialog;
92

    
93
        GtkWidget *optmenu_encoding_method;
94
        GtkWidget *optmenu_mime_fencoding_method;
95

    
96
        GtkWidget *checkbtn_check_attach;
97
        GtkWidget *entry_check_attach_str;
98
        GtkWidget *checkbtn_check_recp;
99
        GtkWidget *entry_check_recp_excl;
100
} p_send;
101

    
102
static struct Compose {
103
        GtkWidget *checkbtn_autosig;
104
        GtkWidget *entry_sigsep;
105

    
106
        GtkWidget *checkbtn_autoextedit;
107
        GtkWidget *spinbtn_undolevel;
108
        GtkObject *spinbtn_undolevel_adj;
109
        GtkWidget *spinbtn_linewrap;
110
        GtkObject *spinbtn_linewrap_adj;
111
        GtkWidget *checkbtn_wrapquote;
112
        GtkWidget *checkbtn_autowrap;
113

    
114
        GtkWidget *checkbtn_autosave;
115
        GtkWidget *spinbtn_autosave;
116
        GtkObject *spinbtn_autosave_adj;
117

    
118
        GtkWidget *checkbtn_reply_account_autosel;
119
        GtkWidget *checkbtn_quote;
120
        GtkWidget *checkbtn_default_reply_list;
121
        GtkWidget *checkbtn_inherit_recipient_on_self_reply;
122
        GtkWidget *checkbtn_reply_address_only;
123
} compose;
124

    
125
static struct Quote {
126
        GtkWidget *entry_quotemark;
127
        GtkWidget *text_quotefmt;
128

    
129
        GtkWidget *entry_fw_quotemark;
130
        GtkWidget *text_fw_quotefmt;
131
} quote;
132

    
133
#if USE_GTKSPELL
134
static struct Spell {
135
        GtkWidget *chkbtn_enable_spell;
136
        GtkWidget *entry_spell_lang;
137
} spell;
138
#endif
139

    
140
static struct Display {
141
        GtkWidget *fontbtn_textfont;
142

    
143
        GtkWidget *chkbtn_folder_unread;
144
        GtkWidget *chkbtn_folder_col_new;
145
        GtkWidget *chkbtn_folder_col_unread;
146
        GtkWidget *chkbtn_folder_col_total;
147
        GtkWidget *entry_ng_abbrev_len;
148
        GtkWidget *spinbtn_ng_abbrev_len;
149
        GtkObject *spinbtn_ng_abbrev_len_adj;
150

    
151
        GtkWidget *chkbtn_swapfrom;
152
        GtkWidget *chkbtn_expand_thread;
153
        GtkWidget *entry_datefmt;
154

    
155
        GtkWidget *optmenu_dispencoding;
156
        GtkWidget *optmenu_outencoding;
157
} display;
158

    
159
static struct Message {
160
        GtkWidget *chkbtn_enablecol;
161
        GtkWidget *button_edit_col;
162
        GtkWidget *chkbtn_disphdrpane;
163
        GtkWidget *chkbtn_disphdr;
164
        GtkWidget *chkbtn_html;
165
        GtkWidget *chkbtn_htmlonly;
166
        GtkWidget *spinbtn_linespc;
167
        GtkObject *spinbtn_linespc_adj;
168

    
169
        GtkWidget *chkbtn_smoothscroll;
170
        GtkWidget *spinbtn_scrollstep;
171
        GtkObject *spinbtn_scrollstep_adj;
172
        GtkWidget *chkbtn_halfpage;
173
} message;
174

    
175
static struct Attach {
176
        GtkWidget *radiobtn_attach_toolbtn_pos;
177
        GtkWidget *chkbtn_show_attach_tab;
178
        GtkWidget *chkbtn_show_files_first;
179

    
180
        GtkWidget *chkbtn_resize_image;
181
        GtkWidget *chkbtn_inline_image;
182
} attach;
183

    
184
static struct ColorLabel {
185
        GtkWidget *entry_color[7];
186
} colorlabel;
187

    
188
static struct JunkMail {
189
        GtkWidget *chkbtn_enable_junk;
190
        GtkWidget *entry_junk_learncmd;
191
        GtkWidget *entry_nojunk_learncmd;
192
        GtkWidget *entry_classify_cmd;
193
        GtkWidget *entry_junkfolder;
194
        GtkWidget *chkbtn_filter_on_recv;
195
        GtkWidget *chkbtn_filter_before;
196
        GtkWidget *chkbtn_delete_on_recv;
197
        GtkWidget *chkbtn_mark_as_read;
198
} junk;
199

    
200
#if USE_GPGME
201
static struct Privacy {
202
        GtkWidget *checkbtn_auto_check_signatures;
203
        GtkWidget *checkbtn_gpg_signature_popup;
204
        GtkWidget *checkbtn_store_passphrase;
205
        GtkWidget *spinbtn_store_passphrase;
206
        GtkObject *spinbtn_store_passphrase_adj;
207
#ifndef G_OS_WIN32
208
        GtkWidget *checkbtn_passphrase_grab;
209
#endif
210
        GtkWidget *checkbtn_gpg_warning;
211
} privacy;
212
#endif
213

    
214
static struct Interface {
215
        GtkWidget *checkbtn_always_show_msg;
216
        GtkWidget *checkbtn_always_mark_read;
217
        GtkWidget *checkbtn_openunread;
218
        GtkWidget *checkbtn_remember_lastsel;
219
        /* GtkWidget *checkbtn_mark_as_read_on_newwin; */
220
        GtkWidget *checkbtn_openinbox;
221
        GtkWidget *checkbtn_openinbox_startup;
222
        GtkWidget *checkbtn_change_account_on_folder_sel;
223
        GtkWidget *checkbtn_immedexec;
224
#ifndef G_OS_WIN32
225
        GtkWidget *checkbtn_comply_gnome_hig;
226
#endif
227
        GtkWidget *checkbtn_show_trayicon;
228
        GtkWidget *checkbtn_minimize_to_tray;
229
        GtkWidget *checkbtn_tray_toggle_window;
230
} iface;
231

    
232
static struct Other {
233
        GtkWidget *optmenu_recvdialog;
234
        GtkWidget *checkbtn_no_recv_err_panel;
235
        GtkWidget *checkbtn_close_recv_dialog;
236

    
237
        GtkWidget *checkbtn_addaddrbyclick;
238
        GtkWidget *checkbtn_add_address_only;
239
        GtkWidget *radiobtn_addr_compl;
240

    
241
        GtkWidget *checkbtn_confonexit;
242
        GtkWidget *checkbtn_cleanonexit;
243
        GtkWidget *checkbtn_askonclean;
244
        GtkWidget *checkbtn_warnqueued;
245
} other;
246

    
247
static struct Extcmd {
248
        GtkWidget *uri_combo;
249
        GtkWidget *uri_entry;
250
        GtkWidget *exteditor_combo;
251
        GtkWidget *exteditor_entry;
252

    
253
        GtkWidget *checkbtn_printcmd;
254
        GtkWidget *printcmd_entry;
255

    
256
        GtkWidget *checkbtn_incext;
257
        GtkWidget *entry_incext;
258
        GtkWidget *button_incext;
259

    
260
        GtkWidget *checkbtn_extsend;
261
        GtkWidget *entry_extsend;
262
        GtkWidget *button_extsend;
263
} extcmd;
264

    
265
#if USE_UPDATE_CHECK
266
static struct UpdateCheck {
267
        GtkWidget *checkbtn_autoupdate;
268
        GtkWidget *checkbtn_useproxy;
269
        GtkWidget *entry_proxyhost;
270
} update_check;
271
#endif
272

    
273
static struct Advanced {
274
        GtkWidget *checkbtn_strict_cache_check;
275

    
276
        GtkWidget *spinbtn_iotimeout;
277
        GtkObject *spinbtn_iotimeout_adj;
278
} advanced;
279

    
280
static struct MessageColorButtons {
281
        GtkWidget *quote_level1_btn;
282
        GtkWidget *quote_level2_btn;
283
        GtkWidget *quote_level3_btn;
284
        GtkWidget *uri_btn;
285
} color_buttons;
286

    
287
static struct KeybindDialog {
288
        GtkWidget *window;
289
        GtkWidget *combo;
290
} keybind;
291

    
292
static GtkWidget *quote_desc_win;
293
static GtkWidget *quote_color_win;
294
static GtkWidget *color_dialog;
295

    
296
static void prefs_common_charset_set_data_from_optmenu           (PrefParam *pparam);
297
static void prefs_common_charset_set_optmenu                   (PrefParam *pparam);
298
static void prefs_common_recv_dialog_set_optmenu           (PrefParam *pparam);
299
static void prefs_common_uri_set_data_from_entry           (PrefParam *pparam);
300
static void prefs_common_uri_set_entry                           (PrefParam *pparam);
301

    
302
static void prefs_common_addr_compl_set_data_from_radiobtn (PrefParam *pparam);
303
static void prefs_common_addr_compl_set_radiobtn           (PrefParam *pparam);
304

    
305
static void prefs_common_attach_toolbtn_pos_set_data_from_radiobtn (PrefParam *pparam);
306
static void prefs_common_attach_toolbtn_pos_set_radiobtn           (PrefParam *pparam);
307

    
308
static PrefsUIData ui_data[] = {
309
        /* Receive */
310
        {"autochk_newmail", &receive.checkbtn_autochk,
311
         prefs_set_data_from_toggle, prefs_set_toggle},
312
        {"autochk_interval", &receive.spinbtn_autochk,
313
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
314
        {"check_on_startup", &receive.checkbtn_chkonstartup,
315
         prefs_set_data_from_toggle, prefs_set_toggle},
316
        {"scan_all_after_inc", &receive.checkbtn_scan_after_inc,
317
         prefs_set_data_from_toggle, prefs_set_toggle},
318
        {"enable_newmsg_notify", &receive.checkbtn_newmsg_notify,
319
         prefs_set_data_from_toggle, prefs_set_toggle},
320
        {"newmsg_notify_command", &receive.entry_newmsg_notify,
321
         prefs_set_data_from_entry, prefs_set_entry},
322
#ifdef G_OS_WIN32
323
        {"enable_newmsg_notify_sound", &receive.checkbtn_newmsg_sound,
324
         prefs_set_data_from_toggle, prefs_set_toggle},
325
        {"newmsg_notify_sound", &receive.entry_newmsg_sound,
326
         prefs_set_data_from_entry, prefs_set_entry},
327
#endif
328
        {"enable_newmsg_notify_window", &receive.checkbtn_newmsg_notify_window,
329
         prefs_set_data_from_toggle, prefs_set_toggle},
330

    
331
#ifndef G_OS_WIN32
332
        {"inc_local", &receive.checkbtn_local,
333
         prefs_set_data_from_toggle, prefs_set_toggle},
334
        {"filter_on_inc_local", &receive.checkbtn_filter_on_inc,
335
         prefs_set_data_from_toggle, prefs_set_toggle},
336
        {"spool_path", &receive.entry_spool,
337
         prefs_set_data_from_entry, prefs_set_entry},
338
#endif
339

    
340
        /* Send */
341
        {"save_message", &p_send.checkbtn_savemsg,
342
         prefs_set_data_from_toggle, prefs_set_toggle},
343
        {"filter_sent_message", &p_send.checkbtn_filter_sent,
344
         prefs_set_data_from_toggle, prefs_set_toggle},
345
        {"recipients_autoreg", &p_send.checkbtn_recipients_autoreg,
346
         prefs_set_data_from_toggle, prefs_set_toggle},
347
        {"show_send_dialog", &p_send.checkbtn_show_send_dialog,
348
         prefs_set_data_from_toggle, prefs_set_toggle},
349

    
350
        {"encoding_method", &p_send.optmenu_encoding_method,
351
         prefs_set_data_from_optmenu, prefs_set_optmenu},
352
        {"mime_filename_encoding_method", &p_send.optmenu_mime_fencoding_method,
353
         prefs_set_data_from_optmenu, prefs_set_optmenu},
354
        {"check_attach", &p_send.checkbtn_check_attach,
355
         prefs_set_data_from_toggle, prefs_set_toggle},
356
        {"check_attach_str", &p_send.entry_check_attach_str,
357
         prefs_set_data_from_entry, prefs_set_entry},
358
        {"check_recipients", &p_send.checkbtn_check_recp,
359
         prefs_set_data_from_toggle, prefs_set_toggle},
360
        {"check_recp_exclude", &p_send.entry_check_recp_excl,
361
         prefs_set_data_from_entry, prefs_set_entry},
362

    
363
        /* {"allow_jisx0201_kana", NULL, NULL, NULL}, */
364

    
365
        /* Compose */
366
        {"auto_signature", &compose.checkbtn_autosig,
367
         prefs_set_data_from_toggle, prefs_set_toggle},
368
        {"signature_separator", &compose.entry_sigsep,
369
         prefs_set_data_from_entry, prefs_set_entry},
370

    
371
        {"auto_ext_editor", &compose.checkbtn_autoextedit,
372
         prefs_set_data_from_toggle, prefs_set_toggle},
373

    
374
        {"undo_level", &compose.spinbtn_undolevel,
375
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
376

    
377
        {"linewrap_length", &compose.spinbtn_linewrap,
378
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
379
        {"linewrap_quotation", &compose.checkbtn_wrapquote,
380
         prefs_set_data_from_toggle, prefs_set_toggle},
381
        {"linewrap_auto", &compose.checkbtn_autowrap,
382
         prefs_set_data_from_toggle, prefs_set_toggle},
383

    
384
        {"enable_autosave", &compose.checkbtn_autosave,
385
         prefs_set_data_from_toggle, prefs_set_toggle},
386
        {"autosave_interval", &compose.spinbtn_autosave,
387
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
388

    
389
        {"reply_with_quote", &compose.checkbtn_quote,
390
         prefs_set_data_from_toggle, prefs_set_toggle},
391
        {"reply_account_autoselect",
392
         &compose.checkbtn_reply_account_autosel,
393
         prefs_set_data_from_toggle, prefs_set_toggle},
394
        {"default_reply_list", &compose.checkbtn_default_reply_list,
395
         prefs_set_data_from_toggle, prefs_set_toggle},
396
        {"inherit_recipient_on_self_reply",
397
         &compose.checkbtn_inherit_recipient_on_self_reply,
398
         prefs_set_data_from_toggle, prefs_set_toggle},
399
        {"reply_address_only",
400
         &compose.checkbtn_reply_address_only,
401
         prefs_set_data_from_toggle, prefs_set_toggle},
402

    
403
        /* {"show_ruler", NULL, NULL, NULL}, */
404

    
405
        /* Quote */
406
        {"reply_quote_mark", &quote.entry_quotemark,
407
         prefs_set_data_from_entry, prefs_set_entry},
408
        {"reply_quote_format", &quote.text_quotefmt,
409
         prefs_set_data_from_text, prefs_set_text},
410

    
411
        {"forward_quote_mark", &quote.entry_fw_quotemark,
412
         prefs_set_data_from_entry, prefs_set_entry},
413
        {"forward_quote_format", &quote.text_fw_quotefmt,
414
         prefs_set_data_from_text, prefs_set_text},
415

    
416
#if USE_GTKSPELL
417
        /* Spelling */
418
        {"check_spell", &spell.chkbtn_enable_spell,
419
         prefs_set_data_from_toggle, prefs_set_toggle},
420
        {"spell_lang",  &spell.entry_spell_lang,
421
         prefs_set_data_from_entry, prefs_set_entry},
422
#endif
423

    
424
        /* Display */
425
        {"message_font_name", &display.fontbtn_textfont,
426
         prefs_set_data_from_fontbtn, prefs_set_fontbtn},
427

    
428
        {"display_folder_unread_num", &display.chkbtn_folder_unread,
429
         prefs_set_data_from_toggle, prefs_set_toggle},
430
        {"folder_col_show_new", &display.chkbtn_folder_col_new,
431
         prefs_set_data_from_toggle, prefs_set_toggle},
432
        {"folder_col_show_unread", &display.chkbtn_folder_col_unread,
433
         prefs_set_data_from_toggle, prefs_set_toggle},
434
        {"folder_col_show_total", &display.chkbtn_folder_col_total,
435
         prefs_set_data_from_toggle, prefs_set_toggle},
436
        {"newsgroup_abbrev_len", &display.spinbtn_ng_abbrev_len,
437
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
438

    
439
        /* Display: Summary View */
440
        {"enable_swap_from", &display.chkbtn_swapfrom,
441
         prefs_set_data_from_toggle, prefs_set_toggle},
442
        {"date_format", &display.entry_datefmt,
443
         prefs_set_data_from_entry, prefs_set_entry},
444
        {"expand_thread", &display.chkbtn_expand_thread,
445
         prefs_set_data_from_toggle, prefs_set_toggle},
446

    
447
#if 0
448
        {"enable_rules_hint", NULL, NULL, NULL},
449
#endif /* 0 */
450

    
451
        /* Message */
452
        {"enable_color", &message.chkbtn_enablecol,
453
         prefs_set_data_from_toggle, prefs_set_toggle},
454

    
455
#if 0
456
        {"convert_mb_alnum", &message.chkbtn_mbalnum,
457
         prefs_set_data_from_toggle, prefs_set_toggle},
458
#endif
459
        {"display_header_pane", &message.chkbtn_disphdrpane,
460
         prefs_set_data_from_toggle, prefs_set_toggle},
461
        {"display_header", &message.chkbtn_disphdr,
462
         prefs_set_data_from_toggle, prefs_set_toggle},
463
        {"render_html", &message.chkbtn_html,
464
         prefs_set_data_from_toggle, prefs_set_toggle},
465
        {"html_only_as_attach", &message.chkbtn_htmlonly,
466
         prefs_set_data_from_toggle, prefs_set_toggle},
467
        {"line_space", &message.spinbtn_linespc,
468
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
469

    
470
        /* {"textview_cursor_visible", NULL, NULL, NULL}, */
471

    
472
        {"enable_smooth_scroll", &message.chkbtn_smoothscroll,
473
         prefs_set_data_from_toggle, prefs_set_toggle},
474
        {"scroll_step", &message.spinbtn_scrollstep,
475
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
476
        {"scroll_half_page", &message.chkbtn_halfpage,
477
         prefs_set_data_from_toggle, prefs_set_toggle},
478

    
479
        /* Attachment */
480
        {"attach_toolbutton_pos", &attach.radiobtn_attach_toolbtn_pos,
481
         prefs_common_attach_toolbtn_pos_set_data_from_radiobtn,
482
         prefs_common_attach_toolbtn_pos_set_radiobtn},
483
        {"show_attach_tab", &attach.chkbtn_show_attach_tab,
484
         prefs_set_data_from_toggle, prefs_set_toggle},
485
        {"show_attached_files_first", &attach.chkbtn_show_files_first,
486
         prefs_set_data_from_toggle, prefs_set_toggle},
487

    
488
        {"resize_image", &attach.chkbtn_resize_image,
489
         prefs_set_data_from_toggle, prefs_set_toggle},
490
        {"inline_image", &attach.chkbtn_inline_image,
491
         prefs_set_data_from_toggle, prefs_set_toggle},
492

    
493
        /* Encoding */
494
        {"default_encoding", &display.optmenu_dispencoding,
495
         prefs_common_charset_set_data_from_optmenu,
496
         prefs_common_charset_set_optmenu},
497
        {"outgoing_charset", &display.optmenu_outencoding,
498
         prefs_common_charset_set_data_from_optmenu,
499
         prefs_common_charset_set_optmenu},
500

    
501
        /* Junk mail */
502
        {"enable_junk", &junk.chkbtn_enable_junk,
503
         prefs_set_data_from_toggle, prefs_set_toggle},
504
        {"junk_learn_command", &junk.entry_junk_learncmd,
505
         prefs_set_data_from_entry, prefs_set_entry},
506
        {"nojunk_learn_command", &junk.entry_nojunk_learncmd,
507
         prefs_set_data_from_entry, prefs_set_entry},
508
        {"junk_classify_command", &junk.entry_classify_cmd,
509
         prefs_set_data_from_entry, prefs_set_entry},
510
        {"junk_folder", &junk.entry_junkfolder,
511
         prefs_set_data_from_entry, prefs_set_entry},
512
        {"filter_junk_on_receive", &junk.chkbtn_filter_on_recv,
513
         prefs_set_data_from_toggle, prefs_set_toggle},
514
        {"filter_junk_before", &junk.chkbtn_filter_before,
515
         prefs_set_data_from_toggle, prefs_set_toggle},
516
        {"delete_junk_on_receive", &junk.chkbtn_delete_on_recv,
517
         prefs_set_data_from_toggle, prefs_set_toggle},
518
        {"mark_junk_as_read", &junk.chkbtn_mark_as_read,
519
         prefs_set_data_from_toggle, prefs_set_toggle},
520

    
521
#if USE_GPGME
522
        /* Privacy */
523
        {"auto_check_signatures",
524
         &privacy.checkbtn_auto_check_signatures,
525
         prefs_set_data_from_toggle, prefs_set_toggle},
526
        {"gpg_signature_popup", &privacy.checkbtn_gpg_signature_popup,
527
         prefs_set_data_from_toggle, prefs_set_toggle},
528
        {"store_passphrase", &privacy.checkbtn_store_passphrase,
529
         prefs_set_data_from_toggle, prefs_set_toggle},
530
        {"store_passphrase_timeout", &privacy.spinbtn_store_passphrase,
531
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
532
#ifndef G_OS_WIN32
533
        {"passphrase_grab", &privacy.checkbtn_passphrase_grab,
534
         prefs_set_data_from_toggle, prefs_set_toggle},
535
#endif /* G_OS_WIN32 */
536
        {"show_gpg_warning", &privacy.checkbtn_gpg_warning,
537
         prefs_set_data_from_toggle, prefs_set_toggle},
538
#endif /* USE_GPGME */
539

    
540
        /* Interface */
541
        {"always_show_message_when_selected",
542
         &iface.checkbtn_always_show_msg,
543
         prefs_set_data_from_toggle, prefs_set_toggle},
544
        {"always_mark_read_on_show_msg", &iface.checkbtn_always_mark_read,
545
         prefs_set_data_from_toggle, prefs_set_toggle},
546
        {"open_unread_on_enter", &iface.checkbtn_openunread,
547
         prefs_set_data_from_toggle, prefs_set_toggle},
548
        {"remember_last_selected", &iface.checkbtn_remember_lastsel,
549
         prefs_set_data_from_toggle, prefs_set_toggle},
550
#if 0
551
        {"mark_as_read_on_new_window",
552
         &iface.checkbtn_mark_as_read_on_newwin,
553
         prefs_set_data_from_toggle, prefs_set_toggle},
554
#endif
555
        {"open_inbox_on_inc", &iface.checkbtn_openinbox,
556
         prefs_set_data_from_toggle, prefs_set_toggle},
557
        {"open_inbox_on_startup", &iface.checkbtn_openinbox_startup,
558
         prefs_set_data_from_toggle, prefs_set_toggle},
559
        {"change_account_on_folder_selection",
560
         &iface.checkbtn_change_account_on_folder_sel,
561
         prefs_set_data_from_toggle, prefs_set_toggle},
562
        {"immediate_execution", &iface.checkbtn_immedexec,
563
         prefs_set_data_from_toggle, prefs_set_toggle},
564

    
565
#ifndef G_OS_WIN32
566
        {"comply_gnome_hig", &iface.checkbtn_comply_gnome_hig,
567
         prefs_set_data_from_toggle, prefs_set_toggle},
568
#endif
569
        {"show_trayicon", &iface.checkbtn_show_trayicon,
570
         prefs_set_data_from_toggle, prefs_set_toggle},
571
        {"minimize_to_tray", &iface.checkbtn_minimize_to_tray,
572
         prefs_set_data_from_toggle, prefs_set_toggle},
573
        {"toggle_window_on_trayicon_click",
574
         &iface.checkbtn_tray_toggle_window,
575
         prefs_set_data_from_toggle, prefs_set_toggle},
576

    
577
        /* Other */
578
        {"receive_dialog_mode", &other.optmenu_recvdialog,
579
         prefs_set_data_from_optmenu, prefs_common_recv_dialog_set_optmenu},
580
        {"no_receive_error_panel", &other.checkbtn_no_recv_err_panel,
581
         prefs_set_data_from_toggle, prefs_set_toggle},
582
        {"close_receive_dialog", &other.checkbtn_close_recv_dialog,
583
         prefs_set_data_from_toggle, prefs_set_toggle},
584

    
585
        {"add_address_by_click", &other.checkbtn_addaddrbyclick,
586
         prefs_set_data_from_toggle, prefs_set_toggle},
587
        {"always_add_address_only", &other.checkbtn_add_address_only,
588
         prefs_set_data_from_toggle, prefs_set_toggle},
589
        {"enable_address_completion", &other.radiobtn_addr_compl,
590
         prefs_common_addr_compl_set_data_from_radiobtn,
591
         prefs_common_addr_compl_set_radiobtn},
592

    
593
        {"confirm_on_exit", &other.checkbtn_confonexit,
594
         prefs_set_data_from_toggle, prefs_set_toggle},
595
        {"clean_trash_on_exit", &other.checkbtn_cleanonexit,
596
         prefs_set_data_from_toggle, prefs_set_toggle},
597
        {"ask_on_cleaning", &other.checkbtn_askonclean,
598
         prefs_set_data_from_toggle, prefs_set_toggle},
599
        {"warn_queued_on_exit", &other.checkbtn_warnqueued,
600
         prefs_set_data_from_toggle, prefs_set_toggle},
601

    
602
        /* {"logwindow_line_limit", NULL, NULL, NULL}, */
603

    
604
        /* External commands */
605
        {"uri_open_command", &extcmd.uri_entry,
606
         prefs_common_uri_set_data_from_entry, prefs_common_uri_set_entry},
607
        {"ext_editor_command", &extcmd.exteditor_entry,
608
         prefs_set_data_from_entry, prefs_set_entry},
609

    
610
        {"use_print_command", &extcmd.checkbtn_printcmd,
611
         prefs_set_data_from_toggle, prefs_set_toggle},
612
        {"print_command", &extcmd.printcmd_entry,
613
         prefs_set_data_from_entry, prefs_set_entry},
614

    
615
#ifndef G_OS_WIN32
616
        {"use_ext_inc", &extcmd.checkbtn_incext,
617
         prefs_set_data_from_toggle, prefs_set_toggle},
618
        {"ext_inc_path", &extcmd.entry_incext,
619
         prefs_set_data_from_entry, prefs_set_entry},
620
#endif
621
        {"use_ext_sendmail", &extcmd.checkbtn_extsend,
622
         prefs_set_data_from_toggle, prefs_set_toggle},
623
        {"ext_sendmail_cmd", &extcmd.entry_extsend,
624
         prefs_set_data_from_entry, prefs_set_entry},
625

    
626
        /* Update check */
627
#if USE_UPDATE_CHECK
628
        {"auto_update_check", &update_check.checkbtn_autoupdate,
629
         prefs_set_data_from_toggle, prefs_set_toggle},
630
        {"use_http_proxy", &update_check.checkbtn_useproxy,
631
         prefs_set_data_from_toggle, prefs_set_toggle},
632
        {"http_proxy_host", &update_check.entry_proxyhost,
633
         prefs_set_data_from_entry, prefs_set_entry},
634
#endif
635

    
636
        /* Advanced */
637
        {"strict_cache_check", &advanced.checkbtn_strict_cache_check,
638
         prefs_set_data_from_toggle, prefs_set_toggle},
639
        {"io_timeout_secs", &advanced.spinbtn_iotimeout,
640
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
641

    
642
        {NULL, NULL, NULL, NULL}
643
};
644

    
645
/* widget creating functions */
646
static void prefs_common_create                (void);
647
static void prefs_receive_create        (void);
648
static void prefs_send_create                (void);
649
static void prefs_compose_create        (void);
650
static GtkWidget *prefs_quote_create        (void);
651
#if USE_GTKSPELL
652
static GtkWidget *prefs_spell_create        (void);
653
#endif
654
static void prefs_display_create        (void);
655
static GtkWidget *prefs_message_create        (void);
656
static GtkWidget *prefs_attach_create        (void);
657

    
658
static GtkWidget *prefs_colorlabel_create        (void);
659
static void prefs_common_colorlabel_set_dialog        (void);
660
static void prefs_common_colorlabel_update        (void);
661

    
662
static void prefs_junk_create                (void);
663
#if USE_GPGME
664
static void prefs_privacy_create        (void);
665
#endif
666
static void prefs_details_create        (void);
667
static GtkWidget *prefs_other_create        (void);
668
static GtkWidget *prefs_extcmd_create        (void);
669
#if USE_UPDATE_CHECK
670
static GtkWidget *prefs_update_create        (void);
671
#endif
672
static GtkWidget *prefs_advanced_create        (void);
673

    
674
static void prefs_common_set_encoding_optmenu        (GtkOptionMenu        *optmenu,
675
                                                 gboolean         outgoing);
676

    
677
static void date_format_ok_btn_clicked                (GtkButton        *button,
678
                                                 GtkWidget     **widget);
679
static void date_format_cancel_btn_clicked        (GtkButton        *button,
680
                                                 GtkWidget     **widget);
681
static gboolean date_format_key_pressed                (GtkWidget        *keywidget,
682
                                                 GdkEventKey        *event,
683
                                                 GtkWidget     **widget);
684
static gboolean date_format_on_delete                (GtkWidget        *dialogwidget,
685
                                                 GdkEventAny        *event,
686
                                                 GtkWidget     **widget);
687
static void date_format_entry_on_change                (GtkEditable        *editable,
688
                                                 GtkLabel        *example);
689
static void date_format_select_row                (GtkWidget        *date_format_list,
690
                                                 gint                 row,
691
                                                 gint                 column,
692
                                                 GdkEventButton        *event,
693
                                                 GtkWidget        *date_format);
694
static GtkWidget *date_format_create                (GtkButton        *button,
695
                                                 void                *data);
696

    
697
static void prefs_quote_description_create        (void);
698
static gboolean prefs_quote_description_key_pressed
699
                                                (GtkWidget        *widget,
700
                                                 GdkEventKey        *event,
701
                                                 gpointer         data);
702
static gboolean prefs_quote_description_deleted        (GtkWidget        *widget,
703
                                                 GdkEventAny        *event,
704
                                                 gpointer         data);
705

    
706
static void prefs_quote_colors_dialog                (void);
707
static void prefs_quote_colors_dialog_create        (void);
708
static gint prefs_quote_colors_deleted                (GtkWidget        *widget,
709
                                                 GdkEventAny        *event,
710
                                                 gpointer         data);
711
static gboolean prefs_quote_colors_key_pressed        (GtkWidget        *widget,
712
                                                 GdkEventKey        *event,
713
                                                 gpointer         data);
714
static void quote_color_set_dialog                (GtkWidget        *widget,
715
                                                 gpointer         data);
716
static void quote_colors_set_dialog_ok                (GtkWidget        *widget,
717
                                                 gpointer         data);
718
static void quote_colors_set_dialog_cancel        (GtkWidget        *widget,
719
                                                 gpointer         data);
720
static gboolean quote_colors_set_dialog_key_pressed
721
                                                (GtkWidget        *widget,
722
                                                 GdkEventKey        *event,
723
                                                 gpointer         data);
724
static void set_button_bg_color                        (GtkWidget        *widget,
725
                                                 gint                 color);
726
static void prefs_enable_message_color_toggled        (void);
727
static void prefs_recycle_colors_toggled        (GtkWidget        *widget);
728

    
729
static void prefs_keybind_select                (void);
730
static gint prefs_keybind_deleted                (GtkWidget        *widget,
731
                                                 GdkEventAny        *event,
732
                                                 gpointer         data);
733
static gboolean prefs_keybind_key_pressed        (GtkWidget        *widget,
734
                                                 GdkEventKey        *event,
735
                                                 gpointer         data);
736
static void prefs_keybind_cancel                (void);
737
static void prefs_keybind_apply_clicked                (GtkWidget        *widget);
738

    
739
static void prefs_common_dispitem_clicked        (void);
740

    
741
static void prefs_common_select_folder_cb        (GtkWidget        *widget,
742
                                                 gpointer         data);
743

    
744
#ifdef G_OS_WIN32
745
static void prefs_common_file_selection_cb        (GtkButton        *button,
746
                                                 gpointer         data);
747
#endif
748

    
749
static gint prefs_common_deleted                (GtkWidget        *widget,
750
                                                 GdkEventAny        *event,
751
                                                 gpointer         data);
752
static gboolean prefs_common_key_pressed        (GtkWidget        *widget,
753
                                                 GdkEventKey        *event,
754
                                                 gpointer         data);
755
static void prefs_common_ok                        (void);
756
static void prefs_common_apply                        (void);
757
static void prefs_common_cancel                        (void);
758

    
759

    
760
void prefs_common_open(void)
761
{
762
        static gboolean ui_registered = FALSE;
763

    
764
        inc_lock();
765

    
766
        if (!ui_registered) {
767
                prefs_register_ui(prefs_common_get_params(), ui_data);
768
                ui_registered = TRUE;
769
        }
770

    
771
        if (!dialog.window) {
772
                prefs_common_create();
773
        }
774

    
775
        gtkut_box_set_reverse_order(GTK_BOX(dialog.confirm_area),
776
                                    !prefs_common.comply_gnome_hig);
777
        manage_window_set_transient(GTK_WINDOW(dialog.window));
778
        gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog.notebook), 0);
779
        gtk_widget_grab_focus(dialog.ok_btn);
780

    
781
        prefs_set_dialog(prefs_common_get_params());
782
        prefs_common_colorlabel_set_dialog();
783

    
784
        gtk_widget_show(dialog.window);
785

    
786
        syl_plugin_signal_emit("prefs-common-open", dialog.window);
787
}
788

    
789
static void prefs_common_create(void)
790
{
791
        gint page = 0;
792

    
793
        debug_print(_("Creating common preferences window...\n"));
794

    
795
        prefs_dialog_create(&dialog);
796
        gtk_window_set_title (GTK_WINDOW(dialog.window),
797
                              _("Common Preferences"));
798
        g_signal_connect (G_OBJECT(dialog.window), "delete_event",
799
                          G_CALLBACK(prefs_common_deleted), NULL);
800
        g_signal_connect (G_OBJECT(dialog.window), "key_press_event",
801
                          G_CALLBACK(prefs_common_key_pressed), NULL);
802
        MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
803

    
804
        g_signal_connect (G_OBJECT(dialog.ok_btn), "clicked",
805
                          G_CALLBACK(prefs_common_ok), NULL);
806
        g_signal_connect (G_OBJECT(dialog.apply_btn), "clicked",
807
                          G_CALLBACK(prefs_common_apply), NULL);
808
        g_signal_connect (G_OBJECT(dialog.cancel_btn), "clicked",
809
                          G_CALLBACK(prefs_common_cancel), NULL);
810

    
811
        /* create all widgets on notebook */
812
        prefs_receive_create();
813
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"),   page++);
814
        prefs_send_create();
815
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"),      page++);
816
        prefs_compose_create();
817
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"),   page++);
818
        prefs_display_create();
819
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Display"),   page++);
820
        prefs_junk_create();
821
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Junk mail"), page++);
822
#if USE_GPGME
823
        prefs_privacy_create();
824
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"),   page++);
825
#endif
826
        prefs_details_create();
827
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Details"), page++);
828

    
829
        gtk_widget_show_all(dialog.window);
830
}
831

    
832
static void prefs_receive_create(void)
833
{
834
        GtkWidget *vbox1;
835
        GtkWidget *vbox2;
836
        GtkWidget *vbox3;
837
        GtkWidget *vbox4;
838
        GtkWidget *hbox;
839

    
840
        GtkWidget *hbox_autochk;
841
        GtkWidget *checkbtn_autochk;
842
        GtkWidget *label_autochk1;
843
        GtkObject *spinbtn_autochk_adj;
844
        GtkWidget *spinbtn_autochk;
845
        GtkWidget *label_autochk2;
846
        GtkWidget *checkbtn_chkonstartup;
847
        GtkWidget *checkbtn_scan_after_inc;
848

    
849
        GtkWidget *frame_notify;
850
        GtkWidget *checkbtn_newmsg_notify_window;
851
        GtkWidget *checkbtn_newmsg_notify;
852
        GtkWidget *label_newmsg_notify;
853
        GtkWidget *entry_newmsg_notify;
854
        GtkWidget *label_notify_cmd_desc;
855
#ifdef G_OS_WIN32
856
        GtkWidget *checkbtn_newmsg_sound;
857
        GtkWidget *label_newmsg_sound;
858
        GtkWidget *entry_newmsg_sound;
859
        GtkWidget *btn_filesel;
860
#endif
861

    
862
#ifndef G_OS_WIN32
863
        GtkWidget *frame_spool;
864
        GtkWidget *checkbtn_local;
865
        GtkWidget *checkbtn_filter_on_inc;
866
        GtkWidget *label_spool;
867
        GtkWidget *entry_spool;
868
#endif
869

    
870
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
871
        gtk_widget_show (vbox1);
872
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
873
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
874

    
875
        vbox2 = gtk_vbox_new (FALSE, 0);
876
        gtk_widget_show (vbox2);
877
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
878

    
879
        /* Auto-checking */
880
        hbox_autochk = gtk_hbox_new (FALSE, 8);
881
        gtk_widget_show (hbox_autochk);
882
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
883

    
884
        PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
885
                           _("Auto-check new mail"));
886

    
887
        label_autochk1 = gtk_label_new (_("every"));
888
        gtk_widget_show (label_autochk1);
889
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
890

    
891
        spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 1000, 1, 10, 0);
892
        spinbtn_autochk = gtk_spin_button_new
893
                (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
894
        gtk_widget_show (spinbtn_autochk);
895
        gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
896
        gtk_widget_set_size_request (spinbtn_autochk, 64, -1);
897
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
898

    
899
        label_autochk2 = gtk_label_new (_("minute(s)"));
900
        gtk_widget_show (label_autochk2);
901
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
902

    
903
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
904
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
905
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
906

    
907
        PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
908
                           _("Check new mail on startup"));
909
        PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
910
                           _("Update all local folders after incorporation"));
911

    
912
        /* New message notify */
913
        PACK_FRAME(vbox1, frame_notify, _("New message notification"));
914

    
915
        vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
916
        gtk_widget_show (vbox3);
917
        gtk_container_add (GTK_CONTAINER (frame_notify), vbox3);
918
        gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
919

    
920
        vbox4 = gtk_vbox_new (FALSE, 0);
921
        gtk_widget_show (vbox4);
922
        gtk_box_pack_start (GTK_BOX (vbox3), vbox4, FALSE, FALSE, 0);
923

    
924
        PACK_CHECK_BUTTON
925
                (vbox4, checkbtn_newmsg_notify_window,
926
                 _("Show notification window when new messages arrive"));
927

    
928
#ifdef G_OS_WIN32
929
        PACK_CHECK_BUTTON
930
                (vbox4, checkbtn_newmsg_sound,
931
                 _("Play sound when new messages arrive"));
932

    
933
        hbox = gtk_hbox_new (FALSE, 8);
934
        gtk_widget_show (hbox);
935
        gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
936

    
937
        label_newmsg_sound = gtk_label_new (_("Sound file"));
938
        gtk_widget_show (label_newmsg_sound);
939
        gtk_box_pack_start (GTK_BOX (hbox), label_newmsg_sound,
940
                            FALSE, FALSE, 0);
941

    
942
        entry_newmsg_sound = gtk_entry_new ();
943
        gtk_widget_show (entry_newmsg_sound);
944
        gtk_box_pack_start (GTK_BOX (hbox), entry_newmsg_sound, TRUE, TRUE, 0);
945

    
946
        btn_filesel = gtk_button_new_with_label("...");
947
        gtk_box_pack_start (GTK_BOX (hbox), btn_filesel, FALSE, FALSE, 0);
948
        g_signal_connect(G_OBJECT(btn_filesel), "clicked",
949
                         G_CALLBACK(prefs_common_file_selection_cb),
950
                         entry_newmsg_sound);
951

    
952
        SET_TOGGLE_SENSITIVITY (checkbtn_newmsg_sound, hbox);
953

    
954
        PACK_CHECK_BUTTON
955
                (vbox3, checkbtn_newmsg_notify,
956
                 _("Execute command when new messages arrive"));
957
#else
958
        PACK_CHECK_BUTTON
959
                (vbox4, checkbtn_newmsg_notify,
960
                 _("Execute command when new messages arrive"));
961
#endif
962

    
963
        hbox = gtk_hbox_new (FALSE, 8);
964
        gtk_widget_show (hbox);
965
        gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
966

    
967
        label_newmsg_notify = gtk_label_new (_("Command"));
968
        gtk_widget_show (label_newmsg_notify);
969
        gtk_box_pack_start (GTK_BOX (hbox), label_newmsg_notify,
970
                            FALSE, FALSE, 0);
971

    
972
        entry_newmsg_notify = gtk_entry_new ();
973
        gtk_widget_show (entry_newmsg_notify);
974
        gtk_box_pack_start (GTK_BOX (hbox), entry_newmsg_notify, TRUE, TRUE, 0);
975

    
976
        SET_TOGGLE_SENSITIVITY (checkbtn_newmsg_notify, hbox);
977

    
978
        PACK_SMALL_LABEL
979
                (vbox3, label_notify_cmd_desc,
980
                 _("`%d' will be replaced with the number of new messages."));
981

    
982
#ifndef G_OS_WIN32
983
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_spool, checkbtn_local,
984
                                     _("Incorporate from local spool"));
985

    
986
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
987
        gtk_widget_show (vbox2);
988
        gtk_container_add (GTK_CONTAINER (frame_spool), vbox2);
989
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
990
        SET_TOGGLE_SENSITIVITY (checkbtn_local, vbox2);
991

    
992
        hbox = gtk_hbox_new (FALSE, 32);
993
        gtk_widget_show (hbox);
994
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
995

    
996
        PACK_CHECK_BUTTON (hbox, checkbtn_filter_on_inc,
997
                           _("Filter on incorporation"));
998

    
999
        hbox = gtk_hbox_new (FALSE, 8);
1000
        gtk_widget_show (hbox);
1001
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1002

    
1003
        label_spool = gtk_label_new (_("Spool path"));
1004
        gtk_widget_show (label_spool);
1005
        gtk_box_pack_start (GTK_BOX (hbox), label_spool, FALSE, FALSE, 0);
1006

    
1007
        entry_spool = gtk_entry_new ();
1008
        gtk_widget_show (entry_spool);
1009
        gtk_box_pack_start (GTK_BOX (hbox), entry_spool, TRUE, TRUE, 0);
1010
#endif /* !G_OS_WIN32 */
1011

    
1012
        receive.checkbtn_autochk    = checkbtn_autochk;
1013
        receive.spinbtn_autochk     = spinbtn_autochk;
1014
        receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1015

    
1016
        receive.checkbtn_chkonstartup   = checkbtn_chkonstartup;
1017
        receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1018

    
1019
        receive.checkbtn_newmsg_notify_window = checkbtn_newmsg_notify_window;
1020
#ifdef G_OS_WIN32
1021
        receive.checkbtn_newmsg_sound   = checkbtn_newmsg_sound;
1022
        receive.entry_newmsg_sound      = entry_newmsg_sound;
1023
#endif
1024
        receive.checkbtn_newmsg_notify  = checkbtn_newmsg_notify;
1025
        receive.entry_newmsg_notify     = entry_newmsg_notify;
1026

    
1027
#ifndef G_OS_WIN32
1028
        receive.checkbtn_local         = checkbtn_local;
1029
        receive.checkbtn_filter_on_inc = checkbtn_filter_on_inc;
1030
        receive.entry_spool            = entry_spool;
1031
#endif
1032
}
1033

    
1034
static void prefs_send_create(void)
1035
{
1036
        GtkWidget *vbox1;
1037

    
1038
        GtkWidget *notebook;
1039
        GtkWidget *vbox_tab;
1040

    
1041
        GtkWidget *vbox2;
1042
        GtkWidget *hbox1;
1043
        GtkWidget *checkbtn_savemsg;
1044
        GtkWidget *checkbtn_filter_sent;
1045
        GtkWidget *checkbtn_recipients_autoreg;
1046
        GtkWidget *checkbtn_show_send_dialog;
1047
        GtkWidget *label;
1048
        GtkWidget *checkbtn_check_attach;
1049
        GtkWidget *entry_check_attach_str;
1050
        GtkWidget *checkbtn_check_recp;
1051
        GtkWidget *entry_check_recp_excl;
1052

    
1053
        GtkWidget *optmenu_trencoding;
1054
        GtkWidget *optmenu_menu;
1055
        GtkWidget *menuitem;
1056
        GtkWidget *optmenu_fencoding;
1057
        GtkWidget *label_encoding;
1058
        GtkWidget *label_encoding_desc;
1059
        GtkWidget *label_fencoding;
1060
        GtkWidget *label_fencoding_desc;
1061

    
1062
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1063
        gtk_widget_show (vbox1);
1064
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1065
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1066

    
1067
        notebook = gtk_notebook_new();
1068
        gtk_widget_show(notebook);
1069
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1070

    
1071
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1072

    
1073
        vbox2 = gtk_vbox_new (FALSE, 0);
1074
        gtk_widget_show (vbox2);
1075
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
1076

    
1077
        PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1078
                           _("Save sent messages to outbox"));
1079
        PACK_CHECK_BUTTON (vbox2, checkbtn_filter_sent,
1080
                           _("Apply filter rules to sent messages"));
1081
        SET_TOGGLE_SENSITIVITY (checkbtn_savemsg, checkbtn_filter_sent);
1082
        PACK_CHECK_BUTTON (vbox2, checkbtn_recipients_autoreg,
1083
                           _("Automatically add recipients to address book"));
1084

    
1085
        PACK_CHECK_BUTTON (vbox2, checkbtn_show_send_dialog,
1086
                           _("Display send dialog"));
1087

    
1088
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1089
        gtk_widget_show (vbox2);
1090
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
1091

    
1092
        PACK_CHECK_BUTTON (vbox2, checkbtn_check_attach,
1093
                           _("Notify for missing attachments when the following strings (comma-separated) are found in the message body"));
1094
        gtk_label_set_line_wrap(GTK_LABEL(GTK_BIN(checkbtn_check_attach)->child), TRUE);
1095

    
1096
        hbox1 = gtk_hbox_new (FALSE, 8);
1097
        gtk_widget_show (hbox1);
1098
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1099

    
1100
        entry_check_attach_str = gtk_entry_new ();
1101
        gtk_widget_show (entry_check_attach_str);
1102
        gtk_box_pack_start (GTK_BOX (hbox1), entry_check_attach_str,
1103
                            TRUE, TRUE, 0);
1104
        label = gtk_label_new (_("(Ex: attach)"));
1105
        gtk_widget_show (label);
1106
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1107

    
1108
        SET_TOGGLE_SENSITIVITY(checkbtn_check_attach, entry_check_attach_str);
1109

    
1110
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1111
        gtk_widget_show (vbox2);
1112
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
1113

    
1114
        PACK_CHECK_BUTTON (vbox2, checkbtn_check_recp,
1115
                           _("Confirm recipients before sending"));
1116

    
1117
        hbox1 = gtk_hbox_new (FALSE, 8);
1118
        gtk_widget_show (hbox1);
1119
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1120
        label = gtk_label_new
1121
                (_("Excluded addresses/domains (comma-separated):"));
1122
        gtk_widget_show (label);
1123
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1124

    
1125
        entry_check_recp_excl = gtk_entry_new ();
1126
        gtk_widget_show (entry_check_recp_excl);
1127
        gtk_box_pack_start (GTK_BOX (vbox2), entry_check_recp_excl,
1128
                            FALSE, FALSE, 0);
1129

    
1130
        SET_TOGGLE_SENSITIVITY(checkbtn_check_recp, entry_check_recp_excl);
1131

    
1132
        /* Encoding */
1133

    
1134
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Encoding"));
1135

    
1136
        hbox1 = gtk_hbox_new (FALSE, 8);
1137
        gtk_widget_show (hbox1);
1138
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1139

    
1140
        label_encoding = gtk_label_new (_("Transfer encoding"));
1141
        gtk_widget_show (label_encoding);
1142
        gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
1143

    
1144
        optmenu_trencoding = gtk_option_menu_new ();
1145
        gtk_widget_show (optmenu_trencoding);
1146
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_trencoding,
1147
                            FALSE, FALSE, 0);
1148

    
1149
        optmenu_menu = gtk_menu_new();
1150

    
1151
#define SET_MENUITEM(str, data) \
1152
        MENUITEM_ADD(optmenu_menu, menuitem, str, data)
1153

    
1154
        SET_MENUITEM(_("Automatic"),         CTE_AUTO);
1155
        SET_MENUITEM("base64",                 CTE_BASE64);
1156
        SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
1157
        SET_MENUITEM("8bit",                 CTE_8BIT);
1158

    
1159
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_trencoding),
1160
                                  optmenu_menu);
1161

    
1162
        PACK_SMALL_LABEL (vbox_tab, label_encoding_desc,
1163
                          _("Specify Content-Transfer-Encoding used when "
1164
                            "message body contains non-ASCII characters."));
1165

    
1166
        hbox1 = gtk_hbox_new (FALSE, 8);
1167
        gtk_widget_show (hbox1);
1168
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1169

    
1170
        label_fencoding = gtk_label_new (_("MIME filename encoding"));
1171
        gtk_widget_show (label_fencoding);
1172
        gtk_box_pack_start (GTK_BOX (hbox1), label_fencoding, FALSE, FALSE, 0);
1173

    
1174
        optmenu_fencoding = gtk_option_menu_new ();
1175
        gtk_widget_show (optmenu_fencoding);
1176
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_fencoding,
1177
                            FALSE, FALSE, 0);
1178

    
1179
        optmenu_menu = gtk_menu_new();
1180

    
1181
        SET_MENUITEM(_("MIME header"), FENC_MIME);
1182
        SET_MENUITEM("RFC 2231", FENC_RFC2231);
1183

    
1184
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_fencoding),
1185
                                  optmenu_menu);
1186

    
1187
#undef SET_MENUITEM
1188

    
1189
        PACK_SMALL_LABEL
1190
                (vbox_tab, label_fencoding_desc,
1191
                 _("Specify encoding method for MIME filename with "
1192
                   "non-ASCII characters.\n"
1193
                   "MIME header: most popular, but violates RFC 2047\n"
1194
                   "RFC 2231: conforms to standard, but not popular"));
1195

    
1196

    
1197
        p_send.checkbtn_savemsg = checkbtn_savemsg;
1198
        p_send.checkbtn_filter_sent = checkbtn_filter_sent;
1199
        p_send.checkbtn_recipients_autoreg = checkbtn_recipients_autoreg;
1200
        p_send.checkbtn_show_send_dialog = checkbtn_show_send_dialog;
1201

    
1202
        p_send.optmenu_encoding_method = optmenu_trencoding;
1203
        p_send.optmenu_mime_fencoding_method = optmenu_fencoding;
1204

    
1205
        p_send.checkbtn_check_attach = checkbtn_check_attach;
1206
        p_send.entry_check_attach_str = entry_check_attach_str;
1207
        p_send.checkbtn_check_recp = checkbtn_check_recp;
1208
        p_send.entry_check_recp_excl = entry_check_recp_excl;
1209
}
1210

    
1211
static void prefs_compose_create(void)
1212
{
1213
        GtkWidget *vbox1;
1214

    
1215
        GtkWidget *notebook;
1216
        GtkWidget *vbox_tab;
1217

    
1218
        GtkWidget *hbox1;
1219
        GtkWidget *hbox2;
1220

    
1221
        GtkWidget *frame_sig;
1222
        GtkWidget *checkbtn_autosig;
1223
        GtkWidget *label_sigsep;
1224
        GtkWidget *entry_sigsep;
1225

    
1226
        GtkWidget *vbox2;
1227
        GtkWidget *checkbtn_autoextedit;
1228
        GtkWidget *vbox3;
1229
        GtkWidget *hbox3;
1230
        GtkWidget *hbox4;
1231
        GtkWidget *label_undolevel;
1232
        GtkObject *spinbtn_undolevel_adj;
1233
        GtkWidget *spinbtn_undolevel;
1234
        GtkWidget *label_linewrap;
1235
        GtkObject *spinbtn_linewrap_adj;
1236
        GtkWidget *spinbtn_linewrap;
1237
        GtkWidget *checkbtn_wrapquote;
1238
        GtkWidget *checkbtn_autowrap;
1239

    
1240
        GtkWidget *hbox_autosave;
1241
        GtkWidget *checkbtn_autosave;
1242
        GtkWidget *label_autosave1;
1243
        GtkObject *spinbtn_autosave_adj;
1244
        GtkWidget *spinbtn_autosave;
1245
        GtkWidget *label_autosave2;
1246

    
1247
        GtkWidget *frame_reply;
1248
        GtkWidget *checkbtn_reply_account_autosel;
1249
        GtkWidget *checkbtn_quote;
1250
        GtkWidget *checkbtn_default_reply_list;
1251
        GtkWidget *checkbtn_inherit_recipient_on_self_reply;
1252
        GtkWidget *checkbtn_reply_address_only;
1253

    
1254
        GtkWidget *quote_wid;
1255
#if USE_GTKSPELL
1256
        GtkWidget *spell_wid;
1257
#endif
1258

    
1259
        vbox1 = gtk_vbox_new(FALSE, VSPACING);
1260
        gtk_widget_show(vbox1);
1261
        gtk_container_add(GTK_CONTAINER(dialog.notebook), vbox1);
1262
        gtk_container_set_border_width(GTK_CONTAINER(vbox1), VBOX_BORDER);
1263

    
1264
        notebook = gtk_notebook_new();
1265
        gtk_widget_show(notebook);
1266
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1267

    
1268
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1269

    
1270
        /* signature */
1271

    
1272
        PACK_FRAME(vbox_tab, frame_sig, _("Signature"));
1273

    
1274
        hbox1 = gtk_hbox_new (FALSE, 32);
1275
        gtk_widget_show (hbox1);
1276
        gtk_container_add (GTK_CONTAINER (frame_sig), hbox1);
1277
        gtk_container_set_border_width (GTK_CONTAINER (hbox1), 8);
1278

    
1279
        hbox2 = gtk_hbox_new (FALSE, 8);
1280
        gtk_widget_show (hbox2);
1281
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1282

    
1283
        label_sigsep = gtk_label_new (_("Signature separator"));
1284
        gtk_widget_show (label_sigsep);
1285
        gtk_box_pack_start (GTK_BOX (hbox2), label_sigsep, FALSE, FALSE, 0);
1286

    
1287
        entry_sigsep = gtk_entry_new ();
1288
        gtk_widget_show (entry_sigsep);
1289
        gtk_box_pack_start (GTK_BOX (hbox2), entry_sigsep, FALSE, FALSE, 0);
1290
        gtk_widget_set_size_request (entry_sigsep, 64, -1);
1291

    
1292
        PACK_CHECK_BUTTON (hbox1, checkbtn_autosig, _("Insert automatically"));
1293

    
1294
        PACK_FRAME(vbox_tab, frame_reply, _("Reply"));
1295

    
1296
        vbox2 = gtk_vbox_new (FALSE, 0);
1297
        gtk_widget_show (vbox2);
1298
        gtk_container_add (GTK_CONTAINER (frame_reply), vbox2);
1299
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1300

    
1301
        PACK_CHECK_BUTTON (vbox2, checkbtn_reply_account_autosel,
1302
                           _("Automatically select account for replies"));
1303
        PACK_CHECK_BUTTON (vbox2, checkbtn_quote,
1304
                           _("Quote message when replying"));
1305
        PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
1306
                           _("Reply to mailing list by Reply button"));
1307
        PACK_CHECK_BUTTON (vbox2, checkbtn_inherit_recipient_on_self_reply,
1308
                           _("Inherit recipients on reply to self messages"));
1309
        PACK_CHECK_BUTTON (vbox2, checkbtn_reply_address_only,
1310
                           _("Set only mail address of recipients when replying"));
1311

    
1312
        /* editor */
1313

    
1314
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Editor"));
1315

    
1316
        vbox2 = gtk_vbox_new (FALSE, 0);
1317
        gtk_widget_show (vbox2);
1318
        gtk_container_add (GTK_CONTAINER (vbox_tab), vbox2);
1319

    
1320
        PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1321
                           _("Automatically launch the external editor"));
1322

    
1323
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1324

    
1325
        /* undo */
1326

    
1327
        hbox3 = gtk_hbox_new (FALSE, 8);
1328
        gtk_widget_show (hbox3);
1329
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1330

    
1331
        label_undolevel = gtk_label_new (_("Undo level"));
1332
        gtk_widget_show (label_undolevel);
1333
        gtk_box_pack_start (GTK_BOX (hbox3), label_undolevel, FALSE, FALSE, 0);
1334

    
1335
        spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 0);
1336
        spinbtn_undolevel = gtk_spin_button_new
1337
                (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1338
        gtk_widget_show (spinbtn_undolevel);
1339
        gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_undolevel, FALSE, FALSE, 0);
1340
        gtk_widget_set_size_request (spinbtn_undolevel, 64, -1);
1341
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1342

    
1343
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1344

    
1345
        /* line-wrapping */
1346

    
1347
        hbox3 = gtk_hbox_new (FALSE, 8);
1348
        gtk_widget_show (hbox3);
1349
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1350

    
1351
        label_linewrap = gtk_label_new (_("Wrap messages at"));
1352
        gtk_widget_show (label_linewrap);
1353
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1354

    
1355
        spinbtn_linewrap_adj = gtk_adjustment_new (72, 20, 1024, 1, 10, 0);
1356
        spinbtn_linewrap = gtk_spin_button_new
1357
                (GTK_ADJUSTMENT (spinbtn_linewrap_adj), 1, 0);
1358
        gtk_widget_show (spinbtn_linewrap);
1359
        gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_linewrap, FALSE, FALSE, 0);
1360
        gtk_widget_set_size_request (spinbtn_linewrap, 64, -1);
1361
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
1362

    
1363
        label_linewrap = gtk_label_new (_("characters"));
1364
        gtk_widget_show (label_linewrap);
1365
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1366

    
1367
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1368

    
1369
        hbox4 = gtk_hbox_new (FALSE, 32);
1370
        gtk_widget_show (hbox4);
1371
        gtk_box_pack_start (GTK_BOX (vbox2), hbox4, FALSE, FALSE, 0);
1372

    
1373
        PACK_CHECK_BUTTON (hbox4, checkbtn_wrapquote, _("Wrap quotation"));
1374

    
1375
        hbox4 = gtk_hbox_new (FALSE, 32);
1376
        gtk_widget_show (hbox4);
1377
        gtk_box_pack_start (GTK_BOX (vbox2), hbox4, FALSE, FALSE, 0);
1378

    
1379
        PACK_CHECK_BUTTON (hbox4, checkbtn_autowrap, _("Wrap on input"));
1380

    
1381
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1382

    
1383
        hbox_autosave = gtk_hbox_new (FALSE, 8);
1384
        gtk_widget_show (hbox_autosave);
1385
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_autosave, FALSE, FALSE, 0);
1386

    
1387
        PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
1388
                           _("Auto-save to draft"));
1389

    
1390
        label_autosave1 = gtk_label_new (_("every"));
1391
        gtk_widget_show (label_autosave1);
1392
        gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave1,
1393
                            FALSE, FALSE, 0);
1394

    
1395
        spinbtn_autosave_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 0);
1396
        spinbtn_autosave = gtk_spin_button_new
1397
                (GTK_ADJUSTMENT (spinbtn_autosave_adj), 1, 0);
1398
        gtk_widget_show (spinbtn_autosave);
1399
        gtk_box_pack_start (GTK_BOX (hbox_autosave), spinbtn_autosave,
1400
                            FALSE, FALSE, 0);
1401
        gtk_widget_set_size_request (spinbtn_autosave, 64, -1);
1402
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autosave), TRUE);
1403

    
1404
        label_autosave2 = gtk_label_new (_("minute(s)"));
1405
        gtk_widget_show (label_autosave2);
1406
        gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave2,
1407
                            FALSE, FALSE, 0);
1408

    
1409
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, label_autosave1);
1410
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, spinbtn_autosave);
1411
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, label_autosave2);
1412

    
1413
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Format"));
1414
        quote_wid = prefs_quote_create();
1415
        gtk_box_pack_start(GTK_BOX(vbox_tab), quote_wid, FALSE, FALSE, 0);
1416

    
1417
#if USE_GTKSPELL
1418
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Spell checking"));
1419
        spell_wid = prefs_spell_create();
1420
        gtk_box_pack_start(GTK_BOX(vbox_tab), spell_wid, FALSE, FALSE, 0);
1421
#endif
1422

    
1423
        compose.checkbtn_autosig = checkbtn_autosig;
1424
        compose.entry_sigsep     = entry_sigsep;
1425

    
1426
        compose.checkbtn_autoextedit = checkbtn_autoextedit;
1427

    
1428
        compose.spinbtn_undolevel     = spinbtn_undolevel;
1429
        compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1430

    
1431
        compose.spinbtn_linewrap     = spinbtn_linewrap;
1432
        compose.spinbtn_linewrap_adj = spinbtn_linewrap_adj;
1433
        compose.checkbtn_wrapquote   = checkbtn_wrapquote;
1434
        compose.checkbtn_autowrap    = checkbtn_autowrap;
1435

    
1436
        compose.checkbtn_autosave    = checkbtn_autosave;
1437
        compose.spinbtn_autosave     = spinbtn_autosave;
1438
        compose.spinbtn_autosave_adj = spinbtn_autosave_adj;
1439

    
1440
        compose.checkbtn_quote = checkbtn_quote;
1441
        compose.checkbtn_reply_account_autosel =
1442
                checkbtn_reply_account_autosel;
1443
        compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
1444
        compose.checkbtn_inherit_recipient_on_self_reply =
1445
                checkbtn_inherit_recipient_on_self_reply;
1446
        compose.checkbtn_reply_address_only = checkbtn_reply_address_only;
1447
}
1448

    
1449
static GtkWidget *prefs_quote_create(void)
1450
{
1451
        GtkWidget *vbox1;
1452
        GtkWidget *frame_quote;
1453
        GtkWidget *vbox_quote;
1454
        GtkWidget *hbox1;
1455
        GtkWidget *hbox2;
1456
        GtkWidget *label_quotemark;
1457
        GtkWidget *entry_quotemark;
1458
        GtkWidget *scrolledwin_quotefmt;
1459
        GtkWidget *text_quotefmt;
1460

    
1461
        GtkWidget *entry_fw_quotemark;
1462
        GtkWidget *text_fw_quotefmt;
1463

    
1464
        GtkWidget *btn_quotedesc;
1465

    
1466
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1467
        gtk_widget_show (vbox1);
1468

    
1469
        /* reply */
1470

    
1471
        PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1472

    
1473
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1474
        gtk_widget_show (vbox_quote);
1475
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1476
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1477

    
1478
        hbox1 = gtk_hbox_new (FALSE, 32);
1479
        gtk_widget_show (hbox1);
1480
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1481

    
1482
        hbox2 = gtk_hbox_new (FALSE, 8);
1483
        gtk_widget_show (hbox2);
1484
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1485

    
1486
        label_quotemark = gtk_label_new (_("Quotation mark"));
1487
        gtk_widget_show (label_quotemark);
1488
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1489

    
1490
        entry_quotemark = gtk_entry_new ();
1491
        gtk_widget_show (entry_quotemark);
1492
        gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1493
        gtk_widget_set_size_request (entry_quotemark, 64, -1);
1494

    
1495
        scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1496
        gtk_widget_show (scrolledwin_quotefmt);
1497
        gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
1498
                            TRUE, TRUE, 0);
1499
        gtk_scrolled_window_set_policy
1500
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1501
                 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1502
        gtk_scrolled_window_set_shadow_type
1503
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
1504

    
1505
        text_quotefmt = gtk_text_view_new ();
1506
        gtk_widget_show (text_quotefmt);
1507
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1508
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_quotefmt), TRUE);
1509
        gtk_widget_set_size_request(text_quotefmt, DEFAULT_ENTRY_WIDTH, 60);
1510

    
1511
        /* forward */
1512

    
1513
        PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1514

    
1515
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1516
        gtk_widget_show (vbox_quote);
1517
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1518
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1519

    
1520
        hbox1 = gtk_hbox_new (FALSE, 32);
1521
        gtk_widget_show (hbox1);
1522
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1523

    
1524
        hbox2 = gtk_hbox_new (FALSE, 8);
1525
        gtk_widget_show (hbox2);
1526
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1527

    
1528
        label_quotemark = gtk_label_new (_("Quotation mark"));
1529
        gtk_widget_show (label_quotemark);
1530
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1531

    
1532
        entry_fw_quotemark = gtk_entry_new ();
1533
        gtk_widget_show (entry_fw_quotemark);
1534
        gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1535
                            FALSE, FALSE, 0);
1536
        gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
1537

    
1538
        scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1539
        gtk_widget_show (scrolledwin_quotefmt);
1540
        gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
1541
                            TRUE, TRUE, 0);
1542
        gtk_scrolled_window_set_policy
1543
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1544
                 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1545
        gtk_scrolled_window_set_shadow_type
1546
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
1547

    
1548
        text_fw_quotefmt = gtk_text_view_new ();
1549
        gtk_widget_show (text_fw_quotefmt);
1550
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1551
                          text_fw_quotefmt);
1552
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
1553
        gtk_widget_set_size_request (text_fw_quotefmt, DEFAULT_ENTRY_WIDTH, 60);
1554

    
1555
        hbox1 = gtk_hbox_new (FALSE, 32);
1556
        gtk_widget_show (hbox1);
1557
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1558

    
1559
        btn_quotedesc =
1560
                gtk_button_new_with_label (_(" Description of symbols "));
1561
        gtk_widget_show (btn_quotedesc);
1562
        gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
1563
        g_signal_connect(G_OBJECT(btn_quotedesc), "clicked",
1564
                         G_CALLBACK(prefs_quote_description), NULL);
1565

    
1566
        quote.entry_quotemark    = entry_quotemark;
1567
        quote.text_quotefmt      = text_quotefmt;
1568
        quote.entry_fw_quotemark = entry_fw_quotemark;
1569
        quote.text_fw_quotefmt   = text_fw_quotefmt;
1570

    
1571
        return vbox1;
1572
}
1573

    
1574
#if USE_GTKSPELL
1575
static GtkWidget *prefs_spell_create(void)
1576
{
1577
        GtkWidget *vbox1;
1578
        GtkWidget *vbox2;
1579
        GtkWidget *frame;
1580
        GtkWidget *hbox;
1581
        GtkWidget *chkbtn_enable_spell;
1582
        GtkWidget *label;
1583
        GtkWidget *entry_spell_lang;
1584
 
1585
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1586
        gtk_widget_show (vbox1);
1587
 
1588
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame, chkbtn_enable_spell,
1589
                                     _("Enable Spell checking"));
1590
 
1591
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1592
        gtk_widget_show (vbox2);
1593
        gtk_container_add (GTK_CONTAINER (frame), vbox2);
1594
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1595
        SET_TOGGLE_SENSITIVITY (chkbtn_enable_spell, vbox2);
1596
 
1597
        hbox = gtk_hbox_new (FALSE, 8);
1598
        gtk_widget_show (hbox);
1599
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1600
 
1601
        label = gtk_label_new (_("Default language:"));
1602
        gtk_widget_show (label);
1603
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1604
 
1605
        entry_spell_lang = gtk_entry_new ();
1606
        gtk_widget_show (entry_spell_lang);
1607
        gtk_box_pack_start (GTK_BOX (hbox), entry_spell_lang, TRUE, TRUE, 0);
1608
 
1609
        spell.chkbtn_enable_spell = chkbtn_enable_spell;
1610
        spell.entry_spell_lang = entry_spell_lang;
1611

    
1612
        return vbox1;
1613
}
1614
#endif /* USE_GTKSPELL */
1615

    
1616
static void prefs_display_create(void)
1617
{
1618
        GtkWidget *vbox1;
1619

    
1620
        GtkWidget *notebook;
1621
        GtkWidget *vbox_tab;
1622

    
1623
        GtkWidget *table1;
1624
        GtkWidget *label_textfont;
1625
        GtkWidget *fontbtn_textfont;
1626
        GtkWidget *frame_folder;
1627
        GtkWidget *chkbtn_folder_unread;
1628
        GtkWidget *label_folder_cols;
1629
        GtkWidget *hbox1;
1630
        GtkWidget *hbox_spc;
1631
        GtkWidget *chkbtn_folder_col_new;
1632
        GtkWidget *chkbtn_folder_col_unread;
1633
        GtkWidget *chkbtn_folder_col_total;
1634
        GtkWidget *label_ng_abbrev;
1635
        GtkWidget *spinbtn_ng_abbrev_len;
1636
        GtkObject *spinbtn_ng_abbrev_len_adj;
1637
        GtkWidget *frame_summary;
1638
        GtkWidget *vbox2;
1639
        GtkWidget *chkbtn_swapfrom;
1640
        GtkWidget *chkbtn_expand_thread;
1641
        GtkWidget *vbox3;
1642
        GtkWidget *label_datefmt;
1643
        GtkWidget *button_datefmt;
1644
        GtkWidget *entry_datefmt;
1645
        GtkWidget *button_dispitem;
1646

    
1647
        GtkWidget *msg_wid;
1648
        GtkWidget *att_wid;
1649
        GtkWidget *clabel_wid;
1650

    
1651
        GtkWidget *label_dispencoding;
1652
        GtkWidget *optmenu_dispencoding;
1653
        GtkWidget *label_outencoding;
1654
        GtkWidget *optmenu_outencoding;
1655
        GtkWidget *label_encoding_desc;
1656

    
1657
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1658
        gtk_widget_show (vbox1);
1659
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1660
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1661

    
1662
        notebook = gtk_notebook_new();
1663
        gtk_widget_show(notebook);
1664
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1665

    
1666
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1667

    
1668
        table1 = gtk_table_new (1, 2, FALSE);
1669
        gtk_widget_show (table1);
1670
        gtk_box_pack_start(GTK_BOX(vbox_tab), table1, FALSE, FALSE, 0);
1671
        gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
1672
        gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
1673

    
1674
        label_textfont = gtk_label_new (_("Text font"));
1675
        gtk_widget_show (label_textfont);
1676
        gtk_table_attach (GTK_TABLE (table1), label_textfont, 0, 1, 0, 1,
1677
                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1678

    
1679
        fontbtn_textfont = gtk_font_button_new ();
1680
        gtk_widget_show (fontbtn_textfont);
1681
        gtk_table_attach (GTK_TABLE (table1), fontbtn_textfont, 1, 2, 0, 1,
1682
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
1683

    
1684
        /* ---- Folder View ---- */
1685

    
1686
        PACK_FRAME(vbox_tab, frame_folder, _("Folder View"));
1687

    
1688
        vbox2 = gtk_vbox_new (FALSE, 0);
1689
        gtk_widget_show (vbox2);
1690
        gtk_container_add (GTK_CONTAINER (frame_folder), vbox2);
1691
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1692

    
1693
        PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1694
                           _("Display unread number next to folder name"));
1695

    
1696
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1697
        label_folder_cols = gtk_label_new
1698
                (_("Displaying message number columns in the folder view:"));
1699
        gtk_widget_show(label_folder_cols);
1700
        gtk_box_pack_start(GTK_BOX(vbox2), label_folder_cols, FALSE, TRUE, 0);
1701
        gtk_misc_set_alignment(GTK_MISC(label_folder_cols), 0, 0.5);
1702

    
1703
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1704
        hbox1 = gtk_hbox_new(FALSE, 8);
1705
        gtk_widget_show(hbox1);
1706
        gtk_box_pack_start(GTK_BOX(vbox2), hbox1, FALSE, TRUE, 0);
1707
        hbox_spc = gtk_hbox_new(FALSE, 0);
1708
        gtk_widget_show(hbox_spc);
1709
        gtk_box_pack_start(GTK_BOX(hbox1), hbox_spc, FALSE, FALSE, 0);
1710
        gtk_widget_set_size_request(hbox_spc, 8, -1);
1711
        PACK_CHECK_BUTTON(hbox1, chkbtn_folder_col_new, _("New"));
1712
        PACK_CHECK_BUTTON(hbox1, chkbtn_folder_col_unread, _("Unread"));
1713
        PACK_CHECK_BUTTON(hbox1, chkbtn_folder_col_total, _("Total"));
1714

    
1715
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1716

    
1717
        hbox1 = gtk_hbox_new (FALSE, 8);
1718
        gtk_widget_show (hbox1);
1719
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1720

    
1721
        label_ng_abbrev = gtk_label_new
1722
                (_("Abbreviate newsgroups longer than"));
1723
        gtk_widget_show (label_ng_abbrev);
1724
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1725

    
1726
        spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 0);
1727
        spinbtn_ng_abbrev_len = gtk_spin_button_new
1728
                (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
1729
        gtk_widget_show (spinbtn_ng_abbrev_len);
1730
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
1731
                            FALSE, FALSE, 0);
1732
        gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
1733
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
1734
                                     TRUE);
1735

    
1736
        label_ng_abbrev = gtk_label_new
1737
                (_("letters"));
1738
        gtk_widget_show (label_ng_abbrev);
1739
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1740

    
1741
        /* ---- Summary ---- */
1742

    
1743
        PACK_FRAME(vbox_tab, frame_summary, _("Summary View"));
1744

    
1745
        vbox2 = gtk_vbox_new (FALSE, 0);
1746
        gtk_widget_show (vbox2);
1747
        gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1748
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1749

    
1750
        PACK_CHECK_BUTTON
1751
                (vbox2, chkbtn_swapfrom,
1752
                 _("Display recipient on `From' column if sender is yourself"));
1753
        PACK_CHECK_BUTTON
1754
                (vbox2, chkbtn_expand_thread, _("Expand threads"));
1755

    
1756
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1757

    
1758
        hbox1 = gtk_hbox_new (FALSE, 8);
1759
        gtk_widget_show (hbox1);
1760
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1761

    
1762
        label_datefmt = gtk_label_new (_("Date format"));
1763
        gtk_widget_show (label_datefmt);
1764
        gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1765

    
1766
        entry_datefmt = gtk_entry_new ();
1767
        gtk_widget_show (entry_datefmt);
1768
        gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1769

    
1770
        button_datefmt = gtk_button_new_with_label ("... ");
1771
        gtk_widget_show (button_datefmt);
1772
        gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
1773
        g_signal_connect (G_OBJECT (button_datefmt), "clicked",
1774
                          G_CALLBACK (date_format_create), NULL);
1775

    
1776
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1777

    
1778
        hbox1 = gtk_hbox_new (FALSE, 8);
1779
        gtk_widget_show (hbox1);
1780
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1781

    
1782
        button_dispitem = gtk_button_new_with_label
1783
                (_(" Set display item of summary... "));
1784
        gtk_widget_show (button_dispitem);
1785
        gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
1786
        g_signal_connect (G_OBJECT (button_dispitem), "clicked",
1787
                          G_CALLBACK (prefs_common_dispitem_clicked), NULL);
1788

    
1789
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Message"));
1790
        msg_wid = prefs_message_create();
1791
        gtk_box_pack_start(GTK_BOX(vbox_tab), msg_wid, FALSE, FALSE, 0);
1792

    
1793
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Attachment"));
1794
        att_wid = prefs_attach_create();
1795
        gtk_box_pack_start(GTK_BOX(vbox_tab), att_wid, FALSE, FALSE, 0);
1796

    
1797
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Color label"));
1798
        clabel_wid = prefs_colorlabel_create();
1799
        gtk_box_pack_start(GTK_BOX(vbox_tab), clabel_wid, FALSE, FALSE, 0);
1800

    
1801
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Encoding"));
1802

    
1803
        hbox1 = gtk_hbox_new (FALSE, 8);
1804
        gtk_widget_show (hbox1);
1805
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1806

    
1807
        label_dispencoding = gtk_label_new (_("Default character encoding"));
1808
        gtk_widget_show (label_dispencoding);
1809
        gtk_box_pack_start (GTK_BOX (hbox1), label_dispencoding,
1810
                            FALSE, FALSE, 0);
1811

    
1812
        optmenu_dispencoding = gtk_option_menu_new ();
1813
        gtk_widget_show (optmenu_dispencoding);
1814
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_dispencoding,
1815
                            FALSE, FALSE, 0);
1816

    
1817
        prefs_common_set_encoding_optmenu
1818
                (GTK_OPTION_MENU (optmenu_dispencoding), FALSE);
1819

    
1820
        PACK_SMALL_LABEL (vbox_tab, label_encoding_desc,
1821
                          _("This is used when displaying messages with missing character encoding."));
1822

    
1823
        hbox1 = gtk_hbox_new (FALSE, 8);
1824
        gtk_widget_show (hbox1);
1825
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1826

    
1827
        label_outencoding = gtk_label_new (_("Outgoing character encoding"));
1828
        gtk_widget_show (label_outencoding);
1829
        gtk_box_pack_start (GTK_BOX (hbox1), label_outencoding,
1830
                            FALSE, FALSE, 0);
1831

    
1832
        optmenu_outencoding = gtk_option_menu_new ();
1833
        gtk_widget_show (optmenu_outencoding);
1834
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_outencoding,
1835
                            FALSE, FALSE, 0);
1836

    
1837
        prefs_common_set_encoding_optmenu
1838
                (GTK_OPTION_MENU (optmenu_outencoding), TRUE);
1839

    
1840
        PACK_SMALL_LABEL (vbox_tab, label_encoding_desc,
1841
                          _("If `Automatic' is selected, the optimal encoding "
1842
                            "for the current locale will be used."));
1843

    
1844
        display.fontbtn_textfont = fontbtn_textfont;
1845

    
1846
        display.chkbtn_folder_unread      = chkbtn_folder_unread;
1847
        display.chkbtn_folder_col_new     = chkbtn_folder_col_new;
1848
        display.chkbtn_folder_col_unread  = chkbtn_folder_col_unread;
1849
        display.chkbtn_folder_col_total   = chkbtn_folder_col_total;
1850
        display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
1851
        display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
1852

    
1853
        display.chkbtn_swapfrom      = chkbtn_swapfrom;
1854
        display.chkbtn_expand_thread = chkbtn_expand_thread;
1855
        display.entry_datefmt        = entry_datefmt;
1856

    
1857
        display.optmenu_dispencoding = optmenu_dispencoding;
1858
        display.optmenu_outencoding  = optmenu_outencoding;
1859
}
1860

    
1861
static GtkWidget *prefs_message_create(void)
1862
{
1863
        GtkWidget *vbox1;
1864
        GtkWidget *vbox2;
1865
        GtkWidget *vbox3;
1866
        GtkWidget *hbox1;
1867
        GtkWidget *chkbtn_enablecol;
1868
        GtkWidget *button_edit_col;
1869
        GtkWidget *chkbtn_disphdrpane;
1870
        GtkWidget *chkbtn_disphdr;
1871
        GtkWidget *button_edit_disphdr;
1872
        GtkWidget *chkbtn_html;
1873
        GtkWidget *chkbtn_htmlonly;
1874
        GtkWidget *hbox_linespc;
1875
        GtkWidget *label_linespc;
1876
        GtkObject *spinbtn_linespc_adj;
1877
        GtkWidget *spinbtn_linespc;
1878

    
1879
        GtkWidget *frame_scr;
1880
        GtkWidget *vbox_scr;
1881
        GtkWidget *chkbtn_smoothscroll;
1882
        GtkWidget *hbox_scr;
1883
        GtkWidget *label_scr;
1884
        GtkObject *spinbtn_scrollstep_adj;
1885
        GtkWidget *spinbtn_scrollstep;
1886
        GtkWidget *chkbtn_halfpage;
1887

    
1888
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1889
        gtk_widget_show (vbox1);
1890

    
1891
        vbox2 = gtk_vbox_new (FALSE, 0);
1892
        gtk_widget_show (vbox2);
1893
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1894

    
1895
        hbox1 = gtk_hbox_new (FALSE, 8);
1896
        gtk_widget_show (hbox1);
1897
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1898

    
1899
        PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
1900
                           _("Enable coloration of message"));
1901
        g_signal_connect(G_OBJECT(chkbtn_enablecol), "toggled",
1902
                         G_CALLBACK(prefs_enable_message_color_toggled), NULL);
1903

    
1904
        button_edit_col = gtk_button_new_with_label (_(" Edit... "));
1905
        gtk_widget_show (button_edit_col);
1906
        gtk_box_pack_end (GTK_BOX (hbox1), button_edit_col, FALSE, TRUE, 0);
1907
        g_signal_connect (G_OBJECT (button_edit_col), "clicked",
1908
                          G_CALLBACK (prefs_quote_colors_dialog), NULL);
1909

    
1910
        SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
1911

    
1912
#if 0
1913
        PACK_CHECK_BUTTON
1914
                (vbox2, chkbtn_mbalnum,
1915
                 _("Display multi-byte alphabet and numeric as\n"
1916
                   "ASCII character (Japanese only)"));
1917
        gtk_label_set_justify (GTK_LABEL (GTK_BIN(chkbtn_mbalnum)->child),
1918
                               GTK_JUSTIFY_LEFT);
1919
#endif
1920

    
1921
        PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1922
                          _("Display header pane above message view"));
1923

    
1924
        hbox1 = gtk_hbox_new (FALSE, 8);
1925
        gtk_widget_show (hbox1);
1926
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1927

    
1928
        PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1929
                          _("Display short headers on message view"));
1930

    
1931
        button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
1932
        gtk_widget_show (button_edit_disphdr);
1933
        gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
1934
                          FALSE, TRUE, 0);
1935
        g_signal_connect (G_OBJECT (button_edit_disphdr), "clicked",
1936
                          G_CALLBACK (prefs_display_header_open), NULL);
1937

    
1938
        SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1939

    
1940
        PACK_CHECK_BUTTON(vbox2, chkbtn_html,
1941
                          _("Render HTML messages as text"));
1942
        PACK_CHECK_BUTTON(vbox2, chkbtn_htmlonly,
1943
                          _("Treat HTML only messages as attachment"));
1944

    
1945
#if 0
1946
        PACK_CHECK_BUTTON(vbox2, chkbtn_cursor,
1947
                          _("Display cursor in message view"));
1948
#endif
1949

    
1950
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1951

    
1952
        hbox1 = gtk_hbox_new (FALSE, 32);
1953
        gtk_widget_show (hbox1);
1954
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1955

    
1956
        hbox_linespc = gtk_hbox_new (FALSE, 8);
1957
        gtk_widget_show (hbox1);
1958
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
1959

    
1960
        label_linespc = gtk_label_new (_("Line space"));
1961
        gtk_widget_show (label_linespc);
1962
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1963
                            FALSE, FALSE, 0);
1964

    
1965
        spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 0);
1966
        spinbtn_linespc = gtk_spin_button_new
1967
                (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
1968
        gtk_widget_show (spinbtn_linespc);
1969
        gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
1970
                            FALSE, FALSE, 0);
1971
        gtk_widget_set_size_request (spinbtn_linespc, 64, -1);
1972
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
1973

    
1974
        label_linespc = gtk_label_new (_("pixel(s)"));
1975
        gtk_widget_show (label_linespc);
1976
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1977
                            FALSE, FALSE, 0);
1978

    
1979
        PACK_FRAME(vbox1, frame_scr, _("Scroll"));
1980

    
1981
        vbox_scr = gtk_vbox_new (FALSE, 0);
1982
        gtk_widget_show (vbox_scr);
1983
        gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
1984
        gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
1985

    
1986
        PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
1987

    
1988
        hbox1 = gtk_hbox_new (FALSE, 32);
1989
        gtk_widget_show (hbox1);
1990
        gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
1991

    
1992
        PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
1993

    
1994
        hbox_scr = gtk_hbox_new (FALSE, 8);
1995
        gtk_widget_show (hbox_scr);
1996
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
1997

    
1998
        label_scr = gtk_label_new (_("Step"));
1999
        gtk_widget_show (label_scr);
2000
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2001

    
2002
        spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 0);
2003
        spinbtn_scrollstep = gtk_spin_button_new
2004
                (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
2005
        gtk_widget_show (spinbtn_scrollstep);
2006
        gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
2007
                            FALSE, FALSE, 0);
2008
        gtk_widget_set_size_request (spinbtn_scrollstep, 64, -1);
2009
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
2010
                                     TRUE);
2011

    
2012
        label_scr = gtk_label_new (_("pixel(s)"));
2013
        gtk_widget_show (label_scr);
2014
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2015

    
2016
        SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
2017

    
2018
        message.chkbtn_enablecol   = chkbtn_enablecol;
2019
        message.button_edit_col    = button_edit_col;
2020
        message.chkbtn_disphdrpane = chkbtn_disphdrpane;
2021
        message.chkbtn_disphdr     = chkbtn_disphdr;
2022
        message.chkbtn_html        = chkbtn_html;
2023
        message.chkbtn_htmlonly    = chkbtn_htmlonly;
2024
        message.spinbtn_linespc    = spinbtn_linespc;
2025

    
2026
        message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
2027
        message.spinbtn_scrollstep     = spinbtn_scrollstep;
2028
        message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
2029
        message.chkbtn_halfpage        = chkbtn_halfpage;
2030

    
2031
        return vbox1;
2032
}
2033

    
2034
static GtkWidget *prefs_attach_create(void)
2035
{
2036
        GtkWidget *vbox1;
2037
        GtkWidget *vbox2;
2038
        GtkWidget *hbox1;
2039
        GtkWidget *label;
2040
        GtkWidget *radiobtn_attach_toolbtn_pos;
2041
        GtkWidget *radiobtn_attach_toolbtn_pos2;
2042
        GtkWidget *chkbtn_show_attach_tab;
2043
        GtkWidget *chkbtn_show_files_first;
2044
        GtkWidget *frame_image;
2045
        GtkWidget *vbox_image;
2046
        GtkWidget *chkbtn_resize_image;
2047
        GtkWidget *chkbtn_inline_image;
2048

    
2049
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2050
        gtk_widget_show (vbox1);
2051

    
2052
        vbox2 = gtk_vbox_new (FALSE, 0);
2053
        gtk_widget_show (vbox2);
2054
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2055

    
2056
        hbox1 = gtk_hbox_new (FALSE, 8);
2057
        gtk_widget_show (hbox1);
2058
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2059

    
2060
        label = gtk_label_new (_("Position of attachment tool button:"));
2061
        gtk_widget_show (label);
2062
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2063

    
2064
        radiobtn_attach_toolbtn_pos = gtk_radio_button_new_with_label
2065
                (NULL, _("Left"));
2066
        gtk_widget_show (radiobtn_attach_toolbtn_pos);
2067
        gtk_box_pack_start (GTK_BOX(hbox1), radiobtn_attach_toolbtn_pos,
2068
                            FALSE, FALSE, 0);
2069
        g_object_set_data (G_OBJECT (radiobtn_attach_toolbtn_pos), MENU_VAL_ID,
2070
                           GINT_TO_POINTER (0));
2071

    
2072
        radiobtn_attach_toolbtn_pos2 = gtk_radio_button_new_with_label_from_widget
2073
                (GTK_RADIO_BUTTON (radiobtn_attach_toolbtn_pos), _("Right"));
2074
        gtk_widget_show (radiobtn_attach_toolbtn_pos2);
2075
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_attach_toolbtn_pos2,
2076
                            FALSE, FALSE, 0);
2077
        g_object_set_data (G_OBJECT (radiobtn_attach_toolbtn_pos2), MENU_VAL_ID,
2078
                           GINT_TO_POINTER (1));
2079

    
2080
        PACK_CHECK_BUTTON (vbox2, chkbtn_show_attach_tab,
2081
                           _("Toggle attachment list view with tab"));
2082
        SET_TOGGLE_SENSITIVITY_REV (chkbtn_show_attach_tab, hbox1);
2083

    
2084
        PACK_CHECK_BUTTON (vbox2, chkbtn_show_files_first,
2085
                           _("Show attached files first on message view"));
2086

    
2087
        PACK_FRAME(vbox1, frame_image, _("Images"));
2088

    
2089
        vbox_image = gtk_vbox_new (FALSE, 0);
2090
        gtk_widget_show (vbox_image);
2091
        gtk_container_add (GTK_CONTAINER (frame_image), vbox_image);
2092
        gtk_container_set_border_width (GTK_CONTAINER (vbox_image), 8);
2093

    
2094
        PACK_CHECK_BUTTON(vbox_image, chkbtn_resize_image,
2095
                          _("Resize attached large images to fit in the window"));
2096
        PACK_CHECK_BUTTON(vbox_image, chkbtn_inline_image,
2097
                          _("Display images as inline"));
2098

    
2099
        attach.chkbtn_show_attach_tab  = chkbtn_show_attach_tab;
2100
        attach.radiobtn_attach_toolbtn_pos = radiobtn_attach_toolbtn_pos;
2101
        attach.chkbtn_show_files_first = chkbtn_show_files_first;
2102

    
2103
        attach.chkbtn_resize_image = chkbtn_resize_image;
2104
        attach.chkbtn_inline_image = chkbtn_inline_image;
2105

    
2106
        return vbox1;
2107
}
2108

    
2109
static GtkWidget *prefs_colorlabel_create(void)
2110
{
2111
        GtkWidget *vbox;
2112
        GtkWidget *hbox;
2113
        GtkWidget *label;
2114
        GtkWidget *table;
2115
        GtkWidget *clabel;
2116
        GtkWidget *entry;
2117
        gint i;
2118

    
2119
        vbox = gtk_vbox_new(FALSE, VSPACING);
2120
        gtk_widget_show(vbox);
2121
        gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
2122

    
2123
        hbox = gtk_hbox_new(FALSE, 8);
2124
        gtk_widget_show(hbox);
2125
        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
2126

    
2127
        label = gtk_label_new(_("You can specify label names for each color (Work, TODO etc.)."));
2128
        gtk_widget_show(label);
2129
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
2130
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
2131
        gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
2132
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2133

    
2134
        table = gtk_table_new(7, 2, FALSE);
2135
        gtk_widget_show(table);
2136
        gtk_container_add(GTK_CONTAINER(vbox), table);
2137
        gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
2138
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
2139

    
2140
        for (i = 0; i < 7; i++) {
2141
                clabel = colorlabel_create_color_widget
2142
                        (colorlabel_get_color(i));
2143
                gtk_widget_show(clabel);
2144
                gtk_table_attach(GTK_TABLE(table), clabel, 0, 1, i, i + 1,
2145
                                 GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 6);
2146
                entry  = gtk_entry_new();
2147
                gtk_widget_show(entry);
2148
                gtk_table_attach(GTK_TABLE(table), entry, 1, 2, i, i + 1,
2149
                                 GTK_EXPAND | GTK_FILL, 0, 0, 0);
2150
                colorlabel.entry_color[i] = entry;
2151
        }
2152

    
2153
        return vbox;
2154
}
2155

    
2156
static void prefs_common_colorlabel_set_dialog(void)
2157
{
2158
        gint i;
2159
        const gchar *text;
2160

    
2161
        for (i = 0; i < 7; i++) {
2162
                if ((text = colorlabel_get_custom_color_text(i))) {
2163
                        gtk_entry_set_text(GTK_ENTRY(colorlabel.entry_color[i]),
2164
                                           text);
2165
                } else {
2166
                        gtk_entry_set_text(GTK_ENTRY(colorlabel.entry_color[i]),
2167
                                           "");
2168
                }
2169
        }
2170
}
2171

    
2172
static void prefs_common_colorlabel_update(void)
2173
{
2174
        gint i;
2175
        const gchar *text;
2176

    
2177
        for (i = 0; i < 7; i++) {
2178
                text = gtk_entry_get_text(GTK_ENTRY(colorlabel.entry_color[i]));
2179
                if (text && text[0] != '\0')
2180
                        colorlabel_set_color_text(i, text);
2181
                else
2182
                        colorlabel_set_color_text(i, NULL);
2183
        }
2184
        colorlabel_update_menu();
2185
}
2186

    
2187
static const struct {
2188
        gchar *junk_cmd;
2189
        gchar *nojunk_cmd;
2190
        gchar *classify_cmd;
2191
} junk_presets[] = {
2192
#ifdef G_OS_WIN32
2193
        {"bogofilter -N -s -I", "bogofilter -n -S -I", "bogofilter -I"},
2194
        {"bsfilterw -C -s -u", "bsfilterw -c -S -u", "bsfilterw"},
2195
        {"sylfilter -j", "sylfilter -c", "sylfilter"}
2196
#else
2197
        {"bogofilter -N -s -I", "bogofilter -n -S -I", "bogofilter -I"},
2198
        {"bsfilter -C -s -u", "bsfilter -c -S -u", "bsfilter"},
2199
        {"sylfilter -j", "sylfilter -c", "sylfilter"}
2200
#endif
2201
};
2202

    
2203
enum
2204
{
2205
        JUNK_NONE,
2206
        JUNK_BOGOFILTER,
2207
        JUNK_BSFILTER,
2208
        JUNK_SYLFILTER,
2209

    
2210
        N_JUNK_ITEMS
2211
};
2212

    
2213
static void prefs_junk_preset_activated(GtkMenuItem *menuitem, gpointer data)
2214
{
2215
        gint i;
2216

    
2217
        i = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2218
        if (i > JUNK_NONE && i < N_JUNK_ITEMS) {
2219
                i--;
2220
                gtk_entry_set_text(GTK_ENTRY(junk.entry_junk_learncmd),
2221
                                   junk_presets[i].junk_cmd); 
2222
                gtk_entry_set_text(GTK_ENTRY(junk.entry_nojunk_learncmd),
2223
                                   junk_presets[i].nojunk_cmd); 
2224
                gtk_entry_set_text(GTK_ENTRY(junk.entry_classify_cmd),
2225
                                   junk_presets[i].classify_cmd); 
2226
        }
2227
}
2228

    
2229
static void prefs_junk_create(void)
2230
{
2231
        GtkWidget *vbox1;
2232
        GtkWidget *vbox2;
2233
        GtkWidget *frame;
2234
        GtkWidget *hbox;
2235
        GtkWidget *chkbtn_enable_junk;
2236
        GtkWidget *label;
2237
        GtkWidget *optmenu_preset;
2238
        GtkWidget *menu;
2239
        GtkWidget *menuitem;
2240
        GtkWidget *entry_junk_learncmd;
2241
        GtkWidget *entry_nojunk_learncmd;
2242
        GtkWidget *entry_classify_cmd;
2243
        GtkWidget *vbox3;
2244
        GtkWidget *entry_junkfolder;
2245
        GtkWidget *btn_folder;
2246
        GtkWidget *chkbtn_filter_on_recv;
2247
        GtkWidget *chkbtn_filter_before;
2248
        GtkWidget *chkbtn_delete_on_recv;
2249
        GtkWidget *chkbtn_mark_as_read;
2250

    
2251
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2252
        gtk_widget_show (vbox1);
2253
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2254
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2255

    
2256
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame, chkbtn_enable_junk,
2257
                                     _("Enable Junk mail control"));
2258

    
2259
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2260
        gtk_widget_show (vbox2);
2261
        gtk_container_add (GTK_CONTAINER (frame), vbox2);
2262
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2263
        SET_TOGGLE_SENSITIVITY (chkbtn_enable_junk, vbox2);
2264

    
2265
        hbox = gtk_hbox_new (FALSE, 8);
2266
        gtk_widget_show (hbox);
2267
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2268

    
2269
        label = gtk_label_new (_("Learning command:"));
2270
        gtk_widget_show (label);
2271
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2272

    
2273
        optmenu_preset = gtk_option_menu_new ();
2274
        gtk_widget_show (optmenu_preset);
2275
        gtk_box_pack_end (GTK_BOX (hbox), optmenu_preset, FALSE, FALSE, 0);
2276

    
2277
        menu = gtk_menu_new ();
2278
        MENUITEM_ADD (menu, menuitem, _("(Select preset)"), 0);
2279
        MENUITEM_ADD (menu, menuitem, "bogofilter", JUNK_BOGOFILTER);
2280
        g_signal_connect (G_OBJECT (menuitem), "activate",
2281
                          G_CALLBACK (prefs_junk_preset_activated), NULL);
2282
        MENUITEM_ADD (menu, menuitem, "bsfilter", JUNK_BSFILTER);
2283
        g_signal_connect (G_OBJECT (menuitem), "activate",
2284
                          G_CALLBACK (prefs_junk_preset_activated), NULL);
2285
        MENUITEM_ADD (menu, menuitem, "sylfilter", JUNK_SYLFILTER);
2286
        g_signal_connect (G_OBJECT (menuitem), "activate",
2287
                          G_CALLBACK (prefs_junk_preset_activated), NULL);
2288
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_preset), menu);
2289

    
2290
        hbox = gtk_hbox_new (FALSE, 8);
2291
        gtk_widget_show (hbox);
2292
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2293

    
2294
        label = gtk_label_new (_("Junk"));
2295
        gtk_widget_show (label);
2296
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2297

    
2298
        entry_junk_learncmd = gtk_entry_new ();
2299
        gtk_widget_show (entry_junk_learncmd);
2300
        gtk_box_pack_start (GTK_BOX (hbox), entry_junk_learncmd, TRUE, TRUE, 0);
2301

    
2302
        hbox = gtk_hbox_new (FALSE, 8);
2303
        gtk_widget_show (hbox);
2304
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2305

    
2306
        label = gtk_label_new (_("Not Junk"));
2307
        gtk_widget_show (label);
2308
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2309

    
2310
        entry_nojunk_learncmd = gtk_entry_new ();
2311
        gtk_widget_show (entry_nojunk_learncmd);
2312
        gtk_box_pack_start (GTK_BOX (hbox), entry_nojunk_learncmd,
2313
                            TRUE, TRUE, 0);
2314

    
2315
        PACK_VSPACER(vbox2, vbox3, 0);
2316

    
2317
        hbox = gtk_hbox_new (FALSE, 8);
2318
        gtk_widget_show (hbox);
2319
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2320

    
2321
        label = gtk_label_new (_("Classifying command"));
2322
        gtk_widget_show (label);
2323
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2324

    
2325
        entry_classify_cmd = gtk_entry_new ();
2326
        gtk_widget_show (entry_classify_cmd);
2327
        gtk_box_pack_start (GTK_BOX (hbox), entry_classify_cmd, TRUE, TRUE, 0);
2328

    
2329
        PACK_VSPACER(vbox2, vbox3, 0);
2330

    
2331
        PACK_SMALL_LABEL (vbox2, label,
2332
                          _("To classify junk mails automatically, both junk "
2333
                            "and not junk mails must be learned manually to "
2334
                            "a certain extent."));
2335

    
2336
        PACK_VSPACER(vbox2, vbox3, 0);
2337

    
2338
        hbox = gtk_hbox_new (FALSE, 8);
2339
        gtk_widget_show (hbox);
2340
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2341

    
2342
        label = gtk_label_new (_("Junk folder"));
2343
        gtk_widget_show (label);
2344
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2345

    
2346
        entry_junkfolder = gtk_entry_new ();
2347
        gtk_widget_show (entry_junkfolder);
2348
        gtk_box_pack_start (GTK_BOX (hbox), entry_junkfolder, TRUE, TRUE, 0);
2349

    
2350
        btn_folder = gtk_button_new_with_label (_(" ... "));
2351
        gtk_widget_show (btn_folder);
2352
        gtk_box_pack_start (GTK_BOX (hbox), btn_folder, FALSE, FALSE, 0);
2353
        g_signal_connect (G_OBJECT (btn_folder), "clicked",
2354
                          G_CALLBACK (prefs_common_select_folder_cb),
2355
                          entry_junkfolder);
2356

    
2357
        PACK_VSPACER(vbox2, vbox3, 0);
2358

    
2359
        PACK_SMALL_LABEL (vbox2, label,
2360
                          _("The messages which are set as junk mail "
2361
                            "will be moved to this folder. If empty, "
2362
                            "the default junk folder will be used."));
2363

    
2364
        PACK_VSPACER(vbox2, vbox3, 0);
2365

    
2366
        vbox3 = gtk_vbox_new (FALSE, 0);
2367
        gtk_widget_show (vbox3);
2368
        gtk_box_pack_start (GTK_BOX(vbox2), vbox3, FALSE, FALSE, 0);
2369

    
2370
        PACK_CHECK_BUTTON
2371
                (vbox3, chkbtn_filter_on_recv,
2372
                 _("Filter messages classified as junk on receiving"));
2373
        PACK_CHECK_BUTTON
2374
                (vbox3, chkbtn_filter_before,
2375
                 _("Filter junk mails before normal filtering"));
2376
        PACK_CHECK_BUTTON
2377
                (vbox3, chkbtn_delete_on_recv,
2378
                 _("Delete junk mails from server on receiving"));
2379
        SET_TOGGLE_SENSITIVITY (chkbtn_filter_on_recv, chkbtn_filter_before);
2380
        SET_TOGGLE_SENSITIVITY (chkbtn_filter_on_recv, chkbtn_delete_on_recv);
2381

    
2382
        PACK_CHECK_BUTTON (vbox3, chkbtn_mark_as_read,
2383
                           _("Mark filtered junk mails as read"));
2384

    
2385
        junk.chkbtn_enable_junk    = chkbtn_enable_junk;
2386
        junk.entry_junk_learncmd   = entry_junk_learncmd;
2387
        junk.entry_nojunk_learncmd = entry_nojunk_learncmd;
2388
        junk.entry_classify_cmd    = entry_classify_cmd;
2389
        junk.entry_junkfolder      = entry_junkfolder;
2390
        junk.chkbtn_filter_on_recv = chkbtn_filter_on_recv;
2391
        junk.chkbtn_filter_before  = chkbtn_filter_before;
2392
        junk.chkbtn_delete_on_recv = chkbtn_delete_on_recv;
2393
        junk.chkbtn_mark_as_read   = chkbtn_mark_as_read;
2394
}
2395

    
2396
#if USE_GPGME
2397
static void prefs_privacy_create(void)
2398
{
2399
        GtkWidget *vbox1;
2400
        GtkWidget *vbox2;
2401
        GtkWidget *vbox3;
2402
        GtkWidget *hbox1;
2403
        GtkWidget *hbox_spc;
2404
        GtkWidget *label;
2405
        GtkWidget *checkbtn_auto_check_signatures;
2406
        GtkWidget *checkbtn_gpg_signature_popup;
2407
        GtkWidget *checkbtn_store_passphrase;
2408
        GtkObject *spinbtn_store_passphrase_adj;
2409
        GtkWidget *spinbtn_store_passphrase;
2410
#ifndef G_OS_WIN32
2411
        GtkWidget *checkbtn_passphrase_grab;
2412
#endif
2413
        GtkWidget *checkbtn_gpg_warning;
2414

    
2415
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2416
        gtk_widget_show (vbox1);
2417
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2418
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2419

    
2420
        vbox2 = gtk_vbox_new (FALSE, 0);
2421
        gtk_widget_show (vbox2);
2422
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2423

    
2424
        PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
2425
                           _("Automatically check signatures"));
2426

    
2427
        PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup,
2428
                           _("Show signature check result in a popup window"));
2429

    
2430
        PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
2431
                           _("Store passphrase in memory temporarily"));
2432

    
2433
        vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2434
        gtk_widget_show (vbox3);
2435
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2436

    
2437
        hbox1 = gtk_hbox_new (FALSE, 8);
2438
        gtk_widget_show (hbox1);
2439
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2440

    
2441
        hbox_spc = gtk_hbox_new (FALSE, 0);
2442
        gtk_widget_show (hbox_spc);
2443
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2444
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2445

    
2446
        label = gtk_label_new (_("Expired after"));
2447
        gtk_widget_show (label);
2448
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2449

    
2450
        spinbtn_store_passphrase_adj = gtk_adjustment_new (0, 0, 1440, 1, 5, 0);
2451
        spinbtn_store_passphrase = gtk_spin_button_new
2452
                (GTK_ADJUSTMENT (spinbtn_store_passphrase_adj), 1, 0);
2453
        gtk_widget_show (spinbtn_store_passphrase);
2454
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_store_passphrase, FALSE, FALSE, 0);
2455
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_store_passphrase),
2456
                                     TRUE);
2457
        gtk_widget_set_size_request (spinbtn_store_passphrase, 64, -1);
2458

    
2459
        label = gtk_label_new (_("minute(s) "));
2460
        gtk_widget_show (label);
2461
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2462

    
2463
        hbox1 = gtk_hbox_new (FALSE, 8);
2464
        gtk_widget_show (hbox1);
2465
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2466

    
2467
        hbox_spc = gtk_hbox_new (FALSE, 0);
2468
        gtk_widget_show (hbox_spc);
2469
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2470
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2471

    
2472
        PACK_SMALL_LABEL (hbox1, label,
2473
                          _("Setting to '0' will store the passphrase "
2474
                            "for the whole session."));
2475

    
2476
        SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, vbox3);
2477

    
2478
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
2479

    
2480
#ifndef G_OS_WIN32
2481
        PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
2482
                           _("Grab input while entering a passphrase"));
2483
#endif
2484

    
2485
        PACK_CHECK_BUTTON
2486
                (vbox2, checkbtn_gpg_warning,
2487
                 _("Display warning on startup if GnuPG doesn't work"));
2488

    
2489
        hbox1 = gtk_hbox_new (FALSE, 8);
2490
        gtk_widget_show (hbox1);
2491
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2492

    
2493
        privacy.checkbtn_auto_check_signatures
2494
                                             = checkbtn_auto_check_signatures;
2495
        privacy.checkbtn_gpg_signature_popup
2496
                                             = checkbtn_gpg_signature_popup;
2497
        privacy.checkbtn_store_passphrase    = checkbtn_store_passphrase;
2498
        privacy.spinbtn_store_passphrase     = spinbtn_store_passphrase;
2499
        privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
2500
#ifndef G_OS_WIN32
2501
        privacy.checkbtn_passphrase_grab     = checkbtn_passphrase_grab;
2502
#endif
2503
        privacy.checkbtn_gpg_warning         = checkbtn_gpg_warning;
2504
}
2505
#endif /* USE_GPGME */
2506

    
2507
static void prefs_details_create(void)
2508
{
2509
        GtkWidget *vbox1;
2510

    
2511
        GtkWidget *notebook;
2512
        GtkWidget *vbox_tab;
2513

    
2514
        GtkWidget *vbox2;
2515
        GtkWidget *vbox3;
2516
        GtkWidget *checkbtn_always_show_msg;
2517
        GtkWidget *checkbtn_always_mark_read;
2518
        GtkWidget *checkbtn_openunread;
2519
        GtkWidget *checkbtn_remember_lastsel;
2520
        /* GtkWidget *checkbtn_mark_as_read_on_newwin; */
2521
        GtkWidget *checkbtn_openinbox;
2522
        GtkWidget *checkbtn_openinbox_startup;
2523
        GtkWidget *checkbtn_change_account_on_folder_sel;
2524
        GtkWidget *checkbtn_immedexec;
2525
        GtkWidget *hbox1;
2526
        GtkWidget *hbox_spc;
2527
        GtkWidget *label;
2528
#ifndef G_OS_WIN32
2529
        GtkWidget *checkbtn_comply_gnome_hig;
2530
#endif
2531
        GtkWidget *checkbtn_show_trayicon;
2532
        GtkWidget *checkbtn_minimize_to_tray;
2533
        GtkWidget *checkbtn_tray_toggle_window;
2534

    
2535
        GtkWidget *button_keybind;
2536

    
2537
        GtkWidget *other_wid;
2538
        GtkWidget *extcmd_wid;
2539
#if USE_UPDATE_CHECK
2540
        GtkWidget *update_wid;
2541
#endif
2542
        GtkWidget *advanced_wid;
2543

    
2544
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2545
        gtk_widget_show (vbox1);
2546
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2547
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2548

    
2549
        notebook = gtk_notebook_new();
2550
        gtk_widget_show(notebook);
2551
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
2552

    
2553
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Interface"));
2554

    
2555
        vbox2 = gtk_vbox_new (FALSE, 0);
2556
        gtk_widget_show (vbox2);
2557
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
2558

    
2559
        PACK_CHECK_BUTTON
2560
                (vbox2, checkbtn_always_show_msg,
2561
                 _("Always open messages in summary when selected"));
2562

    
2563
        PACK_CHECK_BUTTON
2564
                (vbox2, checkbtn_always_mark_read,
2565
                 _("Always mark as read when a message is opened"));
2566
        SET_TOGGLE_SENSITIVITY
2567
                (checkbtn_always_show_msg, checkbtn_always_mark_read);
2568

    
2569
        PACK_CHECK_BUTTON
2570
                (vbox2, checkbtn_openunread,
2571
                 _("Open first unread message when a folder is opened"));
2572
        SET_TOGGLE_SENSITIVITY_REV
2573
                (checkbtn_always_show_msg, checkbtn_openunread);
2574

    
2575
        PACK_CHECK_BUTTON
2576
                (vbox2, checkbtn_remember_lastsel,
2577
                 _("Remember last selected message"));
2578

    
2579
#if 0
2580
        PACK_CHECK_BUTTON
2581
                (vbox2, checkbtn_mark_as_read_on_newwin,
2582
                 _("Only mark message as read when opened in new window"));
2583
#endif
2584

    
2585
        hbox1 = gtk_hbox_new (FALSE, 8);
2586
        gtk_widget_show (hbox1);
2587
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2588
        PACK_CHECK_BUTTON
2589
                (hbox1, checkbtn_openinbox,
2590
                 _("Open inbox after receiving new mail"));
2591
        PACK_CHECK_BUTTON
2592
                (hbox1, checkbtn_openinbox_startup, _("Open inbox on startup"));
2593

    
2594
        PACK_CHECK_BUTTON
2595
                (vbox2, checkbtn_change_account_on_folder_sel,
2596
                 _("Change current account on folder open"));
2597

    
2598
        vbox3 = gtk_vbox_new (FALSE, 0);
2599
        gtk_widget_show (vbox3);
2600
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2601

    
2602
        PACK_CHECK_BUTTON
2603
                (vbox3, checkbtn_immedexec,
2604
                 _("Execute immediately when moving or deleting messages"));
2605

    
2606
        hbox1 = gtk_hbox_new (FALSE, 8);
2607
        gtk_widget_show (hbox1);
2608
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2609

    
2610
        hbox_spc = gtk_hbox_new (FALSE, 0);
2611
        gtk_widget_show (hbox_spc);
2612
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2613
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2614

    
2615
        PACK_SMALL_LABEL (hbox1, label,
2616
                          _("Messages will be marked until execution "
2617
                            "if this is turned off."));
2618

    
2619
        vbox2 = gtk_vbox_new (FALSE, 0);
2620
        gtk_widget_show (vbox2);
2621
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
2622

    
2623
#ifndef G_OS_WIN32
2624
        PACK_CHECK_BUTTON (vbox2, checkbtn_comply_gnome_hig,
2625
                           _("Make the order of buttons comply with GNOME HIG"));
2626
#endif
2627
        PACK_CHECK_BUTTON (vbox2, checkbtn_show_trayicon,
2628
                           _("Display tray icon"));
2629
        PACK_CHECK_BUTTON (vbox2, checkbtn_minimize_to_tray,
2630
                           _("Minimize to tray icon"));
2631
        PACK_CHECK_BUTTON (vbox2, checkbtn_tray_toggle_window,
2632
                           _("Toggle window on trayicon click"));
2633
        SET_TOGGLE_SENSITIVITY (checkbtn_show_trayicon,
2634
                                checkbtn_minimize_to_tray);
2635
        SET_TOGGLE_SENSITIVITY (checkbtn_show_trayicon,
2636
                                checkbtn_tray_toggle_window);
2637

    
2638
        hbox1 = gtk_hbox_new (FALSE, 8);
2639
        gtk_widget_show (hbox1);
2640
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
2641

    
2642
        button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2643
        gtk_widget_show (button_keybind);
2644
        gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2645
        g_signal_connect (G_OBJECT (button_keybind), "clicked",
2646
                          G_CALLBACK (prefs_keybind_select), NULL);
2647

    
2648
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Other"));
2649
        other_wid = prefs_other_create();
2650
        gtk_box_pack_start(GTK_BOX(vbox_tab), other_wid, FALSE, FALSE, 0);
2651

    
2652
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("External commands"));
2653
        extcmd_wid = prefs_extcmd_create();
2654
        gtk_box_pack_start(GTK_BOX(vbox_tab), extcmd_wid, FALSE, FALSE, 0);
2655

    
2656
#if USE_UPDATE_CHECK
2657
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Update"));
2658
        update_wid = prefs_update_create();
2659
        gtk_box_pack_start(GTK_BOX(vbox_tab), update_wid, FALSE, FALSE, 0);
2660
#endif
2661

    
2662
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Advanced"));
2663
        advanced_wid = prefs_advanced_create();
2664
        gtk_box_pack_start(GTK_BOX(vbox_tab), advanced_wid, FALSE, FALSE, 0);
2665

    
2666
        iface.checkbtn_always_show_msg   = checkbtn_always_show_msg;
2667
        iface.checkbtn_always_mark_read  = checkbtn_always_mark_read;
2668
        iface.checkbtn_openunread        = checkbtn_openunread;
2669
        iface.checkbtn_remember_lastsel  = checkbtn_remember_lastsel;
2670
#if 0
2671
        iface.checkbtn_mark_as_read_on_newwin
2672
                                             = checkbtn_mark_as_read_on_newwin;
2673
#endif
2674
        iface.checkbtn_openinbox         = checkbtn_openinbox;
2675
        iface.checkbtn_openinbox_startup = checkbtn_openinbox_startup;
2676
        iface.checkbtn_change_account_on_folder_sel =
2677
                checkbtn_change_account_on_folder_sel;
2678
        iface.checkbtn_immedexec         = checkbtn_immedexec;
2679

    
2680
#ifndef G_OS_WIN32
2681
        iface.checkbtn_comply_gnome_hig  = checkbtn_comply_gnome_hig;
2682
#endif
2683
        iface.checkbtn_show_trayicon      = checkbtn_show_trayicon;
2684
        iface.checkbtn_minimize_to_tray   = checkbtn_minimize_to_tray;
2685
        iface.checkbtn_tray_toggle_window = checkbtn_tray_toggle_window;
2686
}
2687

    
2688
static GtkWidget *prefs_other_create(void)
2689
{
2690
        GtkWidget *vbox1;
2691

    
2692
        GtkWidget *frame_recv;
2693
        GtkWidget *vbox_recv;
2694
        GtkWidget *hbox1;
2695
        GtkWidget *label;
2696
        GtkWidget *optmenu_recvdialog;
2697
        GtkWidget *menu;
2698
        GtkWidget *menuitem;
2699
        GtkWidget *checkbtn_no_recv_err_panel;
2700
        GtkWidget *checkbtn_close_recv_dialog;
2701

    
2702
        GtkWidget *frame_addr;
2703
        GtkWidget *vbox_addr;
2704
        GtkWidget *checkbtn_addaddrbyclick;
2705
        GtkWidget *checkbtn_add_address_only;
2706
        GtkWidget *vbox_spc;
2707
        GtkWidget *radiobtn_addr_compl;
2708
        GtkWidget *radiobtn_compl_tab;
2709
        GtkWidget *radiobtn_no_compl;
2710

    
2711
        GtkWidget *frame_exit;
2712
        GtkWidget *vbox_exit;
2713
        GtkWidget *checkbtn_confonexit;
2714
        GtkWidget *checkbtn_cleanonexit;
2715
        GtkWidget *checkbtn_askonclean;
2716
        GtkWidget *checkbtn_warnqueued;
2717

    
2718
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2719
        gtk_widget_show (vbox1);
2720

    
2721
        PACK_FRAME (vbox1, frame_recv, _("Receive dialog"));
2722
        vbox_recv = gtk_vbox_new (FALSE, 0);
2723
        gtk_widget_show (vbox_recv);
2724
        gtk_container_add (GTK_CONTAINER (frame_recv), vbox_recv);
2725
        gtk_container_set_border_width (GTK_CONTAINER (vbox_recv), 8);
2726

    
2727
        hbox1 = gtk_hbox_new (FALSE, 8);
2728
        gtk_widget_show (hbox1);
2729
        gtk_box_pack_start (GTK_BOX (vbox_recv), hbox1, FALSE, FALSE, 0);
2730

    
2731
        label = gtk_label_new (_("Show receive dialog"));
2732
        gtk_widget_show (label);
2733
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2734

    
2735
        optmenu_recvdialog = gtk_option_menu_new ();
2736
        gtk_widget_show (optmenu_recvdialog);
2737
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_recvdialog,
2738
                            FALSE, FALSE, 0);
2739

    
2740
        menu = gtk_menu_new ();
2741
        MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
2742
        MENUITEM_ADD (menu, menuitem, _("Only on manual receiving"),
2743
                      RECV_DIALOG_MANUAL);
2744
        MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
2745

    
2746
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
2747

    
2748
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_no_recv_err_panel,
2749
                           _("Don't popup error dialog on receive error"));
2750

    
2751
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_close_recv_dialog,
2752
                           _("Close receive dialog when finished"));
2753

    
2754
        PACK_FRAME (vbox1, frame_addr, _("Address book"));
2755

    
2756
        vbox_addr = gtk_vbox_new (FALSE, 0);
2757
        gtk_widget_show (vbox_addr);
2758
        gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2759
        gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2760

    
2761
        PACK_CHECK_BUTTON
2762
                (vbox_addr, checkbtn_addaddrbyclick,
2763
                 _("Add address to destination when double-clicked"));
2764

    
2765
        PACK_CHECK_BUTTON
2766
                (vbox_addr, checkbtn_add_address_only,
2767
                 _("Set only mail address when entering recipient from address book"));
2768

    
2769
        PACK_VSPACER (vbox_addr, vbox_spc, VSPACING_NARROW_2);
2770

    
2771
        hbox1 = gtk_hbox_new (FALSE, 8);
2772
        gtk_widget_show (hbox1);
2773
        gtk_box_pack_start (GTK_BOX (vbox_addr), hbox1, FALSE, FALSE, 0);
2774

    
2775
        label = gtk_label_new (_("Auto-completion:"));
2776
        gtk_widget_show (label);
2777
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2778

    
2779
        radiobtn_addr_compl = gtk_radio_button_new_with_label
2780
                (NULL, _("Automatic"));
2781
        gtk_widget_show (radiobtn_addr_compl);
2782
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_addr_compl,
2783
                            FALSE, FALSE, 0);
2784
        g_object_set_data (G_OBJECT (radiobtn_addr_compl), MENU_VAL_ID,
2785
                           GINT_TO_POINTER (0));
2786

    
2787
        radiobtn_compl_tab = gtk_radio_button_new_with_label_from_widget
2788
                (GTK_RADIO_BUTTON (radiobtn_addr_compl), _("Start with Tab"));
2789
        gtk_widget_show (radiobtn_compl_tab);
2790
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_compl_tab,
2791
                            FALSE, FALSE, 0);
2792
        g_object_set_data (G_OBJECT (radiobtn_compl_tab), MENU_VAL_ID,
2793
                           GINT_TO_POINTER (1));
2794

    
2795
        radiobtn_no_compl = gtk_radio_button_new_with_label_from_widget
2796
                (GTK_RADIO_BUTTON (radiobtn_addr_compl), _("Disable"));
2797
        gtk_widget_show (radiobtn_no_compl);
2798
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_no_compl,
2799
                            FALSE, FALSE, 0);
2800
        g_object_set_data (G_OBJECT (radiobtn_no_compl), MENU_VAL_ID,
2801
                           GINT_TO_POINTER (2));
2802

    
2803
        PACK_FRAME (vbox1, frame_exit, _("On exit"));
2804

    
2805
        vbox_exit = gtk_vbox_new (FALSE, 0);
2806
        gtk_widget_show (vbox_exit);
2807
        gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2808
        gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2809

    
2810
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2811
                           _("Confirm on exit"));
2812

    
2813
        hbox1 = gtk_hbox_new (FALSE, 32);
2814
        gtk_widget_show (hbox1);
2815
        gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2816

    
2817
        PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2818
                           _("Empty trash on exit"));
2819
        PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2820
                           _("Ask before emptying"));
2821
        SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2822

    
2823
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2824
                           _("Warn if there are queued messages"));
2825

    
2826
        other.optmenu_recvdialog         = optmenu_recvdialog;
2827
        other.checkbtn_no_recv_err_panel = checkbtn_no_recv_err_panel;
2828
        other.checkbtn_close_recv_dialog = checkbtn_close_recv_dialog;
2829

    
2830
        other.checkbtn_addaddrbyclick    = checkbtn_addaddrbyclick;
2831
        other.checkbtn_add_address_only  = checkbtn_add_address_only;
2832
        other.radiobtn_addr_compl        = radiobtn_addr_compl;
2833

    
2834
        other.checkbtn_confonexit  = checkbtn_confonexit;
2835
        other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2836
        other.checkbtn_askonclean  = checkbtn_askonclean;
2837
        other.checkbtn_warnqueued  = checkbtn_warnqueued;
2838

    
2839
        return vbox1;
2840
}
2841

    
2842
static GtkWidget *prefs_extcmd_create(void)
2843
{
2844
        GtkWidget *vbox1;
2845
        GtkWidget *hbox1;
2846

    
2847
        GtkWidget *ext_frame;
2848
        GtkWidget *ext_table;
2849

    
2850
        GtkWidget *uri_label;
2851
        GtkWidget *uri_combo;
2852
        GtkWidget *uri_entry;
2853

    
2854
        GtkWidget *exteditor_label;
2855
        GtkWidget *exteditor_combo;
2856
        GtkWidget *exteditor_entry;
2857

    
2858
        GtkWidget *frame_printcmd;
2859
        GtkWidget *vbox_printcmd;
2860
        GtkWidget *checkbtn_printcmd;
2861
        GtkWidget *printcmd_label;
2862
        GtkWidget *printcmd_entry;
2863

    
2864
#ifndef G_OS_WIN32
2865
        GtkWidget *vbox2;
2866
        GtkWidget *frame_incext;
2867
        GtkWidget *checkbtn_incext;
2868
        GtkWidget *label_incext;
2869
        GtkWidget *entry_incext;
2870
#endif
2871
        GtkWidget *frame_extsend;
2872
        GtkWidget *vbox_extsend;
2873
        GtkWidget *checkbtn_extsend;
2874
        GtkWidget *label_extsend;
2875
        GtkWidget *entry_extsend;
2876

    
2877
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2878
        gtk_widget_show (vbox1);
2879

    
2880
        PACK_FRAME(vbox1, ext_frame,
2881
                   _("External commands (%s will be replaced with file name / URI)"));
2882

    
2883
        ext_table = gtk_table_new (2, 2, FALSE);
2884
        gtk_widget_show (ext_table);
2885
        gtk_container_add (GTK_CONTAINER (ext_frame), ext_table);
2886
        gtk_container_set_border_width (GTK_CONTAINER (ext_table), 8);
2887
        gtk_table_set_row_spacings (GTK_TABLE (ext_table), VSPACING_NARROW);
2888
        gtk_table_set_col_spacings (GTK_TABLE (ext_table), 8);
2889

    
2890
        uri_label = gtk_label_new (_("Web browser"));
2891
        gtk_widget_show(uri_label);
2892
        gtk_table_attach (GTK_TABLE (ext_table), uri_label, 0, 1, 0, 1,
2893
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2894
        gtk_misc_set_alignment (GTK_MISC (uri_label), 1, 0.5);
2895

    
2896
        uri_combo = gtk_combo_new ();
2897
        gtk_widget_show (uri_combo);
2898
        gtk_table_attach (GTK_TABLE (ext_table), uri_combo, 1, 2, 0, 1,
2899
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
2900
        gtkut_combo_set_items (GTK_COMBO (uri_combo),
2901
#if defined(G_OS_WIN32) || defined(__APPLE__)
2902
                               _("(Default browser)"),
2903
#else
2904
                               DEFAULT_BROWSER_CMD,
2905
                               "sensible-browser '%s'",
2906
                               "firefox -remote 'openURL(%s,new-window)'",
2907
                               "firefox '%s'",
2908
                               "mozilla -remote 'openURL(%s,new-window)'",
2909
                               "mozilla '%s'",
2910
                               "rxvt -e w3m '%s'",
2911
                               "rxvt -e lynx '%s'",
2912
#endif
2913
                               NULL);
2914
        uri_entry = GTK_COMBO (uri_combo)->entry;
2915

    
2916
        exteditor_label = gtk_label_new (_("Editor"));
2917
        gtk_widget_show (exteditor_label);
2918
        gtk_table_attach (GTK_TABLE (ext_table), exteditor_label, 0, 1, 1, 2,
2919
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2920
        gtk_misc_set_alignment (GTK_MISC (exteditor_label), 1, 0.5);
2921

    
2922
        exteditor_combo = gtk_combo_new ();
2923
        gtk_widget_show (exteditor_combo);
2924
        gtk_table_attach (GTK_TABLE (ext_table), exteditor_combo, 1, 2, 1, 2,
2925
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
2926
        gtkut_combo_set_items (GTK_COMBO (exteditor_combo),
2927
#ifdef G_OS_WIN32
2928
                               "notepad '%s'",
2929
#elif defined(__APPLE__)
2930
                               "open -t '%s'",
2931
#else
2932
                               "gedit %s",
2933
                               "kedit %s",
2934
                               "emacs %s",
2935
                               "xemacs %s",
2936
                               "rxvt -e jed %s",
2937
                               "rxvt -e vi %s",
2938
#endif
2939
                               NULL);
2940
        exteditor_entry = GTK_COMBO (exteditor_combo)->entry;
2941

    
2942
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_printcmd, checkbtn_printcmd,
2943
                                     _("Use external program for printing"));
2944

    
2945
        vbox_printcmd = gtk_vbox_new (FALSE, VSPACING_NARROW);
2946
        gtk_widget_show (vbox_printcmd);
2947
        gtk_container_add (GTK_CONTAINER (frame_printcmd), vbox_printcmd);
2948
        gtk_container_set_border_width (GTK_CONTAINER (vbox_printcmd), 8);
2949
        SET_TOGGLE_SENSITIVITY (checkbtn_printcmd, vbox_printcmd);
2950

    
2951
        hbox1 = gtk_hbox_new (FALSE, 8);
2952
        gtk_widget_show (hbox1);
2953
        gtk_box_pack_start (GTK_BOX (vbox_printcmd), hbox1, FALSE, FALSE, 0);
2954

    
2955
        printcmd_label = gtk_label_new (_("Command"));
2956
        gtk_widget_show (printcmd_label);
2957
        gtk_box_pack_start (GTK_BOX (hbox1), printcmd_label, FALSE, FALSE, 0);
2958

    
2959
        printcmd_entry = gtk_entry_new ();
2960
        gtk_widget_show (printcmd_entry);
2961
        gtk_box_pack_start (GTK_BOX (hbox1), printcmd_entry, TRUE, TRUE, 0);
2962

    
2963
#ifndef G_OS_WIN32
2964
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_incext, checkbtn_incext,
2965
                                     _("Use external program for incorporation"));
2966

    
2967
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2968
        gtk_widget_show (vbox2);
2969
        gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
2970
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2971
        SET_TOGGLE_SENSITIVITY (checkbtn_incext, vbox2);
2972

    
2973
        hbox1 = gtk_hbox_new (FALSE, 8);
2974
        gtk_widget_show (hbox1);
2975
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2976

    
2977
        label_incext = gtk_label_new (_("Command"));
2978
        gtk_widget_show (label_incext);
2979
        gtk_box_pack_start (GTK_BOX (hbox1), label_incext, FALSE, FALSE, 0);
2980

    
2981
        entry_incext = gtk_entry_new ();
2982
        gtk_widget_show (entry_incext);
2983
        gtk_box_pack_start (GTK_BOX (hbox1), entry_incext, TRUE, TRUE, 0);
2984
#endif /* !G_OS_WIN32 */
2985

    
2986
        PACK_FRAME_WITH_CHECK_BUTTON (vbox1, frame_extsend, checkbtn_extsend,
2987
                                      _("Use external program for sending"));
2988

    
2989
        vbox_extsend = gtk_vbox_new (FALSE, VSPACING_NARROW);
2990
        gtk_widget_show (vbox_extsend);
2991
        gtk_container_add (GTK_CONTAINER (frame_extsend), vbox_extsend);
2992
        gtk_container_set_border_width (GTK_CONTAINER (vbox_extsend), 8);
2993
        SET_TOGGLE_SENSITIVITY(checkbtn_extsend, vbox_extsend);
2994

    
2995
        hbox1 = gtk_hbox_new (FALSE, 8);
2996
        gtk_widget_show (hbox1);
2997
        gtk_box_pack_start (GTK_BOX (vbox_extsend), hbox1, FALSE, FALSE, 0);
2998

    
2999
        label_extsend = gtk_label_new (_("Command"));
3000
        gtk_widget_show (label_extsend);
3001
        gtk_box_pack_start (GTK_BOX (hbox1), label_extsend, FALSE, FALSE, 0);
3002

    
3003
        entry_extsend = gtk_entry_new ();
3004
        gtk_widget_show (entry_extsend);
3005
        gtk_box_pack_start (GTK_BOX (hbox1), entry_extsend, TRUE, TRUE, 0);
3006

    
3007
        extcmd.uri_combo = uri_combo;
3008
        extcmd.uri_entry = uri_entry;
3009
        extcmd.checkbtn_printcmd = checkbtn_printcmd;
3010
        extcmd.printcmd_entry = printcmd_entry;
3011

    
3012
        extcmd.exteditor_combo = exteditor_combo;
3013
        extcmd.exteditor_entry = exteditor_entry;
3014

    
3015
#ifndef G_OS_WIN32
3016
        extcmd.checkbtn_incext = checkbtn_incext;
3017
        extcmd.entry_incext    = entry_incext;
3018
#endif
3019
        extcmd.checkbtn_extsend = checkbtn_extsend;
3020
        extcmd.entry_extsend    = entry_extsend;
3021

    
3022
        return vbox1;
3023
}
3024

    
3025
#if USE_UPDATE_CHECK
3026
static GtkWidget *prefs_update_create(void)
3027
{
3028
        GtkWidget *vbox1;
3029
        GtkWidget *vbox2;
3030
        GtkWidget *checkbtn_autoupdate;
3031
        GtkWidget *checkbtn_useproxy;
3032
        GtkWidget *label;
3033
        GtkWidget *entry_proxyhost;
3034

    
3035
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3036
        gtk_widget_show (vbox1);
3037

    
3038
#ifndef G_OS_WIN32
3039
        label = gtk_label_new (_("Update check requires 'curl' command."));
3040
        gtk_widget_show (label);
3041
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
3042
        gtk_box_pack_start (GTK_BOX (vbox1), label, FALSE, FALSE, 0);
3043
#endif
3044

    
3045
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
3046
        gtk_widget_show (vbox2);
3047
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3048

    
3049
        PACK_CHECK_BUTTON (vbox2, checkbtn_autoupdate,
3050
                           _("Enable auto update check"));
3051
        PACK_CHECK_BUTTON (vbox2, checkbtn_useproxy,
3052
                           _("Use HTTP proxy"));
3053

    
3054
        label = gtk_label_new (_("HTTP proxy host (hostname:port):"));
3055
        gtk_widget_show (label);
3056
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
3057
        gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0);
3058

    
3059
        entry_proxyhost = gtk_entry_new ();
3060
        gtk_widget_show (entry_proxyhost);
3061
        gtk_box_pack_start (GTK_BOX (vbox2), entry_proxyhost, FALSE, FALSE, 0);
3062

    
3063
        SET_TOGGLE_SENSITIVITY(checkbtn_useproxy, label);
3064
        SET_TOGGLE_SENSITIVITY(checkbtn_useproxy, entry_proxyhost);
3065

    
3066
        update_check.checkbtn_autoupdate = checkbtn_autoupdate;
3067
        update_check.checkbtn_useproxy = checkbtn_useproxy;
3068
        update_check.entry_proxyhost = entry_proxyhost;
3069

    
3070
        return vbox1;
3071
}
3072
#endif /* USE_UPDATE_CHECK */
3073

    
3074
static GtkWidget *prefs_advanced_create(void)
3075
{
3076
        GtkWidget *vbox1;
3077

    
3078
        GtkWidget *vbox2;
3079
        GtkWidget *checkbtn_strict_cache_check;
3080
        GtkWidget *label;
3081

    
3082
        GtkWidget *hbox1;
3083
        GtkWidget *label_iotimeout;
3084
        GtkWidget *spinbtn_iotimeout;
3085
        GtkObject *spinbtn_iotimeout_adj;
3086

    
3087
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3088
        gtk_widget_show (vbox1);
3089

    
3090
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
3091
        gtk_widget_show (vbox2);
3092
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3093

    
3094
        PACK_CHECK_BUTTON (vbox2, checkbtn_strict_cache_check,
3095
                           _("Enable strict checking of the integrity of summary caches"));
3096
        PACK_SMALL_LABEL
3097
                (vbox2, label,
3098
                 _("Enable this if the contents of folders have the possibility of modification by other applications.\n"
3099
                   "This option will degrade the performance of displaying summary."));
3100

    
3101
        hbox1 = gtk_hbox_new (FALSE, 8);
3102
        gtk_widget_show (hbox1);
3103
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3104

    
3105
        label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
3106
        gtk_widget_show (label_iotimeout);
3107
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
3108

    
3109
        spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 0);
3110
        spinbtn_iotimeout = gtk_spin_button_new
3111
                (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
3112
        gtk_widget_show (spinbtn_iotimeout);
3113
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
3114
                            FALSE, FALSE, 0);
3115
        gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
3116
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
3117

    
3118
        label_iotimeout = gtk_label_new (_("second(s)"));
3119
        gtk_widget_show (label_iotimeout);
3120
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
3121

    
3122
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
3123
        gtk_widget_show (vbox2);
3124
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3125

    
3126
        advanced.checkbtn_strict_cache_check = checkbtn_strict_cache_check;
3127

    
3128
        advanced.spinbtn_iotimeout     = spinbtn_iotimeout;
3129
        advanced.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
3130

    
3131
        return vbox1;
3132
}
3133

    
3134
static void prefs_common_set_encoding_optmenu(GtkOptionMenu *optmenu,
3135
                                              gboolean outgoing)
3136
{
3137
        GtkWidget *menu;
3138
        GtkWidget *menuitem;
3139

    
3140
        menu = gtk_menu_new();
3141

    
3142
#define SET_MENUITEM(str, data) \
3143
        MENUITEM_ADD(menu, menuitem, str, data)
3144

    
3145
        if (outgoing) {
3146
                SET_MENUITEM(_("Automatic (Recommended)"), NULL);
3147
        } else {
3148
                SET_MENUITEM(_("Automatic"), NULL);
3149
        }
3150
        SET_MENUITEM(NULL, NULL);
3151
        SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
3152
        SET_MENUITEM(NULL, NULL);
3153
        SET_MENUITEM(_("Unicode (UTF-8)"),                 CS_UTF_8);
3154
        SET_MENUITEM(NULL, NULL);
3155
        SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
3156
        SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
3157
        if (!outgoing) {
3158
                SET_MENUITEM(_("Western European (Windows-1252)"),
3159
                             CS_WINDOWS_1252);
3160
        }
3161
        SET_MENUITEM(NULL, NULL);
3162
        SET_MENUITEM(_("Central European (ISO-8859-2)"), CS_ISO_8859_2);
3163
        SET_MENUITEM(NULL, NULL);
3164
        SET_MENUITEM(_("Baltic (ISO-8859-13)"),                 CS_ISO_8859_13);
3165
        SET_MENUITEM(_("Baltic (ISO-8859-4)"),                 CS_ISO_8859_4);
3166
        SET_MENUITEM(_("Baltic (Windows-1257)"),         CS_WINDOWS_1257);
3167
        SET_MENUITEM(NULL, NULL);
3168
        SET_MENUITEM(_("Greek (ISO-8859-7)"),                 CS_ISO_8859_7);
3169
        SET_MENUITEM(NULL, NULL);
3170
        SET_MENUITEM(_("Arabic (ISO-8859-6)"),                 CS_ISO_8859_6);
3171
        SET_MENUITEM(_("Arabic (Windows-1256)"),         CS_WINDOWS_1256);
3172
        SET_MENUITEM(NULL, NULL);
3173
        SET_MENUITEM(_("Hebrew (ISO-8859-8)"),                 CS_ISO_8859_8);
3174
        SET_MENUITEM(_("Hebrew (Windows-1255)"),         CS_WINDOWS_1255);
3175
        SET_MENUITEM(NULL, NULL);
3176
        SET_MENUITEM(_("Turkish (ISO-8859-9)"),                 CS_ISO_8859_9);
3177
        SET_MENUITEM(NULL, NULL);
3178
        SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),         CS_ISO_8859_5);
3179
        SET_MENUITEM(_("Cyrillic (KOI8-R)"),                 CS_KOI8_R);
3180
        SET_MENUITEM(_("Cyrillic (KOI8-U)"),                 CS_KOI8_U);
3181
        SET_MENUITEM(_("Cyrillic (Windows-1251)"),         CS_WINDOWS_1251);
3182
        SET_MENUITEM(NULL, NULL);
3183
        SET_MENUITEM(_("Japanese (ISO-2022-JP)"),         CS_ISO_2022_JP);
3184
        if (!outgoing) {
3185
                SET_MENUITEM(_("Japanese (EUC-JP)"),         CS_EUC_JP);
3186
                SET_MENUITEM(_("Japanese (Shift_JIS)"),         CS_SHIFT_JIS);
3187
        }
3188
        SET_MENUITEM(NULL, NULL);
3189
        SET_MENUITEM(_("Simplified Chinese (GB2312)"),         CS_GB2312);
3190
        SET_MENUITEM(_("Simplified Chinese (GBK)"),         CS_GBK);
3191
        SET_MENUITEM(_("Traditional Chinese (Big5)"),         CS_BIG5);
3192
        if (!outgoing) {
3193
                SET_MENUITEM(_("Traditional Chinese (EUC-TW)"), CS_EUC_TW);
3194
                SET_MENUITEM(_("Chinese (ISO-2022-CN)"),        CS_ISO_2022_CN);
3195
        }
3196
        SET_MENUITEM(NULL, NULL);
3197
        SET_MENUITEM(_("Korean (EUC-KR)"),                 CS_EUC_KR);
3198
        SET_MENUITEM(NULL, NULL);
3199
        SET_MENUITEM(_("Thai (TIS-620)"),                 CS_TIS_620);
3200
        SET_MENUITEM(_("Thai (Windows-874)"),                 CS_WINDOWS_874);
3201

    
3202
#undef SET_MENUITEM
3203

    
3204
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
3205
}
3206

    
3207
static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
3208
{
3209
        GtkWidget *datefmt_sample = NULL;
3210
        gchar *text;
3211

    
3212
        g_return_if_fail(widget != NULL);
3213
        g_return_if_fail(*widget != NULL);
3214
        g_return_if_fail(display.entry_datefmt != NULL);
3215

    
3216
        datefmt_sample = GTK_WIDGET(g_object_get_data
3217
                                    (G_OBJECT(*widget), "datefmt_sample"));
3218
        g_return_if_fail(datefmt_sample != NULL);
3219

    
3220
        text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
3221
        g_free(prefs_common.date_format);
3222
        prefs_common.date_format = text;
3223
        gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
3224

    
3225
        gtk_widget_destroy(*widget);
3226
        *widget = NULL;
3227
}
3228

    
3229
static void date_format_cancel_btn_clicked(GtkButton *button,
3230
                                           GtkWidget **widget)
3231
{
3232
        g_return_if_fail(widget != NULL);
3233
        g_return_if_fail(*widget != NULL);
3234

    
3235
        gtk_widget_destroy(*widget);
3236
        *widget = NULL;
3237
}
3238

    
3239
static gboolean date_format_key_pressed(GtkWidget *keywidget,
3240
                                        GdkEventKey *event,
3241
                                        GtkWidget **widget)
3242
{
3243
        if (event && event->keyval == GDK_Escape)
3244
                date_format_cancel_btn_clicked(NULL, widget);
3245
        return FALSE;
3246
}
3247

    
3248
static gboolean date_format_on_delete(GtkWidget *dialogwidget,
3249
                                      GdkEventAny *event, GtkWidget **widget)
3250
{
3251
        g_return_val_if_fail(widget != NULL, FALSE);
3252
        g_return_val_if_fail(*widget != NULL, FALSE);
3253

    
3254
        *widget = NULL;
3255
        return FALSE;
3256
}
3257

    
3258
static void date_format_entry_on_change(GtkEditable *editable,
3259
                                        GtkLabel *example)
3260
{
3261
        time_t cur_time;
3262
        struct tm *cal_time;
3263
        gchar buffer[100];
3264
        gchar *text;
3265

    
3266
        cur_time = time(NULL);
3267
        cal_time = localtime(&cur_time);
3268
        buffer[0] = 0;
3269
        text = gtk_editable_get_chars(editable, 0, -1);
3270
        if (text)
3271
                strftime(buffer, sizeof buffer, text, cal_time); 
3272
        g_free(text);
3273

    
3274
        text = conv_codeset_strdup(buffer, conv_get_locale_charset_str(),
3275
                                   CS_UTF_8);
3276
        if (!text)
3277
                text = g_strdup(buffer);
3278
        gtk_label_set_text(example, text);
3279
        g_free(text);
3280
}
3281

    
3282
static void date_format_select_row(GtkWidget *date_format_list, gint row,
3283
                                   gint column, GdkEventButton *event,
3284
                                   GtkWidget *date_format)
3285
{
3286
        gint cur_pos;
3287
        gchar *format;
3288
        const gchar *old_format;
3289
        gchar *new_format;
3290
        GtkWidget *datefmt_sample;
3291

    
3292
        /* only on double click */
3293
        if (!event || event->type != GDK_2BUTTON_PRESS) return;
3294

    
3295
        datefmt_sample = GTK_WIDGET(g_object_get_data
3296
                                    (G_OBJECT(date_format), "datefmt_sample"));
3297

    
3298
        g_return_if_fail(date_format_list != NULL);
3299
        g_return_if_fail(date_format != NULL);
3300
        g_return_if_fail(datefmt_sample != NULL);
3301

    
3302
        /* get format from clist */
3303
        gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
3304

    
3305
        cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
3306
        old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
3307

    
3308
        /* insert the format into the text entry */
3309
        new_format = g_malloc(strlen(old_format) + 3);
3310

    
3311
        strncpy(new_format, old_format, cur_pos);
3312
        new_format[cur_pos] = '\0';
3313
        strcat(new_format, format);
3314
        strcat(new_format, &old_format[cur_pos]);
3315

    
3316
        gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
3317
        gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
3318

    
3319
        g_free(new_format);
3320
}
3321

    
3322
static GtkWidget *date_format_create(GtkButton *button, void *data)
3323
{
3324
        static GtkWidget *datefmt_win = NULL;
3325
        GtkWidget *vbox1;
3326
        GtkWidget *scrolledwindow1;
3327
        GtkWidget *datefmt_clist;
3328
        GtkWidget *table;
3329
        GtkWidget *label1;
3330
        GtkWidget *label2;
3331
        GtkWidget *label3;
3332
        GtkWidget *confirm_area;
3333
        GtkWidget *ok_btn;
3334
        GtkWidget *cancel_btn;
3335
        GtkWidget *datefmt_entry;
3336

    
3337
        struct {
3338
                gchar *fmt;
3339
                gchar *txt;
3340
        } time_format[] = {
3341
                { "%a", NULL },
3342
                { "%A", NULL },
3343
                { "%b", NULL },
3344
                { "%B", NULL },
3345
                { "%c", NULL },
3346
                { "%C", NULL },
3347
                { "%d", NULL },
3348
                { "%H", NULL },
3349
                { "%I", NULL },
3350
                { "%j", NULL },
3351
                { "%m", NULL },
3352
                { "%M", NULL },
3353
                { "%p", NULL },
3354
                { "%S", NULL },
3355
                { "%w", NULL },
3356
                { "%x", NULL },
3357
                { "%y", NULL },
3358
                { "%Y", NULL },
3359
                { "%Z", NULL }
3360
        };
3361

    
3362
        gchar *titles[2];
3363
        gint i;
3364
        const gint TIME_FORMAT_ELEMS =
3365
                sizeof time_format / sizeof time_format[0];
3366

    
3367
        time_format[0].txt  = _("the full abbreviated weekday name");
3368
        time_format[1].txt  = _("the full weekday name");
3369
        time_format[2].txt  = _("the abbreviated month name");
3370
        time_format[3].txt  = _("the full month name");
3371
        time_format[4].txt  = _("the preferred date and time for the current locale");
3372
        time_format[5].txt  = _("the century number (year/100)");
3373
        time_format[6].txt  = _("the day of the month as a decimal number");
3374
        time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
3375
        time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
3376
        time_format[9].txt  = _("the day of the year as a decimal number");
3377
        time_format[10].txt = _("the month as a decimal number");
3378
        time_format[11].txt = _("the minute as a decimal number");
3379
        time_format[12].txt = _("either AM or PM");
3380
        time_format[13].txt = _("the second as a decimal number");
3381
        time_format[14].txt = _("the day of the week as a decimal number");
3382
        time_format[15].txt = _("the preferred date for the current locale");
3383
        time_format[16].txt = _("the last two digits of a year");
3384
        time_format[17].txt = _("the year as a decimal number");
3385
        time_format[18].txt = _("the time zone or name or abbreviation");
3386

    
3387
        if (datefmt_win) return datefmt_win;
3388

    
3389
        datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3390
        gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
3391
        gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
3392
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3393
        gtk_widget_set_size_request(datefmt_win, 440, 280);
3394

    
3395
        vbox1 = gtk_vbox_new(FALSE, 10);
3396
        gtk_widget_show(vbox1);
3397
        gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
3398

    
3399
        scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
3400
        gtk_scrolled_window_set_policy
3401
                (GTK_SCROLLED_WINDOW(scrolledwindow1),
3402
                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3403
        gtk_widget_show(scrolledwindow1);
3404
        gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
3405

    
3406
        titles[0] = _("Specifier");
3407
        titles[1] = _("Description");
3408
        datefmt_clist = gtk_clist_new_with_titles(2, titles);
3409
        gtk_widget_show(datefmt_clist);
3410
        gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
3411
        /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
3412
        gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
3413
                                     GTK_SELECTION_BROWSE);
3414

    
3415
        for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
3416
                gchar *text[2];
3417
                /* phoney casting necessary because of gtk... */
3418
                text[0] = (gchar *)time_format[i].fmt;
3419
                text[1] = (gchar *)time_format[i].txt;
3420
                gtk_clist_append(GTK_CLIST(datefmt_clist), text);
3421
        }
3422

    
3423
        table = gtk_table_new(2, 2, FALSE);
3424
        gtk_widget_show(table);
3425
        gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
3426
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
3427
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
3428

    
3429
        label1 = gtk_label_new(_("Date format"));
3430
        gtk_widget_show(label1);
3431
        gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
3432
                         GTK_FILL, 0, 0, 0);
3433
        gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
3434
        gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
3435

    
3436
        datefmt_entry = gtk_entry_new();
3437
        gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
3438
        gtk_widget_show(datefmt_entry);
3439
        gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
3440
                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3441

    
3442
        /* we need the "sample" entry box; add it as data so callbacks can
3443
         * get the entry box */
3444
        g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
3445
                          datefmt_entry);
3446

    
3447
        label2 = gtk_label_new(_("Example"));
3448
        gtk_widget_show(label2);
3449
        gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
3450
                         GTK_FILL, 0, 0, 0);
3451
        gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
3452
        gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
3453

    
3454
        label3 = gtk_label_new("");
3455
        gtk_widget_show(label3);
3456
        gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
3457
                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3458
        gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
3459
        gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
3460

    
3461
        gtkut_stock_button_set_create(&confirm_area, &ok_btn, GTK_STOCK_OK,
3462
                                &cancel_btn, GTK_STOCK_CANCEL, NULL, NULL);
3463

    
3464
        gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
3465
        gtk_widget_show(confirm_area);
3466
        gtk_widget_grab_default(ok_btn);
3467

    
3468
        /* set the current format */
3469
        gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
3470
        date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
3471
                                    GTK_LABEL(label3));
3472

    
3473
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3474
                         G_CALLBACK(date_format_ok_btn_clicked), &datefmt_win);
3475
        g_signal_connect(G_OBJECT(cancel_btn), "clicked",
3476
                         G_CALLBACK(date_format_cancel_btn_clicked),
3477
                         &datefmt_win);
3478
        g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
3479
                         G_CALLBACK(date_format_key_pressed), &datefmt_win);
3480
        g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
3481
                         G_CALLBACK(date_format_on_delete), &datefmt_win);
3482
        g_signal_connect(G_OBJECT(datefmt_entry), "changed",
3483
                         G_CALLBACK(date_format_entry_on_change), label3);
3484
        g_signal_connect(G_OBJECT(datefmt_clist), "select_row",
3485
                         G_CALLBACK(date_format_select_row), datefmt_win);
3486

    
3487
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3488
        gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
3489

    
3490
        gtk_widget_show(datefmt_win);
3491
        manage_window_set_transient(GTK_WINDOW(datefmt_win));
3492

    
3493
        gtk_widget_grab_focus(ok_btn);
3494

    
3495
        return datefmt_win;
3496
}
3497

    
3498
void prefs_quote_colors_dialog(void)
3499
{
3500
        if (!quote_color_win)
3501
                prefs_quote_colors_dialog_create();
3502
        gtk_widget_show(quote_color_win);
3503
        manage_window_set_transient(GTK_WINDOW(quote_color_win));
3504

    
3505
        gtk_main();
3506
        gtk_widget_hide(quote_color_win);
3507
        gtk_window_present(GTK_WINDOW(dialog.window));
3508

    
3509
        main_window_reflect_prefs_all();
3510
}
3511

    
3512
static void prefs_quote_colors_dialog_create(void)
3513
{
3514
        GtkWidget *window;
3515
        GtkWidget *vbox;
3516
        GtkWidget *table;
3517
        GtkWidget *quotelevel1_label;
3518
        GtkWidget *quotelevel2_label;
3519
        GtkWidget *quotelevel3_label;
3520
        GtkWidget *uri_label;
3521
        GtkWidget *hbbox;
3522
        GtkWidget *ok_btn;
3523
        GtkWidget *recycle_colors_btn;
3524
        GtkWidget *frame_colors;
3525

    
3526
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3527
        gtk_container_set_border_width(GTK_CONTAINER(window), 2);
3528
        gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
3529
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
3530
        gtk_window_set_modal(GTK_WINDOW(window), TRUE);
3531
        gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
3532

    
3533
        vbox = gtk_vbox_new (FALSE, VSPACING);
3534
        gtk_container_add (GTK_CONTAINER (window), vbox);
3535
        gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
3536
        PACK_FRAME(vbox, frame_colors, _("Colors"));
3537

    
3538
        table = gtk_table_new (4, 2, FALSE);
3539
        gtk_container_add (GTK_CONTAINER (frame_colors), table);
3540
        gtk_container_set_border_width (GTK_CONTAINER (table), 8);
3541
        gtk_table_set_row_spacings (GTK_TABLE (table), 2);
3542
        gtk_table_set_col_spacings (GTK_TABLE (table), 4);
3543

    
3544
        color_buttons.quote_level1_btn = gtk_button_new();
3545
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level1_btn,
3546
                          0, 1, 0, 1, 0, 0, 0, 0);
3547
        gtk_widget_set_size_request (color_buttons.quote_level1_btn, 40, 30);
3548
        gtk_container_set_border_width
3549
                (GTK_CONTAINER (color_buttons.quote_level1_btn), 5);
3550

    
3551
        color_buttons.quote_level2_btn = gtk_button_new();
3552
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level2_btn,
3553
                          0, 1, 1, 2, 0, 0, 0, 0);
3554
        gtk_widget_set_size_request (color_buttons.quote_level2_btn, 40, 30);
3555
        gtk_container_set_border_width (GTK_CONTAINER (color_buttons.quote_level2_btn), 5);
3556

    
3557
        color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
3558
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
3559
                          0, 1, 2, 3, 0, 0, 0, 0);
3560
        gtk_widget_set_size_request (color_buttons.quote_level3_btn, 40, 30);
3561
        gtk_container_set_border_width
3562
                (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
3563

    
3564
        color_buttons.uri_btn = gtk_button_new_with_label ("");
3565
        gtk_table_attach (GTK_TABLE (table), color_buttons.uri_btn,
3566
                          0, 1, 3, 4, 0, 0, 0, 0);
3567
        gtk_widget_set_size_request (color_buttons.uri_btn, 40, 30);
3568
        gtk_container_set_border_width (GTK_CONTAINER (color_buttons.uri_btn), 5);
3569

    
3570
        quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
3571
        gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
3572
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3573
        gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
3574
        gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
3575

    
3576
        quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
3577
        gtk_table_attach (GTK_TABLE (table), quotelevel2_label, 1, 2, 1, 2,
3578
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3579
        gtk_label_set_justify (GTK_LABEL (quotelevel2_label), GTK_JUSTIFY_LEFT);
3580
        gtk_misc_set_alignment (GTK_MISC (quotelevel2_label), 0, 0.5);
3581

    
3582
        quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
3583
        gtk_table_attach (GTK_TABLE (table), quotelevel3_label, 1, 2, 2, 3,
3584
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3585
        gtk_label_set_justify (GTK_LABEL (quotelevel3_label), GTK_JUSTIFY_LEFT);
3586
        gtk_misc_set_alignment (GTK_MISC (quotelevel3_label), 0, 0.5);
3587

    
3588
        uri_label = gtk_label_new (_("URI link"));
3589
        gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
3590
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3591
        gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
3592
        gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
3593

    
3594
        PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
3595
                           _("Recycle quote colors"));
3596

    
3597
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
3598
                                      NULL, NULL, NULL, NULL);
3599
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3600

    
3601
        gtk_widget_grab_default(ok_btn);
3602
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
3603
        g_signal_connect (G_OBJECT (window), "delete_event",
3604
                          G_CALLBACK (prefs_quote_colors_deleted), NULL);
3605
        g_signal_connect(G_OBJECT(window), "key_press_event",
3606
                         G_CALLBACK(prefs_quote_colors_key_pressed), NULL);
3607

    
3608
        g_signal_connect(G_OBJECT(color_buttons.quote_level1_btn), "clicked",
3609
                         G_CALLBACK(quote_color_set_dialog), "LEVEL1");
3610
        g_signal_connect(G_OBJECT(color_buttons.quote_level2_btn), "clicked",
3611
                         G_CALLBACK(quote_color_set_dialog), "LEVEL2");
3612
        g_signal_connect(G_OBJECT(color_buttons.quote_level3_btn), "clicked",
3613
                         G_CALLBACK(quote_color_set_dialog), "LEVEL3");
3614
        g_signal_connect(G_OBJECT(color_buttons.uri_btn), "clicked",
3615
                         G_CALLBACK(quote_color_set_dialog), "URI");
3616
        g_signal_connect(G_OBJECT(recycle_colors_btn), "toggled",
3617
                         G_CALLBACK(prefs_recycle_colors_toggled), NULL);
3618
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3619
                         G_CALLBACK(gtk_main_quit), NULL);
3620

    
3621
        /* show message button colors and recycle options */
3622
        set_button_bg_color(color_buttons.quote_level1_btn,
3623
                            prefs_common.quote_level1_col);
3624
        set_button_bg_color(color_buttons.quote_level2_btn,
3625
                            prefs_common.quote_level2_col);
3626
        set_button_bg_color(color_buttons.quote_level3_btn,
3627
                            prefs_common.quote_level3_col);
3628
        set_button_bg_color(color_buttons.uri_btn,
3629
                            prefs_common.uri_col);
3630
        gtk_toggle_button_set_active((GtkToggleButton *)recycle_colors_btn,
3631
                                     prefs_common.recycle_quote_colors);
3632

    
3633
        gtk_widget_show_all(vbox);
3634
        quote_color_win = window;
3635
}
3636

    
3637
static gint prefs_quote_colors_deleted(GtkWidget *widet, GdkEventAny *event,
3638
                                       gpointer data)
3639
{
3640
        gtk_main_quit();
3641
        return TRUE;
3642
}
3643

    
3644
static gboolean prefs_quote_colors_key_pressed(GtkWidget *widget,
3645
                                               GdkEventKey *event,
3646
                                               gpointer data)
3647
{
3648
        if (event && event->keyval == GDK_Escape)
3649
                gtk_main_quit();
3650
        return FALSE;
3651
}
3652

    
3653
static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
3654
{
3655
        gchar *type = (gchar *)data;
3656
        gchar *title = NULL;
3657
        gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
3658
        gint rgbvalue = 0;
3659
        GtkColorSelectionDialog *dialog;
3660

    
3661
        if(g_ascii_strcasecmp(type, "LEVEL1") == 0) {
3662
                title = _("Pick color for quotation level 1");
3663
                rgbvalue = prefs_common.quote_level1_col;
3664
        } else if(g_ascii_strcasecmp(type, "LEVEL2") == 0) {
3665
                title = _("Pick color for quotation level 2");
3666
                rgbvalue = prefs_common.quote_level2_col;
3667
        } else if(g_ascii_strcasecmp(type, "LEVEL3") == 0) {
3668
                title = _("Pick color for quotation level 3");
3669
                rgbvalue = prefs_common.quote_level3_col;
3670
        } else if(g_ascii_strcasecmp(type, "URI") == 0) {
3671
                title = _("Pick color for URI");
3672
                rgbvalue = prefs_common.uri_col;
3673
        } else {   /* Should never be called */
3674
                g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
3675
                return;
3676
        }
3677

    
3678
        color_dialog = gtk_color_selection_dialog_new(title);
3679
        gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
3680
        gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
3681
        gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
3682
        manage_window_set_transient(GTK_WINDOW(color_dialog));
3683

    
3684
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
3685
                         "clicked", G_CALLBACK(quote_colors_set_dialog_ok), data);
3686
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
3687
                         "clicked", G_CALLBACK(quote_colors_set_dialog_cancel), data);
3688
        g_signal_connect(G_OBJECT(color_dialog), "key_press_event",
3689
                         G_CALLBACK(quote_colors_set_dialog_key_pressed), data);
3690

    
3691
        /* preselect the previous color in the color selection dialog */
3692
        color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
3693
        color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
3694
        color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
3695
        dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
3696
        gtk_color_selection_set_color
3697
                (GTK_COLOR_SELECTION(dialog->colorsel), color);
3698

    
3699
        gtk_widget_show(color_dialog);
3700
}
3701

    
3702
static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
3703
{
3704
        GtkColorSelection *colorsel = (GtkColorSelection *)
3705
                                                ((GtkColorSelectionDialog *)color_dialog)->colorsel;
3706
        gdouble color[4];
3707
        gint red, green, blue, rgbvalue;
3708
        gchar *type = (gchar *)data;
3709

    
3710
        gtk_color_selection_get_color(colorsel, color);
3711

    
3712
        red      = (gint) (color[0] * 255.0);
3713
        green    = (gint) (color[1] * 255.0);
3714
        blue     = (gint) (color[2] * 255.0);
3715
        rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
3716

    
3717
#if 0
3718
        fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
3719
        fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
3720
        fprintf(stderr, "Color is %x\n", rgbvalue);
3721
#endif
3722

    
3723
        if (g_ascii_strcasecmp(type, "LEVEL1") == 0) {
3724
                prefs_common.quote_level1_col = rgbvalue;
3725
                set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
3726
        } else if (g_ascii_strcasecmp(type, "LEVEL2") == 0) {
3727
                prefs_common.quote_level2_col = rgbvalue;
3728
                set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
3729
        } else if (g_ascii_strcasecmp(type, "LEVEL3") == 0) {
3730
                prefs_common.quote_level3_col = rgbvalue;
3731
                set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
3732
        } else if (g_ascii_strcasecmp(type, "URI") == 0) {
3733
                prefs_common.uri_col = rgbvalue;
3734
                set_button_bg_color(color_buttons.uri_btn, rgbvalue);
3735
        } else
3736
                fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
3737

    
3738
        gtk_widget_destroy(color_dialog);
3739
}
3740

    
3741
static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
3742
{
3743
        gtk_widget_destroy(color_dialog);
3744
}
3745

    
3746
static gboolean quote_colors_set_dialog_key_pressed(GtkWidget *widget,
3747
                                                    GdkEventKey *event,
3748
                                                    gpointer data)
3749
{
3750
        if (event && event->keyval == GDK_Escape) {
3751
                gtk_widget_destroy(color_dialog);
3752
                return TRUE;
3753
        }
3754
        return FALSE;
3755
}
3756

    
3757
static void set_button_bg_color(GtkWidget *widget, gint rgbvalue)
3758
{
3759
        GtkStyle *newstyle;
3760
        GdkColor color;
3761

    
3762
        gtkut_convert_int_to_gdk_color(rgbvalue, &color);
3763
        newstyle = gtk_style_copy(gtk_widget_get_default_style());
3764
        newstyle->bg[GTK_STATE_NORMAL]   = color;
3765
        newstyle->bg[GTK_STATE_PRELIGHT] = color;
3766
        newstyle->bg[GTK_STATE_ACTIVE]   = color;
3767

    
3768
        gtk_widget_set_style(GTK_WIDGET(widget), newstyle);
3769
}
3770

    
3771
static void prefs_enable_message_color_toggled(void)
3772
{
3773
        gboolean is_active;
3774

    
3775
        is_active = gtk_toggle_button_get_active
3776
                (GTK_TOGGLE_BUTTON(message.chkbtn_enablecol));
3777
        gtk_widget_set_sensitive(message.button_edit_col, is_active);
3778
        prefs_common.enable_color = is_active;
3779
}
3780

    
3781
static void prefs_recycle_colors_toggled(GtkWidget *widget)
3782
{
3783
        gboolean is_active;
3784

    
3785
        is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3786
        prefs_common.recycle_quote_colors = is_active;
3787
}
3788

    
3789
void prefs_quote_description(void)
3790
{
3791
        if (!quote_desc_win)
3792
                prefs_quote_description_create();
3793

    
3794
        manage_window_set_transient(GTK_WINDOW(quote_desc_win));
3795
        gtk_widget_show(quote_desc_win);
3796
        gtk_main();
3797
        gtk_widget_hide(quote_desc_win);
3798
}
3799

    
3800
static void prefs_quote_description_create(void)
3801
{
3802
        GtkWidget *vbox;
3803
        GtkWidget *hbox;
3804
        GtkWidget *vbox2;
3805
        GtkWidget *label;
3806
        GtkWidget *hbbox;
3807
        GtkWidget *ok_btn;
3808

    
3809
        quote_desc_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3810
        gtk_window_set_title(GTK_WINDOW(quote_desc_win),
3811
                             _("Description of symbols"));
3812
        gtk_container_set_border_width(GTK_CONTAINER(quote_desc_win), 8);
3813
        gtk_window_set_position(GTK_WINDOW(quote_desc_win), GTK_WIN_POS_CENTER);
3814
        gtk_window_set_modal(GTK_WINDOW(quote_desc_win), TRUE);
3815
        gtk_window_set_policy(GTK_WINDOW(quote_desc_win), FALSE, FALSE, FALSE);
3816

    
3817
        vbox = gtk_vbox_new(FALSE, 8);
3818
        gtk_container_add(GTK_CONTAINER(quote_desc_win), vbox);
3819

    
3820
        hbox = gtk_hbox_new(FALSE, 8);
3821
        gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
3822

    
3823
        vbox2 = gtk_vbox_new(FALSE, 8);
3824
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
3825

    
3826
#define PACK_LABEL() \
3827
        gtk_box_pack_start(GTK_BOX(vbox2), label, TRUE, TRUE, 0); \
3828
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); \
3829
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
3830

    
3831
        label = gtk_label_new
3832
                ("%d\n"                /* date */
3833
                 "%f\n"                /* from */
3834
                 "%N\n"                /* full name of sender */
3835
                 "%F\n"                /* first name of sender */
3836
                 "%I\n"                /* initial of sender */
3837
                 "%s\n"                /* subject */
3838
                 "%t\n"                /* to */
3839
                 "%c\n"                /* cc */
3840
                 "%n\n"                /* newsgroups */
3841
                 "%i");                /* message id */
3842
        PACK_LABEL();
3843

    
3844
        label = gtk_label_new
3845
                ("?x{expr}");        /* condition */
3846
        PACK_LABEL();
3847

    
3848
        label = gtk_label_new
3849
                ("%M\n"                /* message body */
3850
                 "%Q\n"                /* quoted message body */
3851
                 "%m\n"                /* message body without signature */
3852
                 "%q\n"                /* quoted message body without signature */
3853
                 "%%");                /* literal percent */
3854
        PACK_LABEL();
3855

    
3856
        label = gtk_label_new
3857
                ("\\\\\n"        /* literal backslash */
3858
                 "\\?\n"        /* literal question mark */
3859
                 "\\{\n"        /* literal opening curly brace */
3860
                 "\\}");        /* literal closing curly brace */
3861
        PACK_LABEL();
3862

    
3863
        vbox2 = gtk_vbox_new(FALSE, 8);
3864
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
3865

    
3866
        label = gtk_label_new
3867
                (_("Date\n"
3868
                   "From\n"
3869
                   "Full Name of Sender\n"
3870
                   "First Name of Sender\n"
3871
                   "Initial of Sender\n"
3872
                   "Subject\n"
3873
                   "To\n"
3874
                   "Cc\n"
3875
                   "Newsgroups\n"
3876
                   "Message-ID"));
3877
        PACK_LABEL();
3878

    
3879
        label = gtk_label_new
3880
                (_("If x is set, displays expr"));
3881
        PACK_LABEL();
3882

    
3883
        label = gtk_label_new
3884
                (_("Message body\n"
3885
                   "Quoted message body\n"
3886
                   "Message body without signature\n"
3887
                   "Quoted message body without signature\n"
3888
                   "Literal %"));
3889
        PACK_LABEL();
3890

    
3891
        label = gtk_label_new
3892
                (_("Literal backslash\n"
3893
                   "Literal question mark\n"
3894
                   "Literal opening curly brace\n"
3895
                   "Literal closing curly brace"));
3896
        PACK_LABEL();
3897

    
3898
#undef PACK_LABEL
3899

    
3900
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
3901
                                      NULL, NULL, NULL, NULL);
3902
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3903

    
3904
        gtk_widget_grab_default(ok_btn);
3905
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3906
                         G_CALLBACK(gtk_main_quit), NULL);
3907
        g_signal_connect
3908
                (G_OBJECT(quote_desc_win), "key_press_event",
3909
                 G_CALLBACK(prefs_quote_description_key_pressed), NULL);
3910
        g_signal_connect(G_OBJECT(quote_desc_win), "delete_event",
3911
                         G_CALLBACK(prefs_quote_description_deleted), NULL);
3912

    
3913
        gtk_widget_show_all(vbox);
3914
}
3915

    
3916
static gboolean prefs_quote_description_key_pressed(GtkWidget *widget,
3917
                                                    GdkEventKey *event,
3918
                                                    gpointer data)
3919
{
3920
        if (event && event->keyval == GDK_Escape)
3921
                gtk_main_quit();
3922
        return FALSE;
3923
}
3924

    
3925
static gboolean prefs_quote_description_deleted(GtkWidget *widget,
3926
                                                GdkEventAny *event,
3927
                                                gpointer data)
3928
{
3929
        gtk_main_quit();
3930
        return TRUE;
3931
}
3932

    
3933
static void prefs_keybind_select(void)
3934
{
3935
        GtkWidget *window;
3936
        GtkWidget *vbox1;
3937
        GtkWidget *hbox1;
3938
        GtkWidget *label;
3939
        GtkWidget *combo;
3940
        GtkWidget *confirm_area;
3941
        GtkWidget *ok_btn;
3942
        GtkWidget *cancel_btn;
3943

    
3944
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3945
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
3946
        gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
3947
        gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
3948
        gtk_window_set_modal (GTK_WINDOW (window), TRUE);
3949
        gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, FALSE);
3950
        manage_window_set_transient (GTK_WINDOW (window));
3951

    
3952
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3953
        gtk_container_add (GTK_CONTAINER (window), vbox1);
3954
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
3955

    
3956
        hbox1 = gtk_hbox_new (FALSE, 8);
3957
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3958

    
3959
        label = gtk_label_new(_("Select the preset of key bindings."));
3960
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
3961
        gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3962

    
3963
        hbox1 = gtk_hbox_new (FALSE, 8);
3964
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3965

    
3966
        combo = gtk_combo_new ();
3967
        gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
3968
        gtkut_combo_set_items (GTK_COMBO (combo),
3969
                               _("Default"),
3970
                               "Mew / Wanderlust",
3971
                               "Mutt",
3972
                               _("Old Sylpheed"),
3973
                               NULL);
3974
        gtk_editable_set_editable
3975
                (GTK_EDITABLE (GTK_COMBO (combo)->entry), FALSE);
3976

    
3977
        hbox1 = gtk_hbox_new (FALSE, 8);
3978
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3979

    
3980
        gtkut_stock_button_set_create (&confirm_area, &ok_btn, GTK_STOCK_OK,
3981
                                       &cancel_btn, GTK_STOCK_CANCEL,
3982
                                       NULL, NULL);
3983
        gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
3984
        gtk_widget_grab_default (ok_btn);
3985

    
3986
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
3987
        g_signal_connect (G_OBJECT (window), "delete_event",
3988
                          G_CALLBACK (prefs_keybind_deleted), NULL);
3989
        g_signal_connect (G_OBJECT (window), "key_press_event",
3990
                          G_CALLBACK (prefs_keybind_key_pressed), NULL);
3991
        g_signal_connect (G_OBJECT (ok_btn), "clicked",
3992
                          G_CALLBACK (prefs_keybind_apply_clicked), NULL);
3993
        g_signal_connect (G_OBJECT (cancel_btn), "clicked",
3994
                          G_CALLBACK (prefs_keybind_cancel), NULL);
3995

    
3996
        gtk_widget_show_all(window);
3997

    
3998
        keybind.window = window;
3999
        keybind.combo = combo;
4000
}
4001

    
4002
static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
4003
                                          gpointer data)
4004
{
4005
        if (event && event->keyval == GDK_Escape)
4006
                prefs_keybind_cancel();
4007
        return FALSE;
4008
}
4009

    
4010
static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
4011
                                  gpointer data)
4012
{
4013
        prefs_keybind_cancel();
4014
        return TRUE;
4015
}
4016

    
4017
static void prefs_keybind_cancel(void)
4018
{
4019
        gtk_widget_destroy(keybind.window);
4020
        keybind.window = NULL;
4021
        keybind.combo = NULL;
4022
}
4023

    
4024
struct KeyBind {
4025
        const gchar *accel_path;
4026
        const gchar *accel_key;
4027
};
4028

    
4029
static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
4030
{
4031
        gint i;
4032
        guint key;
4033
        GdkModifierType mods;
4034

    
4035
        for (i = 0; i < num; i++) {
4036
                const gchar *accel_key =
4037
                        keybind[i].accel_key ? keybind[i].accel_key : "";
4038
                gtk_accelerator_parse(accel_key, &key, &mods);
4039
                gtk_accel_map_change_entry(keybind[i].accel_path,
4040
                                           key, mods, TRUE);
4041
        }
4042
}
4043

    
4044
static void prefs_keybind_apply_clicked(GtkWidget *widget)
4045
{
4046
        GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
4047
        const gchar *text;
4048
        struct KeyBind *menurc;
4049
        gint n_menurc;
4050

    
4051
        static struct KeyBind default_menurc[] = {
4052
                {"<Main>/File/Empty all trash",                        ""},
4053
                {"<Main>/File/Save as...",                        "<control>S"},
4054
                {"<Main>/File/Print...",                        ""},
4055
                {"<Main>/File/Exit",                                "<control>Q"},
4056

    
4057
                {"<Main>/Edit/Copy",                                "<control>C"},
4058
                {"<Main>/Edit/Select all",                        "<control>A"},
4059
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4060
                {"<Main>/Edit/Search messages...",                "<shift><control>F"},
4061

    
4062
                {"<Main>/View/Show or hide/Message view",        "V"},
4063
                {"<Main>/View/Thread view",                        "<control>T"},
4064
                {"<Main>/View/Go to/Prev message",                "P"},
4065
                {"<Main>/View/Go to/Next message",                "N"},
4066
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
4067
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
4068
                {"<Main>/View/Go to/Other folder...",                "G"},
4069
                {"<Main>/View/Open in new window",                "<control><alt>N"},
4070
                {"<Main>/View/View source",                        "<control>U"},
4071
                {"<Main>/View/Show all headers",                "<control>H"},
4072
                {"<Main>/View/Update",                                "<control><alt>U"},
4073

    
4074
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
4075
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
4076
                {"<Main>/Message/Compose new message",                "<control>M"},
4077
                {"<Main>/Message/Reply",                        "<control>R"},
4078
                {"<Main>/Message/Reply to/all",                        "<shift><control>R"},
4079
                {"<Main>/Message/Reply to/sender",                ""},
4080
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
4081
                {"<Main>/Message/Forward",                        "<control><alt>F"},
4082
                {"<Main>/Message/Forward as attachment",        ""},
4083
                {"<Main>/Message/Move...",                        "<control>O"},
4084
                {"<Main>/Message/Copy...",                        "<shift><control>O"},
4085
                {"<Main>/Message/Delete",                        "<control>D"},
4086
                {"<Main>/Message/Mark/Set flag",                "<shift>asterisk"},
4087
                {"<Main>/Message/Mark/Unset flag",                "U"},
4088
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
4089
                {"<Main>/Message/Mark/Mark as read",                ""},
4090

    
4091
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
4092
                {"<Main>/Tools/Execute",                        "X"},
4093
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
4094

    
4095
                {"<Compose>/File/Close",                        "<control>W"},
4096
                {"<Compose>/Edit/Select all",                        "<control>A"},
4097
        };
4098

    
4099
        static struct KeyBind mew_wl_menurc[] = {
4100
                {"<Main>/File/Empty all trash",                        "<shift>D"},
4101
                {"<Main>/File/Save as...",                        "Y"},
4102
                {"<Main>/File/Print...",                        "<shift>numbersign"},
4103
                {"<Main>/File/Exit",                                "<shift>Q"},
4104

    
4105
                {"<Main>/Edit/Copy",                                "<control>C"},
4106
                {"<Main>/Edit/Select all",                        "<control>A"},
4107
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4108
                {"<Main>/Edit/Search messages...",                "<control>S"},
4109

    
4110
                {"<Main>/View/Show or hide/Message view",        "V"},
4111
                {"<Main>/View/Thread view",                        "<shift>T"},
4112
                {"<Main>/View/Go to/Prev message",                "P"},
4113
                {"<Main>/View/Go to/Next message",                "N"},
4114
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
4115
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
4116
                {"<Main>/View/Go to/Other folder...",                "G"},
4117
                {"<Main>/View/Open in new window",                "<control><alt>N"},
4118
                {"<Main>/View/View source",                        "<control>U"},
4119
                {"<Main>/View/Show all headers",                "<shift>H"},
4120
                {"<Main>/View/Update",                                "<shift>S"},
4121

    
4122
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
4123
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
4124
                {"<Main>/Message/Compose new message",                "W"},
4125
                {"<Main>/Message/Reply",                        "<control>R"},
4126
                {"<Main>/Message/Reply to/all",                        "<shift>A"},
4127
                {"<Main>/Message/Reply to/sender",                ""},
4128
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
4129
                {"<Main>/Message/Forward",                        "F"},
4130
                {"<Main>/Message/Forward as attachment",        "<shift>F"},
4131
                {"<Main>/Message/Move...",                        "O"},
4132
                {"<Main>/Message/Copy...",                        "<shift>O"},
4133
                {"<Main>/Message/Delete",                        "D"},
4134
                {"<Main>/Message/Mark/Set flag",                "<shift>asterisk"},
4135
                {"<Main>/Message/Mark/Unset flag",                "U"},
4136
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
4137
                {"<Main>/Message/Mark/Mark as read",                "<shift>R"},
4138

    
4139
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
4140
                {"<Main>/Tools/Execute",                        "X"},
4141
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
4142

    
4143
                {"<Compose>/File/Close",                        "<alt>W"},
4144
                {"<Compose>/Edit/Select all",                        ""},
4145
        };
4146

    
4147
        static struct KeyBind mutt_menurc[] = {
4148
                {"<Main>/File/Empty all trash",                        ""},
4149
                {"<Main>/File/Save as...",                        "S"},
4150
                {"<Main>/File/Print...",                        "P"},
4151
                {"<Main>/File/Exit",                                "Q"},
4152

    
4153
                {"<Main>/Edit/Copy",                                "<control>C"},
4154
                {"<Main>/Edit/Select all",                        "<control>A"},
4155
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4156
                {"<Main>/Edit/Search messages...",                "slash"},
4157

    
4158
                {"<Main>/View/Show or hide/Message view",        "V"},
4159
                {"<Main>/View/Thread view",                        "<control>T"},
4160
                {"<Main>/View/Go to/Prev message",                ""},
4161
                {"<Main>/View/Go to/Next message",                ""},
4162
                {"<Main>/View/Go to/Prev unread message",        ""},
4163
                {"<Main>/View/Go to/Next unread message",        ""},
4164
                {"<Main>/View/Go to/Other folder...",                "C"},
4165
                {"<Main>/View/Open in new window",                "<control><alt>N"},
4166
                {"<Main>/View/View source",                        "<control>U"},
4167
                {"<Main>/View/Show all headers",                "<control>H"},
4168
                {"<Main>/View/Update",                                "<control><alt>U"},
4169

    
4170
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
4171
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
4172
                {"<Main>/Message/Compose new message",                "M"},
4173
                {"<Main>/Message/Reply",                        "R"},
4174
                {"<Main>/Message/Reply to/all",                        "G"},
4175
                {"<Main>/Message/Reply to/sender",                ""},
4176
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
4177
                {"<Main>/Message/Forward",                        "F"},
4178
                {"<Main>/Message/Forward as attachment",        ""},
4179
                {"<Main>/Message/Move...",                        "<control>O"},
4180
                {"<Main>/Message/Copy...",                        "<shift>C"},
4181
                {"<Main>/Message/Delete",                        "D"},
4182
                {"<Main>/Message/Mark/Set flag",                "<shift>F"},
4183
                {"<Main>/Message/Mark/Unset flag",                "U"},
4184
                {"<Main>/Message/Mark/Mark as unread",                "<shift>N"},
4185
                {"<Main>/Message/Mark/Mark as read",                ""},
4186

    
4187
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
4188
                {"<Main>/Tools/Execute",                        "X"},
4189
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
4190

    
4191
                {"<Compose>/File/Close",                        "<alt>W"},
4192
                {"<Compose>/Edit/Select all",                        ""},
4193
        };
4194

    
4195
        static struct KeyBind old_sylpheed_menurc[] = {
4196
                {"<Main>/File/Empty all trash",                        ""},
4197
                {"<Main>/File/Save as...",                        ""},
4198
                {"<Main>/File/Print...",                        "<alt>P"},
4199
                {"<Main>/File/Exit",                                "<alt>Q"},
4200

    
4201
                {"<Main>/Edit/Copy",                                "<control>C"},
4202
                {"<Main>/Edit/Select all",                        "<control>A"},
4203
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4204
                {"<Main>/Edit/Search messages...",                "<control>S"},
4205

    
4206
                {"<Main>/View/Show or hide/Message view",        "V"},
4207
                {"<Main>/View/Thread view",                        "<control>T"},
4208
                {"<Main>/View/Go to/Prev message",                "P"},
4209
                {"<Main>/View/Go to/Next message",                "N"},
4210
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
4211
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
4212
                {"<Main>/View/Go to/Other folder...",                "<alt>G"},
4213
                {"<Main>/View/Open in new window",                "<shift><control>N"},
4214
                {"<Main>/View/View source",                        "<control>U"},
4215
                {"<Main>/View/Show all headers",                "<control>H"},
4216
                {"<Main>/View/Update",                                "<alt>U"},
4217

    
4218
                {"<Main>/Message/Receive/Get new mail",                        "<alt>I"},
4219
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><alt>I"},
4220
                {"<Main>/Message/Compose new message",                "<alt>N"},
4221
                {"<Main>/Message/Reply",                        "<alt>R"},
4222
                {"<Main>/Message/Reply to/all",                        "<shift><alt>R"},
4223
                {"<Main>/Message/Reply to/sender",                "<control><alt>R"},
4224
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
4225
                {"<Main>/Message/Forward",                        "<shift><alt>F"},
4226
                {"<Main>/Message/Forward as attachment",        "<shift><control>F"},
4227
                {"<Main>/Message/Move...",                        "<alt>O"},
4228
                {"<Main>/Message/Copy...",                        ""},
4229
                {"<Main>/Message/Delete",                        "<alt>D"},
4230
                {"<Main>/Message/Mark/Set flag",                "<shift>asterisk"},
4231
                {"<Main>/Message/Mark/Unset flag",                "U"},
4232
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
4233
                {"<Main>/Message/Mark/Mark as read",                ""},
4234

    
4235
                {"<Main>/Tools/Address book",                        "<alt>A"},
4236
                {"<Main>/Tools/Execute",                        "<alt>X"},
4237
                {"<Main>/Tools/Log window",                        "<alt>L"},
4238

    
4239
                {"<Compose>/File/Close",                        "<alt>W"},
4240
                {"<Compose>/Edit/Select all",                        ""},
4241
        };
4242

    
4243
        static struct KeyBind empty_menurc[] = {
4244
                {"<Main>/File/Empty all trash",                        ""},
4245
                {"<Main>/File/Save as...",                        ""},
4246
                {"<Main>/File/Print...",                        ""},
4247
                {"<Main>/File/Exit",                                ""},
4248

    
4249
                {"<Main>/Edit/Copy",                                ""},
4250
                {"<Main>/Edit/Select all",                        ""},
4251
                {"<Main>/Edit/Find in current message...",        ""},
4252
                {"<Main>/Edit/Search messages...",                ""},
4253

    
4254
                {"<Main>/View/Show or hide/Message view",        ""},
4255
                {"<Main>/View/Thread view",                        ""},
4256
                {"<Main>/View/Go to/Prev message",                ""},
4257
                {"<Main>/View/Go to/Next message",                ""},
4258
                {"<Main>/View/Go to/Prev unread message",        ""},
4259
                {"<Main>/View/Go to/Next unread message",        ""},
4260
                {"<Main>/View/Go to/Other folder...",                ""},
4261
                {"<Main>/View/Open in new window",                ""},
4262
                {"<Main>/View/View source",                        ""},
4263
                {"<Main>/View/Show all headers",                ""},
4264
                {"<Main>/View/Update",                                ""},
4265

    
4266
                {"<Main>/Message/Receive/Get new mail",                        ""},
4267
                {"<Main>/Message/Receive/Get from all accounts",        ""},
4268
                {"<Main>/Message/Compose new message",                ""},
4269
                {"<Main>/Message/Reply",                        ""},
4270
                {"<Main>/Message/Reply to/all",                        ""},
4271
                {"<Main>/Message/Reply to/sender",                ""},
4272
                {"<Main>/Message/Reply to/mailing list",        ""},
4273
                {"<Main>/Message/Forward",                        ""},
4274
                {"<Main>/Message/Forward as attachment",        ""},
4275
                {"<Main>/Message/Move...",                        ""},
4276
                {"<Main>/Message/Copy...",                        ""},
4277
                {"<Main>/Message/Delete",                        ""},
4278
                {"<Main>/Message/Mark/Set flag",                ""},
4279
                {"<Main>/Message/Mark/Unset flag",                ""},
4280
                {"<Main>/Message/Mark/Mark as unread",                ""},
4281
                {"<Main>/Message/Mark/Mark as read",                ""},
4282

    
4283
                {"<Main>/Tools/Address book",                        ""},
4284
                {"<Main>/Tools/Execute",                        ""},
4285
                {"<Main>/Tools/Log window",                        ""},
4286

    
4287
                {"<Compose>/File/Close",                        ""},
4288
                {"<Compose>/Edit/Select all",                        ""},
4289
        };
4290

    
4291
        text = gtk_entry_get_text(entry);
4292

    
4293
        if (!strcmp(text, _("Default"))) {
4294
                menurc = default_menurc;
4295
                n_menurc = G_N_ELEMENTS(default_menurc);
4296
        } else if (!strcmp(text, "Mew / Wanderlust")) {
4297
                menurc = mew_wl_menurc;
4298
                n_menurc = G_N_ELEMENTS(mew_wl_menurc);
4299
        } else if (!strcmp(text, "Mutt")) {
4300
                menurc = mutt_menurc;
4301
                n_menurc = G_N_ELEMENTS(mutt_menurc);
4302
        } else if (!strcmp(text, _("Old Sylpheed"))) {
4303
                menurc = old_sylpheed_menurc;
4304
                n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
4305
        } else
4306
                return;
4307

    
4308
        prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc));
4309
        prefs_keybind_apply(menurc, n_menurc);
4310

    
4311
        gtk_widget_destroy(keybind.window);
4312
        keybind.window = NULL;
4313
        keybind.combo = NULL;
4314
}
4315

    
4316
static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
4317
{
4318
        PrefsUIData *ui_data;
4319
        GtkWidget *menu;
4320
        GtkWidget *menuitem;
4321
        gchar *charset;
4322

    
4323
        ui_data = (PrefsUIData *)pparam->ui_data;
4324
        g_return_if_fail(ui_data != NULL);
4325
        g_return_if_fail(*ui_data->widget != NULL);
4326

    
4327
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*ui_data->widget));
4328
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
4329
        charset = g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
4330
        g_free(*((gchar **)pparam->data));
4331
        *((gchar **)pparam->data) = g_strdup(charset);
4332
}
4333

    
4334
static void prefs_common_charset_set_optmenu(PrefParam *pparam)
4335
{
4336
        PrefsUIData *ui_data;
4337
        GtkOptionMenu *optmenu;
4338
        gint index;
4339

    
4340
        ui_data = (PrefsUIData *)pparam->ui_data;
4341
        g_return_if_fail(ui_data != NULL);
4342
        g_return_if_fail(*ui_data->widget != NULL);
4343

    
4344
        optmenu = GTK_OPTION_MENU(*ui_data->widget);
4345
        g_return_if_fail(optmenu != NULL);
4346

    
4347
        index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
4348
                                            (GCompareFunc)strcmp2);
4349
        if (index >= 0)
4350
                gtk_option_menu_set_history(optmenu, index);
4351
        else {
4352
                gtk_option_menu_set_history(optmenu, 0);
4353
                prefs_common_charset_set_data_from_optmenu(pparam);
4354
        }
4355
}
4356

    
4357
static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
4358
{
4359
        PrefsUIData *ui_data;
4360
        RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
4361
        GtkOptionMenu *optmenu;
4362
        GtkWidget *menu;
4363
        GtkWidget *menuitem;
4364
        gint index;
4365

    
4366
        ui_data = (PrefsUIData *)pparam->ui_data;
4367
        g_return_if_fail(ui_data != NULL);
4368
        g_return_if_fail(*ui_data->widget != NULL);
4369

    
4370
        optmenu = GTK_OPTION_MENU(*ui_data->widget);
4371
        g_return_if_fail(optmenu != NULL);
4372

    
4373
        index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(mode),
4374
                                            NULL);
4375
        if (index >= 0)
4376
                gtk_option_menu_set_history(optmenu, index);
4377
        else {
4378
                gtk_option_menu_set_history(optmenu, 0);
4379
                prefs_set_data_from_optmenu(pparam);
4380
        }
4381

    
4382
        menu = gtk_option_menu_get_menu(optmenu);
4383
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
4384
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
4385
}
4386

    
4387
static void prefs_common_uri_set_data_from_entry(PrefParam *pparam)
4388
{
4389
        PrefsUIData *ui_data;
4390
        gchar **str;
4391
        const gchar *entry_str;
4392

    
4393
        ui_data = (PrefsUIData *)pparam->ui_data;
4394
        g_return_if_fail(ui_data != NULL);
4395
        g_return_if_fail(*ui_data->widget != NULL);
4396

    
4397
        entry_str = gtk_entry_get_text(GTK_ENTRY(*ui_data->widget));
4398

    
4399
        if (pparam->type == P_STRING) {
4400
                str = (gchar **)pparam->data;
4401
                g_free(*str);
4402

    
4403
                if (entry_str[0] == '\0' ||
4404
                    !strcmp(_("(Default browser)"), entry_str))
4405
                        *str = NULL;
4406
                else
4407
                        *str = g_strdup(entry_str);
4408
        } else {
4409
                g_warning("Invalid type for URI setting\n");
4410
        }
4411
}
4412

    
4413
static void prefs_common_uri_set_entry(PrefParam *pparam)
4414
{
4415
        PrefsUIData *ui_data;
4416
        gchar **str;
4417

    
4418
        ui_data = (PrefsUIData *)pparam->ui_data;
4419
        g_return_if_fail(ui_data != NULL);
4420
        g_return_if_fail(*ui_data->widget != NULL);
4421

    
4422
        if (pparam->type == P_STRING) {
4423
                str = (gchar **)pparam->data;
4424
                gtk_entry_set_text(GTK_ENTRY(*ui_data->widget),
4425
                                   *str ? *str : _("(Default browser)"));
4426
        } else {
4427
                g_warning("Invalid type for URI setting\n");
4428
        }
4429
}
4430

    
4431
static void prefs_common_addr_compl_set_data_from_radiobtn(PrefParam *pparam)
4432
{
4433
        PrefsUIData *ui_data;
4434
        GtkRadioButton *radiobtn;
4435
        GSList *group;
4436

    
4437
        ui_data = (PrefsUIData *)pparam->ui_data;
4438
        g_return_if_fail(ui_data != NULL);
4439
        g_return_if_fail(*ui_data->widget != NULL);
4440

    
4441
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4442
        group = gtk_radio_button_get_group(radiobtn);
4443
        while (group != NULL) {
4444
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4445
                gint mode;
4446

    
4447
                if (gtk_toggle_button_get_active(btn)) {
4448
                        mode = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
4449
                                                                 MENU_VAL_ID));
4450
                        if (mode == 2) {
4451
                                prefs_common.enable_address_completion = FALSE;
4452
                                prefs_common.fullauto_completion_mode = FALSE;
4453
                        } else {
4454
                                prefs_common.enable_address_completion = TRUE;
4455
                                if (mode == 0)
4456
                                        prefs_common.fullauto_completion_mode = TRUE;
4457
                                else
4458
                                        prefs_common.fullauto_completion_mode = FALSE;
4459
                        }
4460
                        break;
4461
                }
4462
                group = group->next;
4463
        }
4464
}
4465

    
4466
static void prefs_common_addr_compl_set_radiobtn(PrefParam *pparam)
4467
{
4468
        PrefsUIData *ui_data;
4469
        GtkRadioButton *radiobtn;
4470
        GSList *group;
4471
        gint mode;
4472

    
4473
        if (prefs_common.enable_address_completion) {
4474
                if (prefs_common.fullauto_completion_mode)
4475
                        mode = 0;
4476
                else
4477
                        mode = 1;
4478
        } else
4479
                mode = 2;
4480

    
4481
        ui_data = (PrefsUIData *)pparam->ui_data;
4482
        g_return_if_fail(ui_data != NULL);
4483
        g_return_if_fail(*ui_data->widget != NULL);
4484

    
4485
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4486
        group = gtk_radio_button_get_group(radiobtn);
4487
        while (group != NULL) {
4488
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4489
                gint data;
4490

    
4491
                data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
4492
                                                         MENU_VAL_ID));
4493
                if (data == mode) {
4494
                        gtk_toggle_button_set_active(btn, TRUE);
4495
                        break;
4496
                }
4497
                group = group->next;
4498
        }
4499
}
4500

    
4501
static void prefs_common_attach_toolbtn_pos_set_data_from_radiobtn(PrefParam *pparam)
4502
{
4503
        PrefsUIData *ui_data;
4504
        GtkRadioButton *radiobtn;
4505
        GSList *group;
4506

    
4507
        ui_data = (PrefsUIData *)pparam->ui_data;
4508
        g_return_if_fail(ui_data != NULL);
4509
        g_return_if_fail(*ui_data->widget != NULL);
4510

    
4511
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4512
        group = gtk_radio_button_get_group(radiobtn);
4513
        while (group != NULL) {
4514
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4515

    
4516
                if (gtk_toggle_button_get_active(btn)) {
4517
                        prefs_common.attach_toolbutton_pos =
4518
                                GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn), MENU_VAL_ID));
4519
                        break;
4520
                }
4521
                group = group->next;
4522
        }
4523
}
4524

    
4525
static void prefs_common_attach_toolbtn_pos_set_radiobtn(PrefParam *pparam)
4526
{
4527
        PrefsUIData *ui_data;
4528
        GtkRadioButton *radiobtn;
4529
        GSList *group;
4530

    
4531
        ui_data = (PrefsUIData *)pparam->ui_data;
4532
        g_return_if_fail(ui_data != NULL);
4533
        g_return_if_fail(*ui_data->widget != NULL);
4534

    
4535
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4536
        group = gtk_radio_button_get_group(radiobtn);
4537
        while (group != NULL) {
4538
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4539
                gint data;
4540

    
4541
                data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
4542
                                                         MENU_VAL_ID));
4543
                if (data == prefs_common.attach_toolbutton_pos) {