Statistics
| Revision:

root / src / prefs_common_dialog.c @ 3222

History | View | Annotate | Download (149 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2013 Hiroyuki Yamamoto
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 */
19

    
20
#ifdef HAVE_CONFIG_H
21
#  include "config.h"
22
#endif
23

    
24
#include "defs.h"
25

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

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

    
62
static PrefsDialog dialog;
63

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

    
69
        GtkWidget *checkbtn_chkonstartup;
70
        GtkWidget *checkbtn_scan_after_inc;
71

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

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

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

    
93
        GtkWidget *optmenu_encoding_method;
94
        GtkWidget *optmenu_mime_fencoding_method;
95

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

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

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

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

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

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

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

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

    
140
static struct Display {
141
        GtkWidget *fontbtn_textfont;
142

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
254
        GtkWidget *checkbtn_printcmd;
255
        GtkWidget *printcmd_entry;
256

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

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

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

    
274
static struct Advanced {
275
        GtkWidget *checkbtn_strict_cache_check;
276

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
588
        {"add_address_by_click", &other.checkbtn_addaddrbyclick,
589
         prefs_set_data_from_toggle, prefs_set_toggle},
590
        {"always_add_address_only", &other.checkbtn_add_address_only,
591
         prefs_set_data_from_toggle, prefs_set_toggle},
592
        {"enable_address_completion", &other.radiobtn_addr_compl,
593
         prefs_common_addr_compl_set_data_from_radiobtn,
594
         prefs_common_addr_compl_set_radiobtn},
595

    
596
        {"confirm_on_exit", &other.checkbtn_confonexit,
597
         prefs_set_data_from_toggle, prefs_set_toggle},
598
        {"clean_trash_on_exit", &other.checkbtn_cleanonexit,
599
         prefs_set_data_from_toggle, prefs_set_toggle},
600
        {"ask_on_cleaning", &other.checkbtn_askonclean,
601
         prefs_set_data_from_toggle, prefs_set_toggle},
602
        {"warn_queued_on_exit", &other.checkbtn_warnqueued,
603
         prefs_set_data_from_toggle, prefs_set_toggle},
604

    
605
        /* {"logwindow_line_limit", NULL, NULL, NULL}, */
606

    
607
        /* External commands */
608
        {"uri_open_command", &extcmd.uri_entry,
609
         prefs_common_uri_set_data_from_entry, prefs_common_uri_set_entry},
610
        {"ext_editor_command", &extcmd.exteditor_entry,
611
         prefs_set_data_from_entry, prefs_set_entry},
612

    
613
        {"use_print_command", &extcmd.checkbtn_printcmd,
614
         prefs_set_data_from_toggle, prefs_set_toggle},
615
        {"print_command", &extcmd.printcmd_entry,
616
         prefs_set_data_from_entry, prefs_set_entry},
617

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

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

    
639
        /* Advanced */
640
        {"strict_cache_check", &advanced.checkbtn_strict_cache_check,
641
         prefs_set_data_from_toggle, prefs_set_toggle},
642
        {"io_timeout_secs", &advanced.spinbtn_iotimeout,
643
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
644

    
645
        {NULL, NULL, NULL, NULL}
646
};
647

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

    
661
static GtkWidget *prefs_colorlabel_create        (void);
662
static void prefs_common_colorlabel_set_dialog        (void);
663
static void prefs_common_colorlabel_update        (void);
664

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

    
677
static void prefs_common_set_encoding_optmenu        (GtkOptionMenu        *optmenu,
678
                                                 gboolean         outgoing);
679

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

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

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

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

    
742
static void prefs_common_dispitem_clicked        (void);
743

    
744
static void prefs_common_select_folder_cb        (GtkWidget        *widget,
745
                                                 gpointer         data);
746

    
747
#ifdef G_OS_WIN32
748
static void prefs_common_file_selection_cb        (GtkButton        *button,
749
                                                 gpointer         data);
750
#endif
751

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

    
762

    
763
void prefs_common_open(void)
764
{
765
        static gboolean ui_registered = FALSE;
766

    
767
        inc_lock();
768

    
769
        if (!ui_registered) {
770
                prefs_register_ui(prefs_common_get_params(), ui_data);
771
                ui_registered = TRUE;
772
        }
773

    
774
        if (!dialog.window) {
775
                prefs_common_create();
776
        }
777

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

    
784
        prefs_set_dialog(prefs_common_get_params());
785
        prefs_common_colorlabel_set_dialog();
786

    
787
        gtk_widget_show(dialog.window);
788

    
789
        syl_plugin_signal_emit("prefs-common-open", dialog.window);
790
}
791

    
792
static void prefs_common_create(void)
793
{
794
        gint page = 0;
795

    
796
        debug_print(_("Creating common preferences window...\n"));
797

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

    
807
        g_signal_connect (G_OBJECT(dialog.ok_btn), "clicked",
808
                          G_CALLBACK(prefs_common_ok), NULL);
809
        g_signal_connect (G_OBJECT(dialog.apply_btn), "clicked",
810
                          G_CALLBACK(prefs_common_apply), NULL);
811
        g_signal_connect (G_OBJECT(dialog.cancel_btn), "clicked",
812
                          G_CALLBACK(prefs_common_cancel), NULL);
813

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

    
832
        gtk_widget_show_all(dialog.window);
833
}
834

    
835
static void prefs_receive_create(void)
836
{
837
        GtkWidget *vbox1;
838
        GtkWidget *vbox2;
839
        GtkWidget *vbox3;
840
        GtkWidget *vbox4;
841
        GtkWidget *hbox;
842

    
843
        GtkWidget *hbox_autochk;
844
        GtkWidget *checkbtn_autochk;
845
        GtkWidget *label_autochk1;
846
        GtkObject *spinbtn_autochk_adj;
847
        GtkWidget *spinbtn_autochk;
848
        GtkWidget *label_autochk2;
849
        GtkWidget *checkbtn_chkonstartup;
850
        GtkWidget *checkbtn_scan_after_inc;
851

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

    
865
#ifndef G_OS_WIN32
866
        GtkWidget *frame_spool;
867
        GtkWidget *checkbtn_local;
868
        GtkWidget *checkbtn_filter_on_inc;
869
        GtkWidget *label_spool;
870
        GtkWidget *entry_spool;
871
#endif
872

    
873
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
874
        gtk_widget_show (vbox1);
875
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
876
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
877

    
878
        vbox2 = gtk_vbox_new (FALSE, 0);
879
        gtk_widget_show (vbox2);
880
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
881

    
882
        /* Auto-checking */
883
        hbox_autochk = gtk_hbox_new (FALSE, 8);
884
        gtk_widget_show (hbox_autochk);
885
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
886

    
887
        PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
888
                           _("Auto-check new mail"));
889

    
890
        label_autochk1 = gtk_label_new (_("every"));
891
        gtk_widget_show (label_autochk1);
892
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
893

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

    
902
        label_autochk2 = gtk_label_new (_("minute(s)"));
903
        gtk_widget_show (label_autochk2);
904
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
905

    
906
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
907
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
908
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
909

    
910
        PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
911
                           _("Check new mail on startup"));
912
        PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
913
                           _("Update all local folders after incorporation"));
914

    
915
        /* New message notify */
916
        PACK_FRAME(vbox1, frame_notify, _("New message notification"));
917

    
918
        vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
919
        gtk_widget_show (vbox3);
920
        gtk_container_add (GTK_CONTAINER (frame_notify), vbox3);
921
        gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
922

    
923
        vbox4 = gtk_vbox_new (FALSE, 0);
924
        gtk_widget_show (vbox4);
925
        gtk_box_pack_start (GTK_BOX (vbox3), vbox4, FALSE, FALSE, 0);
926

    
927
        PACK_CHECK_BUTTON
928
                (vbox4, checkbtn_newmsg_notify_window,
929
                 _("Show notification window when new messages arrive"));
930

    
931
#ifdef G_OS_WIN32
932
        PACK_CHECK_BUTTON
933
                (vbox4, checkbtn_newmsg_sound,
934
                 _("Play sound when new messages arrive"));
935

    
936
        hbox = gtk_hbox_new (FALSE, 8);
937
        gtk_widget_show (hbox);
938
        gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
939

    
940
        label_newmsg_sound = gtk_label_new (_("Sound file"));
941
        gtk_widget_show (label_newmsg_sound);
942
        gtk_box_pack_start (GTK_BOX (hbox), label_newmsg_sound,
943
                            FALSE, FALSE, 0);
944

    
945
        entry_newmsg_sound = gtk_entry_new ();
946
        gtk_widget_show (entry_newmsg_sound);
947
        gtk_box_pack_start (GTK_BOX (hbox), entry_newmsg_sound, TRUE, TRUE, 0);
948

    
949
        btn_filesel = gtk_button_new_with_label("...");
950
        gtk_box_pack_start (GTK_BOX (hbox), btn_filesel, FALSE, FALSE, 0);
951
        g_signal_connect(G_OBJECT(btn_filesel), "clicked",
952
                         G_CALLBACK(prefs_common_file_selection_cb),
953
                         entry_newmsg_sound);
954

    
955
        SET_TOGGLE_SENSITIVITY (checkbtn_newmsg_sound, hbox);
956

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

    
966
        hbox = gtk_hbox_new (FALSE, 8);
967
        gtk_widget_show (hbox);
968
        gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
969

    
970
        label_newmsg_notify = gtk_label_new (_("Command"));
971
        gtk_widget_show (label_newmsg_notify);
972
        gtk_box_pack_start (GTK_BOX (hbox), label_newmsg_notify,
973
                            FALSE, FALSE, 0);
974

    
975
        entry_newmsg_notify = gtk_entry_new ();
976
        gtk_widget_show (entry_newmsg_notify);
977
        gtk_box_pack_start (GTK_BOX (hbox), entry_newmsg_notify, TRUE, TRUE, 0);
978

    
979
        SET_TOGGLE_SENSITIVITY (checkbtn_newmsg_notify, hbox);
980

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

    
985
#ifndef G_OS_WIN32
986
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_spool, checkbtn_local,
987
                                     _("Incorporate from local spool"));
988

    
989
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
990
        gtk_widget_show (vbox2);
991
        gtk_container_add (GTK_CONTAINER (frame_spool), vbox2);
992
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
993
        SET_TOGGLE_SENSITIVITY (checkbtn_local, vbox2);
994

    
995
        hbox = gtk_hbox_new (FALSE, 32);
996
        gtk_widget_show (hbox);
997
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
998

    
999
        PACK_CHECK_BUTTON (hbox, checkbtn_filter_on_inc,
1000
                           _("Filter on incorporation"));
1001

    
1002
        hbox = gtk_hbox_new (FALSE, 8);
1003
        gtk_widget_show (hbox);
1004
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1005

    
1006
        label_spool = gtk_label_new (_("Spool path"));
1007
        gtk_widget_show (label_spool);
1008
        gtk_box_pack_start (GTK_BOX (hbox), label_spool, FALSE, FALSE, 0);
1009

    
1010
        entry_spool = gtk_entry_new ();
1011
        gtk_widget_show (entry_spool);
1012
        gtk_box_pack_start (GTK_BOX (hbox), entry_spool, TRUE, TRUE, 0);
1013
#endif /* !G_OS_WIN32 */
1014

    
1015
        receive.checkbtn_autochk    = checkbtn_autochk;
1016
        receive.spinbtn_autochk     = spinbtn_autochk;
1017
        receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1018

    
1019
        receive.checkbtn_chkonstartup   = checkbtn_chkonstartup;
1020
        receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1021

    
1022
        receive.checkbtn_newmsg_notify_window = checkbtn_newmsg_notify_window;
1023
#ifdef G_OS_WIN32
1024
        receive.checkbtn_newmsg_sound   = checkbtn_newmsg_sound;
1025
        receive.entry_newmsg_sound      = entry_newmsg_sound;
1026
#endif
1027
        receive.checkbtn_newmsg_notify  = checkbtn_newmsg_notify;
1028
        receive.entry_newmsg_notify     = entry_newmsg_notify;
1029

    
1030
#ifndef G_OS_WIN32
1031
        receive.checkbtn_local         = checkbtn_local;
1032
        receive.checkbtn_filter_on_inc = checkbtn_filter_on_inc;
1033
        receive.entry_spool            = entry_spool;
1034
#endif
1035
}
1036

    
1037
static void prefs_send_create(void)
1038
{
1039
        GtkWidget *vbox1;
1040

    
1041
        GtkWidget *notebook;
1042
        GtkWidget *vbox_tab;
1043

    
1044
        GtkWidget *vbox2;
1045
        GtkWidget *hbox1;
1046
        GtkWidget *checkbtn_savemsg;
1047
        GtkWidget *checkbtn_filter_sent;
1048
        GtkWidget *checkbtn_recipients_autoreg;
1049
        GtkWidget *checkbtn_show_send_dialog;
1050
        GtkWidget *label;
1051
        GtkWidget *checkbtn_check_attach;
1052
        GtkWidget *entry_check_attach_str;
1053
        GtkWidget *checkbtn_check_recp;
1054
        GtkWidget *entry_check_recp_excl;
1055

    
1056
        GtkWidget *optmenu_trencoding;
1057
        GtkWidget *optmenu_menu;
1058
        GtkWidget *menuitem;
1059
        GtkWidget *optmenu_fencoding;
1060
        GtkWidget *label_encoding;
1061
        GtkWidget *label_encoding_desc;
1062
        GtkWidget *label_fencoding;
1063
        GtkWidget *label_fencoding_desc;
1064

    
1065
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1066
        gtk_widget_show (vbox1);
1067
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1068
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1069

    
1070
        notebook = gtk_notebook_new();
1071
        gtk_widget_show(notebook);
1072
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1073

    
1074
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1075

    
1076
        vbox2 = gtk_vbox_new (FALSE, 0);
1077
        gtk_widget_show (vbox2);
1078
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
1079

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

    
1088
        PACK_CHECK_BUTTON (vbox2, checkbtn_show_send_dialog,
1089
                           _("Display send dialog"));
1090

    
1091
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1092
        gtk_widget_show (vbox2);
1093
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
1094

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

    
1099
        hbox1 = gtk_hbox_new (FALSE, 8);
1100
        gtk_widget_show (hbox1);
1101
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1102

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

    
1111
        SET_TOGGLE_SENSITIVITY(checkbtn_check_attach, entry_check_attach_str);
1112

    
1113
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1114
        gtk_widget_show (vbox2);
1115
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
1116

    
1117
        PACK_CHECK_BUTTON (vbox2, checkbtn_check_recp,
1118
                           _("Confirm recipients before sending"));
1119

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

    
1128
        entry_check_recp_excl = gtk_entry_new ();
1129
        gtk_widget_show (entry_check_recp_excl);
1130
        gtk_box_pack_start (GTK_BOX (vbox2), entry_check_recp_excl,
1131
                            FALSE, FALSE, 0);
1132

    
1133
        SET_TOGGLE_SENSITIVITY(checkbtn_check_recp, entry_check_recp_excl);
1134

    
1135
        /* Encoding */
1136

    
1137
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Encoding"));
1138

    
1139
        hbox1 = gtk_hbox_new (FALSE, 8);
1140
        gtk_widget_show (hbox1);
1141
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1142

    
1143
        label_encoding = gtk_label_new (_("Transfer encoding"));
1144
        gtk_widget_show (label_encoding);
1145
        gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
1146

    
1147
        optmenu_trencoding = gtk_option_menu_new ();
1148
        gtk_widget_show (optmenu_trencoding);
1149
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_trencoding,
1150
                            FALSE, FALSE, 0);
1151

    
1152
        optmenu_menu = gtk_menu_new();
1153

    
1154
#define SET_MENUITEM(str, data) \
1155
        MENUITEM_ADD(optmenu_menu, menuitem, str, data)
1156

    
1157
        SET_MENUITEM(_("Automatic"),         CTE_AUTO);
1158
        SET_MENUITEM("base64",                 CTE_BASE64);
1159
        SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
1160
        SET_MENUITEM("8bit",                 CTE_8BIT);
