Statistics
| Revision:

root / src / prefs_common.c @ 1

History | View | Annotate | Download (119 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2004 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 <gtk/gtk.h>
28
#include <gdk/gdkkeysyms.h>
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <string.h>
32
#include <unistd.h>
33
#include <sys/types.h>
34
#include <sys/stat.h>
35
#include <errno.h>
36

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

    
56
PrefsCommon prefs_common;
57

    
58
static PrefsDialog dialog;
59

    
60
static struct Receive {
61
        GtkWidget *checkbtn_incext;
62
        GtkWidget *entry_incext;
63
        GtkWidget *button_incext;
64

    
65
        GtkWidget *checkbtn_local;
66
        GtkWidget *checkbtn_filter_on_inc;
67
        GtkWidget *entry_spool;
68

    
69
        GtkWidget *checkbtn_autochk;
70
        GtkWidget *spinbtn_autochk;
71
        GtkObject *spinbtn_autochk_adj;
72

    
73
        GtkWidget *checkbtn_chkonstartup;
74
        GtkWidget *checkbtn_scan_after_inc;
75

    
76
        GtkWidget *spinbtn_maxarticle;
77
        GtkObject *spinbtn_maxarticle_adj;
78
} receive;
79

    
80
static struct Send {
81
        GtkWidget *checkbtn_extsend;
82
        GtkWidget *entry_extsend;
83
        GtkWidget *button_extsend;
84

    
85
        GtkWidget *checkbtn_savemsg;
86

    
87
        GtkWidget *optmenu_charset;
88
        GtkWidget *optmenu_encoding_method;
89
} p_send;
90

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

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

    
104
        GtkWidget *checkbtn_reply_account_autosel;
105
        GtkWidget *checkbtn_quote;
106
        GtkWidget *checkbtn_default_reply_list;
107
} compose;
108

    
109
static struct Quote {
110
        GtkWidget *entry_quotemark;
111
        GtkWidget *text_quotefmt;
112

    
113
        GtkWidget *entry_fw_quotemark;
114
        GtkWidget *text_fw_quotefmt;
115
} quote;
116

    
117
static struct Display {
118
        GtkWidget *entry_textfont;
119
        GtkWidget *button_textfont;
120

    
121
        GtkWidget *chkbtn_folder_unread;
122
        GtkWidget *entry_ng_abbrev_len;
123
        GtkWidget *spinbtn_ng_abbrev_len;
124
        GtkObject *spinbtn_ng_abbrev_len_adj;
125

    
126
        GtkWidget *chkbtn_transhdr;
127

    
128
        GtkWidget *chkbtn_swapfrom;
129
        GtkWidget *chkbtn_expand_thread;
130
        GtkWidget *entry_datefmt;
131
} display;
132

    
133
static struct Message {
134
        GtkWidget *chkbtn_enablecol;
135
        GtkWidget *button_edit_col;
136
        GtkWidget *chkbtn_mbalnum;
137
        GtkWidget *chkbtn_disphdrpane;
138
        GtkWidget *chkbtn_disphdr;
139
        GtkWidget *spinbtn_linespc;
140
        GtkObject *spinbtn_linespc_adj;
141
        GtkWidget *chkbtn_headspc;
142

    
143
        GtkWidget *chkbtn_smoothscroll;
144
        GtkWidget *spinbtn_scrollstep;
145
        GtkObject *spinbtn_scrollstep_adj;
146
        GtkWidget *chkbtn_halfpage;
147

    
148
        GtkWidget *chkbtn_resize_image;
149
} message;
150

    
151
#if USE_GPGME
152
static struct Privacy {
153
        GtkWidget *checkbtn_auto_check_signatures;
154
        GtkWidget *checkbtn_gpg_signature_popup;
155
        GtkWidget *checkbtn_store_passphrase;
156
        GtkWidget *spinbtn_store_passphrase;
157
        GtkObject *spinbtn_store_passphrase_adj;
158
        GtkWidget *checkbtn_passphrase_grab;
159
        GtkWidget *checkbtn_gpg_warning;
160
} privacy;
161
#endif
162

    
163
static struct Interface {
164
        GtkWidget *checkbtn_always_show_msg;
165
        GtkWidget *checkbtn_openunread;
166
        GtkWidget *checkbtn_mark_as_read_on_newwin;
167
        GtkWidget *checkbtn_openinbox;
168
        GtkWidget *checkbtn_immedexec;
169
        GtkWidget *optmenu_recvdialog;
170
        GtkWidget *checkbtn_no_recv_err_panel;
171
        GtkWidget *checkbtn_close_recv_dialog;
172
} interface;
173

    
174
static struct Other {
175
        GtkWidget *uri_combo;
176
        GtkWidget *uri_entry;
177
        GtkWidget *printcmd_entry;
178
        GtkWidget *exteditor_combo;
179
        GtkWidget *exteditor_entry;
180

    
181
        GtkWidget *checkbtn_addaddrbyclick;
182
        GtkWidget *checkbtn_confonexit;
183
        GtkWidget *checkbtn_cleanonexit;
184
        GtkWidget *checkbtn_askonclean;
185
        GtkWidget *checkbtn_warnqueued;
186

    
187
        GtkWidget *spinbtn_iotimeout;
188
        GtkObject *spinbtn_iotimeout_adj;
189
} other;
190

    
191
static struct MessageColorButtons {
192
        GtkWidget *quote_level1_btn;
193
        GtkWidget *quote_level2_btn;
194
        GtkWidget *quote_level3_btn;
195
        GtkWidget *uri_btn;
196
} color_buttons;
197

    
198
static struct KeybindDialog {
199
        GtkWidget *window;
200
        GtkWidget *combo;
201
} keybind;
202

    
203
static GtkWidget *quote_desc_win;
204
static GtkWidget *font_sel_win;
205
static GtkWidget *quote_color_win;
206
static GtkWidget *color_dialog;
207

    
208
static void prefs_common_charset_set_data_from_optmenu           (PrefParam *pparam);
209
static void prefs_common_charset_set_optmenu                   (PrefParam *pparam);
210
static void prefs_common_encoding_set_data_from_optmenu    (PrefParam *pparam);
211
static void prefs_common_encoding_set_optmenu                   (PrefParam *pparam);
212
static void prefs_common_recv_dialog_set_data_from_optmenu (PrefParam *pparam);
213
static void prefs_common_recv_dialog_set_optmenu           (PrefParam *pparam);
214

    
215
/*
216
   parameter name, default value, pointer to the prefs variable, data type,
217
   pointer to the widget pointer,
218
   pointer to the function for data setting,
219
   pointer to the function for widget setting
220
 */
