Statistics
| Revision:

root / src / prefs_common_dialog.c @ 3253

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_prefer_html;
166
        GtkWidget *chkbtn_htmlonly;
167
        GtkWidget *spinbtn_linespc;
168
        GtkObject *spinbtn_linespc_adj;
169

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

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

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

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

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

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

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

    
234
static struct Other {
235
        GtkWidget *optmenu_recvdialog;
236
        GtkWidget *checkbtn_no_recv_err_panel;
237
        GtkWidget *checkbtn_close_recv_dialog;
238

    
239
        GtkWidget *checkbtn_addaddrbyclick;
240
        GtkWidget *checkbtn_add_address_only;
241
        GtkWidget *radiobtn_addr_compl;
242

    
243
        GtkWidget *checkbtn_confonexit;
244
        GtkWidget *checkbtn_cleanonexit;
245
        GtkWidget *checkbtn_askonclean;
246
        GtkWidget *checkbtn_warnqueued;
247
} other;
248

    
249
static struct Extcmd {
250
        GtkWidget *uri_combo;
251
        GtkWidget *uri_entry;
252
        GtkWidget *exteditor_combo;
253
        GtkWidget *exteditor_entry;
254

    
255
        GtkWidget *checkbtn_printcmd;
256
        GtkWidget *printcmd_entry;
257

    
258
        GtkWidget *checkbtn_incext;
259
        GtkWidget *entry_incext;
260
        GtkWidget *button_incext;
261

    
262
        GtkWidget *checkbtn_extsend;
263
        GtkWidget *entry_extsend;
264
        GtkWidget *button_extsend;
265
} extcmd;
266

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

    
275
static struct Advanced {
276
        GtkWidget *checkbtn_strict_cache_check;
277

    
278
        GtkWidget *spinbtn_iotimeout;
279
        GtkObject *spinbtn_iotimeout_adj;
280
} advanced;
281

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

    
289
static struct KeybindDialog {
290
        GtkWidget *window;
291
        GtkWidget *combo;
292
} keybind;
293

    
294
static GtkWidget *quote_desc_win;
295
static GtkWidget *quote_color_win;
296
static GtkWidget *color_dialog;
297

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

    
304
static void prefs_common_addr_compl_set_data_from_radiobtn (PrefParam *pparam);
305
static void prefs_common_addr_compl_set_radiobtn           (PrefParam *pparam);
306

    
307
static void prefs_common_attach_toolbtn_pos_set_data_from_radiobtn (PrefParam *pparam);
308
static void prefs_common_attach_toolbtn_pos_set_radiobtn           (PrefParam *pparam);
309

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

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

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

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

    
365
        /* {"allow_jisx0201_kana", NULL, NULL, NULL}, */
366

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

    
373
        {"auto_ext_editor", &compose.checkbtn_autoextedit,
374
         prefs_set_data_from_toggle, prefs_set_toggle},
375

    
376
        {"undo_level", &compose.spinbtn_undolevel,
377
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
378

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

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

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

    
405
        /* {"show_ruler", NULL, NULL, NULL}, */
406

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

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

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

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

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

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

    
449
#if 0
450
        {"enable_rules_hint", NULL, NULL, NULL},
451
#endif /* 0 */
452

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

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

    
474
        /* {"textview_cursor_visible", NULL, NULL, NULL}, */
475

    
476
        {"enable_smooth_scroll", &message.chkbtn_smoothscroll,
477
         prefs_set_data_from_toggle, prefs_set_toggle},
478
        {"scroll_step", &message.spinbtn_scrollstep,
479
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
480
        {"scroll_half_page", &message.chkbtn_halfpage,
481
         prefs_set_data_from_toggle, prefs_set_toggle},
482

    
483
        /* Attachment */
484
        {"attach_toolbutton_pos", &attach.radiobtn_attach_toolbtn_pos,
485
         prefs_common_attach_toolbtn_pos_set_data_from_radiobtn,
486
         prefs_common_attach_toolbtn_pos_set_radiobtn},
487
        {"show_attach_tab", &attach.chkbtn_show_attach_tab,
488
         prefs_set_data_from_toggle, prefs_set_toggle},
489
        {"show_attached_files_first", &attach.chkbtn_show_files_first,
490
         prefs_set_data_from_toggle, prefs_set_toggle},
491

    
492
        {"resize_image", &attach.chkbtn_resize_image,
493
         prefs_set_data_from_toggle, prefs_set_toggle},
494
        {"inline_image", &attach.chkbtn_inline_image,
495
         prefs_set_data_from_toggle, prefs_set_toggle},
496

    
497
        /* Encoding */
498
        {"default_encoding", &display.optmenu_dispencoding,
499
         prefs_common_charset_set_data_from_optmenu,
500
         prefs_common_charset_set_optmenu},
501
        {"outgoing_charset", &display.optmenu_outencoding,
502
         prefs_common_charset_set_data_from_optmenu,
503
         prefs_common_charset_set_optmenu},
504

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

    
527
#if USE_GPGME
528
        /* Privacy */
529
        {"auto_check_signatures",
530
         &privacy.checkbtn_auto_check_signatures,
531
         prefs_set_data_from_toggle, prefs_set_toggle},
532
        {"gpg_signature_popup", &privacy.checkbtn_gpg_signature_popup,
533
         prefs_set_data_from_toggle, prefs_set_toggle},
534
        {"store_passphrase", &privacy.checkbtn_store_passphrase,
535
         prefs_set_data_from_toggle, prefs_set_toggle},
536
        {"store_passphrase_timeout", &privacy.spinbtn_store_passphrase,
537
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
538
#ifndef G_OS_WIN32
539
        {"passphrase_grab", &privacy.checkbtn_passphrase_grab,
540
         prefs_set_data_from_toggle, prefs_set_toggle},
541
#endif /* G_OS_WIN32 */
542
        {"show_gpg_warning", &privacy.checkbtn_gpg_warning,
543
         prefs_set_data_from_toggle, prefs_set_toggle},
544
#endif /* USE_GPGME */
545

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

    
571
#ifndef G_OS_WIN32
572
        {"comply_gnome_hig", &iface.checkbtn_comply_gnome_hig,
573
         prefs_set_data_from_toggle, prefs_set_toggle},
574
#endif
575
        {"show_trayicon", &iface.checkbtn_show_trayicon,
576
         prefs_set_data_from_toggle, prefs_set_toggle},
577
        {"minimize_to_tray", &iface.checkbtn_minimize_to_tray,
578
         prefs_set_data_from_toggle, prefs_set_toggle},
579
        {"toggle_window_on_trayicon_click",
580
         &iface.checkbtn_tray_toggle_window,
581
         prefs_set_data_from_toggle, prefs_set_toggle},
582

    
583
        /* Other */
584
        {"receive_dialog_mode", &other.optmenu_recvdialog,
585
         prefs_set_data_from_optmenu, prefs_common_recv_dialog_set_optmenu},
586
        {"no_receive_error_panel", &other.checkbtn_no_recv_err_panel,
587
         prefs_set_data_from_toggle, prefs_set_toggle},
588
        {"close_receive_dialog", &other.checkbtn_close_recv_dialog,
589
         prefs_set_data_from_toggle, prefs_set_toggle},
590

    
591
        {"add_address_by_click", &other.checkbtn_addaddrbyclick,
592
         prefs_set_data_from_toggle, prefs_set_toggle},
593
        {"always_add_address_only", &other.checkbtn_add_address_only,
594
         prefs_set_data_from_toggle, prefs_set_toggle},
595
        {"enable_address_completion", &other.radiobtn_addr_compl,
596
         prefs_common_addr_compl_set_data_from_radiobtn,
597
         prefs_common_addr_compl_set_radiobtn},
598

    
599
        {"confirm_on_exit", &other.checkbtn_confonexit,
600
         prefs_set_data_from_toggle, prefs_set_toggle},
601
        {"clean_trash_on_exit", &other.checkbtn_cleanonexit,
602
         prefs_set_data_from_toggle, prefs_set_toggle},
603
        {"ask_on_cleaning", &other.checkbtn_askonclean,
604
         prefs_set_data_from_toggle, prefs_set_toggle},
605
        {"warn_queued_on_exit", &other.checkbtn_warnqueued,
606
         prefs_set_data_from_toggle, prefs_set_toggle},
607

    
608
        /* {"logwindow_line_limit", NULL, NULL, NULL}, */
609

    
610
        /* External commands */
611
        {"uri_open_command", &extcmd.uri_entry,
612
         prefs_common_uri_set_data_from_entry, prefs_common_uri_set_entry},
613
        {"ext_editor_command", &extcmd.exteditor_entry,
614
         prefs_set_data_from_entry, prefs_set_entry},
615

    
616
        {"use_print_command", &extcmd.checkbtn_printcmd,
617
         prefs_set_data_from_toggle, prefs_set_toggle},
618
        {"print_command", &extcmd.printcmd_entry,
619
         prefs_set_data_from_entry, prefs_set_entry},
620

    
621
#ifndef G_OS_WIN32
622
        {"use_ext_inc", &extcmd.checkbtn_incext,
623
         prefs_set_data_from_toggle, prefs_set_toggle},
624
        {"ext_inc_path", &extcmd.entry_incext,
625
         prefs_set_data_from_entry, prefs_set_entry},
626
#endif
627
        {"use_ext_sendmail", &extcmd.checkbtn_extsend,
628
         prefs_set_data_from_toggle, prefs_set_toggle},
629
        {"ext_sendmail_cmd", &extcmd.entry_extsend,
630
         prefs_set_data_from_entry, prefs_set_entry},
631

    
632
        /* Update check */
633
#if USE_UPDATE_CHECK
634
        {"auto_update_check", &update_check.checkbtn_autoupdate,
635
         prefs_set_data_from_toggle, prefs_set_toggle},
636
        {"use_http_proxy", &update_check.checkbtn_useproxy,
637
         prefs_set_data_from_toggle, prefs_set_toggle},
638
        {"http_proxy_host", &update_check.entry_proxyhost,
639
         prefs_set_data_from_entry, prefs_set_entry},
640
#endif
641

    
642
        /* Advanced */
643
        {"strict_cache_check", &advanced.checkbtn_strict_cache_check,
644
         prefs_set_data_from_toggle, prefs_set_toggle},
645
        {"io_timeout_secs", &advanced.spinbtn_iotimeout,
646
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
647

    
648
        {NULL, NULL, NULL, NULL}
649
};
650

    
651
/* widget creating functions */
652
static void prefs_common_create                (void);
653
static void prefs_receive_create        (void);
654
static void prefs_send_create                (void);
655
static void prefs_compose_create        (void);
656
static GtkWidget *prefs_quote_create        (void);
657
#if USE_GTKSPELL
658
static GtkWidget *prefs_spell_create        (void);
659
#endif
660
static void prefs_display_create        (void);
661
static GtkWidget *prefs_message_create        (void);
662
static GtkWidget *prefs_attach_create        (void);
663

    
664
static GtkWidget *prefs_colorlabel_create        (void);
665
static void prefs_common_colorlabel_set_dialog        (void);
666
static void prefs_common_colorlabel_update        (void);
667

    
668
static void prefs_junk_create                (void);
669
#if USE_GPGME
670
static void prefs_privacy_create        (void);
671
#endif
672
static void prefs_details_create        (void);
673
static GtkWidget *prefs_other_create        (void);
674
static GtkWidget *prefs_extcmd_create        (void);
675
#if USE_UPDATE_CHECK
676
static GtkWidget *prefs_update_create        (void);
677
#endif
678
static GtkWidget *prefs_advanced_create        (void);
679

    
680
static void prefs_common_set_encoding_optmenu        (GtkOptionMenu        *optmenu,
681
                                                 gboolean         outgoing);
682

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

    
703
static void prefs_quote_description_create        (void);
704
static gboolean prefs_quote_description_key_pressed
705
                                                (GtkWidget        *widget,
706
                                                 GdkEventKey        *event,
707
                                                 gpointer         data);
708
static gboolean prefs_quote_description_deleted        (GtkWidget        *widget,
709
                                                 GdkEventAny        *event,
710
                                                 gpointer         data);
711

    
712
static void prefs_quote_colors_dialog                (void);
713
static void prefs_quote_colors_dialog_create        (void);
714
static gint prefs_quote_colors_deleted                (GtkWidget        *widget,
715
                                                 GdkEventAny        *event,
716
                                                 gpointer         data);
717
static gboolean prefs_quote_colors_key_pressed        (GtkWidget        *widget,
718
                                                 GdkEventKey        *event,
719
                                                 gpointer         data);
720
static void quote_color_set_dialog                (GtkWidget        *widget,
721
                                                 gpointer         data);
722
static void quote_colors_set_dialog_ok                (GtkWidget        *widget,
723
                                                 gpointer         data);
724
static void quote_colors_set_dialog_cancel        (GtkWidget        *widget,
725
                                                 gpointer         data);
726
static gboolean quote_colors_set_dialog_key_pressed
727
                                                (GtkWidget        *widget,
728
                                                 GdkEventKey        *event,
729
                                                 gpointer         data);
730
static void set_button_bg_color                        (GtkWidget        *widget,
731
                                                 gint                 color);
732
static void prefs_enable_message_color_toggled        (void);
733
static void prefs_recycle_colors_toggled        (GtkWidget        *widget);
734

    
735
static void prefs_keybind_select                (void);
736
static gint prefs_keybind_deleted                (GtkWidget        *widget,
737
                                                 GdkEventAny        *event,
738
                                                 gpointer         data);
739
static gboolean prefs_keybind_key_pressed        (GtkWidget        *widget,
740
                                                 GdkEventKey        *event,
741
                                                 gpointer         data);
742
static void prefs_keybind_cancel                (void);
743
static void prefs_keybind_apply_clicked                (GtkWidget        *widget);
744

    
745
static void prefs_common_dispitem_clicked        (void);
746

    
747
static void prefs_common_select_folder_cb        (GtkWidget        *widget,
748
                                                 gpointer         data);
749

    
750
#ifdef G_OS_WIN32
751
static void prefs_common_file_selection_cb        (GtkButton        *button,
752
                                                 gpointer         data);
753
#endif
754

    
755
static gint prefs_common_deleted                (GtkWidget        *widget,
756
                                                 GdkEventAny        *event,
757
                                                 gpointer         data);
758
static gboolean prefs_common_key_pressed        (GtkWidget        *widget,
759
                                                 GdkEventKey        *event,
760
                                                 gpointer         data);
761
static void prefs_common_ok                        (void);
762
static void prefs_common_apply                        (void);
763
static void prefs_common_cancel                        (void);
764

    
765

    
766
void prefs_common_open(void)
767
{
768
        static gboolean ui_registered = FALSE;
769

    
770
        inc_lock();
771

    
772
        if (!ui_registered) {
773
                prefs_register_ui(prefs_common_get_params(), ui_data);
774
                ui_registered = TRUE;
775
        }
776

    
777
        if (!dialog.window) {
778
                prefs_common_create();
779
        }
780

    
781
        gtkut_box_set_reverse_order(GTK_BOX(dialog.confirm_area),
782
                                    !prefs_common.comply_gnome_hig);
783
        manage_window_set_transient(GTK_WINDOW(dialog.window));
784
        gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog.notebook), 0);
785
        gtk_widget_grab_focus(dialog.ok_btn);
786

    
787
        prefs_set_dialog(prefs_common_get_params());
788
        prefs_common_colorlabel_set_dialog();
789

    
790
        gtk_widget_show(dialog.window);
791

    
792
        syl_plugin_signal_emit("prefs-common-open", dialog.window);
793
}
794

    
795
static void prefs_common_create(void)
796
{
797
        gint page = 0;
798

    
799
        debug_print(_("Creating common preferences window...\n"));
800

    
801
        prefs_dialog_create(&dialog);
802
        gtk_window_set_title (GTK_WINDOW(dialog.window),
803
                              _("Common Preferences"));
804
        g_signal_connect (G_OBJECT(dialog.window), "delete_event",
805
                          G_CALLBACK(prefs_common_deleted), NULL);
806
        g_signal_connect (G_OBJECT(dialog.window), "key_press_event",
807
                          G_CALLBACK(prefs_common_key_pressed), NULL);
808
        MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
809

    
810
        g_signal_connect (G_OBJECT(dialog.ok_btn), "clicked",
811
                          G_CALLBACK(prefs_common_ok), NULL);
812
        g_signal_connect (G_OBJECT(dialog.apply_btn), "clicked",
813
                          G_CALLBACK(prefs_common_apply), NULL);
814
        g_signal_connect (G_OBJECT(dialog.cancel_btn), "clicked",
815
                          G_CALLBACK(prefs_common_cancel), NULL);
816

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

    
835
        gtk_widget_show_all(dialog.window);
836
}
837

    
838
static void prefs_receive_create(void)
839
{
840
        GtkWidget *vbox1;
841
        GtkWidget *vbox2;
842
        GtkWidget *vbox3;
843
        GtkWidget *vbox4;
844
        GtkWidget *hbox;
845

    
846
        GtkWidget *hbox_autochk;
847
        GtkWidget *checkbtn_autochk;
848
        GtkWidget *label_autochk1;
849
        GtkObject *spinbtn_autochk_adj;
850
        GtkWidget *spinbtn_autochk;
851
        GtkWidget *label_autochk2;
852
        GtkWidget *checkbtn_chkonstartup;
853
        GtkWidget *checkbtn_scan_after_inc;
854

    
855
        GtkWidget *frame_notify;
856
        GtkWidget *checkbtn_newmsg_notify_window;
857
        GtkWidget *checkbtn_newmsg_notify;
858
        GtkWidget *label_newmsg_notify;
859
        GtkWidget *entry_newmsg_notify;
860
        GtkWidget *label_notify_cmd_desc;
861
#ifdef G_OS_WIN32
862
        GtkWidget *checkbtn_newmsg_sound;
863
        GtkWidget *label_newmsg_sound;
864
        GtkWidget *entry_newmsg_sound;
865
        GtkWidget *btn_filesel;
866
#endif
867

    
868
#ifndef G_OS_WIN32
869
        GtkWidget *frame_spool;
870
        GtkWidget *checkbtn_local;
871
        GtkWidget *checkbtn_filter_on_inc;
872
        GtkWidget *label_spool;
873
        GtkWidget *entry_spool;
874
#endif
875

    
876
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
877
        gtk_widget_show (vbox1);
878
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
879
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
880

    
881
        vbox2 = gtk_vbox_new (FALSE, 0);
882
        gtk_widget_show (vbox2);
883
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
884

    
885
        /* Auto-checking */
886
        hbox_autochk = gtk_hbox_new (FALSE, 8);
887
        gtk_widget_show (hbox_autochk);
888
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
889

    
890
        PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
891
                           _("Auto-check new mail"));
892

    
893
        label_autochk1 = gtk_label_new (_("every"));
894
        gtk_widget_show (label_autochk1);
895
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
896

    
897
        spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 1000, 1, 10, 0);
898
        spinbtn_autochk = gtk_spin_button_new
899
                (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
900
        gtk_widget_show (spinbtn_autochk);
901
        gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
902
        gtk_widget_set_size_request (spinbtn_autochk, 64, -1);
903
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
904

    
905
        label_autochk2 = gtk_label_new (_("minute(s)"));
906
        gtk_widget_show (label_autochk2);
907
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
908

    
909
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
910
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
911
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
912

    
913
        PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
914
                           _("Check new mail on startup"));
915
        PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
916
                           _("Update all local folders after incorporation"));
917

    
918
        /* New message notify */
919
        PACK_FRAME(vbox1, frame_notify, _("New message notification"));
920

    
921
        vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
922
        gtk_widget_show (vbox3);
923
        gtk_container_add (GTK_CONTAINER (frame_notify), vbox3);
924
        gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
925

    
926
        vbox4 = gtk_vbox_new (FALSE, 0);
927
        gtk_widget_show (vbox4);
928
        gtk_box_pack_start (GTK_BOX (vbox3), vbox4, FALSE, FALSE, 0);
929

    
930
        PACK_CHECK_BUTTON
931
                (vbox4, checkbtn_newmsg_notify_window,
932
                 _("Show notification window when new messages arrive"));
933

    
934
#ifdef G_OS_WIN32
935
        PACK_CHECK_BUTTON
936
                (vbox4, checkbtn_newmsg_sound,
937
                 _("Play sound when new messages arrive"));
938

    
939
        hbox = gtk_hbox_new (FALSE, 8);
940
        gtk_widget_show (hbox);
941
        gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
942

    
943
        label_newmsg_sound = gtk_label_new (_("Sound file"));
944
        gtk_widget_show (label_newmsg_sound);
945
        gtk_box_pack_start (GTK_BOX (hbox), label_newmsg_sound,
946
                            FALSE, FALSE, 0);
947

    
948
        entry_newmsg_sound = gtk_entry_new ();
949
        gtk_widget_show (entry_newmsg_sound);
950
        gtk_box_pack_start (GTK_BOX (hbox), entry_newmsg_sound, TRUE, TRUE, 0);
951

    
952
        btn_filesel = gtk_button_new_with_label("...");
953
        gtk_box_pack_start (GTK_BOX (hbox), btn_filesel, FALSE, FALSE, 0);
954
        g_signal_connect(G_OBJECT(btn_filesel), "clicked",
955
                         G_CALLBACK(prefs_common_file_selection_cb),
956
                         entry_newmsg_sound);