1161

    
1162
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_trencoding),
1163
                                  optmenu_menu);
1164

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

    
1169
        hbox1 = gtk_hbox_new (FALSE, 8);
1170
        gtk_widget_show (hbox1);
1171
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1172

    
1173
        label_fencoding = gtk_label_new (_("MIME filename encoding"));
1174
        gtk_widget_show (label_fencoding);
1175
        gtk_box_pack_start (GTK_BOX (hbox1), label_fencoding, FALSE, FALSE, 0);
1176

    
1177
        optmenu_fencoding = gtk_option_menu_new ();
1178
        gtk_widget_show (optmenu_fencoding);
1179
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_fencoding,
1180
                            FALSE, FALSE, 0);
1181

    
1182
        optmenu_menu = gtk_menu_new();
1183

    
1184
        SET_MENUITEM(_("MIME header"), FENC_MIME);
1185
        SET_MENUITEM("RFC 2231", FENC_RFC2231);
1186

    
1187
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_fencoding),
1188
                                  optmenu_menu);
1189

    
1190
#undef SET_MENUITEM
1191

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

    
1199

    
1200
        p_send.checkbtn_savemsg = checkbtn_savemsg;
1201
        p_send.checkbtn_filter_sent = checkbtn_filter_sent;
1202
        p_send.checkbtn_recipients_autoreg = checkbtn_recipients_autoreg;
1203
        p_send.checkbtn_show_send_dialog = checkbtn_show_send_dialog;
1204

    
1205
        p_send.optmenu_encoding_method = optmenu_trencoding;
1206
        p_send.optmenu_mime_fencoding_method = optmenu_fencoding;
1207

    
1208
        p_send.checkbtn_check_attach = checkbtn_check_attach;
1209
        p_send.entry_check_attach_str = entry_check_attach_str;
1210
        p_send.checkbtn_check_recp = checkbtn_check_recp;
1211
        p_send.entry_check_recp_excl = entry_check_recp_excl;
1212
}
1213

    
1214
static void prefs_compose_create(void)
1215
{
1216
        GtkWidget *vbox1;
1217

    
1218
        GtkWidget *notebook;
1219
        GtkWidget *vbox_tab;
1220

    
1221
        GtkWidget *hbox1;
1222
        GtkWidget *hbox2;
1223

    
1224
        GtkWidget *frame_sig;
1225
        GtkWidget *checkbtn_autosig;
1226
        GtkWidget *label_sigsep;
1227
        GtkWidget *entry_sigsep;
1228

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

    
1243
        GtkWidget *hbox_autosave;
1244
        GtkWidget *checkbtn_autosave;
1245
        GtkWidget *label_autosave1;
1246
        GtkObject *spinbtn_autosave_adj;
1247
        GtkWidget *spinbtn_autosave;
1248
        GtkWidget *label_autosave2;
1249

    
1250
        GtkWidget *frame_reply;
1251
        GtkWidget *checkbtn_reply_account_autosel;
1252
        GtkWidget *checkbtn_quote;
1253
        GtkWidget *checkbtn_default_reply_list;
1254
        GtkWidget *checkbtn_inherit_recipient_on_self_reply;
1255
        GtkWidget *checkbtn_reply_address_only;
1256

    
1257
        GtkWidget *quote_wid;
1258
#if USE_GTKSPELL
1259
        GtkWidget *spell_wid;
1260
#endif
1261

    
1262
        vbox1 = gtk_vbox_new(FALSE, VSPACING);
1263
        gtk_widget_show(vbox1);
1264
        gtk_container_add(GTK_CONTAINER(dialog.notebook), vbox1);
1265
        gtk_container_set_border_width(GTK_CONTAINER(vbox1), VBOX_BORDER);
1266

    
1267
        notebook = gtk_notebook_new();
1268
        gtk_widget_show(notebook);
1269
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1270

    
1271
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1272

    
1273
        /* signature */
1274

    
1275
        PACK_FRAME(vbox_tab, frame_sig, _("Signature"));
1276

    
1277
        hbox1 = gtk_hbox_new (FALSE, 32);
1278
        gtk_widget_show (hbox1);
1279
        gtk_container_add (GTK_CONTAINER (frame_sig), hbox1);
1280
        gtk_container_set_border_width (GTK_CONTAINER (hbox1), 8);
1281

    
1282
        hbox2 = gtk_hbox_new (FALSE, 8);
1283
        gtk_widget_show (hbox2);
1284
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1285

    
1286
        label_sigsep = gtk_label_new (_("Signature separator"));
1287
        gtk_widget_show (label_sigsep);
1288
        gtk_box_pack_start (GTK_BOX (hbox2), label_sigsep, FALSE, FALSE, 0);
1289

    
1290
        entry_sigsep = gtk_entry_new ();
1291
        gtk_widget_show (entry_sigsep);
1292
        gtk_box_pack_start (GTK_BOX (hbox2), entry_sigsep, FALSE, FALSE, 0);
1293
        gtk_widget_set_size_request (entry_sigsep, 64, -1);
1294

    
1295
        PACK_CHECK_BUTTON (hbox1, checkbtn_autosig, _("Insert automatically"));
1296

    
1297
        PACK_FRAME(vbox_tab, frame_reply, _("Reply"));
1298

    
1299
        vbox2 = gtk_vbox_new (FALSE, 0);
1300
        gtk_widget_show (vbox2);
1301
        gtk_container_add (GTK_CONTAINER (frame_reply), vbox2);
1302
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1303

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

    
1315
        /* editor */
1316

    
1317
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Editor"));
1318

    
1319
        vbox2 = gtk_vbox_new (FALSE, 0);
1320
        gtk_widget_show (vbox2);
1321
        gtk_container_add (GTK_CONTAINER (vbox_tab), vbox2);
1322

    
1323
        PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1324
                           _("Automatically launch the external editor"));
1325

    
1326
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1327

    
1328
        /* undo */
1329

    
1330
        hbox3 = gtk_hbox_new (FALSE, 8);
1331
        gtk_widget_show (hbox3);
1332
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1333

    
1334
        label_undolevel = gtk_label_new (_("Undo level"));
1335
        gtk_widget_show (label_undolevel);
1336
        gtk_box_pack_start (GTK_BOX (hbox3), label_undolevel, FALSE, FALSE, 0);
1337

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

    
1346
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1347

    
1348
        /* line-wrapping */
1349

    
1350
        hbox3 = gtk_hbox_new (FALSE, 8);
1351
        gtk_widget_show (hbox3);
1352
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1353

    
1354
        label_linewrap = gtk_label_new (_("Wrap messages at"));
1355
        gtk_widget_show (label_linewrap);
1356
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1357

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

    
1366
        label_linewrap = gtk_label_new (_("characters"));
1367
        gtk_widget_show (label_linewrap);
1368
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1369

    
1370
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1371

    
1372
        hbox4 = gtk_hbox_new (FALSE, 32);
1373
        gtk_widget_show (hbox4);
1374
        gtk_box_pack_start (GTK_BOX (vbox2), hbox4, FALSE, FALSE, 0);
1375

    
1376
        PACK_CHECK_BUTTON (hbox4, checkbtn_wrapquote, _("Wrap quotation"));
1377

    
1378
        hbox4 = gtk_hbox_new (FALSE, 32);
1379
        gtk_widget_show (hbox4);
1380
        gtk_box_pack_start (GTK_BOX (vbox2), hbox4, FALSE, FALSE, 0);
1381

    
1382
        PACK_CHECK_BUTTON (hbox4, checkbtn_autowrap, _("Wrap on input"));
1383

    
1384
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1385

    
1386
        hbox_autosave = gtk_hbox_new (FALSE, 8);
1387
        gtk_widget_show (hbox_autosave);
1388
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_autosave, FALSE, FALSE, 0);
1389

    
1390
        PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
1391
                           _("Auto-save to draft"));
1392

    
1393
        label_autosave1 = gtk_label_new (_("every"));
1394
        gtk_widget_show (label_autosave1);
1395
        gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave1,
1396
                            FALSE, FALSE, 0);
1397

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

    
1407
        label_autosave2 = gtk_label_new (_("minute(s)"));
1408
        gtk_widget_show (label_autosave2);
1409
        gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave2,
1410
                            FALSE, FALSE, 0);
1411

    
1412
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, label_autosave1);
1413
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, spinbtn_autosave);
1414
        SET_TOGGLE_SENSITIVITY(checkbtn_autosave, label_autosave2);
1415

    
1416
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Format"));
1417
        quote_wid = prefs_quote_create();
1418
        gtk_box_pack_start(GTK_BOX(vbox_tab), quote_wid, FALSE, FALSE, 0);
1419

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

    
1426
        compose.checkbtn_autosig = checkbtn_autosig;
1427
        compose.entry_sigsep     = entry_sigsep;
1428

    
1429
        compose.checkbtn_autoextedit = checkbtn_autoextedit;
1430

    
1431
        compose.spinbtn_undolevel     = spinbtn_undolevel;
1432
        compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1433

    
1434
        compose.spinbtn_linewrap     = spinbtn_linewrap;
1435
        compose.spinbtn_linewrap_adj = spinbtn_linewrap_adj;
1436
        compose.checkbtn_wrapquote   = checkbtn_wrapquote;
1437
        compose.checkbtn_autowrap    = checkbtn_autowrap;
1438

    
1439
        compose.checkbtn_autosave    = checkbtn_autosave;
1440
        compose.spinbtn_autosave     = spinbtn_autosave;
1441
        compose.spinbtn_autosave_adj = spinbtn_autosave_adj;
1442

    
1443
        compose.checkbtn_quote = checkbtn_quote;
1444
        compose.checkbtn_reply_account_autosel =
1445
                checkbtn_reply_account_autosel;
1446
        compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
1447
        compose.checkbtn_inherit_recipient_on_self_reply =
1448
                checkbtn_inherit_recipient_on_self_reply;
1449
        compose.checkbtn_reply_address_only = checkbtn_reply_address_only;
1450
}
1451

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

    
1464
        GtkWidget *entry_fw_quotemark;
1465
        GtkWidget *text_fw_quotefmt;
1466

    
1467
        GtkWidget *btn_quotedesc;
1468

    
1469
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1470
        gtk_widget_show (vbox1);
1471

    
1472
        /* reply */
1473

    
1474
        PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1475

    
1476
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1477
        gtk_widget_show (vbox_quote);
1478
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1479
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1480

    
1481
        hbox1 = gtk_hbox_new (FALSE, 32);
1482
        gtk_widget_show (hbox1);
1483
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1484

    
1485
        hbox2 = gtk_hbox_new (FALSE, 8);
1486
        gtk_widget_show (hbox2);
1487
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1488

    
1489
        label_quotemark = gtk_label_new (_("Quotation mark"));
1490
        gtk_widget_show (label_quotemark);
1491
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1492

    
1493
        entry_quotemark = gtk_entry_new ();
1494
        gtk_widget_show (entry_quotemark);
1495
        gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1496
        gtk_widget_set_size_request (entry_quotemark, 64, -1);
1497

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

    
1508
        text_quotefmt = gtk_text_view_new ();
1509
        gtk_widget_show (text_quotefmt);
1510
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1511
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_quotefmt), TRUE);
1512
        gtk_widget_set_size_request(text_quotefmt, DEFAULT_ENTRY_WIDTH, 60);
1513

    
1514
        /* forward */
1515

    
1516
        PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1517

    
1518
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1519
        gtk_widget_show (vbox_quote);
1520
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1521
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1522

    
1523
        hbox1 = gtk_hbox_new (FALSE, 32);
1524
        gtk_widget_show (hbox1);
1525
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1526

    
1527
        hbox2 = gtk_hbox_new (FALSE, 8);
1528
        gtk_widget_show (hbox2);
1529
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1530

    
1531
        label_quotemark = gtk_label_new (_("Quotation mark"));
1532
        gtk_widget_show (label_quotemark);
1533
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1534

    
1535
        entry_fw_quotemark = gtk_entry_new ();
1536
        gtk_widget_show (entry_fw_quotemark);
1537
        gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1538
                            FALSE, FALSE, 0);
1539
        gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
1540

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

    
1551
        text_fw_quotefmt = gtk_text_view_new ();
1552
        gtk_widget_show (text_fw_quotefmt);
1553
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1554
                          text_fw_quotefmt);
1555
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
1556
        gtk_widget_set_size_request (text_fw_quotefmt, DEFAULT_ENTRY_WIDTH, 60);
1557

    
1558
        hbox1 = gtk_hbox_new (FALSE, 32);
1559
        gtk_widget_show (hbox1);
1560
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1561

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

    
1569
        quote.entry_quotemark    = entry_quotemark;
1570
        quote.text_quotefmt      = text_quotefmt;
1571
        quote.entry_fw_quotemark = entry_fw_quotemark;
1572
        quote.text_fw_quotefmt   = text_fw_quotefmt;
1573

    
1574
        return vbox1;
1575
}
1576

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

    
1615
        return vbox1;
1616
}
1617
#endif /* USE_GTKSPELL */
1618

    
1619
static void prefs_display_create(void)
1620
{
1621
        GtkWidget *vbox1;
1622

    
1623
        GtkWidget *notebook;
1624
        GtkWidget *vbox_tab;
1625

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

    
1650
        GtkWidget *msg_wid;
1651
        GtkWidget *att_wid;
1652
        GtkWidget *clabel_wid;
1653

    
1654
        GtkWidget *label_dispencoding;
1655
        GtkWidget *optmenu_dispencoding;
1656
        GtkWidget *label_outencoding;
1657
        GtkWidget *optmenu_outencoding;
1658
        GtkWidget *label_encoding_desc;
1659

    
1660
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1661
        gtk_widget_show (vbox1);
1662
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1663
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1664

    
1665
        notebook = gtk_notebook_new();
1666
        gtk_widget_show(notebook);
1667
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
1668

    
1669
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("General"));
1670

    
1671
        table1 = gtk_table_new (1, 2, FALSE);
1672
        gtk_widget_show (table1);
1673
        gtk_box_pack_start(GTK_BOX(vbox_tab), table1, FALSE, FALSE, 0);
1674
        gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
1675
        gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
1676

    
1677
        label_textfont = gtk_label_new (_("Text font"));
1678
        gtk_widget_show (label_textfont);
1679
        gtk_table_attach (GTK_TABLE (table1), label_textfont, 0, 1, 0, 1,
1680
                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1681

    
1682
        fontbtn_textfont = gtk_font_button_new ();
1683
        gtk_widget_show (fontbtn_textfont);
1684
        gtk_table_attach (GTK_TABLE (table1), fontbtn_textfont, 1, 2, 0, 1,
1685
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
1686

    
1687
        /* ---- Folder View ---- */
1688

    
1689
        PACK_FRAME(vbox_tab, frame_folder, _("Folder View"));
1690

    
1691
        vbox2 = gtk_vbox_new (FALSE, 0);
1692
        gtk_widget_show (vbox2);
1693
        gtk_container_add (GTK_CONTAINER (frame_folder), vbox2);
1694
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1695

    
1696
        PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1697
                           _("Display unread number next to folder name"));
1698

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

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

    
1718
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1719

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

    
1724
        label_ng_abbrev = gtk_label_new
1725
                (_("Abbreviate newsgroups longer than"));
1726
        gtk_widget_show (label_ng_abbrev);
1727
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1728

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

    
1739
        label_ng_abbrev = gtk_label_new
1740
                (_("letters"));
1741
        gtk_widget_show (label_ng_abbrev);
1742
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1743

    
1744
        /* ---- Summary ---- */
1745

    
1746
        PACK_FRAME(vbox_tab, frame_summary, _("Summary View"));
1747

    
1748
        vbox2 = gtk_vbox_new (FALSE, 0);
1749
        gtk_widget_show (vbox2);
1750
        gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1751
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1752

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

    
1759
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1760

    
1761
        hbox1 = gtk_hbox_new (FALSE, 8);
1762
        gtk_widget_show (hbox1);
1763
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1764

    
1765
        label_datefmt = gtk_label_new (_("Date format"));
1766
        gtk_widget_show (label_datefmt);
1767
        gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1768

    
1769
        entry_datefmt = gtk_entry_new ();
1770
        gtk_widget_show (entry_datefmt);
1771
        gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1772

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

    
1779
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1780

    
1781
        hbox1 = gtk_hbox_new (FALSE, 8);
1782
        gtk_widget_show (hbox1);
1783
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1784

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

    
1792
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Message"));
1793
        msg_wid = prefs_message_create();
1794
        gtk_box_pack_start(GTK_BOX(vbox_tab), msg_wid, FALSE, FALSE, 0);
1795

    
1796
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Attachment"));
1797
        att_wid = prefs_attach_create();
1798
        gtk_box_pack_start(GTK_BOX(vbox_tab), att_wid, FALSE, FALSE, 0);
1799

    
1800
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Color label"));
1801
        clabel_wid = prefs_colorlabel_create();
1802
        gtk_box_pack_start(GTK_BOX(vbox_tab), clabel_wid, FALSE, FALSE, 0);
1803

    
1804
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Encoding"));
1805

    
1806
        hbox1 = gtk_hbox_new (FALSE, 8);
1807
        gtk_widget_show (hbox1);
1808
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1809

    
1810
        label_dispencoding = gtk_label_new (_("Default character encoding"));
1811
        gtk_widget_show (label_dispencoding);
1812
        gtk_box_pack_start (GTK_BOX (hbox1), label_dispencoding,
1813
                            FALSE, FALSE, 0);
1814

    
1815
        optmenu_dispencoding = gtk_option_menu_new ();
1816
        gtk_widget_show (optmenu_dispencoding);
1817
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_dispencoding,
1818
                            FALSE, FALSE, 0);