221

    
222
static PrefParam param[] = {
223
        /* Receive */
224
        {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL,
225
         &receive.checkbtn_incext,
226
         prefs_set_data_from_toggle, prefs_set_toggle},
227
        {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING,
228
         &receive.entry_incext,
229
         prefs_set_data_from_entry, prefs_set_entry},
230

    
231
        {"inc_local", "FALSE", &prefs_common.inc_local, P_BOOL,
232
         &receive.checkbtn_local,
233
         prefs_set_data_from_toggle, prefs_set_toggle},
234
        {"filter_on_inc_local", "TRUE", &prefs_common.filter_on_inc, P_BOOL,
235
         &receive.checkbtn_filter_on_inc,
236
         prefs_set_data_from_toggle, prefs_set_toggle},
237
        {"spool_path", DEFAULT_SPOOL_PATH, &prefs_common.spool_path, P_STRING,
238
         &receive.entry_spool,
239
         prefs_set_data_from_entry, prefs_set_entry},
240

    
241
        {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL,
242
         &receive.checkbtn_autochk,
243
         prefs_set_data_from_toggle, prefs_set_toggle},
244
        {"autochk_interval", "10", &prefs_common.autochk_itv, P_INT,
245
         &receive.spinbtn_autochk,
246
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
247
        {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL,
248
         &receive.checkbtn_chkonstartup,
249
         prefs_set_data_from_toggle, prefs_set_toggle},
250
        {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
251
         P_BOOL, &receive.checkbtn_scan_after_inc,
252
         prefs_set_data_from_toggle, prefs_set_toggle},
253

    
254
        {"max_news_articles", "300", &prefs_common.max_articles, P_INT,
255
         &receive.spinbtn_maxarticle,
256
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
257

    
258
        /* Send */
259
        {"use_ext_sendmail", "FALSE", &prefs_common.use_extsend, P_BOOL,
260
         &p_send.checkbtn_extsend,
261
         prefs_set_data_from_toggle, prefs_set_toggle},
262
        {"ext_sendmail_cmd", DEFAULT_SENDMAIL_CMD,
263
         &prefs_common.extsend_cmd, P_STRING,
264
         &p_send.entry_extsend, prefs_set_data_from_entry, prefs_set_entry},
265
        {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL,
266
         &p_send.checkbtn_savemsg,
267
         prefs_set_data_from_toggle, prefs_set_toggle},
268

    
269
        {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
270
         &p_send.optmenu_charset,
271
         prefs_common_charset_set_data_from_optmenu,
272
         prefs_common_charset_set_optmenu},
273
        {"encoding_method", "0", &prefs_common.encoding_method, P_ENUM,
274
         &p_send.optmenu_encoding_method,
275
         prefs_common_encoding_set_data_from_optmenu,
276
         prefs_common_encoding_set_optmenu},
277

    
278
        {"allow_jisx0201_kana", "FALSE", &prefs_common.allow_jisx0201_kana,
279
         P_BOOL, NULL, NULL, NULL},
280

    
281
        /* Compose */
282
        {"auto_signature", "TRUE", &prefs_common.auto_sig, P_BOOL,
283
         &compose.checkbtn_autosig,
284
         prefs_set_data_from_toggle, prefs_set_toggle},
285
        {"signature_separator", "-- ", &prefs_common.sig_sep, P_STRING,
286
         &compose.entry_sigsep, prefs_set_data_from_entry, prefs_set_entry},
287

    
288
        {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL,
289
         &compose.checkbtn_autoextedit,
290
         prefs_set_data_from_toggle, prefs_set_toggle},
291

    
292
        {"undo_level", "50", &prefs_common.undolevels, P_INT,
293
         &compose.spinbtn_undolevel,
294
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
295

    
296
        {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT,
297
         &compose.spinbtn_linewrap,
298
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
299
        {"linewrap_quotation", "FALSE", &prefs_common.linewrap_quote, P_BOOL,
300
         &compose.checkbtn_wrapquote,
301
         prefs_set_data_from_toggle, prefs_set_toggle},
302
        {"linewrap_auto", "FALSE", &prefs_common.autowrap, P_BOOL,
303
         &compose.checkbtn_autowrap,
304
         prefs_set_data_from_toggle, prefs_set_toggle},
305
        {"linewrap_before_sending", "FALSE",
306
         &prefs_common.linewrap_at_send, P_BOOL,
307
         &compose.checkbtn_wrapatsend,
308
         prefs_set_data_from_toggle, prefs_set_toggle},
309

    
310
        {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
311
         &compose.checkbtn_quote,
312
         prefs_set_data_from_toggle, prefs_set_toggle},
313
        {"reply_account_autoselect", "TRUE",
314
         &prefs_common.reply_account_autosel, P_BOOL,
315
         &compose.checkbtn_reply_account_autosel,
316
         prefs_set_data_from_toggle, prefs_set_toggle},
317
        {"default_reply_list", "TRUE", &prefs_common.default_reply_list, P_BOOL,
318
         &compose.checkbtn_default_reply_list,
319
         prefs_set_data_from_toggle, prefs_set_toggle},
320

    
321
        {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
322
         NULL, NULL, NULL},
323

    
324
        /* Quote */
325
        {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
326
         &quote.entry_quotemark, prefs_set_data_from_entry, prefs_set_entry},
327
        {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q",
328
         &prefs_common.quotefmt, P_STRING, &quote.text_quotefmt,
329
         prefs_set_data_from_text, prefs_set_text},
330

    
331
        {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING,
332
         &quote.entry_fw_quotemark,
333
         prefs_set_data_from_entry, prefs_set_entry},
334
        {"forward_quote_format",
335
         "\\n\\nBegin forwarded message:\\n\\n"
336
         "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
337
         "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M",
338
         &prefs_common.fw_quotefmt, P_STRING, &quote.text_fw_quotefmt,
339
         prefs_set_data_from_text, prefs_set_text},
340

    
341
        /* Display */
342
        {"widget_font", NULL, &prefs_common.widgetfont, P_STRING,
343
         NULL, NULL, NULL},
344
        {"message_font", DEFAULT_MESSAGE_FONT, &prefs_common.textfont, P_STRING,
345
         &display.entry_textfont, prefs_set_data_from_entry, prefs_set_entry},
346
        {"normal_font", DEFAULT_NORMAL_FONT, &prefs_common.normalfont, P_STRING,
347
         NULL, NULL, NULL},
348
        {"bold_font", DEFAULT_BOLD_FONT, &prefs_common.boldfont, P_STRING,
349
         NULL, NULL, NULL},
350
        {"small_font", DEFAULT_SMALL_FONT, &prefs_common.smallfont, P_STRING,
351
         NULL, NULL, NULL},
352
        {"title_font", DEFAULT_TITLE_FONT, &prefs_common.titlefont, P_STRING,
353
         NULL, NULL, NULL},
354

    
355
        {"display_folder_unread_num", "TRUE",
356
         &prefs_common.display_folder_unread, P_BOOL,
357
         &display.chkbtn_folder_unread,
358
         prefs_set_data_from_toggle, prefs_set_toggle},
359
        {"newsgroup_abbrev_len", "16",
360
         &prefs_common.ng_abbrev_len, P_INT,
361
         &display.spinbtn_ng_abbrev_len,
362
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
363

    
364
        {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL,
365
         &display.chkbtn_transhdr,
366
         prefs_set_data_from_toggle, prefs_set_toggle},
367

    
368
        /* Display: Summary View */
369
        {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
370
         &display.chkbtn_swapfrom,
371
         prefs_set_data_from_toggle, prefs_set_toggle},
372
        {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
373
         P_STRING, &display.entry_datefmt,
374
         prefs_set_data_from_entry, prefs_set_entry},
375
        {"expand_thread", "TRUE", &prefs_common.expand_thread, P_BOOL,
376
         &display.chkbtn_expand_thread,
377
         prefs_set_data_from_toggle, prefs_set_toggle},
378

    
379
        {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
380
         NULL, NULL, NULL},
381
        {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL,
382
         NULL, NULL, NULL},
383

    
384
        {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL,
385
         NULL, NULL, NULL},
386
        {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM,
387
         NULL, NULL, NULL},
388
        {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
389
         NULL, NULL, NULL},
390

    
391
        {"folderview_vscrollbar_policy", "0",
392
         &prefs_common.folderview_vscrollbar_policy, P_ENUM,
393
         NULL, NULL, NULL},
394

    
395
        {"summary_col_show_mark", "TRUE",
396
         &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL, NULL, NULL, NULL},
397
        {"summary_col_show_unread", "TRUE",
398
         &prefs_common.summary_col_visible[S_COL_UNREAD], P_BOOL, NULL, NULL, NULL},
399
        {"summary_col_show_mime", "TRUE",
400
         &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
401
        {"summary_col_show_subject", "TRUE",
402
         &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL, NULL, NULL, NULL},
403
        {"summary_col_show_from", "TRUE",
404
         &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL, NULL, NULL, NULL},
405
        {"summary_col_show_date", "TRUE",
406
         &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL, NULL, NULL, NULL},
407
        {"summary_col_show_size", "TRUE",
408
         &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL, NULL, NULL, NULL},
409
        {"summary_col_show_number", "FALSE",
410
         &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL, NULL, NULL, NULL},
411

    
412
        {"summary_col_pos_mark", "0",
413
          &prefs_common.summary_col_pos[S_COL_MARK], P_INT, NULL, NULL, NULL},
414
        {"summary_col_pos_unread", "1",
415
          &prefs_common.summary_col_pos[S_COL_UNREAD], P_INT, NULL, NULL, NULL},
416
        {"summary_col_pos_mime", "2",
417
          &prefs_common.summary_col_pos[S_COL_MIME], P_INT, NULL, NULL, NULL},
418
        {"summary_col_pos_subject", "3",
419
          &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
420
        {"summary_col_pos_from", "4",
421
          &prefs_common.summary_col_pos[S_COL_FROM], P_INT, NULL, NULL, NULL},
422
        {"summary_col_pos_date", "5",
423
          &prefs_common.summary_col_pos[S_COL_DATE], P_INT, NULL, NULL, NULL},
424
        {"summary_col_pos_size", "6",
425
          &prefs_common.summary_col_pos[S_COL_SIZE], P_INT, NULL, NULL, NULL},
426
        {"summary_col_pos_number", "7",
427
          &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
428

    
429
        {"summary_col_size_mark", "10",
430
         &prefs_common.summary_col_size[S_COL_MARK], P_INT, NULL, NULL, NULL},
431
        {"summary_col_size_unread", "13",
432
         &prefs_common.summary_col_size[S_COL_UNREAD], P_INT, NULL, NULL, NULL},
433
        {"summary_col_size_mime", "10",
434
         &prefs_common.summary_col_size[S_COL_MIME], P_INT, NULL, NULL, NULL},
435
        {"summary_col_size_subject", "200",
436
         &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
437
        {"summary_col_size_from", "120",
438
         &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
439
        {"summary_col_size_date", "118",
440
         &prefs_common.summary_col_size[S_COL_DATE], P_INT, NULL, NULL, NULL},
441
        {"summary_col_size_size", "45",
442
         &prefs_common.summary_col_size[S_COL_SIZE], P_INT, NULL, NULL, NULL},
443
        {"summary_col_size_number", "40",
444
         &prefs_common.summary_col_size[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
445

    
446
        /* Widget size */
447
        {"folderwin_x", "16", &prefs_common.folderwin_x, P_INT,
448
         NULL, NULL, NULL},
449
        {"folderwin_y", "16", &prefs_common.folderwin_y, P_INT,
450
         NULL, NULL, NULL},
451
        {"folderview_width", "179", &prefs_common.folderview_width, P_INT,
452
         NULL, NULL, NULL},
453
        {"folderview_height", "450", &prefs_common.folderview_height, P_INT,
454
         NULL, NULL, NULL},
455
        {"folderview_visible", "TRUE", &prefs_common.folderview_visible, P_BOOL,
456
         NULL, NULL, NULL},
457

    
458
        {"folder_col_folder", "150", &prefs_common.folder_col_folder, P_INT,
459
         NULL, NULL, NULL},
460
        {"folder_col_new", "32", &prefs_common.folder_col_new, P_INT,
461
         NULL, NULL, NULL},
462
        {"folder_col_unread", "32", &prefs_common.folder_col_unread, P_INT,
463
         NULL, NULL, NULL},
464
        {"folder_col_total", "32", &prefs_common.folder_col_total, P_INT,
465
         NULL, NULL, NULL},
466

    
467
        {"summaryview_width", "600", &prefs_common.summaryview_width, P_INT,
468
         NULL, NULL, NULL},
469
        {"summaryview_height", "157", &prefs_common.summaryview_height, P_INT,
470
         NULL, NULL, NULL},
471

    
472
        {"main_messagewin_x", "256", &prefs_common.main_msgwin_x, P_INT,
473
         NULL, NULL, NULL},
474
        {"main_messagewin_y", "210", &prefs_common.main_msgwin_y, P_INT,
475
         NULL, NULL, NULL},
476
        {"messageview_width", "600", &prefs_common.msgview_width, P_INT,
477
         NULL, NULL, NULL},
478
        {"messageview_height", "300", &prefs_common.msgview_height, P_INT,
479
         NULL, NULL, NULL},
480
        {"messageview_visible", "TRUE", &prefs_common.msgview_visible, P_BOOL,
481
         NULL, NULL, NULL},
482

    
483
        {"mainview_x", "64", &prefs_common.mainview_x, P_INT,
484
         NULL, NULL, NULL},
485
        {"mainview_y", "64", &prefs_common.mainview_y, P_INT,
486
         NULL, NULL, NULL},
487
        {"mainview_width", "600", &prefs_common.mainview_width, P_INT,
488
         NULL, NULL, NULL},
489
        {"mainview_height", "600", &prefs_common.mainview_height, P_INT,
490
         NULL, NULL, NULL},
491
        {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT,
492
         NULL, NULL, NULL},
493
        {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT,
494
         NULL, NULL, NULL},
495
        {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT,
496
         NULL, NULL, NULL},
497
        {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT,
498
         NULL, NULL, NULL},
499
        {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT,
500
         NULL, NULL, NULL},
501
        {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT,
502
         NULL, NULL, NULL},
503
        {"sourcewin_width", "600", &prefs_common.sourcewin_width, P_INT,
504
         NULL, NULL, NULL},
505
        {"sourcewin_height", "500", &prefs_common.sourcewin_height, P_INT,
506
         NULL, NULL, NULL},
507
        {"compose_width", "600", &prefs_common.compose_width, P_INT,
508
         NULL, NULL, NULL},
509
        {"compose_height", "560", &prefs_common.compose_height, P_INT,
510
         NULL, NULL, NULL},
511

    
512
        /* Message */
513
        {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
514
         &message.chkbtn_enablecol,
515
         prefs_set_data_from_toggle, prefs_set_toggle},
516

    
517
        {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_INT,
518
         NULL, NULL, NULL},
519
        {"quote_level2_color", "179", &prefs_common.quote_level2_col, P_INT,
520
         NULL, NULL, NULL},
521
        {"quote_level3_color", "179", &prefs_common.quote_level3_col, P_INT,
522
         NULL, NULL, NULL},
523
        {"uri_color", "32512", &prefs_common.uri_col, P_INT,
524
         NULL, NULL, NULL},
525
        {"signature_color", "0", &prefs_common.sig_col, P_USHORT,
526
         NULL, NULL, NULL},
527
        {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
528
         P_BOOL, NULL, NULL, NULL},
529

    
530
        {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL,
531
         &message.chkbtn_mbalnum,
532
         prefs_set_data_from_toggle, prefs_set_toggle},
533
        {"display_header_pane", "TRUE", &prefs_common.display_header_pane,
534
         P_BOOL, &message.chkbtn_disphdrpane,
535
         prefs_set_data_from_toggle, prefs_set_toggle},
536
        {"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
537
         &message.chkbtn_disphdr,
538
         prefs_set_data_from_toggle, prefs_set_toggle},
539
        {"line_space", "2", &prefs_common.line_space, P_INT,
540
         &message.spinbtn_linespc,
541
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
542
        {"enable_head_space", "FALSE", &prefs_common.head_space, P_BOOL,
543
         &message.chkbtn_headspc,
544
         prefs_set_data_from_toggle, prefs_set_toggle},
545

    
546
        {"enable_smooth_scroll", "FALSE",
547
         &prefs_common.enable_smooth_scroll, P_BOOL,
548
         &message.chkbtn_smoothscroll,
549
         prefs_set_data_from_toggle, prefs_set_toggle},
550
        {"scroll_step", "1", &prefs_common.scroll_step, P_INT,
551
         &message.spinbtn_scrollstep,
552
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
553
        {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL,
554
         &message.chkbtn_halfpage,
555
         prefs_set_data_from_toggle, prefs_set_toggle},
556

    
557
        {"resize_image", "TRUE", &prefs_common.resize_image, P_BOOL,
558
         &message.chkbtn_resize_image,
559
         prefs_set_data_from_toggle, prefs_set_toggle},
560

    
561
        {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
562
         NULL, NULL, NULL},
563

    
564
        /* MIME viewer */
565
        {"mime_image_viewer", "display '%s'",
566
         &prefs_common.mime_image_viewer, P_STRING, NULL, NULL, NULL},
567
        {"mime_audio_player", "play '%s'",
568
         &prefs_common.mime_audio_player, P_STRING, NULL, NULL, NULL},
569
        {"mime_open_command", "gedit '%s'",
570
         &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL},
571

    
572
#if USE_GPGME
573
        /* Privacy */
574
        {"auto_check_signatures", "TRUE",
575
         &prefs_common.auto_check_signatures, P_BOOL,
576
         &privacy.checkbtn_auto_check_signatures,
577
         prefs_set_data_from_toggle, prefs_set_toggle},
578
        {"gpg_signature_popup", "FALSE",
579
         &prefs_common.gpg_signature_popup, P_BOOL,
580
         &privacy.checkbtn_gpg_signature_popup,
581
         prefs_set_data_from_toggle, prefs_set_toggle},
582
        {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL,
583
         &privacy.checkbtn_store_passphrase,
584
         prefs_set_data_from_toggle, prefs_set_toggle},
585
        {"store_passphrase_timeout", "0",
586
         &prefs_common.store_passphrase_timeout, P_INT,
587
         &privacy.spinbtn_store_passphrase,
588
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
589
#ifndef __MINGW32__
590
        {"passphrase_grab", "FALSE", &prefs_common.passphrase_grab, P_BOOL,
591
         &privacy.checkbtn_passphrase_grab,
592
         prefs_set_data_from_toggle, prefs_set_toggle},
593
#endif /* __MINGW32__ */
594
        {"gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL,
595
         &privacy.checkbtn_gpg_warning,
596
         prefs_set_data_from_toggle, prefs_set_toggle},
597
#endif /* USE_GPGME */
598

    
599
        /* Interface */
600
        {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL,
601
         NULL, NULL, NULL},
602
        {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL,
603
         NULL, NULL, NULL},
604

    
605
        {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
606
         NULL, NULL, NULL},
607
        {"always_show_message_when_selected", "FALSE",
608
         &prefs_common.always_show_msg,
609
         P_BOOL, &interface.checkbtn_always_show_msg,
610
         prefs_set_data_from_toggle, prefs_set_toggle},
611
        {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter,
612
         P_BOOL, &interface.checkbtn_openunread,
613
         prefs_set_data_from_toggle, prefs_set_toggle},
614
        {"mark_as_read_on_new_window", "FALSE",
615
         &prefs_common.mark_as_read_on_new_window,
616
         P_BOOL, &interface.checkbtn_mark_as_read_on_newwin,
617
         prefs_set_data_from_toggle, prefs_set_toggle},
618
        {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc,
619
         P_BOOL, &interface.checkbtn_openinbox,
620
         prefs_set_data_from_toggle, prefs_set_toggle},
621
        {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL,
622
         &interface.checkbtn_immedexec,
623
         prefs_set_data_from_toggle, prefs_set_toggle},
624
        {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM,
625
         &interface.optmenu_recvdialog,
626
         prefs_common_recv_dialog_set_data_from_optmenu,
627
         prefs_common_recv_dialog_set_optmenu},
628
        {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel,
629
         P_BOOL, &interface.checkbtn_no_recv_err_panel,
630
         prefs_set_data_from_toggle, prefs_set_toggle},
631
        {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog,
632
         P_BOOL, &interface.checkbtn_close_recv_dialog,
633
         prefs_set_data_from_toggle, prefs_set_toggle},
634

    
635
        /* Other */
636
        {"uri_open_command", DEFAULT_BROWSER_CMD,
637
         &prefs_common.uri_cmd, P_STRING,
638
         &other.uri_entry, prefs_set_data_from_entry, prefs_set_entry},
639
        {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING,
640
         &other.printcmd_entry, prefs_set_data_from_entry, prefs_set_entry},
641
        {"ext_editor_command", "gedit %s",
642
         &prefs_common.ext_editor_cmd, P_STRING,
643
         &other.exteditor_entry, prefs_set_data_from_entry, prefs_set_entry},
644

    
645
        {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
646
         P_BOOL, &other.checkbtn_addaddrbyclick,
647
         prefs_set_data_from_toggle, prefs_set_toggle},
648

    
649
        {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL,
650
         &other.checkbtn_confonexit,
651
         prefs_set_data_from_toggle, prefs_set_toggle},
652
        {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL,
653
         &other.checkbtn_cleanonexit,
654
         prefs_set_data_from_toggle, prefs_set_toggle},
655
        {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL,
656
         &other.checkbtn_askonclean,
657
         prefs_set_data_from_toggle, prefs_set_toggle},
658
        {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
659
         P_BOOL, &other.checkbtn_warnqueued,
660
         prefs_set_data_from_toggle, prefs_set_toggle},
661

    
662
        {"io_timeout_secs", "60", &prefs_common.io_timeout_secs,
663
         P_INT, &other.spinbtn_iotimeout,
664
         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
665

    
666
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
667
};
668

    
669
/* widget creating functions */
670
static void prefs_common_create                (void);
671
static void prefs_receive_create        (void);
672
static void prefs_send_create                (void);
673
static void prefs_compose_create        (void);
674
static void prefs_quote_create                (void);
675
static void prefs_display_create        (void);
676
static void prefs_message_create        (void);
677
#if USE_GPGME
678
static void prefs_privacy_create        (void);
679
#endif
680
static void prefs_interface_create        (void);
681
static void prefs_other_create                (void);
682

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

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

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

    
729
static void prefs_font_select                        (GtkButton        *button);
730
static gboolean prefs_font_selection_key_pressed(GtkWidget        *widget,
731
                                                 GdkEventKey        *event,
732
                                                 gpointer         data);
733
static void prefs_font_selection_ok                (GtkButton        *button);
734

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

    
745
static gint prefs_common_deleted                (GtkWidget        *widget,
746
                                                 GdkEventAny        *event,
747
                                                 gpointer         data);
748
static gboolean prefs_common_key_pressed        (GtkWidget        *widget,
749
                                                 GdkEventKey        *event,
750
                                                 gpointer         data);
751
static void prefs_common_ok                        (void);
752
static void prefs_common_apply                        (void);
753
static void prefs_common_cancel                        (void);
754

    
755
void prefs_common_read_config(void)
756
{
757
        FILE *fp;
758
        gchar *path;
759
        gchar buf[PREFSBUFSIZE];
760

    
761
        prefs_read_config(param, "Common", COMMON_RC);
762

    
763
        prefs_common.online_mode = TRUE;
764

    
765
        path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
766
                           NULL);
767
        if ((fp = fopen(path, "rb")) == NULL) {
768
                if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
769
                g_free(path);
770
                return;
771
        }
772
        g_free(path);
773
        while (fgets(buf, sizeof(buf), fp) != NULL) {
774
                g_strstrip(buf);
775
                if (buf[0] == '\0') continue;
776
                prefs_common.mime_open_cmd_history =
777
                        add_history(prefs_common.mime_open_cmd_history, buf);
778
        }
779
        fclose(fp);
780

    
781
        prefs_common.mime_open_cmd_history =
782
                g_list_reverse(prefs_common.mime_open_cmd_history);
783
}
784

    
785
void prefs_common_write_config(void)
786
{
787
        GList *cur;
788
        FILE *fp;
789
        gchar *path;
790

    
791
        prefs_write_config(param, "Common", COMMON_RC);
792

    
793
        path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
794
                           NULL);
795
        if ((fp = fopen(path, "wb")) == NULL) {
796
                FILE_OP_ERROR(path, "fopen");
797
                g_free(path);
798
                return;
799
        }
800

    
801
        for (cur = prefs_common.mime_open_cmd_history;
802
             cur != NULL; cur = cur->next) {
803
                fputs((gchar *)cur->data, fp);
804
                fputc('\n', fp);
805
        }
806

    
807
        fclose(fp);
808
        g_free(path);
809
}
810

    
811
void prefs_common_open(void)
812
{
813
        inc_lock();
814

    
815
        if (!dialog.window) {
816
                prefs_common_create();
817
        }
818

    
819
        manage_window_set_transient(GTK_WINDOW(dialog.window));
820
        gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog.notebook), 0);
821
        gtk_widget_grab_focus(dialog.ok_btn);
822

    
823
        prefs_set_dialog(param);
824

    
825
        gtk_widget_show(dialog.window);
826
}
827

    
828
static void prefs_common_create(void)
829
{
830
        gint page = 0;
831

    
832
        debug_print(_("Creating common preferences window...\n"));
833

    
834
        prefs_dialog_create(&dialog);
835
        gtk_window_set_title (GTK_WINDOW(dialog.window),
836
                              _("Common Preferences"));
837
        g_signal_connect (G_OBJECT(dialog.window), "delete_event",
838
                          G_CALLBACK(prefs_common_deleted), NULL);
839
        g_signal_connect (G_OBJECT(dialog.window), "key_press_event",
840
                          G_CALLBACK(prefs_common_key_pressed), NULL);
841
        MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
842

    
843
        g_signal_connect (G_OBJECT(dialog.ok_btn), "clicked",
844
                          G_CALLBACK(prefs_common_ok), NULL);
845
        g_signal_connect (G_OBJECT(dialog.apply_btn), "clicked",
846
                          G_CALLBACK(prefs_common_apply), NULL);
847
        g_signal_connect (G_OBJECT(dialog.cancel_btn), "clicked",
848
                          G_CALLBACK(prefs_common_cancel), NULL);
849

    
850
        /* create all widgets on notebook */
851
        prefs_receive_create();
852
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"),   page++);
853
        prefs_send_create();
854
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"),      page++);
855
        prefs_compose_create();
856
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"),   page++);
857
        prefs_quote_create();
858
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Quote"),   page++);
859
        prefs_display_create();
860
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Display"),   page++);
861
        prefs_message_create();
862
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Message"),   page++);
863
#if USE_GPGME
864
        prefs_privacy_create();
865
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"),   page++);
866
#endif
867
        prefs_interface_create();
868
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Interface"), page++);
869
        prefs_other_create();
870
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Other"),     page++);
871

    
872
        gtk_widget_show_all(dialog.window);
873
}
874

    
875
static void prefs_receive_create(void)
876
{
877
        GtkWidget *vbox1;
878
        GtkWidget *vbox2;
879
        GtkWidget *frame_incext;
880
        GtkWidget *checkbtn_incext;
881
        GtkWidget *hbox;
882
        GtkWidget *label_incext;
883
        GtkWidget *entry_incext;
884
        /* GtkWidget *button_incext; */
885

    
886
        GtkWidget *frame_spool;
887
        GtkWidget *checkbtn_local;
888
        GtkWidget *checkbtn_filter_on_inc;
889
        GtkWidget *label_spool;
890
        GtkWidget *entry_spool;
891

    
892
        GtkWidget *hbox_autochk;
893
        GtkWidget *checkbtn_autochk;
894
        GtkWidget *label_autochk1;
895
        GtkObject *spinbtn_autochk_adj;
896
        GtkWidget *spinbtn_autochk;
897
        GtkWidget *label_autochk2;
898
        GtkWidget *checkbtn_chkonstartup;
899
        GtkWidget *checkbtn_scan_after_inc;
900

    
901
        GtkWidget *frame_news;
902
        GtkWidget *label_maxarticle;
903
        GtkWidget *spinbtn_maxarticle;
904
        GtkObject *spinbtn_maxarticle_adj;
905

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

    
911
        PACK_FRAME(vbox1, frame_incext, _("External program"));
912

    
913
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
914
        gtk_widget_show (vbox2);
915
        gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
916
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
917

    
918
        /* Use of external incorporation program */
919
        PACK_CHECK_BUTTON (vbox2, checkbtn_incext,
920
                           _("Use external program for incorporation"));
921

    
922
        hbox = gtk_hbox_new (FALSE, 8);
923
        gtk_widget_show (hbox);
924
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
925
        SET_TOGGLE_SENSITIVITY (checkbtn_incext, hbox);
926

    
927
        label_incext = gtk_label_new (_("Command"));
928
        gtk_widget_show (label_incext);
929
        gtk_box_pack_start (GTK_BOX (hbox), label_incext, FALSE, FALSE, 0);
930

    
931
        entry_incext = gtk_entry_new ();
932
        gtk_widget_show (entry_incext);
933
        gtk_box_pack_start (GTK_BOX (hbox), entry_incext, TRUE, TRUE, 0);
934

    
935
#if 0
936
        button_incext = gtk_button_new_with_label ("... ");
937
        gtk_widget_show (button_incext);
938
        gtk_box_pack_start (GTK_BOX (hbox), button_incext, FALSE, FALSE, 0);
939
#endif
940

    
941
        PACK_FRAME(vbox1, frame_spool, _("Local spool"));
942

    
943
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
944
        gtk_widget_show (vbox2);
945
        gtk_container_add (GTK_CONTAINER (frame_spool), vbox2);
946
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
947

    
948
        hbox = gtk_hbox_new (FALSE, 32);
949
        gtk_widget_show (hbox);
950
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
951

    
952
        PACK_CHECK_BUTTON (hbox, checkbtn_local, _("Incorporate from spool"));
953
        PACK_CHECK_BUTTON (hbox, checkbtn_filter_on_inc,
954
                           _("Filter on incorporation"));
955
        SET_TOGGLE_SENSITIVITY (checkbtn_local, checkbtn_filter_on_inc);
956

    
957
        hbox = gtk_hbox_new (FALSE, 8);
958
        gtk_widget_show (hbox);
959
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
960
        SET_TOGGLE_SENSITIVITY (checkbtn_local, hbox);
961

    
962
        label_spool = gtk_label_new (_("Spool path"));
963
        gtk_widget_show (label_spool);
964
        gtk_box_pack_start (GTK_BOX (hbox), label_spool, FALSE, FALSE, 0);
965

    
966
        entry_spool = gtk_entry_new ();
967
        gtk_widget_show (entry_spool);
968
        gtk_box_pack_start (GTK_BOX (hbox), entry_spool, TRUE, TRUE, 0);
969

    
970
        vbox2 = gtk_vbox_new (FALSE, 0);
971
        gtk_widget_show (vbox2);
972
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
973

    
974
        /* Auto-checking */
975
        hbox_autochk = gtk_hbox_new (FALSE, 8);
976
        gtk_widget_show (hbox_autochk);
977
        gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
978

    
979
        PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
980
                           _("Auto-check new mail"));
981

    
982
        label_autochk1 = gtk_label_new (_("every"));
983
        gtk_widget_show (label_autochk1);
984
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
985

    
986
        spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
987
        spinbtn_autochk = gtk_spin_button_new
988
                (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
989
        gtk_widget_show (spinbtn_autochk);
990
        gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
991
        gtk_widget_set_size_request (spinbtn_autochk, 64, -1);
992
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
993

    
994
        label_autochk2 = gtk_label_new (_("minute(s)"));
995
        gtk_widget_show (label_autochk2);
996
        gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
997

    
998
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
999
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
1000
        SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
1001

    
1002
        PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
1003
                           _("Check new mail on startup"));
1004
        PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
1005
                           _("Update all local folders after incorporation"));
1006

    
1007
        PACK_FRAME(vbox1, frame_news, _("News"));
1008

    
1009
        hbox = gtk_hbox_new (FALSE, 8);
1010
        gtk_widget_show (hbox);
1011
        gtk_container_add (GTK_CONTAINER (frame_news), hbox);
1012
        gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
1013

    
1014
        label_maxarticle = gtk_label_new
1015
                (_("Maximum number of articles to download\n"
1016
                   "(unlimited if 0 is specified)"));
1017
        gtk_widget_show (label_maxarticle);
1018
        gtk_box_pack_start (GTK_BOX (hbox), label_maxarticle, FALSE, FALSE, 0);
1019
        gtk_label_set_justify (GTK_LABEL (label_maxarticle), GTK_JUSTIFY_LEFT);
1020

    
1021
        spinbtn_maxarticle_adj =
1022
                gtk_adjustment_new (300, 0, 10000, 10, 100, 100);
1023
        spinbtn_maxarticle = gtk_spin_button_new
1024
                (GTK_ADJUSTMENT (spinbtn_maxarticle_adj), 10, 0);
1025
        gtk_widget_show (spinbtn_maxarticle);
1026
        gtk_box_pack_start (GTK_BOX (hbox), spinbtn_maxarticle,
1027
                            FALSE, FALSE, 0);
1028
        gtk_widget_set_size_request (spinbtn_maxarticle, 64, -1);
1029
        gtk_spin_button_set_numeric
1030
                (GTK_SPIN_BUTTON (spinbtn_maxarticle), TRUE);
1031

    
1032
        receive.checkbtn_incext = checkbtn_incext;
1033
        receive.entry_incext    = entry_incext;
1034
        /* receive.button_incext   = button_incext; */
1035

    
1036
        receive.checkbtn_local         = checkbtn_local;
1037
        receive.checkbtn_filter_on_inc = checkbtn_filter_on_inc;
1038
        receive.entry_spool            = entry_spool;
1039

    
1040
        receive.checkbtn_autochk    = checkbtn_autochk;
1041
        receive.spinbtn_autochk     = spinbtn_autochk;
1042
        receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1043

    
1044
        receive.checkbtn_chkonstartup   = checkbtn_chkonstartup;
1045
        receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1046

    
1047
        receive.spinbtn_maxarticle     = spinbtn_maxarticle;
1048
        receive.spinbtn_maxarticle_adj = spinbtn_maxarticle_adj;
1049
}
1050

    
1051
static void prefs_send_create(void)
1052
{
1053
        GtkWidget *vbox1;
1054
        GtkWidget *vbox2;
1055
        GtkWidget *frame_extsend;
1056
        GtkWidget *vbox_extsend;
1057
        GtkWidget *checkbtn_extsend;
1058
        GtkWidget *hbox1;
1059
        GtkWidget *label_extsend;
1060
        GtkWidget *entry_extsend;
1061
        /* GtkWidget *button_extsend; */
1062
        GtkWidget *checkbtn_savemsg;
1063
        GtkWidget *label_outcharset;
1064
        GtkWidget *optmenu_charset;
1065
        GtkWidget *optmenu_menu;
1066
        GtkWidget *menuitem;
1067
        GtkWidget *label_charset_desc;
1068
        GtkWidget *optmenu_encoding;
1069
        GtkWidget *label_encoding;
1070
        GtkWidget *label_encoding_desc;
1071

    
1072
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1073
        gtk_widget_show (vbox1);
1074
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1075
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1076

    
1077
        PACK_FRAME(vbox1, frame_extsend, _("External program"));
1078

    
1079
        vbox_extsend = gtk_vbox_new (FALSE, VSPACING_NARROW);
1080
        gtk_widget_show (vbox_extsend);
1081
        gtk_container_add (GTK_CONTAINER (frame_extsend), vbox_extsend);
1082
        gtk_container_set_border_width (GTK_CONTAINER (vbox_extsend), 8);
1083

    
1084
        PACK_CHECK_BUTTON (vbox_extsend, checkbtn_extsend,
1085
                           _("Use external program for sending"));
1086

    
1087
        hbox1 = gtk_hbox_new (FALSE, 8);
1088
        gtk_widget_show (hbox1);
1089
        gtk_box_pack_start (GTK_BOX (vbox_extsend), hbox1, FALSE, FALSE, 0);
1090
        SET_TOGGLE_SENSITIVITY(checkbtn_extsend, hbox1);
1091

    
1092
        label_extsend = gtk_label_new (_("Command"));
1093
        gtk_widget_show (label_extsend);
1094
        gtk_box_pack_start (GTK_BOX (hbox1), label_extsend, FALSE, FALSE, 0);
1095

    
1096
        entry_extsend = gtk_entry_new ();
1097
        gtk_widget_show (entry_extsend);
1098
        gtk_box_pack_start (GTK_BOX (hbox1), entry_extsend, TRUE, TRUE, 0);
1099

    
1100
#if 0
1101
        button_extsend = gtk_button_new_with_label ("... ");
1102
        gtk_widget_show (button_extsend);
1103
        gtk_box_pack_start (GTK_BOX (hbox1), button_extsend, FALSE, FALSE, 0);
1104
#endif
1105

    
1106
        vbox2 = gtk_vbox_new (FALSE, 0);
1107
        gtk_widget_show (vbox2);
1108
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1109

    
1110
        PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1111
                           _("Save sent messages to outbox"));
1112

    
1113
        hbox1 = gtk_hbox_new (FALSE, 8);
1114
        gtk_widget_show (hbox1);
1115
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1116

    
1117
        label_outcharset = gtk_label_new (_("Outgoing codeset"));
1118
        gtk_widget_show (label_outcharset);
1119
        gtk_box_pack_start (GTK_BOX (hbox1), label_outcharset, FALSE, FALSE, 0);
1120

    
1121
        optmenu_charset = gtk_option_menu_new ();
1122
        gtk_widget_show (optmenu_charset);
1123
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_charset, FALSE, FALSE, 0);
1124

    
1125
        optmenu_menu = gtk_menu_new ();
1126

    
1127
#define SET_MENUITEM(str, data) \
1128
{ \
1129
        MENUITEM_ADD(optmenu_menu, menuitem, str, data); \
1130
}
1131

    
1132
        SET_MENUITEM(_("Automatic (Recommended)"),         CS_AUTO);
1133
        SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
1134
#if HAVE_ICONV
1135
        SET_MENUITEM(_("Unicode (UTF-8)"),                 CS_UTF_8);
1136
#endif
1137
        SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
1138
        SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
1139
        SET_MENUITEM(_("Central European (ISO-8859-2)"),  CS_ISO_8859_2);
1140
        SET_MENUITEM(_("Baltic (ISO-8859-13)"),                  CS_ISO_8859_13);
1141
        SET_MENUITEM(_("Baltic (ISO-8859-4)"),                  CS_ISO_8859_4);
1142
        SET_MENUITEM(_("Greek (ISO-8859-7)"),                  CS_ISO_8859_7);
1143
        SET_MENUITEM(_("Turkish (ISO-8859-9)"),                  CS_ISO_8859_9);
1144
#if HAVE_ICONV
1145
        SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
1146
#endif
1147
        SET_MENUITEM(_("Cyrillic (KOI8-R)"),                 CS_KOI8_R);
1148
#if HAVE_ICONV
1149
        SET_MENUITEM(_("Cyrillic (Windows-1251)"),         CS_WINDOWS_1251);
1150
        SET_MENUITEM(_("Cyrillic (KOI8-U)"),                 CS_KOI8_U);
1151
#endif
1152
        SET_MENUITEM(_("Japanese (ISO-2022-JP)"),         CS_ISO_2022_JP);
1153
#if 0
1154
        SET_MENUITEM(_("Japanese (EUC-JP)"),                 CS_EUC_JP);
1155
        SET_MENUITEM(_("Japanese (Shift_JIS)"),                 CS_SHIFT_JIS);
1156
#endif /* 0 */
1157
        SET_MENUITEM(_("Simplified Chinese (GB2312)"),         CS_GB2312);
1158
        SET_MENUITEM(_("Traditional Chinese (Big5)"),         CS_BIG5);
1159
#if 0
1160
        SET_MENUITEM(_("Traditional Chinese (EUC-TW)"),  CS_EUC_TW);
1161
        SET_MENUITEM(_("Chinese (ISO-2022-CN)"),         CS_ISO_2022_CN);
1162
#endif /* 0 */
1163
        SET_MENUITEM(_("Korean (EUC-KR)"),                 CS_EUC_KR);
1164
        SET_MENUITEM(_("Thai (TIS-620)"),                 CS_TIS_620);
1165
        SET_MENUITEM(_("Thai (Windows-874)"),                 CS_WINDOWS_874);
1166

    
1167
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_charset),
1168
                                  optmenu_menu);
1169

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

    
1174
        label_charset_desc = gtk_label_new
1175
                (_("If `Automatic' is selected, the optimal encoding\n"
1176
                   "for the current locale will be used."));
1177
        gtk_widget_show (label_charset_desc);
1178
        gtk_box_pack_start (GTK_BOX (hbox1), label_charset_desc,
1179
                            FALSE, FALSE, 0);
1180
        gtk_label_set_justify (GTK_LABEL (label_charset_desc),
1181
                               GTK_JUSTIFY_LEFT);
1182

    
1183
        hbox1 = gtk_hbox_new (FALSE, 8);
1184
        gtk_widget_show (hbox1);
1185
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1186

    
1187
        label_encoding = gtk_label_new (_("Transfer encoding"));
1188
        gtk_widget_show (label_encoding);
1189
        gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
1190

    
1191
        optmenu_encoding = gtk_option_menu_new ();
1192
        gtk_widget_show (optmenu_encoding);
1193
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_encoding, FALSE, FALSE, 0);
1194

    
1195
        optmenu_menu = gtk_menu_new ();
1196

    
1197
        SET_MENUITEM(_("Automatic"),         CTE_AUTO);
1198
        SET_MENUITEM("base64",                 CTE_BASE64);
1199
        SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
1200
        SET_MENUITEM("8bit",                 CTE_8BIT);
1201

    
1202
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_encoding),
1203
                                  optmenu_menu);
1204

    
1205
        hbox1 = gtk_hbox_new (FALSE, 8);
1206
        gtk_widget_show (hbox1);
1207
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1208

    
1209
        label_encoding_desc = gtk_label_new
1210
                (_("Specify Content-Transfer-Encoding used when\n"
1211
                   "message body contains non-ASCII characters."));
1212
        gtk_widget_show (label_encoding_desc);
1213
        gtk_box_pack_start (GTK_BOX (hbox1), label_encoding_desc,
1214
                            FALSE, FALSE, 0);
1215
        gtk_label_set_justify (GTK_LABEL (label_encoding_desc),
1216
                               GTK_JUSTIFY_LEFT);
1217

    
1218
        p_send.checkbtn_extsend = checkbtn_extsend;
1219
        p_send.entry_extsend    = entry_extsend;
1220
        /* p_send.button_extsend   = button_extsend; */
1221

    
1222
        p_send.checkbtn_savemsg  = checkbtn_savemsg;
1223

    
1224
        p_send.optmenu_charset = optmenu_charset;
1225
        p_send.optmenu_encoding_method = optmenu_encoding;
1226
}
1227

    
1228
static void prefs_compose_create(void)
1229
{
1230
        GtkWidget *vbox1;
1231
        GtkWidget *hbox1;
1232
        GtkWidget *hbox2;
1233

    
1234
        GtkWidget *frame_sig;
1235
        GtkWidget *checkbtn_autosig;
1236
        GtkWidget *label_sigsep;
1237
        GtkWidget *entry_sigsep;
1238

    
1239
        GtkWidget *frame_editor;
1240
        GtkWidget *vbox2;
1241
        GtkWidget *checkbtn_autoextedit;
1242
        GtkWidget *vbox3;
1243
        GtkWidget *hbox3;
1244
        GtkWidget *hbox4;
1245
        GtkWidget *label_undolevel;
1246
        GtkObject *spinbtn_undolevel_adj;
1247
        GtkWidget *spinbtn_undolevel;
1248
        GtkWidget *label_linewrap;
1249
        GtkObject *spinbtn_linewrap_adj;
1250
        GtkWidget *spinbtn_linewrap;
1251
        GtkWidget *checkbtn_wrapquote;
1252
        GtkWidget *checkbtn_autowrap;
1253
        GtkWidget *checkbtn_wrapatsend;
1254

    
1255
        GtkWidget *frame_reply;
1256
        GtkWidget *checkbtn_reply_account_autosel;
1257
        GtkWidget *checkbtn_quote;
1258
        GtkWidget *checkbtn_default_reply_list;
1259

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

    
1265
        /* signature */
1266

    
1267
        PACK_FRAME(vbox1, frame_sig, _("Signature"));
1268

    
1269
        hbox1 = gtk_hbox_new (FALSE, 32);
1270
        gtk_widget_show (hbox1);
1271
        gtk_container_add (GTK_CONTAINER (frame_sig), hbox1);
1272
        gtk_container_set_border_width (GTK_CONTAINER (hbox1), 8);
1273

    
1274
        hbox2 = gtk_hbox_new (FALSE, 8);
1275
        gtk_widget_show (hbox2);
1276
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1277

    
1278
        label_sigsep = gtk_label_new (_("Signature separator"));
1279
        gtk_widget_show (label_sigsep);
1280
        gtk_box_pack_start (GTK_BOX (hbox2), label_sigsep, FALSE, FALSE, 0);
1281

    
1282
        entry_sigsep = gtk_entry_new ();
1283
        gtk_widget_show (entry_sigsep);
1284
        gtk_box_pack_start (GTK_BOX (hbox2), entry_sigsep, FALSE, FALSE, 0);
1285
        gtk_widget_set_size_request (entry_sigsep, 64, -1);
1286

    
1287
        PACK_CHECK_BUTTON (hbox1, checkbtn_autosig, _("Insert automatically"));
1288

    
1289
        PACK_FRAME (vbox1, frame_editor, _("Editor"));
1290

    
1291
        vbox2 = gtk_vbox_new (FALSE, 0);
1292
        gtk_widget_show (vbox2);
1293
        gtk_container_add (GTK_CONTAINER (frame_editor), vbox2);
1294
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1295

    
1296
        PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1297
                           _("Automatically launch the external editor"));
1298

    
1299
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1300

    
1301
        /* undo */
1302

    
1303
        hbox3 = gtk_hbox_new (FALSE, 8);
1304
        gtk_widget_show (hbox3);
1305
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1306

    
1307
        label_undolevel = gtk_label_new (_("Undo level"));
1308
        gtk_widget_show (label_undolevel);
1309
        gtk_box_pack_start (GTK_BOX (hbox3), label_undolevel, FALSE, FALSE, 0);
1310

    
1311
        spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 10);
1312
        spinbtn_undolevel = gtk_spin_button_new
1313
                (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1314
        gtk_widget_show (spinbtn_undolevel);
1315
        gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_undolevel, FALSE, FALSE, 0);
1316
        gtk_widget_set_size_request (spinbtn_undolevel, 64, -1);
1317
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1318

    
1319
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1320

    
1321
        /* line-wrapping */
1322

    
1323
        hbox3 = gtk_hbox_new (FALSE, 8);
1324
        gtk_widget_show (hbox3);
1325
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
1326

    
1327
        label_linewrap = gtk_label_new (_("Wrap messages at"));
1328
        gtk_widget_show (label_linewrap);
1329
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1330

    
1331
        spinbtn_linewrap_adj = gtk_adjustment_new (72, 20, 1024, 1, 10, 10);
1332
        spinbtn_linewrap = gtk_spin_button_new
1333
                (GTK_ADJUSTMENT (spinbtn_linewrap_adj), 1, 0);
1334
        gtk_widget_show (spinbtn_linewrap);
1335
        gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_linewrap, FALSE, FALSE, 0);
1336
        gtk_widget_set_size_request (spinbtn_linewrap, 64, -1);
1337
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
1338

    
1339
        label_linewrap = gtk_label_new (_("characters"));
1340
        gtk_widget_show (label_linewrap);
1341
        gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1342

    
1343
        PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1344

    
1345
        hbox4 = gtk_hbox_new (FALSE, 32);
1346
        gtk_widget_show (hbox4);
1347
        gtk_box_pack_start (GTK_BOX (vbox2), hbox4, FALSE, FALSE, 0);
1348

    
1349
        PACK_CHECK_BUTTON (hbox4, checkbtn_wrapquote, _("Wrap quotation"));
1350

    
1351
        hbox4 = gtk_hbox_new (FALSE, 32);
1352
        gtk_widget_show (hbox4);
1353
        gtk_box_pack_start (GTK_BOX (vbox2), hbox4, FALSE, FALSE, 0);
1354

    
1355
        PACK_CHECK_BUTTON (hbox4, checkbtn_autowrap, _("Wrap on input"));
1356
        PACK_CHECK_BUTTON
1357
                (hbox4, checkbtn_wrapatsend, _("Wrap before sending"));
1358

    
1359
        PACK_FRAME(vbox1, frame_reply, _("Reply"));
1360

    
1361
        vbox2 = gtk_vbox_new (FALSE, 0);
1362
        gtk_widget_show (vbox2);
1363
        gtk_container_add (GTK_CONTAINER (frame_reply), vbox2);
1364
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1365

    
1366
        PACK_CHECK_BUTTON (vbox2, checkbtn_reply_account_autosel,
1367
                           _("Automatically select account for replies"));
1368
        PACK_CHECK_BUTTON (vbox2, checkbtn_quote,
1369
                           _("Quote message when replying"));
1370
        PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
1371
                           _("Reply button invokes mailing list reply"));