957

    
958
        SET_TOGGLE_SENSITIVITY (checkbtn_newmsg_sound, hbox);
959

    
960
        PACK_CHECK_BUTTON
961
                (vbox3, checkbtn_newmsg_notify,
962
                 _("Execute command when new messages arrive"));
963
#else
964
        PACK_CHECK_BUTTON
965
                (vbox4, checkbtn_newmsg_notify,
966
                 _("Execute command when new messages arrive"));
967
#endif
968

    
969
        hbox = gtk_hbox_new (FALSE, 8);
970
        gtk_widget_show (hbox);
971
        gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
972

    
973
        label_newmsg_notify = gtk_label_new (_("Command"));
974
        gtk_widget_show (label_newmsg_notify);
975
        gtk_box_pack_start (GTK_BOX (hbox), label_newmsg_notify,
976
                            FALSE, FALSE, 0);
977

    
978
        entry_newmsg_notify = gtk_entry_new ();
979
        gtk_widget_show (entry_newmsg_notify);
980
        gtk_box_pack_start (GTK_BOX (hbox), entry_newmsg_notify, TRUE, TRUE, 0);
981

    
982
        SET_TOGGLE_SENSITIVITY (checkbtn_newmsg_notify, hbox);
983

    
984
        PACK_SMALL_LABEL
985
                (vbox3, label_notify_cmd_desc,
986
                 _("`%d' will be replaced with the number of new messages."));
987

    
988
#ifndef G_OS_WIN32
989
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_spool, checkbtn_local,
990
                                     _("Incorporate from local spool"));
991

    
992
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
993
        gtk_widget_show (vbox2);
994
        gtk_container_add (GTK_CONTAINER (frame_spool), vbox2);
995
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
996
        SET_TOGGLE_SENSITIVITY (checkbtn_local, vbox2);
997

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

    
1002
        PACK_CHECK_BUTTON (hbox, checkbtn_filter_on_inc,
1003
                           _("Filter on incorporation"));
1004

    
1005
        hbox = gtk_hbox_new (FALSE, 8);
1006
        gtk_widget_show (hbox);
1007
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1008

    
1009
        label_spool = gtk_label_new (_("Spool path"));
1010
        gtk_widget_show (label_spool);
1011
        gtk_box_pack_start (GTK_BOX (hbox), label_spool, FALSE, FALSE, 0);
1012

    
1013
        entry_spool = gtk_entry_new ();
1014
        gtk_widget_show (entry_spool);
1015
        gtk_box_pack_start (GTK_BOX (hbox), entry_spool, TRUE, TRUE, 0);
1016
#endif /* !G_OS_WIN32 */
1017

    
1018
        receive.checkbtn_autochk    = checkbtn_autochk;
1019
        receive.spinbtn_autochk     = spinbtn_autochk;
1020
        receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1021

    
1022
        receive.checkbtn_chkonstartup   = checkbtn_chkonstartup;
1023
        receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1024

    
1025
        receive.checkbtn_newmsg_notify_window = checkbtn_newmsg_notify_window;
1026
#ifdef G_OS_WIN32
1027
        receive.checkbtn_newmsg_sound   = checkbtn_newmsg_sound;
1028
        receive.entry_newmsg_sound      = entry_newmsg_sound;
1029
#endif
1030
        receive.checkbtn_newmsg_notify  = checkbtn_newmsg_notify;
1031
        receive.entry_newmsg_notify     = entry_newmsg_notify;
1032

    
1033
#ifndef G_OS_WIN32
1034
        receive.checkbtn_local         = checkbtn_local;
1035
        receive.checkbtn_filter_on_inc = checkbtn_filter_on_inc;
1036
        receive.entry_spool            = entry_spool;
1037
#endif
1038
}
1039

    
1040
static void prefs_send_create(void)
1041
{
1042
        GtkWidget *vbox1;
1043

    
1044
        GtkWidget *notebook;
1045
        GtkWidget *vbox_tab;
1046

    
1047
        GtkWidget *vbox2;
1048
        GtkWidget *hbox1;
1049
        GtkWidget *checkbtn_savemsg;
1050
        GtkWidget *checkbtn_filter_sent;
1051
        GtkWidget *checkbtn_recipients_autoreg;
1052
        GtkWidget *checkbtn_show_send_dialog;
1053
        GtkWidget *label;
1054
        GtkWidget *checkbtn_check_attach;
1055
        GtkWidget *entry_check_attach_str;
1056
        GtkWidget *checkbtn_check_recp;
1057
        GtkWidget *entry_check_recp_excl;
1058

    
1059
        GtkWidget *optmenu_trencoding;
1060
        GtkWidget *optmenu_menu;
1061
        GtkWidget *menuitem;
1062
        GtkWidget *optmenu_fencoding;
1063
        GtkWidget *label_encoding;
1064
        GtkWidget *label_encoding_desc;
1065
        GtkWidget *label_fencoding;
1066
        GtkWidget *label_fencoding_desc;
1067

    
1068
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1069
        gtk_widget_show (vbox1);
1070
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1071
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1072

    
1073
        notebook = gtk_notebook_new();
1074
        gtk_widget_show(notebook);
1075
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1076

    
1077
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1078

    
1079
        vbox2 = gtk_vbox_new (FALSE, 0);
1080
        gtk_widget_show (vbox2);
1081
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
1082

    
1083
        PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1084
                           _("Save sent messages to outbox"));
1085
        PACK_CHECK_BUTTON (vbox2, checkbtn_filter_sent,
1086
                           _("Apply filter rules to sent messages"));
1087
        SET_TOGGLE_SENSITIVITY (checkbtn_savemsg, checkbtn_filter_sent);
1088
        PACK_CHECK_BUTTON (vbox2, checkbtn_recipients_autoreg,
1089
                           _("Automatically add recipients to address book"));
1090

    
1091
        PACK_CHECK_BUTTON (vbox2, checkbtn_show_send_dialog,
1092
                           _("Display send dialog"));
1093

    
1094
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1095
        gtk_widget_show (vbox2);
1096
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
1097

    
1098
        PACK_CHECK_BUTTON (vbox2, checkbtn_check_attach,
1099
                           _("Notify for missing attachments when the following strings (comma-separated) are found in the message body"));
1100
        gtk_label_set_line_wrap(GTK_LABEL(GTK_BIN(checkbtn_check_attach)->child), TRUE);
1101

    
1102
        hbox1 = gtk_hbox_new (FALSE, 8);
1103
        gtk_widget_show (hbox1);
1104
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1105

    
1106
        entry_check_attach_str = gtk_entry_new ();
1107
        gtk_widget_show (entry_check_attach_str);
1108
        gtk_box_pack_start (GTK_BOX (hbox1), entry_check_attach_str,
1109
                            TRUE, TRUE, 0);
1110
        label = gtk_label_new (_("(Ex: attach)"));
1111
        gtk_widget_show (label);
1112
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1113

    
1114
        SET_TOGGLE_SENSITIVITY(checkbtn_check_attach, entry_check_attach_str);
1115

    
1116
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1117
        gtk_widget_show (vbox2);
1118
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
1119

    
1120
        PACK_CHECK_BUTTON (vbox2, checkbtn_check_recp,
1121
                           _("Confirm recipients before sending"));
1122

    
1123
        hbox1 = gtk_hbox_new (FALSE, 8);
1124
        gtk_widget_show (hbox1);
1125
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1126
        label = gtk_label_new
1127
                (_("Excluded addresses/domains (comma-separated):"));
1128
        gtk_widget_show (label);
1129
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1130

    
1131
        entry_check_recp_excl = gtk_entry_new ();
1132
        gtk_widget_show (entry_check_recp_excl);
1133
        gtk_box_pack_start (GTK_BOX (vbox2), entry_check_recp_excl,
1134
                            FALSE, FALSE, 0);
1135

    
1136
        SET_TOGGLE_SENSITIVITY(checkbtn_check_recp, entry_check_recp_excl);
1137

    
1138
        /* Encoding */
1139

    
1140
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Encoding"));
1141

    
1142
        hbox1 = gtk_hbox_new (FALSE, 8);
1143
        gtk_widget_show (hbox1);
1144
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1145

    
1146
        label_encoding = gtk_label_new (_("Transfer encoding"));
1147
        gtk_widget_show (label_encoding);
1148
        gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
1149

    
1150
        optmenu_trencoding = gtk_option_menu_new ();
1151
        gtk_widget_show (optmenu_trencoding);
1152
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_trencoding,
1153
                            FALSE, FALSE, 0);
1154

    
1155
        optmenu_menu = gtk_menu_new();
1156

    
1157
#define SET_MENUITEM(str, data) \
1158
        MENUITEM_ADD(optmenu_menu, menuitem, str, data)
1159

    
1160
        SET_MENUITEM(_("Automatic"),         CTE_AUTO);
1161
        SET_MENUITEM("base64",                 CTE_BASE64);
1162
        SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
1163
        SET_MENUITEM("8bit",                 CTE_8BIT);
1164

    
1165
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_trencoding),
1166
                                  optmenu_menu);
1167

    
1168
        PACK_SMALL_LABEL (vbox_tab, label_encoding_desc,
1169
                          _("Specify Content-Transfer-Encoding used when "
1170
                            "message body contains non-ASCII characters."));
1171

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

    
1176
        label_fencoding = gtk_label_new (_("MIME filename encoding"));
1177
        gtk_widget_show (label_fencoding);
1178
        gtk_box_pack_start (GTK_BOX (hbox1), label_fencoding, FALSE, FALSE, 0);
1179

    
1180
        optmenu_fencoding = gtk_option_menu_new ();
1181
        gtk_widget_show (optmenu_fencoding);
1182
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_fencoding,
1183
                            FALSE, FALSE, 0);
1184

    
1185
        optmenu_menu = gtk_menu_new();
1186

    
1187
        SET_MENUITEM(_("MIME header"), FENC_MIME);
1188
        SET_MENUITEM("RFC 2231", FENC_RFC2231);
1189

    
1190
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_fencoding),
1191
                                  optmenu_menu);
1192

    
1193
#undef SET_MENUITEM
1194

    
1195
        PACK_SMALL_LABEL
1196
                (vbox_tab, label_fencoding_desc,
1197
                 _("Specify encoding method for MIME filename with "
1198
                   "non-ASCII characters.\n"
1199
                   "MIME header: most popular, but violates RFC 2047\n"
1200
                   "RFC 2231: conforms to standard, but not popular"));
1201

    
1202

    
1203
        p_send.checkbtn_savemsg = checkbtn_savemsg;
1204
        p_send.checkbtn_filter_sent = checkbtn_filter_sent;
1205
        p_send.checkbtn_recipients_autoreg = checkbtn_recipients_autoreg;
1206
        p_send.checkbtn_show_send_dialog = checkbtn_show_send_dialog;
1207

    
1208
        p_send.optmenu_encoding_method = optmenu_trencoding;
1209
        p_send.optmenu_mime_fencoding_method = optmenu_fencoding;
1210

    
1211
        p_send.checkbtn_check_attach = checkbtn_check_attach;
1212
        p_send.entry_check_attach_str = entry_check_attach_str;
1213
        p_send.checkbtn_check_recp = checkbtn_check_recp;
1214
        p_send.entry_check_recp_excl = entry_check_recp_excl;
1215
}
1216

    
1217
static void prefs_compose_create(void)
1218
{
1219
        GtkWidget *vbox1;
1220

    
1221
        GtkWidget *notebook;
1222
        GtkWidget *vbox_tab;
1223

    
1224
        GtkWidget *hbox1;
1225
        GtkWidget *hbox2;
1226

    
1227
        GtkWidget *frame_sig;
1228
        GtkWidget *checkbtn_autosig;
1229
        GtkWidget *label_sigsep;
1230
        GtkWidget *entry_sigsep;
1231

    
1232
        GtkWidget *vbox2;
1233
        GtkWidget *checkbtn_autoextedit;
1234
        GtkWidget *vbox3;
1235
        GtkWidget *hbox3;
1236
        GtkWidget *hbox4;
1237
        GtkWidget *label_undolevel;
1238
        GtkObject *spinbtn_undolevel_adj;
1239
        GtkWidget *spinbtn_undolevel;
1240
        GtkWidget *label_linewrap;
1241
        GtkObject *spinbtn_linewrap_adj;
1242
        GtkWidget *spinbtn_linewrap;
1243
        GtkWidget *checkbtn_wrapquote;
1244
        GtkWidget *checkbtn_autowrap;
1245

    
1246
        GtkWidget *hbox_autosave;
1247
        GtkWidget *checkbtn_autosave;
1248
        GtkWidget *label_autosave1;
1249
        GtkObject *spinbtn_autosave_adj;
1250
        GtkWidget *spinbtn_autosave;
1251
        GtkWidget *label_autosave2;
1252

    
1253
        GtkWidget *frame_reply;
1254
        GtkWidget *checkbtn_reply_account_autosel;
1255
        GtkWidget *checkbtn_quote;
1256
        GtkWidget *checkbtn_default_reply_list;
1257
        GtkWidget *checkbtn_inherit_recipient_on_self_reply;
1258
        GtkWidget *checkbtn_reply_address_only;
1259

    
1260
        GtkWidget *quote_wid;
1261
#if USE_GTKSPELL
1262
        GtkWidget *spell_wid;
1263
#endif
1264

    
1265
        vbox1 = gtk_vbox_new(FALSE, VSPACING);
1266
        gtk_widget_show(vbox1);
1267
        gtk_container_add(GTK_CONTAINER(dialog.notebook), vbox1);
1268
        gtk_container_set_border_width(GTK_CONTAINER(vbox1), VBOX_BORDER);
1269

    
1270
        notebook = gtk_notebook_new();
1271
        gtk_widget_show(notebook);
1272
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1273

    
1274
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1275

    
1276
        /* signature */
1277

    
1278
        PACK_FRAME(vbox_tab, frame_sig, _("Signature"));
1279

    
1280
        hbox1 = gtk_hbox_new (FALSE, 32);
1281
        gtk_widget_show (hbox1);
1282
        gtk_container_add (GTK_CONTAINER (frame_sig), hbox1);
1283
        gtk_container_set_border_width (GTK_CONTAINER (hbox1), 8);
1284

    
1285
        hbox2 = gtk_hbox_new (FALSE, 8);
1286
        gtk_widget_show (hbox2);
1287
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1288

    
1289
        label_sigsep = gtk_label_new (_("Signature separator"));
1290
        gtk_widget_show (label_sigsep);
1291
        gtk_box_pack_start (GTK_BOX (hbox2), label_sigsep, FALSE, FALSE, 0);
1292

    
1293
        entry_sigsep = gtk_entry_new ();
1294
        gtk_widget_show (entry_sigsep);
1295
        gtk_box_pack_start (GTK_BOX (hbox2), entry_sigsep, FALSE, FALSE, 0);
1296
        gtk_widget_set_size_request (entry_sigsep, 64, -1);
1297

    
1298
        PACK_CHECK_BUTTON (hbox1, checkbtn_autosig, _("Insert automatically"));
1299

    
1300
        PACK_FRAME(vbox_tab, frame_reply, _("Reply"));
1301

    
1302
        vbox2 = gtk_vbox_new (FALSE, 0);
1303
        gtk_widget_show (vbox2);
1304
        gtk_container_add (GTK_CONTAINER (frame_reply), vbox2);
1305
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1306

    
1307
        PACK_CHECK_BUTTON (vbox2, checkbtn_reply_account_autosel,
1308
                           _("Automatically select account for replies"));
1309
        PACK_CHECK_BUTTON (vbox2, checkbtn_quote,
1310
                           _("Quote message when replying"));
1311
        PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
1312
                           _("Reply to mailing list by Reply button"));
1313
        PACK_CHECK_BUTTON (vbox2, checkbtn_inherit_recipient_on_self_reply,
1314
                           _("Inherit recipients on reply to self messages"));
1315
        PACK_CHECK_BUTTON (vbox2, checkbtn_reply_address_only,
1316
                           _("Set only mail address of recipients when replying"));
1317

    
1318
        /* editor */
1319

    
1320
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Editor"));
1321

    
1322
        vbox2 = gtk_vbox_new (FALSE, 0);
1323
        gtk_widget_show (vbox2);
1324
        gtk_container_add (GTK_CONTAINER (vbox_tab), vbox2);
1325

    
1326
        PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1327
                           _("Automatically launch the external editor"));
1328

    
1329
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1330

    
1331
        /* undo */
1332

    
1333
        hbox3 = gtk_hbox_new (FALSE, 8);
1334
        gtk_widget_show (hbox3);
1335
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1336

    
1337
        label_undolevel = gtk_label_new (_("Undo level"));
1338
        gtk_widget_show (label_undolevel);
1339
        gtk_box_pack_start (GTK_BOX (hbox3), label_undolevel, FALSE, FALSE, 0);
1340

    
1341
        spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 0);
1342
        spinbtn_undolevel = gtk_spin_button_new
1343
                (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1344
        gtk_widget_show (spinbtn_undolevel);
1345
        gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_undolevel, FALSE, FALSE, 0);
1346
        gtk_widget_set_size_request (spinbtn_undolevel, 64, -1);
1347
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1348

    
1349
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1350

    
1351
        /* line-wrapping */
1352

    
1353
        hbox3 = gtk_hbox_new (FALSE, 8);
1354
        gtk_widget_show (hbox3);
1355
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1356

    
1357
        label_linewrap = gtk_label_new (_("Wrap messages at"));
1358
        gtk_widget_show (label_linewrap);
1359
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1360

    
1361
        spinbtn_linewrap_adj = gtk_adjustment_new (72, 20, 1024, 1, 10, 0);
1362
        spinbtn_linewrap = gtk_spin_button_new
1363
                (GTK_ADJUSTMENT (spinbtn_linewrap_adj), 1, 0);
1364
        gtk_widget_show (spinbtn_linewrap);
1365
        gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_linewrap, FALSE, FALSE, 0);
1366
        gtk_widget_set_size_request (spinbtn_linewrap, 64, -1);
1367
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
1368

    
1369
        label_linewrap = gtk_label_new (_("characters"));
1370
        gtk_widget_show (label_linewrap);
1371
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1372

    
1373
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
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_wrapquote, _("Wrap quotation"));
1380

    
1381
        hbox4 = gtk_hbox_new (FALSE, 32);
1382
        gtk_widget_show (hbox4);
1383
        gtk_box_pack_start (GTK_BOX (vbox2), hbox4, FALSE, FALSE, 0);
1384

    
1385
        PACK_CHECK_BUTTON (hbox4, checkbtn_autowrap, _("Wrap on input"));
1386

    
1387
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1388

    
1389
        hbox_autosave = gtk_hbox_new (FALSE, 8);
1390
        gtk_widget_show (hbox_autosave);
1391
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_autosave, FALSE, FALSE, 0);
1392

    
1393
        PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
1394
                           _("Auto-save to draft"));
1395

    
1396
        label_autosave1 = gtk_label_new (_("every"));
1397
        gtk_widget_show (label_autosave1);
1398
        gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave1,
1399
                            FALSE, FALSE, 0);
1400

    
1401
        spinbtn_autosave_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 0);
1402
        spinbtn_autosave = gtk_spin_button_new
1403
                (GTK_ADJUSTMENT (spinbtn_autosave_adj), 1, 0);
1404
        gtk_widget_show (spinbtn_autosave);
1405
        gtk_box_pack_start (GTK_BOX (hbox_autosave), spinbtn_autosave,
1406
                            FALSE, FALSE, 0);
1407
        gtk_widget_set_size_request (spinbtn_autosave, 64, -1);
1408
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autosave), TRUE);
1409

    
1410
        label_autosave2 = gtk_label_new (_("minute(s)"));
1411
        gtk_widget_show (label_autosave2);
1412
        gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave2,
1413
                            FALSE, FALSE, 0);
1414

    
1415
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, label_autosave1);
1416
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, spinbtn_autosave);
1417
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, label_autosave2);
1418

    
1419
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Format"));
1420
        quote_wid = prefs_quote_create();
1421
        gtk_box_pack_start(GTK_BOX(vbox_tab), quote_wid, FALSE, FALSE, 0);
1422

    
1423
#if USE_GTKSPELL
1424
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Spell checking"));
1425
        spell_wid = prefs_spell_create();
1426
        gtk_box_pack_start(GTK_BOX(vbox_tab), spell_wid, FALSE, FALSE, 0);
1427
#endif
1428

    
1429
        compose.checkbtn_autosig = checkbtn_autosig;
1430
        compose.entry_sigsep     = entry_sigsep;
1431

    
1432
        compose.checkbtn_autoextedit = checkbtn_autoextedit;
1433

    
1434
        compose.spinbtn_undolevel     = spinbtn_undolevel;
1435
        compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1436

    
1437
        compose.spinbtn_linewrap     = spinbtn_linewrap;
1438
        compose.spinbtn_linewrap_adj = spinbtn_linewrap_adj;
1439
        compose.checkbtn_wrapquote   = checkbtn_wrapquote;
1440
        compose.checkbtn_autowrap    = checkbtn_autowrap;
1441

    
1442
        compose.checkbtn_autosave    = checkbtn_autosave;
1443
        compose.spinbtn_autosave     = spinbtn_autosave;
1444
        compose.spinbtn_autosave_adj = spinbtn_autosave_adj;