1819

    
1820
        prefs_common_set_encoding_optmenu
1821
                (GTK_OPTION_MENU (optmenu_dispencoding), FALSE);
1822

    
1823
        PACK_SMALL_LABEL (vbox_tab, label_encoding_desc,
1824
                          _("This is used when displaying messages with missing character encoding."));
1825

    
1826
        hbox1 = gtk_hbox_new (FALSE, 8);
1827
        gtk_widget_show (hbox1);
1828
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
1829

    
1830
        label_outencoding = gtk_label_new (_("Outgoing character encoding"));
1831
        gtk_widget_show (label_outencoding);
1832
        gtk_box_pack_start (GTK_BOX (hbox1), label_outencoding,
1833
                            FALSE, FALSE, 0);
1834

    
1835
        optmenu_outencoding = gtk_option_menu_new ();
1836
        gtk_widget_show (optmenu_outencoding);
1837
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_outencoding,
1838
                            FALSE, FALSE, 0);
1839

    
1840
        prefs_common_set_encoding_optmenu
1841
                (GTK_OPTION_MENU (optmenu_outencoding), TRUE);
1842

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

    
1847
        display.fontbtn_textfont = fontbtn_textfont;
1848

    
1849
        display.chkbtn_folder_unread      = chkbtn_folder_unread;
1850
        display.chkbtn_folder_col_new     = chkbtn_folder_col_new;
1851
        display.chkbtn_folder_col_unread  = chkbtn_folder_col_unread;
1852
        display.chkbtn_folder_col_total   = chkbtn_folder_col_total;
1853
        display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
1854
        display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
1855

    
1856
        display.chkbtn_swapfrom      = chkbtn_swapfrom;
1857
        display.chkbtn_expand_thread = chkbtn_expand_thread;
1858
        display.entry_datefmt        = entry_datefmt;
1859

    
1860
        display.optmenu_dispencoding = optmenu_dispencoding;
1861
        display.optmenu_outencoding  = optmenu_outencoding;
1862
}
1863

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

    
1882
        GtkWidget *frame_scr;
1883
        GtkWidget *vbox_scr;
1884
        GtkWidget *chkbtn_smoothscroll;
1885
        GtkWidget *hbox_scr;
1886
        GtkWidget *label_scr;
1887
        GtkObject *spinbtn_scrollstep_adj;
1888
        GtkWidget *spinbtn_scrollstep;
1889
        GtkWidget *chkbtn_halfpage;
1890

    
1891
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1892
        gtk_widget_show (vbox1);
1893

    
1894
        vbox2 = gtk_vbox_new (FALSE, 0);
1895
        gtk_widget_show (vbox2);
1896
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1897

    
1898
        hbox1 = gtk_hbox_new (FALSE, 8);
1899
        gtk_widget_show (hbox1);
1900
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1901

    
1902
        PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
1903
                           _("Enable coloration of message"));
1904
        g_signal_connect(G_OBJECT(chkbtn_enablecol), "toggled",
1905
                         G_CALLBACK(prefs_enable_message_color_toggled), NULL);
1906

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

    
1913
        SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
1914

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

    
1924
        PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1925
                          _("Display header pane above message view"));
1926

    
1927
        hbox1 = gtk_hbox_new (FALSE, 8);
1928
        gtk_widget_show (hbox1);
1929
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1930

    
1931
        PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1932
                          _("Display short headers on message view"));
1933

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

    
1941
        SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1942

    
1943
        PACK_CHECK_BUTTON(vbox2, chkbtn_html,
1944
                          _("Render HTML messages as text"));
1945
        PACK_CHECK_BUTTON(vbox2, chkbtn_htmlonly,
1946
                          _("Treat HTML only messages as attachment"));
1947

    
1948
#if 0
1949
        PACK_CHECK_BUTTON(vbox2, chkbtn_cursor,
1950
                          _("Display cursor in message view"));
1951
#endif
1952

    
1953
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1954

    
1955
        hbox1 = gtk_hbox_new (FALSE, 32);
1956
        gtk_widget_show (hbox1);
1957
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1958

    
1959
        hbox_linespc = gtk_hbox_new (FALSE, 8);
1960
        gtk_widget_show (hbox1);
1961
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
1962

    
1963
        label_linespc = gtk_label_new (_("Line space"));
1964
        gtk_widget_show (label_linespc);
1965
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1966
                            FALSE, FALSE, 0);
1967

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

    
1977
        label_linespc = gtk_label_new (_("pixel(s)"));
1978
        gtk_widget_show (label_linespc);
1979
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1980
                            FALSE, FALSE, 0);
1981

    
1982
        PACK_FRAME(vbox1, frame_scr, _("Scroll"));
1983

    
1984
        vbox_scr = gtk_vbox_new (FALSE, 0);
1985
        gtk_widget_show (vbox_scr);
1986
        gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
1987
        gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
1988

    
1989
        PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
1990

    
1991
        hbox1 = gtk_hbox_new (FALSE, 32);
1992
        gtk_widget_show (hbox1);
1993
        gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
1994

    
1995
        PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
1996

    
1997
        hbox_scr = gtk_hbox_new (FALSE, 8);
1998
        gtk_widget_show (hbox_scr);
1999
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
2000

    
2001
        label_scr = gtk_label_new (_("Step"));
2002
        gtk_widget_show (label_scr);
2003
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2004

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

    
2015
        label_scr = gtk_label_new (_("pixel(s)"));
2016
        gtk_widget_show (label_scr);
2017
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2018

    
2019
        SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
2020

    
2021
        message.chkbtn_enablecol   = chkbtn_enablecol;
2022
        message.button_edit_col    = button_edit_col;
2023
        message.chkbtn_disphdrpane = chkbtn_disphdrpane;
2024
        message.chkbtn_disphdr     = chkbtn_disphdr;
2025
        message.chkbtn_html        = chkbtn_html;
2026
        message.chkbtn_htmlonly    = chkbtn_htmlonly;
2027
        message.spinbtn_linespc    = spinbtn_linespc;
2028

    
2029
        message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
2030
        message.spinbtn_scrollstep     = spinbtn_scrollstep;
2031
        message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
2032
        message.chkbtn_halfpage        = chkbtn_halfpage;
2033

    
2034
        return vbox1;
2035
}
2036

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

    
2052
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2053
        gtk_widget_show (vbox1);
2054

    
2055
        vbox2 = gtk_vbox_new (FALSE, 0);
2056
        gtk_widget_show (vbox2);
2057
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2058

    
2059
        hbox1 = gtk_hbox_new (FALSE, 8);
2060
        gtk_widget_show (hbox1);
2061
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2062

    
2063
        label = gtk_label_new (_("Position of attachment tool button:"));
2064
        gtk_widget_show (label);
2065
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2066

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

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

    
2083
        PACK_CHECK_BUTTON (vbox2, chkbtn_show_attach_tab,
2084
                           _("Toggle attachment list view with tab"));
2085
        SET_TOGGLE_SENSITIVITY_REV (chkbtn_show_attach_tab, hbox1);
2086

    
2087
        PACK_CHECK_BUTTON (vbox2, chkbtn_show_files_first,
2088
                           _("Show attached files first on message view"));
2089

    
2090
        PACK_FRAME(vbox1, frame_image, _("Images"));
2091

    
2092
        vbox_image = gtk_vbox_new (FALSE, 0);
2093
        gtk_widget_show (vbox_image);
2094
        gtk_container_add (GTK_CONTAINER (frame_image), vbox_image);
2095
        gtk_container_set_border_width (GTK_CONTAINER (vbox_image), 8);
2096

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

    
2102
        attach.chkbtn_show_attach_tab  = chkbtn_show_attach_tab;
2103
        attach.radiobtn_attach_toolbtn_pos = radiobtn_attach_toolbtn_pos;
2104
        attach.chkbtn_show_files_first = chkbtn_show_files_first;
2105

    
2106
        attach.chkbtn_resize_image = chkbtn_resize_image;
2107
        attach.chkbtn_inline_image = chkbtn_inline_image;
2108

    
2109
        return vbox1;
2110
}
2111

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

    
2122
        vbox = gtk_vbox_new(FALSE, VSPACING);
2123
        gtk_widget_show(vbox);
2124
        gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
2125

    
2126
        hbox = gtk_hbox_new(FALSE, 8);
2127
        gtk_widget_show(hbox);
2128
        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
2129

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

    
2137
        table = gtk_table_new(7, 2, FALSE);
2138
        gtk_widget_show(table);
2139
        gtk_container_add(GTK_CONTAINER(vbox), table);
2140
        gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
2141
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
2142

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

    
2156
        return vbox;
2157
}
2158

    
2159
static void prefs_common_colorlabel_set_dialog(void)
2160
{
2161
        gint i;
2162
        const gchar *text;
2163

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

    
2175
static void prefs_common_colorlabel_update(void)
2176
{
2177
        gint i;
2178
        const gchar *text;
2179

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

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

    
2206
enum
2207
{
2208
        JUNK_NONE,
2209
        JUNK_BOGOFILTER,
2210
        JUNK_BSFILTER,
2211
        JUNK_SYLFILTER,
2212

    
2213
        N_JUNK_ITEMS
2214
};
2215

    
2216
static void prefs_junk_preset_activated(GtkMenuItem *menuitem, gpointer data)
2217
{
2218
        gint i;
2219

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

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

    
2255
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2256
        gtk_widget_show (vbox1);
2257
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2258
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2259

    
2260
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame, chkbtn_enable_junk,
2261
                                     _("Enable Junk mail control"));
2262

    
2263
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2264
        gtk_widget_show (vbox2);
2265
        gtk_container_add (GTK_CONTAINER (frame), vbox2);
2266
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2267
        SET_TOGGLE_SENSITIVITY (chkbtn_enable_junk, vbox2);
2268

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

    
2273
        label = gtk_label_new (_("Learning command:"));
2274
        gtk_widget_show (label);
2275
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2276

    
2277
        optmenu_preset = gtk_option_menu_new ();
2278
        gtk_widget_show (optmenu_preset);
2279
        gtk_box_pack_end (GTK_BOX (hbox), optmenu_preset, FALSE, FALSE, 0);
2280

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

    
2294
        hbox = gtk_hbox_new (FALSE, 8);
2295
        gtk_widget_show (hbox);
2296
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2297

    
2298
        label = gtk_label_new (_("Junk"));
2299
        gtk_widget_show (label);
2300
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2301

    
2302
        entry_junk_learncmd = gtk_entry_new ();
2303
        gtk_widget_show (entry_junk_learncmd);
2304
        gtk_box_pack_start (GTK_BOX (hbox), entry_junk_learncmd, TRUE, TRUE, 0);
2305

    
2306
        hbox = gtk_hbox_new (FALSE, 8);
2307
        gtk_widget_show (hbox);
2308
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2309

    
2310
        label = gtk_label_new (_("Not Junk"));
2311
        gtk_widget_show (label);
2312
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2313

    
2314
        entry_nojunk_learncmd = gtk_entry_new ();
2315
        gtk_widget_show (entry_nojunk_learncmd);
2316
        gtk_box_pack_start (GTK_BOX (hbox), entry_nojunk_learncmd,
2317
                            TRUE, TRUE, 0);
2318

    
2319
        PACK_VSPACER(vbox2, vbox3, 0);
2320

    
2321
        hbox = gtk_hbox_new (FALSE, 8);
2322
        gtk_widget_show (hbox);
2323
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2324

    
2325
        label = gtk_label_new (_("Classifying command"));
2326
        gtk_widget_show (label);
2327
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2328

    
2329
        entry_classify_cmd = gtk_entry_new ();
2330
        gtk_widget_show (entry_classify_cmd);
2331
        gtk_box_pack_start (GTK_BOX (hbox), entry_classify_cmd, TRUE, TRUE, 0);
2332

    
2333
        PACK_VSPACER(vbox2, vbox3, 0);
2334

    
2335
        PACK_SMALL_LABEL (vbox2, label,
2336
                          _("To classify junk mails automatically, both junk "
2337
                            "and not junk mails must be learned manually to "
2338
                            "a certain extent."));
2339

    
2340
        PACK_VSPACER(vbox2, vbox3, 0);
2341

    
2342
        hbox = gtk_hbox_new (FALSE, 8);
2343
        gtk_widget_show (hbox);
2344
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2345

    
2346
        label = gtk_label_new (_("Junk folder"));
2347
        gtk_widget_show (label);
2348
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2349

    
2350
        entry_junkfolder = gtk_entry_new ();
2351
        gtk_widget_show (entry_junkfolder);
2352
        gtk_box_pack_start (GTK_BOX (hbox), entry_junkfolder, TRUE, TRUE, 0);
2353

    
2354
        btn_folder = gtk_button_new_with_label (_(" ... "));
2355
        gtk_widget_show (btn_folder);
2356
        gtk_box_pack_start (GTK_BOX (hbox), btn_folder, FALSE, FALSE, 0);
2357
        g_signal_connect (G_OBJECT (btn_folder), "clicked",
2358
                          G_CALLBACK (prefs_common_select_folder_cb),
2359
                          entry_junkfolder);
2360

    
2361
        PACK_VSPACER(vbox2, vbox3, 0);
2362

    
2363
        PACK_SMALL_LABEL (vbox2, label,
2364
                          _("The messages which are set as junk mail "
2365
                            "will be moved to this folder. If empty, "
2366
                            "the default junk folder will be used."));
2367

    
2368
        PACK_VSPACER(vbox2, vbox3, 0);
2369

    
2370
        vbox3 = gtk_vbox_new (FALSE, 0);
2371
        gtk_widget_show (vbox3);
2372
        gtk_box_pack_start (GTK_BOX(vbox2), vbox3, FALSE, FALSE, 0);
2373

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

    
2386
        PACK_CHECK_BUTTON
2387
                (vbox3, chkbtn_nofilter_in_book,
2388
                 _("Do not classify message as junk if sender is in the address book"));
2389
        PACK_CHECK_BUTTON (vbox3, chkbtn_mark_as_read,
2390
                           _("Mark filtered junk mails as read"));
2391

    
2392
        junk.chkbtn_enable_junk      = chkbtn_enable_junk;
2393
        junk.entry_junk_learncmd     = entry_junk_learncmd;
2394
        junk.entry_nojunk_learncmd   = entry_nojunk_learncmd;
2395
        junk.entry_classify_cmd      = entry_classify_cmd;
2396
        junk.entry_junkfolder        = entry_junkfolder;
2397
        junk.chkbtn_filter_on_recv   = chkbtn_filter_on_recv;
2398
        junk.chkbtn_filter_before    = chkbtn_filter_before;
2399
        junk.chkbtn_delete_on_recv   = chkbtn_delete_on_recv;
2400
        junk.chkbtn_nofilter_in_book = chkbtn_nofilter_in_book;
2401
        junk.chkbtn_mark_as_read     = chkbtn_mark_as_read;
2402
}
2403

    
2404
#if USE_GPGME
2405
static void prefs_privacy_create(void)
2406
{
2407
        GtkWidget *vbox1;
2408
        GtkWidget *vbox2;
2409
        GtkWidget *vbox3;
2410
        GtkWidget *hbox1;
2411
        GtkWidget *hbox_spc;
2412
        GtkWidget *label;
2413
        GtkWidget *checkbtn_auto_check_signatures;
2414
        GtkWidget *checkbtn_gpg_signature_popup;
2415
        GtkWidget *checkbtn_store_passphrase;
2416
        GtkObject *spinbtn_store_passphrase_adj;
2417
        GtkWidget *spinbtn_store_passphrase;
2418
#ifndef G_OS_WIN32
2419
        GtkWidget *checkbtn_passphrase_grab;
2420
#endif
2421
        GtkWidget *checkbtn_gpg_warning;
2422

    
2423
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2424
        gtk_widget_show (vbox1);
2425
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2426
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2427

    
2428
        vbox2 = gtk_vbox_new (FALSE, 0);
2429
        gtk_widget_show (vbox2);
2430
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2431

    
2432
        PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
2433
                           _("Automatically check signatures"));
2434

    
2435
        PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup,
2436
                           _("Show signature check result in a popup window"));