1372

    
1373
        compose.checkbtn_autosig = checkbtn_autosig;
1374
        compose.entry_sigsep     = entry_sigsep;
1375

    
1376
        compose.checkbtn_autoextedit = checkbtn_autoextedit;
1377

    
1378
        compose.spinbtn_undolevel     = spinbtn_undolevel;
1379
        compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1380

    
1381
        compose.spinbtn_linewrap     = spinbtn_linewrap;
1382
        compose.spinbtn_linewrap_adj = spinbtn_linewrap_adj;
1383
        compose.checkbtn_wrapquote   = checkbtn_wrapquote;
1384
        compose.checkbtn_autowrap    = checkbtn_autowrap;
1385
        compose.checkbtn_wrapatsend  = checkbtn_wrapatsend;
1386

    
1387
        compose.checkbtn_quote = checkbtn_quote;
1388
        compose.checkbtn_reply_account_autosel =
1389
                checkbtn_reply_account_autosel;
1390
        compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
1391
}
1392

    
1393
static void prefs_quote_create(void)
1394
{
1395
        GtkWidget *vbox1;
1396
        GtkWidget *frame_quote;
1397
        GtkWidget *vbox_quote;
1398
        GtkWidget *hbox1;
1399
        GtkWidget *hbox2;
1400
        GtkWidget *label_quotemark;
1401
        GtkWidget *entry_quotemark;
1402
        GtkWidget *scrolledwin_quotefmt;
1403
        GtkWidget *text_quotefmt;
1404

    
1405
        GtkWidget *entry_fw_quotemark;
1406
        GtkWidget *text_fw_quotefmt;
1407

    
1408
        GtkWidget *btn_quotedesc;
1409

    
1410
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1411
        gtk_widget_show (vbox1);
1412
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1413
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1414

    
1415
        /* reply */
1416

    
1417
        PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1418

    
1419
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1420
        gtk_widget_show (vbox_quote);
1421
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1422
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1423

    
1424
        hbox1 = gtk_hbox_new (FALSE, 32);
1425
        gtk_widget_show (hbox1);
1426
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1427

    
1428
        hbox2 = gtk_hbox_new (FALSE, 8);
1429
        gtk_widget_show (hbox2);
1430
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1431

    
1432
        label_quotemark = gtk_label_new (_("Quotation mark"));
1433
        gtk_widget_show (label_quotemark);
1434
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1435

    
1436
        entry_quotemark = gtk_entry_new ();
1437
        gtk_widget_show (entry_quotemark);
1438
        gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1439
        gtk_widget_set_size_request (entry_quotemark, 64, -1);
1440

    
1441
        scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1442
        gtk_widget_show (scrolledwin_quotefmt);
1443
        gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1444
        gtk_scrolled_window_set_policy
1445
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1446
                 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1447

    
1448
        text_quotefmt = gtk_text_view_new ();
1449
        gtk_widget_show (text_quotefmt);
1450
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1451
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_quotefmt), TRUE);
1452
        gtk_widget_set_size_request(text_quotefmt, -1, 60);