1445

    
1446
        compose.checkbtn_quote = checkbtn_quote;
1447
        compose.checkbtn_reply_account_autosel =
1448
                checkbtn_reply_account_autosel;
1449
        compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
1450
        compose.checkbtn_inherit_recipient_on_self_reply =
1451
                checkbtn_inherit_recipient_on_self_reply;
1452
        compose.checkbtn_reply_address_only = checkbtn_reply_address_only;
1453
}
1454

    
1455
static GtkWidget *prefs_quote_create(void)
1456
{
1457
        GtkWidget *vbox1;
1458
        GtkWidget *frame_quote;
1459
        GtkWidget *vbox_quote;
1460
        GtkWidget *hbox1;
1461
        GtkWidget *hbox2;
1462
        GtkWidget *label_quotemark;
1463
        GtkWidget *entry_quotemark;
1464
        GtkWidget *scrolledwin_quotefmt;
1465
        GtkWidget *text_quotefmt;
1466

    
1467
        GtkWidget *entry_fw_quotemark;
1468
        GtkWidget *text_fw_quotefmt;
1469

    
1470
        GtkWidget *btn_quotedesc;
1471

    
1472
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1473
        gtk_widget_show (vbox1);
1474

    
1475
        /* reply */
1476

    
1477
        PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1478

    
1479
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1480
        gtk_widget_show (vbox_quote);
1481
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1482
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1483

    
1484
        hbox1 = gtk_hbox_new (FALSE, 32);
1485
        gtk_widget_show (hbox1);
1486
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1487

    
1488
        hbox2 = gtk_hbox_new (FALSE, 8);
1489
        gtk_widget_show (hbox2);
1490
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1491

    
1492
        label_quotemark = gtk_label_new (_("Quotation mark"));
1493
        gtk_widget_show (label_quotemark);
1494
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1495

    
1496
        entry_quotemark = gtk_entry_new ();
1497
        gtk_widget_show (entry_quotemark);
1498
        gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1499
        gtk_widget_set_size_request (entry_quotemark, 64, -1);
1500

    
1501
        scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1502
        gtk_widget_show (scrolledwin_quotefmt);
1503
        gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
1504
                            TRUE, TRUE, 0);
1505
        gtk_scrolled_window_set_policy
1506
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1507
                 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1508
        gtk_scrolled_window_set_shadow_type
1509
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
1510

    
1511
        text_quotefmt = gtk_text_view_new ();
1512
        gtk_widget_show (text_quotefmt);
1513
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1514
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_quotefmt), TRUE);
1515
        gtk_widget_set_size_request(text_quotefmt, DEFAULT_ENTRY_WIDTH, 60);
1516

    
1517
        /* forward */
1518

    
1519
        PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1520

    
1521
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1522
        gtk_widget_show (vbox_quote);
1523
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1524
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1525

    
1526
        hbox1 = gtk_hbox_new (FALSE, 32);
1527
        gtk_widget_show (hbox1);
1528
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1529

    
1530
        hbox2 = gtk_hbox_new (FALSE, 8);
1531
        gtk_widget_show (hbox2);
1532
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1533

    
1534
        label_quotemark = gtk_label_new (_("Quotation mark"));
1535
        gtk_widget_show (label_quotemark);
1536
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1537

    
1538
        entry_fw_quotemark = gtk_entry_new ();
1539
        gtk_widget_show (entry_fw_quotemark);
1540
        gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1541
                            FALSE, FALSE, 0);
1542
        gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
1543

    
1544
        scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1545
        gtk_widget_show (scrolledwin_quotefmt);
1546
        gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
1547
                            TRUE, TRUE, 0);
1548
        gtk_scrolled_window_set_policy
1549
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1550
                 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1551
        gtk_scrolled_window_set_shadow_type
1552
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
1553

    
1554
        text_fw_quotefmt = gtk_text_view_new ();
1555
        gtk_widget_show (text_fw_quotefmt);
1556
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1557
                          text_fw_quotefmt);
1558
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
1559
        gtk_widget_set_size_request (text_fw_quotefmt, DEFAULT_ENTRY_WIDTH, 60);
1560

    
1561
        hbox1 = gtk_hbox_new (FALSE, 32);
1562
        gtk_widget_show (hbox1);
1563
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1564

    
1565
        btn_quotedesc =
1566
                gtk_button_new_with_label (_(" Description of symbols "));
1567
        gtk_widget_show (btn_quotedesc);
1568
        gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
1569
        g_signal_connect(G_OBJECT(btn_quotedesc), "clicked",
1570
                         G_CALLBACK(prefs_quote_description), NULL);
1571

    
1572
        quote.entry_quotemark    = entry_quotemark;
1573
        quote.text_quotefmt      = text_quotefmt;
1574
        quote.entry_fw_quotemark = entry_fw_quotemark;
1575
        quote.text_fw_quotefmt   = text_fw_quotefmt;
1576

    
1577
        return vbox1;
1578
}
1579

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

    
1618
        return vbox1;
1619
}
1620
#endif /* USE_GTKSPELL */
1621

    
1622
static void prefs_display_create(void)
1623
{
1624
        GtkWidget *vbox1;
1625

    
1626
        GtkWidget *notebook;
1627
        GtkWidget *vbox_tab;
1628

    
1629
        GtkWidget *table1;
1630
        GtkWidget *label_textfont;
1631
        GtkWidget *fontbtn_textfont;
1632
        GtkWidget *frame_folder;
1633
        GtkWidget *chkbtn_folder_unread;
1634
        GtkWidget *label_folder_cols;
1635
        GtkWidget *hbox1;
1636
        GtkWidget *hbox_spc;
1637
        GtkWidget *chkbtn_folder_col_new;
1638
        GtkWidget *chkbtn_folder_col_unread;
1639
        GtkWidget *chkbtn_folder_col_total;
1640
        GtkWidget *label_ng_abbrev;
1641
        GtkWidget *spinbtn_ng_abbrev_len;
1642
        GtkObject *spinbtn_ng_abbrev_len_adj;
1643
        GtkWidget *frame_summary;
1644
        GtkWidget *vbox2;
1645
        GtkWidget *chkbtn_swapfrom;
1646
        GtkWidget *chkbtn_expand_thread;
1647
        GtkWidget *vbox3;
1648
        GtkWidget *label_datefmt;
1649
        GtkWidget *button_datefmt;
1650
        GtkWidget *entry_datefmt;
1651
        GtkWidget *button_dispitem;
1652

    
1653
        GtkWidget *msg_wid;
1654
        GtkWidget *att_wid;
1655
        GtkWidget *clabel_wid;
1656

    
1657
        GtkWidget *label_dispencoding;
1658
        GtkWidget *optmenu_dispencoding;
1659
        GtkWidget *label_outencoding;
1660
        GtkWidget *optmenu_outencoding;
1661
        GtkWidget *label_encoding_desc;
1662

    
1663
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1664
        gtk_widget_show (vbox1);
1665
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1666
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1667

    
1668
        notebook = gtk_notebook_new();
1669
        gtk_widget_show(notebook);
1670
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1671

    
1672
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1673

    
1674
        table1 = gtk_table_new (1, 2, FALSE);
1675
        gtk_widget_show (table1);
1676
        gtk_box_pack_start(GTK_BOX(vbox_tab), table1, FALSE, FALSE, 0);
1677
        gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
1678
        gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
1679

    
1680
        label_textfont = gtk_label_new (_("Text font"));
1681
        gtk_widget_show (label_textfont);
1682
        gtk_table_attach (GTK_TABLE (table1), label_textfont, 0, 1, 0, 1,
1683
                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1684

    
1685
        fontbtn_textfont = gtk_font_button_new ();
1686
        gtk_widget_show (fontbtn_textfont);
1687
        gtk_table_attach (GTK_TABLE (table1), fontbtn_textfont, 1, 2, 0, 1,
1688
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
1689

    
1690
        /* ---- Folder View ---- */
1691

    
1692
        PACK_FRAME(vbox_tab, frame_folder, _("Folder View"));
1693

    
1694
        vbox2 = gtk_vbox_new (FALSE, 0);
1695
        gtk_widget_show (vbox2);
1696
        gtk_container_add (GTK_CONTAINER (frame_folder), vbox2);
1697
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1698

    
1699
        PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1700
                           _("Display unread number next to folder name"));
1701

    
1702
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1703
        label_folder_cols = gtk_label_new
1704
                (_("Displaying message number columns in the folder view:"));
1705
        gtk_widget_show(label_folder_cols);
1706
        gtk_box_pack_start(GTK_BOX(vbox2), label_folder_cols, FALSE, TRUE, 0);
1707
        gtk_misc_set_alignment(GTK_MISC(label_folder_cols), 0, 0.5);
1708

    
1709
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1710
        hbox1 = gtk_hbox_new(FALSE, 8);
1711
        gtk_widget_show(hbox1);
1712
        gtk_box_pack_start(GTK_BOX(vbox2), hbox1, FALSE, TRUE, 0);
1713
        hbox_spc = gtk_hbox_new(FALSE, 0);
1714
        gtk_widget_show(hbox_spc);
1715
        gtk_box_pack_start(GTK_BOX(hbox1), hbox_spc, FALSE, FALSE, 0);
1716
        gtk_widget_set_size_request(hbox_spc, 8, -1);
1717
        PACK_CHECK_BUTTON(hbox1, chkbtn_folder_col_new, _("New"));
1718
        PACK_CHECK_BUTTON(hbox1, chkbtn_folder_col_unread, _("Unread"));
1719
        PACK_CHECK_BUTTON(hbox1, chkbtn_folder_col_total, _("Total"));
1720

    
1721
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1722

    
1723
        hbox1 = gtk_hbox_new (FALSE, 8);
1724
        gtk_widget_show (hbox1);
1725
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1726

    
1727
        label_ng_abbrev = gtk_label_new
1728
                (_("Abbreviate newsgroups longer than"));
1729
        gtk_widget_show (label_ng_abbrev);
1730
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1731

    
1732
        spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 0);
1733
        spinbtn_ng_abbrev_len = gtk_spin_button_new
1734
                (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
1735
        gtk_widget_show (spinbtn_ng_abbrev_len);
1736
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
1737
                            FALSE, FALSE, 0);
1738
        gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
1739
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
1740
                                     TRUE);
1741

    
1742
        label_ng_abbrev = gtk_label_new
1743
                (_("letters"));
1744
        gtk_widget_show (label_ng_abbrev);
1745
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1746

    
1747
        /* ---- Summary ---- */
1748

    
1749
        PACK_FRAME(vbox_tab, frame_summary, _("Summary View"));
1750

    
1751
        vbox2 = gtk_vbox_new (FALSE, 0);
1752
        gtk_widget_show (vbox2);
1753
        gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1754
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1755

    
1756
        PACK_CHECK_BUTTON
1757
                (vbox2, chkbtn_swapfrom,
1758
                 _("Display recipient on `From' column if sender is yourself"));
1759
        PACK_CHECK_BUTTON
1760
                (vbox2, chkbtn_expand_thread, _("Expand threads"));
1761

    
1762
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1763

    
1764
        hbox1 = gtk_hbox_new (FALSE, 8);
1765
        gtk_widget_show (hbox1);
1766
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1767

    
1768
        label_datefmt = gtk_label_new (_("Date format"));
1769
        gtk_widget_show (label_datefmt);
1770
        gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1771

    
1772
        entry_datefmt = gtk_entry_new ();
1773
        gtk_widget_show (entry_datefmt);
1774
        gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1775

    
1776
        button_datefmt = gtk_button_new_with_label ("... ");
1777
        gtk_widget_show (button_datefmt);
1778
        gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
1779
        g_signal_connect (G_OBJECT (button_datefmt), "clicked",
1780
                          G_CALLBACK (date_format_create), NULL);
1781

    
1782
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1783

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

    
1788
        button_dispitem = gtk_button_new_with_label
1789
                (_(" Set display item of summary... "));
1790
        gtk_widget_show (button_dispitem);
1791
        gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
1792
        g_signal_connect (G_OBJECT (button_dispitem), "clicked",
1793
                          G_CALLBACK (prefs_common_dispitem_clicked), NULL);
1794

    
1795
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Message"));
1796
        msg_wid = prefs_message_create();
1797
        gtk_box_pack_start(GTK_BOX(vbox_tab), msg_wid, FALSE, FALSE, 0);
1798

    
1799
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Attachment"));
1800
        att_wid = prefs_attach_create();
1801
        gtk_box_pack_start(GTK_BOX(vbox_tab), att_wid, FALSE, FALSE, 0);
1802

    
1803
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Color label"));
1804
        clabel_wid = prefs_colorlabel_create();
1805
        gtk_box_pack_start(GTK_BOX(vbox_tab), clabel_wid, FALSE, FALSE, 0);
1806

    
1807
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Encoding"));
1808

    
1809
        hbox1 = gtk_hbox_new (FALSE, 8);
1810
        gtk_widget_show (hbox1);
1811
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1812

    
1813
        label_dispencoding = gtk_label_new (_("Default character encoding"));
1814
        gtk_widget_show (label_dispencoding);
1815
        gtk_box_pack_start (GTK_BOX (hbox1), label_dispencoding,
1816
                            FALSE, FALSE, 0);
1817

    
1818
        optmenu_dispencoding = gtk_option_menu_new ();
1819
        gtk_widget_show (optmenu_dispencoding);
1820
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_dispencoding,
1821
                            FALSE, FALSE, 0);
1822

    
1823
        prefs_common_set_encoding_optmenu
1824
                (GTK_OPTION_MENU (optmenu_dispencoding), FALSE);
1825

    
1826
        PACK_SMALL_LABEL (vbox_tab, label_encoding_desc,
1827
                          _("This is used when displaying messages with missing character encoding."));
1828

    
1829
        hbox1 = gtk_hbox_new (FALSE, 8);
1830
        gtk_widget_show (hbox1);
1831
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1832

    
1833
        label_outencoding = gtk_label_new (_("Outgoing character encoding"));
1834
        gtk_widget_show (label_outencoding);
1835
        gtk_box_pack_start (GTK_BOX (hbox1), label_outencoding,
1836
                            FALSE, FALSE, 0);
1837

    
1838
        optmenu_outencoding = gtk_option_menu_new ();
1839
        gtk_widget_show (optmenu_outencoding);
1840
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_outencoding,
1841
                            FALSE, FALSE, 0);
1842

    
1843
        prefs_common_set_encoding_optmenu
1844
                (GTK_OPTION_MENU (optmenu_outencoding), TRUE);
1845

    
1846
        PACK_SMALL_LABEL (vbox_tab, label_encoding_desc,
1847
                          _("If `Automatic' is selected, the optimal encoding "
1848
                            "for the current locale will be used."));
1849

    
1850
        display.fontbtn_textfont = fontbtn_textfont;
1851

    
1852
        display.chkbtn_folder_unread      = chkbtn_folder_unread;
1853
        display.chkbtn_folder_col_new     = chkbtn_folder_col_new;
1854
        display.chkbtn_folder_col_unread  = chkbtn_folder_col_unread;
1855
        display.chkbtn_folder_col_total   = chkbtn_folder_col_total;
1856
        display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
1857
        display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
1858

    
1859
        display.chkbtn_swapfrom      = chkbtn_swapfrom;
1860
        display.chkbtn_expand_thread = chkbtn_expand_thread;
1861
        display.entry_datefmt        = entry_datefmt;
1862

    
1863
        display.optmenu_dispencoding = optmenu_dispencoding;
1864
        display.optmenu_outencoding  = optmenu_outencoding;
1865
}
1866

    
1867
static GtkWidget *prefs_message_create(void)
1868
{
1869
        GtkWidget *vbox1;
1870
        GtkWidget *vbox2;
1871
        GtkWidget *vbox3;
1872
        GtkWidget *hbox1;
1873
        GtkWidget *chkbtn_enablecol;
1874
        GtkWidget *button_edit_col;
1875
        GtkWidget *chkbtn_disphdrpane;
1876
        GtkWidget *chkbtn_disphdr;
1877
        GtkWidget *button_edit_disphdr;
1878
        GtkWidget *chkbtn_html;
1879
        GtkWidget *chkbtn_prefer_html;
1880
        GtkWidget *chkbtn_htmlonly;
1881
        GtkWidget *hbox_linespc;
1882
        GtkWidget *label_linespc;
1883
        GtkObject *spinbtn_linespc_adj;
1884
        GtkWidget *spinbtn_linespc;
1885

    
1886
        GtkWidget *frame_scr;
1887
        GtkWidget *vbox_scr;
1888
        GtkWidget *chkbtn_smoothscroll;
1889
        GtkWidget *hbox_scr;
1890
        GtkWidget *label_scr;
1891
        GtkObject *spinbtn_scrollstep_adj;
1892
        GtkWidget *spinbtn_scrollstep;
1893
        GtkWidget *chkbtn_halfpage;
1894

    
1895
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1896
        gtk_widget_show (vbox1);
1897

    
1898
        vbox2 = gtk_vbox_new (FALSE, 0);
1899
        gtk_widget_show (vbox2);
1900
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1901

    
1902
        hbox1 = gtk_hbox_new (FALSE, 8);
1903
        gtk_widget_show (hbox1);
1904
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1905

    
1906
        PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
1907
                           _("Enable coloration of message"));
1908
        g_signal_connect(G_OBJECT(chkbtn_enablecol), "toggled",
1909
                         G_CALLBACK(prefs_enable_message_color_toggled), NULL);
1910

    
1911
        button_edit_col = gtk_button_new_with_label (_(" Edit... "));
1912
        gtk_widget_show (button_edit_col);
1913
        gtk_box_pack_end (GTK_BOX (hbox1), button_edit_col, FALSE, TRUE, 0);
1914
        g_signal_connect (G_OBJECT (button_edit_col), "clicked",
1915
                          G_CALLBACK (prefs_quote_colors_dialog), NULL);
1916

    
1917
        SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
1918

    
1919
#if 0
1920
        PACK_CHECK_BUTTON
1921
                (vbox2, chkbtn_mbalnum,
1922
                 _("Display multi-byte alphabet and numeric as\n"
1923
                   "ASCII character (Japanese only)"));
1924
        gtk_label_set_justify (GTK_LABEL (GTK_BIN(chkbtn_mbalnum)->child),
1925
                               GTK_JUSTIFY_LEFT);
1926
#endif
1927

    
1928
        PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1929
                          _("Display header pane above message view"));
1930

    
1931
        hbox1 = gtk_hbox_new (FALSE, 8);
1932
        gtk_widget_show (hbox1);
1933
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1934

    
1935
        PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1936
                          _("Display short headers on message view"));
1937

    
1938
        button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
1939
        gtk_widget_show (button_edit_disphdr);
1940
        gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
1941
                          FALSE, TRUE, 0);
1942
        g_signal_connect (G_OBJECT (button_edit_disphdr), "clicked",
1943
                          G_CALLBACK (prefs_display_header_open), NULL);
1944

    
1945
        SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1946

    
1947
        PACK_CHECK_BUTTON(vbox2, chkbtn_html,
1948
                          _("Render HTML messages as text"));
1949
        PACK_CHECK_BUTTON(vbox2, chkbtn_prefer_html,
1950
                          _("Prefer HTML in multipart/alternative for display"));
1951
        PACK_CHECK_BUTTON(vbox2, chkbtn_htmlonly,
1952
                          _("Treat HTML only messages as attachment"));
1953

    
1954
#if 0
1955
        PACK_CHECK_BUTTON(vbox2, chkbtn_cursor,
1956
                          _("Display cursor in message view"));
1957
#endif
1958

    
1959
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1960

    
1961
        hbox1 = gtk_hbox_new (FALSE, 32);
1962
        gtk_widget_show (hbox1);
1963
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1964

    
1965
        hbox_linespc = gtk_hbox_new (FALSE, 8);
1966
        gtk_widget_show (hbox1);
1967
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
1968

    
1969
        label_linespc = gtk_label_new (_("Line space"));
1970
        gtk_widget_show (label_linespc);
1971
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1972
                            FALSE, FALSE, 0);
1973

    
1974
        spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 0);
1975
        spinbtn_linespc = gtk_spin_button_new
1976
                (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
1977
        gtk_widget_show (spinbtn_linespc);
1978
        gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
1979
                            FALSE, FALSE, 0);
1980
        gtk_widget_set_size_request (spinbtn_linespc, 64, -1);
1981
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
1982

    
1983
        label_linespc = gtk_label_new (_("pixel(s)"));
1984
        gtk_widget_show (label_linespc);
1985
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1986
                            FALSE, FALSE, 0);
1987

    
1988
        PACK_FRAME(vbox1, frame_scr, _("Scroll"));
1989

    
1990
        vbox_scr = gtk_vbox_new (FALSE, 0);
1991
        gtk_widget_show (vbox_scr);
1992
        gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
1993
        gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
1994

    
1995
        PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
1996

    
1997
        hbox1 = gtk_hbox_new (FALSE, 32);
1998
        gtk_widget_show (hbox1);
1999
        gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
2000

    
2001
        PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
2002

    
2003
        hbox_scr = gtk_hbox_new (FALSE, 8);
2004
        gtk_widget_show (hbox_scr);
2005
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
2006

    
2007
        label_scr = gtk_label_new (_("Step"));
2008
        gtk_widget_show (label_scr);