2437

    
2438
        PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
2439
                           _("Store passphrase in memory temporarily"));
2440

    
2441
        vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2442
        gtk_widget_show (vbox3);
2443
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2444

    
2445
        hbox1 = gtk_hbox_new (FALSE, 8);
2446
        gtk_widget_show (hbox1);
2447
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2448

    
2449
        hbox_spc = gtk_hbox_new (FALSE, 0);
2450
        gtk_widget_show (hbox_spc);
2451
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2452
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2453

    
2454
        label = gtk_label_new (_("Expired after"));
2455
        gtk_widget_show (label);
2456
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2457

    
2458
        spinbtn_store_passphrase_adj = gtk_adjustment_new (0, 0, 1440, 1, 5, 0);
2459
        spinbtn_store_passphrase = gtk_spin_button_new
2460
                (GTK_ADJUSTMENT (spinbtn_store_passphrase_adj), 1, 0);
2461
        gtk_widget_show (spinbtn_store_passphrase);
2462
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_store_passphrase, FALSE, FALSE, 0);
2463
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_store_passphrase),
2464
                                     TRUE);
2465
        gtk_widget_set_size_request (spinbtn_store_passphrase, 64, -1);
2466

    
2467
        label = gtk_label_new (_("minute(s) "));
2468
        gtk_widget_show (label);
2469
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2470

    
2471
        hbox1 = gtk_hbox_new (FALSE, 8);
2472
        gtk_widget_show (hbox1);
2473
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2474

    
2475
        hbox_spc = gtk_hbox_new (FALSE, 0);
2476
        gtk_widget_show (hbox_spc);
2477
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2478
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2479

    
2480
        PACK_SMALL_LABEL (hbox1, label,
2481
                          _("Setting to '0' will store the passphrase "
2482
                            "for the whole session."));
2483

    
2484
        SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, vbox3);
2485

    
2486
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
2487

    
2488
#ifndef G_OS_WIN32
2489
        PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
2490
                           _("Grab input while entering a passphrase"));
2491
#endif
2492

    
2493
        PACK_CHECK_BUTTON
2494
                (vbox2, checkbtn_gpg_warning,
2495
                 _("Display warning on startup if GnuPG doesn't work"));
2496

    
2497
        hbox1 = gtk_hbox_new (FALSE, 8);
2498
        gtk_widget_show (hbox1);
2499
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2500

    
2501
        privacy.checkbtn_auto_check_signatures
2502
                                             = checkbtn_auto_check_signatures;
2503
        privacy.checkbtn_gpg_signature_popup
2504
                                             = checkbtn_gpg_signature_popup;
2505
        privacy.checkbtn_store_passphrase    = checkbtn_store_passphrase;
2506
        privacy.spinbtn_store_passphrase     = spinbtn_store_passphrase;
2507
        privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
2508
#ifndef G_OS_WIN32
2509
        privacy.checkbtn_passphrase_grab     = checkbtn_passphrase_grab;
2510
#endif
2511
        privacy.checkbtn_gpg_warning         = checkbtn_gpg_warning;
2512
}
2513
#endif /* USE_GPGME */
2514

    
2515
static void prefs_details_create(void)
2516
{
2517
        GtkWidget *vbox1;
2518

    
2519
        GtkWidget *notebook;
2520
        GtkWidget *vbox_tab;
2521

    
2522
        GtkWidget *vbox2;
2523
        GtkWidget *vbox3;
2524
        GtkWidget *checkbtn_always_show_msg;
2525
        GtkWidget *checkbtn_always_mark_read;
2526
        GtkWidget *checkbtn_openunread;
2527
        GtkWidget *checkbtn_remember_lastsel;
2528
        /* GtkWidget *checkbtn_mark_as_read_on_newwin; */
2529
        GtkWidget *checkbtn_openinbox;
2530
        GtkWidget *checkbtn_openinbox_startup;
2531
        GtkWidget *checkbtn_change_account_on_folder_sel;
2532
        GtkWidget *checkbtn_immedexec;
2533
        GtkWidget *hbox1;
2534
        GtkWidget *hbox_spc;
2535
        GtkWidget *label;
2536
#ifndef G_OS_WIN32
2537
        GtkWidget *checkbtn_comply_gnome_hig;
2538
#endif
2539
        GtkWidget *checkbtn_show_trayicon;
2540
        GtkWidget *checkbtn_minimize_to_tray;
2541
        GtkWidget *checkbtn_tray_toggle_window;
2542

    
2543
        GtkWidget *button_keybind;
2544

    
2545
        GtkWidget *other_wid;
2546
        GtkWidget *extcmd_wid;
2547
#if USE_UPDATE_CHECK
2548
        GtkWidget *update_wid;
2549
#endif
2550
        GtkWidget *advanced_wid;
2551

    
2552
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2553
        gtk_widget_show (vbox1);
2554
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2555
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2556

    
2557
        notebook = gtk_notebook_new();
2558
        gtk_widget_show(notebook);
2559
        gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
2560

    
2561
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Interface"));
2562

    
2563
        vbox2 = gtk_vbox_new (FALSE, 0);
2564
        gtk_widget_show (vbox2);
2565
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
2566

    
2567
        PACK_CHECK_BUTTON
2568
                (vbox2, checkbtn_always_show_msg,
2569
                 _("Always open messages in summary when selected"));
2570

    
2571
        PACK_CHECK_BUTTON
2572
                (vbox2, checkbtn_always_mark_read,
2573
                 _("Always mark as read when a message is opened"));
2574
        SET_TOGGLE_SENSITIVITY
2575
                (checkbtn_always_show_msg, checkbtn_always_mark_read);
2576

    
2577
        PACK_CHECK_BUTTON
2578
                (vbox2, checkbtn_openunread,
2579
                 _("Open first unread message when a folder is opened"));
2580
        SET_TOGGLE_SENSITIVITY_REV
2581
                (checkbtn_always_show_msg, checkbtn_openunread);
2582

    
2583
        PACK_CHECK_BUTTON
2584
                (vbox2, checkbtn_remember_lastsel,
2585
                 _("Remember last selected message"));
2586

    
2587
#if 0
2588
        PACK_CHECK_BUTTON
2589
                (vbox2, checkbtn_mark_as_read_on_newwin,
2590
                 _("Only mark message as read when opened in new window"));
2591
#endif
2592

    
2593
        hbox1 = gtk_hbox_new (FALSE, 8);
2594
        gtk_widget_show (hbox1);
2595
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2596
        PACK_CHECK_BUTTON
2597
                (hbox1, checkbtn_openinbox,
2598
                 _("Open inbox after receiving new mail"));
2599
        PACK_CHECK_BUTTON
2600
                (hbox1, checkbtn_openinbox_startup, _("Open inbox on startup"));
2601

    
2602
        PACK_CHECK_BUTTON
2603
                (vbox2, checkbtn_change_account_on_folder_sel,
2604
                 _("Change current account on folder open"));
2605

    
2606
        vbox3 = gtk_vbox_new (FALSE, 0);
2607
        gtk_widget_show (vbox3);
2608
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2609

    
2610
        PACK_CHECK_BUTTON
2611
                (vbox3, checkbtn_immedexec,
2612
                 _("Execute immediately when moving or deleting messages"));
2613

    
2614
        hbox1 = gtk_hbox_new (FALSE, 8);
2615
        gtk_widget_show (hbox1);
2616
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2617

    
2618
        hbox_spc = gtk_hbox_new (FALSE, 0);
2619
        gtk_widget_show (hbox_spc);
2620
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2621
        gtk_widget_set_size_request (hbox_spc, 12, -1);
2622

    
2623
        PACK_SMALL_LABEL (hbox1, label,
2624
                          _("Messages will be marked until execution "
2625
                            "if this is turned off."));
2626

    
2627
        vbox2 = gtk_vbox_new (FALSE, 0);
2628
        gtk_widget_show (vbox2);
2629
        gtk_box_pack_start (GTK_BOX (vbox_tab), vbox2, FALSE, FALSE, 0);
2630

    
2631
#ifndef G_OS_WIN32
2632
        PACK_CHECK_BUTTON (vbox2, checkbtn_comply_gnome_hig,
2633
                           _("Make the order of buttons comply with GNOME HIG"));
2634
#endif
2635
        PACK_CHECK_BUTTON (vbox2, checkbtn_show_trayicon,
2636
                           _("Display tray icon"));
2637
        PACK_CHECK_BUTTON (vbox2, checkbtn_minimize_to_tray,
2638
                           _("Minimize to tray icon"));
2639
        PACK_CHECK_BUTTON (vbox2, checkbtn_tray_toggle_window,
2640
                           _("Toggle window on trayicon click"));
2641
        SET_TOGGLE_SENSITIVITY (checkbtn_show_trayicon,
2642
                                checkbtn_minimize_to_tray);
2643
        SET_TOGGLE_SENSITIVITY (checkbtn_show_trayicon,
2644
                                checkbtn_tray_toggle_window);
2645

    
2646
        hbox1 = gtk_hbox_new (FALSE, 8);
2647
        gtk_widget_show (hbox1);
2648
        gtk_box_pack_start (GTK_BOX (vbox_tab), hbox1, FALSE, FALSE, 0);
2649

    
2650
        button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2651
        gtk_widget_show (button_keybind);
2652
        gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2653
        g_signal_connect (G_OBJECT (button_keybind), "clicked",
2654
                          G_CALLBACK (prefs_keybind_select), NULL);
2655

    
2656
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Other"));
2657
        other_wid = prefs_other_create();
2658
        gtk_box_pack_start(GTK_BOX(vbox_tab), other_wid, FALSE, FALSE, 0);
2659

    
2660
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("External commands"));
2661
        extcmd_wid = prefs_extcmd_create();
2662
        gtk_box_pack_start(GTK_BOX(vbox_tab), extcmd_wid, FALSE, FALSE, 0);
2663

    
2664
#if USE_UPDATE_CHECK
2665
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Update"));
2666
        update_wid = prefs_update_create();
2667
        gtk_box_pack_start(GTK_BOX(vbox_tab), update_wid, FALSE, FALSE, 0);
2668
#endif
2669

    
2670
        APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Advanced"));
2671
        advanced_wid = prefs_advanced_create();
2672
        gtk_box_pack_start(GTK_BOX(vbox_tab), advanced_wid, FALSE, FALSE, 0);
2673

    
2674
        iface.checkbtn_always_show_msg   = checkbtn_always_show_msg;
2675
        iface.checkbtn_always_mark_read  = checkbtn_always_mark_read;
2676
        iface.checkbtn_openunread        = checkbtn_openunread;
2677
        iface.checkbtn_remember_lastsel  = checkbtn_remember_lastsel;
2678
#if 0
2679
        iface.checkbtn_mark_as_read_on_newwin
2680
                                             = checkbtn_mark_as_read_on_newwin;
2681
#endif
2682
        iface.checkbtn_openinbox         = checkbtn_openinbox;
2683
        iface.checkbtn_openinbox_startup = checkbtn_openinbox_startup;
2684
        iface.checkbtn_change_account_on_folder_sel =
2685
                checkbtn_change_account_on_folder_sel;
2686
        iface.checkbtn_immedexec         = checkbtn_immedexec;
2687

    
2688
#ifndef G_OS_WIN32
2689
        iface.checkbtn_comply_gnome_hig  = checkbtn_comply_gnome_hig;
2690
#endif
2691
        iface.checkbtn_show_trayicon      = checkbtn_show_trayicon;
2692
        iface.checkbtn_minimize_to_tray   = checkbtn_minimize_to_tray;
2693
        iface.checkbtn_tray_toggle_window = checkbtn_tray_toggle_window;
2694
}
2695

    
2696
static GtkWidget *prefs_other_create(void)
2697
{
2698
        GtkWidget *vbox1;
2699

    
2700
        GtkWidget *frame_recv;
2701
        GtkWidget *vbox_recv;
2702
        GtkWidget *hbox1;
2703
        GtkWidget *label;
2704
        GtkWidget *optmenu_recvdialog;
2705
        GtkWidget *menu;
2706
        GtkWidget *menuitem;
2707
        GtkWidget *checkbtn_no_recv_err_panel;
2708
        GtkWidget *checkbtn_close_recv_dialog;
2709

    
2710
        GtkWidget *frame_addr;
2711
        GtkWidget *vbox_addr;
2712
        GtkWidget *checkbtn_addaddrbyclick;
2713
        GtkWidget *checkbtn_add_address_only;
2714
        GtkWidget *vbox_spc;
2715
        GtkWidget *radiobtn_addr_compl;
2716
        GtkWidget *radiobtn_compl_tab;
2717
        GtkWidget *radiobtn_no_compl;
2718

    
2719
        GtkWidget *frame_exit;
2720
        GtkWidget *vbox_exit;
2721
        GtkWidget *checkbtn_confonexit;
2722
        GtkWidget *checkbtn_cleanonexit;
2723
        GtkWidget *checkbtn_askonclean;
2724
        GtkWidget *checkbtn_warnqueued;
2725

    
2726
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2727
        gtk_widget_show (vbox1);
2728

    
2729
        PACK_FRAME (vbox1, frame_recv, _("Receive dialog"));
2730
        vbox_recv = gtk_vbox_new (FALSE, 0);
2731
        gtk_widget_show (vbox_recv);
2732
        gtk_container_add (GTK_CONTAINER (frame_recv), vbox_recv);
2733
        gtk_container_set_border_width (GTK_CONTAINER (vbox_recv), 8);
2734

    
2735
        hbox1 = gtk_hbox_new (FALSE, 8);
2736
        gtk_widget_show (hbox1);
2737
        gtk_box_pack_start (GTK_BOX (vbox_recv), hbox1, FALSE, FALSE, 0);
2738

    
2739
        label = gtk_label_new (_("Show receive dialog"));
2740
        gtk_widget_show (label);
2741
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2742

    
2743
        optmenu_recvdialog = gtk_option_menu_new ();
2744
        gtk_widget_show (optmenu_recvdialog);
2745
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_recvdialog,
2746
                            FALSE, FALSE, 0);
2747

    
2748
        menu = gtk_menu_new ();
2749
        MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
2750
        MENUITEM_ADD (menu, menuitem, _("Only on manual receiving"),
2751
                      RECV_DIALOG_MANUAL);
2752
        MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