1453

    
1454
        /* forward */
1455

    
1456
        PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1457

    
1458
        vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1459
        gtk_widget_show (vbox_quote);
1460
        gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1461
        gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1462

    
1463
        hbox1 = gtk_hbox_new (FALSE, 32);
1464
        gtk_widget_show (hbox1);
1465
        gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1466

    
1467
        hbox2 = gtk_hbox_new (FALSE, 8);
1468
        gtk_widget_show (hbox2);
1469
        gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1470

    
1471
        label_quotemark = gtk_label_new (_("Quotation mark"));
1472
        gtk_widget_show (label_quotemark);
1473
        gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1474

    
1475
        entry_fw_quotemark = gtk_entry_new ();
1476
        gtk_widget_show (entry_fw_quotemark);
1477
        gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1478
                            FALSE, FALSE, 0);
1479
        gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
1480

    
1481
        scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1482
        gtk_widget_show (scrolledwin_quotefmt);
1483
        gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1484
        gtk_scrolled_window_set_policy
1485
                (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1486
                 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1487

    
1488
        text_fw_quotefmt = gtk_text_view_new ();
1489
        gtk_widget_show (text_fw_quotefmt);
1490
        gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1491
                          text_fw_quotefmt);
1492
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
1493
        gtk_widget_set_size_request (text_fw_quotefmt, -1, 60);
1494

    
1495
        hbox1 = gtk_hbox_new (FALSE, 32);
1496
        gtk_widget_show (hbox1);
1497
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1498

    
1499
        btn_quotedesc =
1500
                gtk_button_new_with_label (_(" Description of symbols "));
1501
        gtk_widget_show (btn_quotedesc);
1502
        gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
1503
        g_signal_connect(G_OBJECT(btn_quotedesc), "clicked",
1504
                         G_CALLBACK(prefs_quote_description), NULL);
1505

    
1506
        quote.entry_quotemark    = entry_quotemark;
1507
        quote.text_quotefmt      = text_quotefmt;
1508
        quote.entry_fw_quotemark = entry_fw_quotemark;
1509
        quote.text_fw_quotefmt   = text_fw_quotefmt;
1510
}
1511

    
1512
static void prefs_display_create(void)
1513
{
1514
        GtkWidget *vbox1;
1515
        GtkWidget *frame_font;
1516
        GtkWidget *table1;
1517
        GtkWidget *label_textfont;
1518
        GtkWidget *entry_textfont;
1519
        GtkWidget *button_textfont;
1520
        GtkWidget *chkbtn_transhdr;
1521
        GtkWidget *chkbtn_folder_unread;
1522
        GtkWidget *hbox1;
1523
        GtkWidget *label_ng_abbrev;
1524
        GtkWidget *spinbtn_ng_abbrev_len;
1525
        GtkObject *spinbtn_ng_abbrev_len_adj;
1526
        GtkWidget *frame_summary;
1527
        GtkWidget *vbox2;
1528
        GtkWidget *chkbtn_swapfrom;
1529
        GtkWidget *chkbtn_expand_thread;
1530
        GtkWidget *vbox3;
1531
        GtkWidget *label_datefmt;
1532
        GtkWidget *button_datefmt;
1533
        GtkWidget *entry_datefmt;
1534
        GtkWidget *button_dispitem;
1535

    
1536
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1537
        gtk_widget_show (vbox1);
1538
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1539
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1540

    
1541
        PACK_FRAME(vbox1, frame_font, _("Font"));
1542

    
1543
        table1 = gtk_table_new (1, 3, FALSE);
1544
        gtk_widget_show (table1);
1545
        gtk_container_add (GTK_CONTAINER (frame_font), table1);
1546
        gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
1547
        gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
1548
        gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
1549

    
1550
        label_textfont = gtk_label_new (_("Text"));
1551
        gtk_widget_show (label_textfont);
1552
        gtk_table_attach (GTK_TABLE (table1), label_textfont, 0, 1, 0, 1,
1553
                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1554

    
1555
        entry_textfont = gtk_entry_new ();
1556
        gtk_widget_show (entry_textfont);
1557
        gtk_table_attach (GTK_TABLE (table1), entry_textfont, 1, 2, 0, 1,
1558
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
1559

    
1560
        button_textfont = gtk_button_new_with_label ("... ");
1561
        gtk_widget_show (button_textfont);
1562
        gtk_table_attach (GTK_TABLE (table1), button_textfont, 2, 3, 0, 1,
1563
                          0, 0, 0, 0);
1564
        g_signal_connect (G_OBJECT (button_textfont), "clicked",
1565
                          G_CALLBACK (prefs_font_select), NULL);
1566

    
1567
        vbox2 = gtk_vbox_new (FALSE, 0);
1568
        gtk_widget_show (vbox2);
1569
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
1570

    
1571
        PACK_CHECK_BUTTON
1572
                (vbox2, chkbtn_transhdr,
1573
                 _("Translate header name (such as `From:', `Subject:')"));
1574

    
1575
        PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1576
                           _("Display unread number next to folder name"));
1577

    
1578
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1579

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

    
1584
        label_ng_abbrev = gtk_label_new
1585
                (_("Abbreviate newsgroups longer than"));
1586
        gtk_widget_show (label_ng_abbrev);
1587
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1588

    
1589
        spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
1590
        spinbtn_ng_abbrev_len = gtk_spin_button_new
1591
                (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
1592
        gtk_widget_show (spinbtn_ng_abbrev_len);
1593
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
1594
                            FALSE, FALSE, 0);
1595
        gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
1596
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
1597
                                     TRUE);
1598

    
1599
        label_ng_abbrev = gtk_label_new
1600
                (_("letters"));
1601
        gtk_widget_show (label_ng_abbrev);
1602
        gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1603

    
1604
        /* ---- Summary ---- */
1605

    
1606
        PACK_FRAME(vbox1, frame_summary, _("Summary View"));
1607

    
1608
        vbox2 = gtk_vbox_new (FALSE, 0);
1609
        gtk_widget_show (vbox2);
1610
        gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1611
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1612

    
1613
        PACK_CHECK_BUTTON
1614
                (vbox2, chkbtn_swapfrom,
1615
                 _("Display recipient on `From' column if sender is yourself"));
1616
        PACK_CHECK_BUTTON
1617
                (vbox2, chkbtn_expand_thread, _("Expand threads"));
1618

    
1619
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1620

    
1621
        hbox1 = gtk_hbox_new (FALSE, 8);
1622
        gtk_widget_show (hbox1);
1623
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1624

    
1625
        label_datefmt = gtk_label_new (_("Date format"));
1626
        gtk_widget_show (label_datefmt);
1627
        gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1628

    
1629
        entry_datefmt = gtk_entry_new ();
1630
        gtk_widget_show (entry_datefmt);
1631
        gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1632

    
1633
        button_datefmt = gtk_button_new_with_label ("... ");
1634
        gtk_widget_show (button_datefmt);
1635
        gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
1636
        g_signal_connect (G_OBJECT (button_datefmt), "clicked",
1637
                          G_CALLBACK (date_format_create), NULL);
1638

    
1639
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1640

    
1641
        hbox1 = gtk_hbox_new (FALSE, 8);
1642
        gtk_widget_show (hbox1);
1643
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1644

    
1645
        button_dispitem = gtk_button_new_with_label
1646
                (_(" Set display item of summary... "));
1647
        gtk_widget_show (button_dispitem);
1648
        gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
1649
        g_signal_connect (G_OBJECT (button_dispitem), "clicked",
1650
                          G_CALLBACK (prefs_summary_column_open), NULL);
1651

    
1652
        display.entry_textfont        = entry_textfont;
1653
        display.button_textfont        = button_textfont;
1654

    
1655
        display.chkbtn_transhdr           = chkbtn_transhdr;
1656
        display.chkbtn_folder_unread      = chkbtn_folder_unread;
1657
        display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
1658
        display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
1659

    
1660
        display.chkbtn_swapfrom      = chkbtn_swapfrom;
1661
        display.chkbtn_expand_thread = chkbtn_expand_thread;
1662
        display.entry_datefmt        = entry_datefmt;
1663
}
1664

    
1665
static void prefs_message_create(void)
1666
{
1667
        GtkWidget *vbox1;
1668
        GtkWidget *vbox2;
1669
        GtkWidget *vbox3;
1670
        GtkWidget *hbox1;
1671
        GtkWidget *chkbtn_enablecol;
1672
        GtkWidget *button_edit_col;
1673
        GtkWidget *chkbtn_mbalnum;
1674
        GtkWidget *chkbtn_disphdrpane;
1675
        GtkWidget *chkbtn_disphdr;
1676
        GtkWidget *button_edit_disphdr;
1677
        GtkWidget *hbox_linespc;
1678
        GtkWidget *label_linespc;
1679
        GtkObject *spinbtn_linespc_adj;
1680
        GtkWidget *spinbtn_linespc;
1681
        GtkWidget *chkbtn_headspc;
1682

    
1683
        GtkWidget *frame_scr;
1684
        GtkWidget *vbox_scr;
1685
        GtkWidget *chkbtn_smoothscroll;
1686
        GtkWidget *hbox_scr;
1687
        GtkWidget *label_scr;
1688
        GtkObject *spinbtn_scrollstep_adj;
1689
        GtkWidget *spinbtn_scrollstep;
1690
        GtkWidget *chkbtn_halfpage;
1691

    
1692
        GtkWidget *chkbtn_resize_image;
1693

    
1694
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1695
        gtk_widget_show (vbox1);
1696
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1697
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1698

    
1699
        vbox2 = gtk_vbox_new (FALSE, 0);
1700
        gtk_widget_show (vbox2);
1701
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1702

    
1703
        hbox1 = gtk_hbox_new (FALSE, 8);
1704
        gtk_widget_show (hbox1);
1705
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1706

    
1707
        PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
1708
                           _("Enable coloration of message"));
1709
        g_signal_connect(G_OBJECT(chkbtn_enablecol), "toggled",
1710
                         G_CALLBACK(prefs_enable_message_color_toggled), NULL);
1711

    
1712
        button_edit_col = gtk_button_new_with_label (_(" Edit... "));
1713
        gtk_widget_show (button_edit_col);
1714
        gtk_box_pack_end (GTK_BOX (hbox1), button_edit_col, FALSE, TRUE, 0);
1715
        g_signal_connect (G_OBJECT (button_edit_col), "clicked",
1716
                          G_CALLBACK (prefs_quote_colors_dialog), NULL);
1717

    
1718
        SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
1719

    
1720
        PACK_CHECK_BUTTON
1721
                (vbox2, chkbtn_mbalnum,
1722
                 _("Display multi-byte alphabet and numeric as\n"
1723
                   "ASCII character (Japanese only)"));
1724
        gtk_label_set_justify (GTK_LABEL (GTK_BIN(chkbtn_mbalnum)->child),
1725
                               GTK_JUSTIFY_LEFT);
1726

    
1727
        PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1728
                          _("Display header pane above message view"));
1729

    
1730
        hbox1 = gtk_hbox_new (FALSE, 8);
1731
        gtk_widget_show (hbox1);
1732
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1733

    
1734
        PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1735
                          _("Display short headers on message view"));
1736

    
1737
        button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
1738
        gtk_widget_show (button_edit_disphdr);
1739
        gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
1740
                          FALSE, TRUE, 0);
1741
        g_signal_connect (G_OBJECT (button_edit_disphdr), "clicked",
1742
                          G_CALLBACK (prefs_display_header_open), NULL);
1743

    
1744
        SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1745

    
1746
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1747

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

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

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

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

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

    
1775
        PACK_CHECK_BUTTON(hbox1, chkbtn_headspc, _("Leave space on head"));
1776

    
1777
        PACK_FRAME(vbox1, frame_scr, _("Scroll"));
1778

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

    
1784
        PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
1785

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

    
1790
        PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
1791

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

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

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

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

    
1814
        SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
1815

    
1816
        PACK_CHECK_BUTTON(vbox1, chkbtn_resize_image,
1817
                          _("Resize attached large images to fit in the window"));
1818

    
1819
        message.chkbtn_enablecol   = chkbtn_enablecol;
1820
        message.button_edit_col    = button_edit_col;
1821
        message.chkbtn_mbalnum     = chkbtn_mbalnum;
1822
        message.chkbtn_disphdrpane = chkbtn_disphdrpane;
1823
        message.chkbtn_disphdr     = chkbtn_disphdr;
1824
        message.spinbtn_linespc    = spinbtn_linespc;
1825
        message.chkbtn_headspc     = chkbtn_headspc;
1826

    
1827
        message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
1828
        message.spinbtn_scrollstep     = spinbtn_scrollstep;
1829
        message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
1830
        message.chkbtn_halfpage        = chkbtn_halfpage;
1831

    
1832
        message.chkbtn_resize_image = chkbtn_resize_image;