2009
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2010

    
2011
        spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 0);
2012
        spinbtn_scrollstep = gtk_spin_button_new
2013
                (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
2014
        gtk_widget_show (spinbtn_scrollstep);
2015
        gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
2016
                            FALSE, FALSE, 0);
2017
        gtk_widget_set_size_request (spinbtn_scrollstep, 64, -1);
2018
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
2019
                                     TRUE);
2020

    
2021
        label_scr = gtk_label_new (_("pixel(s)"));
2022
        gtk_widget_show (label_scr);
2023
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2024

    
2025
        SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
2026

    
2027
        message.chkbtn_enablecol   = chkbtn_enablecol;
2028
        message.button_edit_col    = button_edit_col;
2029
        message.chkbtn_disphdrpane = chkbtn_disphdrpane;
2030
        message.chkbtn_disphdr     = chkbtn_disphdr;
2031
        message.chkbtn_html        = chkbtn_html;
2032
        message.chkbtn_prefer_html = chkbtn_prefer_html;
2033
        message.chkbtn_htmlonly    = chkbtn_htmlonly;
2034
        message.spinbtn_linespc    = spinbtn_linespc;
2035

    
2036
        message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
2037
        message.spinbtn_scrollstep     = spinbtn_scrollstep;
2038
        message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
2039
        message.chkbtn_halfpage        = chkbtn_halfpage;
2040

    
2041
        return vbox1;
2042
}
2043

    
2044
static GtkWidget *prefs_attach_create(void)
2045
{
2046
        GtkWidget *vbox1;
2047
        GtkWidget *vbox2;
2048
        GtkWidget *hbox1;
2049
        GtkWidget *label;
2050
        GtkWidget *radiobtn_attach_toolbtn_pos;
2051
        GtkWidget *radiobtn_attach_toolbtn_pos2;
2052
        GtkWidget *chkbtn_show_attach_tab;
2053
        GtkWidget *chkbtn_show_files_first;
2054
        GtkWidget *frame_image;
2055
        GtkWidget *vbox_image;
2056
        GtkWidget *chkbtn_resize_image;
2057
        GtkWidget *chkbtn_inline_image;
2058

    
2059
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2060
        gtk_widget_show (vbox1);
2061

    
2062
        vbox2 = gtk_vbox_new (FALSE, 0);
2063
        gtk_widget_show (vbox2);
2064
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2065

    
2066
        hbox1 = gtk_hbox_new (FALSE, 8);
2067
        gtk_widget_show (hbox1);
2068
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2069

    
2070
        label = gtk_label_new (_("Position of attachment tool button:"));
2071
        gtk_widget_show (label);
2072
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2073

    
2074
        radiobtn_attach_toolbtn_pos = gtk_radio_button_new_with_label
2075
                (NULL, _("Left"));
2076
        gtk_widget_show (radiobtn_attach_toolbtn_pos);
2077
        gtk_box_pack_start (GTK_BOX(hbox1), radiobtn_attach_toolbtn_pos,
2078
                            FALSE, FALSE, 0);
2079
        g_object_set_data (G_OBJECT (radiobtn_attach_toolbtn_pos), MENU_VAL_ID,
2080
                           GINT_TO_POINTER (0));
2081

    
2082
        radiobtn_attach_toolbtn_pos2 = gtk_radio_button_new_with_label_from_widget
2083
                (GTK_RADIO_BUTTON (radiobtn_attach_toolbtn_pos), _("Right"));
2084
        gtk_widget_show (radiobtn_attach_toolbtn_pos2);
2085
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_attach_toolbtn_pos2,
2086
                            FALSE, FALSE, 0);
2087
        g_object_set_data (G_OBJECT (radiobtn_attach_toolbtn_pos2), MENU_VAL_ID,
2088
                           GINT_TO_POINTER (1));
2089

    
2090
        PACK_CHECK_BUTTON (vbox2, chkbtn_show_attach_tab,
2091
                           _("Toggle attachment list view with tab"));
2092
        SET_TOGGLE_SENSITIVITY_REV (chkbtn_show_attach_tab, hbox1);
2093

    
2094
        PACK_CHECK_BUTTON (vbox2, chkbtn_show_files_first,
2095
                           _("Show attached files first on message view"));
2096

    
2097
        PACK_FRAME(vbox1, frame_image, _("Images"));
2098

    
2099
        vbox_image = gtk_vbox_new (FALSE, 0);
2100
        gtk_widget_show (vbox_image);
2101
        gtk_container_add (GTK_CONTAINER (frame_image), vbox_image);
2102
        gtk_container_set_border_width (GTK_CONTAINER (vbox_image), 8);
2103

    
2104
        PACK_CHECK_BUTTON(vbox_image, chkbtn_resize_image,
2105
                          _("Resize attached large images to fit in the window"));
2106
        PACK_CHECK_BUTTON(vbox_image, chkbtn_inline_image,
2107
                          _("Display images as inline"));
2108

    
2109
        attach.chkbtn_show_attach_tab  = chkbtn_show_attach_tab;
2110
        attach.radiobtn_attach_toolbtn_pos = radiobtn_attach_toolbtn_pos;
2111
        attach.chkbtn_show_files_first = chkbtn_show_files_first;
2112

    
2113
        attach.chkbtn_resize_image = chkbtn_resize_image;
2114
        attach.chkbtn_inline_image = chkbtn_inline_image;
2115

    
2116
        return vbox1;
2117
}
2118

    
2119
static GtkWidget *prefs_colorlabel_create(void)
2120
{
2121
        GtkWidget *vbox;
2122
        GtkWidget *hbox;
2123
        GtkWidget *label;
2124
        GtkWidget *table;
2125
        GtkWidget *clabel;
2126
        GtkWidget *entry;
2127
        gint i;
2128

    
2129
        vbox = gtk_vbox_new(FALSE, VSPACING);
2130
        gtk_widget_show(vbox);
2131
        gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
2132

    
2133
        hbox = gtk_hbox_new(FALSE, 8);
2134
        gtk_widget_show(hbox);
2135
        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
2136

    
2137
        label = gtk_label_new(_("You can specify label names for each color (Work, TODO etc.)."));
2138
        gtk_widget_show(label);
2139
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
2140
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
2141
        gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
2142
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2143

    
2144
        table = gtk_table_new(7, 2, FALSE);
2145
        gtk_widget_show(table);
2146
        gtk_container_add(GTK_CONTAINER(vbox), table);
2147
        gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
2148
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
2149

    
2150
        for (i = 0; i < 7; i++) {
2151
                clabel = colorlabel_create_color_widget
2152
                        (colorlabel_get_color(i));
2153
                gtk_widget_show(clabel);
2154
                gtk_table_attach(GTK_TABLE(table), clabel, 0, 1, i, i + 1,
2155
                                 GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 6);
2156
                entry  = gtk_entry_new();
2157
                gtk_widget_show(entry);
2158
                gtk_table_attach(GTK_TABLE(table), entry, 1, 2, i, i + 1,
2159
                                 GTK_EXPAND | GTK_FILL, 0, 0, 0);
2160
                colorlabel.entry_color[i] = entry;
2161
        }
2162

    
2163
        return vbox;
2164
}
2165

    
2166
static void prefs_common_colorlabel_set_dialog(void)
2167
{
2168
        gint i;
2169
        const gchar *text;
2170

    
2171
        for (i = 0; i < 7; i++) {
2172
                if ((text = colorlabel_get_custom_color_text(i))) {
2173
                        gtk_entry_set_text(GTK_ENTRY(colorlabel.entry_color[i]),
2174
                                           text);
2175
                } else {
2176
                        gtk_entry_set_text(GTK_ENTRY(colorlabel.entry_color[i]),
2177
                                           "");
2178
                }
2179
        }
2180
}
2181

    
2182
static void prefs_common_colorlabel_update(void)
2183
{
2184
        gint i;
2185
        const gchar *text;
2186

    
2187
        for (i = 0; i < 7; i++) {
2188
                text = gtk_entry_get_text(GTK_ENTRY(colorlabel.entry_color[i]));
2189
                if (text && text[0] != '\0')
2190
                        colorlabel_set_color_text(i, text);
2191
                else
2192
                        colorlabel_set_color_text(i, NULL);
2193
        }
2194
        colorlabel_update_menu();
2195
}
2196

    
2197
static const struct {
2198
        gchar *junk_cmd;
2199
        gchar *nojunk_cmd;
2200
        gchar *classify_cmd;
2201
} junk_presets[] = {
2202
#ifdef G_OS_WIN32
2203
        {"bogofilter -N -s -I", "bogofilter -n -S -I", "bogofilter -I"},
2204
        {"bsfilterw -C -s -u", "bsfilterw -c -S -u", "bsfilterw"},
2205
        {"sylfilter -j", "sylfilter -c", "sylfilter"}
2206
#else
2207
        {"bogofilter -N -s -I", "bogofilter -n -S -I", "bogofilter -I"},
2208
        {"bsfilter -C -s -u", "bsfilter -c -S -u", "bsfilter"},
2209
        {"sylfilter -j", "sylfilter -c", "sylfilter"}
2210
#endif
2211
};
2212

    
2213
enum
2214
{
2215
        JUNK_NONE,
2216
        JUNK_BOGOFILTER,
2217
        JUNK_BSFILTER,
2218
        JUNK_SYLFILTER,
2219

    
2220
        N_JUNK_ITEMS
2221
};
2222

    
2223
static void prefs_junk_preset_activated(GtkMenuItem *menuitem, gpointer data)
2224
{
2225
        gint i;
2226

    
2227
        i = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2228
        if (i > JUNK_NONE && i < N_JUNK_ITEMS) {
2229
                i--;
2230
                gtk_entry_set_text(GTK_ENTRY(junk.entry_junk_learncmd),
2231
                                   junk_presets[i].junk_cmd); 
2232
                gtk_entry_set_text(GTK_ENTRY(junk.entry_nojunk_learncmd),
2233
                                   junk_presets[i].nojunk_cmd); 
2234
                gtk_entry_set_text(GTK_ENTRY(junk.entry_classify_cmd),
2235
                                   junk_presets[i].classify_cmd); 
2236
        }
2237
}
2238

    
2239
static void prefs_junk_create(void)
2240
{
2241
        GtkWidget *vbox1;
2242
        GtkWidget *vbox2;
2243
        GtkWidget *frame;
2244
        GtkWidget *hbox;
2245
        GtkWidget *chkbtn_enable_junk;
2246
        GtkWidget *label;
2247
        GtkWidget *optmenu_preset;
2248
        GtkWidget *menu;
2249
        GtkWidget *menuitem;
2250
        GtkWidget *entry_junk_learncmd;
2251
        GtkWidget *entry_nojunk_learncmd;
2252
        GtkWidget *entry_classify_cmd;
2253
        GtkWidget *vbox3;
2254
        GtkWidget *entry_junkfolder;
2255
        GtkWidget *btn_folder;
2256
        GtkWidget *chkbtn_filter_on_recv;
2257
        GtkWidget *chkbtn_filter_before;
2258
        GtkWidget *chkbtn_delete_on_recv;
2259
        GtkWidget *chkbtn_nofilter_in_book;
2260
        GtkWidget *chkbtn_mark_as_read;
2261

    
2262
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2263
        gtk_widget_show (vbox1);
2264
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2265
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2266

    
2267
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame, chkbtn_enable_junk,
2268
                                     _("Enable Junk mail control"));
2269

    
2270
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2271
        gtk_widget_show (vbox2);
2272
        gtk_container_add (GTK_CONTAINER (frame), vbox2);
2273
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2274
        SET_TOGGLE_SENSITIVITY (chkbtn_enable_junk, vbox2);
2275

    
2276
        hbox = gtk_hbox_new (FALSE, 8);
2277
        gtk_widget_show (hbox);
2278
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2279

    
2280
        label = gtk_label_new (_("Learning command:"));
2281
        gtk_widget_show (label);
2282
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2283

    
2284
        optmenu_preset = gtk_option_menu_new ();
2285
        gtk_widget_show (optmenu_preset);
2286
        gtk_box_pack_end (GTK_BOX (hbox), optmenu_preset, FALSE, FALSE, 0);
2287

    
2288
        menu = gtk_menu_new ();
2289
        MENUITEM_ADD (menu, menuitem, _("(Select preset)"), 0);
2290
        MENUITEM_ADD (menu, menuitem, "bogofilter", JUNK_BOGOFILTER);
2291
        g_signal_connect (G_OBJECT (menuitem), "activate",
2292
                          G_CALLBACK (prefs_junk_preset_activated), NULL);
2293
        MENUITEM_ADD (menu, menuitem, "bsfilter", JUNK_BSFILTER);
2294
        g_signal_connect (G_OBJECT (menuitem), "activate",
2295
                          G_CALLBACK (prefs_junk_preset_activated), NULL);
2296
        MENUITEM_ADD (menu, menuitem, "sylfilter", JUNK_SYLFILTER);
2297
        g_signal_connect (G_OBJECT (menuitem), "activate",
2298
                          G_CALLBACK (prefs_junk_preset_activated), NULL);
2299
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_preset), menu);
2300

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

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

    
2309
        entry_junk_learncmd = gtk_entry_new ();
2310
        gtk_widget_show (entry_junk_learncmd);
2311
        gtk_box_pack_start (GTK_BOX (hbox), entry_junk_learncmd, TRUE, TRUE, 0);
2312

    
2313
        hbox = gtk_hbox_new (FALSE, 8);
2314
        gtk_widget_show (hbox);
2315
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2316

    
2317
        label = gtk_label_new (_("Not Junk"));
2318
        gtk_widget_show (label);
2319
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2320

    
2321
        entry_nojunk_learncmd = gtk_entry_new ();
2322
        gtk_widget_show (entry_nojunk_learncmd);
2323
        gtk_box_pack_start (GTK_BOX (hbox), entry_nojunk_learncmd,
2324
                            TRUE, TRUE, 0);
2325

    
2326
        PACK_VSPACER(vbox2, vbox3, 0);
2327

    
2328
        hbox = gtk_hbox_new (FALSE, 8);
2329
        gtk_widget_show (hbox);
2330
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2331

    
2332
        label = gtk_label_new (_("Classifying command"));
2333
        gtk_widget_show (label);
2334
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2335

    
2336
        entry_classify_cmd = gtk_entry_new ();
2337
        gtk_widget_show (entry_classify_cmd);
2338
        gtk_box_pack_start (GTK_BOX (hbox), entry_classify_cmd, TRUE, TRUE, 0);
2339

    
2340
        PACK_VSPACER(vbox2, vbox3, 0);
2341

    
2342
        PACK_SMALL_LABEL (vbox2, label,
2343
                          _("To classify junk mails automatically, both junk "
2344
                            "and not junk mails must be learned manually to "
2345
                            "a certain extent."));
2346

    
2347
        PACK_VSPACER(vbox2, vbox3, 0);
2348

    
2349
        hbox = gtk_hbox_new (FALSE, 8);
2350
        gtk_widget_show (hbox);
2351
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2352

    
2353
        label = gtk_label_new (_("Junk folder"));
2354
        gtk_widget_show (label);
2355
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2356

    
2357
        entry_junkfolder = gtk_entry_new ();
2358
        gtk_widget_show (entry_junkfolder);
2359
        gtk_box_pack_start (GTK_BOX (hbox), entry_junkfolder, TRUE, TRUE, 0);
2360

    
2361
        btn_folder = gtk_button_new_with_label (_(" ... "));
2362
        gtk_widget_show (btn_folder);
2363
        gtk_box_pack_start (GTK_BOX (hbox), btn_folder, FALSE, FALSE, 0);
2364
        g_signal_connect (G_OBJECT (btn_folder), "clicked",
2365
                          G_CALLBACK (prefs_common_select_folder_cb),
2366
                          entry_junkfolder);
2367

    
2368
        PACK_VSPACER(vbox2, vbox3, 0);
2369

    
2370
        PACK_SMALL_LABEL (vbox2, label,
2371
                          _("The messages which are set as junk mail "
2372
                            "will be moved to this folder. If empty, "
2373
                            "the default junk folder will be used."));
2374

    
2375
        PACK_VSPACER(vbox2, vbox3, 0);
2376

    
2377
        vbox3 = gtk_vbox_new (FALSE, 0);
2378
        gtk_widget_show (vbox3);
2379
        gtk_box_pack_start (GTK_BOX(vbox2), vbox3, FALSE, FALSE, 0);
2380

    
2381
        PACK_CHECK_BUTTON
2382
                (vbox3, chkbtn_filter_on_recv,
2383
                 _("Filter messages classified as junk on receiving"));
2384
        PACK_CHECK_BUTTON
2385
                (vbox3, chkbtn_filter_before,
2386
                 _("Filter junk mails before normal filtering"));
2387
        PACK_CHECK_BUTTON
2388
                (vbox3, chkbtn_delete_on_recv,
2389
                 _("Delete junk mails from server on receiving"));
2390
        SET_TOGGLE_SENSITIVITY (chkbtn_filter_on_recv, chkbtn_filter_before);
2391
        SET_TOGGLE_SENSITIVITY (chkbtn_filter_on_recv, chkbtn_delete_on_recv);
2392

    
2393
        PACK_CHECK_BUTTON
2394
                (vbox3, chkbtn_nofilter_in_book,
2395
                 _("Do not classify message as junk if sender is in the address book"));
2396
        PACK_CHECK_BUTTON (vbox3, chkbtn_mark_as_read,
2397
                           _("Mark filtered junk mails as read"));
2398

    
2399
        junk.chkbtn_enable_junk      = chkbtn_enable_junk;
2400
        junk.entry_junk_learncmd     = entry_junk_learncmd;
2401
        junk.entry_nojunk_learncmd   = entry_nojunk_learncmd;
2402
        junk.entry_classify_cmd      = entry_classify_cmd;
2403
        junk.entry_junkfolder        = entry_junkfolder;
2404
        junk.chkbtn_filter_on_recv   = chkbtn_filter_on_recv;
2405
        junk.chkbtn_filter_before    = chkbtn_filter_before;
2406
        junk.chkbtn_delete_on_recv   = chkbtn_delete_on_recv;
2407
        junk.chkbtn_nofilter_in_book = chkbtn_nofilter_in_book;
2408
        junk.chkbtn_mark_as_read     = chkbtn_mark_as_read;
2409
}
2410

    
2411
#if USE_GPGME
2412
static void prefs_privacy_create(void)
2413
{
2414
        GtkWidget *vbox1;
2415
        GtkWidget *vbox2;
2416
        GtkWidget *vbox3;
2417
        GtkWidget *hbox1;
2418
        GtkWidget *hbox_spc;
2419
        GtkWidget *label;
2420
        GtkWidget *checkbtn_auto_check_signatures;
2421
        GtkWidget *checkbtn_gpg_signature_popup;
2422
        GtkWidget *checkbtn_store_passphrase;
2423
        GtkObject *spinbtn_store_passphrase_adj;
2424
        GtkWidget *spinbtn_store_passphrase;
2425
#ifndef G_OS_WIN32
2426
        GtkWidget *checkbtn_passphrase_grab;
2427
#endif
2428
        GtkWidget *checkbtn_gpg_warning;
2429

    
2430
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2431
        gtk_widget_show (vbox1);
2432
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2433
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2434

    
2435
        vbox2 = gtk_vbox_new (FALSE, 0);
2436
        gtk_widget_show (vbox2);
2437
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2438

    
2439
        PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
2440
                           _("Automatically check signatures"));
2441

    
2442
        PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup,
2443
                           _("Show signature check result in a popup window"));
2444

    
2445
        PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
2446
                           _("Store passphrase in memory temporarily"));
2447

    
2448
        vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2449
        gtk_widget_show (vbox3);
2450
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2451

    
2452
        hbox1 = gtk_hbox_new (FALSE, 8);
2453
        gtk_widget_show (hbox1);
2454
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2455

    
2456
        hbox_spc = gtk_hbox_new (FALSE, 0);
2457
        gtk_widget_show (hbox_spc);
2458
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2459
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2460

    
2461
        label = gtk_label_new (_("Expired after"));
2462
        gtk_widget_show (label);
2463
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2464

    
2465
        spinbtn_store_passphrase_adj = gtk_adjustment_new (0, 0, 1440, 1, 5, 0);
2466
        spinbtn_store_passphrase = gtk_spin_button_new
2467
                (GTK_ADJUSTMENT (spinbtn_store_passphrase_adj), 1, 0);
2468
        gtk_widget_show (spinbtn_store_passphrase);
2469
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_store_passphrase, FALSE, FALSE, 0);
2470
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_store_passphrase),
2471
                                     TRUE);
2472
        gtk_widget_set_size_request (spinbtn_store_passphrase, 64, -1);
2473

    
2474
        label = gtk_label_new (_("minute(s) "));
2475
        gtk_widget_show (label);
2476
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2477

    
2478
        hbox1 = gtk_hbox_new (FALSE, 8);
2479
        gtk_widget_show (hbox1);
2480
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2481

    
2482
        hbox_spc = gtk_hbox_new (FALSE, 0);
2483
        gtk_widget_show (hbox_spc);
2484
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2485
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2486

    
2487
        PACK_SMALL_LABEL (hbox1, label,
2488
                          _("Setting to '0' will store the passphrase "
2489
                            "for the whole session."));
2490

    
2491
        SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, vbox3);