2753

    
2754
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
2755

    
2756
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_no_recv_err_panel,
2757
                           _("Don't popup error dialog on receive error"));
2758

    
2759
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_close_recv_dialog,
2760
                           _("Close receive dialog when finished"));
2761

    
2762
        PACK_FRAME (vbox1, frame_addr, _("Address book"));
2763

    
2764
        vbox_addr = gtk_vbox_new (FALSE, 0);
2765
        gtk_widget_show (vbox_addr);
2766
        gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2767
        gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2768

    
2769
        PACK_CHECK_BUTTON
2770
                (vbox_addr, checkbtn_addaddrbyclick,
2771
                 _("Add address to destination when double-clicked"));
2772

    
2773
        PACK_CHECK_BUTTON
2774
                (vbox_addr, checkbtn_add_address_only,
2775
                 _("Set only mail address when entering recipient from address book"));
2776

    
2777
        PACK_VSPACER (vbox_addr, vbox_spc, VSPACING_NARROW_2);
2778

    
2779
        hbox1 = gtk_hbox_new (FALSE, 8);
2780
        gtk_widget_show (hbox1);
2781
        gtk_box_pack_start (GTK_BOX (vbox_addr), hbox1, FALSE, FALSE, 0);
2782

    
2783
        label = gtk_label_new (_("Auto-completion:"));
2784
        gtk_widget_show (label);
2785
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2786

    
2787
        radiobtn_addr_compl = gtk_radio_button_new_with_label
2788
                (NULL, _("Automatic"));
2789
        gtk_widget_show (radiobtn_addr_compl);
2790
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_addr_compl,
2791
                            FALSE, FALSE, 0);
2792
        g_object_set_data (G_OBJECT (radiobtn_addr_compl), MENU_VAL_ID,
2793
                           GINT_TO_POINTER (0));
2794

    
2795
        radiobtn_compl_tab = gtk_radio_button_new_with_label_from_widget
2796
                (GTK_RADIO_BUTTON (radiobtn_addr_compl), _("Start with Tab"));
2797
        gtk_widget_show (radiobtn_compl_tab);
2798
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_compl_tab,
2799
                            FALSE, FALSE, 0);
2800
        g_object_set_data (G_OBJECT (radiobtn_compl_tab), MENU_VAL_ID,
2801
                           GINT_TO_POINTER (1));
2802

    
2803
        radiobtn_no_compl = gtk_radio_button_new_with_label_from_widget
2804
                (GTK_RADIO_BUTTON (radiobtn_addr_compl), _("Disable"));
2805
        gtk_widget_show (radiobtn_no_compl);
2806
        gtk_box_pack_start (GTK_BOX (hbox1), radiobtn_no_compl,
2807
                            FALSE, FALSE, 0);
2808
        g_object_set_data (G_OBJECT (radiobtn_no_compl), MENU_VAL_ID,
2809
                           GINT_TO_POINTER (2));
2810

    
2811
        PACK_FRAME (vbox1, frame_exit, _("On exit"));
2812

    
2813
        vbox_exit = gtk_vbox_new (FALSE, 0);
2814
        gtk_widget_show (vbox_exit);
2815
        gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2816
        gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2817

    
2818
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2819
                           _("Confirm on exit"));
2820

    
2821
        hbox1 = gtk_hbox_new (FALSE, 32);
2822
        gtk_widget_show (hbox1);
2823
        gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2824

    
2825
        PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2826
                           _("Empty trash on exit"));
2827
        PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2828
                           _("Ask before emptying"));
2829
        SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2830

    
2831
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2832
                           _("Warn if there are queued messages"));
2833

    
2834
        other.optmenu_recvdialog         = optmenu_recvdialog;
2835
        other.checkbtn_no_recv_err_panel = checkbtn_no_recv_err_panel;
2836
        other.checkbtn_close_recv_dialog = checkbtn_close_recv_dialog;
2837

    
2838
        other.checkbtn_addaddrbyclick    = checkbtn_addaddrbyclick;
2839
        other.checkbtn_add_address_only  = checkbtn_add_address_only;
2840
        other.radiobtn_addr_compl        = radiobtn_addr_compl;
2841

    
2842
        other.checkbtn_confonexit  = checkbtn_confonexit;
2843
        other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2844
        other.checkbtn_askonclean  = checkbtn_askonclean;
2845
        other.checkbtn_warnqueued  = checkbtn_warnqueued;
2846

    
2847
        return vbox1;
2848
}
2849

    
2850
static GtkWidget *prefs_extcmd_create(void)
2851
{
2852
        GtkWidget *vbox1;
2853
        GtkWidget *hbox1;
2854

    
2855
        GtkWidget *ext_frame;
2856
        GtkWidget *ext_table;
2857

    
2858
        GtkWidget *uri_label;
2859
        GtkWidget *uri_combo;
2860
        GtkWidget *uri_entry;
2861

    
2862
        GtkWidget *exteditor_label;
2863
        GtkWidget *exteditor_combo;
2864
        GtkWidget *exteditor_entry;
2865

    
2866
        GtkWidget *frame_printcmd;
2867
        GtkWidget *vbox_printcmd;
2868
        GtkWidget *checkbtn_printcmd;
2869
        GtkWidget *printcmd_label;
2870
        GtkWidget *printcmd_entry;
2871

    
2872
#ifndef G_OS_WIN32
2873
        GtkWidget *vbox2;
2874
        GtkWidget *frame_incext;
2875
        GtkWidget *checkbtn_incext;
2876
        GtkWidget *label_incext;
2877
        GtkWidget *entry_incext;
2878
#endif
2879
        GtkWidget *frame_extsend;
2880
        GtkWidget *vbox_extsend;
2881
        GtkWidget *checkbtn_extsend;
2882
        GtkWidget *label_extsend;
2883
        GtkWidget *entry_extsend;
2884

    
2885
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2886
        gtk_widget_show (vbox1);
2887

    
2888
        PACK_FRAME(vbox1, ext_frame,
2889
                   _("External commands (%s will be replaced with file name / URI)"));
2890

    
2891
        ext_table = gtk_table_new (2, 2, FALSE);
2892
        gtk_widget_show (ext_table);
2893
        gtk_container_add (GTK_CONTAINER (ext_frame), ext_table);
2894
        gtk_container_set_border_width (GTK_CONTAINER (ext_table), 8);
2895
        gtk_table_set_row_spacings (GTK_TABLE (ext_table), VSPACING_NARROW);
2896
        gtk_table_set_col_spacings (GTK_TABLE (ext_table), 8);
2897

    
2898
        uri_label = gtk_label_new (_("Web browser"));
2899
        gtk_widget_show(uri_label);
2900
        gtk_table_attach (GTK_TABLE (ext_table), uri_label, 0, 1, 0, 1,
2901
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2902
        gtk_misc_set_alignment (GTK_MISC (uri_label), 1, 0.5);
2903

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

    
2924
        exteditor_label = gtk_label_new (_("Editor"));
2925
        gtk_widget_show (exteditor_label);
2926
        gtk_table_attach (GTK_TABLE (ext_table), exteditor_label, 0, 1, 1, 2,
2927
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2928
        gtk_misc_set_alignment (GTK_MISC (exteditor_label), 1, 0.5);
2929

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

    
2950
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_printcmd, checkbtn_printcmd,
2951
                                     _("Use external program for printing"));
2952

    
2953
        vbox_printcmd = gtk_vbox_new (FALSE, VSPACING_NARROW);
2954
        gtk_widget_show (vbox_printcmd);
2955
        gtk_container_add (GTK_CONTAINER (frame_printcmd), vbox_printcmd);
2956
        gtk_container_set_border_width (GTK_CONTAINER (vbox_printcmd), 8);
2957
        SET_TOGGLE_SENSITIVITY (checkbtn_printcmd, vbox_printcmd);
2958

    
2959
        hbox1 = gtk_hbox_new (FALSE, 8);
2960
        gtk_widget_show (hbox1);
2961
        gtk_box_pack_start (GTK_BOX (vbox_printcmd), hbox1, FALSE, FALSE, 0);
2962

    
2963
        printcmd_label = gtk_label_new (_("Command"));
2964
        gtk_widget_show (printcmd_label);
2965
        gtk_box_pack_start (GTK_BOX (hbox1), printcmd_label, FALSE, FALSE, 0);
2966

    
2967
        printcmd_entry = gtk_entry_new ();
2968
        gtk_widget_show (printcmd_entry);
2969
        gtk_box_pack_start (GTK_BOX (hbox1), printcmd_entry, TRUE, TRUE, 0);
2970

    
2971
#ifndef G_OS_WIN32
2972
        PACK_FRAME_WITH_CHECK_BUTTON(vbox1, frame_incext, checkbtn_incext,
2973
                                     _("Use external program for incorporation"));
2974

    
2975
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2976
        gtk_widget_show (vbox2);
2977
        gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
2978
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2979
        SET_TOGGLE_SENSITIVITY (checkbtn_incext, vbox2);
2980

    
2981
        hbox1 = gtk_hbox_new (FALSE, 8);
2982
        gtk_widget_show (hbox1);
2983
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2984

    
2985
        label_incext = gtk_label_new (_("Command"));
2986
        gtk_widget_show (label_incext);
2987
        gtk_box_pack_start (GTK_BOX (hbox1), label_incext, FALSE, FALSE, 0);
2988

    
2989
        entry_incext = gtk_entry_new ();
2990
        gtk_widget_show (entry_incext);
2991
        gtk_box_pack_start (GTK_BOX (hbox1), entry_incext, TRUE, TRUE, 0);
2992
#endif /* !G_OS_WIN32 */
2993

    
2994
        PACK_FRAME_WITH_CHECK_BUTTON (vbox1, frame_extsend, checkbtn_extsend,
2995
                                      _("Use external program for sending"));
2996

    
2997
        vbox_extsend = gtk_vbox_new (FALSE, VSPACING_NARROW);
2998
        gtk_widget_show (vbox_extsend);
2999
        gtk_container_add (GTK_CONTAINER (frame_extsend), vbox_extsend);
3000
        gtk_container_set_border_width (GTK_CONTAINER (vbox_extsend), 8);
3001
        SET_TOGGLE_SENSITIVITY(checkbtn_extsend, vbox_extsend);
3002

    
3003
        hbox1 = gtk_hbox_new (FALSE, 8);
3004
        gtk_widget_show (hbox1);
3005
        gtk_box_pack_start (GTK_BOX (vbox_extsend), hbox1, FALSE, FALSE, 0);
3006

    
3007
        label_extsend = gtk_label_new (_("Command"));
3008
        gtk_widget_show (label_extsend);
3009
        gtk_box_pack_start (GTK_BOX (hbox1), label_extsend, FALSE, FALSE, 0);
3010

    
3011
        entry_extsend = gtk_entry_new ();
3012
        gtk_widget_show (entry_extsend);
3013
        gtk_box_pack_start (GTK_BOX (hbox1), entry_extsend, TRUE, TRUE, 0);
3014

    
3015
        extcmd.uri_combo = uri_combo;
3016
        extcmd.uri_entry = uri_entry;
3017
        extcmd.checkbtn_printcmd = checkbtn_printcmd;
3018
        extcmd.printcmd_entry = printcmd_entry;
3019

    
3020
        extcmd.exteditor_combo = exteditor_combo;
3021
        extcmd.exteditor_entry = exteditor_entry;
3022

    
3023
#ifndef G_OS_WIN32
3024
        extcmd.checkbtn_incext = checkbtn_incext;
3025
        extcmd.entry_incext    = entry_incext;
3026
#endif
3027
        extcmd.checkbtn_extsend = checkbtn_extsend;
3028
        extcmd.entry_extsend    = entry_extsend;
3029

    
3030
        return vbox1;
3031
}
3032

    
3033
#if USE_UPDATE_CHECK
3034
static GtkWidget *prefs_update_create(void)
3035
{
3036
        GtkWidget *vbox1;
3037
        GtkWidget *vbox2;
3038
        GtkWidget *checkbtn_autoupdate;
3039
        GtkWidget *checkbtn_useproxy;
3040
        GtkWidget *label;
3041
        GtkWidget *entry_proxyhost;
3042

    
3043
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3044
        gtk_widget_show (vbox1);
3045

    
3046
#ifndef G_OS_WIN32
3047
        label = gtk_label_new (_("Update check requires 'curl' command."));
3048
        gtk_widget_show (label);
3049
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
3050
        gtk_box_pack_start (GTK_BOX (vbox1), label, FALSE, FALSE, 0);
3051
#endif
3052

    
3053
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
3054
        gtk_widget_show (vbox2);
3055
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3056

    
3057
        PACK_CHECK_BUTTON (vbox2, checkbtn_autoupdate,
3058
                           _("Enable auto update check"));
3059
        PACK_CHECK_BUTTON (vbox2, checkbtn_useproxy,
3060
                           _("Use HTTP proxy"));
3061

    
3062
        label = gtk_label_new (_("HTTP proxy host (hostname:port):"));
3063
        gtk_widget_show (label);
3064
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
3065
        gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0);
3066

    
3067
        entry_proxyhost = gtk_entry_new ();
3068
        gtk_widget_show (entry_proxyhost);
3069
        gtk_box_pack_start (GTK_BOX (vbox2), entry_proxyhost, FALSE, FALSE, 0);
3070

    
3071
        SET_TOGGLE_SENSITIVITY(checkbtn_useproxy, label);
3072
        SET_TOGGLE_SENSITIVITY(checkbtn_useproxy, entry_proxyhost);
3073

    
3074
        update_check.checkbtn_autoupdate = checkbtn_autoupdate;
3075
        update_check.checkbtn_useproxy = checkbtn_useproxy;
3076
        update_check.entry_proxyhost = entry_proxyhost;
3077

    
3078
        return vbox1;
3079
}
3080
#endif /* USE_UPDATE_CHECK */
3081

    
3082
static GtkWidget *prefs_advanced_create(void)
3083
{
3084
        GtkWidget *vbox1;
3085

    
3086
        GtkWidget *vbox2;
3087
        GtkWidget *checkbtn_strict_cache_check;
3088
        GtkWidget *label;
3089

    
3090
        GtkWidget *hbox1;
3091
        GtkWidget *label_iotimeout;
3092
        GtkWidget *spinbtn_iotimeout;
3093
        GtkObject *spinbtn_iotimeout_adj;
3094

    
3095
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3096
        gtk_widget_show (vbox1);
3097

    
3098
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
3099
        gtk_widget_show (vbox2);
3100
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3101

    
3102
        PACK_CHECK_BUTTON (vbox2, checkbtn_strict_cache_check,
3103
                           _("Enable strict checking of the integrity of summary caches"));
3104
        PACK_SMALL_LABEL
3105
                (vbox2, label,
3106
                 _("Enable this if the contents of folders have the possibility of modification by other applications.\n"
3107
                   "This option will degrade the performance of displaying summary."));
3108

    
3109
        hbox1 = gtk_hbox_new (FALSE, 8);
3110
        gtk_widget_show (hbox1);
3111
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3112

    
3113
        label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
3114
        gtk_widget_show (label_iotimeout);
3115
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
3116

    
3117
        spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 0);
3118
        spinbtn_iotimeout = gtk_spin_button_new
3119
                (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
3120
        gtk_widget_show (spinbtn_iotimeout);
3121
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
3122
                            FALSE, FALSE, 0);
3123
        gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
3124
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
3125

    
3126
        label_iotimeout = gtk_label_new (_("second(s)"));
3127
        gtk_widget_show (label_iotimeout);
3128
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
3129

    
3130
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
3131
        gtk_widget_show (vbox2);
3132
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3133

    
3134
        advanced.checkbtn_strict_cache_check = checkbtn_strict_cache_check;
3135

    
3136
        advanced.spinbtn_iotimeout     = spinbtn_iotimeout;
3137
        advanced.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
3138

    
3139
        return vbox1;
3140
}
3141

    
3142
static void prefs_common_set_encoding_optmenu(GtkOptionMenu *optmenu,
3143
                                              gboolean outgoing)