1833
}
1834

    
1835
#if USE_GPGME
1836
static void prefs_privacy_create(void)
1837
{
1838
        GtkWidget *vbox1;
1839
        GtkWidget *vbox2;
1840
        GtkWidget *vbox3;
1841
        GtkWidget *hbox1;
1842
        GtkWidget *hbox_spc;
1843
        GtkWidget *label;
1844
        GtkWidget *checkbtn_auto_check_signatures;
1845
        GtkWidget *checkbtn_gpg_signature_popup;
1846
        GtkWidget *checkbtn_store_passphrase;
1847
        GtkObject *spinbtn_store_passphrase_adj;
1848
        GtkWidget *spinbtn_store_passphrase;
1849
        GtkWidget *checkbtn_passphrase_grab;
1850
        GtkWidget *checkbtn_gpg_warning;
1851

    
1852
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1853
        gtk_widget_show (vbox1);
1854
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1855
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1856

    
1857
        vbox2 = gtk_vbox_new (FALSE, 0);
1858
        gtk_widget_show (vbox2);
1859
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1860

    
1861
        PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
1862
                           _("Automatically check signatures"));
1863

    
1864
        PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup,
1865
                           _("Show signature check result in a popup window"));
1866

    
1867
        PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
1868
                           _("Store passphrase in memory temporarily"));
1869

    
1870
        vbox3 = gtk_vbox_new (FALSE, 0);
1871
        gtk_widget_show (vbox3);
1872
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
1873

    
1874
        hbox1 = gtk_hbox_new (FALSE, 8);
1875
        gtk_widget_show (hbox1);
1876
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
1877

    
1878
        hbox_spc = gtk_hbox_new (FALSE, 0);
1879
        gtk_widget_show (hbox_spc);
1880
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1881
        gtk_widget_set_size_request (hbox_spc, 12, -1);
1882

    
1883
        label = gtk_label_new (_("Expired after"));
1884
        gtk_widget_show (label);
1885
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1886

    
1887
        spinbtn_store_passphrase_adj = gtk_adjustment_new (0, 0, 1440, 1, 5, 5);
1888
        spinbtn_store_passphrase = gtk_spin_button_new
1889
                (GTK_ADJUSTMENT (spinbtn_store_passphrase_adj), 1, 0);
1890
        gtk_widget_show (spinbtn_store_passphrase);
1891
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_store_passphrase, FALSE, FALSE, 0);
1892
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_store_passphrase),
1893
                                     TRUE);
1894
        gtk_widget_set_size_request (spinbtn_store_passphrase, 64, -1);
1895

    
1896
        label = gtk_label_new (_("minute(s) "));
1897
        gtk_widget_show (label);
1898
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1899

    
1900
        hbox1 = gtk_hbox_new (FALSE, 8);
1901
        gtk_widget_show (hbox1);
1902
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
1903

    
1904
        hbox_spc = gtk_hbox_new (FALSE, 0);
1905
        gtk_widget_show (hbox_spc);
1906
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1907
        gtk_widget_set_size_request (hbox_spc, 12, -1);
1908

    
1909
        label = gtk_label_new (_("(Setting to '0' will store the passphrase\n"
1910
                                 " for the whole session)"));
1911
        gtk_widget_show (label);
1912
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1913
        gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1914

    
1915
        SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, vbox3);
1916

    
1917
#ifndef __MINGW32__
1918
        PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
1919
                           _("Grab input while entering a passphrase"));
1920
#endif
1921

    
1922
        PACK_CHECK_BUTTON
1923
                (vbox2, checkbtn_gpg_warning,
1924
                 _("Display warning on startup if GnuPG doesn't work"));
1925

    
1926
        hbox1 = gtk_hbox_new (FALSE, 8);
1927
        gtk_widget_show (hbox1);
1928
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1929

    
1930
        privacy.checkbtn_auto_check_signatures
1931
                                             = checkbtn_auto_check_signatures;
1932
        privacy.checkbtn_gpg_signature_popup
1933
                                             = checkbtn_gpg_signature_popup;
1934
        privacy.checkbtn_store_passphrase    = checkbtn_store_passphrase;
1935
        privacy.spinbtn_store_passphrase     = spinbtn_store_passphrase;
1936
        privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
1937
        privacy.checkbtn_passphrase_grab     = checkbtn_passphrase_grab;
1938
        privacy.checkbtn_gpg_warning         = checkbtn_gpg_warning;
1939
}
1940
#endif /* USE_GPGME */
1941

    
1942
static void prefs_interface_create(void)
1943
{
1944
        GtkWidget *vbox1;
1945
        GtkWidget *vbox2;
1946
        GtkWidget *vbox3;
1947
        GtkWidget *checkbtn_always_show_msg;
1948
        GtkWidget *checkbtn_openunread;
1949
        GtkWidget *checkbtn_mark_as_read_on_newwin;
1950
        GtkWidget *checkbtn_openinbox;
1951
        GtkWidget *checkbtn_immedexec;
1952
        GtkWidget *frame_recv;
1953
        GtkWidget *vbox_recv;
1954
        GtkWidget *hbox1;
1955
        GtkWidget *label;
1956
        GtkWidget *optmenu_recvdialog;
1957
        GtkWidget *menu;
1958
        GtkWidget *menuitem;
1959
        GtkWidget *checkbtn_no_recv_err_panel;
1960
        GtkWidget *checkbtn_close_recv_dialog;
1961

    
1962
        GtkWidget *button_keybind;
1963

    
1964
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1965
        gtk_widget_show (vbox1);
1966
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1967
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1968

    
1969
        vbox2 = gtk_vbox_new (FALSE, 0);
1970
        gtk_widget_show (vbox2);
1971
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1972

    
1973
        PACK_CHECK_BUTTON
1974
                (vbox2, checkbtn_always_show_msg,
1975
                 _("Always open messages in summary when selected"));
1976

    
1977
        PACK_CHECK_BUTTON
1978
                (vbox2, checkbtn_openunread,
1979
                 _("Open first unread message when entering a folder"));
1980

    
1981
        PACK_CHECK_BUTTON
1982
                (vbox2, checkbtn_mark_as_read_on_newwin,
1983
                 _("Only mark message as read when opened in new window"));
1984

    
1985
        PACK_CHECK_BUTTON
1986
                (vbox2, checkbtn_openinbox,
1987
                 _("Go to inbox after receiving new mail"));
1988

    
1989
        vbox3 = gtk_vbox_new (FALSE, 0);
1990
        gtk_widget_show (vbox3);
1991
        gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
1992

    
1993
        PACK_CHECK_BUTTON
1994
                (vbox3, checkbtn_immedexec,
1995
                 _("Execute immediately when moving or deleting messages"));
1996

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

    
2001
        label = gtk_label_new
2002
                (_("(Messages will be marked until execution\n"
2003
                   " if this is turned off)"));
2004
        gtk_widget_show (label);
2005
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 8);
2006
        gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2007

    
2008
        PACK_FRAME (vbox1, frame_recv, _("Receive dialog"));
2009
        vbox_recv = gtk_vbox_new (FALSE, 0);
2010
        gtk_widget_show (vbox_recv);
2011
        gtk_container_add (GTK_CONTAINER (frame_recv), vbox_recv);
2012
        gtk_container_set_border_width (GTK_CONTAINER (vbox_recv), 8);
2013

    
2014
        hbox1 = gtk_hbox_new (FALSE, 8);
2015
        gtk_widget_show (hbox1);
2016
        gtk_box_pack_start (GTK_BOX (vbox_recv), hbox1, FALSE, FALSE, 0);
2017

    
2018
        label = gtk_label_new (_("Show receive dialog"));
2019
        gtk_widget_show (label);
2020
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2021

    
2022
        optmenu_recvdialog = gtk_option_menu_new ();
2023
        gtk_widget_show (optmenu_recvdialog);
2024
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu_recvdialog,
2025
                            FALSE, FALSE, 0);
2026

    
2027
        menu = gtk_menu_new ();
2028
        MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
2029
        MENUITEM_ADD (menu, menuitem, _("Only on manual receiving"),
2030
                      RECV_DIALOG_MANUAL);
2031
        MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
2032

    
2033
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
2034

    
2035
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_no_recv_err_panel,
2036
                           _("Don't popup error dialog on receive error"));
2037

    
2038
        PACK_CHECK_BUTTON (vbox_recv, checkbtn_close_recv_dialog,
2039
                           _("Close receive dialog when finished"));
2040

    
2041
        hbox1 = gtk_hbox_new (FALSE, 8);
2042
        gtk_widget_show (hbox1);
2043
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2044

    
2045
        button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2046
        gtk_widget_show (button_keybind);
2047
        gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2048
        g_signal_connect (G_OBJECT (button_keybind), "clicked",
2049
                          G_CALLBACK (prefs_keybind_select), NULL);
2050

    
2051
        interface.checkbtn_always_show_msg   = checkbtn_always_show_msg;
2052
        interface.checkbtn_openunread        = checkbtn_openunread;
2053
        interface.checkbtn_mark_as_read_on_newwin
2054
                                             = checkbtn_mark_as_read_on_newwin;
2055
        interface.checkbtn_openinbox         = checkbtn_openinbox;
2056
        interface.checkbtn_immedexec         = checkbtn_immedexec;
2057
        interface.optmenu_recvdialog         = optmenu_recvdialog;
2058
        interface.checkbtn_no_recv_err_panel = checkbtn_no_recv_err_panel;
2059
        interface.checkbtn_close_recv_dialog = checkbtn_close_recv_dialog;
2060
}
2061

    
2062
static void prefs_other_create(void)
2063
{
2064
        GtkWidget *vbox1;
2065
        GtkWidget *ext_frame;
2066
        GtkWidget *ext_table;
2067
        GtkWidget *hbox1;
2068

    
2069
        GtkWidget *uri_label;
2070
        GtkWidget *uri_combo;
2071
        GtkWidget *uri_entry;
2072

    
2073
        GtkWidget *printcmd_label;
2074
        GtkWidget *printcmd_entry;
2075

    
2076
        GtkWidget *exteditor_label;
2077
        GtkWidget *exteditor_combo;
2078
        GtkWidget *exteditor_entry;
2079

    
2080
        GtkWidget *frame_addr;
2081
        GtkWidget *vbox_addr;
2082
        GtkWidget *checkbtn_addaddrbyclick;
2083

    
2084
        GtkWidget *frame_exit;
2085
        GtkWidget *vbox_exit;
2086
        GtkWidget *checkbtn_confonexit;
2087
        GtkWidget *checkbtn_cleanonexit;
2088
        GtkWidget *checkbtn_askonclean;
2089
        GtkWidget *checkbtn_warnqueued;
2090

    
2091
        GtkWidget *label_iotimeout;
2092
        GtkWidget *spinbtn_iotimeout;
2093
        GtkObject *spinbtn_iotimeout_adj;
2094

    
2095
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
2096
        gtk_widget_show (vbox1);
2097
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2098
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2099

    
2100
        PACK_FRAME(vbox1, ext_frame,
2101
                   _("External commands (%s will be replaced with file name / URI)"));
2102

    
2103
        ext_table = gtk_table_new (3, 2, FALSE);
2104
        gtk_widget_show (ext_table);
2105
        gtk_container_add (GTK_CONTAINER (ext_frame), ext_table);
2106
        gtk_container_set_border_width (GTK_CONTAINER (ext_table), 8);
2107
        gtk_table_set_row_spacings (GTK_TABLE (ext_table), VSPACING_NARROW);
2108
        gtk_table_set_col_spacings (GTK_TABLE (ext_table), 8);
2109

    
2110
        uri_label = gtk_label_new (_("Web browser"));
2111
        gtk_widget_show(uri_label);
2112
        gtk_table_attach (GTK_TABLE (ext_table), uri_label, 0, 1, 0, 1,
2113
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2114
        gtk_misc_set_alignment (GTK_MISC (uri_label), 1, 0.5);
2115

    
2116
        uri_combo = gtk_combo_new ();
2117
        gtk_widget_show (uri_combo);
2118
        gtk_table_attach (GTK_TABLE (ext_table), uri_combo, 1, 2, 0, 1,
2119
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
2120
        gtkut_combo_set_items (GTK_COMBO (uri_combo),
2121
                               DEFAULT_BROWSER_CMD,
2122
                               "mozilla-firefox '%s'",
2123
                               "mozilla -remote 'openURL(%s,new-window)'",
2124
                               "mozilla '%s'",
2125
                               "netscape -remote 'openURL(%s,new-window)'",
2126
                               "netscape '%s'",
2127
                               "gnome-moz-remote --newwin '%s'",
2128
                               "rxvt -e w3m '%s'",
2129
                               "rxvt -e lynx '%s'",
2130
                               NULL);
2131
        uri_entry = GTK_COMBO (uri_combo)->entry;
2132

    
2133
        printcmd_label = gtk_label_new (_("Print"));
2134
        gtk_widget_show (printcmd_label);
2135
        gtk_table_attach (GTK_TABLE (ext_table), printcmd_label, 0, 1, 1, 2,
2136
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2137
        gtk_misc_set_alignment (GTK_MISC (printcmd_label), 1, 0.5);
2138

    
2139
        printcmd_entry = gtk_entry_new ();
2140
        gtk_widget_show (printcmd_entry);
2141
        gtk_table_attach (GTK_TABLE (ext_table), printcmd_entry, 1, 2, 1, 2,
2142
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
2143

    
2144
        exteditor_label = gtk_label_new (_("Editor"));
2145
        gtk_widget_show (exteditor_label);
2146
        gtk_table_attach (GTK_TABLE (ext_table), exteditor_label, 0, 1, 2, 3,
2147
                          GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2148
        gtk_misc_set_alignment (GTK_MISC (exteditor_label), 1, 0.5);
2149

    
2150
        exteditor_combo = gtk_combo_new ();
2151
        gtk_widget_show (exteditor_combo);
2152
        gtk_table_attach (GTK_TABLE (ext_table), exteditor_combo, 1, 2, 2, 3,
2153
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
2154
        gtkut_combo_set_items (GTK_COMBO (exteditor_combo),
2155
                               "gedit %s",
2156
                               "kedit %s",
2157
                               "mgedit --no-fork %s",
2158
                               "emacs %s",
2159
                               "xemacs %s",
2160
                               "kterm -e jed %s",
2161
                               "kterm -e vi %s",
2162
                               NULL);
2163
        exteditor_entry = GTK_COMBO (exteditor_combo)->entry;
2164

    
2165
        PACK_FRAME (vbox1, frame_addr, _("Address book"));
2166

    
2167
        vbox_addr = gtk_vbox_new (FALSE, 0);
2168
        gtk_widget_show (vbox_addr);
2169
        gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2170
        gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2171

    
2172
        PACK_CHECK_BUTTON
2173
                (vbox_addr, checkbtn_addaddrbyclick,
2174
                 _("Add address to destination when double-clicked"));
2175

    
2176
        PACK_FRAME (vbox1, frame_exit, _("On exit"));
2177

    
2178
        vbox_exit = gtk_vbox_new (FALSE, 0);
2179
        gtk_widget_show (vbox_exit);
2180
        gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2181
        gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2182

    
2183
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2184
                           _("Confirm on exit"));
2185

    
2186
        hbox1 = gtk_hbox_new (FALSE, 32);
2187
        gtk_widget_show (hbox1);
2188
        gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2189

    
2190
        PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2191
                           _("Empty trash on exit"));
2192
        PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2193
                           _("Ask before emptying"));
2194
        SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2195

    
2196
        PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2197
                           _("Warn if there are queued messages"));
2198

    
2199
        hbox1 = gtk_hbox_new (FALSE, 8);
2200
        gtk_widget_show (hbox1);
2201
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2202

    
2203
        label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
2204
        gtk_widget_show (label_iotimeout);
2205
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2206

    
2207
        spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
2208
        spinbtn_iotimeout = gtk_spin_button_new
2209
                (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
2210
        gtk_widget_show (spinbtn_iotimeout);
2211
        gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
2212
                            FALSE, FALSE, 0);
2213
        gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
2214
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
2215

    
2216
        label_iotimeout = gtk_label_new (_("second(s)"));
2217
        gtk_widget_show (label_iotimeout);
2218
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2219

    
2220
        other.uri_combo = uri_combo;
2221
        other.uri_entry = uri_entry;
2222
        other.printcmd_entry = printcmd_entry;
2223

    
2224
        other.exteditor_combo = exteditor_combo;
2225
        other.exteditor_entry = exteditor_entry;
2226

    
2227
        other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
2228

    
2229
        other.checkbtn_confonexit  = checkbtn_confonexit;
2230
        other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2231
        other.checkbtn_askonclean  = checkbtn_askonclean;
2232
        other.checkbtn_warnqueued  = checkbtn_warnqueued;
2233

    
2234
        other.spinbtn_iotimeout     = spinbtn_iotimeout;
2235
        other.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
2236
}
2237

    
2238
static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
2239
{
2240
        GtkWidget *datefmt_sample = NULL;
2241
        gchar *text;
2242

    
2243
        g_return_if_fail(widget != NULL);
2244
        g_return_if_fail(*widget != NULL);
2245
        g_return_if_fail(display.entry_datefmt != NULL);
2246

    
2247
        datefmt_sample = GTK_WIDGET(g_object_get_data
2248
                                    (G_OBJECT(*widget), "datefmt_sample"));
2249
        g_return_if_fail(datefmt_sample != NULL);
2250

    
2251
        text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
2252
        g_free(prefs_common.date_format);
2253
        prefs_common.date_format = text;
2254
        gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
2255

    
2256
        gtk_widget_destroy(*widget);
2257
        *widget = NULL;
2258
}
2259

    
2260
static void date_format_cancel_btn_clicked(GtkButton *button,
2261
                                           GtkWidget **widget)
2262
{
2263
        g_return_if_fail(widget != NULL);
2264
        g_return_if_fail(*widget != NULL);
2265

    
2266
        gtk_widget_destroy(*widget);
2267
        *widget = NULL;
2268
}
2269

    
2270
static gboolean date_format_key_pressed(GtkWidget *keywidget,
2271
                                        GdkEventKey *event,
2272
                                        GtkWidget **widget)
2273
{
2274
        if (event && event->keyval == GDK_Escape)
2275
                date_format_cancel_btn_clicked(NULL, widget);
2276
        return FALSE;
2277
}
2278

    
2279
static gboolean date_format_on_delete(GtkWidget *dialogwidget,
2280
                                      GdkEventAny *event, GtkWidget **widget)
2281
{
2282
        g_return_val_if_fail(widget != NULL, FALSE);
2283
        g_return_val_if_fail(*widget != NULL, FALSE);
2284

    
2285
        *widget = NULL;
2286
        return FALSE;
2287
}
2288

    
2289
static void date_format_entry_on_change(GtkEditable *editable,
2290
                                        GtkLabel *example)
2291
{
2292
        time_t cur_time;
2293
        struct tm *cal_time;
2294
        gchar buffer[100];
2295
        gchar *text;
2296

    
2297
        cur_time = time(NULL);
2298
        cal_time = localtime(&cur_time);
2299
        buffer[0] = 0;
2300
        text = gtk_editable_get_chars(editable, 0, -1);
2301
        if (text)
2302
                strftime(buffer, sizeof buffer, text, cal_time); 
2303
        g_free(text);
2304

    
2305
        text = conv_codeset_strdup(buffer, conv_get_locale_charset_str(),
2306
                                   CS_UTF_8);
2307
        if (!text)
2308
                text = g_strdup(buffer);
2309
        gtk_label_set_text(example, text);
2310
        g_free(text);
2311
}
2312

    
2313
static void date_format_select_row(GtkWidget *date_format_list, gint row,
2314
                                   gint column, GdkEventButton *event,
2315
                                   GtkWidget *date_format)
2316
{
2317
        gint cur_pos;
2318
        gchar *format;
2319
        const gchar *old_format;
2320
        gchar *new_format;
2321
        GtkWidget *datefmt_sample;
2322

    
2323
        /* only on double click */
2324
        if (!event || event->type != GDK_2BUTTON_PRESS) return;
2325

    
2326
        datefmt_sample = GTK_WIDGET(g_object_get_data
2327
                                    (G_OBJECT(date_format), "datefmt_sample"));
2328

    
2329
        g_return_if_fail(date_format_list != NULL);
2330
        g_return_if_fail(date_format != NULL);
2331
        g_return_if_fail(datefmt_sample != NULL);
2332

    
2333
        /* get format from clist */
2334
        gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
2335

    
2336
        cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
2337
        old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
2338

    
2339
        /* insert the format into the text entry */
2340
        new_format = g_malloc(strlen(old_format) + 3);
2341

    
2342
        strncpy(new_format, old_format, cur_pos);
2343
        new_format[cur_pos] = '\0';
2344
        strcat(new_format, format);
2345
        strcat(new_format, &old_format[cur_pos]);
2346

    
2347
        gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
2348
        gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
2349

    
2350
        g_free(new_format);
2351
}
2352

    
2353
static GtkWidget *date_format_create(GtkButton *button, void *data)
2354
{
2355
        static GtkWidget *datefmt_win = NULL;
2356
        GtkWidget *vbox1;
2357
        GtkWidget *scrolledwindow1;
2358
        GtkWidget *datefmt_clist;
2359
        GtkWidget *table;
2360
        GtkWidget *label1;
2361
        GtkWidget *label2;
2362
        GtkWidget *label3;
2363
        GtkWidget *confirm_area;
2364
        GtkWidget *ok_btn;
2365
        GtkWidget *cancel_btn;
2366
        GtkWidget *datefmt_entry;
2367

    
2368
        struct {
2369
                gchar *fmt;
2370
                gchar *txt;
2371
        } time_format[] = {
2372
                { "%a", NULL },
2373
                { "%A", NULL },
2374
                { "%b", NULL },
2375
                { "%B", NULL },
2376
                { "%c", NULL },
2377
                { "%C", NULL },
2378
                { "%d", NULL },
2379
                { "%H", NULL },
2380
                { "%I", NULL },
2381
                { "%j", NULL },
2382
                { "%m", NULL },
2383
                { "%M", NULL },
2384
                { "%p", NULL },
2385
                { "%S", NULL },
2386
                { "%w", NULL },
2387
                { "%x", NULL },
2388
                { "%y", NULL },
2389
                { "%Y", NULL },
2390
                { "%Z", NULL }
2391
        };
2392

    
2393
        gchar *titles[2];
2394
        gint i;
2395
        const gint TIME_FORMAT_ELEMS =
2396
                sizeof time_format / sizeof time_format[0];
2397

    
2398
        time_format[0].txt  = _("the full abbreviated weekday name");
2399
        time_format[1].txt  = _("the full weekday name");
2400
        time_format[2].txt  = _("the abbreviated month name");
2401
        time_format[3].txt  = _("the full month name");
2402
        time_format[4].txt  = _("the preferred date and time for the current locale");
2403
        time_format[5].txt  = _("the century number (year/100)");
2404
        time_format[6].txt  = _("the day of the month as a decimal number");
2405
        time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
2406
        time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
2407
        time_format[9].txt  = _("the day of the year as a decimal number");
2408
        time_format[10].txt = _("the month as a decimal number");
2409
        time_format[11].txt = _("the minute as a decimal number");
2410
        time_format[12].txt = _("either AM or PM");
2411
        time_format[13].txt = _("the second as a decimal number");
2412
        time_format[14].txt = _("the day of the week as a decimal number");
2413
        time_format[15].txt = _("the preferred date for the current locale");
2414
        time_format[16].txt = _("the last two digits of a year");
2415
        time_format[17].txt = _("the year as a decimal number");
2416
        time_format[18].txt = _("the time zone or name or abbreviation");
2417

    
2418
        if (datefmt_win) return datefmt_win;
2419

    
2420
        datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2421
        gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
2422
        gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
2423
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2424
        gtk_widget_set_size_request(datefmt_win, 440, 280);
2425

    
2426
        vbox1 = gtk_vbox_new(FALSE, 10);
2427
        gtk_widget_show(vbox1);
2428
        gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
2429

    
2430
        scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
2431
        gtk_scrolled_window_set_policy
2432
                (GTK_SCROLLED_WINDOW(scrolledwindow1),
2433
                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
2434
        gtk_widget_show(scrolledwindow1);
2435
        gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
2436

    
2437
        titles[0] = _("Specifier");
2438
        titles[1] = _("Description");
2439
        datefmt_clist = gtk_clist_new_with_titles(2, titles);
2440
        gtk_widget_show(datefmt_clist);
2441
        gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
2442
        /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
2443
        gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
2444
                                     GTK_SELECTION_BROWSE);
2445

    
2446
        for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
2447
                gchar *text[2];
2448
                /* phoney casting necessary because of gtk... */
2449
                text[0] = (gchar *)time_format[i].fmt;
2450
                text[1] = (gchar *)time_format[i].txt;
2451
                gtk_clist_append(GTK_CLIST(datefmt_clist), text);
2452
        }
2453

    
2454
        table = gtk_table_new(2, 2, FALSE);
2455
        gtk_widget_show(table);
2456
        gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
2457
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
2458
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
2459

    
2460
        label1 = gtk_label_new(_("Date format"));
2461
        gtk_widget_show(label1);
2462
        gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
2463
                         GTK_FILL, 0, 0, 0);
2464
        gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
2465
        gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
2466

    
2467
        datefmt_entry = gtk_entry_new();
2468
        gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
2469
        gtk_widget_show(datefmt_entry);
2470
        gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
2471
                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2472

    
2473
        /* we need the "sample" entry box; add it as data so callbacks can
2474
         * get the entry box */
2475
        g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
2476
                          datefmt_entry);