2492

    
2493
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
2494

    
2495
#ifndef G_OS_WIN32
2496
        PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
2497
                           _("Grab input while entering a passphrase"));
2498
#endif
2499

    
2500
        PACK_CHECK_BUTTON
2501
                (vbox2, checkbtn_gpg_warning,
2502
                 _("Display warning on startup if GnuPG doesn't work"));
2503

    
2504
        hbox1 = gtk_hbox_new (FALSE, 8);
2505
        gtk_widget_show (hbox1);
2506
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2507

    
2508
        privacy.checkbtn_auto_check_signatures
2509
                                             = checkbtn_auto_check_signatures;
2510
        privacy.checkbtn_gpg_signature_popup
2511
                                             = checkbtn_gpg_signature_popup;
2512
        privacy.checkbtn_store_passphrase    = checkbtn_store_passphrase;
2513
        privacy.spinbtn_store_passphrase     = spinbtn_store_passphrase;
2514
        privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
2515
#ifndef G_OS_WIN32
2516
        privacy.checkbtn_passphrase_grab     = checkbtn_passphrase_grab;
2517
#endif
2518
        privacy.checkbtn_gpg_warning         = checkbtn_gpg_warning;
2519
}
2520
#endif /* USE_GPGME */
2521

    
2522
static void prefs_details_create(void)
2523
{
2524
        GtkWidget *vbox1;
2525

    
2526
        GtkWidget *notebook;
2527
        GtkWidget *vbox_tab;
2528

    
2529
        GtkWidget *vbox2;
2530
        GtkWidget *vbox3;
2531
        GtkWidget *checkbtn_always_show_msg;
2532
        GtkWidget *checkbtn_always_mark_read;
2533
        GtkWidget *checkbtn_openunread;
2534
        GtkWidget *checkbtn_remember_lastsel;
2535
        /* GtkWidget *checkbtn_mark_as_read_on_newwin; */
2536
        GtkWidget *checkbtn_openinbox;
2537
        GtkWidget *checkbtn_openinbox_startup;
2538
        GtkWidget *checkbtn_change_account_on_folder_sel;
2539
        GtkWidget *checkbtn_immedexec;
2540
        GtkWidget *hbox1;
2541
        GtkWidget *hbox_spc;
2542
        GtkWidget *label;
2543
#ifndef G_OS_WIN32
2544
        GtkWidget *checkbtn_comply_gnome_hig;
2545
#endif
2546
        GtkWidget *checkbtn_show_trayicon;
2547
        GtkWidget *checkbtn_minimize_to_tray;
2548
        GtkWidget *checkbtn_tray_toggle_window;
2549

    
2550
        GtkWidget *button_keybind;
2551

    
2552
        GtkWidget *other_wid;
2553
        GtkWidget *extcmd_wid;
2554
#if USE_UPDATE_CHECK
2555
        GtkWidget *update_wid;
2556
#endif
2557
        GtkWidget *advanced_wid;
2558

    
2559
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2560
        gtk_widget_show (vbox1);
2561
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2562
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2563

    
2564
        notebook = gtk_notebook_new();
2565
        gtk_widget_show(notebook);
2566
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
2567

    
2568
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Interface"));
2569

    
2570
        vbox2 = gtk_vbox_new (FALSE, 0);
2571
        gtk_widget_show (vbox2);
2572
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
2573

    
2574
        PACK_CHECK_BUTTON
2575
                (vbox2, checkbtn_always_show_msg,
2576
                 _("Always open messages in summary when selected"));
2577

    
2578
        PACK_CHECK_BUTTON
2579
                (vbox2, checkbtn_always_mark_read,
2580
                 _("Always mark as read when a message is opened"));
2581
        SET_TOGGLE_SENSITIVITY
2582
                (checkbtn_always_show_msg, checkbtn_always_mark_read);
2583

    
2584
        PACK_CHECK_BUTTON
2585
                (vbox2, checkbtn_openunread,
2586
                 _("Open first unread message when a folder is opened"));
2587
        SET_TOGGLE_SENSITIVITY_REV
2588
                (checkbtn_always_show_msg, checkbtn_openunread);
2589

    
2590
        PACK_CHECK_BUTTON
2591
                (vbox2, checkbtn_remember_lastsel,
2592
                 _("Remember last selected message"));
2593

    
2594
#if 0
2595
        PACK_CHECK_BUTTON
2596
                (vbox2, checkbtn_mark_as_read_on_newwin,
2597
                 _("Only mark message as read when opened in new window"));
2598
#endif
2599

    
2600
        hbox1 = gtk_hbox_new (FALSE, 8);
2601
        gtk_widget_show (hbox1);
2602
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2603
        PACK_CHECK_BUTTON
2604
                (hbox1, checkbtn_openinbox,
2605
                 _("Open inbox after receiving new mail"));
2606
        PACK_CHECK_BUTTON
2607
                (hbox1, checkbtn_openinbox_startup, _("Open inbox on startup"));
2608

    
2609
        PACK_CHECK_BUTTON
2610
                (vbox2, checkbtn_change_account_on_folder_sel,
2611
                 _("Change current account on folder open"));
2612

    
2613
        vbox3 = gtk_vbox_new (FALSE, 0);
2614
        gtk_widget_show (vbox3);
2615
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2616

    
2617
        PACK_CHECK_BUTTON
2618
                (vbox3, checkbtn_immedexec,
2619
                 _("Execute immediately when moving or deleting messages"));
2620

    
2621
        hbox1 = gtk_hbox_new (FALSE, 8);
2622
        gtk_widget_show (hbox1);
2623
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2624

    
2625
        hbox_spc = gtk_hbox_new (FALSE, 0);
2626
        gtk_widget_show (hbox_spc);
2627
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2628
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2629

    
2630
        PACK_SMALL_LABEL (hbox1, label,
2631
                          _("Messages will be marked until execution "
2632
                            "if this is turned off."));
2633

    
2634
        vbox2 = gtk_vbox_new (FALSE, 0);
2635
        gtk_widget_show (vbox2);
2636
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
2637

    
2638
#ifndef G_OS_WIN32
2639
        PACK_CHECK_BUTTON (vbox2, checkbtn_comply_gnome_hig,
2640
                           _("Make the order of buttons comply with GNOME HIG"));
2641
#endif
2642
        PACK_CHECK_BUTTON (vbox2, checkbtn_show_trayicon,
2643
                           _("Display tray icon"));
2644
        PACK_CHECK_BUTTON (vbox2, checkbtn_minimize_to_tray,
2645
                           _("Minimize to tray icon"));
2646
        PACK_CHECK_BUTTON (vbox2, checkbtn_tray_toggle_window,
2647
                           _("Toggle window on trayicon click"));
2648
        SET_TOGGLE_SENSITIVITY (checkbtn_show_trayicon,
2649
                                checkbtn_minimize_to_tray);
2650
        SET_TOGGLE_SENSITIVITY (checkbtn_show_trayicon,
2651
                                checkbtn_tray_toggle_window);
2652

    
2653
        hbox1 = gtk_hbox_new (FALSE, 8);
2654
        gtk_widget_show (hbox1);
2655
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
2656

    
2657
        button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2658
        gtk_widget_show (button_keybind);
2659
        gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2660
        g_signal_connect (G_OBJECT (button_keybind), "clicked",
2661
                          G_CALLBACK (prefs_keybind_select), NULL);
2662

    
2663
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Other"));
2664
        other_wid = prefs_other_create();
2665
        gtk_box_pack_start(GTK_BOX(vbox_tab), other_wid, FALSE, FALSE, 0);
2666

    
2667
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("External commands"));
2668
        extcmd_wid = prefs_extcmd_create();
2669
        gtk_box_pack_start(GTK_BOX(vbox_tab), extcmd_wid, FALSE, FALSE, 0);
2670

    
2671
#if USE_UPDATE_CHECK
2672
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Update"));
2673
        update_wid = prefs_update_create();
2674
        gtk_box_pack_start(GTK_BOX(vbox_tab), update_wid, FALSE, FALSE, 0);
2675
#endif
2676

    
2677
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Advanced"));
2678
        advanced_wid = prefs_advanced_create();
2679
        gtk_box_pack_start(GTK_BOX(vbox_tab), advanced_wid, FALSE, FALSE, 0);
2680

    
2681
        iface.checkbtn_always_show_msg   = checkbtn_always_show_msg;
2682
        iface.checkbtn_always_mark_read  = checkbtn_always_mark_read;
2683
        iface.checkbtn_openunread        = checkbtn_openunread;
2684
        iface.checkbtn_remember_lastsel  = checkbtn_remember_lastsel;
2685
#if 0
2686
        iface.checkbtn_mark_as_read_on_newwin
2687
                                             = checkbtn_mark_as_read_on_newwin;
2688
#endif
2689
        iface.checkbtn_openinbox         = checkbtn_openinbox;
2690
        iface.checkbtn_openinbox_startup = checkbtn_openinbox_startup;
2691
        iface.checkbtn_change_account_on_folder_sel =
2692
                checkbtn_change_account_on_folder_sel;
2693
        iface.checkbtn_immedexec         = checkbtn_immedexec;
2694

    
2695
#ifndef G_OS_WIN32
2696
        iface.checkbtn_comply_gnome_hig  = checkbtn_comply_gnome_hig;
2697
#endif
2698
        iface.checkbtn_show_trayicon      = checkbtn_show_trayicon;
2699
        iface.checkbtn_minimize_to_tray   = checkbtn_minimize_to_tray;
2700
        iface.checkbtn_tray_toggle_window = checkbtn_tray_toggle_window;
2701
}
2702

    
2703
static GtkWidget *prefs_other_create(void)
2704
{
2705
        GtkWidget *vbox1;
2706

    
2707
        GtkWidget *frame_recv;
2708
        GtkWidget *vbox_recv;
2709
        GtkWidget *hbox1;
2710
        GtkWidget *label;
2711
        GtkWidget *optmenu_recvdialog;
2712
        GtkWidget *menu;
2713
        GtkWidget *menuitem;
2714
        GtkWidget *checkbtn_no_recv_err_panel;
2715
        GtkWidget *checkbtn_close_recv_dialog;
2716

    
2717
        GtkWidget *frame_addr;
2718
        GtkWidget *vbox_addr;
2719
        GtkWidget *checkbtn_addaddrbyclick;
2720
        GtkWidget *checkbtn_add_address_only;
2721
        GtkWidget *vbox_spc;
2722
        GtkWidget *radiobtn_addr_compl;
2723
        GtkWidget *radiobtn_compl_tab;
2724
        GtkWidget *radiobtn_no_compl;
2725

    
2726
        GtkWidget *frame_exit;
2727
        GtkWidget *vbox_exit;
2728
        GtkWidget *checkbtn_confonexit;
2729
        GtkWidget *checkbtn_cleanonexit;
2730
        GtkWidget *checkbtn_askonclean;
2731
        GtkWidget *checkbtn_warnqueued;
2732

    
2733
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2734
        gtk_widget_show (vbox1);
2735

    
2736
        PACK_FRAME (vbox1, frame_recv, _("Receive dialog"));
2737
        vbox_recv = gtk_vbox_new (FALSE, 0);
2738
        gtk_widget_show (vbox_recv);
2739
        gtk_container_add (GTK_CONTAINER (frame_recv), vbox_recv);
2740
        gtk_container_set_border_width (GTK_CONTAINER (vbox_recv), 8);
2741

    
2742
        hbox1 = gtk_hbox_new (FALSE, 8);
2743
        gtk_widget_show (hbox1);
2744
        gtk_box_pack_start (GTK_BOX (vbox_recv), hbox1, FALSE, FALSE, 0);
2745

    
2746
        label = gtk_label_new (_("Show receive dialog"));
2747
        gtk_widget_show (label);
2748
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2749

    
2750
        optmenu_recvdialog = gtk_option_menu_new ();
2751
        gtk_widget_show (optmenu_recvdialog);
2752
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_recvdialog,
2753
                            FALSE, FALSE, 0);
2754

    
2755
        menu = gtk_menu_new ();
2756
        MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
2757
        MENUITEM_ADD (menu, menuitem, _("Only on manual receiving"),
2758
                      RECV_DIALOG_MANUAL);
2759
        MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
2760

    
2761
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
2762

    
2763
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_no_recv_err_panel,
2764
                           _("Don't popup error dialog on receive error"));
2765

    
2766
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_close_recv_dialog,
2767
                           _("Close receive dialog when finished"));
2768

    
2769
        PACK_FRAME (vbox1, frame_addr, _("Address book"));
2770

    
2771
        vbox_addr = gtk_vbox_new (FALSE, 0);
2772
        gtk_widget_show (vbox_addr);
2773
        gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2774
        gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2775

    
2776
        PACK_CHECK_BUTTON
2777
                (vbox_addr, checkbtn_addaddrbyclick,
2778
                 _("Add address to destination when double-clicked"));
2779

    
2780
        PACK_CHECK_BUTTON
2781
                (vbox_addr, checkbtn_add_address_only,
2782
                 _("Set only mail address when entering recipient from address book"));
2783

    
2784
        PACK_VSPACER (vbox_addr, vbox_spc, VSPACING_NARROW_2);
2785

    
2786
        hbox1 = gtk_hbox_new (FALSE, 8);
2787
        gtk_widget_show (hbox1);
2788
        gtk_box_pack_start (GTK_BOX (vbox_addr), hbox1, FALSE, FALSE, 0);
2789

    
2790
        label = gtk_label_new (_("Auto-completion:"));
2791
        gtk_widget_show (label);
2792
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2793

    
2794
        radiobtn_addr_compl = gtk_radio_button_new_with_label
2795
                (NULL, _("Automatic"));
2796
        gtk_widget_show (radiobtn_addr_compl);
2797
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_addr_compl,
2798
                            FALSE, FALSE, 0);
2799
        g_object_set_data (G_OBJECT (radiobtn_addr_compl), MENU_VAL_ID,
2800
                           GINT_TO_POINTER (0));
2801

    
2802
        radiobtn_compl_tab = gtk_radio_button_new_with_label_from_widget
2803
                (GTK_RADIO_BUTTON (radiobtn_addr_compl), _("Start with Tab"));
2804
        gtk_widget_show (radiobtn_compl_tab);
2805
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_compl_tab,
2806
                            FALSE, FALSE, 0);
2807
        g_object_set_data (G_OBJECT (radiobtn_compl_tab), MENU_VAL_ID,
2808
                           GINT_TO_POINTER (1));
2809

    
2810
        radiobtn_no_compl = gtk_radio_button_new_with_label_from_widget
2811
                (GTK_RADIO_BUTTON (radiobtn_addr_compl), _("Disable"));
2812
        gtk_widget_show (radiobtn_no_compl);
2813
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_no_compl,
2814
                            FALSE, FALSE, 0);
2815
        g_object_set_data (G_OBJECT (radiobtn_no_compl), MENU_VAL_ID,
2816
                           GINT_TO_POINTER (2));
2817

    
2818
        PACK_FRAME (vbox1, frame_exit, _("On exit"));
2819

    
2820
        vbox_exit = gtk_vbox_new (FALSE, 0);
2821
        gtk_widget_show (vbox_exit);
2822
        gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2823
        gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2824

    
2825
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2826
                           _("Confirm on exit"));
2827

    
2828
        hbox1 = gtk_hbox_new (FALSE, 32);
2829
        gtk_widget_show (hbox1);
2830
        gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2831

    
2832
        PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2833
                           _("Empty trash on exit"));
2834
        PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2835
                           _("Ask before emptying"));
2836
        SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2837

    
2838
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2839
                           _("Warn if there are queued messages"));
2840

    
2841
        other.optmenu_recvdialog         = optmenu_recvdialog;
2842
        other.checkbtn_no_recv_err_panel = checkbtn_no_recv_err_panel;
2843
        other.checkbtn_close_recv_dialog = checkbtn_close_recv_dialog;
2844

    
2845
        other.checkbtn_addaddrbyclick    = checkbtn_addaddrbyclick;
2846
        other.checkbtn_add_address_only  = checkbtn_add_address_only;
2847
        other.radiobtn_addr_compl        = radiobtn_addr_compl;
2848

    
2849
        other.checkbtn_confonexit  = checkbtn_confonexit;
2850
        other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2851
        other.checkbtn_askonclean  = checkbtn_askonclean;
2852
        other.checkbtn_warnqueued  = checkbtn_warnqueued;
2853

    
2854
        return vbox1;