3144
{
3145
        GtkWidget *menu;
3146
        GtkWidget *menuitem;
3147

    
3148
        menu = gtk_menu_new();
3149

    
3150
#define SET_MENUITEM(str, data) \
3151
        MENUITEM_ADD(menu, menuitem, str, data)
3152

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

    
3210
#undef SET_MENUITEM
3211

    
3212
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
3213
}
3214

    
3215
static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
3216
{
3217
        GtkWidget *datefmt_sample = NULL;
3218
        gchar *text;
3219

    
3220
        g_return_if_fail(widget != NULL);
3221
        g_return_if_fail(*widget != NULL);
3222
        g_return_if_fail(display.entry_datefmt != NULL);
3223

    
3224
        datefmt_sample = GTK_WIDGET(g_object_get_data
3225
                                    (G_OBJECT(*widget), "datefmt_sample"));
3226
        g_return_if_fail(datefmt_sample != NULL);
3227

    
3228
        text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
3229
        g_free(prefs_common.date_format);
3230
        prefs_common.date_format = text;
3231
        gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
3232

    
3233
        gtk_widget_destroy(*widget);
3234
        *widget = NULL;
3235
}
3236

    
3237
static void date_format_cancel_btn_clicked(GtkButton *button,
3238
                                           GtkWidget **widget)
3239
{
3240
        g_return_if_fail(widget != NULL);
3241
        g_return_if_fail(*widget != NULL);
3242

    
3243
        gtk_widget_destroy(*widget);
3244
        *widget = NULL;
3245
}
3246

    
3247
static gboolean date_format_key_pressed(GtkWidget *keywidget,
3248
                                        GdkEventKey *event,
3249
                                        GtkWidget **widget)
3250
{
3251
        if (event && event->keyval == GDK_Escape)
3252
                date_format_cancel_btn_clicked(NULL, widget);
3253
        return FALSE;
3254
}
3255

    
3256
static gboolean date_format_on_delete(GtkWidget *dialogwidget,
3257
                                      GdkEventAny *event, GtkWidget **widget)
3258
{
3259
        g_return_val_if_fail(widget != NULL, FALSE);
3260
        g_return_val_if_fail(*widget != NULL, FALSE);
3261

    
3262
        *widget = NULL;
3263
        return FALSE;
3264
}
3265

    
3266
static void date_format_entry_on_change(GtkEditable *editable,
3267
                                        GtkLabel *example)
3268
{
3269
        time_t cur_time;
3270
        struct tm *cal_time;
3271
        gchar buffer[100];
3272
        gchar *text;
3273

    
3274
        cur_time = time(NULL);
3275
        cal_time = localtime(&cur_time);
3276
        buffer[0] = 0;
3277
        text = gtk_editable_get_chars(editable, 0, -1);
3278
        if (text)
3279
                strftime(buffer, sizeof buffer, text, cal_time); 
3280
        g_free(text);
3281

    
3282
        text = conv_codeset_strdup(buffer, conv_get_locale_charset_str(),
3283
                                   CS_UTF_8);
3284
        if (!text)
3285
                text = g_strdup(buffer);
3286
        gtk_label_set_text(example, text);
3287
        g_free(text);
3288
}
3289

    
3290
static void date_format_select_row(GtkWidget *date_format_list, gint row,
3291
                                   gint column, GdkEventButton *event,
3292
                                   GtkWidget *date_format)
3293
{
3294
        gint cur_pos;
3295
        gchar *format;
3296
        const gchar *old_format;
3297
        gchar *new_format;
3298
        GtkWidget *datefmt_sample;
3299

    
3300
        /* only on double click */
3301
        if (!event || event->type != GDK_2BUTTON_PRESS) return;
3302

    
3303
        datefmt_sample = GTK_WIDGET(g_object_get_data
3304
                                    (G_OBJECT(date_format), "datefmt_sample"));
3305

    
3306
        g_return_if_fail(date_format_list != NULL);
3307
        g_return_if_fail(date_format != NULL);
3308
        g_return_if_fail(datefmt_sample != NULL);
3309

    
3310
        /* get format from clist */
3311
        gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
3312

    
3313
        cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
3314
        old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
3315

    
3316
        /* insert the format into the text entry */
3317
        new_format = g_malloc(strlen(old_format) + 3);
3318

    
3319
        strncpy(new_format, old_format, cur_pos);
3320
        new_format[cur_pos] = '\0';
3321
        strcat(new_format, format);
3322
        strcat(new_format, &old_format[cur_pos]);
3323

    
3324
        gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
3325
        gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
3326

    
3327
        g_free(new_format);
3328
}
3329

    
3330
static GtkWidget *date_format_create(GtkButton *button, void *data)
3331
{
3332
        static GtkWidget *datefmt_win = NULL;
3333
        GtkWidget *vbox1;
3334
        GtkWidget *scrolledwindow1;
3335
        GtkWidget *datefmt_clist;
3336
        GtkWidget *table;
3337
        GtkWidget *label1;
3338
        GtkWidget *label2;
3339
        GtkWidget *label3;
3340
        GtkWidget *confirm_area;
3341
        GtkWidget *ok_btn;
3342
        GtkWidget *cancel_btn;
3343
        GtkWidget *datefmt_entry;
3344

    
3345
        struct {
3346
                gchar *fmt;
3347
                gchar *txt;
3348
        } time_format[] = {
3349
                { "%a", NULL },
3350
                { "%A", NULL },
3351
                { "%b", NULL },
3352
                { "%B", NULL },
3353
                { "%c", NULL },
3354
                { "%C", NULL },
3355
                { "%d", NULL },
3356
                { "%H", NULL },
3357
                { "%I", NULL },
3358
                { "%j", NULL },
3359
                { "%m", NULL },
3360
                { "%M", NULL },
3361
                { "%p", NULL },
3362
                { "%S", NULL },
3363
                { "%w", NULL },
3364
                { "%x", NULL },
3365
                { "%y", NULL },
3366
                { "%Y", NULL },
3367
                { "%Z", NULL }
3368
        };
3369

    
3370
        gchar *titles[2];
3371
        gint i;
3372
        const gint TIME_FORMAT_ELEMS =
3373
                sizeof time_format / sizeof time_format[0];
3374

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

    
3395
        if (datefmt_win) return datefmt_win;
3396

    
3397
        datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3398
        gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
3399
        gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
3400
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3401
        gtk_widget_set_size_request(datefmt_win, 440, 280);
3402

    
3403
        vbox1 = gtk_vbox_new(FALSE, 10);
3404
        gtk_widget_show(vbox1);
3405
        gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
3406

    
3407
        scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
3408
        gtk_scrolled_window_set_policy
3409
                (GTK_SCROLLED_WINDOW(scrolledwindow1),
3410
                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3411
        gtk_widget_show(scrolledwindow1);
3412
        gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
3413

    
3414
        titles[0] = _("Specifier");
3415
        titles[1] = _("Description");
3416
        datefmt_clist = gtk_clist_new_with_titles(2, titles);
3417
        gtk_widget_show(datefmt_clist);
3418
        gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
3419
        /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
3420
        gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
3421
                                     GTK_SELECTION_BROWSE);
3422

    
3423
        for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
3424
                gchar *text[2];
3425
                /* phoney casting necessary because of gtk... */
3426
                text[0] = (gchar *)time_format[i].fmt;
3427
                text[1] = (gchar *)time_format[i].txt;
3428
                gtk_clist_append(GTK_CLIST(datefmt_clist), text);
3429
        }
3430

    
3431
        table = gtk_table_new(2, 2, FALSE);
3432
        gtk_widget_show(table);
3433
        gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
3434
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
3435
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
3436

    
3437
        label1 = gtk_label_new(_("Date format"));
3438
        gtk_widget_show(label1);
3439
        gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
3440
                         GTK_FILL, 0, 0, 0);
3441
        gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
3442
        gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
3443

    
3444
        datefmt_entry = gtk_entry_new();
3445
        gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
3446
        gtk_widget_show(datefmt_entry);
3447
        gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
3448
                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3449

    
3450
        /* we need the "sample" entry box; add it as data so callbacks can
3451
         * get the entry box */
3452
        g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
3453
                          datefmt_entry);
3454

    
3455
        label2 = gtk_label_new(_("Example"));
3456
        gtk_widget_show(label2);
3457
        gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
3458
                         GTK_FILL, 0, 0, 0);
3459
        gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
3460
        gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
3461

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

    
3469
        gtkut_stock_button_set_create(&confirm_area, &ok_btn, GTK_STOCK_OK,
3470
                                &cancel_btn, GTK_STOCK_CANCEL, NULL, NULL);
3471

    
3472
        gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
3473
        gtk_widget_show(confirm_area);
3474
        gtk_widget_grab_default(ok_btn);
3475

    
3476
        /* set the current format */
3477
        gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
3478
        date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
3479
                                    GTK_LABEL(label3));
3480

    
3481
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3482
                         G_CALLBACK(date_format_ok_btn_clicked), &datefmt_win);
3483
        g_signal_connect(G_OBJECT(cancel_btn), "clicked",
3484
                         G_CALLBACK(date_format_cancel_btn_clicked),
3485
                         &datefmt_win);
3486
        g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
3487
                         G_CALLBACK(date_format_key_pressed), &datefmt_win);
3488
        g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
3489
                         G_CALLBACK(date_format_on_delete), &datefmt_win);
3490
        g_signal_connect(G_OBJECT(datefmt_entry), "changed",
3491
                         G_CALLBACK(date_format_entry_on_change), label3);
3492
        g_signal_connect(G_OBJECT(datefmt_clist), "select_row",
3493
                         G_CALLBACK(date_format_select_row), datefmt_win);
3494

    
3495
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3496
        gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
3497

    
3498
        gtk_widget_show(datefmt_win);
3499
        manage_window_set_transient(GTK_WINDOW(datefmt_win));
3500

    
3501
        gtk_widget_grab_focus(ok_btn);
3502

    
3503
        return datefmt_win;
3504
}
3505

    
3506
void prefs_quote_colors_dialog(void)
3507
{
3508
        if (!quote_color_win)
3509
                prefs_quote_colors_dialog_create();
3510
        gtk_widget_show(quote_color_win);
3511
        manage_window_set_transient(GTK_WINDOW(quote_color_win));
3512

    
3513
        gtk_main();
3514
        gtk_widget_hide(quote_color_win);
3515
        gtk_window_present(GTK_WINDOW(dialog.window));
3516

    
3517
        main_window_reflect_prefs_all();
3518
}
3519

    
3520
static void prefs_quote_colors_dialog_create(void)
3521
{
3522
        GtkWidget *window;
3523
        GtkWidget *vbox;
3524
        GtkWidget *table;
3525
        GtkWidget *quotelevel1_label;
3526
        GtkWidget *quotelevel2_label;
3527
        GtkWidget *quotelevel3_label;
3528
        GtkWidget *uri_label;
3529
        GtkWidget *hbbox;
3530
        GtkWidget *ok_btn;
3531
        GtkWidget *recycle_colors_btn;
3532
        GtkWidget *frame_colors;
3533

    
3534
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3535
        gtk_container_set_border_width(GTK_CONTAINER(window), 2);
3536
        gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
3537
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
3538
        gtk_window_set_modal(GTK_WINDOW(window), TRUE);
3539
        gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
3540

    
3541
        vbox = gtk_vbox_new (FALSE, VSPACING);
3542
        gtk_container_add (GTK_CONTAINER (window), vbox);
3543
        gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
3544
        PACK_FRAME(vbox, frame_colors, _("Colors"));
3545

    
3546
        table = gtk_table_new (4, 2, FALSE);
3547
        gtk_container_add (GTK_CONTAINER (frame_colors), table);
3548
        gtk_container_set_border_width (GTK_CONTAINER (table), 8);
3549
        gtk_table_set_row_spacings (GTK_TABLE (table), 2);
3550
        gtk_table_set_col_spacings (GTK_TABLE (table), 4);
3551

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

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

    
3565
        color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
3566
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
3567
                          0, 1, 2, 3, 0, 0, 0, 0);
3568
        gtk_widget_set_size_request (color_buttons.quote_level3_btn, 40, 30);
3569
        gtk_container_set_border_width
3570
                (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
3571

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

    
3578
        quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
3579
        gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
3580
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3581
        gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
3582
        gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
3583

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

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

    
3596
        uri_label = gtk_label_new (_("URI link"));
3597
        gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
3598
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3599
        gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
3600
        gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
3601

    
3602
        PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
3603
                           _("Recycle quote colors"));
3604

    
3605
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
3606
                                      NULL, NULL, NULL, NULL);
3607
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3608

    
3609
        gtk_widget_grab_default(ok_btn);
3610
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
3611
        g_signal_connect (G_OBJECT (window), "delete_event",
3612
                          G_CALLBACK (prefs_quote_colors_deleted), NULL);
3613
        g_signal_connect(G_OBJECT(window), "key_press_event",
3614
                         G_CALLBACK(prefs_quote_colors_key_pressed), NULL);
3615

    
3616
        g_signal_connect(G_OBJECT(color_buttons.quote_level1_btn), "clicked",
3617
                         G_CALLBACK(quote_color_set_dialog), "LEVEL1");
3618
        g_signal_connect(G_OBJECT(color_buttons.quote_level2_btn), "clicked",
3619
                         G_CALLBACK(quote_color_set_dialog), "LEVEL2");
3620
        g_signal_connect(G_OBJECT(color_buttons.quote_level3_btn), "clicked",
3621
                         G_CALLBACK(quote_color_set_dialog), "LEVEL3");
3622
        g_signal_connect(G_OBJECT(color_buttons.uri_btn), "clicked",
3623
                         G_CALLBACK(quote_color_set_dialog), "URI");
3624
        g_signal_connect(G_OBJECT(recycle_colors_btn), "toggled",
3625
                         G_CALLBACK(prefs_recycle_colors_toggled), NULL);
3626
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3627
                         G_CALLBACK(gtk_main_quit), NULL);
3628

    
3629
        /* show message button colors and recycle options */
3630
        set_button_bg_color(color_buttons.quote_level1_btn,
3631
                            prefs_common.quote_level1_col);
3632
        set_button_bg_color(color_buttons.quote_level2_btn,
3633
                            prefs_common.quote_level2_col);
3634
        set_button_bg_color(color_buttons.quote_level3_btn,
3635
                            prefs_common.quote_level3_col);
3636
        set_button_bg_color(color_buttons.uri_btn,
3637
                            prefs_common.uri_col);
3638
        gtk_toggle_button_set_active((GtkToggleButton *)recycle_colors_btn,
3639
                                     prefs_common.recycle_quote_colors);
3640

    
3641
        gtk_widget_show_all(vbox);
3642
        quote_color_win = window;
3643
}
3644

    
3645
static gint prefs_quote_colors_deleted(GtkWidget *widet, GdkEventAny *event,
3646
                                       gpointer data)
3647
{
3648
        gtk_main_quit();
3649
        return TRUE;
3650
}
3651

    
3652
static gboolean prefs_quote_colors_key_pressed(GtkWidget *widget,
3653
                                               GdkEventKey *event,
3654
                                               gpointer data)
3655
{
3656
        if (event && event->keyval == GDK_Escape)
3657
                gtk_main_quit();
3658
        return FALSE;
3659
}
3660

    
3661
static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
3662
{
3663
        gchar *type = (gchar *)data;
3664
        gchar *title = NULL;
3665
        gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
3666
        gint rgbvalue = 0;
3667
        GtkColorSelectionDialog *dialog;
3668

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

    
3686
        color_dialog = gtk_color_selection_dialog_new(title);
3687
        gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
3688
        gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
3689
        gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
3690
        manage_window_set_transient(GTK_WINDOW(color_dialog));
3691

    
3692
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
3693
                         "clicked", G_CALLBACK(quote_colors_set_dialog_ok), data);
3694
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
3695
                         "clicked", G_CALLBACK(quote_colors_set_dialog_cancel), data);
3696
        g_signal_connect(G_OBJECT(color_dialog), "key_press_event",
3697
                         G_CALLBACK(quote_colors_set_dialog_key_pressed), data);