2477

    
2478
        label2 = gtk_label_new(_("Example"));
2479
        gtk_widget_show(label2);
2480
        gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
2481
                         GTK_FILL, 0, 0, 0);
2482
        gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
2483
        gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
2484

    
2485
        label3 = gtk_label_new("");
2486
        gtk_widget_show(label3);
2487
        gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
2488
                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2489
        gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
2490
        gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
2491

    
2492
        gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
2493
                                &cancel_btn, _("Cancel"), NULL, NULL);
2494

    
2495
        gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
2496
        gtk_widget_show(confirm_area);
2497
        gtk_widget_grab_default(ok_btn);
2498

    
2499
        /* set the current format */
2500
        gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
2501
        date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
2502
                                    GTK_LABEL(label3));
2503

    
2504
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
2505
                         G_CALLBACK(date_format_ok_btn_clicked), &datefmt_win);
2506
        g_signal_connect(G_OBJECT(cancel_btn), "clicked",
2507
                         G_CALLBACK(date_format_cancel_btn_clicked),
2508
                         &datefmt_win);
2509
        g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
2510
                         G_CALLBACK(date_format_key_pressed), &datefmt_win);
2511
        g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
2512
                         G_CALLBACK(date_format_on_delete), &datefmt_win);
2513
        g_signal_connect(G_OBJECT(datefmt_entry), "changed",
2514
                         G_CALLBACK(date_format_entry_on_change), label3);
2515
        g_signal_connect(G_OBJECT(datefmt_clist), "select_row",
2516
                         G_CALLBACK(date_format_select_row), datefmt_win);
2517

    
2518
        gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2519
        gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
2520

    
2521
        gtk_widget_show(datefmt_win);
2522
        manage_window_set_transient(GTK_WINDOW(datefmt_win));
2523

    
2524
        gtk_widget_grab_focus(ok_btn);
2525

    
2526
        return datefmt_win;
2527
}
2528

    
2529
void prefs_quote_colors_dialog(void)
2530
{
2531
        if (!quote_color_win)
2532
                prefs_quote_colors_dialog_create();
2533
        gtk_widget_show(quote_color_win);
2534
        manage_window_set_transient(GTK_WINDOW(quote_color_win));
2535

    
2536
        gtk_main();
2537
        gtk_widget_hide(quote_color_win);
2538

    
2539
        textview_update_message_colors();
2540
        main_window_reflect_prefs_all();
2541
}
2542

    
2543
static void prefs_quote_colors_dialog_create(void)
2544
{
2545
        GtkWidget *window;
2546
        GtkWidget *vbox;
2547
        GtkWidget *table;
2548
        GtkWidget *quotelevel1_label;
2549
        GtkWidget *quotelevel2_label;
2550
        GtkWidget *quotelevel3_label;
2551
        GtkWidget *uri_label;
2552
        GtkWidget *hbbox;
2553
        GtkWidget *ok_btn;
2554
        GtkWidget *recycle_colors_btn;
2555
        GtkWidget *frame_colors;
2556

    
2557
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2558
        gtk_container_set_border_width(GTK_CONTAINER(window), 2);
2559
        gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
2560
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
2561
        gtk_window_set_modal(GTK_WINDOW(window), TRUE);
2562
        gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
2563

    
2564
        vbox = gtk_vbox_new (FALSE, VSPACING);
2565
        gtk_container_add (GTK_CONTAINER (window), vbox);
2566
        gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
2567
        PACK_FRAME(vbox, frame_colors, _("Colors"));
2568

    
2569
        table = gtk_table_new (4, 2, FALSE);
2570
        gtk_container_add (GTK_CONTAINER (frame_colors), table);
2571
        gtk_container_set_border_width (GTK_CONTAINER (table), 8);
2572
        gtk_table_set_row_spacings (GTK_TABLE (table), 2);
2573
        gtk_table_set_col_spacings (GTK_TABLE (table), 4);
2574

    
2575
        color_buttons.quote_level1_btn = gtk_button_new();
2576
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level1_btn,
2577
                          0, 1, 0, 1, 0, 0, 0, 0);
2578
        gtk_widget_set_size_request (color_buttons.quote_level1_btn, 40, 30);
2579
        gtk_container_set_border_width
2580
                (GTK_CONTAINER (color_buttons.quote_level1_btn), 5);
2581

    
2582
        color_buttons.quote_level2_btn = gtk_button_new();
2583
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level2_btn,
2584
                          0, 1, 1, 2, 0, 0, 0, 0);
2585
        gtk_widget_set_size_request (color_buttons.quote_level2_btn, 40, 30);
2586
        gtk_container_set_border_width (GTK_CONTAINER (color_buttons.quote_level2_btn), 5);
2587

    
2588
        color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
2589
        gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
2590
                          0, 1, 2, 3, 0, 0, 0, 0);
2591
        gtk_widget_set_size_request (color_buttons.quote_level3_btn, 40, 30);
2592
        gtk_container_set_border_width
2593
                (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
2594

    
2595
        color_buttons.uri_btn = gtk_button_new_with_label ("");
2596
        gtk_table_attach (GTK_TABLE (table), color_buttons.uri_btn,
2597
                          0, 1, 3, 4, 0, 0, 0, 0);
2598
        gtk_widget_set_size_request (color_buttons.uri_btn, 40, 30);
2599
        gtk_container_set_border_width (GTK_CONTAINER (color_buttons.uri_btn), 5);
2600

    
2601
        quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
2602
        gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
2603
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2604
        gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
2605
        gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
2606

    
2607
        quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
2608
        gtk_table_attach (GTK_TABLE (table), quotelevel2_label, 1, 2, 1, 2,
2609
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2610
        gtk_label_set_justify (GTK_LABEL (quotelevel2_label), GTK_JUSTIFY_LEFT);
2611
        gtk_misc_set_alignment (GTK_MISC (quotelevel2_label), 0, 0.5);
2612

    
2613
        quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
2614
        gtk_table_attach (GTK_TABLE (table), quotelevel3_label, 1, 2, 2, 3,
2615
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2616
        gtk_label_set_justify (GTK_LABEL (quotelevel3_label), GTK_JUSTIFY_LEFT);
2617
        gtk_misc_set_alignment (GTK_MISC (quotelevel3_label), 0, 0.5);
2618

    
2619
        uri_label = gtk_label_new (_("URI link"));
2620
        gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
2621
                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2622
        gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
2623
        gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
2624

    
2625
        PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
2626
                           _("Recycle quote colors"));
2627

    
2628
        gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
2629
                                NULL, NULL, NULL, NULL);
2630
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
2631

    
2632
        gtk_widget_grab_default(ok_btn);
2633
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
2634
        g_signal_connect(G_OBJECT(window), "delete_event",
2635
                         G_CALLBACK(gtk_main_quit), NULL);
2636
        g_signal_connect(G_OBJECT(window), "key_press_event",
2637
                         G_CALLBACK(prefs_quote_colors_key_pressed), NULL);
2638

    
2639
        g_signal_connect(G_OBJECT(color_buttons.quote_level1_btn), "clicked",
2640
                         G_CALLBACK(quote_color_set_dialog), "LEVEL1");
2641
        g_signal_connect(G_OBJECT(color_buttons.quote_level2_btn), "clicked",
2642
                         G_CALLBACK(quote_color_set_dialog), "LEVEL2");
2643
        g_signal_connect(G_OBJECT(color_buttons.quote_level3_btn), "clicked",
2644
                         G_CALLBACK(quote_color_set_dialog), "LEVEL3");
2645
        g_signal_connect(G_OBJECT(color_buttons.uri_btn), "clicked",
2646
                         G_CALLBACK(quote_color_set_dialog), "URI");
2647
        g_signal_connect(G_OBJECT(recycle_colors_btn), "toggled",
2648
                         G_CALLBACK(prefs_recycle_colors_toggled), NULL);
2649
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
2650
                         G_CALLBACK(gtk_main_quit), NULL);
2651

    
2652
        /* show message button colors and recycle options */
2653
        set_button_bg_color(color_buttons.quote_level1_btn,
2654
                            prefs_common.quote_level1_col);
2655
        set_button_bg_color(color_buttons.quote_level2_btn,
2656
                            prefs_common.quote_level2_col);
2657
        set_button_bg_color(color_buttons.quote_level3_btn,
2658
                            prefs_common.quote_level3_col);
2659
        set_button_bg_color(color_buttons.uri_btn,
2660
                            prefs_common.uri_col);
2661
        gtk_toggle_button_set_active((GtkToggleButton *)recycle_colors_btn,
2662
                                     prefs_common.recycle_quote_colors);
2663

    
2664
        gtk_widget_show_all(vbox);
2665
        quote_color_win = window;
2666
}
2667

    
2668
static gboolean prefs_quote_colors_key_pressed(GtkWidget *widget,
2669
                                               GdkEventKey *event,
2670
                                               gpointer data)
2671
{
2672
        if (event && event->keyval == GDK_Escape)
2673
                gtk_main_quit();
2674
        return FALSE;
2675
}
2676

    
2677
static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
2678
{
2679
        gchar *type = (gchar *)data;
2680
        gchar *title = NULL;
2681
        gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
2682
        gint rgbvalue = 0;
2683
        GtkColorSelectionDialog *dialog;
2684

    
2685
        if(g_strcasecmp(type, "LEVEL1") == 0) {
2686
                title = _("Pick color for quotation level 1");
2687
                rgbvalue = prefs_common.quote_level1_col;
2688
        } else if(g_strcasecmp(type, "LEVEL2") == 0) {
2689
                title = _("Pick color for quotation level 2");
2690
                rgbvalue = prefs_common.quote_level2_col;
2691
        } else if(g_strcasecmp(type, "LEVEL3") == 0) {
2692
                title = _("Pick color for quotation level 3");
2693
                rgbvalue = prefs_common.quote_level3_col;
2694
        } else if(g_strcasecmp(type, "URI") == 0) {
2695
                title = _("Pick color for URI");
2696
                rgbvalue = prefs_common.uri_col;
2697
        } else {   /* Should never be called */
2698
                g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
2699
                return;
2700
        }
2701

    
2702
        color_dialog = gtk_color_selection_dialog_new(title);
2703
        gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
2704
        gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
2705
        gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
2706
        manage_window_set_transient(GTK_WINDOW(color_dialog));
2707

    
2708
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
2709
                         "clicked", G_CALLBACK(quote_colors_set_dialog_ok), data);
2710
        g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
2711
                         "clicked", G_CALLBACK(quote_colors_set_dialog_cancel), data);
2712
        g_signal_connect(G_OBJECT(color_dialog), "key_press_event",
2713
                         G_CALLBACK(quote_colors_set_dialog_key_pressed), data);
2714

    
2715
        /* preselect the previous color in the color selection dialog */
2716
        color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
2717
        color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
2718
        color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
2719
        dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
2720
        gtk_color_selection_set_color
2721
                (GTK_COLOR_SELECTION(dialog->colorsel), color);
2722

    
2723
        gtk_widget_show(color_dialog);