2855
}
2856

    
2857
static GtkWidget *prefs_extcmd_create(void)
2858
{
2859
        GtkWidget *vbox1;
2860
        GtkWidget *hbox1;
2861

    
2862
        GtkWidget *ext_frame;
2863
        GtkWidget *ext_table;
2864

    
2865
        GtkWidget *uri_label;
2866
        GtkWidget *uri_combo;
2867
        GtkWidget *uri_entry;
2868

    
2869
        GtkWidget *exteditor_label;
2870
        GtkWidget *exteditor_combo;
2871
        GtkWidget *exteditor_entry;
2872

    
2873
        GtkWidget *frame_printcmd;
2874
        GtkWidget *vbox_printcmd;
2875
        GtkWidget *checkbtn_printcmd;
2876
        GtkWidget *printcmd_label;
2877
        GtkWidget *printcmd_entry;
2878

    
2879
#ifndef G_OS_WIN32
2880
        GtkWidget *vbox2;
2881
        GtkWidget *frame_incext;
2882
        GtkWidget *checkbtn_incext;
2883
        GtkWidget *label_incext;
2884
        GtkWidget *entry_incext;
2885
#endif
2886
        GtkWidget *frame_extsend;
2887
        GtkWidget *vbox_extsend;
2888
        GtkWidget *checkbtn_extsend;
2889
        GtkWidget *label_extsend;
2890
        GtkWidget *entry_extsend;
2891

    
2892
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2893
        gtk_widget_show (vbox1);
2894

    
2895
        PACK_FRAME(vbox1, ext_frame,
2896
                   _("External commands (%s will be replaced with file name / URI)"));
2897

    
2898
        ext_table = gtk_table_new (2, 2, FALSE);
2899
        gtk_widget_show (ext_table);
2900
        gtk_container_add (GTK_CONTAINER (ext_frame), ext_table);
2901
        gtk_container_set_border_width (GTK_CONTAINER (ext_table), 8);
2902
        gtk_table_set_row_spacings (GTK_TABLE (ext_table), VSPACING_NARROW);
2903
        gtk_table_set_col_spacings (GTK_TABLE (ext_table), 8);
2904

    
2905
        uri_label = gtk_label_new (_("Web browser"));
2906
        gtk_widget_show(uri_label);
2907
        gtk_table_attach (GTK_TABLE (ext_table), uri_label, 0, 1, 0, 1,
2908
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2909
        gtk_misc_set_alignment (GTK_MISC (uri_label), 1, 0.5);
2910

    
2911
        uri_combo = gtk_combo_new ();
2912
        gtk_widget_show (uri_combo);
2913
        gtk_table_attach (GTK_TABLE (ext_table), uri_combo, 1, 2, 0, 1,
2914
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
2915
        gtkut_combo_set_items (GTK_COMBO (uri_combo),
2916
#if defined(G_OS_WIN32) || defined(__APPLE__)
2917
                               _("(Default browser)"),
2918
#else
2919
                               DEFAULT_BROWSER_CMD,
2920
                               "sensible-browser '%s'",
2921
                               "firefox -remote 'openURL(%s,new-window)'",
2922
                               "firefox '%s'",
2923
                               "mozilla -remote 'openURL(%s,new-window)'",
2924
                               "mozilla '%s'",
2925
                               "rxvt -e w3m '%s'",
2926
                               "rxvt -e lynx '%s'",
2927
#endif
2928
                               NULL);
2929
        uri_entry = GTK_COMBO (uri_combo)->entry;
2930

    
2931
        exteditor_label = gtk_label_new (_("Editor"));
2932
        gtk_widget_show (exteditor_label);
2933
        gtk_table_attach (GTK_TABLE (ext_table), exteditor_label, 0, 1, 1, 2,
2934
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2935
        gtk_misc_set_alignment (GTK_MISC (exteditor_label), 1, 0.5);
2936

    
2937
        exteditor_combo = gtk_combo_new ();
2938
        gtk_widget_show (exteditor_combo);
2939
        gtk_table_attach (GTK_TABLE (ext_table), exteditor_combo, 1, 2, 1, 2,
2940
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
2941
        gtkut_combo_set_items (GTK_COMBO (exteditor_combo),
2942
#ifdef G_OS_WIN32
2943
                               "notepad '%s'",
2944
#elif defined(__APPLE__)
2945
                               "open -t '%s'",
2946
#else
2947
                               "gedit %s",
2948
                               "kedit %s",
2949
                               "emacs %s",
2950
                               "xemacs %s",
2951
                               "rxvt -e jed %s",
2952
                               "rxvt -e vi %s",
2953
#endif
2954
                               NULL);
2955
        exteditor_entry = GTK_COMBO (exteditor_combo)->entry;
2956

    
2957
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_printcmd, checkbtn_printcmd,
2958
                                     _("Use external program for printing"));
2959

    
2960
        vbox_printcmd = gtk_vbox_new (FALSE, VSPACING_NARROW);
2961
        gtk_widget_show (vbox_printcmd);
2962
        gtk_container_add (GTK_CONTAINER (frame_printcmd), vbox_printcmd);
2963
        gtk_container_set_border_width (GTK_CONTAINER (vbox_printcmd), 8);
2964
        SET_TOGGLE_SENSITIVITY (checkbtn_printcmd, vbox_printcmd);
2965

    
2966
        hbox1 = gtk_hbox_new (FALSE, 8);
2967
        gtk_widget_show (hbox1);
2968
        gtk_box_pack_start (GTK_BOX (vbox_printcmd), hbox1, FALSE, FALSE, 0);
2969

    
2970
        printcmd_label = gtk_label_new (_("Command"));
2971
        gtk_widget_show (printcmd_label);
2972
        gtk_box_pack_start (GTK_BOX (hbox1), printcmd_label, FALSE, FALSE, 0);
2973

    
2974
        printcmd_entry = gtk_entry_new ();
2975
        gtk_widget_show (printcmd_entry);
2976
        gtk_box_pack_start (GTK_BOX (hbox1), printcmd_entry, TRUE, TRUE, 0);
2977

    
2978
#ifndef G_OS_WIN32
2979
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_incext, checkbtn_incext,
2980
                                     _("Use external program for incorporation"));
2981

    
2982
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2983
        gtk_widget_show (vbox2);
2984
        gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
2985
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2986
        SET_TOGGLE_SENSITIVITY (checkbtn_incext, vbox2);
2987

    
2988
        hbox1 = gtk_hbox_new (FALSE, 8);
2989
        gtk_widget_show (hbox1);
2990
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2991

    
2992
        label_incext = gtk_label_new (_("Command"));
2993
        gtk_widget_show (label_incext);
2994
        gtk_box_pack_start (GTK_BOX (hbox1), label_incext, FALSE, FALSE, 0);
2995

    
2996
        entry_incext = gtk_entry_new ();
2997
        gtk_widget_show (entry_incext);
2998
        gtk_box_pack_start (GTK_BOX (hbox1), entry_incext, TRUE, TRUE, 0);
2999
#endif /* !G_OS_WIN32 */
3000

    
3001
        PACK_FRAME_WITH_CHECK_BUTTON (vbox1, frame_extsend, checkbtn_extsend,
3002
                                      _("Use external program for sending"));
3003

    
3004
        vbox_extsend = gtk_vbox_new (FALSE, VSPACING_NARROW);
3005
        gtk_widget_show (vbox_extsend);
3006
        gtk_container_add (GTK_CONTAINER (frame_extsend), vbox_extsend);
3007
        gtk_container_set_border_width (GTK_CONTAINER (vbox_extsend), 8);
3008
        SET_TOGGLE_SENSITIVITY(checkbtn_extsend, vbox_extsend);
3009

    
3010
        hbox1 = gtk_hbox_new (FALSE, 8);
3011
        gtk_widget_show (hbox1);
3012
        gtk_box_pack_start (GTK_BOX (vbox_extsend), hbox1, FALSE, FALSE, 0);
3013

    
3014
        label_extsend = gtk_label_new (_("Command"));
3015
        gtk_widget_show (label_extsend);
3016
        gtk_box_pack_start (GTK_BOX (hbox1), label_extsend, FALSE, FALSE, 0);
3017

    
3018
        entry_extsend = gtk_entry_new ();
3019
        gtk_widget_show (entry_extsend);
3020
        gtk_box_pack_start (GTK_BOX (hbox1), entry_extsend, TRUE, TRUE, 0);
3021

    
3022
        extcmd.uri_combo = uri_combo;
3023
        extcmd.uri_entry = uri_entry;
3024
        extcmd.checkbtn_printcmd = checkbtn_printcmd;
3025
        extcmd.printcmd_entry = printcmd_entry;
3026

    
3027
        extcmd.exteditor_combo = exteditor_combo;
3028
        extcmd.exteditor_entry = exteditor_entry;
3029

    
3030
#ifndef G_OS_WIN32
3031
        extcmd.checkbtn_incext = checkbtn_incext;
3032
        extcmd.entry_incext    = entry_incext;
3033
#endif
3034
        extcmd.checkbtn_extsend = checkbtn_extsend;
3035
        extcmd.entry_extsend    = entry_extsend;
3036

    
3037
        return vbox1;
3038
}
3039

    
3040
#if USE_UPDATE_CHECK
3041
static GtkWidget *prefs_update_create(void)
3042
{
3043
        GtkWidget *vbox1;
3044
        GtkWidget *vbox2;
3045
        GtkWidget *checkbtn_autoupdate;
3046
        GtkWidget *checkbtn_useproxy;
3047
        GtkWidget *label;
3048
        GtkWidget *entry_proxyhost;
3049

    
3050
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3051
        gtk_widget_show (vbox1);
3052

    
3053
#ifndef G_OS_WIN32
3054
        label = gtk_label_new (_("Update check requires 'curl' command."));
3055
        gtk_widget_show (label);
3056
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
3057
        gtk_box_pack_start (GTK_BOX (vbox1), label, FALSE, FALSE, 0);
3058
#endif
3059

    
3060
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
3061
        gtk_widget_show (vbox2);
3062
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3063

    
3064
        PACK_CHECK_BUTTON (vbox2, checkbtn_autoupdate,
3065
                           _("Enable auto update check"));
3066
        PACK_CHECK_BUTTON (vbox2, checkbtn_useproxy,
3067
                           _("Use HTTP proxy"));
3068

    
3069
        label = gtk_label_new (_("HTTP proxy host (hostname:port):"));
3070
        gtk_widget_show (label);
3071
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
3072
        gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0);
3073

    
3074
        entry_proxyhost = gtk_entry_new ();
3075
        gtk_widget_show (entry_proxyhost);
3076
        gtk_box_pack_start (GTK_BOX (vbox2), entry_proxyhost, FALSE, FALSE, 0);
3077

    
3078
        SET_TOGGLE_SENSITIVITY(checkbtn_useproxy, label);
3079
        SET_TOGGLE_SENSITIVITY(checkbtn_useproxy, entry_proxyhost);
3080

    
3081
        update_check.checkbtn_autoupdate = checkbtn_autoupdate;
3082
        update_check.checkbtn_useproxy = checkbtn_useproxy;
3083
        update_check.entry_proxyhost = entry_proxyhost;
3084

    
3085
        return vbox1;
3086
}
3087
#endif /* USE_UPDATE_CHECK */
3088

    
3089
static GtkWidget *prefs_advanced_create(void)
3090
{
3091
        GtkWidget *vbox1;
3092

    
3093
        GtkWidget *vbox2;
3094
        GtkWidget *checkbtn_strict_cache_check;
3095
        GtkWidget *label;
3096

    
3097
        GtkWidget *hbox1;
3098
        GtkWidget *label_iotimeout;
3099
        GtkWidget *spinbtn_iotimeout;
3100
        GtkObject *spinbtn_iotimeout_adj;
3101

    
3102
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3103
        gtk_widget_show (vbox1);
3104

    
3105
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
3106
        gtk_widget_show (vbox2);
3107
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3108

    
3109
        PACK_CHECK_BUTTON (vbox2, checkbtn_strict_cache_check,
3110
                           _("Enable strict checking of the integrity of summary caches"));
3111
        PACK_SMALL_LABEL
3112
                (vbox2, label,
3113
                 _("Enable this if the contents of folders have the possibility of modification by other applications.\n"
3114
                   "This option will degrade the performance of displaying summary."));
3115

    
3116
        hbox1 = gtk_hbox_new (FALSE, 8);
3117
        gtk_widget_show (hbox1);
3118
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3119

    
3120
        label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
3121
        gtk_widget_show (label_iotimeout);
3122
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
3123

    
3124
        spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 0);
3125
        spinbtn_iotimeout = gtk_spin_button_new
3126
                (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
3127
        gtk_widget_show (spinbtn_iotimeout);
3128
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
3129
                            FALSE, FALSE, 0);
3130
        gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
3131
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
3132

    
3133
        label_iotimeout = gtk_label_new (_("second(s)"));
3134
        gtk_widget_show (label_iotimeout);
3135
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
3136

    
3137
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
3138
        gtk_widget_show (vbox2);
3139
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3140

    
3141
        advanced.checkbtn_strict_cache_check = checkbtn_strict_cache_check;
3142

    
3143
        advanced.spinbtn_iotimeout     = spinbtn_iotimeout;
3144
        advanced.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
3145

    
3146
        return vbox1;
3147
}
3148

    
3149
static void prefs_common_set_encoding_optmenu(GtkOptionMenu *optmenu,
3150
                                              gboolean outgoing)
3151
{
3152
        GtkWidget *menu;
3153
        GtkWidget *menuitem;
3154

    
3155
        menu = gtk_menu_new();
3156

    
3157
#define SET_MENUITEM(str, data) \
3158
        MENUITEM_ADD(menu, menuitem, str, data)
3159

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

    
3217
#undef SET_MENUITEM
3218

    
3219
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
3220
}
3221

    
3222
static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
3223
{
3224
        GtkWidget *datefmt_sample = NULL;
3225
        gchar *text;
3226

    
3227
        g_return_if_fail(widget != NULL);
3228
        g_return_if_fail(*widget != NULL);
3229
        g_return_if_fail(display.entry_datefmt != NULL);
3230

    
3231
        datefmt_sample = GTK_WIDGET(g_object_get_data
3232
                                    (G_OBJECT(*widget), "datefmt_sample"));
3233
        g_return_if_fail(datefmt_sample != NULL);
3234

    
3235
        text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
3236
        g_free(prefs_common.date_format);
3237
        prefs_common.date_format = text;
3238
        gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
3239

    
3240
        gtk_widget_destroy(*widget);
3241
        *widget = NULL;
3242
}
3243

    
3244
static void date_format_cancel_btn_clicked(GtkButton *button,
3245
                                           GtkWidget **widget)
3246
{
3247
        g_return_if_fail(widget != NULL);
3248
        g_return_if_fail(*widget != NULL);
3249

    
3250
        gtk_widget_destroy(*widget);
3251
        *widget = NULL;
3252
}
3253

    
3254
static gboolean date_format_key_pressed(GtkWidget *keywidget,
3255
                                        GdkEventKey *event,
3256
                                        GtkWidget **widget)
3257
{
3258
        if (event && event->keyval == GDK_Escape)
3259
                date_format_cancel_btn_clicked(NULL, widget);
3260
        return FALSE;
3261
}
3262

    
3263
static gboolean date_format_on_delete(GtkWidget *dialogwidget,
3264
                                      GdkEventAny *event, GtkWidget **widget)
3265
{
3266
        g_return_val_if_fail(widget != NULL, FALSE);
3267
        g_return_val_if_fail(*widget != NULL, FALSE);
3268

    
3269
        *widget = NULL;
3270
        return FALSE;
3271
}
3272

    
3273
static void date_format_entry_on_change(GtkEditable *editable,
3274
                                        GtkLabel *example)
3275
{
3276
        time_t cur_time;
3277
        struct tm *cal_time;
3278
        gchar buffer[100];
3279
        gchar *text;
3280

    
3281
        cur_time = time(NULL);
3282
        cal_time = localtime(&cur_time);
3283
        buffer[0] = 0;
3284
        text = gtk_editable_get_chars(editable, 0, -1);
3285
        if (text)
3286
                strftime(buffer, sizeof buffer, text, cal_time); 
3287
        g_free(text);
3288

    
3289
        text = conv_codeset_strdup(buffer, conv_get_locale_charset_str(),
3290
                                   CS_UTF_8);
3291
        if (!text)
3292
                text = g_strdup(buffer);
3293
        gtk_label_set_text(example, text);
3294
        g_free(text);
3295
}
3296

    
3297
static void date_format_select_row(GtkWidget *date_format_list, gint row,
3298
                                   gint column, GdkEventButton *event,
3299
                                   GtkWidget *date_format)
3300
{
3301
        gint cur_pos;
3302
        gchar *format;
3303
        const gchar *old_format;
3304
        gchar *new_format;
3305
        GtkWidget *datefmt_sample;
3306

    
3307
        /* only on double click */
3308
        if (!event || event->type != GDK_2BUTTON_PRESS) return;
3309

    
3310
        datefmt_sample = GTK_WIDGET(g_object_get_data
3311
                                    (G_OBJECT(date_format), "datefmt_sample"));
3312

    
3313
        g_return_if_fail(date_format_list != NULL);
3314
        g_return_if_fail(date_format != NULL);
3315
        g_return_if_fail(datefmt_sample != NULL);
3316

    
3317
        /* get format from clist */
3318
        gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
3319

    
3320
        cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
3321
        old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
3322

    
3323
        /* insert the format into the text entry */
3324
        new_format = g_malloc(strlen(old_format) + 3);
3325

    
3326
        strncpy(new_format, old_format, cur_pos);
3327
        new_format[cur_pos] = '\0';
3328
        strcat(new_format, format);
3329
        strcat(new_format, &old_format[cur_pos]);
3330

    
3331
        gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
3332
        gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
3333

    
3334
        g_free(new_format);
3335
}
3336

    
3337
static GtkWidget *date_format_create(GtkButton *button, void *data)
3338
{
3339
        static GtkWidget *datefmt_win = NULL;
3340
        GtkWidget *vbox1;
3341
        GtkWidget *scrolledwindow1;
3342
        GtkWidget *datefmt_clist;
3343
        GtkWidget *table;
3344
        GtkWidget *label1;
3345
        GtkWidget *label2;
3346
        GtkWidget *label3;
3347
        GtkWidget *confirm_area;
3348
        GtkWidget *ok_btn;
3349
        GtkWidget *cancel_btn;
3350
        GtkWidget *datefmt_entry;
3351

    
3352
        struct {
3353
                gchar *fmt;
3354
                gchar *txt;
3355
        } time_format[] = {
3356
                { "%a", NULL },
3357
                { "%A", NULL },
3358
                { "%b", NULL },
3359
                { "%B", NULL },
3360
                { "%c", NULL },
3361
                { "%C", NULL },
3362
                { "%d", NULL },
3363
                { "%H", NULL },
3364
                { "%I", NULL },
3365
                { "%j", NULL },
3366
                { "%m", NULL },
3367
                { "%M", NULL },
3368
                { "%p", NULL },
3369
                { "%S", NULL },
3370
                { "%w", NULL },
3371
                { "%x", NULL },
3372
                { "%y", NULL },
3373
                { "%Y", NULL },
3374
                { "%Z", NULL }
3375
        };
3376

    
3377
        gchar *titles[2];
3378
        gint i;
3379
        const gint TIME_FORMAT_ELEMS =
3380
                sizeof time_format / sizeof time_format[0];
3381

    
3382
        time_format[0].txt  = _("the full abbreviated weekday name");
3383
        time_format[1].txt  = _("the full weekday name");
3384
        time_format[2].txt  = _("the abbreviated month name");
3385
        time_format[3].txt  = _("the full month name");
3386
        time_format[4].txt  = _("the preferred date and time for the current locale");
3387
        time_format[5].txt  = _("the century number (year/100)");
3388
        time_format[6].txt  = _("the day of the month as a decimal number");
3389
        time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
3390
        time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
3391
        time_format[9].txt  = _("the day of the year as a decimal number");
3392
        time_format[10].txt = _("the month as a decimal number");
3393
        time_format[11].txt = _("the minute as a decimal number");
3394
        time_format[12].txt = _("either AM or PM");
3395
        time_format[13].txt = _("the second as a decimal number");
3396
        time_format[14].txt = _("the day of the week as a decimal number");
3397
        time_format[15].txt = _("the preferred date for the current locale");
3398
        time_format[16].txt = _("the last two digits of a year");
3399
        time_format[17].txt = _("the year as a decimal number");
3400
        time_format[18].txt = _("the time zone or name or abbreviation");
3401

    
3402
        if (datefmt_win) return datefmt_win;
3403

    
3404
        datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3405
        gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
3406
        gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
3407
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3408
        gtk_widget_set_size_request(datefmt_win, 440, 280);
3409

    
3410
        vbox1 = gtk_vbox_new(FALSE, 10);
3411
        gtk_widget_show(vbox1);
3412
        gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
3413

    
3414
        scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
3415
        gtk_scrolled_window_set_policy
3416
                (GTK_SCROLLED_WINDOW(scrolledwindow1),
3417
                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3418
        gtk_widget_show(scrolledwindow1);
3419
        gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
3420

    
3421
        titles[0] = _("Specifier");
3422
        titles[1] = _("Description");
3423
        datefmt_clist = gtk_clist_new_with_titles(2, titles);
3424
        gtk_widget_show(datefmt_clist);
3425
        gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
3426
        /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
3427
        gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
3428
                                     GTK_SELECTION_BROWSE);
3429

    
3430
        for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
3431
                gchar *text[2];
3432
                /* phoney casting necessary because of gtk... */
3433
                text[0] = (gchar *)time_format[i].fmt;
3434
                text[1] = (gchar *)time_format[i].txt;
3435
                gtk_clist_append(GTK_CLIST(datefmt_clist), text);
3436
        }
3437

    
3438
        table = gtk_table_new(2, 2, FALSE);
3439
        gtk_widget_show(table);
3440
        gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
3441
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
3442
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
3443

    
3444
        label1 = gtk_label_new(_("Date format"));
3445
        gtk_widget_show(label1);
3446
        gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
3447
                         GTK_FILL, 0, 0, 0);
3448
        gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
3449
        gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
3450

    
3451
        datefmt_entry = gtk_entry_new();
3452
        gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
3453
        gtk_widget_show(datefmt_entry);
3454
        gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
3455
                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3456

    
3457
        /* we need the "sample" entry box; add it as data so callbacks can
3458
         * get the entry box */
3459
        g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
3460
                          datefmt_entry);
3461

    
3462
        label2 = gtk_label_new(_("Example"));
3463
        gtk_widget_show(label2);
3464
        gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
3465
                         GTK_FILL, 0, 0, 0);
3466
        gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
3467
        gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
3468

    
3469
        label3 = gtk_label_new("");
3470
        gtk_widget_show(label3);
3471
        gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
3472
                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3473
        gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
3474
        gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
3475

    
3476
        gtkut_stock_button_set_create(&confirm_area, &ok_btn, GTK_STOCK_OK,
3477
                                &cancel_btn, GTK_STOCK_CANCEL, NULL, NULL);
3478

    
3479
        gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
3480
        gtk_widget_show(confirm_area);
3481
        gtk_widget_grab_default(ok_btn);
3482

    
3483
        /* set the current format */
3484
        gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
3485
        date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
3486
                                    GTK_LABEL(label3));
3487

    
3488
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3489
                         G_CALLBACK(date_format_ok_btn_clicked), &datefmt_win);
3490
        g_signal_connect(G_OBJECT(cancel_btn), "clicked",
3491
                         G_CALLBACK(date_format_cancel_btn_clicked),
3492
                         &datefmt_win);
3493
        g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
3494
                         G_CALLBACK(date_format_key_pressed), &datefmt_win);
3495
        g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
3496
                         G_CALLBACK(date_format_on_delete), &datefmt_win);
3497
        g_signal_connect(G_OBJECT(datefmt_entry), "changed",
3498
                         G_CALLBACK(date_format_entry_on_change), label3);
3499
        g_signal_connect(G_OBJECT(datefmt_clist), "select_row",
3500
                         G_CALLBACK(date_format_select_row), datefmt_win);
3501

    
3502
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3503
        gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
3504

    
3505
        gtk_widget_show(datefmt_win);
3506
        manage_window_set_transient(GTK_WINDOW(datefmt_win));
3507

    
3508
        gtk_widget_grab_focus(ok_btn);
3509

    
3510
        return datefmt_win;
3511
}
3512

    
3513
void prefs_quote_colors_dialog(void)
3514
{
3515
        if (!quote_color_win)
3516
                prefs_quote_colors_dialog_create();
3517
        gtk_widget_show(quote_color_win);
3518
        manage_window_set_transient(GTK_WINDOW(quote_color_win));
3519

    
3520
        gtk_main();
3521
        gtk_widget_hide(quote_color_win);
3522
        gtk_window_present(GTK_WINDOW(dialog.window));
3523

    
3524
        main_window_reflect_prefs_all();
3525
}
3526

    
3527
static void prefs_quote_colors_dialog_create(void)
3528
{
3529
        GtkWidget *window;
3530
        GtkWidget *vbox;
3531
        GtkWidget *table;
3532
        GtkWidget *quotelevel1_label;
3533
        GtkWidget *quotelevel2_label;
3534
        GtkWidget *quotelevel3_label;
3535
        GtkWidget *uri_label;
3536
        GtkWidget *hbbox;
3537
        GtkWidget *ok_btn;
3538
        GtkWidget *recycle_colors_btn;
3539
        GtkWidget *frame_colors;
3540

    
3541
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3542
        gtk_container_set_border_width(GTK_CONTAINER(window), 2);
3543
        gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
3544
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
3545
        gtk_window_set_modal(GTK_WINDOW(window), TRUE);
3546
        gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
3547

    
3548
        vbox = gtk_vbox_new (FALSE, VSPACING);
3549
        gtk_container_add (GTK_CONTAINER (window), vbox);
3550
        gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
3551
        PACK_FRAME(vbox, frame_colors, _("Colors"));
3552

    
3553
        table = gtk_table_new (4, 2, FALSE);
3554
        gtk_container_add (GTK_CONTAINER (frame_colors), table);
3555
        gtk_container_set_border_width (GTK_CONTAINER (table), 8);
3556
        gtk_table_set_row_spacings (GTK_TABLE (table), 2);
3557
        gtk_table_set_col_spacings (GTK_TABLE (table), 4);
3558

    
3559
        color_buttons.quote_level1_btn = gtk_button_new();
3560
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level1_btn,
3561
                          0, 1, 0, 1, 0, 0, 0, 0);