3698

    
3699
        /* preselect the previous color in the color selection dialog */
3700
        color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
3701
        color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
3702
        color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
3703
        dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
3704
        gtk_color_selection_set_color
3705
                (GTK_COLOR_SELECTION(dialog->colorsel), color);
3706

    
3707
        gtk_widget_show(color_dialog);
3708
}
3709

    
3710
static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
3711
{
3712
        GtkColorSelection *colorsel = (GtkColorSelection *)
3713
                                                ((GtkColorSelectionDialog *)color_dialog)->colorsel;
3714
        gdouble color[4];
3715
        gint red, green, blue, rgbvalue;
3716
        gchar *type = (gchar *)data;
3717

    
3718
        gtk_color_selection_get_color(colorsel, color);
3719

    
3720
        red      = (gint) (color[0] * 255.0);
3721
        green    = (gint) (color[1] * 255.0);
3722
        blue     = (gint) (color[2] * 255.0);
3723
        rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
3724

    
3725
#if 0
3726
        fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
3727
        fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
3728
        fprintf(stderr, "Color is %x\n", rgbvalue);
3729
#endif
3730

    
3731
        if (g_ascii_strcasecmp(type, "LEVEL1") == 0) {
3732
                prefs_common.quote_level1_col = rgbvalue;
3733
                set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
3734
        } else if (g_ascii_strcasecmp(type, "LEVEL2") == 0) {
3735
                prefs_common.quote_level2_col = rgbvalue;
3736
                set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
3737
        } else if (g_ascii_strcasecmp(type, "LEVEL3") == 0) {
3738
                prefs_common.quote_level3_col = rgbvalue;
3739
                set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
3740
        } else if (g_ascii_strcasecmp(type, "URI") == 0) {
3741
                prefs_common.uri_col = rgbvalue;
3742
                set_button_bg_color(color_buttons.uri_btn, rgbvalue);
3743
        } else
3744
                fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
3745

    
3746
        gtk_widget_destroy(color_dialog);
3747
}
3748

    
3749
static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
3750
{
3751
        gtk_widget_destroy(color_dialog);
3752
}
3753

    
3754
static gboolean quote_colors_set_dialog_key_pressed(GtkWidget *widget,
3755
                                                    GdkEventKey *event,
3756
                                                    gpointer data)
3757
{
3758
        if (event && event->keyval == GDK_Escape) {
3759
                gtk_widget_destroy(color_dialog);
3760
                return TRUE;
3761
        }
3762
        return FALSE;
3763
}
3764

    
3765
static void set_button_bg_color(GtkWidget *widget, gint rgbvalue)
3766
{
3767
        GtkStyle *newstyle;
3768
        GdkColor color;
3769

    
3770
        gtkut_convert_int_to_gdk_color(rgbvalue, &color);
3771
        newstyle = gtk_style_copy(gtk_widget_get_default_style());
3772
        newstyle->bg[GTK_STATE_NORMAL]   = color;
3773
        newstyle->bg[GTK_STATE_PRELIGHT] = color;
3774
        newstyle->bg[GTK_STATE_ACTIVE]   = color;
3775

    
3776
        gtk_widget_set_style(GTK_WIDGET(widget), newstyle);
3777
}
3778

    
3779
static void prefs_enable_message_color_toggled(void)
3780
{
3781
        gboolean is_active;
3782

    
3783
        is_active = gtk_toggle_button_get_active
3784
                (GTK_TOGGLE_BUTTON(message.chkbtn_enablecol));
3785
        gtk_widget_set_sensitive(message.button_edit_col, is_active);
3786
        prefs_common.enable_color = is_active;
3787
}
3788

    
3789
static void prefs_recycle_colors_toggled(GtkWidget *widget)
3790
{
3791
        gboolean is_active;
3792

    
3793
        is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3794
        prefs_common.recycle_quote_colors = is_active;
3795
}
3796

    
3797
void prefs_quote_description(void)
3798
{
3799
        if (!quote_desc_win)
3800
                prefs_quote_description_create();
3801

    
3802
        manage_window_set_transient(GTK_WINDOW(quote_desc_win));
3803
        gtk_widget_show(quote_desc_win);
3804
        gtk_main();
3805
        gtk_widget_hide(quote_desc_win);
3806
}
3807

    
3808
static void prefs_quote_description_create(void)
3809
{
3810
        GtkWidget *vbox;
3811
        GtkWidget *hbox;
3812
        GtkWidget *vbox2;
3813
        GtkWidget *label;
3814
        GtkWidget *hbbox;
3815
        GtkWidget *ok_btn;
3816

    
3817
        quote_desc_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3818
        gtk_window_set_title(GTK_WINDOW(quote_desc_win),
3819
                             _("Description of symbols"));
3820
        gtk_container_set_border_width(GTK_CONTAINER(quote_desc_win), 8);
3821
        gtk_window_set_position(GTK_WINDOW(quote_desc_win), GTK_WIN_POS_CENTER);
3822
        gtk_window_set_modal(GTK_WINDOW(quote_desc_win), TRUE);
3823
        gtk_window_set_policy(GTK_WINDOW(quote_desc_win), FALSE, FALSE, FALSE);
3824

    
3825
        vbox = gtk_vbox_new(FALSE, 8);
3826
        gtk_container_add(GTK_CONTAINER(quote_desc_win), vbox);
3827

    
3828
        hbox = gtk_hbox_new(FALSE, 8);
3829
        gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
3830

    
3831
        vbox2 = gtk_vbox_new(FALSE, 8);
3832
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
3833

    
3834
#define PACK_LABEL() \
3835
        gtk_box_pack_start(GTK_BOX(vbox2), label, TRUE, TRUE, 0); \
3836
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); \
3837
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
3838

    
3839
        label = gtk_label_new
3840
                ("%d\n"                /* date */
3841
                 "%f\n"                /* from */
3842
                 "%N\n"                /* full name of sender */
3843
                 "%F\n"                /* first name of sender */
3844
                 "%I\n"                /* initial of sender */
3845
                 "%s\n"                /* subject */
3846
                 "%t\n"                /* to */
3847
                 "%c\n"                /* cc */
3848
                 "%n\n"                /* newsgroups */
3849
                 "%i");                /* message id */
3850
        PACK_LABEL();
3851

    
3852
        label = gtk_label_new
3853
                ("?x{expr}");        /* condition */
3854
        PACK_LABEL();
3855

    
3856
        label = gtk_label_new
3857
                ("%M\n"                /* message body */
3858
                 "%Q\n"                /* quoted message body */
3859
                 "%m\n"                /* message body without signature */
3860
                 "%q\n"                /* quoted message body without signature */
3861
                 "%%");                /* literal percent */
3862
        PACK_LABEL();
3863

    
3864
        label = gtk_label_new
3865
                ("\\\\\n"        /* literal backslash */
3866
                 "\\?\n"        /* literal question mark */
3867
                 "\\{\n"        /* literal opening curly brace */
3868
                 "\\}");        /* literal closing curly brace */
3869
        PACK_LABEL();
3870

    
3871
        vbox2 = gtk_vbox_new(FALSE, 8);
3872
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
3873

    
3874
        label = gtk_label_new
3875
                (_("Date\n"
3876
                   "From\n"
3877
                   "Full Name of Sender\n"
3878
                   "First Name of Sender\n"
3879
                   "Initial of Sender\n"
3880
                   "Subject\n"
3881
                   "To\n"
3882
                   "Cc\n"
3883
                   "Newsgroups\n"
3884
                   "Message-ID"));
3885
        PACK_LABEL();
3886

    
3887
        label = gtk_label_new
3888
                (_("If x is set, displays expr"));
3889
        PACK_LABEL();
3890

    
3891
        label = gtk_label_new
3892
                (_("Message body\n"
3893
                   "Quoted message body\n"
3894
                   "Message body without signature\n"
3895
                   "Quoted message body without signature\n"
3896
                   "Literal %"));
3897
        PACK_LABEL();
3898

    
3899
        label = gtk_label_new
3900
                (_("Literal backslash\n"
3901
                   "Literal question mark\n"
3902
                   "Literal opening curly brace\n"
3903
                   "Literal closing curly brace"));
3904
        PACK_LABEL();
3905

    
3906
#undef PACK_LABEL
3907

    
3908
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
3909
                                      NULL, NULL, NULL, NULL);
3910
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3911

    
3912
        gtk_widget_grab_default(ok_btn);
3913
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
3914
                         G_CALLBACK(gtk_main_quit), NULL);
3915
        g_signal_connect
3916
                (G_OBJECT(quote_desc_win), "key_press_event",
3917
                 G_CALLBACK(prefs_quote_description_key_pressed), NULL);
3918
        g_signal_connect(G_OBJECT(quote_desc_win), "delete_event",
3919
                         G_CALLBACK(prefs_quote_description_deleted), NULL);
3920

    
3921
        gtk_widget_show_all(vbox);
3922
}
3923

    
3924
static gboolean prefs_quote_description_key_pressed(GtkWidget *widget,
3925
                                                    GdkEventKey *event,
3926
                                                    gpointer data)
3927
{
3928
        if (event && event->keyval == GDK_Escape)
3929
                gtk_main_quit();
3930
        return FALSE;
3931
}
3932

    
3933
static gboolean prefs_quote_description_deleted(GtkWidget *widget,
3934
                                                GdkEventAny *event,
3935
                                                gpointer data)
3936
{
3937
        gtk_main_quit();
3938
        return TRUE;
3939
}
3940

    
3941
static void prefs_keybind_select(void)
3942
{
3943
        GtkWidget *window;
3944
        GtkWidget *vbox1;
3945
        GtkWidget *hbox1;
3946
        GtkWidget *label;
3947
        GtkWidget *combo;
3948
        GtkWidget *confirm_area;
3949
        GtkWidget *ok_btn;
3950
        GtkWidget *cancel_btn;
3951

    
3952
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3953
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
3954
        gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
3955
        gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
3956
        gtk_window_set_modal (GTK_WINDOW (window), TRUE);
3957
        gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, FALSE);
3958
        manage_window_set_transient (GTK_WINDOW (window));
3959

    
3960
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3961
        gtk_container_add (GTK_CONTAINER (window), vbox1);
3962
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
3963

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

    
3967
        label = gtk_label_new(_("Select the preset of key bindings."));
3968
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
3969
        gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3970

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

    
3974
        combo = gtk_combo_new ();
3975
        gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
3976
        gtkut_combo_set_items (GTK_COMBO (combo),
3977
                               _("Default"),
3978
                               "Mew / Wanderlust",
3979
                               "Mutt",
3980
                               _("Old Sylpheed"),
3981
                               NULL);
3982
        gtk_editable_set_editable
3983
                (GTK_EDITABLE (GTK_COMBO (combo)->entry), FALSE);
3984

    
3985
        hbox1 = gtk_hbox_new (FALSE, 8);
3986
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3987

    
3988
        gtkut_stock_button_set_create (&confirm_area, &ok_btn, GTK_STOCK_OK,
3989
                                       &cancel_btn, GTK_STOCK_CANCEL,
3990
                                       NULL, NULL);
3991
        gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
3992
        gtk_widget_grab_default (ok_btn);
3993

    
3994
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
3995
        g_signal_connect (G_OBJECT (window), "delete_event",
3996
                          G_CALLBACK (prefs_keybind_deleted), NULL);
3997
        g_signal_connect (G_OBJECT (window), "key_press_event",
3998
                          G_CALLBACK (prefs_keybind_key_pressed), NULL);
3999
        g_signal_connect (G_OBJECT (ok_btn), "clicked",
4000
                          G_CALLBACK (prefs_keybind_apply_clicked), NULL);
4001
        g_signal_connect (G_OBJECT (cancel_btn), "clicked",
4002
                          G_CALLBACK (prefs_keybind_cancel), NULL);
4003

    
4004
        gtk_widget_show_all(window);
4005

    
4006
        keybind.window = window;
4007
        keybind.combo = combo;
4008
}
4009

    
4010
static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
4011
                                          gpointer data)
4012
{
4013
        if (event && event->keyval == GDK_Escape)
4014
                prefs_keybind_cancel();
4015
        return FALSE;
4016
}
4017

    
4018
static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
4019
                                  gpointer data)