2724
}
2725

    
2726
static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
2727
{
2728
        GtkColorSelection *colorsel = (GtkColorSelection *)
2729
                                                ((GtkColorSelectionDialog *)color_dialog)->colorsel;
2730
        gdouble color[4];
2731
        gint red, green, blue, rgbvalue;
2732
        gchar *type = (gchar *)data;
2733

    
2734
        gtk_color_selection_get_color(colorsel, color);
2735

    
2736
        red      = (gint) (color[0] * 255.0);
2737
        green    = (gint) (color[1] * 255.0);
2738
        blue     = (gint) (color[2] * 255.0);
2739
        rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
2740

    
2741
#if 0
2742
        fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
2743
        fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
2744
        fprintf(stderr, "Color is %x\n", rgbvalue);
2745
#endif
2746

    
2747
        if (g_strcasecmp(type, "LEVEL1") == 0) {
2748
                prefs_common.quote_level1_col = rgbvalue;
2749
                set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
2750
        } else if (g_strcasecmp(type, "LEVEL2") == 0) {
2751
                prefs_common.quote_level2_col = rgbvalue;
2752
                set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
2753
        } else if (g_strcasecmp(type, "LEVEL3") == 0) {
2754
                prefs_common.quote_level3_col = rgbvalue;
2755
                set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
2756
        } else if (g_strcasecmp(type, "URI") == 0) {
2757
                prefs_common.uri_col = rgbvalue;
2758
                set_button_bg_color(color_buttons.uri_btn, rgbvalue);
2759
        } else
2760
                fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
2761

    
2762
        gtk_widget_destroy(color_dialog);
2763
}
2764

    
2765
static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
2766
{
2767
        gtk_widget_destroy(color_dialog);
2768
}
2769

    
2770
static gboolean quote_colors_set_dialog_key_pressed(GtkWidget *widget,
2771
                                                    GdkEventKey *event,
2772
                                                    gpointer data)
2773
{
2774
        gtk_widget_destroy(color_dialog);
2775
        return FALSE;
2776
}
2777

    
2778
static void set_button_bg_color(GtkWidget *widget, gint rgbvalue)
2779
{
2780
        GtkStyle *newstyle;
2781
        GdkColor color;
2782

    
2783
        gtkut_convert_int_to_gdk_color(rgbvalue, &color);
2784
        newstyle = gtk_style_copy(gtk_widget_get_default_style());
2785
        newstyle->bg[GTK_STATE_NORMAL]   = color;
2786
        newstyle->bg[GTK_STATE_PRELIGHT] = color;
2787
        newstyle->bg[GTK_STATE_ACTIVE]   = color;
2788

    
2789
        gtk_widget_set_style(GTK_WIDGET(widget), newstyle);
2790
}
2791

    
2792
static void prefs_enable_message_color_toggled(void)
2793
{
2794
        gboolean is_active;
2795

    
2796
        is_active = gtk_toggle_button_get_active
2797
                (GTK_TOGGLE_BUTTON(message.chkbtn_enablecol));
2798
        gtk_widget_set_sensitive(message.button_edit_col, is_active);
2799
        prefs_common.enable_color = is_active;
2800
}
2801

    
2802
static void prefs_recycle_colors_toggled(GtkWidget *widget)
2803
{
2804
        gboolean is_active;
2805

    
2806
        is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
2807
        prefs_common.recycle_quote_colors = is_active;
2808
}
2809

    
2810
void prefs_quote_description(void)
2811
{
2812
        if (!quote_desc_win)
2813
                prefs_quote_description_create();
2814

    
2815
        manage_window_set_transient(GTK_WINDOW(quote_desc_win));
2816
        gtk_widget_show(quote_desc_win);
2817
        gtk_main();
2818
        gtk_widget_hide(quote_desc_win);
2819
}
2820

    
2821
static void prefs_quote_description_create(void)
2822
{
2823
        GtkWidget *vbox;
2824
        GtkWidget *hbox;
2825
        GtkWidget *vbox2;
2826
        GtkWidget *label;
2827
        GtkWidget *hbbox;
2828
        GtkWidget *ok_btn;
2829

    
2830
        quote_desc_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2831
        gtk_window_set_title(GTK_WINDOW(quote_desc_win),
2832
                             _("Description of symbols"));
2833
        gtk_container_set_border_width(GTK_CONTAINER(quote_desc_win), 8);
2834
        gtk_window_set_position(GTK_WINDOW(quote_desc_win), GTK_WIN_POS_CENTER);
2835
        gtk_window_set_modal(GTK_WINDOW(quote_desc_win), TRUE);
2836
        gtk_window_set_policy(GTK_WINDOW(quote_desc_win), FALSE, FALSE, FALSE);
2837

    
2838
        vbox = gtk_vbox_new(FALSE, 8);
2839
        gtk_container_add(GTK_CONTAINER(quote_desc_win), vbox);
2840

    
2841
        hbox = gtk_hbox_new(FALSE, 8);
2842
        gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
2843

    
2844
        vbox2 = gtk_vbox_new(FALSE, 8);
2845
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
2846

    
2847
#define PACK_LABEL() \
2848
        gtk_box_pack_start(GTK_BOX(vbox2), label, TRUE, TRUE, 0); \
2849
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); \
2850
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
2851

    
2852
        label = gtk_label_new
2853
                ("%d\n"                /* date */
2854
                 "%f\n"                /* from */
2855
                 "%N\n"                /* full name of sender */
2856
                 "%F\n"                /* first name of sender */
2857
                 "%I\n"                /* initial of sender */
2858
                 "%s\n"                /* subject */
2859
                 "%t\n"                /* to */
2860
                 "%c\n"                /* cc */
2861
                 "%n\n"                /* newsgroups */
2862
                 "%i");                /* message id */
2863
        PACK_LABEL();
2864

    
2865
        label = gtk_label_new
2866
                ("?x{expr}");        /* condition */
2867
        PACK_LABEL();
2868

    
2869
        label = gtk_label_new
2870
                ("%M\n"                /* message body */
2871
                 "%Q\n"                /* quoted message body */
2872
                 "%m\n"                /* message body without signature */
2873
                 "%q\n"                /* quoted message body without signature */
2874
                 "%%");                /* literal percent */
2875
        PACK_LABEL();
2876

    
2877
        label = gtk_label_new
2878
                ("\\\\\n"        /* literal backslash */
2879
                 "\\?\n"        /* literal question mark */
2880
                 "\\{\n"        /* literal opening curly brace */
2881
                 "\\}");        /* literal closing curly brace */
2882
        PACK_LABEL();
2883

    
2884
        vbox2 = gtk_vbox_new(FALSE, 8);
2885
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
2886

    
2887
        label = gtk_label_new
2888
                (_("Date\n"
2889
                   "From\n"
2890
                   "Full Name of Sender\n"
2891
                   "First Name of Sender\n"
2892
                   "Initial of Sender\n"
2893
                   "Subject\n"
2894
                   "To\n"
2895
                   "Cc\n"
2896
                   "Newsgroups\n"
2897
                   "Message-ID"));
2898
        PACK_LABEL();
2899

    
2900
        label = gtk_label_new
2901
                (_("If x is set, displays expr"));
2902
        PACK_LABEL();
2903

    
2904
        label = gtk_label_new
2905
                (_("Message body\n"
2906
                   "Quoted message body\n"
2907
                   "Message body without signature\n"
2908
                   "Quoted message body without signature\n"
2909
                   "Literal %"));
2910
        PACK_LABEL();
2911

    
2912
        label = gtk_label_new
2913
                (_("Literal backslash\n"
2914
                   "Literal question mark\n"
2915
                   "Literal opening curly brace\n"
2916
                   "Literal closing curly brace"));
2917
        PACK_LABEL();
2918

    
2919
#undef PACK_LABEL
2920

    
2921
        gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
2922
                                NULL, NULL, NULL, NULL);
2923
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
2924

    
2925
        gtk_widget_grab_default(ok_btn);
2926
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
2927
                         G_CALLBACK(gtk_main_quit), NULL);
2928
        g_signal_connect
2929
                (G_OBJECT(quote_desc_win), "key_press_event",
2930
                 G_CALLBACK(prefs_quote_description_key_pressed), NULL);
2931
        g_signal_connect(G_OBJECT(quote_desc_win), "delete_event",
2932
                         G_CALLBACK(gtk_main_quit), NULL);
2933

    
2934
        gtk_widget_show_all(vbox);
2935
}
2936

    
2937
static gboolean prefs_quote_description_key_pressed(GtkWidget *widget,
2938
                                                    GdkEventKey *event,
2939
                                                    gpointer data)
2940
{
2941
        if (event && event->keyval == GDK_Escape)
2942
                gtk_main_quit();
2943
        return FALSE;
2944
}
2945

    
2946
static void prefs_font_select(GtkButton *button)
2947
{
2948
        if (!font_sel_win) {
2949
                font_sel_win = gtk_font_selection_dialog_new
2950
                        (_("Font selection"));
2951
                gtk_window_set_position(GTK_WINDOW(font_sel_win),
2952
                                        GTK_WIN_POS_CENTER);
2953
                g_signal_connect(G_OBJECT(font_sel_win), "delete_event",
2954
                                 G_CALLBACK(gtk_widget_hide_on_delete), NULL);
2955
                g_signal_connect
2956
                        (G_OBJECT(font_sel_win), "key_press_event",
2957
                         G_CALLBACK(prefs_font_selection_key_pressed), NULL);
2958
                g_signal_connect
2959
                        (G_OBJECT(GTK_FONT_SELECTION_DIALOG(font_sel_win)->ok_button),
2960
                         "clicked",
2961
                         G_CALLBACK(prefs_font_selection_ok), NULL);
2962
                g_signal_connect_closure
2963
                        (G_OBJECT(GTK_FONT_SELECTION_DIALOG(font_sel_win)->cancel_button),
2964
                         "clicked",
2965
                         g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide_on_delete),
2966
                                              font_sel_win, NULL),
2967
                         FALSE);
2968
        }
2969

    
2970
        manage_window_set_transient(GTK_WINDOW(font_sel_win));
2971
        gtk_window_set_modal(GTK_WINDOW(font_sel_win), TRUE);
2972
        gtk_widget_grab_focus
2973
                (GTK_FONT_SELECTION_DIALOG(font_sel_win)->ok_button);
2974
        gtk_widget_show(font_sel_win);
2975
}
2976

    
2977
static gboolean prefs_font_selection_key_pressed(GtkWidget *widget,
2978
                                             GdkEventKey *event,
2979
                                             gpointer data)
2980
{
2981
        if (event && event->keyval == GDK_Escape)
2982
                gtk_widget_hide(font_sel_win);
2983
        return FALSE;
2984
}
2985

    
2986
static void prefs_font_selection_ok(GtkButton *button)
2987
{
2988
        gchar *fontname;
2989

    
2990
        fontname = gtk_font_selection_dialog_get_font_name
2991
                (GTK_FONT_SELECTION_DIALOG(font_sel_win));
2992

    
2993
        if (fontname) {
2994
                gtk_entry_set_text(GTK_ENTRY(display.entry_textfont), fontname);
2995
                g_free(fontname);
2996
        }
2997

    
2998
        gtk_widget_hide(font_sel_win);
2999
}
3000

    
3001
static void prefs_keybind_select(void)
3002
{
3003
        GtkWidget *window;
3004
        GtkWidget *vbox1;
3005
        GtkWidget *hbox1;
3006
        GtkWidget *label;
3007
        GtkWidget *combo;
3008
        GtkWidget *confirm_area;
3009
        GtkWidget *ok_btn;
3010
        GtkWidget *cancel_btn;
3011

    
3012
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3013
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
3014
        gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
3015
        gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
3016
        gtk_window_set_modal (GTK_WINDOW (window), TRUE);
3017
        gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, FALSE);
3018
        manage_window_set_transient (GTK_WINDOW (window));
3019

    
3020
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
3021
        gtk_container_add (GTK_CONTAINER (window), vbox1);
3022
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
3023

    
3024
        hbox1 = gtk_hbox_new (FALSE, 8);
3025
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3026

    
3027
        label = gtk_label_new
3028
                (_("Select the preset of key bindings.\n"
3029
                   "You can also modify each menu's shortcuts by pressing\n"
3030
                   "any key(s) when placing the mouse pointer on the item."));
3031
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
3032
        gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3033

    
3034
        hbox1 = gtk_hbox_new (FALSE, 8);
3035
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3036

    
3037
        combo = gtk_combo_new ();
3038
        gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
3039
        gtkut_combo_set_items (GTK_COMBO (combo),
3040
                               _("Default"),
3041
                               "Mew / Wanderlust",
3042
                               "Mutt",
3043
                               _("Old Sylpheed"),
3044
                               NULL);
3045
        gtk_editable_set_editable
3046
                (GTK_EDITABLE (GTK_COMBO (combo)->entry), FALSE);
3047

    
3048
        hbox1 = gtk_hbox_new (FALSE, 8);
3049
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3050

    
3051
        gtkut_button_set_create (&confirm_area, &ok_btn, _("OK"),
3052
                                 &cancel_btn, _("Cancel"), NULL, NULL);
3053
        gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
3054
        gtk_widget_grab_default (ok_btn);
3055

    
3056
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
3057
        g_signal_connect (G_OBJECT (window), "delete_event",
3058
                          G_CALLBACK (prefs_keybind_deleted), NULL);
3059
        g_signal_connect (G_OBJECT (window), "key_press_event",
3060
                          G_CALLBACK (prefs_keybind_key_pressed), NULL);
3061
        g_signal_connect (G_OBJECT (ok_btn), "clicked",
3062
                          G_CALLBACK (prefs_keybind_apply_clicked), NULL);
3063
        g_signal_connect (G_OBJECT (cancel_btn), "clicked",
3064
                          G_CALLBACK (prefs_keybind_cancel), NULL);
3065

    
3066
        gtk_widget_show_all(window);
3067

    
3068
        keybind.window = window;
3069
        keybind.combo = combo;
3070
}
3071

    
3072
static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
3073
                                          gpointer data)
3074
{
3075
        if (event && event->keyval == GDK_Escape)
3076
                prefs_keybind_cancel();
3077
        return FALSE;
3078
}
3079

    
3080
static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
3081
                                  gpointer data)