3562
        gtk_widget_set_size_request (color_buttons.quote_level1_btn, 40, 30);
3563
        gtk_container_set_border_width
3564
                (GTK_CONTAINER (color_buttons.quote_level1_btn), 5);
3565

    
3566
        color_buttons.quote_level2_btn = gtk_button_new();
3567
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level2_btn,
3568
                          0, 1, 1, 2, 0, 0, 0, 0);
3569
        gtk_widget_set_size_request (color_buttons.quote_level2_btn, 40, 30);
3570
        gtk_container_set_border_width (GTK_CONTAINER (color_buttons.quote_level2_btn), 5);
3571

    
3572
        color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
3573
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
3574
                          0, 1, 2, 3, 0, 0, 0, 0);
3575
        gtk_widget_set_size_request (color_buttons.quote_level3_btn, 40, 30);
3576
        gtk_container_set_border_width
3577
                (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
3578

    
3579
        color_buttons.uri_btn = gtk_button_new_with_label ("");
3580
        gtk_table_attach (GTK_TABLE (table), color_buttons.uri_btn,
3581
                          0, 1, 3, 4, 0, 0, 0, 0);
3582
        gtk_widget_set_size_request (color_buttons.uri_btn, 40, 30);
3583
        gtk_container_set_border_width (GTK_CONTAINER (color_buttons.uri_btn), 5);
3584

    
3585
        quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
3586
        gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
3587
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3588
        gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
3589
        gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
3590

    
3591
        quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
3592
        gtk_table_attach (GTK_TABLE (table), quotelevel2_label, 1, 2, 1, 2,
3593
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3594
        gtk_label_set_justify (GTK_LABEL (quotelevel2_label), GTK_JUSTIFY_LEFT);
3595
        gtk_misc_set_alignment (GTK_MISC (quotelevel2_label), 0, 0.5);
3596

    
3597
        quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
3598
        gtk_table_attach (GTK_TABLE (table), quotelevel3_label, 1, 2, 2, 3,
3599
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3600
        gtk_label_set_justify (GTK_LABEL (quotelevel3_label), GTK_JUSTIFY_LEFT);
3601
        gtk_misc_set_alignment (GTK_MISC (quotelevel3_label), 0, 0.5);
3602

    
3603
        uri_label = gtk_label_new (_("URI link"));
3604
        gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
3605
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3606
        gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
3607
        gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
3608

    
3609
        PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
3610
                           _("Recycle quote colors"));
3611

    
3612
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
3613
                                      NULL, NULL, NULL, NULL);
3614
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3615

    
3616
        gtk_widget_grab_default(ok_btn);
3617
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
3618
        g_signal_connect (G_OBJECT (window), "delete_event",
3619
                          G_CALLBACK (prefs_quote_colors_deleted), NULL);
3620
        g_signal_connect(G_OBJECT(window), "key_press_event",
3621
                         G_CALLBACK(prefs_quote_colors_key_pressed), NULL);
3622

    
3623
        g_signal_connect(G_OBJECT(color_buttons.quote_level1_btn), "clicked",
3624
                         G_CALLBACK(quote_color_set_dialog), "LEVEL1");
3625
        g_signal_connect(G_OBJECT(color_buttons.quote_level2_btn), "clicked",
3626
                         G_CALLBACK(quote_color_set_dialog), "LEVEL2");
3627
        g_signal_connect(G_OBJECT(color_buttons.quote_level3_btn), "clicked",
3628
                         G_CALLBACK(quote_color_set_dialog), "LEVEL3");
3629
        g_signal_connect(G_OBJECT(color_buttons.uri_btn), "clicked",
3630
                         G_CALLBACK(quote_color_set_dialog), "URI");
3631
        g_signal_connect(G_OBJECT(recycle_colors_btn), "toggled",
3632
                         G_CALLBACK(prefs_recycle_colors_toggled), NULL);
3633
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3634
                         G_CALLBACK(gtk_main_quit), NULL);
3635

    
3636
        /* show message button colors and recycle options */
3637
        set_button_bg_color(color_buttons.quote_level1_btn,
3638
                            prefs_common.quote_level1_col);
3639
        set_button_bg_color(color_buttons.quote_level2_btn,
3640
                            prefs_common.quote_level2_col);
3641
        set_button_bg_color(color_buttons.quote_level3_btn,
3642
                            prefs_common.quote_level3_col);
3643
        set_button_bg_color(color_buttons.uri_btn,
3644
                            prefs_common.uri_col);
3645
        gtk_toggle_button_set_active((GtkToggleButton *)recycle_colors_btn,
3646
                                     prefs_common.recycle_quote_colors);
3647

    
3648
        gtk_widget_show_all(vbox);
3649
        quote_color_win = window;
3650
}
3651

    
3652
static gint prefs_quote_colors_deleted(GtkWidget *widet, GdkEventAny *event,
3653
                                       gpointer data)
3654
{
3655
        gtk_main_quit();
3656
        return TRUE;
3657
}
3658

    
3659
static gboolean prefs_quote_colors_key_pressed(GtkWidget *widget,
3660
                                               GdkEventKey *event,
3661
                                               gpointer data)
3662
{
3663
        if (event && event->keyval == GDK_Escape)
3664
                gtk_main_quit();
3665
        return FALSE;
3666
}
3667

    
3668
static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
3669
{
3670
        gchar *type = (gchar *)data;
3671
        gchar *title = NULL;
3672
        gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
3673
        gint rgbvalue = 0;
3674
        GtkColorSelectionDialog *dialog;
3675

    
3676
        if(g_ascii_strcasecmp(type, "LEVEL1") == 0) {
3677
                title = _("Pick color for quotation level 1");
3678
                rgbvalue = prefs_common.quote_level1_col;
3679
        } else if(g_ascii_strcasecmp(type, "LEVEL2") == 0) {
3680
                title = _("Pick color for quotation level 2");
3681
                rgbvalue = prefs_common.quote_level2_col;
3682
        } else if(g_ascii_strcasecmp(type, "LEVEL3") == 0) {
3683
                title = _("Pick color for quotation level 3");
3684
                rgbvalue = prefs_common.quote_level3_col;
3685
        } else if(g_ascii_strcasecmp(type, "URI") == 0) {
3686
                title = _("Pick color for URI");
3687
                rgbvalue = prefs_common.uri_col;
3688
        } else {   /* Should never be called */
3689
                g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
3690
                return;
3691
        }
3692

    
3693
        color_dialog = gtk_color_selection_dialog_new(title);
3694
        gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
3695
        gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
3696
        gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
3697
        manage_window_set_transient(GTK_WINDOW(color_dialog));
3698

    
3699
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
3700
                         "clicked", G_CALLBACK(quote_colors_set_dialog_ok), data);
3701
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
3702
                         "clicked", G_CALLBACK(quote_colors_set_dialog_cancel), data);
3703
        g_signal_connect(G_OBJECT(color_dialog), "key_press_event",
3704
                         G_CALLBACK(quote_colors_set_dialog_key_pressed), data);
3705

    
3706
        /* preselect the previous color in the color selection dialog */
3707
        color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
3708
        color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
3709
        color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
3710
        dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
3711
        gtk_color_selection_set_color
3712
                (GTK_COLOR_SELECTION(dialog->colorsel), color);
3713

    
3714
        gtk_widget_show(color_dialog);
3715
}
3716

    
3717
static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
3718
{
3719
        GtkColorSelection *colorsel = (GtkColorSelection *)
3720
                                                ((GtkColorSelectionDialog *)color_dialog)->colorsel;
3721
        gdouble color[4];
3722
        gint red, green, blue, rgbvalue;
3723
        gchar *type = (gchar *)data;
3724

    
3725
        gtk_color_selection_get_color(colorsel, color);
3726

    
3727
        red      = (gint) (color[0] * 255.0);
3728
        green    = (gint) (color[1] * 255.0);
3729
        blue     = (gint) (color[2] * 255.0);
3730
        rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
3731

    
3732
#if 0
3733
        fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
3734
        fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
3735
        fprintf(stderr, "Color is %x\n", rgbvalue);
3736
#endif
3737

    
3738
        if (g_ascii_strcasecmp(type, "LEVEL1") == 0) {
3739
                prefs_common.quote_level1_col = rgbvalue;
3740
                set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
3741
        } else if (g_ascii_strcasecmp(type, "LEVEL2") == 0) {
3742
                prefs_common.quote_level2_col = rgbvalue;
3743
                set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
3744
        } else if (g_ascii_strcasecmp(type, "LEVEL3") == 0) {
3745
                prefs_common.quote_level3_col = rgbvalue;
3746
                set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
3747
        } else if (g_ascii_strcasecmp(type, "URI") == 0) {
3748
                prefs_common.uri_col = rgbvalue;
3749
                set_button_bg_color(color_buttons.uri_btn, rgbvalue);
3750
        } else
3751
                fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
3752

    
3753
        gtk_widget_destroy(color_dialog);
3754
}
3755

    
3756
static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
3757
{
3758
        gtk_widget_destroy(color_dialog);
3759
}
3760

    
3761
static gboolean quote_colors_set_dialog_key_pressed(GtkWidget *widget,
3762
                                                    GdkEventKey *event,
3763
                                                    gpointer data)
3764
{
3765
        if (event && event->keyval == GDK_Escape) {
3766
                gtk_widget_destroy(color_dialog);
3767
                return TRUE;
3768
        }
3769
        return FALSE;
3770
}
3771

    
3772
static void set_button_bg_color(GtkWidget *widget, gint rgbvalue)
3773
{
3774
        GtkStyle *newstyle;
3775
        GdkColor color;
3776

    
3777
        gtkut_convert_int_to_gdk_color(rgbvalue, &color);
3778
        newstyle = gtk_style_copy(gtk_widget_get_default_style());
3779
        newstyle->bg[GTK_STATE_NORMAL]   = color;
3780
        newstyle->bg[GTK_STATE_PRELIGHT] = color;
3781
        newstyle->bg[GTK_STATE_ACTIVE]   = color;
3782

    
3783
        gtk_widget_set_style(GTK_WIDGET(widget), newstyle);
3784
}
3785

    
3786
static void prefs_enable_message_color_toggled(void)
3787
{
3788
        gboolean is_active;
3789

    
3790
        is_active = gtk_toggle_button_get_active
3791
                (GTK_TOGGLE_BUTTON(message.chkbtn_enablecol));
3792
        gtk_widget_set_sensitive(message.button_edit_col, is_active);
3793
        prefs_common.enable_color = is_active;
3794
}
3795

    
3796
static void prefs_recycle_colors_toggled(GtkWidget *widget)
3797
{
3798
        gboolean is_active;
3799

    
3800
        is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3801
        prefs_common.recycle_quote_colors = is_active;
3802
}
3803

    
3804
void prefs_quote_description(void)
3805
{
3806
        if (!quote_desc_win)
3807
                prefs_quote_description_create();
3808

    
3809
        manage_window_set_transient(GTK_WINDOW(quote_desc_win));
3810
        gtk_widget_show(quote_desc_win);
3811
        gtk_main();
3812
        gtk_widget_hide(quote_desc_win);
3813
}
3814

    
3815
static void prefs_quote_description_create(void)
3816
{
3817
        GtkWidget *vbox;
3818
        GtkWidget *hbox;
3819
        GtkWidget *vbox2;
3820
        GtkWidget *label;
3821
        GtkWidget *hbbox;
3822
        GtkWidget *ok_btn;
3823

    
3824
        quote_desc_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3825
        gtk_window_set_title(GTK_WINDOW(quote_desc_win),
3826
                             _("Description of symbols"));
3827
        gtk_container_set_border_width(GTK_CONTAINER(quote_desc_win), 8);
3828
        gtk_window_set_position(GTK_WINDOW(quote_desc_win), GTK_WIN_POS_CENTER);
3829
        gtk_window_set_modal(GTK_WINDOW(quote_desc_win), TRUE);
3830
        gtk_window_set_policy(GTK_WINDOW(quote_desc_win), FALSE, FALSE, FALSE);
3831

    
3832
        vbox = gtk_vbox_new(FALSE, 8);
3833
        gtk_container_add(GTK_CONTAINER(quote_desc_win), vbox);
3834

    
3835
        hbox = gtk_hbox_new(FALSE, 8);
3836
        gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
3837

    
3838
        vbox2 = gtk_vbox_new(FALSE, 8);
3839
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
3840

    
3841
#define PACK_LABEL() \
3842
        gtk_box_pack_start(GTK_BOX(vbox2), label, TRUE, TRUE, 0); \
3843
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); \
3844
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
3845

    
3846
        label = gtk_label_new
3847
                ("%d\n"                /* date */
3848
                 "%f\n"                /* from */
3849
                 "%N\n"                /* full name of sender */
3850
                 "%F\n"                /* first name of sender */
3851
                 "%I\n"                /* initial of sender */
3852
                 "%s\n"                /* subject */
3853
                 "%t\n"                /* to */
3854
                 "%c\n"                /* cc */
3855
                 "%n\n"                /* newsgroups */
3856
                 "%i");                /* message id */
3857
        PACK_LABEL();
3858

    
3859
        label = gtk_label_new
3860
                ("?x{expr}");        /* condition */
3861
        PACK_LABEL();
3862

    
3863
        label = gtk_label_new
3864
                ("%M\n"                /* message body */
3865
                 "%Q\n"                /* quoted message body */
3866
                 "%m\n"                /* message body without signature */
3867
                 "%q\n"                /* quoted message body without signature */
3868
                 "%%");                /* literal percent */
3869
        PACK_LABEL();
3870

    
3871
        label = gtk_label_new
3872
                ("\\\\\n"        /* literal backslash */
3873
                 "\\?\n"        /* literal question mark */
3874
                 "\\{\n"        /* literal opening curly brace */
3875
                 "\\}");        /* literal closing curly brace */
3876
        PACK_LABEL();
3877

    
3878
        vbox2 = gtk_vbox_new(FALSE, 8);
3879
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
3880

    
3881
        label = gtk_label_new
3882
                (_("Date\n"
3883
                   "From\n"
3884
                   "Full Name of Sender\n"
3885
                   "First Name of Sender\n"
3886
                   "Initial of Sender\n"
3887
                   "Subject\n"
3888
                   "To\n"
3889
                   "Cc\n"
3890
                   "Newsgroups\n"
3891
                   "Message-ID"));
3892
        PACK_LABEL();
3893

    
3894
        label = gtk_label_new
3895
                (_("If x is set, displays expr"));
3896
        PACK_LABEL();
3897

    
3898
        label = gtk_label_new
3899
                (_("Message body\n"
3900
                   "Quoted message body\n"
3901
                   "Message body without signature\n"
3902
                   "Quoted message body without signature\n"
3903
                   "Literal %"));
3904
        PACK_LABEL();
3905

    
3906
        label = gtk_label_new
3907
                (_("Literal backslash\n"
3908
                   "Literal question mark\n"
3909
                   "Literal opening curly brace\n"
3910
                   "Literal closing curly brace"));
3911
        PACK_LABEL();
3912

    
3913
#undef PACK_LABEL
3914

    
3915
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
3916
                                      NULL, NULL, NULL, NULL);
3917
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3918

    
3919
        gtk_widget_grab_default(ok_btn);
3920
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3921
                         G_CALLBACK(gtk_main_quit), NULL);
3922
        g_signal_connect
3923
                (G_OBJECT(quote_desc_win), "key_press_event",
3924
                 G_CALLBACK(prefs_quote_description_key_pressed), NULL);
3925
        g_signal_connect(G_OBJECT(quote_desc_win), "delete_event",
3926
                         G_CALLBACK(prefs_quote_description_deleted), NULL);
3927

    
3928
        gtk_widget_show_all(vbox);
3929
}
3930

    
3931
static gboolean prefs_quote_description_key_pressed(GtkWidget *widget,
3932
                                                    GdkEventKey *event,
3933
                                                    gpointer data)
3934
{
3935
        if (event && event->keyval == GDK_Escape)
3936
                gtk_main_quit();
3937
        return FALSE;
3938
}
3939

    
3940
static gboolean prefs_quote_description_deleted(GtkWidget *widget,
3941
                                                GdkEventAny *event,
3942
                                                gpointer data)
3943
{
3944
        gtk_main_quit();
3945
        return TRUE;
3946
}
3947

    
3948
static void prefs_keybind_select(void)
3949
{
3950
        GtkWidget *window;
3951
        GtkWidget *vbox1;
3952
        GtkWidget *hbox1;
3953
        GtkWidget *label;
3954
        GtkWidget *combo;
3955
        GtkWidget *confirm_area;
3956
        GtkWidget *ok_btn;
3957
        GtkWidget *cancel_btn;
3958

    
3959
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3960
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
3961
        gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
3962
        gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
3963
        gtk_window_set_modal (GTK_WINDOW (window), TRUE);
3964
        gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, FALSE);
3965
        manage_window_set_transient (GTK_WINDOW (window));
3966

    
3967
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3968
        gtk_container_add (GTK_CONTAINER (window), vbox1);
3969
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
3970

    
3971
        hbox1 = gtk_hbox_new (FALSE, 8);
3972
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3973

    
3974
        label = gtk_label_new(_("Select the preset of key bindings."));
3975
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
3976
        gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3977

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

    
3981
        combo = gtk_combo_new ();
3982
        gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
3983
        gtkut_combo_set_items (GTK_COMBO (combo),
3984
                               _("Default"),
3985
                               "Mew / Wanderlust",
3986
                               "Mutt",
3987
                               _("Old Sylpheed"),
3988
                               NULL);
3989
        gtk_editable_set_editable
3990
                (GTK_EDITABLE (GTK_COMBO (combo)->entry), FALSE);
3991

    
3992
        hbox1 = gtk_hbox_new (FALSE, 8);
3993
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3994

    
3995
        gtkut_stock_button_set_create (&confirm_area, &ok_btn, GTK_STOCK_OK,
3996
                                       &cancel_btn, GTK_STOCK_CANCEL,
3997
                                       NULL, NULL);
3998
        gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
3999
        gtk_widget_grab_default (ok_btn);
4000

    
4001
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
4002
        g_signal_connect (G_OBJECT (window), "delete_event",
4003
                          G_CALLBACK (prefs_keybind_deleted), NULL);
4004
        g_signal_connect (G_OBJECT (window), "key_press_event",
4005
                          G_CALLBACK (prefs_keybind_key_pressed), NULL);
4006
        g_signal_connect (G_OBJECT (ok_btn), "clicked",
4007
                          G_CALLBACK (prefs_keybind_apply_clicked), NULL);
4008
        g_signal_connect (G_OBJECT (cancel_btn), "clicked",
4009
                          G_CALLBACK (prefs_keybind_cancel), NULL);
4010

    
4011
        gtk_widget_show_all(window);
4012

    
4013
        keybind.window = window;
4014
        keybind.combo = combo;
4015
}
4016

    
4017
static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
4018
                                          gpointer data)
4019
{
4020
        if (event && event->keyval == GDK_Escape)
4021
                prefs_keybind_cancel();
4022
        return FALSE;
4023
}
4024

    
4025
static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
4026
                                  gpointer data)