4020
{
4021
        prefs_keybind_cancel();
4022
        return TRUE;
4023
}
4024

    
4025
static void prefs_keybind_cancel(void)
4026
{
4027
        gtk_widget_destroy(keybind.window);
4028
        keybind.window = NULL;
4029
        keybind.combo = NULL;
4030
}
4031

    
4032
struct KeyBind {
4033
        const gchar *accel_path;
4034
        const gchar *accel_key;
4035
};
4036

    
4037
static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
4038
{
4039
        gint i;
4040
        guint key;
4041
        GdkModifierType mods;
4042

    
4043
        for (i = 0; i < num; i++) {
4044
                const gchar *accel_key =
4045
                        keybind[i].accel_key ? keybind[i].accel_key : "";
4046
                gtk_accelerator_parse(accel_key, &key, &mods);
4047
                gtk_accel_map_change_entry(keybind[i].accel_path,
4048
                                           key, mods, TRUE);
4049
        }
4050
}
4051

    
4052
static void prefs_keybind_apply_clicked(GtkWidget *widget)
4053
{
4054
        GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
4055
        const gchar *text;
4056
        struct KeyBind *menurc;
4057
        gint n_menurc;
4058

    
4059
        static struct KeyBind default_menurc[] = {
4060
                {"<Main>/File/Empty all trash",                        ""},
4061
                {"<Main>/File/Save as...",                        "<control>S"},
4062
                {"<Main>/File/Print...",                        ""},
4063
                {"<Main>/File/Exit",                                "<control>Q"},
4064

    
4065
                {"<Main>/Edit/Copy",                                "<control>C"},
4066
                {"<Main>/Edit/Select all",                        "<control>A"},
4067
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4068
                {"<Main>/Edit/Search messages...",                "<shift><control>F"},
4069

    
4070
                {"<Main>/View/Show or hide/Message view",        "V"},
4071
                {"<Main>/View/Thread view",                        "<control>T"},
4072
                {"<Main>/View/Go to/Prev message",                "P"},
4073
                {"<Main>/View/Go to/Next message",                "N"},
4074
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
4075
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
4076
                {"<Main>/View/Go to/Other folder...",                "G"},
4077
                {"<Main>/View/Open in new window",                "<control><alt>N"},
4078
                {"<Main>/View/View source",                        "<control>U"},
4079
                {"<Main>/View/Show all headers",                "<control>H"},
4080
                {"<Main>/View/Update",                                "<control><alt>U"},
4081

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

    
4099
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
4100
                {"<Main>/Tools/Execute",                        "X"},
4101
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
4102

    
4103
                {"<Compose>/File/Close",                        "<control>W"},
4104
                {"<Compose>/Edit/Select all",                        "<control>A"},
4105
        };
4106

    
4107
        static struct KeyBind mew_wl_menurc[] = {
4108
                {"<Main>/File/Empty all trash",                        "<shift>D"},
4109
                {"<Main>/File/Save as...",                        "Y"},
4110
                {"<Main>/File/Print...",                        "<shift>numbersign"},
4111
                {"<Main>/File/Exit",                                "<shift>Q"},
4112

    
4113
                {"<Main>/Edit/Copy",                                "<control>C"},
4114
                {"<Main>/Edit/Select all",                        "<control>A"},
4115
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4116
                {"<Main>/Edit/Search messages...",                "<control>S"},
4117

    
4118
                {"<Main>/View/Show or hide/Message view",        "V"},
4119
                {"<Main>/View/Thread view",                        "<shift>T"},
4120
                {"<Main>/View/Go to/Prev message",                "P"},
4121
                {"<Main>/View/Go to/Next message",                "N"},
4122
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
4123
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
4124
                {"<Main>/View/Go to/Other folder...",                "G"},
4125
                {"<Main>/View/Open in new window",                "<control><alt>N"},
4126
                {"<Main>/View/View source",                        "<control>U"},
4127
                {"<Main>/View/Show all headers",                "<shift>H"},
4128
                {"<Main>/View/Update",                                "<shift>S"},
4129

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

    
4147
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
4148
                {"<Main>/Tools/Execute",                        "X"},
4149
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
4150

    
4151
                {"<Compose>/File/Close",                        "<alt>W"},
4152
                {"<Compose>/Edit/Select all",                        ""},
4153
        };
4154

    
4155
        static struct KeyBind mutt_menurc[] = {
4156
                {"<Main>/File/Empty all trash",                        ""},
4157
                {"<Main>/File/Save as...",                        "S"},
4158
                {"<Main>/File/Print...",                        "P"},
4159
                {"<Main>/File/Exit",                                "Q"},
4160

    
4161
                {"<Main>/Edit/Copy",                                "<control>C"},
4162
                {"<Main>/Edit/Select all",                        "<control>A"},
4163
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4164
                {"<Main>/Edit/Search messages...",                "slash"},
4165

    
4166
                {"<Main>/View/Show or hide/Message view",        "V"},
4167
                {"<Main>/View/Thread view",                        "<control>T"},
4168
                {"<Main>/View/Go to/Prev message",                ""},
4169
                {"<Main>/View/Go to/Next message",                ""},
4170
                {"<Main>/View/Go to/Prev unread message",        ""},
4171
                {"<Main>/View/Go to/Next unread message",        ""},
4172
                {"<Main>/View/Go to/Other folder...",                "C"},
4173
                {"<Main>/View/Open in new window",                "<control><alt>N"},
4174
                {"<Main>/View/View source",                        "<control>U"},
4175
                {"<Main>/View/Show all headers",                "<control>H"},
4176
                {"<Main>/View/Update",                                "<control><alt>U"},
4177

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

    
4195
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
4196
                {"<Main>/Tools/Execute",                        "X"},
4197
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
4198

    
4199
                {"<Compose>/File/Close",                        "<alt>W"},
4200
                {"<Compose>/Edit/Select all",                        ""},
4201
        };
4202

    
4203
        static struct KeyBind old_sylpheed_menurc[] = {
4204
                {"<Main>/File/Empty all trash",                        ""},
4205
                {"<Main>/File/Save as...",                        ""},
4206
                {"<Main>/File/Print...",                        "<alt>P"},
4207
                {"<Main>/File/Exit",                                "<alt>Q"},
4208

    
4209
                {"<Main>/Edit/Copy",                                "<control>C"},
4210
                {"<Main>/Edit/Select all",                        "<control>A"},
4211
                {"<Main>/Edit/Find in current message...",        "<control>F"},
4212
                {"<Main>/Edit/Search messages...",                "<control>S"},
4213

    
4214
                {"<Main>/View/Show or hide/Message view",        "V"},
4215
                {"<Main>/View/Thread view",                        "<control>T"},
4216
                {"<Main>/View/Go to/Prev message",                "P"},
4217
                {"<Main>/View/Go to/Next message",                "N"},
4218
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
4219
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
4220
                {"<Main>/View/Go to/Other folder...",                "<alt>G"},
4221
                {"<Main>/View/Open in new window",                "<shift><control>N"},
4222
                {"<Main>/View/View source",                        "<control>U"},
4223
                {"<Main>/View/Show all headers",                "<control>H"},
4224
                {"<Main>/View/Update",                                "<alt>U"},
4225

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

    
4243
                {"<Main>/Tools/Address book",                        "<alt>A"},
4244
                {"<Main>/Tools/Execute",                        "<alt>X"},
4245
                {"<Main>/Tools/Log window",                        "<alt>L"},
4246

    
4247
                {"<Compose>/File/Close",                        "<alt>W"},
4248
                {"<Compose>/Edit/Select all",                        ""},
4249
        };
4250

    
4251
        static struct KeyBind empty_menurc[] = {
4252
                {"<Main>/File/Empty all trash",                        ""},
4253
                {"<Main>/File/Save as...",                        ""},
4254
                {"<Main>/File/Print...",                        ""},
4255
                {"<Main>/File/Exit",                                ""},
4256

    
4257
                {"<Main>/Edit/Copy",                                ""},
4258
                {"<Main>/Edit/Select all",                        ""},
4259
                {"<Main>/Edit/Find in current message...",        ""},
4260
                {"<Main>/Edit/Search messages...",                ""},
4261

    
4262
                {"<Main>/View/Show or hide/Message view",        ""},
4263
                {"<Main>/View/Thread view",                        ""},
4264
                {"<Main>/View/Go to/Prev message",                ""},
4265
                {"<Main>/View/Go to/Next message",                ""},
4266
                {"<Main>/View/Go to/Prev unread message",        ""},
4267
                {"<Main>/View/Go to/Next unread message",        ""},
4268
                {"<Main>/View/Go to/Other folder...",                ""},
4269
                {"<Main>/View/Open in new window",                ""},
4270
                {"<Main>/View/View source",                        ""},
4271
                {"<Main>/View/Show all headers",                ""},
4272
                {"<Main>/View/Update",                                ""},
4273

    
4274
                {"<Main>/Message/Receive/Get new mail",                        ""},
4275
                {"<Main>/Message/Receive/Get from all accounts",        ""},
4276
                {"<Main>/Message/Compose new message",                ""},
4277
                {"<Main>/Message/Reply",                        ""},
4278
                {"<Main>/Message/Reply to/all",                        ""},
4279
                {"<Main>/Message/Reply to/sender",                ""},
4280
                {"<Main>/Message/Reply to/mailing list",        ""},
4281
                {"<Main>/Message/Forward",                        ""},
4282
                {"<Main>/Message/Forward as attachment",        ""},
4283
                {"<Main>/Message/Move...",                        ""},
4284
                {"<Main>/Message/Copy...",                        ""},
4285
                {"<Main>/Message/Delete",                        ""},
4286
                {"<Main>/Message/Mark/Set flag",                ""},
4287
                {"<Main>/Message/Mark/Unset flag",                ""},
4288
                {"<Main>/Message/Mark/Mark as unread",                ""},
4289
                {"<Main>/Message/Mark/Mark as read",                ""},
4290

    
4291
                {"<Main>/Tools/Address book",                        ""},
4292
                {"<Main>/Tools/Execute",                        ""},
4293
                {"<Main>/Tools/Log window",                        ""},
4294

    
4295
                {"<Compose>/File/Close",                        ""},
4296
                {"<Compose>/Edit/Select all",                        ""},
4297
        };
4298

    
4299
        text = gtk_entry_get_text(entry);
4300

    
4301
        if (!strcmp(text, _("Default"))) {
4302
                menurc = default_menurc;
4303
                n_menurc = G_N_ELEMENTS(default_menurc);
4304
        } else if (!strcmp(text, "Mew / Wanderlust")) {
4305
                menurc = mew_wl_menurc;
4306
                n_menurc = G_N_ELEMENTS(mew_wl_menurc);
4307
        } else if (!strcmp(text, "Mutt")) {
4308
                menurc = mutt_menurc;
4309
                n_menurc = G_N_ELEMENTS(mutt_menurc);
4310
        } else if (!strcmp(text, _("Old Sylpheed"))) {
4311
                menurc = old_sylpheed_menurc;
4312
                n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
4313
        } else
4314
                return;
4315

    
4316
        prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc));
4317
        prefs_keybind_apply(menurc, n_menurc);
4318

    
4319
        gtk_widget_destroy(keybind.window);
4320
        keybind.window = NULL;
4321
        keybind.combo = NULL;
4322
}
4323

    
4324
static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
4325
{
4326
        PrefsUIData *ui_data;
4327
        GtkWidget *menu;
4328
        GtkWidget *menuitem;
4329
        gchar *charset;
4330

    
4331
        ui_data = (PrefsUIData *)pparam->ui_data;
4332
        g_return_if_fail(ui_data != NULL);
4333
        g_return_if_fail(*ui_data->widget != NULL);
4334

    
4335
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*ui_data->widget));
4336
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
4337
        charset = g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
4338
        g_free(*((gchar **)pparam->data));
4339
        *((gchar **)pparam->data) = g_strdup(charset);
4340
}
4341

    
4342
static void prefs_common_charset_set_optmenu(PrefParam *pparam)
4343
{
4344
        PrefsUIData *ui_data;
4345
        GtkOptionMenu *optmenu;
4346
        gint index;
4347

    
4348
        ui_data = (PrefsUIData *)pparam->ui_data;
4349
        g_return_if_fail(ui_data != NULL);
4350
        g_return_if_fail(*ui_data->widget != NULL);
4351

    
4352
        optmenu = GTK_OPTION_MENU(*ui_data->widget);
4353
        g_return_if_fail(optmenu != NULL);
4354

    
4355
        index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
4356
                                            (GCompareFunc)strcmp2);
4357
        if (index >= 0)
4358
                gtk_option_menu_set_history(optmenu, index);
4359
        else {
4360
                gtk_option_menu_set_history(optmenu, 0);
4361
                prefs_common_charset_set_data_from_optmenu(pparam);
4362
        }
4363
}
4364

    
4365
static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
4366
{
4367
        PrefsUIData *ui_data;
4368
        RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
4369
        GtkOptionMenu *optmenu;
4370
        GtkWidget *menu;
4371
        GtkWidget *menuitem;
4372
        gint index;
4373

    
4374
        ui_data = (PrefsUIData *)pparam->ui_data;
4375
        g_return_if_fail(ui_data != NULL);
4376
        g_return_if_fail(*ui_data->widget != NULL);
4377

    
4378
        optmenu = GTK_OPTION_MENU(*ui_data->widget);
4379
        g_return_if_fail(optmenu != NULL);
4380

    
4381
        index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(mode),
4382
                                            NULL);
4383
        if (index >= 0)
4384
                gtk_option_menu_set_history(optmenu, index);
4385
        else {
4386
                gtk_option_menu_set_history(optmenu, 0);
4387
                prefs_set_data_from_optmenu(pparam);
4388
        }
4389

    
4390
        menu = gtk_option_menu_get_menu(optmenu);
4391
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
4392
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
4393
}
4394

    
4395
static void prefs_common_uri_set_data_from_entry(PrefParam *pparam)
4396
{
4397
        PrefsUIData *ui_data;
4398
        gchar **str;
4399
        const gchar *entry_str;
4400

    
4401
        ui_data = (PrefsUIData *)pparam->ui_data;
4402
        g_return_if_fail(ui_data != NULL);
4403
        g_return_if_fail(*ui_data->widget != NULL);
4404

    
4405
        entry_str = gtk_entry_get_text(GTK_ENTRY(*ui_data->widget));
4406

    
4407
        if (pparam->type == P_STRING) {
4408
                str = (gchar **)pparam->data;
4409
                g_free(*str);
4410

    
4411
                if (entry_str[0] == '\0' ||
4412
                    !strcmp(_("(Default browser)"), entry_str))
4413
                        *str = NULL;
4414
                else
4415
                        *str = g_strdup(entry_str);
4416
        } else {
4417
                g_warning("Invalid type for URI setting\n");
4418
        }
4419
}
4420

    
4421
static void prefs_common_uri_set_entry(PrefParam *pparam)
4422
{
4423
        PrefsUIData *ui_data;
4424
        gchar **str;
4425

    
4426
        ui_data = (PrefsUIData *)pparam->ui_data;
4427
        g_return_if_fail(ui_data != NULL);
4428
        g_return_if_fail(*ui_data->widget != NULL);
4429

    
4430
        if (pparam->type == P_STRING) {
4431
                str = (gchar **)pparam->data;
4432
                gtk_entry_set_text(GTK_ENTRY(*ui_data->widget),
4433
                                   *str ? *str : _("(Default browser)"));
4434
        } else {
4435
                g_warning("Invalid type for URI setting\n");
4436
        }
4437
}
4438

    
4439
static void prefs_common_addr_compl_set_data_from_radiobtn(PrefParam *pparam)
4440
{
4441
        PrefsUIData *ui_data;
4442
        GtkRadioButton *radiobtn;
4443
        GSList *group;
4444

    
4445
        ui_data = (PrefsUIData *)pparam->ui_data;
4446
        g_return_if_fail(ui_data != NULL);
4447
        g_return_if_fail(*ui_data->widget != NULL);
4448

    
4449
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4450
        group = gtk_radio_button_get_group(radiobtn);
4451
        while (group != NULL) {
4452
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4453
                gint mode;
4454

    
4455
                if (gtk_toggle_button_get_active(btn)) {
4456
                        mode = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
4457
                                                                 MENU_VAL_ID));
4458
                        if (mode == 2) {
4459
                                prefs_common.enable_address_completion = FALSE;
4460
                                prefs_common.fullauto_completion_mode = FALSE;
4461
                        } else {
4462
                                prefs_common.enable_address_completion = TRUE;
4463
                                if (mode == 0)
4464
                                        prefs_common.fullauto_completion_mode = TRUE;
4465
                                else
4466
                                        prefs_common.fullauto_completion_mode = FALSE;
4467
                        }
4468
                        break;
4469
                }
4470
                group = group->next;
4471
        }
4472
}
4473

    
4474
static void prefs_common_addr_compl_set_radiobtn(PrefParam *pparam)
4475
{
4476
        PrefsUIData *ui_data;
4477
        GtkRadioButton *radiobtn;
4478
        GSList *group;
4479
        gint mode;
4480

    
4481
        if (prefs_common.enable_address_completion) {
4482
                if (prefs_common.fullauto_completion_mode)
4483
                        mode = 0;
4484
                else
4485
                        mode = 1;
4486
        } else
4487
                mode = 2;
4488

    
4489
        ui_data = (PrefsUIData *)pparam->ui_data;
4490
        g_return_if_fail(ui_data != NULL);
4491
        g_return_if_fail(*ui_data->widget != NULL);
4492

    
4493
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4494
        group = gtk_radio_button_get_group(radiobtn);
4495
        while (group != NULL) {
4496
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4497
                gint data;
4498

    
4499
                data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
4500
                                                         MENU_VAL_ID));
4501
                if (data == mode) {
4502
                        gtk_toggle_button_set_active(btn, TRUE);
4503
                        break;
4504
                }
4505
                group = group->next;
4506
        }
4507
}
4508

    
4509
static void prefs_common_attach_toolbtn_pos_set_data_from_radiobtn(PrefParam *pparam)
4510
{
4511
        PrefsUIData *ui_data;
4512
        GtkRadioButton *radiobtn;
4513
        GSList *group;
4514

    
4515
        ui_data = (PrefsUIData *)pparam->ui_data;
4516
        g_return_if_fail(ui_data != NULL);
4517
        g_return_if_fail(*ui_data->widget != NULL);
4518

    
4519
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4520
        group = gtk_radio_button_get_group(radiobtn);
4521
        while (group != NULL) {
4522
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4523

    
4524
                if (gtk_toggle_button_get_active(btn)) {
4525
                        prefs_common.attach_toolbutton_pos =
4526
                                GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn), MENU_VAL_ID));
4527
                        break;
4528
                }
4529
                group = group->next;
4530
        }
4531
}
4532

    
4533
static void prefs_common_attach_toolbtn_pos_set_radiobtn(PrefParam *pparam)
4534
{
4535
        PrefsUIData *ui_data;
4536
        GtkRadioButton *radiobtn;
4537
        GSList *group;
4538

    
4539
        ui_data = (PrefsUIData *)pparam->ui_data;
4540
        g_return_if_fail(ui_data != NULL);
4541
        g_return_if_fail(*ui_data->widget != NULL);
4542

    
4543
        radiobtn = GTK_RADIO_BUTTON(*ui_data->widget);
4544
        group = gtk_radio_button_get_group(radiobtn);
4545
        while (group != NULL) {
4546
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON(group->data);
4547
                gint data;
4548

    
4549
                data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(btn),
4550
                                                         MENU_VAL_ID));
4551
                if (data == prefs_common.attach_toolbutton_pos) {
4552
                        gtk_toggle_button_set_active(btn, TRUE);
4553
                        break;
4554
                }
4555
                group = group->next;
4556
        }