3082
{
3083
        prefs_keybind_cancel();
3084
        return TRUE;
3085
}
3086

    
3087
static void prefs_keybind_cancel(void)
3088
{
3089
        gtk_widget_destroy(keybind.window);
3090
        keybind.window = NULL;
3091
        keybind.combo = NULL;
3092
}
3093

    
3094
struct KeyBind {
3095
        const gchar *accel_path;
3096
        const gchar *accel_key;
3097
};
3098

    
3099
static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
3100
{
3101
        gint i;
3102
        guint key;
3103
        GdkModifierType mods;
3104

    
3105
        for (i = 0; i < num; i++) {
3106
                const gchar *accel_key =
3107
                        keybind[i].accel_key ? keybind[i].accel_key : "";
3108
                gtk_accelerator_parse(accel_key, &key, &mods);
3109
                gtk_accel_map_change_entry(keybind[i].accel_path,
3110
                                           key, mods, TRUE);
3111
        }
3112
}
3113

    
3114
static void prefs_keybind_apply_clicked(GtkWidget *widget)
3115
{
3116
        GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
3117
        const gchar *text;
3118
        struct KeyBind *menurc;
3119
        gint n_menurc;
3120

    
3121
        static struct KeyBind default_menurc[] = {
3122
                {"<Main>/File/Empty all trash",                        ""},
3123
                {"<Main>/File/Save as...",                        "<control>S"},
3124
                {"<Main>/File/Print...",                        ""},
3125
                {"<Main>/File/Exit",                                "<control>Q"},
3126

    
3127
                {"<Main>/Edit/Copy",                                "<control>C"},
3128
                {"<Main>/Edit/Select all",                        "<control>A"},
3129
                {"<Main>/Edit/Find in current message...",        "<control>F"},
3130
                {"<Main>/Edit/Search messages...",                "<shift><control>F"},
3131

    
3132
                {"<Main>/View/Show or hide/Message view",        "V"},
3133
                {"<Main>/View/Thread view",                        "<control>T"},
3134
                {"<Main>/View/Go to/Prev message",                "P"},
3135
                {"<Main>/View/Go to/Next message",                "N"},
3136
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
3137
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
3138
                {"<Main>/View/Go to/Other folder...",                "G"},
3139
                {"<Main>/View/Open in new window",                "<control><alt>N"},
3140
                {"<Main>/View/View source",                        "<control>U"},
3141
                {"<Main>/View/Show all header",                        "<control>H"},
3142
                {"<Main>/View/Update",                                "<control><alt>U"},
3143

    
3144
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
3145
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
3146
                {"<Main>/Message/Compose new message",                "<control>M"},
3147
                {"<Main>/Message/Reply",                        "<control>R"},
3148
                {"<Main>/Message/Reply to/all",                        "<shift><control>R"},
3149
                {"<Main>/Message/Reply to/sender",                ""},
3150
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
3151
                {"<Main>/Message/Forward",                        "<control><alt>F"},
3152
                {"<Main>/Message/Forward as attachment",        ""},
3153
                {"<Main>/Message/Move...",                        "<control>O"},
3154
                {"<Main>/Message/Copy...",                        "<shift><control>O"},
3155
                {"<Main>/Message/Delete",                        "<control>D"},
3156
                {"<Main>/Message/Mark/Mark",                        "<shift>asterisk"},
3157
                {"<Main>/Message/Mark/Unmark",                        "U"},
3158
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
3159
                {"<Main>/Message/Mark/Mark as read",                ""},
3160

    
3161
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
3162
                {"<Main>/Tools/Execute",                        "X"},
3163
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
3164

    
3165
                {"<Compose>/File/Close",                        "<control>W"},
3166
                {"<Compose>/Edit/Select all",                        "<control>A"},
3167
                {"<Compose>/Edit/Advanced/Move a word backward",        ""},
3168
                {"<Compose>/Edit/Advanced/Move a word forward",                ""},
3169
                {"<Compose>/Edit/Advanced/Move to beginning of line",        ""},
3170
                {"<Compose>/Edit/Advanced/Delete a word backward",        ""},
3171
                {"<Compose>/Edit/Advanced/Delete a word forward",        ""},
3172
        };
3173

    
3174
        static struct KeyBind mew_wl_menurc[] = {
3175
                {"<Main>/File/Empty all trash",                        "<shift>D"},
3176
                {"<Main>/File/Save as...",                        "Y"},
3177
                {"<Main>/File/Print...",                        "<shift>numbersign"},
3178
                {"<Main>/File/Exit",                                "<shift>Q"},
3179

    
3180
                {"<Main>/Edit/Copy",                                "<control>C"},
3181
                {"<Main>/Edit/Select all",                        "<control>A"},
3182
                {"<Main>/Edit/Find in current message...",        "<control>F"},
3183
                {"<Main>/Edit/Search messages...",                "<control>S"},
3184

    
3185
                {"<Main>/View/Show or hide/Message view",        "V"},
3186
                {"<Main>/View/Thread view",                        "<shift>T"},
3187
                {"<Main>/View/Go to/Prev message",                "P"},
3188
                {"<Main>/View/Go to/Next message",                "N"},
3189
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
3190
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
3191
                {"<Main>/View/Go to/Other folder...",                "G"},
3192
                {"<Main>/View/Open in new window",                "<control><alt>N"},
3193
                {"<Main>/View/View source",                        "<control>U"},
3194
                {"<Main>/View/Show all header",                        "<shift>H"},
3195
                {"<Main>/View/Update",                                "<shift>S"},
3196

    
3197
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
3198
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
3199
                {"<Main>/Message/Compose new message",                "W"},
3200
                {"<Main>/Message/Reply",                        "<control>R"},
3201
                {"<Main>/Message/Reply to/all",                        "<shift>A"},
3202
                {"<Main>/Message/Reply to/sender",                ""},
3203
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
3204
                {"<Main>/Message/Forward",                        "F"},
3205
                {"<Main>/Message/Forward as attachment",        "<shift>F"},
3206
                {"<Main>/Message/Move...",                        "O"},
3207
                {"<Main>/Message/Copy...",                        "<shift>O"},
3208
                {"<Main>/Message/Delete",                        "D"},
3209
                {"<Main>/Message/Mark/Mark",                        "<shift>asterisk"},
3210
                {"<Main>/Message/Mark/Unmark",                        "U"},
3211
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
3212
                {"<Main>/Message/Mark/Mark as read",                "<shift>R"},
3213

    
3214
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
3215
                {"<Main>/Tools/Execute",                        "X"},
3216
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
3217

    
3218
                {"<Compose>/File/Close",                        "<alt>W"},
3219
                {"<Compose>/Edit/Select all",                        ""},
3220
                {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
3221
                {"<Compose>/Edit/Advanced/Move a word forward",                "<alt>F"},
3222
                {"<Compose>/Edit/Advanced/Move to beginning of line",        "<control>A"},
3223
                {"<Compose>/Edit/Advanced/Delete a word backward",        "<control>W"},
3224
                {"<Compose>/Edit/Advanced/Delete a word forward",        "<alt>D"},
3225
        };
3226

    
3227
        static struct KeyBind mutt_menurc[] = {
3228
                {"<Main>/File/Empty all trash",                        ""},
3229
                {"<Main>/File/Save as...",                        "S"},
3230
                {"<Main>/File/Print...",                        "P"},
3231
                {"<Main>/File/Exit",                                "Q"},
3232

    
3233
                {"<Main>/Edit/Copy",                                "<control>C"},
3234
                {"<Main>/Edit/Select all",                        "<control>A"},
3235
                {"<Main>/Edit/Find in current message...",        "<control>F"},
3236
                {"<Main>/Edit/Search messages...",                "slash"},
3237

    
3238
                {"<Main>/View/Show or hide/Message view",        "V"},
3239
                {"<Main>/View/Thread view",                        "<control>T"},
3240
                {"<Main>/View/Go to/Prev message",                ""},
3241
                {"<Main>/View/Go to/Next message",                ""},
3242
                {"<Main>/View/Go to/Prev unread message",        ""},
3243
                {"<Main>/View/Go to/Next unread message",        ""},
3244
                {"<Main>/View/Go to/Other folder...",                "C"},
3245
                {"<Main>/View/Open in new window",                "<control><alt>N"},
3246
                {"<Main>/View/View source",                        "<control>U"},
3247
                {"<Main>/View/Show all header",                        "<control>H"},
3248
                {"<Main>/View/Update",                                "<control><alt>U"},
3249

    
3250
                {"<Main>/Message/Receive/Get new mail",                        "<control>I"},
3251
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
3252
                {"<Main>/Message/Compose new message",                "M"},
3253
                {"<Main>/Message/Reply",                        "R"},
3254
                {"<Main>/Message/Reply to/all",                        "G"},
3255
                {"<Main>/Message/Reply to/sender",                ""},
3256
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
3257
                {"<Main>/Message/Forward",                        "F"},
3258
                {"<Main>/Message/Forward as attachment",        ""},
3259
                {"<Main>/Message/Move...",                        "<control>O"},
3260
                {"<Main>/Message/Copy...",                        "<shift>C"},
3261
                {"<Main>/Message/Delete",                        "D"},
3262
                {"<Main>/Message/Mark/Mark",                        "<shift>F"},
3263
                {"<Main>/Message/Mark/Unmark",                        "U"},
3264
                {"<Main>/Message/Mark/Mark as unread",                "<shift>N"},
3265
                {"<Main>/Message/Mark/Mark as read",                ""},
3266

    
3267
                {"<Main>/Tools/Address book",                        "<shift><control>A"},
3268
                {"<Main>/Tools/Execute",                        "X"},
3269
                {"<Main>/Tools/Log window",                        "<shift><control>L"},
3270

    
3271
                {"<Compose>/File/Close",                        "<alt>W"},
3272
                {"<Compose>/Edit/Select all",                        ""},
3273
                {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
3274
                {"<Compose>/Edit/Advanced/Move a word forward",                "<alt>F"},
3275
                {"<Compose>/Edit/Advanced/Move to beginning of line",        "<control>A"},
3276
                {"<Compose>/Edit/Advanced/Delete a word backward",        "<control>W"},
3277
                {"<Compose>/Edit/Advanced/Delete a word forward",        "<alt>D"},
3278
        };
3279

    
3280
        static struct KeyBind old_sylpheed_menurc[] = {
3281
                {"<Main>/File/Empty all trash",                        ""},
3282
                {"<Main>/File/Save as...",                        ""},
3283
                {"<Main>/File/Print...",                        "<alt>P"},
3284
                {"<Main>/File/Exit",                                "<alt>Q"},
3285

    
3286
                {"<Main>/Edit/Copy",                                "<control>C"},
3287
                {"<Main>/Edit/Select all",                        "<control>A"},
3288
                {"<Main>/Edit/Find in current message...",        "<control>F"},
3289
                {"<Main>/Edit/Search messages...",                "<control>S"},
3290

    
3291
                {"<Main>/View/Show or hide/Message view",        "V"},
3292
                {"<Main>/View/Thread view",                        "<control>T"},
3293
                {"<Main>/View/Go to/Prev message",                "P"},
3294
                {"<Main>/View/Go to/Next message",                "N"},
3295
                {"<Main>/View/Go to/Prev unread message",        "<shift>P"},
3296
                {"<Main>/View/Go to/Next unread message",        "<shift>N"},
3297
                {"<Main>/View/Go to/Other folder...",                "<alt>G"},
3298
                {"<Main>/View/Open in new window",                "<shift><control>N"},
3299
                {"<Main>/View/View source",                        "<control>U"},
3300
                {"<Main>/View/Show all header",                        "<control>H"},
3301
                {"<Main>/View/Update",                                "<alt>U"},
3302

    
3303
                {"<Main>/Message/Receive/Get new mail",                        "<alt>I"},
3304
                {"<Main>/Message/Receive/Get from all accounts",        "<shift><alt>I"},
3305
                {"<Main>/Message/Compose new message",                "<alt>N"},
3306
                {"<Main>/Message/Reply",                        "<alt>R"},
3307
                {"<Main>/Message/Reply to/all",                        "<shift><alt>R"},
3308
                {"<Main>/Message/Reply to/sender",                "<control><alt>R"},
3309
                {"<Main>/Message/Reply to/mailing list",        "<control>L"},
3310
                {"<Main>/Message/Forward",                        "<shift><alt>F"},
3311
                {"<Main>/Message/Forward as attachment",        "<shift><control>F"},
3312
                {"<Main>/Message/Move...",                        "<alt>O"},
3313
                {"<Main>/Message/Copy...",                        ""},
3314
                {"<Main>/Message/Delete",                        "<alt>D"},
3315
                {"<Main>/Message/Mark/Mark",                        "<shift>asterisk"},
3316
                {"<Main>/Message/Mark/Unmark",                        "U"},
3317
                {"<Main>/Message/Mark/Mark as unread",                "<shift>exclam"},
3318
                {"<Main>/Message/Mark/Mark as read",                ""},
3319

    
3320
                {"<Main>/Tools/Address book",                        "<alt>A"},
3321
                {"<Main>/Tools/Execute",                        "<alt>X"},
3322
                {"<Main>/Tools/Log window",                        "<alt>L"},
3323

    
3324
                {"<Compose>/File/Close",                        "<alt>W"},
3325
                {"<Compose>/Edit/Select all",                        ""},
3326
                {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
3327
                {"<Compose>/Edit/Advanced/Move a word forward",                "<alt>F"},
3328
                {"<Compose>/Edit/Advanced/Move to beginning of line",        "<control>A"},
3329
                {"<Compose>/Edit/Advanced/Delete a word backward",        "<control>W"},
3330
                {"<Compose>/Edit/Advanced/Delete a word forward",        "<alt>D"},
3331
        };
3332

    
3333
        static struct KeyBind empty_menurc[] = {
3334
                {"<Main>/File/Empty all trash",                        ""},
3335
                {"<Main>/File/Save as...",                        ""},
3336
                {"<Main>/File/Print...",                        ""},
3337
                {"<Main>/File/Exit",                                ""},
3338

    
3339
                {"<Main>/Edit/Copy",                                ""},
3340
                {"<Main>/Edit/Select all",                        ""},
3341
                {"<Main>/Edit/Find in current message...",        ""},
3342
                {"<Main>/Edit/Search messages...",                ""},
3343

    
3344
                {"<Main>/View/Show or hide/Message view",        ""},
3345
                {"<Main>/View/Thread view",                        ""},
3346
                {"<Main>/View/Go to/Prev message",                ""},
3347
                {"<Main>/View/Go to/Next message",                ""},
3348
                {"<Main>/View/Go to/Prev unread message",        ""},
3349
                {"<Main>/View/Go to/Next unread message",        ""},
3350
                {"<Main>/View/Go to/Other folder...",                ""},
3351
                {"<Main>/View/Open in new window",                ""},
3352
                {"<Main>/View/View source",                        ""},
3353
                {"<Main>/View/Show all header",                        ""},
3354
                {"<Main>/View/Update",                                ""},
3355

    
3356
                {"<Main>/Message/Receive/Get new mail",                        ""},
3357
                {"<Main>/Message/Receive/Get from all accounts",        ""},
3358
                {"<Main>/Message/Compose new message",                ""},
3359
                {"<Main>/Message/Reply",                        ""},
3360
                {"<Main>/Message/Reply to/all",                        ""},
3361
                {"<Main>/Message/Reply to/sender",                ""},
3362
                {"<Main>/Message/Reply to/mailing list",        ""},
3363
                {"<Main>/Message/Forward",                        ""},
3364
                {"<Main>/Message/Forward as attachment",        ""},
3365
                {"<Main>/Message/Move...",                        ""},
3366
                {"<Main>/Message/Copy...",                        ""},
3367
                {"<Main>/Message/Delete",                        ""},
3368
                {"<Main>/Message/Mark/Mark",                        ""},
3369
                {"<Main>/Message/Mark/Unmark",                        ""},
3370
                {"<Main>/Message/Mark/Mark as unread",                ""},
3371
                {"<Main>/Message/Mark/Mark as read",                ""},
3372

    
3373
                {"<Main>/Tools/Address book",                        ""},
3374
                {"<Main>/Tools/Execute",                        ""},
3375
                {"<Main>/Tools/Log window",                        ""},
3376

    
3377
                {"<Compose>/File/Close",                        ""},
3378
                {"<Compose>/Edit/Select all",                        ""},
3379
                {"<Compose>/Edit/Advanced/Move a word backward",        ""},
3380
                {"<Compose>/Edit/Advanced/Move a word forward",                ""},
3381
                {"<Compose>/Edit/Advanced/Move to beginning of line",        ""},
3382
                {"<Compose>/Edit/Advanced/Delete a word backward",        ""},
3383
                {"<Compose>/Edit/Advanced/Delete a word forward",        ""},
3384
        };
3385

    
3386
        text = gtk_entry_get_text(entry);
3387

    
3388
        if (!strcmp(text, _("Default"))) {
3389
                menurc = default_menurc;
3390
                n_menurc = G_N_ELEMENTS(default_menurc);
3391
        } else if (!strcmp(text, "Mew / Wanderlust")) {
3392
                menurc = mew_wl_menurc;
3393
                n_menurc = G_N_ELEMENTS(mew_wl_menurc);
3394
        } else if (!strcmp(text, "Mutt")) {
3395
                menurc = mutt_menurc;
3396
                n_menurc = G_N_ELEMENTS(mutt_menurc);
3397
        } else if (!strcmp(text, _("Old Sylpheed"))) {
3398
                menurc = old_sylpheed_menurc;
3399
                n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
3400
        } else
3401
                return;
3402

    
3403
        prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc));
3404
        prefs_keybind_apply(menurc, n_menurc);
3405

    
3406
        gtk_widget_destroy(keybind.window);
3407
        keybind.window = NULL;
3408
        keybind.combo = NULL;
3409
}
3410

    
3411
static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
3412
{
3413
        GtkWidget *menu;
3414
        GtkWidget *menuitem;
3415
        gchar *charset;
3416

    
3417
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3418
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
3419
        charset = g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
3420
        g_free(*((gchar **)pparam->data));
3421
        *((gchar **)pparam->data) = g_strdup(charset);
3422
}
3423

    
3424
static void prefs_common_charset_set_optmenu(PrefParam *pparam)
3425
{
3426
        GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3427
        gint index;
3428

    
3429
        g_return_if_fail(optmenu != NULL);
3430
        g_return_if_fail(*((gchar **)pparam->data) != NULL);
3431

    
3432
        index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
3433
                                            (GCompareFunc)strcmp);
3434
        if (index >= 0)
3435
                gtk_option_menu_set_history(optmenu, index);
3436
        else {
3437
                gtk_option_menu_set_history(optmenu, 0);
3438
                prefs_common_charset_set_data_from_optmenu(pparam);
3439
        }
3440
}
3441

    
3442
static void prefs_common_encoding_set_data_from_optmenu(PrefParam *pparam)
3443
{
3444
        GtkWidget *menu;
3445
        GtkWidget *menuitem;
3446

    
3447
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3448
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
3449
        *((TransferEncodingMethod *)pparam->data) = GPOINTER_TO_INT
3450
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
3451
}
3452

    
3453
static void prefs_common_encoding_set_optmenu(PrefParam *pparam)
3454
{
3455
        TransferEncodingMethod method =
3456
                *((TransferEncodingMethod *)pparam->data);
3457
        GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3458
        gint index;
3459

    
3460
        g_return_if_fail(optmenu != NULL);
3461

    
3462
        index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(method),
3463
                                            NULL);
3464
        if (index >= 0)
3465
                gtk_option_menu_set_history(optmenu, index);
3466
        else {
3467
                gtk_option_menu_set_history(optmenu, 0);
3468
                prefs_common_encoding_set_data_from_optmenu(pparam);
3469
        }
3470
}
3471

    
3472
static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam)
3473
{
3474
        GtkWidget *menu;
3475
        GtkWidget *menuitem;
3476

    
3477
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3478
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
3479
        *((RecvDialogMode *)pparam->data) = GPOINTER_TO_INT
3480
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
3481
}
3482

    
3483
static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
3484
{
3485
        RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
3486
        GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3487
        GtkWidget *menu;
3488
        GtkWidget *menuitem;
3489
        gint index;
3490

    
3491
        index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(mode),
3492
                                            NULL);
3493
        if (index >= 0)
3494
                gtk_option_menu_set_history(optmenu, index);
3495
        else {
3496
                gtk_option_menu_set_history(optmenu, 0);
3497
                prefs_common_recv_dialog_set_data_from_optmenu(pparam);
3498
        }
3499

    
3500
        menu = gtk_option_menu_get_menu(optmenu);
3501
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
3502
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3503
}
3504

    
3505
static gint prefs_common_deleted(GtkWidget *widget, GdkEventAny *event,
3506
                                 gpointer data)
3507
{
3508
        prefs_common_cancel();
3509
        return TRUE;
3510
}
3511

    
3512
static gboolean prefs_common_key_pressed(GtkWidget *widget, GdkEventKey *event,
3513
                                         gpointer data)
3514
{
3515
        if (event && event->keyval == GDK_Escape)
3516
                prefs_common_cancel();
3517
        return FALSE;
3518
}
3519

    
3520
static void prefs_common_ok(void)
3521
{
3522
        prefs_common_apply();
3523
        gtk_widget_hide(dialog.window);
3524
        if (quote_desc_win && GTK_WIDGET_VISIBLE(quote_desc_win))
3525
                gtk_widget_hide(quote_desc_win);
3526

    
3527
        inc_unlock();
3528
}
3529

    
3530
static void prefs_common_apply(void)
3531
{
3532
        prefs_set_data_from_dialog(param);
3533
        main_window_reflect_prefs_all();
3534
        sock_set_io_timeout(prefs_common.io_timeout_secs);
3535
        prefs_common_write_config();
3536

    
3537
        inc_autocheck_timer_remove();
3538
        inc_autocheck_timer_set();
3539
}
3540

    
3541
static void prefs_common_cancel(void)
3542
{
3543
        gtk_widget_hide(dialog.window);
3544
        inc_unlock();
3545
}