4027
{
4028
        prefs_keybind_cancel();
4029
        return TRUE;
4030
}
4031

    
4032
static void prefs_keybind_cancel(void)
4033
{
4034
        gtk_widget_destroy(keybind.window);
4035
        keybind.window = NULL;
4036
        keybind.combo = NULL;
4037
}
4038

    
4039
struct KeyBind {
4040
        const gchar *accel_path;
4041
        const gchar *accel_key;
4042
};
4043

    
4044
static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
4045
{
4046
        gint i;
4047
        guint key;
4048
        GdkModifierType mods;
4049

    
4050
        for (i = 0; i < num; i++) {
4051
                const gchar *accel_key =
4052
                        keybind[i].accel_key ? keybind[i].accel_key : "";
4053
                gtk_accelerator_parse(accel_key, &key, &mods);
4054
                gtk_accel_map_change_entry(keybind[i].accel_path,
4055
                                           key, mods, TRUE);
4056
        }
4057
}
4058

    
4059
static void prefs_keybind_apply_clicked(GtkWidget *widget)
4060
{
4061
        GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
4062
        const gchar *text;
4063
        struct KeyBind *menurc;
4064
        gint n_menurc;
4065

    
4066
        static struct KeyBind default_menurc[] = {
4067
                {"<Main>/File/Empty all trash",                        ""},
4068
                {"<Main>/File/Save as...",                        "<control>S"},
4069
                {"<Main>/File/Print...",                        ""},
4070
                {"<Main>/File/Exit",                                "<control>Q"},
4071

    
4072
                {"<Main>/Edit/Copy",                                "<control>C"},
4073
                {"<Main>/Edit/Select all",                        "<control>A"},
4074
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4075
                {"<Main>/Edit/Search messages...",                "<shift><control>F"},
4076

    
4077
                {"<Main>/View/Show or hide/Message view",        "V"},
4078
                {"<Main>/View/Thread view",                        "<control>T"},
4079
                {"<Main>/View/Go to/Prev message",                "P"},
4080
                {"<Main>/View/Go to/Next message",                "N"},
4081
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
4082
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
4083
                {"<Main>/View/Go to/Other folder...",                "G"},
4084
                {"<Main>/View/Open in new window",                "<control><alt>N"},
4085
                {"<Main>/View/View source",                        "<control>U"},
4086
                {"<Main>/View/Show all headers",                "<control>H"},
4087
                {"<Main>/View/Update",                                "<control><alt>U"},
4088

    
4089
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
4090
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
4091
                {"<Main>/Message/Compose new message",                "<control>M"},
4092
                {"<Main>/Message/Reply",                        "<control>R"},
4093
                {"<Main>/Message/Reply to/all",                        "<shift><control>R"},
4094
                {"<Main>/Message/Reply to/sender",                ""},
4095
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
4096
                {"<Main>/Message/Forward",                        "<control><alt>F"},
4097
                {"<Main>/Message/Forward as attachment",        ""},
4098
                {"<Main>/Message/Move...",                        "<control>O"},
4099
                {"<Main>/Message/Copy...",                        "<shift><control>O"},
4100
                {"<Main>/Message/Delete",                        "<control>D"},
4101
                {"<Main>/Message/Mark/Set flag",                "<shift>asterisk"},
4102
                {"<Main>/Message/Mark/Unset flag",                "U"},
4103
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
4104
                {"<Main>/Message/Mark/Mark as read",                ""},
4105

    
4106
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
4107
                {"<Main>/Tools/Execute",                        "X"},
4108
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
4109

    
4110
                {"<Compose>/File/Close",                        "<control>W"},
4111
                {"<Compose>/Edit/Select all",                        "<control>A"},
4112
        };
4113

    
4114
        static struct KeyBind mew_wl_menurc[] = {
4115
                {"<Main>/File/Empty all trash",                        "<shift>D"},
4116
                {"<Main>/File/Save as...",                        "Y"},
4117
                {"<Main>/File/Print...",                        "<shift>numbersign"},
4118
                {"<Main>/File/Exit",                                "<shift>Q"},
4119

    
4120
                {"<Main>/Edit/Copy",                                "<control>C"},
4121
                {"<Main>/Edit/Select all",                        "<control>A"},
4122
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4123
                {"<Main>/Edit/Search messages...",                "<control>S"},
4124

    
4125
                {"<Main>/View/Show or hide/Message view",        "V"},
4126
                {"<Main>/View/Thread view",                        "<shift>T"},
4127
                {"<Main>/View/Go to/Prev message",                "P"},
4128
                {"<Main>/View/Go to/Next message",                "N"},
4129
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
4130
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
4131
                {"<Main>/View/Go to/Other folder...",                "G"},
4132
                {"<Main>/View/Open in new window",                "<control><alt>N"},
4133
                {"<Main>/View/View source",                        "<control>U"},
4134
                {"<Main>/View/Show all headers",                "<shift>H"},
4135
                {"<Main>/View/Update",                                "<shift>S"},
4136

    
4137
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
4138
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
4139
                {"<Main>/Message/Compose new message",                "W"},
4140
                {"<Main>/Message/Reply",                        "<control>R"},
4141
                {"<Main>/Message/Reply to/all",                        "<shift>A"},
4142
                {"<Main>/Message/Reply to/sender",                ""},
4143
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
4144
                {"<Main>/Message/Forward",                        "F"},
4145
                {"<Main>/Message/Forward as attachment",        "<shift>F"},
4146
                {"<Main>/Message/Move...",                        "O"},
4147
                {"<Main>/Message/Copy...",                        "<shift>O"},
4148
                {"<Main>/Message/Delete",                        "D"},
4149
                {"<Main>/Message/Mark/Set flag",                "<shift>asterisk"},
4150
                {"<Main>/Message/Mark/Unset flag",                "U"},
4151
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
4152
                {"<Main>/Message/Mark/Mark as read",                "<shift>R"},
4153

    
4154
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
4155
                {"<Main>/Tools/Execute",                        "X"},
4156
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
4157

    
4158
                {"<Compose>/File/Close",                        "<alt>W"},
4159
                {"<Compose>/Edit/Select all",                        ""},
4160
        };
4161

    
4162
        static struct KeyBind mutt_menurc[] = {
4163
                {"<Main>/File/Empty all trash",                        ""},
4164
                {"<Main>/File/Save as...",                        "S"},
4165
                {"<Main>/File/Print...",                        "P"},
4166
                {"<Main>/File/Exit",                                "Q"},
4167

    
4168
                {"<Main>/Edit/Copy",                                "<control>C"},
4169
                {"<Main>/Edit/Select all",                        "<control>A"},
4170
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4171
                {"<Main>/Edit/Search messages...",                "slash"},
4172

    
4173
                {"<Main>/View/Show or hide/Message view",        "V"},
4174
                {"<Main>/View/Thread view",                        "<control>T"},
4175
                {"<Main>/View/Go to/Prev message",                ""},
4176
                {"<Main>/View/Go to/Next message",                ""},
4177
                {"<Main>/View/Go to/Prev unread message",        ""},
4178
                {"<Main>/View/Go to/Next unread message",        ""},
4179
                {"<Main>/View/Go to/Other folder...",                "C"},
4180
                {"<Main>/View/Open in new window",                "<control><alt>N"},
4181
                {"<Main>/View/View source",                        "<control>U"},
4182
                {"<Main>/View/Show all headers",                "<control>H"},
4183
                {"<Main>/View/Update",                                "<control><alt>U"},
4184

    
4185
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
4186
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
4187
                {"<Main>/Message/Compose new message",                "M"},
4188
                {"<Main>/Message/Reply",                        "R"},
4189
                {"<Main>/Message/Reply to/all",                        "G"},
4190
                {"<Main>/Message/Reply to/sender",                ""},
4191
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
4192
                {"<Main>/Message/Forward",                        "F"},
4193
                {"<Main>/Message/Forward as attachment",        ""},
4194
                {"<Main>/Message/Move...",                        "<control>O"},
4195
                {"<Main>/Message/Copy...",                        "<shift>C"},
4196
                {"<Main>/Message/Delete",                        "D"},
4197
                {"<Main>/Message/Mark/Set flag",                "<shift>F"},
4198
                {"<Main>/Message/Mark/Unset flag",                "U"},
4199
                {"<Main>/Message/Mark/Mark as unread",                "<shift>N"},
4200
                {"<Main>/Message/Mark/Mark as read",                ""},
4201

    
4202
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
4203
                {"<Main>/Tools/Execute",                        "X"},
4204
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
4205

    
4206
                {"<Compose>/File/Close",                        "<alt>W"},
4207
                {"<Compose>/Edit/Select all",                        ""},
4208
        };
4209

    
4210
        static struct KeyBind old_sylpheed_menurc[] = {
4211
                {"<Main>/File/Empty all trash",                        ""},
4212
                {"<Main>/File/Save as...",                        ""},
4213
                {"<Main>/File/Print...",                        "<alt>P"},
4214
                {"<Main>/File/Exit",                                "<alt>Q"},
4215

    
4216
                {"<Main>/Edit/Copy",                                "<control>C"},
4217
                {"<Main>/Edit/Select all",                        "<control>A"},
4218
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4219
                {"<Main>/Edit/Search messages...",                "<control>S"},
4220

    
4221
                {"<Main>/View/Show or hide/Message view",        "V"},
4222
                {"<Main>/View/Thread view",                        "<control>T"},
4223
                {"<Main>/View/Go to/Prev message",                "P"},
4224
                {"<Main>/View/Go to/Next message",                "N"},
4225
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
4226
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
4227
                {"<Main>/View/Go to/Other folder...",                "<alt>G"},
4228
                {"<Main>/View/Open in new window",                "<shift><control>N"},
4229
                {"<Main>/View/View source",                        "<control>U"},
4230
                {"<Main>/View/Show all headers",                "<control>H"},
4231
                {"<Main>/View/Update",                                "<alt>U"},
4232

    
4233
                {"<Main>/Message/Receive/Get new mail",                        "<alt>I"},
4234
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><alt>I"},
4235
                {"<Main>/Message/Compose new message",                "<alt>N"},
4236
                {"<Main>/Message/Reply",                        "<alt>R"},
4237
                {"<Main>/Message/Reply to/all",                        "<shift><alt>R"},
4238
                {"<Main>/Message/Reply to/sender",                "<control><alt>R"},
4239
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
4240
                {"<Main>/Message/Forward",                        "<shift><alt>F"},
4241
                {"<Main>/Message/Forward as attachment",        "<shift><control>F"},
4242
                {"<Main>/Message/Move...",                        "<alt>O"},
4243
                {"<Main>/Message/Copy...",                        ""},
4244
                {"<Main>/Message/Delete",                        "<alt>D"},
4245
                {"<Main>/Message/Mark/Set flag",                "<shift>asterisk"},
4246
                {"<Main>/Message/Mark/Unset flag",                "U"},
4247
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
4248
                {"<Main>/Message/Mark/Mark as read",                ""},
4249

    
4250
                {"<Main>/Tools/Address book",                        "<alt>A"},
4251
                {"<Main>/Tools/Execute",                        "<alt>X"},
4252
                {"<Main>/Tools/Log window",                        "<alt>L"},
4253

    
4254
                {"<Compose>/File/Close",                        "<alt>W"},
4255
                {"<Compose>/Edit/Select all",                        ""},
4256
        };
4257

    
4258
        static struct KeyBind empty_menurc[] = {
4259
                {"<Main>/File/Empty all trash",                        ""},
4260
                {"<Main>/File/Save as...",                        ""},
4261
                {"<Main>/File/Print...",                        ""},
4262
                {"<Main>/File/Exit",                                ""},
4263

    
4264
                {"<Main>/Edit/Copy",                                ""},
4265
                {"<Main>/Edit/Select all",                        ""},
4266
                {"<Main>/Edit/Find in current message...",        ""},
4267
                {"<Main>/Edit/Search messages...",                ""},
4268

    
4269
                {"<Main>/View/Show or hide/Message view",        ""},
4270
                {"<Main>/View/Thread view",                        ""},
4271
                {"<Main>/View/Go to/Prev message",                ""},
4272
                {"<Main>/View/Go to/Next message",                ""},
4273
                {"<Main>/View/Go to/Prev unread message",        ""},
4274
                {"<Main>/View/Go to/Next unread message",        ""},
4275
                {"<Main>/View/Go to/Other folder...",                ""},
4276
                {"<Main>/View/Open in new window",                ""},
4277
                {"<Main>/View/View source",                        ""},
4278
                {"<Main>/View/Show all headers",                ""},
4279
                {"<Main>/View/Update",                                ""},
4280

    
4281
                {"<Main>/Message/Receive/Get new mail",                        ""},
4282
                {"<Main>/Message/Receive/Get from all accounts",        ""},
4283
                {"<Main>/Message/Compose new message",                ""},
4284
                {"<Main>/Message/Reply",                        ""},
4285
                {"<Main>/Message/Reply to/all",                        ""},
4286
                {"<Main>/Message/Reply to/sender",                ""},
4287
                {"<Main>/Message/Reply to/mailing list",        ""},
4288
                {"<Main>/Message/Forward",                        ""},
4289
                {"<Main>/Message/Forward as attachment",        ""},
4290
                {"<Main>/Message/Move...",                        ""},
4291
                {"<Main>/Message/Copy...",                        ""},
4292
                {"<Main>/Message/Delete",                        ""},
4293
                {"<Main>/Message/Mark/Set flag",                ""},
4294
                {"<Main>/Message/Mark/Unset flag",                ""},
4295
                {"<Main>/Message/Mark/Mark as unread",                ""},
4296
                {"<Main>/Message/Mark/Mark as read",                ""},
4297

    
4298
                {"<Main>/Tools/Address book",                        ""},
4299
                {"<Main>/Tools/Execute",                        ""},
4300
                {"<Main>/Tools/Log window",                        ""},
4301

    
4302
                {"<Compose>/File/Close",                        ""},
4303
                {"<Compose>/Edit/Select all",                        ""},
4304
        };
4305

    
4306
        text = gtk_entry_get_text(entry);
4307

    
4308
        if (!strcmp(text, _("Default"))) {
4309
                menurc = default_menurc;
4310
                n_menurc = G_N_ELEMENTS(default_menurc);
4311
        } else if (!strcmp(text, "Mew / Wanderlust")) {
4312
                menurc = mew_wl_menurc;
4313
                n_menurc = G_N_ELEMENTS(mew_wl_menurc);
4314
        } else if (!strcmp(text, "Mutt")) {
4315
                menurc = mutt_menurc;
4316
                n_menurc = G_N_ELEMENTS(mutt_menurc);
4317
        } else if (!strcmp(text, _("Old Sylpheed"))) {
4318
                menurc = old_sylpheed_menurc;
4319
                n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
4320
        } else
4321
                return;
4322

    
4323
        prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc));
4324
        prefs_keybind_apply(menurc, n_menurc);
4325

    
4326
        gtk_widget_destroy(keybind.window);
4327
        keybind.window = NULL;
4328
        keybind.combo = NULL;
4329
}
4330

    
4331
static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
4332
{
4333
        PrefsUIData *ui_data;
4334
        GtkWidget *menu;
4335
        GtkWidget *menuitem;
4336
        gchar *charset;
4337

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

    
4342
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*ui_data->widget));
4343
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
4344
        charset = g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
4345
        g_free(*((gchar **)pparam->data));
4346
        *((gchar **)pparam->data) = g_strdup(charset);
4347
}
4348

    
4349
static void prefs_common_charset_set_optmenu(PrefParam *pparam)
4350
{
4351
        PrefsUIData *ui_data;
4352
        GtkOptionMenu *optmenu;
4353
        gint index;
4354

    
4355
        ui_data = (PrefsUIData *)pparam->ui_data;
4356
        g_return_if_fail(ui_data != NULL);
4357
        g_return_if_fail(*ui_data->widget != NULL);
4358

    
4359
        optmenu = GTK_OPTION_MENU(*ui_data->widget);
4360
        g_return_if_fail(optmenu != NULL);
4361

    
4362
        index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
4363
                                            (GCompareFunc)strcmp2);
4364
        if (index >= 0)
4365
                gtk_option_menu_set_history(optmenu, index);
4366
        else {
4367
                gtk_option_menu_set_history(optmenu, 0);
4368
                prefs_common_charset_set_data_from_optmenu(pparam);
4369
        }
4370
}
4371

    
4372
static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
4373
{
4374
        PrefsUIData *ui_data;
4375
        RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
4376
        GtkOptionMenu *optmenu;
4377
        GtkWidget *menu;
4378
        GtkWidget *menuitem;
4379
        gint index;
4380

    
4381
        ui_data = (PrefsUIData *)pparam->ui_data;
4382
        g_return_if_fail(ui_data != NULL);
4383
        g_return_if_fail(*ui_data->widget != NULL);
4384

    
4385
        optmenu = GTK_OPTION_MENU(*ui_data->widget);
4386
        g_return_if_fail(optmenu != NULL);
4387

    
4388
        index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(mode),
4389
                                            NULL);
4390
        if (index >= 0)
4391
                gtk_option_menu_set_history(optmenu, index);
4392
        else {
4393
                gtk_option_menu_set_history(optmenu, 0);
4394
                prefs_set_data_from_optmenu(pparam);
4395
        }
4396

    
4397
        menu = gtk_option_menu_get_menu(optmenu);
4398
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
4399
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
4400
}
4401

    
4402
static void prefs_common_uri_set_data_from_entry(PrefParam *pparam)
4403
{
4404
        PrefsUIData *ui_data;
4405
        gchar **str;
4406
        const gchar *entry_str;
4407

    
4408
        ui_data = (PrefsUIData *)pparam->ui_data;
4409
        g_return_if_fail(ui_data != NULL);
4410
        g_return_if_fail(*ui_data->widget != NULL);
4411

    
4412
        entry_str = gtk_entry_get_text(GTK_ENTRY(*ui_data->widget));
4413

    
4414
        if (pparam->type == P_STRING) {
4415
                str = (gchar **)pparam->data;
4416
                g_free(*str);
4417

    
4418
                if (entry_str[0] == '\0' ||
4419
                    !strcmp(_("(Default browser)"), entry_str))
4420
                        *str = NULL;
4421
                else
4422
                        *str = g_strdup(entry_str);
4423
        } else {
4424
                g_warning("Invalid type for URI setting\n");
4425
        }
4426
}
4427

    
4428
static void prefs_common_uri_set_entry(PrefParam *pparam)
4429
{
4430
        PrefsUIData *ui_data;
4431
        gchar **str;
4432

    
4433
        ui_data = (PrefsUIData *)pparam->ui_data;
4434
        g_return_if_fail(ui_data != NULL);
4435
        g_return_if_fail(*ui_data->widget != NULL);
4436

    
4437
        if (pparam->type == P_STRING) {
4438
                str = (gchar **)pparam->data;
4439
                gtk_entry_set_text(GTK_ENTRY(*ui_data->widget),
4440
                                   *str ? *str : _("(Default browser)"));
4441
        } else {
4442
                g_warning("Invalid type for URI setting\n");
4443
        }
4444
}
4445

    
4446
static void prefs_common_addr_compl_set_data_from_radiobtn(PrefParam *pparam)
4447
{
4448
        PrefsUIData *ui_data;
4449
        GtkRadioButton *radiobtn;
4450
        GSList *group;
4451

    
4452
        ui_data = (PrefsUIData *)pparam->ui_data;
4453
        g_return_if_fail(ui_data != NULL);
4454
        g_return_if_fail(*ui_data->widget != NULL);
4455

    
4456
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4457
        group = gtk_radio_button_get_group(radiobtn);
4458
        while (group != NULL) {
4459
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4460
                gint mode;
4461

    
4462
                if (gtk_toggle_button_get_active(btn)) {
4463
                        mode = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
4464
                                                                 MENU_VAL_ID));
4465
                        if (mode == 2) {
4466
                                prefs_common.enable_address_completion = FALSE;
4467
                                prefs_common.fullauto_completion_mode = FALSE;
4468
                        } else {
4469
                                prefs_common.enable_address_completion = TRUE;
4470
                                if (mode == 0)
4471
                                        prefs_common.fullauto_completion_mode = TRUE;
4472
                                else
4473
                                        prefs_common.fullauto_completion_mode = FALSE;
4474
                        }
4475
                        break;
4476
                }
4477
                group = group->next;
4478
        }
4479
}
4480

    
4481
static void prefs_common_addr_compl_set_radiobtn(PrefParam *pparam)
4482
{
4483
        PrefsUIData *ui_data;
4484
        GtkRadioButton *radiobtn;
4485
        GSList *group;
4486
        gint mode;
4487

    
4488
        if (prefs_common.enable_address_completion) {
4489
                if (prefs_common.fullauto_completion_mode)
4490
                        mode = 0;
4491
                else
4492
                        mode = 1;
4493
        } else
4494
                mode = 2;
4495

    
4496
        ui_data = (PrefsUIData *)pparam->ui_data;
4497
        g_return_if_fail(ui_data != NULL);
4498
        g_return_if_fail(*ui_data->widget != NULL);
4499

    
4500
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4501
        group = gtk_radio_button_get_group(radiobtn);
4502
        while (group != NULL) {
4503
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4504
                gint data;
4505

    
4506
                data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
4507
                                                         MENU_VAL_ID));
4508
                if (data == mode) {
4509
                        gtk_toggle_button_set_active(btn, TRUE);
4510
                        break;
4511
                }
4512
                group = group->next;
4513
        }
4514
}
4515

    
4516
static void prefs_common_attach_toolbtn_pos_set_data_from_radiobtn(PrefParam *pparam)
4517
{
4518
        PrefsUIData *ui_data;
4519
        GtkRadioButton *radiobtn;
4520
        GSList *group;
4521

    
4522
        ui_data = (PrefsUIData *)pparam->ui_data;
4523
        g_return_if_fail(ui_data != NULL);
4524
        g_return_if_fail(*ui_data->widget != NULL);
4525

    
4526
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4527
        group = gtk_radio_button_get_group(radiobtn);
4528
        while (group != NULL) {
4529
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4530

    
4531
                if (gtk_toggle_button_get_active(btn)) {
4532
                        prefs_common.attach_toolbutton_pos =
4533
                                GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn), MENU_VAL_ID));
4534
                        break;
4535
                }
4536
                group = group->next;
4537
        }
4538
}
4539

    
4540
static void prefs_common_attach_toolbtn_pos_set_radiobtn(PrefParam *pparam)
4541
{
4542
        PrefsUIData *ui_data;
4543
        GtkRadioButton *radiobtn;
4544
        GSList *group;
4545

    
4546
        ui_data = (PrefsUIData *)pparam->ui_data;
4547
        g_return_if_fail(ui_data != NULL);
4548
        g_return_if_fail(*ui_data->widget != NULL);
4549

    
4550
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4551
        group = gtk_radio_button_get_group(radiobtn);
4552
        while (group != NULL) {
4553
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4554
                gint data;
4555

    
4556
                data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
4557
                                                         MENU_VAL_ID));
4558
                if (data == prefs_common.attach_toolbutton_pos) {
4559
                        gtk_toggle_button_set_active(btn, TRUE);
4560
                        break;
4561
                }
4562
                group = group->