aad3b5c409ced5d58e05b6333fac1831ff7d2920
[claws.git] / src / prefs_common.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2003 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_gtk.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 #include "filesel.h"
56 #include "folderview.h"
57 #include "stock_pixmap.h"
58 #include "quote_fmt.h"
59
60 #if USE_ASPELL
61 #include "gtkaspell.h"
62 #endif
63
64 PrefsCommon prefs_common;
65
66 static PrefsDialog dialog;
67
68 static struct Receive {
69         GtkWidget *checkbtn_incext;
70         GtkWidget *entry_incext;
71         GtkWidget *button_incext;
72
73         GtkWidget *checkbtn_local;
74         GtkWidget *checkbtn_filter_on_inc;
75         GtkWidget *entry_spool;
76
77         GtkWidget *checkbtn_autochk;
78         GtkWidget *spinbtn_autochk;
79         GtkObject *spinbtn_autochk_adj;
80
81         GtkWidget *checkbtn_chkonstartup;
82         GtkWidget *checkbtn_scan_after_inc;
83
84
85         GtkWidget *checkbtn_newmail_auto;
86         GtkWidget *checkbtn_newmail_manu;
87         GtkWidget *entry_newmail_notify_cmd;
88         GtkWidget *hbox_newmail_notify;
89         GtkWidget *optmenu_recvdialog;
90         GtkWidget *checkbtn_no_recv_err_panel;
91         GtkWidget *checkbtn_close_recv_dialog;
92 } receive;
93
94 static struct Send {
95         GtkWidget *checkbtn_extsend;
96         GtkWidget *entry_extsend;
97         GtkWidget *button_extsend;
98
99         GtkWidget *checkbtn_savemsg;
100         GtkWidget *checkbtn_queuemsg;
101         GtkWidget *optmenu_senddialog;
102
103         GtkWidget *optmenu_charset;
104         GtkWidget *optmenu_encoding_method;
105 } p_send;
106
107 static struct Compose {
108         GtkWidget *entry_fw_quotemark;
109         GtkWidget *text_fw_quotefmt;
110
111         GtkWidget *checkbtn_autoextedit;
112         GtkWidget *spinbtn_undolevel;
113         GtkObject *spinbtn_undolevel_adj;
114         GtkWidget *spinbtn_linewrap;
115         GtkObject *spinbtn_linewrap_adj;
116         GtkWidget *checkbtn_wrapquote;
117         GtkWidget *checkbtn_autowrap;
118         GtkWidget *checkbtn_wrapatsend;
119
120         GtkWidget *checkbtn_reply_account_autosel;
121         GtkWidget *checkbtn_forward_account_autosel;
122         GtkWidget *checkbtn_reedit_account_autosel;
123         GtkWidget *checkbtn_quote;
124         GtkWidget *checkbtn_default_reply_list;
125         GtkWidget *checkbtn_forward_as_attachment;
126         GtkWidget *checkbtn_redirect_keep_from;
127         GtkWidget *checkbtn_smart_wrapping;
128         GtkWidget *checkbtn_block_cursor;
129         GtkWidget *checkbtn_reply_with_quote;
130         
131         GtkWidget *checkbtn_autosave;
132         GtkWidget *entry_autosave_length;
133 } compose;
134
135         /* spelling */
136 #if USE_ASPELL
137 static struct Spelling {
138         GtkWidget *checkbtn_enable_aspell;
139         GtkWidget *entry_aspell_path;
140         GtkWidget *btn_aspell_path;
141         GtkWidget *optmenu_dictionary;
142         GtkWidget *optmenu_sugmode;
143         GtkWidget *misspelled_btn;
144         GtkWidget *checkbtn_use_alternate;
145         GtkWidget *checkbtn_check_while_typing;
146 } spelling;
147 #endif
148
149 static struct Quote {
150         GtkWidget *entry_quotemark;
151         GtkWidget *text_quotefmt;
152
153         GtkWidget *entry_fw_quotemark;
154         GtkWidget *text_fw_quotefmt;
155         
156         GtkWidget *entry_quote_chars;
157 } quote;
158
159 static struct Display {
160         GtkWidget *entry_textfont;
161         GtkWidget *button_textfont;
162
163         GtkWidget *entry_smallfont;
164         GtkWidget *entry_normalfont;
165         GtkWidget *entry_boldfont;
166
167         GtkWidget *chkbtn_folder_unread;
168         GtkWidget *entry_ng_abbrev_len;
169         GtkWidget *spinbtn_ng_abbrev_len;
170         GtkObject *spinbtn_ng_abbrev_len_adj;
171
172         GtkWidget *chkbtn_transhdr;
173
174         GtkWidget *chkbtn_swapfrom;
175         GtkWidget *chkbtn_useaddrbook;
176         GtkWidget *chkbtn_threadsubj;
177         GtkWidget *entry_datefmt;
178 } display;
179
180 static struct Message {
181         GtkWidget *chkbtn_enablecol;
182         GtkWidget *button_edit_col;
183         GtkWidget *chkbtn_mbalnum;
184         GtkWidget *chkbtn_disphdrpane;
185         GtkWidget *chkbtn_disphdr;
186         GtkWidget *spinbtn_linespc;
187         GtkObject *spinbtn_linespc_adj;
188         GtkWidget *chkbtn_headspc;
189
190         GtkWidget *chkbtn_smoothscroll;
191         GtkWidget *spinbtn_scrollstep;
192         GtkObject *spinbtn_scrollstep_adj;
193         GtkWidget *chkbtn_halfpage;
194
195         GtkWidget *chkbtn_attach_desc;
196 } message;
197
198 #if USE_GPGME
199 static struct Privacy {
200         GtkWidget *checkbtn_auto_check_signatures;
201         GtkWidget *checkbtn_gpg_signature_popup;
202         GtkWidget *checkbtn_store_passphrase;
203         GtkWidget *spinbtn_store_passphrase;
204         GtkObject *spinbtn_store_passphrase_adj;
205         GtkWidget *checkbtn_passphrase_grab;
206         GtkWidget *checkbtn_gpg_warning;
207 } privacy;
208 #endif
209
210 static struct Interface {
211         /* GtkWidget *checkbtn_emacs; */
212         GtkWidget *checkbtn_always_show_msg;
213         GtkWidget *checkbtn_openunread;
214         GtkWidget *checkbtn_mark_as_read_on_newwin;
215         GtkWidget *checkbtn_openinbox;
216         GtkWidget *checkbtn_immedexec;
217         GtkWidget *optmenu_nextunreadmsgdialog;
218         GtkWidget *entry_pixmap_theme;
219         GtkWidget *combo_pixmap_theme;
220 } interface;
221
222 static struct Other {
223         GtkWidget *uri_combo;
224         GtkWidget *uri_entry;
225         GtkWidget *printcmd_entry;
226         GtkWidget *exteditor_combo;
227         GtkWidget *exteditor_entry;
228
229         GtkWidget *checkbtn_addaddrbyclick;
230         GtkWidget *checkbtn_confonexit;
231         GtkWidget *checkbtn_cleanonexit;
232         GtkWidget *checkbtn_askonclean;
233         GtkWidget *checkbtn_warnqueued;
234         GtkWidget *checkbtn_cliplog;
235         GtkWidget *loglength_entry;
236 #if 0
237 #ifdef USE_OPENSSL
238         GtkWidget *checkbtn_ssl_ask_unknown_valid;
239 #endif
240 #endif
241
242         GtkWidget *spinbtn_iotimeout;
243         GtkObject *spinbtn_iotimeout_adj;
244 } other;
245
246 static struct MessageColorButtons {
247         GtkWidget *quote_level1_btn;
248         GtkWidget *quote_level2_btn;
249         GtkWidget *quote_level3_btn;
250         GtkWidget *uri_btn;
251         GtkWidget *tgt_folder_btn;
252         GtkWidget *signature_btn;
253 } color_buttons;
254
255 static struct KeybindDialog {
256         GtkWidget *window;
257         GtkWidget *combo;
258 } keybind;
259
260 static GtkWidget *font_sel_win;
261 static guint font_sel_conn_id; 
262 static GtkWidget *quote_color_win;
263 static GtkWidget *color_dialog;
264
265 static void prefs_common_charset_set_data_from_optmenu     (PrefParam *pparam);
266 static void prefs_common_charset_set_optmenu               (PrefParam *pparam);
267 static void prefs_common_encoding_set_data_from_optmenu    (PrefParam *pparam);
268 static void prefs_common_encoding_set_optmenu              (PrefParam *pparam);
269 static void prefs_common_recv_dialog_set_data_from_optmenu (PrefParam *pparam);
270 static void prefs_common_recv_dialog_set_optmenu           (PrefParam *pparam);
271 static void prefs_common_recv_dialog_newmail_notify_toggle_cb   (GtkWidget *w,
272                                                                  gpointer data);
273 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam);
274 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam);
275 static void prefs_common_send_dialog_set_data_from_optmenu(PrefParam *pparam);
276 static void prefs_common_send_dialog_set_optmenu(PrefParam *pparam);
277 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam);
278 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam);
279
280 #if USE_ASPELL
281 static void prefs_dictionary_set_data_from_optmenu      (PrefParam *param);
282 static void prefs_dictionary_set_optmenu                (PrefParam *pparam);
283 static void prefs_speller_sugmode_set_data_from_optmenu (PrefParam *pparam);
284 static void prefs_speller_sugmode_set_optmenu           (PrefParam *pparam);
285 #endif
286
287
288 /*
289    parameter name, default value, pointer to the prefs variable, data type,
290    pointer to the widget pointer,
291    pointer to the function for data setting,
292    pointer to the function for widget setting
293  */
294
295 static PrefParam param[] = {
296         /* Receive */
297         {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL,
298          &receive.checkbtn_incext,
299          prefs_set_data_from_toggle, prefs_set_toggle},
300         {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING,
301          &receive.entry_incext,
302          prefs_set_data_from_entry, prefs_set_entry},
303
304         {"inc_local", "TRUE", &prefs_common.inc_local, P_BOOL,
305          &receive.checkbtn_local,
306          prefs_set_data_from_toggle, prefs_set_toggle},
307         {"filter_on_inc_local", "TRUE", &prefs_common.filter_on_inc, P_BOOL,
308          &receive.checkbtn_filter_on_inc,
309          prefs_set_data_from_toggle, prefs_set_toggle},
310         {"spool_path", DEFAULT_SPOOL_PATH, &prefs_common.spool_path, P_STRING,
311          &receive.entry_spool,
312          prefs_set_data_from_entry, prefs_set_entry},
313
314         {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL,
315          &receive.checkbtn_autochk,
316          prefs_set_data_from_toggle, prefs_set_toggle},
317         {"autochk_interval", "10", &prefs_common.autochk_itv, P_INT,
318          &receive.spinbtn_autochk,
319          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
320         {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL,
321          &receive.checkbtn_chkonstartup,
322          prefs_set_data_from_toggle, prefs_set_toggle},
323         {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
324          P_BOOL, &receive.checkbtn_scan_after_inc,
325          prefs_set_data_from_toggle, prefs_set_toggle},
326         {"newmail_notify_manu", "FALSE", &prefs_common.newmail_notify_manu,
327          P_BOOL, &receive.checkbtn_newmail_manu,
328          prefs_set_data_from_toggle, prefs_set_toggle},
329         {"newmail_notify_auto", "FALSE", &prefs_common.newmail_notify_auto,
330         P_BOOL, &receive.checkbtn_newmail_auto,
331          prefs_set_data_from_toggle, prefs_set_toggle},
332         {"newmail_notify_cmd", "", &prefs_common.newmail_notify_cmd, P_STRING,
333          &receive.entry_newmail_notify_cmd,
334          prefs_set_data_from_entry, prefs_set_entry},
335         {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM,
336          &receive.optmenu_recvdialog,
337          prefs_common_recv_dialog_set_data_from_optmenu,
338          prefs_common_recv_dialog_set_optmenu},
339         {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel,
340          P_BOOL, &receive.checkbtn_no_recv_err_panel,
341          prefs_set_data_from_toggle, prefs_set_toggle},
342         {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog,
343          P_BOOL, &receive.checkbtn_close_recv_dialog,
344          prefs_set_data_from_toggle, prefs_set_toggle},
345  
346         /* Send */
347         {"use_ext_sendmail", "FALSE", &prefs_common.use_extsend, P_BOOL,
348          &p_send.checkbtn_extsend,
349          prefs_set_data_from_toggle, prefs_set_toggle},
350         {"ext_sendmail_cmd", DEFAULT_SENDMAIL_CMD,
351          &prefs_common.extsend_cmd, P_STRING,
352          &p_send.entry_extsend, prefs_set_data_from_entry, prefs_set_entry},
353         {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL,
354          &p_send.checkbtn_savemsg,
355          prefs_set_data_from_toggle, prefs_set_toggle},
356         {"queue_message", "FALSE", &prefs_common.queue_msg, P_BOOL,
357          &p_send.checkbtn_queuemsg,
358          prefs_set_data_from_toggle, prefs_set_toggle},
359         {"send_dialog_mode", "0", &prefs_common.send_dialog_mode, P_ENUM,
360          &p_send.optmenu_senddialog,
361          prefs_common_send_dialog_set_data_from_optmenu,
362          prefs_common_send_dialog_set_optmenu},
363
364         {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
365          &p_send.optmenu_charset,
366          prefs_common_charset_set_data_from_optmenu,
367          prefs_common_charset_set_optmenu},
368         {"encoding_method", "0", &prefs_common.encoding_method, P_ENUM,
369          &p_send.optmenu_encoding_method,
370          prefs_common_encoding_set_data_from_optmenu,
371          prefs_common_encoding_set_optmenu},
372
373         /* Compose */
374         {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL,
375          &compose.checkbtn_autoextedit,
376          prefs_set_data_from_toggle, prefs_set_toggle},
377         {"forward_as_attachment", "FALSE", &prefs_common.forward_as_attachment,
378          P_BOOL, &compose.checkbtn_forward_as_attachment,
379          prefs_set_data_from_toggle, prefs_set_toggle},
380         {"redirect_keep_from", "FALSE",
381          &prefs_common.redirect_keep_from, P_BOOL,
382          &compose.checkbtn_redirect_keep_from,
383          prefs_set_data_from_toggle, prefs_set_toggle},
384         {"undo_level", "50", &prefs_common.undolevels, P_INT,
385          &compose.spinbtn_undolevel,
386          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
387         {"block_cursor", "FALSE", &prefs_common.block_cursor,
388          P_BOOL, &compose.checkbtn_block_cursor,
389          prefs_set_data_from_toggle, prefs_set_toggle},
390
391         {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT,
392          &compose.spinbtn_linewrap,
393          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
394         {"linewrap_quotation", "FALSE", &prefs_common.linewrap_quote, P_BOOL,
395          &compose.checkbtn_wrapquote,
396          prefs_set_data_from_toggle, prefs_set_toggle},
397         {"linewrap_auto", "FALSE", &prefs_common.autowrap, P_BOOL,
398          &compose.checkbtn_autowrap,
399          prefs_set_data_from_toggle, prefs_set_toggle},
400         {"linewrap_before_sending", "FALSE",
401          &prefs_common.linewrap_at_send, P_BOOL,
402          &compose.checkbtn_wrapatsend,
403          prefs_set_data_from_toggle, prefs_set_toggle},
404         {"smart_wrapping", "TRUE", &prefs_common.smart_wrapping,
405          P_BOOL, &compose.checkbtn_smart_wrapping,
406          prefs_set_data_from_toggle, prefs_set_toggle},
407         {"autosave", "FALSE", &prefs_common.autosave,
408          P_BOOL, &compose.checkbtn_autosave,
409          prefs_set_data_from_toggle, prefs_set_toggle},
410         {"autosave_length", "50", &prefs_common.autosave_length,
411          P_INT, &compose.entry_autosave_length,
412          prefs_set_data_from_entry, prefs_set_entry},
413 #if USE_ASPELL
414         {"enable_aspell", "TRUE", &prefs_common.enable_aspell,
415          P_BOOL, &spelling.checkbtn_enable_aspell,
416          prefs_set_data_from_toggle, prefs_set_toggle},
417         {"aspell_path", ASPELL_PATH, &prefs_common.aspell_path, 
418          P_STRING, &spelling.entry_aspell_path, 
419          prefs_set_data_from_entry, prefs_set_entry},
420         {"dictionary",  "", &prefs_common.dictionary,
421          P_STRING, &spelling.optmenu_dictionary, 
422          prefs_dictionary_set_data_from_optmenu, prefs_dictionary_set_optmenu },
423         {"aspell_sugmode",  "1", &prefs_common.aspell_sugmode,
424          P_INT, &spelling.optmenu_sugmode, 
425          prefs_speller_sugmode_set_data_from_optmenu, prefs_speller_sugmode_set_optmenu },
426         {"use_alternate_dict", "FALSE", &prefs_common.use_alternate,
427          P_BOOL, &spelling.checkbtn_use_alternate,
428          prefs_set_data_from_toggle, prefs_set_toggle},
429         {"check_while_typing", "TRUE", &prefs_common.check_while_typing,
430          P_BOOL, &spelling.checkbtn_check_while_typing,
431          prefs_set_data_from_toggle, prefs_set_toggle},
432         {"misspelled_color", "16711680", &prefs_common.misspelled_col, P_COLOR,
433          NULL, NULL, NULL},
434 #endif
435         {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
436          &compose.checkbtn_reply_with_quote, prefs_set_data_from_toggle, prefs_set_toggle},
437
438         /* Account autoselection */
439         {"reply_account_autoselect", "TRUE",
440          &prefs_common.reply_account_autosel, P_BOOL,
441          &compose.checkbtn_reply_account_autosel,
442          prefs_set_data_from_toggle, prefs_set_toggle},
443         {"forward_account_autoselect", "TRUE",
444          &prefs_common.forward_account_autosel, P_BOOL,
445          &compose.checkbtn_forward_account_autosel,
446          prefs_set_data_from_toggle, prefs_set_toggle},
447         {"reedit_account_autoselect", "TRUE",
448          &prefs_common.reedit_account_autosel, P_BOOL,
449          &compose.checkbtn_reedit_account_autosel,
450          prefs_set_data_from_toggle, prefs_set_toggle},
451
452         {"default_reply_list", "TRUE", &prefs_common.default_reply_list, P_BOOL,
453          &compose.checkbtn_default_reply_list,
454          prefs_set_data_from_toggle, prefs_set_toggle},
455
456         {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
457          NULL, NULL, NULL},
458
459         /* Quote */
460         {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
461          &quote.entry_quotemark, prefs_set_data_from_entry, prefs_set_entry},
462         {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q",
463          &prefs_common.quotefmt, P_STRING, &quote.text_quotefmt,
464          prefs_set_data_from_text, prefs_set_text},
465
466         {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING,
467          &quote.entry_fw_quotemark,
468          prefs_set_data_from_entry, prefs_set_entry},
469         {"forward_quote_format",
470          "\\n\\nBegin forwarded message:\\n\\n"
471          "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
472          "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M",
473          &prefs_common.fw_quotefmt, P_STRING, &quote.text_fw_quotefmt,
474          prefs_set_data_from_text, prefs_set_text},
475         {"quote_chars", ">", &prefs_common.quote_chars, P_STRING,
476          &quote.entry_quote_chars, prefs_set_data_from_entry, prefs_set_entry},
477
478         /* Display */
479         {"widget_font", NULL, &prefs_common.widgetfont, P_STRING,
480          NULL, NULL, NULL},
481         {"message_font", "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*",
482          &prefs_common.textfont, P_STRING,
483          &display.entry_textfont,
484          prefs_set_data_from_entry, prefs_set_entry},
485         {"small_font",   "-*-helvetica-medium-r-normal--10-*-*-*-*-*-*-*",
486          &prefs_common.smallfont,   P_STRING,
487          &display.entry_smallfont,
488          prefs_set_data_from_entry, prefs_set_entry},
489         {"bold_font",    "-*-helvetica-bold-r-normal--12-*-*-*-*-*-*-*",
490          &prefs_common.boldfont,    P_STRING,
491          &display.entry_boldfont,
492          prefs_set_data_from_entry, prefs_set_entry},
493         {"normal_font",  "-*-helvetica-medium-r-normal--12-*-*-*-*-*-*-*",
494          &prefs_common.normalfont,  P_STRING,
495          &display.entry_normalfont, 
496          prefs_set_data_from_entry, prefs_set_entry},
497
498
499         {"display_folder_unread_num", "TRUE",
500          &prefs_common.display_folder_unread, P_BOOL,
501          &display.chkbtn_folder_unread,
502          prefs_set_data_from_toggle, prefs_set_toggle},
503         {"newsgroup_abbrev_len", "16",
504          &prefs_common.ng_abbrev_len, P_INT,
505          &display.spinbtn_ng_abbrev_len,
506          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
507
508         {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL,
509          &display.chkbtn_transhdr,
510          prefs_set_data_from_toggle, prefs_set_toggle},
511
512         /* Display: Summary View */
513         {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
514          &display.chkbtn_swapfrom,
515          prefs_set_data_from_toggle, prefs_set_toggle},
516         {"use_address_book", "TRUE", &prefs_common.use_addr_book, P_BOOL,
517          &display.chkbtn_useaddrbook,
518          prefs_set_data_from_toggle, prefs_set_toggle},
519         {"thread_by_subject", "TRUE", &prefs_common.thread_by_subject, P_BOOL,
520          &display.chkbtn_threadsubj,
521          prefs_set_data_from_toggle, prefs_set_toggle},
522         {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
523          P_STRING, &display.entry_datefmt,
524          prefs_set_data_from_entry, prefs_set_entry},
525
526         {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
527          NULL, NULL, NULL},
528         {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL,
529          NULL, NULL, NULL},
530         {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
531         P_INT, NULL, NULL, NULL },
532
533         {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL,
534          NULL, NULL, NULL},
535         {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM,
536          NULL, NULL, NULL},
537         {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
538          NULL, NULL, NULL},
539         {"show_searchbar", "TRUE", &prefs_common.show_searchbar, P_BOOL,
540          NULL, NULL, NULL},
541
542         {"folderview_vscrollbar_policy", "0",
543          &prefs_common.folderview_vscrollbar_policy, P_ENUM,
544          NULL, NULL, NULL},
545
546         {"summary_col_show_mark", "TRUE",
547          &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL, NULL, NULL, NULL},
548         {"summary_col_show_unread", "TRUE",
549          &prefs_common.summary_col_visible[S_COL_STATUS], P_BOOL, NULL, NULL, NULL},
550         {"summary_col_show_mime", "TRUE",
551          &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
552         {"summary_col_show_subject", "TRUE",
553          &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL, NULL, NULL, NULL},
554         {"summary_col_show_from", "TRUE",
555          &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL, NULL, NULL, NULL},
556         {"summary_col_show_date", "TRUE",
557          &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL, NULL, NULL, NULL},
558         {"summary_col_show_size", "TRUE",
559          &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL, NULL, NULL, NULL},
560         {"summary_col_show_number", "FALSE",
561          &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL, NULL, NULL, NULL},
562         {"summary_col_show_score", "FALSE",
563          &prefs_common.summary_col_visible[S_COL_SCORE], P_BOOL, NULL, NULL, NULL},
564         {"summary_col_show_locked", "FALSE",
565          &prefs_common.summary_col_visible[S_COL_LOCKED], P_BOOL, NULL, NULL, NULL},
566
567         {"summary_col_pos_mark", "0",
568           &prefs_common.summary_col_pos[S_COL_MARK], P_INT, NULL, NULL, NULL},
569         {"summary_col_pos_unread", "1",
570           &prefs_common.summary_col_pos[S_COL_STATUS], P_INT, NULL, NULL, NULL},
571         {"summary_col_pos_mime", "2",
572           &prefs_common.summary_col_pos[S_COL_MIME], P_INT, NULL, NULL, NULL},
573         {"summary_col_pos_subject", "3",
574           &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
575         {"summary_col_pos_from", "4",
576           &prefs_common.summary_col_pos[S_COL_FROM], P_INT, NULL, NULL, NULL},
577         {"summary_col_pos_date", "5",
578           &prefs_common.summary_col_pos[S_COL_DATE], P_INT, NULL, NULL, NULL},
579         {"summary_col_pos_size", "6",
580           &prefs_common.summary_col_pos[S_COL_SIZE], P_INT, NULL, NULL, NULL},
581         {"summary_col_pos_number", "7",
582           &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
583         {"summary_col_pos_score", "8",
584          &prefs_common.summary_col_pos[S_COL_SCORE], P_INT, NULL, NULL, NULL},
585         {"summary_col_pos_locked", "9",
586          &prefs_common.summary_col_pos[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
587
588         {"summary_col_size_mark", "10",
589          &prefs_common.summary_col_size[S_COL_MARK], P_INT, NULL, NULL, NULL},
590         {"summary_col_size_unread", "13",
591          &prefs_common.summary_col_size[S_COL_STATUS], P_INT, NULL, NULL, NULL},
592         {"summary_col_size_mime", "10",
593          &prefs_common.summary_col_size[S_COL_MIME], P_INT, NULL, NULL, NULL},
594         {"summary_col_size_subject", "200",
595          &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
596         {"summary_col_size_from", "120",
597          &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
598         {"summary_col_size_date", "118",
599          &prefs_common.summary_col_size[S_COL_DATE], P_INT, NULL, NULL, NULL},
600         {"summary_col_size_size", "45",
601          &prefs_common.summary_col_size[S_COL_SIZE], P_INT, NULL, NULL, NULL},
602         {"summary_col_size_number", "40",
603          &prefs_common.summary_col_size[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
604         {"summary_col_size_score", "40",
605          &prefs_common.summary_col_size[S_COL_SCORE], P_INT, NULL, NULL, NULL},
606         {"summary_col_size_locked", "13",
607          &prefs_common.summary_col_size[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
608
609         /* Widget size */
610         {"folderview_width", "179", &prefs_common.folderview_width, P_INT,
611          NULL, NULL, NULL},
612         {"folderview_height", "600", &prefs_common.folderview_height, P_INT,
613          NULL, NULL, NULL},
614         {"folder_col_folder", "150", &prefs_common.folder_col_folder, P_INT,
615          NULL, NULL, NULL},
616         {"folder_col_new", "32", &prefs_common.folder_col_new, P_INT,
617          NULL, NULL, NULL},
618         {"folder_col_unread", "32", &prefs_common.folder_col_unread, P_INT,
619          NULL, NULL, NULL},
620         {"folder_col_total", "32", &prefs_common.folder_col_total, P_INT,
621          NULL, NULL, NULL},
622
623         {"summaryview_width", "600", &prefs_common.summaryview_width, P_INT,
624          NULL, NULL, NULL},
625         {"summaryview_height", "173", &prefs_common.summaryview_height, P_INT,
626          NULL, NULL, NULL},
627
628         {"mainview_x", "64", &prefs_common.mainview_x, P_INT,
629          NULL, NULL, NULL},
630         {"mainview_y", "64", &prefs_common.mainview_y, P_INT,
631          NULL, NULL, NULL},
632         {"mainview_width", "600", &prefs_common.mainview_width, P_INT,
633          NULL, NULL, NULL},
634         {"mainview_height", "600", &prefs_common.mainview_height, P_INT,
635          NULL, NULL, NULL},
636         {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT,
637          NULL, NULL, NULL},
638         {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT,
639          NULL, NULL, NULL},
640         {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT,
641          NULL, NULL, NULL},
642         {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT,
643          NULL, NULL, NULL},
644         {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT,
645          NULL, NULL, NULL},
646         {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT,
647          NULL, NULL, NULL},
648         {"sourcewin_width", "600", &prefs_common.sourcewin_width, P_INT,
649          NULL, NULL, NULL},
650         {"sourcewin_height", "500", &prefs_common.sourcewin_height, P_INT,
651          NULL, NULL, NULL},
652         {"compose_width", "600", &prefs_common.compose_width, P_INT,
653          NULL, NULL, NULL},
654         {"compose_height", "560", &prefs_common.compose_height, P_INT,
655          NULL, NULL, NULL},
656
657         /* Message */
658         {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
659          &message.chkbtn_enablecol,
660          prefs_set_data_from_toggle, prefs_set_toggle},
661
662         {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_COLOR,
663          NULL, NULL, NULL},
664         {"quote_level2_color", "179", &prefs_common.quote_level2_col, P_COLOR,
665          NULL, NULL, NULL},
666         {"quote_level3_color", "179", &prefs_common.quote_level3_col, P_COLOR,
667          NULL, NULL, NULL},
668         {"uri_color", "32512", &prefs_common.uri_col, P_COLOR,
669          NULL, NULL, NULL},
670         {"target_folder_color", "14294218", &prefs_common.tgt_folder_col, P_COLOR,
671          NULL, NULL, NULL},
672         {"signature_color", "7960953", &prefs_common.signature_col, P_COLOR,
673          NULL, NULL, NULL},
674         {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
675          P_BOOL, NULL, NULL, NULL},
676
677         {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL,
678          &message.chkbtn_mbalnum,
679          prefs_set_data_from_toggle, prefs_set_toggle},
680         {"display_header_pane", "TRUE", &prefs_common.display_header_pane,
681          P_BOOL, &message.chkbtn_disphdrpane,
682          prefs_set_data_from_toggle, prefs_set_toggle},
683         {"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
684          &message.chkbtn_disphdr,
685          prefs_set_data_from_toggle, prefs_set_toggle},
686         {"line_space", "2", &prefs_common.line_space, P_INT,
687          &message.spinbtn_linespc,
688          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
689         {"enable_head_space", "FALSE", &prefs_common.head_space, P_BOOL,
690          &message.chkbtn_headspc,
691          prefs_set_data_from_toggle, prefs_set_toggle},
692
693         {"enable_smooth_scroll", "FALSE",
694          &prefs_common.enable_smooth_scroll, P_BOOL,
695          &message.chkbtn_smoothscroll,
696          prefs_set_data_from_toggle, prefs_set_toggle},
697         {"scroll_step", "1", &prefs_common.scroll_step, P_INT,
698          &message.spinbtn_scrollstep,
699          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
700         {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL,
701          &message.chkbtn_halfpage,
702          prefs_set_data_from_toggle, prefs_set_toggle},
703
704         {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
705          NULL, NULL, NULL},
706
707         {"attach_desc", "TRUE", &prefs_common.attach_desc, P_BOOL,
708          &message.chkbtn_attach_desc,
709          prefs_set_data_from_toggle, prefs_set_toggle},
710
711         /* MIME viewer */
712         {"mime_image_viewer", "display '%s'",
713          &prefs_common.mime_image_viewer, P_STRING, NULL, NULL, NULL},
714         {"mime_audio_player", "play '%s'",
715          &prefs_common.mime_audio_player, P_STRING, NULL, NULL, NULL},
716         {"mime_open_command", "gedit '%s'",
717          &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL},
718
719 #if USE_GPGME
720         /* Privacy */
721         {"auto_check_signatures", "TRUE",
722          &prefs_common.auto_check_signatures, P_BOOL,
723          &privacy.checkbtn_auto_check_signatures,
724          prefs_set_data_from_toggle, prefs_set_toggle},
725         {"gpg_signature_popup", "FALSE",
726          &prefs_common.gpg_signature_popup, P_BOOL,
727          &privacy.checkbtn_gpg_signature_popup,
728          prefs_set_data_from_toggle, prefs_set_toggle},
729         {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL,
730          &privacy.checkbtn_store_passphrase,
731          prefs_set_data_from_toggle, prefs_set_toggle},
732         {"store_passphrase_timeout", "0",
733          &prefs_common.store_passphrase_timeout, P_INT,
734          &privacy.spinbtn_store_passphrase,
735          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
736 #ifndef __MINGW32__
737         {"passphrase_grab", "FALSE", &prefs_common.passphrase_grab, P_BOOL,
738          &privacy.checkbtn_passphrase_grab,
739          prefs_set_data_from_toggle, prefs_set_toggle},
740 #endif /* __MINGW32__ */
741         {"gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL,
742          &privacy.checkbtn_gpg_warning,
743          prefs_set_data_from_toggle, prefs_set_toggle},
744 #endif /* USE_GPGME */
745
746         /* Interface */
747         {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL,
748          NULL, NULL, NULL},
749         {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL,
750          NULL, NULL, NULL},
751
752         /* {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
753          NULL, NULL, NULL}, */
754         {"always_show_message_when_selected", "FALSE",
755          &prefs_common.always_show_msg,
756          P_BOOL, &interface.checkbtn_always_show_msg,
757          prefs_set_data_from_toggle, prefs_set_toggle},
758         {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter,
759          P_BOOL, &interface.checkbtn_openunread,
760          prefs_set_data_from_toggle, prefs_set_toggle},
761         {"mark_as_read_on_new_window", "FALSE",
762          &prefs_common.mark_as_read_on_new_window,
763          P_BOOL, &interface.checkbtn_mark_as_read_on_newwin,
764          prefs_set_data_from_toggle, prefs_set_toggle},
765         {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc,
766          P_BOOL, &interface.checkbtn_openinbox,
767          prefs_set_data_from_toggle, prefs_set_toggle},
768         {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL,
769          &interface.checkbtn_immedexec,
770          prefs_set_data_from_toggle, prefs_set_toggle},
771         {"nextunreadmsg_dialog", NULL, &prefs_common.next_unread_msg_dialog, P_ENUM,
772          &interface.optmenu_nextunreadmsgdialog,
773          prefs_nextunreadmsgdialog_set_data_from_optmenu,
774          prefs_nextunreadmsgdialog_set_optmenu},
775
776         {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
777          &prefs_common.pixmap_theme_path, P_STRING,
778          &interface.entry_pixmap_theme, prefs_set_data_from_entry, prefs_set_entry},
779
780         {"hover_timeout", "500", &prefs_common.hover_timeout, P_INT,
781          NULL, NULL, NULL},
782         
783         /* Other */
784         {"uri_open_command", DEFAULT_BROWSER_CMD,
785          &prefs_common.uri_cmd, P_STRING,
786          &other.uri_entry, prefs_set_data_from_entry, prefs_set_entry},
787         {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING,
788          &other.printcmd_entry, prefs_set_data_from_entry, prefs_set_entry},
789         {"ext_editor_command", "gedit %s",
790          &prefs_common.ext_editor_cmd, P_STRING,
791          &other.exteditor_entry, prefs_set_data_from_entry, prefs_set_entry},
792
793         {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
794          P_BOOL, &other.checkbtn_addaddrbyclick,
795          prefs_set_data_from_toggle, prefs_set_toggle},
796
797         {"confirm_on_exit", "TRUE", &prefs_common.confirm_on_exit, P_BOOL,
798          &other.checkbtn_confonexit,
799          prefs_set_data_from_toggle, prefs_set_toggle},
800         {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL,
801          &other.checkbtn_cleanonexit,
802          prefs_set_data_from_toggle, prefs_set_toggle},
803         {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL,
804          &other.checkbtn_askonclean,
805          prefs_set_data_from_toggle, prefs_set_toggle},
806         {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
807          P_BOOL, &other.checkbtn_warnqueued,
808          prefs_set_data_from_toggle, prefs_set_toggle},
809 #if 0
810 #ifdef USE_OPENSSL
811         {"ssl_ask_unknown_valid", "TRUE", &prefs_common.ssl_ask_unknown_valid,
812          P_BOOL, &other.checkbtn_ssl_ask_unknown_valid,
813          prefs_set_data_from_toggle, prefs_set_toggle},
814 #endif
815 #endif
816         {"work_offline", "FALSE", &prefs_common.work_offline, P_BOOL,
817          NULL, NULL, NULL},
818         {"summary_quicksearch_type", "0", &prefs_common.summary_quicksearch_type, P_INT,
819          NULL, NULL, NULL},
820
821         {"io_timeout_secs", "60", &prefs_common.io_timeout_secs,
822          P_INT, &other.spinbtn_iotimeout,
823          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
824         {"hide_score", "-9999", &prefs_common.kill_score, P_INT,
825          NULL, NULL, NULL},
826         {"important_score", "1", &prefs_common.important_score, P_INT,
827          NULL, NULL, NULL},
828         {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
829          &other.checkbtn_cliplog,
830          prefs_set_data_from_toggle, prefs_set_toggle},
831         {"log_length", "500", &prefs_common.loglength, P_INT,
832          &other.loglength_entry,
833          prefs_set_data_from_entry, prefs_set_entry},
834
835         {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
836          NULL, NULL, NULL},
837         {"cache_min_keep_time", "15", &prefs_common.cache_min_keep_time, P_INT,
838          NULL, NULL, NULL},
839
840         {"color_new", "179", &prefs_common.color_new, P_COLOR,
841          NULL, NULL, NULL},
842
843         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
844 };
845
846 /* widget creating functions */
847 static void prefs_common_create         (void);
848 static void prefs_receive_create        (void);
849 static void prefs_send_create           (void);
850 #ifdef USE_ASPELL
851 static void prefs_spelling_create       (void);
852 #endif
853 static void prefs_compose_create        (void);
854 static void prefs_quote_create          (void);
855 static void prefs_display_create        (void);
856 static void prefs_message_create        (void);
857 #if USE_GPGME
858 static void prefs_privacy_create        (void);
859 #endif
860 static void prefs_interface_create      (void);
861 static void prefs_other_create          (void);
862
863 static void date_format_ok_btn_clicked          (GtkButton      *button,
864                                                  GtkWidget     **widget);
865 static void date_format_cancel_btn_clicked      (GtkButton      *button,
866                                                  GtkWidget     **widget);
867 static void date_format_key_pressed             (GtkWidget      *keywidget,
868                                                  GdkEventKey    *event,
869                                                  GtkWidget     **widget);
870 static gboolean date_format_on_delete           (GtkWidget      *dialogwidget,
871                                                  GdkEventAny    *event,
872                                                  GtkWidget     **widget);
873 static void date_format_entry_on_change         (GtkEditable    *editable,
874                                                  GtkLabel       *example);
875 static void date_format_select_row              (GtkWidget      *date_format_list,
876                                                  gint            row,
877                                                  gint            column,
878                                                  GdkEventButton *event,
879                                                  GtkWidget      *date_format);
880 static GtkWidget *date_format_create            (GtkButton      *button,
881                                                  void           *data);
882
883 static void prefs_quote_colors_dialog           (void);
884 static void prefs_quote_colors_dialog_create    (void);
885 static void prefs_quote_colors_key_pressed      (GtkWidget      *widget,
886                                                  GdkEventKey    *event,
887                                                  gpointer        data);
888 static void quote_color_set_dialog              (GtkWidget      *widget,
889                                                  gpointer        data);
890 static void quote_colors_set_dialog_ok          (GtkWidget      *widget,
891                                                  gpointer        data);
892 static void quote_colors_set_dialog_cancel      (GtkWidget      *widget,
893                                                  gpointer        data);
894 static void quote_colors_set_dialog_key_pressed (GtkWidget      *widget,
895                                                  GdkEventKey    *event,
896                                                  gpointer        data);
897 static void set_button_bg_color                 (GtkWidget      *widget,
898                                                  gint            color);
899 static void prefs_enable_message_color_toggled  (void);
900 static void prefs_recycle_colors_toggled        (GtkWidget      *widget);
901
902 static void prefs_font_select   (GtkButton *button, GtkEntry *entry);
903
904 static void prefs_font_selection_key_pressed    (GtkWidget      *widget,
905                                                  GdkEventKey    *event,
906                                                  gpointer        data);
907 static void prefs_font_selection_ok             (GtkButton      *button, GtkEntry *entry);
908
909 static void prefs_keybind_select                (void);
910 static gint prefs_keybind_deleted               (GtkWidget      *widget,
911                                                  GdkEventAny    *event,
912                                                  gpointer        data);
913 static void prefs_keybind_key_pressed           (GtkWidget      *widget,
914                                                  GdkEventKey    *event,
915                                                  gpointer        data);
916 static void prefs_keybind_cancel                (void);
917 static void prefs_keybind_apply_clicked         (GtkWidget      *widget);
918
919 static gint prefs_common_deleted        (GtkWidget      *widget,
920                                          GdkEventAny    *event,
921                                          gpointer        data);
922 static void prefs_common_key_pressed    (GtkWidget      *widget,
923                                          GdkEventKey    *event,
924                                          gpointer        data);
925 static void prefs_common_ok             (void);
926 static void prefs_common_apply          (void);
927 static void prefs_common_cancel         (void);
928
929 void prefs_common_init(void) 
930 {
931         prefs_common.disphdr_list = NULL;
932 }
933
934 PrefsCommon *prefs_common_get(void)
935 {
936         return &prefs_common;
937 }
938
939 void prefs_common_read_config(void)
940 {
941         FILE *fp;
942         gchar *path;
943         gchar buf[PREFSBUFSIZE];
944
945         prefs_read_config(param, "Common", COMMON_RC);
946
947         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
948                            NULL);
949         if ((fp = fopen(path, "rb")) == NULL) {
950                 if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
951                 g_free(path);
952                 return;
953         }
954         g_free(path);
955         while (fgets(buf, sizeof(buf), fp) != NULL) {
956                 g_strstrip(buf);
957                 if (buf[0] == '\0') continue;
958                 prefs_common.mime_open_cmd_history =
959                         add_history(prefs_common.mime_open_cmd_history, buf);
960         }
961         fclose(fp);
962
963         prefs_common.mime_open_cmd_history =
964                 g_list_reverse(prefs_common.mime_open_cmd_history);
965 }
966
967 void prefs_common_save_config(void)
968 {
969         GList *cur;
970         FILE *fp;
971         gchar *path;
972
973         prefs_save_config(param, "Common", COMMON_RC);
974
975         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
976                            NULL);
977         if ((fp = fopen(path, "wb")) == NULL) {
978                 FILE_OP_ERROR(path, "fopen");
979                 g_free(path);
980                 return;
981         }
982
983         for (cur = prefs_common.mime_open_cmd_history;
984              cur != NULL; cur = cur->next) {
985                 fputs((gchar *)cur->data, fp);
986                 fputc('\n', fp);
987         }
988
989         fclose(fp);
990         g_free(path);
991 }
992
993 void prefs_common_open(void)
994 {
995         if (prefs_rc_is_readonly(COMMON_RC))
996                 return;
997
998         inc_lock();
999
1000         if (!dialog.window) {
1001                 prefs_common_create();
1002         }
1003
1004         manage_window_set_transient(GTK_WINDOW(dialog.window));
1005         gtk_notebook_set_page(GTK_NOTEBOOK(dialog.notebook), 0);
1006         gtk_widget_grab_focus(dialog.ok_btn);
1007
1008         prefs_set_dialog(param);
1009
1010         gtk_widget_show(dialog.window);
1011 }
1012
1013 static void prefs_common_create(void)
1014 {
1015         gint page = 0;
1016
1017         debug_print("Creating common preferences window...\n");
1018
1019         prefs_dialog_create(&dialog);
1020         gtk_window_set_title (GTK_WINDOW(dialog.window),
1021                               _("Common Preferences"));
1022         gtk_signal_connect (GTK_OBJECT(dialog.window), "delete_event",
1023                             GTK_SIGNAL_FUNC(prefs_common_deleted), NULL);
1024         gtk_signal_connect (GTK_OBJECT(dialog.window), "key_press_event",
1025                             GTK_SIGNAL_FUNC(prefs_common_key_pressed), NULL);
1026         MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
1027
1028         gtk_signal_connect (GTK_OBJECT(dialog.ok_btn), "clicked",
1029                             GTK_SIGNAL_FUNC(prefs_common_ok), NULL);
1030         gtk_signal_connect (GTK_OBJECT(dialog.apply_btn), "clicked",
1031                             GTK_SIGNAL_FUNC(prefs_common_apply), NULL);
1032         gtk_signal_connect_object (GTK_OBJECT(dialog.cancel_btn), "clicked",
1033                                    GTK_SIGNAL_FUNC(prefs_common_cancel),
1034                                    GTK_OBJECT(dialog.window));
1035
1036         /* create all widgets on notebook */
1037         prefs_receive_create();
1038         SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"),   page++);
1039         prefs_send_create();
1040         SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"),      page++);
1041         prefs_compose_create();
1042         SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"),   page++);
1043 #if USE_ASPELL
1044         prefs_spelling_create();
1045         SET_NOTEBOOK_LABEL(dialog.notebook, _("Spell Checker"),   page++);
1046 #endif  
1047         prefs_quote_create();
1048         SET_NOTEBOOK_LABEL(dialog.notebook, _("Quote"),   page++);
1049         prefs_display_create();
1050         SET_NOTEBOOK_LABEL(dialog.notebook, _("Display"),   page++);
1051         prefs_message_create();
1052         SET_NOTEBOOK_LABEL(dialog.notebook, _("Message"),   page++);
1053 #if USE_GPGME
1054         prefs_privacy_create();
1055         SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"),   page++);
1056 #endif
1057         prefs_interface_create();
1058         SET_NOTEBOOK_LABEL(dialog.notebook, _("Interface"), page++);
1059         prefs_other_create();
1060         SET_NOTEBOOK_LABEL(dialog.notebook, _("Other"),     page++);
1061
1062         gtk_widget_show_all(dialog.window);
1063 }
1064
1065 static void prefs_receive_create(void)
1066 {
1067         GtkWidget *vbox1;
1068         GtkWidget *vbox2;
1069         GtkWidget *frame_incext;
1070         GtkWidget *checkbtn_incext;
1071         GtkWidget *hbox;
1072         GtkWidget *label_incext;
1073         GtkWidget *entry_incext;
1074         /* GtkWidget *button_incext; */
1075
1076         GtkWidget *frame_spool;
1077         GtkWidget *checkbtn_local;
1078         GtkWidget *checkbtn_filter_on_inc;
1079         GtkWidget *label_spool;
1080         GtkWidget *entry_spool;
1081
1082         GtkWidget *hbox_autochk;
1083         GtkWidget *checkbtn_autochk;
1084         GtkWidget *label_autochk1;
1085         GtkObject *spinbtn_autochk_adj;
1086         GtkWidget *spinbtn_autochk;
1087         GtkWidget *label_autochk2;
1088         GtkWidget *checkbtn_chkonstartup;
1089         GtkWidget *checkbtn_scan_after_inc;
1090
1091
1092         GtkWidget *frame_newmail;
1093         GtkWidget *hbox_newmail_notify;
1094         GtkWidget *checkbtn_newmail_auto;
1095         GtkWidget *checkbtn_newmail_manu;
1096         GtkWidget *entry_newmail_notify_cmd;
1097         GtkWidget *label_newmail_notify_cmd;
1098
1099         GtkWidget *hbox_recvdialog;
1100         GtkWidget *label_recvdialog;
1101         GtkWidget *menu;
1102         GtkWidget *menuitem;
1103         GtkWidget *optmenu_recvdialog;
1104         GtkWidget *checkbtn_no_recv_err_panel;
1105         GtkWidget *checkbtn_close_recv_dialog;
1106
1107         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1108         gtk_widget_show (vbox1);
1109         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1110         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1111
1112         PACK_FRAME(vbox1, frame_incext, _("External program"));
1113
1114         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1115         gtk_widget_show (vbox2);
1116         gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
1117         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1118
1119         /* Use of external incorporation program */
1120         PACK_CHECK_BUTTON (vbox2, checkbtn_incext,
1121                            _("Use external program for incorporation"));
1122
1123         hbox = gtk_hbox_new (FALSE, 8);
1124         gtk_widget_show (hbox);
1125         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1126         SET_TOGGLE_SENSITIVITY (checkbtn_incext, hbox);
1127
1128         label_incext = gtk_label_new (_("Command"));
1129         gtk_widget_show (label_incext);
1130         gtk_box_pack_start (GTK_BOX (hbox), label_incext, FALSE, FALSE, 0);
1131
1132         entry_incext = gtk_entry_new ();
1133         gtk_widget_show (entry_incext);
1134         gtk_box_pack_start (GTK_BOX (hbox), entry_incext, TRUE, TRUE, 0);
1135
1136 #if 0
1137         button_incext = gtk_button_new_with_label ("... ");
1138         gtk_widget_show (button_incext);
1139         gtk_box_pack_start (GTK_BOX (hbox), button_incext, FALSE, FALSE, 0);
1140 #endif
1141
1142         PACK_FRAME(vbox1, frame_spool, _("Local spool"));
1143
1144         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1145         gtk_widget_show (vbox2);
1146         gtk_container_add (GTK_CONTAINER (frame_spool), vbox2);
1147         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1148
1149         hbox = gtk_hbox_new (FALSE, 32);
1150         gtk_widget_show (hbox);
1151         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1152
1153         PACK_CHECK_BUTTON (hbox, checkbtn_local, _("Incorporate from spool"));
1154         PACK_CHECK_BUTTON (hbox, checkbtn_filter_on_inc,
1155                            _("Filter on incorporation"));
1156         SET_TOGGLE_SENSITIVITY (checkbtn_local, checkbtn_filter_on_inc);
1157
1158         hbox = gtk_hbox_new (FALSE, 8);
1159         gtk_widget_show (hbox);
1160         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1161         SET_TOGGLE_SENSITIVITY (checkbtn_local, hbox);
1162
1163         label_spool = gtk_label_new (_("Spool directory"));
1164         gtk_widget_show (label_spool);
1165         gtk_box_pack_start (GTK_BOX (hbox), label_spool, FALSE, FALSE, 0);
1166
1167         entry_spool = gtk_entry_new ();
1168         gtk_widget_show (entry_spool);
1169         gtk_box_pack_start (GTK_BOX (hbox), entry_spool, TRUE, TRUE, 0);
1170
1171         vbox2 = gtk_vbox_new (FALSE, 0);
1172         gtk_widget_show (vbox2);
1173         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1174
1175         /* Auto-checking */
1176         hbox_autochk = gtk_hbox_new (FALSE, 8);
1177         gtk_widget_show (hbox_autochk);
1178         gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
1179
1180         PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
1181                            _("Auto-check new mail"));
1182
1183         label_autochk1 = gtk_label_new (_("every"));
1184         gtk_widget_show (label_autochk1);
1185         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
1186
1187         spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
1188         spinbtn_autochk = gtk_spin_button_new
1189                 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
1190         gtk_widget_show (spinbtn_autochk);
1191         gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
1192         gtk_widget_set_usize (spinbtn_autochk, 64, -1);
1193         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
1194
1195         label_autochk2 = gtk_label_new (_("minute(s)"));
1196         gtk_widget_show (label_autochk2);
1197         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
1198
1199         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
1200         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
1201         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
1202
1203         PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
1204                            _("Check new mail on startup"));
1205         PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
1206                            _("Update all local folders after incorporation"));
1207
1208
1209         /* receive dialog */
1210         hbox_recvdialog = gtk_hbox_new (FALSE, 8);
1211         gtk_widget_show (hbox_recvdialog);
1212         gtk_box_pack_start (GTK_BOX (vbox2), hbox_recvdialog, FALSE, FALSE, 0);
1213
1214         label_recvdialog = gtk_label_new (_("Show receive dialog"));
1215         gtk_misc_set_alignment(GTK_MISC(label_recvdialog), 0, 0.5);
1216         gtk_widget_show (label_recvdialog);
1217         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), label_recvdialog, FALSE, FALSE, 0);
1218
1219         optmenu_recvdialog = gtk_option_menu_new ();
1220         gtk_widget_show (optmenu_recvdialog);
1221         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), optmenu_recvdialog, FALSE, FALSE, 0);
1222
1223         menu = gtk_menu_new ();
1224         MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
1225         MENUITEM_ADD (menu, menuitem, _("Only if a window is active"),
1226                       RECV_DIALOG_ACTIVE);
1227         MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
1228
1229         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
1230
1231         PACK_CHECK_BUTTON (vbox2, checkbtn_no_recv_err_panel,
1232                            _("Don't popup error dialog on receive error"));
1233
1234         PACK_CHECK_BUTTON (vbox2, checkbtn_close_recv_dialog,
1235                            _("Close receive dialog when finished"));
1236         
1237         PACK_FRAME(vbox1, frame_newmail, _("Run command when new mail "
1238                                            "arrives"));
1239         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1240         gtk_widget_show (vbox2);
1241         gtk_container_add (GTK_CONTAINER (frame_newmail), vbox2);
1242         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1243
1244         hbox = gtk_hbox_new (TRUE, 8);
1245         gtk_widget_show (hbox);
1246         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_auto,
1247                            _("after autochecking"));
1248         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_manu,
1249                            _("after manual checking"));
1250         gtk_box_pack_start (GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
1251         gtk_signal_connect(GTK_OBJECT(checkbtn_newmail_auto), "toggled",
1252                            GTK_SIGNAL_FUNC(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1253                            NULL);
1254         gtk_signal_connect(GTK_OBJECT(checkbtn_newmail_manu), "toggled",
1255                            GTK_SIGNAL_FUNC(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1256                            NULL);
1257
1258         hbox_newmail_notify = gtk_hbox_new (FALSE, 8);
1259         gtk_widget_show (hbox);
1260         gtk_box_pack_start (GTK_BOX (vbox2), hbox_newmail_notify, FALSE, 
1261                             FALSE, 0);
1262
1263         label_newmail_notify_cmd = gtk_label_new (_("Command to execute:\n"
1264                                                     "(use %d as number of new "
1265                                                     "mails)"));
1266         gtk_label_set_justify(GTK_LABEL(label_newmail_notify_cmd), 
1267                               GTK_JUSTIFY_RIGHT);
1268         gtk_widget_show (label_newmail_notify_cmd);
1269         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1270                             label_newmail_notify_cmd, FALSE, FALSE, 0);
1271
1272         entry_newmail_notify_cmd = gtk_entry_new ();
1273         gtk_widget_show (entry_newmail_notify_cmd);
1274         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1275                             entry_newmail_notify_cmd, TRUE, TRUE, 0);
1276
1277         gtk_widget_set_sensitive(hbox_newmail_notify, 
1278                                  prefs_common.newmail_notify_auto || 
1279                                  prefs_common.newmail_notify_manu);
1280
1281         receive.checkbtn_incext = checkbtn_incext;
1282         receive.entry_incext    = entry_incext;
1283         /* receive.button_incext   = button_incext; */
1284
1285         receive.checkbtn_local         = checkbtn_local;
1286         receive.checkbtn_filter_on_inc = checkbtn_filter_on_inc;
1287         receive.entry_spool            = entry_spool;
1288
1289         receive.checkbtn_autochk    = checkbtn_autochk;
1290         receive.spinbtn_autochk     = spinbtn_autochk;
1291         receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1292
1293         receive.checkbtn_chkonstartup = checkbtn_chkonstartup;
1294         receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1295
1296
1297         receive.checkbtn_newmail_auto  = checkbtn_newmail_auto;
1298         receive.checkbtn_newmail_manu  = checkbtn_newmail_manu;
1299         receive.hbox_newmail_notify    = hbox_newmail_notify;
1300         receive.entry_newmail_notify_cmd = entry_newmail_notify_cmd;
1301         receive.optmenu_recvdialog          = optmenu_recvdialog;
1302         receive.checkbtn_no_recv_err_panel  = checkbtn_no_recv_err_panel;
1303         receive.checkbtn_close_recv_dialog  = checkbtn_close_recv_dialog;
1304 }
1305
1306 static void prefs_send_create(void)
1307 {
1308         GtkWidget *vbox1;
1309         GtkWidget *vbox2;
1310         GtkWidget *frame_extsend;
1311         GtkWidget *vbox_extsend;
1312         GtkWidget *checkbtn_extsend;
1313         GtkWidget *hbox1;
1314         GtkWidget *label_extsend;
1315         GtkWidget *entry_extsend;
1316         /* GtkWidget *button_extsend; */
1317         GtkWidget *checkbtn_savemsg;
1318         GtkWidget *checkbtn_queuemsg;
1319         GtkWidget *label_outcharset;
1320         GtkWidget *optmenu_charset;
1321         GtkWidget *optmenu_menu;
1322         GtkWidget *menuitem;
1323         GtkWidget *label_charset_desc;
1324         GtkWidget *optmenu_encoding;
1325         GtkWidget *label_encoding;
1326         GtkWidget *label_encoding_desc;
1327         GtkWidget *label_senddialog;
1328         GtkWidget *menu;
1329         GtkWidget *optmenu_senddialog;
1330         GtkWidget *hbox_senddialog;
1331
1332         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1333         gtk_widget_show (vbox1);
1334         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1335         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1336
1337         PACK_FRAME(vbox1, frame_extsend, _("External program"));
1338
1339         vbox_extsend = gtk_vbox_new (FALSE, VSPACING_NARROW);
1340         gtk_widget_show (vbox_extsend);
1341         gtk_container_add (GTK_CONTAINER (frame_extsend), vbox_extsend);
1342         gtk_container_set_border_width (GTK_CONTAINER (vbox_extsend), 8);
1343
1344         PACK_CHECK_BUTTON (vbox_extsend, checkbtn_extsend,
1345                            _("Use external program for sending"));
1346
1347         hbox1 = gtk_hbox_new (FALSE, 8);
1348         gtk_widget_show (hbox1);
1349         gtk_box_pack_start (GTK_BOX (vbox_extsend), hbox1, FALSE, FALSE, 0);
1350         SET_TOGGLE_SENSITIVITY(checkbtn_extsend, hbox1);
1351
1352         label_extsend = gtk_label_new (_("Command"));
1353         gtk_widget_show (label_extsend);
1354         gtk_box_pack_start (GTK_BOX (hbox1), label_extsend, FALSE, FALSE, 0);
1355
1356         entry_extsend = gtk_entry_new ();
1357         gtk_widget_show (entry_extsend);
1358         gtk_box_pack_start (GTK_BOX (hbox1), entry_extsend, TRUE, TRUE, 0);
1359
1360 #if 0
1361         button_extsend = gtk_button_new_with_label ("... ");
1362         gtk_widget_show (button_extsend);
1363         gtk_box_pack_start (GTK_BOX (hbox1), button_extsend, FALSE, FALSE, 0);
1364 #endif
1365
1366         vbox2 = gtk_vbox_new (FALSE, 0);
1367         gtk_widget_show (vbox2);
1368         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1369
1370         PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1371                            _("Save sent messages to Sent folder"));
1372         PACK_CHECK_BUTTON (vbox2, checkbtn_queuemsg,
1373                            _("Queue messages that fail to send"));
1374
1375         hbox_senddialog = gtk_hbox_new (FALSE, 8);
1376         gtk_widget_show (hbox1);
1377         gtk_box_pack_start (GTK_BOX (vbox1), hbox_senddialog, FALSE, FALSE, 0);
1378
1379         label_senddialog = gtk_label_new (_("Show send dialog"));
1380         gtk_widget_show (label_senddialog);
1381         gtk_box_pack_start (GTK_BOX (hbox_senddialog), label_senddialog, FALSE, FALSE, 0);
1382
1383         optmenu_senddialog = gtk_option_menu_new ();
1384         gtk_widget_show (optmenu_senddialog);
1385         gtk_box_pack_start (GTK_BOX (hbox_senddialog), optmenu_senddialog, FALSE, FALSE, 0);
1386         
1387         menu = gtk_menu_new ();
1388         MENUITEM_ADD (menu, menuitem, _("Always"), SEND_DIALOG_ALWAYS);
1389         MENUITEM_ADD (menu, menuitem, _("Never"), SEND_DIALOG_NEVER);
1390
1391         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_senddialog), menu);
1392
1393         hbox1 = gtk_hbox_new (FALSE, 8);
1394         gtk_widget_show (hbox1);
1395         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1396
1397         label_outcharset = gtk_label_new (_("Outgoing codeset"));
1398         gtk_widget_show (label_outcharset);
1399         gtk_box_pack_start (GTK_BOX (hbox1), label_outcharset, FALSE, FALSE, 0);
1400
1401         optmenu_charset = gtk_option_menu_new ();
1402         gtk_widget_show (optmenu_charset);
1403         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_charset, FALSE, FALSE, 0);
1404
1405         optmenu_menu = gtk_menu_new ();
1406
1407 #define SET_MENUITEM(str, data) \
1408 { \
1409         MENUITEM_ADD(optmenu_menu, menuitem, str, data); \
1410 }
1411
1412         SET_MENUITEM(_("Automatic (Recommended)"),       CS_AUTO);
1413         SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
1414 #if HAVE_ICONV
1415         SET_MENUITEM(_("Unicode (UTF-8)"),               CS_UTF_8);
1416 #endif
1417         SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
1418         SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
1419         SET_MENUITEM(_("Central European (ISO-8859-2)"),  CS_ISO_8859_2);
1420         SET_MENUITEM(_("Baltic (ISO-8859-13)"),           CS_ISO_8859_13);
1421         SET_MENUITEM(_("Baltic (ISO-8859-4)"),            CS_ISO_8859_4);
1422         SET_MENUITEM(_("Greek (ISO-8859-7)"),             CS_ISO_8859_7);
1423         SET_MENUITEM(_("Turkish (ISO-8859-9)"),           CS_ISO_8859_9);
1424 #if HAVE_ICONV
1425         SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
1426 #endif
1427         SET_MENUITEM(_("Cyrillic (KOI8-R)"),             CS_KOI8_R);
1428 #if HAVE_ICONV
1429         SET_MENUITEM(_("Cyrillic (Windows-1251)"),       CS_WINDOWS_1251);
1430         SET_MENUITEM(_("Cyrillic (KOI8-U)"),             CS_KOI8_U);
1431 #endif
1432         SET_MENUITEM(_("Japanese (ISO-2022-JP)"),        CS_ISO_2022_JP);
1433 #if 0
1434         SET_MENUITEM(_("Japanese (EUC-JP)"),             CS_EUC_JP);
1435         SET_MENUITEM(_("Japanese (Shift_JIS)"),          CS_SHIFT_JIS);
1436 #endif /* 0 */
1437         SET_MENUITEM(_("Simplified Chinese (GB2312)"),   CS_GB2312);
1438         SET_MENUITEM(_("Traditional Chinese (Big5)"),    CS_BIG5);
1439 #if 0
1440         SET_MENUITEM(_("Traditional Chinese (EUC-TW)"),  CS_EUC_TW);
1441         SET_MENUITEM(_("Chinese (ISO-2022-CN)"),         CS_ISO_2022_CN);
1442 #endif /* 0 */
1443         SET_MENUITEM(_("Korean (EUC-KR)"),               CS_EUC_KR);
1444         SET_MENUITEM(_("Thai (TIS-620)"),                CS_TIS_620);
1445         SET_MENUITEM(_("Thai (Windows-874)"),            CS_WINDOWS_874);
1446
1447         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_charset),
1448                                   optmenu_menu);
1449
1450         hbox1 = gtk_hbox_new (FALSE, 8);
1451         gtk_widget_show (hbox1);
1452         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1453
1454         label_charset_desc = gtk_label_new
1455                 (_("If `Automatic' is selected, the optimal encoding\n"
1456                    "for the current locale will be used."));
1457         gtk_widget_show (label_charset_desc);
1458         gtk_box_pack_start (GTK_BOX (hbox1), label_charset_desc,
1459                             FALSE, FALSE, 0);
1460         gtk_label_set_justify (GTK_LABEL (label_charset_desc),
1461                                GTK_JUSTIFY_LEFT);
1462
1463         hbox1 = gtk_hbox_new (FALSE, 8);
1464         gtk_widget_show (hbox1);
1465         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1466
1467         label_encoding = gtk_label_new (_("Transfer encoding"));
1468         gtk_widget_show (label_encoding);
1469         gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
1470
1471         optmenu_encoding = gtk_option_menu_new ();
1472         gtk_widget_show (optmenu_encoding);
1473         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_encoding, FALSE, FALSE, 0);
1474
1475         optmenu_menu = gtk_menu_new ();
1476
1477         SET_MENUITEM(_("Automatic"),     CTE_AUTO);
1478         SET_MENUITEM("base64",           CTE_BASE64);
1479         SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
1480         SET_MENUITEM("8bit",             CTE_8BIT);
1481
1482         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_encoding),
1483                                   optmenu_menu);
1484
1485         hbox1 = gtk_hbox_new (FALSE, 8);
1486         gtk_widget_show (hbox1);
1487         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1488
1489         label_encoding_desc = gtk_label_new
1490                 (_("Specify Content-Transfer-Encoding used when\n"
1491                    "message body contains non-ASCII characters."));
1492         gtk_widget_show (label_encoding_desc);
1493         gtk_box_pack_start (GTK_BOX (hbox1), label_encoding_desc,
1494                             FALSE, FALSE, 0);
1495         gtk_label_set_justify (GTK_LABEL (label_encoding_desc),
1496                                GTK_JUSTIFY_LEFT);
1497
1498         p_send.checkbtn_extsend = checkbtn_extsend;
1499         p_send.entry_extsend    = entry_extsend;
1500         /* p_send.button_extsend   = button_extsend; */
1501
1502         p_send.checkbtn_savemsg  = checkbtn_savemsg;
1503         p_send.checkbtn_queuemsg = checkbtn_queuemsg;
1504         p_send.optmenu_senddialog = optmenu_senddialog;
1505
1506         p_send.optmenu_charset = optmenu_charset;
1507         p_send.optmenu_encoding_method = optmenu_encoding;
1508 }
1509
1510 static void prefs_common_recv_dialog_newmail_notify_toggle_cb(GtkWidget *w, gpointer data)
1511 {
1512         gboolean toggled;
1513
1514         toggled = gtk_toggle_button_get_active
1515                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_manu)) ||
1516                   gtk_toggle_button_get_active
1517                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_auto));
1518         gtk_widget_set_sensitive(receive.hbox_newmail_notify, toggled);
1519 }
1520
1521 #if USE_ASPELL
1522 static void prefs_dictionary_set_data_from_optmenu(PrefParam *param)
1523 {
1524         gchar *str;
1525         gchar *dict_fullname;
1526         
1527         g_return_if_fail(param);
1528         g_return_if_fail(param->data);
1529         g_return_if_fail(param->widget);
1530         g_return_if_fail(*(param->widget));
1531
1532         dict_fullname = gtkaspell_get_dictionary_menu_active_item
1533                 (gtk_option_menu_get_menu(GTK_OPTION_MENU(*(param->widget))));
1534         str = *((gchar **) param->data);
1535         if (str)
1536                 g_free(str);
1537         *((gchar **) param->data) = dict_fullname;
1538 }
1539
1540 static void prefs_dictionary_set_optmenu(PrefParam *pparam)
1541 {
1542         GList *cur;
1543         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
1544         GtkWidget *menu;
1545         GtkWidget *menuitem;
1546         gchar *dict_name;
1547         gint n = 0;
1548
1549         g_return_if_fail(optmenu != NULL);
1550         g_return_if_fail(pparam->data != NULL);
1551
1552         if (*(gchar **) pparam->data) {
1553                 menu = gtk_option_menu_get_menu(optmenu);
1554                 for (cur = GTK_MENU_SHELL(menu)->children;
1555                      cur != NULL; cur = cur->next) {
1556                         menuitem = GTK_WIDGET(cur->data);
1557                         dict_name = gtk_object_get_data(GTK_OBJECT(menuitem), 
1558                                                         "dict_name");
1559                         if (!strcmp2(dict_name, *((gchar **)pparam->data))) {
1560                                 gtk_option_menu_set_history(optmenu, n);
1561                                 return;
1562                         }
1563                         n++;
1564                 }
1565         }               
1566
1567         gtk_option_menu_set_history(optmenu, 0);
1568         prefs_dictionary_set_data_from_optmenu(pparam);
1569 }
1570
1571 static void prefs_speller_sugmode_set_data_from_optmenu(PrefParam *param)
1572 {
1573         gint sugmode;
1574         g_return_if_fail(param);
1575         g_return_if_fail(param->data);
1576         g_return_if_fail(param->widget);
1577         g_return_if_fail(*(param->widget));
1578
1579         sugmode = gtkaspell_get_sugmode_from_option_menu
1580                 (GTK_OPTION_MENU(*(param->widget)));
1581         *((gint *) param->data) = sugmode;
1582 }
1583
1584 static void prefs_speller_sugmode_set_optmenu(PrefParam *pparam)
1585 {
1586         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
1587         gint sugmode;
1588
1589         g_return_if_fail(optmenu != NULL);
1590         g_return_if_fail(pparam->data != NULL);
1591
1592         sugmode = *(gint *) pparam->data;
1593         gtkaspell_sugmode_option_menu_set(optmenu, sugmode);
1594 }
1595         
1596         
1597 static void prefs_spelling_checkbtn_enable_aspell_toggle_cb
1598         (GtkWidget *widget,
1599          gpointer data)
1600 {
1601         gboolean toggled;
1602
1603         toggled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
1604
1605         gtk_widget_set_sensitive(spelling.entry_aspell_path,   toggled);
1606         gtk_widget_set_sensitive(spelling.optmenu_dictionary,  toggled);
1607         gtk_widget_set_sensitive(spelling.optmenu_sugmode,     toggled);
1608         gtk_widget_set_sensitive(spelling.btn_aspell_path,     toggled);
1609         gtk_widget_set_sensitive(spelling.misspelled_btn,      toggled);
1610         gtk_widget_set_sensitive(spelling.checkbtn_use_alternate,      toggled);
1611         gtk_widget_set_sensitive(spelling.checkbtn_check_while_typing, toggled);
1612 }
1613
1614 static void prefs_spelling_btn_aspell_path_clicked_cb(GtkWidget *widget,
1615                                                      gpointer data)
1616 {
1617         gchar *file_path, *tmp;
1618         GtkWidget *new_menu;
1619
1620         file_path = filesel_select_file(_("Select dictionaries location"),
1621                                         prefs_common.aspell_path);
1622         if (file_path == NULL) {
1623                 /* don't change */      
1624         }
1625         else {
1626           tmp=g_dirname(file_path);
1627           
1628                 if (prefs_common.aspell_path)
1629                         g_free(prefs_common.aspell_path);
1630                 prefs_common.aspell_path = g_strdup_printf("%s%s",tmp,
1631                                                            G_DIR_SEPARATOR_S);
1632
1633                 new_menu = gtkaspell_dictionary_option_menu_new(prefs_common.aspell_path);
1634                 gtk_option_menu_set_menu(GTK_OPTION_MENU(spelling.optmenu_dictionary),
1635                                          new_menu);
1636
1637                 gtk_entry_set_text(GTK_ENTRY(spelling.entry_aspell_path), 
1638                                    prefs_common.aspell_path);                                    
1639                 /* select first one */
1640                 gtk_option_menu_set_history(GTK_OPTION_MENU(
1641                                         spelling.optmenu_dictionary), 0);
1642         
1643                 if (prefs_common.dictionary)
1644                         g_free(prefs_common.dictionary);
1645
1646                 prefs_common.dictionary = 
1647                         gtkaspell_get_dictionary_menu_active_item(
1648                                 gtk_option_menu_get_menu(
1649                                         GTK_OPTION_MENU(
1650                                                 spelling.optmenu_dictionary)));
1651                 g_free(tmp);
1652
1653         }
1654 }
1655
1656 static void prefs_spelling_create()
1657 {
1658         GtkWidget *vbox1;
1659         GtkWidget *frame_spell;
1660         GtkWidget *vbox_spell;
1661         GtkWidget *hbox_aspell_path;
1662         GtkWidget *checkbtn_enable_aspell;
1663         GtkWidget *label_aspell_path;
1664         GtkWidget *entry_aspell_path;
1665         GtkWidget *btn_aspell_path;
1666         GtkWidget *spell_table;
1667         GtkWidget *label_dictionary;
1668         GtkWidget *optmenu_dictionary;
1669         GtkWidget *sugmode_label;
1670         GtkWidget *sugmode_optmenu;
1671         GtkWidget *checkbtn_use_alternate;
1672         GtkWidget *help_label;
1673         GtkWidget *checkbtn_check_while_typing;
1674         GtkWidget *color_label;
1675         GtkWidget *col_align;
1676
1677         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1678         gtk_widget_show (vbox1);
1679         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1680         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1681
1682         /* spell checker defaults */                       
1683         PACK_FRAME(vbox1, frame_spell, _("Global spelling checker settings"));
1684         vbox_spell = gtk_vbox_new(FALSE, VSPACING_NARROW);
1685         gtk_widget_show (vbox_spell);
1686         gtk_container_add(GTK_CONTAINER(frame_spell), vbox_spell);
1687         gtk_container_set_border_width(GTK_CONTAINER(vbox_spell), 8);
1688
1689         PACK_CHECK_BUTTON(vbox_spell, checkbtn_enable_aspell, 
1690                           _("Enable spell checker"));
1691
1692         gtk_signal_connect(GTK_OBJECT(checkbtn_enable_aspell), "toggled",
1693                            GTK_SIGNAL_FUNC(prefs_spelling_checkbtn_enable_aspell_toggle_cb),
1694                            NULL);
1695
1696         /* Check while typing */
1697         PACK_CHECK_BUTTON(vbox_spell, checkbtn_check_while_typing, 
1698                           _("Check while typing"));
1699
1700         PACK_CHECK_BUTTON(vbox_spell, checkbtn_use_alternate, 
1701                           _("Enable alternate dictionary"));
1702
1703         help_label = gtk_label_new(_("Enabling an alternate dictionary makes switching\n"
1704                                      "with the last used dictionary faster."));
1705         gtk_misc_set_alignment (GTK_MISC (help_label), 0, 0);
1706         gtk_widget_show(help_label);
1707         gtk_box_pack_start(GTK_BOX(vbox_spell), help_label, FALSE, TRUE, 0);
1708         
1709         spell_table = gtk_table_new(4, 3, FALSE);
1710         gtk_container_set_border_width (GTK_CONTAINER (spell_table), VSPACING);
1711         gtk_table_set_row_spacings(GTK_TABLE(spell_table), 8);
1712         gtk_table_set_col_spacings(GTK_TABLE(spell_table), 8);
1713
1714         gtk_box_pack_start(GTK_BOX(vbox_spell), spell_table, TRUE, TRUE, 0);
1715
1716         label_aspell_path = gtk_label_new (_("Dictionaries path:"));
1717         gtk_misc_set_alignment(GTK_MISC(label_aspell_path), 1.0, 0.5);
1718         gtk_widget_show(label_aspell_path);
1719         gtk_table_attach (GTK_TABLE (spell_table), label_aspell_path, 0, 1, 0,
1720                           1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1721         
1722         hbox_aspell_path = gtk_hbox_new (FALSE, 8);
1723         gtk_table_attach (GTK_TABLE (spell_table), hbox_aspell_path, 1, 2, 0,
1724                           1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1725         gtk_widget_show(hbox_aspell_path);
1726
1727         entry_aspell_path = gtk_entry_new();
1728         gtk_widget_show(entry_aspell_path);
1729         gtk_box_pack_start(GTK_BOX(hbox_aspell_path), entry_aspell_path, TRUE,
1730                            TRUE, 0);    
1731         
1732         gtk_widget_set_sensitive(entry_aspell_path, prefs_common.enable_aspell);
1733
1734         btn_aspell_path = gtk_button_new_with_label(" ... ");
1735         gtk_widget_show(btn_aspell_path);
1736         gtk_box_pack_start(GTK_BOX(hbox_aspell_path), btn_aspell_path, FALSE, FALSE, 0);
1737         gtk_widget_set_sensitive(btn_aspell_path, prefs_common.enable_aspell);
1738
1739         gtk_signal_connect(GTK_OBJECT(btn_aspell_path), "clicked", 
1740                            GTK_SIGNAL_FUNC(prefs_spelling_btn_aspell_path_clicked_cb),
1741                            NULL);
1742
1743         label_dictionary = gtk_label_new(_("Default dictionary:"));
1744         gtk_misc_set_alignment(GTK_MISC(label_dictionary), 1.0, 0.5);
1745         gtk_widget_show(label_dictionary);
1746         gtk_table_attach (GTK_TABLE (spell_table), label_dictionary, 0, 1, 1, 2,
1747                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1748
1749         optmenu_dictionary = gtk_option_menu_new();
1750         gtk_widget_show(optmenu_dictionary);
1751         gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_dictionary), 
1752                                  gtkaspell_dictionary_option_menu_new(
1753                                          prefs_common.aspell_path));
1754         gtk_table_attach (GTK_TABLE (spell_table), optmenu_dictionary, 1, 2, 1,
1755                           2, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1756         gtk_widget_set_sensitive(optmenu_dictionary, prefs_common.enable_aspell);
1757
1758         /* Suggestion mode */
1759         sugmode_label = gtk_label_new(_("Default suggestion mode"));
1760         gtk_misc_set_alignment(GTK_MISC(sugmode_label), 1.0, 0.5);
1761         gtk_widget_show(sugmode_label);
1762         gtk_table_attach(GTK_TABLE (spell_table), sugmode_label, 0, 1, 2, 3,
1763                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1764
1765         sugmode_optmenu = gtk_option_menu_new();
1766         gtk_widget_show(sugmode_optmenu);
1767         gtk_option_menu_set_menu(GTK_OPTION_MENU(sugmode_optmenu),
1768                             gtkaspell_sugmode_option_menu_new(prefs_common.aspell_sugmode));
1769         gtk_table_attach(GTK_TABLE(spell_table), sugmode_optmenu, 1, 2, 2, 3,
1770                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1771         gtk_widget_set_sensitive(sugmode_optmenu, prefs_common.enable_aspell);
1772
1773         /* Color */
1774         color_label = gtk_label_new(_("Misspelled word color:"));
1775         gtk_misc_set_alignment(GTK_MISC(color_label), 1.0, 0.5);
1776         gtk_table_attach (GTK_TABLE (spell_table), color_label, 0, 1, 3, 4,
1777                           GTK_FILL, GTK_SHRINK, 0, 0);
1778         gtk_widget_show(color_label);
1779         
1780         col_align = gtk_alignment_new(0.0, 0.5, 0, 0);
1781         gtk_widget_show(col_align);
1782         gtk_table_attach (GTK_TABLE (spell_table), col_align, 1, 2, 3, 4,
1783                           GTK_FILL, GTK_SHRINK, 0, 0);
1784
1785         spelling.misspelled_btn = gtk_button_new_with_label ("");
1786         set_button_bg_color(spelling.misspelled_btn,
1787                             prefs_common.misspelled_col);
1788         gtk_widget_set_usize (spelling.misspelled_btn, 30, 20);
1789         gtk_widget_set_sensitive(spelling.misspelled_btn, prefs_common.enable_aspell);
1790         gtk_signal_connect (GTK_OBJECT (spelling.misspelled_btn), "clicked",
1791                             GTK_SIGNAL_FUNC(quote_color_set_dialog), "Misspelled word");
1792         gtk_container_add(GTK_CONTAINER(col_align), spelling.misspelled_btn);
1793
1794
1795         spelling.checkbtn_enable_aspell = checkbtn_enable_aspell;
1796         spelling.entry_aspell_path      = entry_aspell_path;
1797         spelling.btn_aspell_path        = btn_aspell_path;
1798         spelling.optmenu_dictionary     = optmenu_dictionary;
1799         spelling.optmenu_sugmode        = sugmode_optmenu;
1800         spelling.checkbtn_use_alternate = checkbtn_use_alternate;
1801         spelling.checkbtn_check_while_typing = checkbtn_check_while_typing;
1802 }
1803
1804 #endif
1805
1806
1807 static void prefs_compose_create(void)
1808 {
1809         GtkWidget *vbox1;
1810         GtkWidget *vbox2;
1811
1812         GtkWidget *checkbtn_autoextedit;
1813
1814         GtkWidget *frame_autosel;
1815         GtkWidget *hbox_autosel;
1816         GtkWidget *checkbtn_reply_account_autosel;
1817         GtkWidget *checkbtn_forward_account_autosel;
1818         GtkWidget *checkbtn_reedit_account_autosel;
1819
1820         GtkWidget *hbox_undolevel;
1821         GtkWidget *label_undolevel;
1822         GtkObject *spinbtn_undolevel_adj;
1823         GtkWidget *spinbtn_undolevel;
1824
1825         GtkWidget *vbox_linewrap;
1826
1827         GtkWidget *hbox3;
1828         GtkWidget *hbox4;
1829         GtkWidget *hbox5;
1830         GtkWidget *label_linewrap;
1831         GtkObject *spinbtn_linewrap_adj;
1832         GtkWidget *spinbtn_linewrap;
1833         GtkWidget *checkbtn_wrapquote;
1834         GtkWidget *checkbtn_autowrap;
1835         GtkWidget *checkbtn_wrapatsend;
1836
1837         GtkWidget *checkbtn_default_reply_list;
1838
1839         GtkWidget *checkbtn_forward_as_attachment;
1840         GtkWidget *checkbtn_redirect_keep_from;
1841         GtkWidget *checkbtn_smart_wrapping;
1842         GtkWidget *checkbtn_block_cursor;
1843         GtkWidget *frame_msgwrap;
1844
1845         GtkWidget *hbox_autosave;
1846         GtkWidget *checkbtn_autosave;
1847         GtkWidget *entry_autosave_length;
1848         GtkWidget *label_autosave_length;
1849         
1850         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1851         gtk_widget_show (vbox1);
1852         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1853         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1854
1855         /* Account autoselection */
1856         PACK_FRAME(vbox1, frame_autosel, _("Automatic account selection"));
1857
1858         hbox_autosel = gtk_hbox_new (FALSE, VSPACING_NARROW);
1859         gtk_widget_show (hbox_autosel);
1860         gtk_container_add (GTK_CONTAINER (frame_autosel), hbox_autosel);
1861         gtk_container_set_border_width (GTK_CONTAINER (hbox_autosel), 8);
1862
1863         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reply_account_autosel,
1864                            _("when replying"));
1865         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_forward_account_autosel,
1866                            _("when forwarding"));
1867         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reedit_account_autosel,
1868                            _("when re-editing"));
1869
1870         vbox2 = gtk_vbox_new (FALSE, 0);
1871         gtk_widget_show (vbox2);
1872         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1873
1874         PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
1875                            _("Reply button invokes mailing list reply"));
1876
1877         PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1878                            _("Automatically launch the external editor"));
1879
1880         hbox5 = gtk_hbox_new (FALSE, 8);
1881         gtk_widget_show (hbox5);
1882         gtk_box_pack_start (GTK_BOX (vbox2), hbox5, FALSE, FALSE, 0);
1883
1884         PACK_CHECK_BUTTON (hbox5, checkbtn_forward_as_attachment,
1885                            _("Forward as attachment"));
1886
1887         PACK_CHECK_BUTTON (hbox5, checkbtn_block_cursor,
1888                           _("Block cursor"));
1889
1890         PACK_CHECK_BUTTON (vbox2, checkbtn_redirect_keep_from,
1891                            _("Keep the original 'From' header when redirecting"));
1892
1893         
1894         hbox_autosave = gtk_hbox_new (FALSE, 8);
1895         gtk_widget_show (hbox_autosave);
1896         gtk_box_pack_start (GTK_BOX (vbox1), hbox_autosave, FALSE, FALSE, 0);
1897         
1898         PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
1899                            _("Autosave to Drafts folder every "));
1900
1901         entry_autosave_length = gtk_entry_new();
1902         gtk_widget_set_usize (entry_autosave_length, 64, -1);   
1903         gtk_widget_show (entry_autosave_length);
1904         gtk_box_pack_start (GTK_BOX (hbox_autosave), entry_autosave_length, FALSE, FALSE, 0);
1905         
1906         label_autosave_length = gtk_label_new(_("characters"));
1907         gtk_widget_show (label_autosave_length);
1908         gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave_length, FALSE, FALSE, 0);
1909         
1910         hbox_undolevel = gtk_hbox_new (FALSE, 8);
1911         gtk_widget_show (hbox_undolevel);
1912         gtk_box_pack_start (GTK_BOX (vbox1), hbox_undolevel, FALSE, FALSE, 0);
1913
1914         label_undolevel = gtk_label_new (_("Undo level"));
1915         gtk_widget_show (label_undolevel);
1916         gtk_box_pack_start (GTK_BOX (hbox_undolevel), label_undolevel, FALSE, FALSE, 0);
1917
1918         spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 10);
1919         spinbtn_undolevel = gtk_spin_button_new
1920                 (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1921         gtk_widget_show (spinbtn_undolevel);
1922         gtk_box_pack_start (GTK_BOX (hbox_undolevel), spinbtn_undolevel, FALSE, FALSE, 0);
1923         gtk_widget_set_usize (spinbtn_undolevel, 64, -1);
1924         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1925
1926         /* line-wrapping */
1927         PACK_FRAME(vbox1, frame_msgwrap, _("Message wrapping"));
1928
1929         vbox_linewrap = gtk_vbox_new (FALSE, VSPACING_NARROW);
1930         gtk_widget_show (vbox_linewrap);
1931         gtk_container_add (GTK_CONTAINER (frame_msgwrap), vbox_linewrap);
1932         gtk_container_set_border_width (GTK_CONTAINER (vbox_linewrap), 8);
1933
1934         hbox3 = gtk_hbox_new (FALSE, 8);
1935         gtk_widget_show (hbox3);
1936         gtk_box_pack_start (GTK_BOX (vbox_linewrap), hbox3, FALSE, FALSE, 0);
1937
1938
1939         label_linewrap = gtk_label_new (_("Wrap messages at"));
1940         gtk_widget_show (label_linewrap);
1941         gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1942
1943         spinbtn_linewrap_adj = gtk_adjustment_new (72, 20, 1024, 1, 10, 10);
1944         spinbtn_linewrap = gtk_spin_button_new
1945                 (GTK_ADJUSTMENT (spinbtn_linewrap_adj), 1, 0);
1946         gtk_widget_show (spinbtn_linewrap);
1947         gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_linewrap, FALSE, FALSE, 0);
1948         gtk_widget_set_usize (spinbtn_linewrap, 64, -1);
1949         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
1950
1951         label_linewrap = gtk_label_new (_("characters"));
1952         gtk_widget_show (label_linewrap);
1953         gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1954
1955         hbox4 = gtk_hbox_new (FALSE, VSPACING);
1956         gtk_widget_show (hbox4);
1957         gtk_box_pack_start (GTK_BOX (vbox_linewrap), hbox4, FALSE, FALSE, 0);
1958
1959         PACK_CHECK_BUTTON (hbox4, checkbtn_wrapquote, _("Wrap quotation"));
1960
1961         PACK_CHECK_BUTTON (hbox4, checkbtn_autowrap, _("Wrap on input"));
1962
1963         PACK_CHECK_BUTTON
1964                 (hbox4, checkbtn_wrapatsend, _("Wrap before sending"));
1965
1966         PACK_CHECK_BUTTON (vbox_linewrap, checkbtn_smart_wrapping,
1967                            _("Smart wrapping (EXPERIMENTAL)"));
1968         
1969        /*
1970         compose.checkbtn_quote   = checkbtn_quote;
1971         compose.entry_quotemark  = entry_quotemark;
1972         compose.text_quotefmt    = text_quotefmt;
1973         */
1974
1975         compose.checkbtn_autoextedit = checkbtn_autoextedit;
1976
1977         compose.checkbtn_reply_account_autosel   = checkbtn_reply_account_autosel;
1978         compose.checkbtn_forward_account_autosel = checkbtn_forward_account_autosel;
1979         compose.checkbtn_reedit_account_autosel  = checkbtn_reedit_account_autosel;
1980
1981         compose.spinbtn_undolevel     = spinbtn_undolevel;
1982         compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1983
1984         compose.spinbtn_linewrap      = spinbtn_linewrap;
1985         compose.spinbtn_linewrap_adj  = spinbtn_linewrap_adj;
1986         compose.checkbtn_wrapquote    = checkbtn_wrapquote;
1987         compose.checkbtn_autowrap     = checkbtn_autowrap;
1988         compose.checkbtn_wrapatsend   = checkbtn_wrapatsend;
1989
1990         compose.checkbtn_autosave     = checkbtn_autosave;
1991         compose.entry_autosave_length = entry_autosave_length;
1992         
1993         compose.checkbtn_forward_as_attachment =
1994                 checkbtn_forward_as_attachment;
1995         compose.checkbtn_redirect_keep_from =
1996                 checkbtn_redirect_keep_from;
1997         compose.checkbtn_smart_wrapping = 
1998                 checkbtn_smart_wrapping;
1999         compose.checkbtn_block_cursor   =
2000                 checkbtn_block_cursor;
2001         compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
2002 }
2003
2004 static void prefs_quote_create(void)
2005 {
2006         GtkWidget *vbox1;
2007         GtkWidget *frame_quote;
2008         GtkWidget *vbox_quote;
2009         GtkWidget *hbox1;
2010         GtkWidget *hbox2;
2011         GtkWidget *label_quotemark;
2012         GtkWidget *entry_quotemark;
2013         GtkWidget *scrolledwin_quotefmt;
2014         GtkWidget *text_quotefmt;
2015
2016         GtkWidget *entry_fw_quotemark;
2017         GtkWidget *text_fw_quotefmt;
2018
2019         GtkWidget *entry_quote_chars;
2020         GtkWidget *label_quote_chars;
2021         
2022         GtkWidget *btn_quotedesc;
2023
2024         GtkWidget *checkbtn_reply_with_quote;
2025
2026         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2027         gtk_widget_show (vbox1);
2028         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2029         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2030
2031         /* reply */
2032
2033         PACK_CHECK_BUTTON (vbox1, checkbtn_reply_with_quote, _("Reply will quote by default"));
2034
2035         PACK_FRAME (vbox1, frame_quote, _("Reply format"));
2036
2037         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
2038         gtk_widget_show (vbox_quote);
2039         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
2040         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
2041
2042         hbox1 = gtk_hbox_new (FALSE, 32);
2043         gtk_widget_show (hbox1);
2044         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
2045
2046         hbox2 = gtk_hbox_new (FALSE, 8);
2047         gtk_widget_show (hbox2);
2048         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
2049
2050         label_quotemark = gtk_label_new (_("Quotation mark"));
2051         gtk_widget_show (label_quotemark);
2052         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
2053
2054         entry_quotemark = gtk_entry_new ();
2055         gtk_widget_show (entry_quotemark);
2056         gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
2057         gtk_widget_set_usize (entry_quotemark, 64, -1);
2058
2059         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
2060         gtk_widget_show (scrolledwin_quotefmt);
2061         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
2062         gtk_scrolled_window_set_policy
2063                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
2064                  GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
2065
2066         text_quotefmt = gtk_text_new (NULL, NULL);
2067         gtk_widget_show (text_quotefmt);
2068         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
2069         gtk_text_set_editable (GTK_TEXT (text_quotefmt), TRUE);
2070         gtk_widget_set_usize(text_quotefmt, -1, 60);
2071
2072         /* forward */
2073
2074         PACK_FRAME (vbox1, frame_quote, _("Forward format"));
2075
2076         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
2077         gtk_widget_show (vbox_quote);
2078         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
2079         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
2080
2081         hbox1 = gtk_hbox_new (FALSE, 32);
2082         gtk_widget_show (hbox1);
2083         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
2084
2085         hbox2 = gtk_hbox_new (FALSE, 8);
2086         gtk_widget_show (hbox2);
2087         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
2088
2089         label_quotemark = gtk_label_new (_("Quotation mark"));
2090         gtk_widget_show (label_quotemark);
2091         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
2092
2093         entry_fw_quotemark = gtk_entry_new ();
2094         gtk_widget_show (entry_fw_quotemark);
2095         gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
2096                             FALSE, FALSE, 0);
2097         gtk_widget_set_usize (entry_fw_quotemark, 64, -1);
2098
2099         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
2100         gtk_widget_show (scrolledwin_quotefmt);
2101         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
2102         gtk_scrolled_window_set_policy
2103                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
2104                  GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
2105
2106         text_fw_quotefmt = gtk_text_new (NULL, NULL);
2107         gtk_widget_show (text_fw_quotefmt);
2108         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
2109                           text_fw_quotefmt);
2110         gtk_text_set_editable (GTK_TEXT (text_fw_quotefmt), TRUE);
2111         gtk_widget_set_usize(text_fw_quotefmt, -1, 60);
2112
2113         hbox1 = gtk_hbox_new (FALSE, 32);
2114         gtk_widget_show (hbox1);
2115         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2116
2117         btn_quotedesc =
2118                 gtk_button_new_with_label (_(" Description of symbols "));
2119         gtk_widget_show (btn_quotedesc);
2120         gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
2121         gtk_signal_connect(GTK_OBJECT(btn_quotedesc), "clicked",
2122                            GTK_SIGNAL_FUNC(quote_fmt_quote_description), NULL);
2123
2124         /* quote chars */
2125
2126         PACK_FRAME (vbox1, frame_quote, _("Quotation characters"));
2127
2128         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
2129         gtk_widget_show (vbox_quote);
2130         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
2131         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
2132
2133         hbox1 = gtk_hbox_new (FALSE, 32);
2134         gtk_widget_show (hbox1);
2135         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
2136
2137         hbox2 = gtk_hbox_new (FALSE, 8);
2138         gtk_widget_show (hbox2);
2139         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
2140
2141         label_quote_chars = gtk_label_new (_("Treat these characters as quotation marks: "));
2142         gtk_widget_show (label_quote_chars);
2143         gtk_box_pack_start (GTK_BOX (hbox2), label_quote_chars, FALSE, FALSE, 0);
2144
2145         entry_quote_chars = gtk_entry_new ();
2146         gtk_widget_show (entry_quote_chars);
2147         gtk_box_pack_start (GTK_BOX (hbox2), entry_quote_chars,
2148                             FALSE, FALSE, 0);
2149         gtk_widget_set_usize (entry_quote_chars, 64, -1);
2150
2151
2152         compose.checkbtn_reply_with_quote= checkbtn_reply_with_quote;
2153         quote.entry_quotemark    = entry_quotemark;
2154         quote.text_quotefmt      = text_quotefmt;
2155         quote.entry_fw_quotemark = entry_fw_quotemark;
2156         quote.text_fw_quotefmt   = text_fw_quotefmt;
2157         quote.entry_quote_chars  = entry_quote_chars;
2158 }
2159
2160 static void prefs_display_create(void)
2161 {
2162         GtkWidget *vbox1;
2163         GtkWidget *frame_font;
2164         GtkWidget *table1;
2165         GtkWidget *label_textfont;
2166         GtkWidget *entry_textfont;
2167         GtkWidget *button_textfont;
2168         GtkWidget *chkbtn_transhdr;
2169         GtkWidget *chkbtn_folder_unread;
2170         GtkWidget *hbox1;
2171         GtkWidget *label_ng_abbrev;
2172         GtkWidget *spinbtn_ng_abbrev_len;
2173         GtkObject *spinbtn_ng_abbrev_len_adj;
2174         GtkWidget *frame_summary;
2175         GtkWidget *vbox2;
2176         GtkWidget *chkbtn_swapfrom;
2177         GtkWidget *chkbtn_useaddrbook;
2178         GtkWidget *chkbtn_threadsubj;
2179         GtkWidget *vbox3;
2180         GtkWidget *label_datefmt;
2181         GtkWidget *button_datefmt;
2182         GtkWidget *entry_datefmt;
2183         GtkWidget *button_dispitem;
2184         GtkWidget *tmplabel, *tmpbutton, *tmpentry;
2185
2186         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2187         gtk_widget_show (vbox1);
2188         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2189         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2190
2191         PACK_FRAME(vbox1, frame_font, _("Font"));
2192
2193         table1 = gtk_table_new (4, 3, FALSE);
2194
2195         gtk_widget_show (table1);
2196         gtk_container_add (GTK_CONTAINER (frame_font), table1);
2197         gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
2198         gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
2199         gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
2200
2201         label_textfont = gtk_label_new (_("Text"));
2202         gtk_misc_set_alignment(GTK_MISC(label_textfont), 0, 0.5);
2203         gtk_widget_show (label_textfont);
2204         gtk_table_attach (GTK_TABLE (table1), label_textfont, 0, 1, 0, 1,
2205                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
2206
2207         entry_textfont = gtk_entry_new ();
2208         gtk_widget_show (entry_textfont);
2209         gtk_table_attach (GTK_TABLE (table1), entry_textfont, 1, 2, 0, 1,
2210                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2211
2212         button_textfont = gtk_button_new_with_label (" ... ");
2213
2214         gtk_widget_show (button_textfont);
2215         gtk_table_attach (GTK_TABLE (table1), button_textfont, 2, 3, 0, 1,
2216                           0, 0, 0, 0);
2217         gtk_signal_connect (GTK_OBJECT (button_textfont), "clicked",
2218                             GTK_SIGNAL_FUNC (prefs_font_select), entry_textfont);
2219
2220         tmplabel = gtk_label_new (_("Small"));
2221         gtk_misc_set_alignment(GTK_MISC(tmplabel), 0, 0.5);
2222         gtk_widget_show (tmplabel);
2223         gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 1, 2,
2224                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
2225
2226         tmpentry = gtk_entry_new ();
2227         gtk_widget_show (tmpentry);
2228         gtk_table_attach (GTK_TABLE (table1), tmpentry, 1, 2, 1, 2,
2229                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2230
2231         tmpbutton = gtk_button_new_with_label (" ... ");
2232         gtk_widget_show (tmpbutton);
2233         gtk_table_attach (GTK_TABLE (table1), tmpbutton, 2, 3, 1, 2,
2234                           0, 0, 0, 0);
2235         gtk_signal_connect (GTK_OBJECT(tmpbutton), "clicked",
2236                             GTK_SIGNAL_FUNC(prefs_font_select), tmpentry);
2237         display.entry_smallfont = tmpentry;                       
2238
2239         tmplabel = gtk_label_new (_("Normal"));
2240         gtk_misc_set_alignment(GTK_MISC(tmplabel), 0, 0.5);
2241         gtk_widget_show (tmplabel);
2242         gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 2, 3,
2243                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
2244
2245         tmpentry = gtk_entry_new ();
2246         gtk_widget_show (tmpentry);
2247         gtk_table_attach (GTK_TABLE (table1), tmpentry, 1, 2, 2, 3,
2248                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2249
2250         tmpbutton = gtk_button_new_with_label (" ... ");
2251         gtk_widget_show (tmpbutton);
2252         gtk_table_attach (GTK_TABLE (table1), tmpbutton, 2, 3, 2, 3,
2253                           0, 0, 0, 0);
2254         gtk_signal_connect (GTK_OBJECT(tmpbutton), "clicked",
2255                                 GTK_SIGNAL_FUNC(prefs_font_select), tmpentry);
2256         display.entry_normalfont = tmpentry;                      
2257
2258         tmplabel = gtk_label_new (_("Bold"));
2259         gtk_misc_set_alignment(GTK_MISC(tmplabel), 0, 0.5);
2260         gtk_widget_show (tmplabel);
2261         gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 3, 4,
2262                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
2263
2264         tmpentry = gtk_entry_new ();
2265         gtk_widget_show (tmpentry);
2266         gtk_table_attach (GTK_TABLE (table1), tmpentry, 1, 2, 3, 4,
2267                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2268
2269         tmpbutton = gtk_button_new_with_label (" ... ");
2270         gtk_widget_show (tmpbutton);
2271         gtk_table_attach (GTK_TABLE (table1), tmpbutton, 2, 3, 3, 4,
2272                           0, 0, 0, 0);
2273         gtk_signal_connect (GTK_OBJECT(tmpbutton), "clicked",
2274                                 GTK_SIGNAL_FUNC(prefs_font_select), tmpentry);
2275         display.entry_boldfont = tmpentry;
2276
2277         vbox2 = gtk_vbox_new (FALSE, 0);
2278         gtk_widget_show (vbox2);
2279         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
2280
2281         PACK_CHECK_BUTTON
2282                 (vbox2, chkbtn_transhdr,
2283                  _("Translate header name (such as `From:', `Subject:')"));
2284
2285         PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
2286                            _("Display unread number next to folder name"));
2287
2288         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
2289
2290         hbox1 = gtk_hbox_new (FALSE, 8);
2291         gtk_widget_show (hbox1);
2292         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2293
2294         label_ng_abbrev = gtk_label_new
2295                 (_("Abbreviate newsgroup names longer than"));
2296         gtk_widget_show (label_ng_abbrev);
2297         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
2298
2299         spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
2300         spinbtn_ng_abbrev_len = gtk_spin_button_new
2301                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
2302         gtk_widget_show (spinbtn_ng_abbrev_len);
2303         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
2304                             FALSE, FALSE, 0);
2305         gtk_widget_set_usize (spinbtn_ng_abbrev_len, 56, -1);
2306         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
2307                                      TRUE);
2308
2309         label_ng_abbrev = gtk_label_new
2310                 (_("letters"));
2311         gtk_widget_show (label_ng_abbrev);
2312         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
2313
2314         /* ---- Summary ---- */
2315
2316         PACK_FRAME(vbox1, frame_summary, _("Summary View"));
2317
2318         vbox2 = gtk_vbox_new (FALSE, 0);
2319         gtk_widget_show (vbox2);
2320         gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
2321         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2322
2323         PACK_CHECK_BUTTON
2324                 (vbox2, chkbtn_swapfrom,
2325                  _("Display recipient in `From' column if sender is yourself"));
2326         PACK_CHECK_BUTTON
2327                 (vbox2, chkbtn_useaddrbook,
2328                  _("Display sender using address book"));
2329         PACK_CHECK_BUTTON
2330                 (vbox2, chkbtn_threadsubj,
2331                  _("Thread using subject in addition to standard headers"));
2332
2333         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
2334
2335         hbox1 = gtk_hbox_new (FALSE, 8);
2336         gtk_widget_show (hbox1);
2337         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2338
2339         label_datefmt = gtk_label_new (_("Date format"));
2340         gtk_widget_show (label_datefmt);
2341         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
2342
2343         entry_datefmt = gtk_entry_new ();
2344         gtk_widget_show (entry_datefmt);
2345         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
2346
2347         button_datefmt = gtk_button_new_with_label (" ... ");
2348
2349         gtk_widget_show (button_datefmt);
2350         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
2351         gtk_signal_connect (GTK_OBJECT (button_datefmt), "clicked",
2352                             GTK_SIGNAL_FUNC (date_format_create), NULL);
2353
2354         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
2355
2356         hbox1 = gtk_hbox_new (FALSE, 8);
2357         gtk_widget_show (hbox1);
2358         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2359
2360         button_dispitem = gtk_button_new_with_label
2361                 (_(" Set displayed items in summary... "));
2362         gtk_widget_show (button_dispitem);
2363         gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
2364         gtk_signal_connect (GTK_OBJECT (button_dispitem), "clicked",
2365                             GTK_SIGNAL_FUNC (prefs_summary_column_open),
2366                             NULL);
2367
2368         display.entry_textfont  = entry_textfont;
2369         display.button_textfont = button_textfont;
2370
2371         display.chkbtn_transhdr           = chkbtn_transhdr;
2372         display.chkbtn_folder_unread      = chkbtn_folder_unread;
2373         display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
2374         display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
2375
2376         display.chkbtn_swapfrom      = chkbtn_swapfrom;
2377         display.chkbtn_useaddrbook   = chkbtn_useaddrbook;
2378         display.chkbtn_threadsubj    = chkbtn_threadsubj;
2379         display.entry_datefmt        = entry_datefmt;
2380 }
2381
2382 static void prefs_message_create(void)
2383 {
2384         GtkWidget *vbox1;
2385         GtkWidget *vbox2;
2386         GtkWidget *vbox3;
2387         GtkWidget *hbox1;
2388         GtkWidget *chkbtn_enablecol;
2389         GtkWidget *button_edit_col;
2390         GtkWidget *chkbtn_mbalnum;
2391         GtkWidget *chkbtn_disphdrpane;
2392         GtkWidget *chkbtn_disphdr;
2393         GtkWidget *button_edit_disphdr;
2394         GtkWidget *hbox_linespc;
2395         GtkWidget *label_linespc;
2396         GtkObject *spinbtn_linespc_adj;
2397         GtkWidget *spinbtn_linespc;
2398         GtkWidget *chkbtn_headspc;
2399
2400         GtkWidget *frame_scr;
2401         GtkWidget *vbox_scr;
2402         GtkWidget *chkbtn_smoothscroll;
2403         GtkWidget *hbox_scr;
2404         GtkWidget *label_scr;
2405         GtkObject *spinbtn_scrollstep_adj;
2406         GtkWidget *spinbtn_scrollstep;
2407         GtkWidget *chkbtn_halfpage;
2408
2409         GtkWidget *chkbtn_attach_desc;
2410
2411         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2412         gtk_widget_show (vbox1);
2413         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2414         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2415
2416         vbox2 = gtk_vbox_new (FALSE, 0);
2417         gtk_widget_show (vbox2);
2418         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2419
2420         hbox1 = gtk_hbox_new (FALSE, 8);
2421         gtk_widget_show (hbox1);
2422         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2423
2424         PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
2425                            _("Enable coloration of message"));
2426         gtk_signal_connect (GTK_OBJECT (chkbtn_enablecol), "toggled",
2427                                                 GTK_SIGNAL_FUNC (prefs_enable_message_color_toggled),
2428                                                 NULL);
2429
2430         button_edit_col = gtk_button_new_with_label (_(" Edit... "));
2431         gtk_widget_show (button_edit_col);
2432         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_col, FALSE, TRUE, 0);
2433         gtk_signal_connect (GTK_OBJECT (button_edit_col), "clicked",
2434                             GTK_SIGNAL_FUNC (prefs_quote_colors_dialog), NULL);
2435
2436         SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
2437
2438         PACK_CHECK_BUTTON
2439                 (vbox2, chkbtn_mbalnum,
2440                  _("Display multi-byte alphanumeric as\n"
2441                    "ASCII character (Japanese only)"));
2442         gtk_label_set_justify (GTK_LABEL (GTK_BIN(chkbtn_mbalnum)->child),
2443                                GTK_JUSTIFY_LEFT);
2444
2445         PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
2446                           _("Display header pane above message view"));
2447
2448         hbox1 = gtk_hbox_new (FALSE, 8);
2449         gtk_widget_show (hbox1);
2450         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2451
2452         PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
2453                           _("Display short headers on message view"));
2454
2455         button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
2456         gtk_widget_show (button_edit_disphdr);
2457         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
2458                           FALSE, TRUE, 0);
2459         gtk_signal_connect (GTK_OBJECT (button_edit_disphdr), "clicked",
2460                             GTK_SIGNAL_FUNC (prefs_display_header_open),
2461                             NULL);
2462
2463         SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
2464
2465         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
2466
2467         hbox1 = gtk_hbox_new (FALSE, 32);
2468         gtk_widget_show (hbox1);
2469         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2470
2471         hbox_linespc = gtk_hbox_new (FALSE, 8);
2472         gtk_widget_show (hbox1);
2473         gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
2474
2475         label_linespc = gtk_label_new (_("Line space"));
2476         gtk_widget_show (label_linespc);
2477         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
2478                             FALSE, FALSE, 0);
2479
2480         spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
2481         spinbtn_linespc = gtk_spin_button_new
2482                 (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
2483         gtk_widget_show (spinbtn_linespc);
2484         gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
2485                             FALSE, FALSE, 0);
2486         gtk_widget_set_usize (spinbtn_linespc, 64, -1);
2487         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
2488
2489         label_linespc = gtk_label_new (_("pixel(s)"));
2490         gtk_widget_show (label_linespc);
2491         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
2492                             FALSE, FALSE, 0);
2493
2494         PACK_CHECK_BUTTON(hbox1, chkbtn_headspc, _("Leave space on head"));
2495
2496         PACK_FRAME(vbox1, frame_scr, _("Scroll"));
2497
2498         vbox_scr = gtk_vbox_new (FALSE, 0);
2499         gtk_widget_show (vbox_scr);
2500         gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
2501         gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
2502
2503         PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
2504
2505         hbox1 = gtk_hbox_new (FALSE, 32);
2506         gtk_widget_show (hbox1);
2507         gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
2508
2509         PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
2510
2511         hbox_scr = gtk_hbox_new (FALSE, 8);
2512         gtk_widget_show (hbox_scr);
2513         gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
2514
2515         label_scr = gtk_label_new (_("Step"));
2516         gtk_widget_show (label_scr);
2517         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2518
2519         spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
2520         spinbtn_scrollstep = gtk_spin_button_new
2521                 (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
2522         gtk_widget_show (spinbtn_scrollstep);
2523         gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
2524                             FALSE, FALSE, 0);
2525         gtk_widget_set_usize (spinbtn_scrollstep, 64, -1);
2526         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
2527                                      TRUE);
2528
2529         label_scr = gtk_label_new (_("pixel(s)"));
2530         gtk_widget_show (label_scr);
2531         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2532
2533         SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
2534
2535         vbox3 = gtk_vbox_new (FALSE, 0);
2536         gtk_widget_show (vbox3);
2537         gtk_box_pack_start (GTK_BOX (vbox1), vbox3, FALSE, FALSE, 0);
2538
2539         PACK_CHECK_BUTTON(vbox3, chkbtn_attach_desc,
2540                           _("Show attachment descriptions (rather than names)"));
2541
2542
2543         message.chkbtn_enablecol   = chkbtn_enablecol;
2544         message.button_edit_col    = button_edit_col;
2545         message.chkbtn_mbalnum     = chkbtn_mbalnum;
2546         message.chkbtn_disphdrpane = chkbtn_disphdrpane;
2547         message.chkbtn_disphdr     = chkbtn_disphdr;
2548         message.spinbtn_linespc    = spinbtn_linespc;
2549         message.chkbtn_headspc     = chkbtn_headspc;
2550
2551         message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
2552         message.spinbtn_scrollstep     = spinbtn_scrollstep;
2553         message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
2554         message.chkbtn_halfpage        = chkbtn_halfpage;
2555
2556         message.chkbtn_attach_desc  = chkbtn_attach_desc;
2557 }
2558
2559 #if USE_GPGME
2560 static void prefs_privacy_create(void)
2561 {
2562         GtkWidget *vbox1;
2563         GtkWidget *vbox2;
2564         GtkWidget *vbox3;
2565         GtkWidget *hbox1;
2566         GtkWidget *hbox_spc;
2567         GtkWidget *label;
2568         GtkWidget *checkbtn_auto_check_signatures;
2569         GtkWidget *checkbtn_gpg_signature_popup;
2570         GtkWidget *checkbtn_store_passphrase;
2571         GtkObject *spinbtn_store_passphrase_adj;
2572         GtkWidget *spinbtn_store_passphrase;
2573         GtkWidget *checkbtn_passphrase_grab;
2574         GtkWidget *checkbtn_gpg_warning;
2575
2576         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2577         gtk_widget_show (vbox1);
2578         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2579         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2580
2581         vbox2 = gtk_vbox_new (FALSE, 0);
2582         gtk_widget_show (vbox2);
2583         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2584
2585         PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
2586                            _("Automatically check signatures"));
2587
2588         PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup,
2589                            _("Show signature check result in a popup window"));
2590
2591         PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
2592                            _("Store passphrase in memory temporarily"));
2593
2594         vbox3 = gtk_vbox_new (FALSE, 0);
2595         gtk_widget_show (vbox3);
2596         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2597
2598         hbox1 = gtk_hbox_new (FALSE, 8);
2599         gtk_widget_show (hbox1);
2600         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2601
2602         hbox_spc = gtk_hbox_new (FALSE, 0);
2603         gtk_widget_show (hbox_spc);
2604         gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2605         gtk_widget_set_usize (hbox_spc, 12, -1);
2606
2607         label = gtk_label_new (_("Expire after"));
2608         gtk_widget_show (label);
2609         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2610
2611         spinbtn_store_passphrase_adj = gtk_adjustment_new (0, 0, 1440, 1, 5, 5);
2612         spinbtn_store_passphrase = gtk_spin_button_new
2613                 (GTK_ADJUSTMENT (spinbtn_store_passphrase_adj), 1, 0);
2614         gtk_widget_show (spinbtn_store_passphrase);
2615         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_store_passphrase, FALSE, FALSE, 0);
2616         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_store_passphrase),
2617                                      TRUE);
2618         gtk_widget_set_usize (spinbtn_store_passphrase, 64, -1);
2619
2620         label = gtk_label_new (_("minute(s) "));
2621         gtk_widget_show (label);
2622         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2623
2624         hbox1 = gtk_hbox_new (FALSE, 8);
2625         gtk_widget_show (hbox1);
2626         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2627
2628         hbox_spc = gtk_hbox_new (FALSE, 0);
2629         gtk_widget_show (hbox_spc);
2630         gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
2631         gtk_widget_set_usize (hbox_spc, 12, -1);
2632
2633         label = gtk_label_new (_("(Setting to '0' will store the passphrase\n"
2634                                  " for the whole session)"));
2635         gtk_widget_show (label);
2636         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2637         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2638
2639         SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, vbox3);
2640
2641 #ifndef __MINGW32__
2642         PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
2643                            _("Grab input while entering a passphrase"));
2644 #endif
2645
2646         PACK_CHECK_BUTTON
2647                 (vbox2, checkbtn_gpg_warning,
2648                  _("Display warning on startup if GnuPG doesn't work"));
2649
2650         hbox1 = gtk_hbox_new (FALSE, 8);
2651         gtk_widget_show (hbox1);
2652         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2653
2654         privacy.checkbtn_auto_check_signatures
2655                                              = checkbtn_auto_check_signatures;
2656         privacy.checkbtn_gpg_signature_popup
2657                                              = checkbtn_gpg_signature_popup;
2658         privacy.checkbtn_store_passphrase    = checkbtn_store_passphrase;
2659         privacy.spinbtn_store_passphrase     = spinbtn_store_passphrase;
2660         privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
2661         privacy.checkbtn_passphrase_grab     = checkbtn_passphrase_grab;
2662         privacy.checkbtn_gpg_warning         = checkbtn_gpg_warning;
2663 }
2664 #endif /* USE_GPGME */
2665
2666 static void prefs_interface_create(void)
2667 {
2668         GtkWidget *vbox1;
2669         GtkWidget *vbox2;
2670         GtkWidget *vbox3;
2671         /* GtkWidget *checkbtn_emacs; */
2672         GtkWidget *checkbtn_always_show_msg;
2673         GtkWidget *checkbtn_openunread;
2674         GtkWidget *checkbtn_mark_as_read_on_newwin;
2675         GtkWidget *checkbtn_openinbox;
2676         GtkWidget *checkbtn_immedexec;
2677         GtkWidget *hbox1;
2678         GtkWidget *label;
2679         GtkWidget *menu;
2680         GtkWidget *menuitem;
2681
2682         GtkWidget *button_keybind;
2683
2684         GtkWidget *hbox_nextunreadmsgdialog;
2685         GtkWidget *optmenu_nextunreadmsgdialog;
2686
2687         GtkWidget *frame_pixmap_theme;
2688         GtkWidget *vbox_pixmap_theme;
2689         GtkWidget *entry_pixmap_theme;
2690         GtkWidget *combo_pixmap_theme;
2691         GList *avail_pixmap_themes = NULL;
2692
2693         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2694         gtk_widget_show (vbox1);
2695         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2696         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2697
2698         vbox2 = gtk_vbox_new (FALSE, 0);
2699         gtk_widget_show (vbox2);
2700         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2701
2702         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
2703                            _("Emulate the behavior of mouse operation of\n"
2704                              "Emacs-based mailer"));
2705         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
2706                                GTK_JUSTIFY_LEFT);   */
2707
2708         PACK_CHECK_BUTTON
2709                 (vbox2, checkbtn_always_show_msg,
2710                  _("Always open messages in summary when selected"));
2711
2712         PACK_CHECK_BUTTON
2713                 (vbox2, checkbtn_openunread,
2714                  _("Open first unread message when entering a folder"));
2715
2716         PACK_CHECK_BUTTON
2717                 (vbox2, checkbtn_mark_as_read_on_newwin,
2718                  _("Only mark message as read when opened in new window"));
2719
2720         PACK_CHECK_BUTTON
2721                 (vbox2, checkbtn_openinbox,
2722                  _("Go to inbox after receiving new mail"));
2723
2724         vbox3 = gtk_vbox_new (FALSE, 0);
2725         gtk_widget_show (vbox3);
2726         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2727
2728         PACK_CHECK_BUTTON
2729                 (vbox3, checkbtn_immedexec,
2730                  _("Execute immediately when moving or deleting messages"));
2731
2732         hbox1 = gtk_hbox_new (FALSE, 0);
2733         gtk_widget_show (hbox1);
2734         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2735
2736         label = gtk_label_new
2737                 (_("(Messages will be marked until execution\n"
2738                    " if this is turned off)"));
2739         gtk_widget_show (label);
2740         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 8);
2741         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2742
2743         /* Next Unread Message Dialog */
2744         hbox_nextunreadmsgdialog = gtk_hbox_new (FALSE, 8);
2745         gtk_widget_show (hbox1);
2746         gtk_box_pack_start (GTK_BOX (vbox1), hbox_nextunreadmsgdialog, FALSE, FALSE, 0);
2747
2748         label = gtk_label_new (_("Show no-unread-message dialog"));
2749         gtk_widget_show (label);
2750         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), label, FALSE, FALSE, 8);
2751
2752         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
2753         gtk_widget_show (optmenu_nextunreadmsgdialog);
2754         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), optmenu_nextunreadmsgdialog, FALSE, FALSE, 8);
2755         
2756         menu = gtk_menu_new ();
2757         MENUITEM_ADD (menu, menuitem, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
2758         MENUITEM_ADD (menu, menuitem, _("Assume 'Yes'"), 
2759                       NEXTUNREADMSGDIALOG_ASSUME_YES);
2760         MENUITEM_ADD (menu, menuitem, _("Assume 'No'"), 
2761                       NEXTUNREADMSGDIALOG_ASSUME_NO);
2762
2763         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog), menu);
2764
2765         hbox1 = gtk_hbox_new (FALSE, 8);
2766         gtk_widget_show (hbox1);
2767         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2768
2769         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2770         gtk_widget_show (button_keybind);
2771         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2772         gtk_signal_connect (GTK_OBJECT (button_keybind), "clicked",
2773                             GTK_SIGNAL_FUNC (prefs_keybind_select), NULL);
2774
2775         PACK_FRAME(vbox1, frame_pixmap_theme, _("Icon theme"));
2776         
2777         vbox_pixmap_theme = gtk_vbox_new(FALSE, 0);
2778         gtk_widget_show(vbox_pixmap_theme);
2779         gtk_container_add(GTK_CONTAINER(frame_pixmap_theme), vbox_pixmap_theme);
2780         gtk_container_set_border_width(GTK_CONTAINER(vbox_pixmap_theme), 8);
2781  
2782         avail_pixmap_themes = stock_pixmap_themes_list_new(); 
2783  
2784         combo_pixmap_theme = gtk_combo_new ();
2785         gtk_widget_show (combo_pixmap_theme);
2786         gtk_box_pack_start (GTK_BOX (vbox_pixmap_theme), combo_pixmap_theme, TRUE, TRUE, 0);
2787         gtk_combo_set_popdown_strings(GTK_COMBO(combo_pixmap_theme), avail_pixmap_themes);
2788         entry_pixmap_theme = GTK_COMBO (combo_pixmap_theme)->entry;
2789
2790         stock_pixmap_themes_list_free(avail_pixmap_themes);
2791
2792         /* interface.checkbtn_emacs          = checkbtn_emacs; */
2793         interface.checkbtn_always_show_msg    = checkbtn_always_show_msg;
2794         interface.checkbtn_openunread         = checkbtn_openunread;
2795         interface.checkbtn_mark_as_read_on_newwin
2796                                               = checkbtn_mark_as_read_on_newwin;
2797         interface.checkbtn_openinbox          = checkbtn_openinbox;
2798         interface.checkbtn_immedexec          = checkbtn_immedexec;
2799         interface.optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
2800         interface.combo_pixmap_theme          = combo_pixmap_theme;
2801         interface.entry_pixmap_theme          = entry_pixmap_theme;
2802 }
2803
2804 static void prefs_other_create(void)
2805 {
2806         GtkWidget *vbox1;
2807         GtkWidget *ext_frame;
2808         GtkWidget *ext_table;
2809         GtkWidget *hbox1;
2810
2811         GtkWidget *uri_label;
2812         GtkWidget *uri_combo;
2813         GtkWidget *uri_entry;
2814
2815         GtkWidget *printcmd_label;
2816         GtkWidget *printcmd_entry;
2817
2818         GtkWidget *exteditor_label;
2819         GtkWidget *exteditor_combo;
2820         GtkWidget *exteditor_entry;
2821
2822         GtkWidget *frame_addr;
2823         GtkWidget *vbox_addr;
2824         GtkWidget *checkbtn_addaddrbyclick;
2825         
2826         GtkWidget *frame_cliplog;
2827         GtkWidget *vbox_cliplog;
2828         GtkWidget *hbox_cliplog;
2829         GtkWidget *checkbtn_cliplog;
2830         GtkWidget *loglength_label;
2831         GtkWidget *loglength_entry;
2832
2833         GtkWidget *frame_exit;
2834         GtkWidget *vbox_exit;
2835         GtkWidget *checkbtn_confonexit;
2836         GtkWidget *checkbtn_cleanonexit;
2837         GtkWidget *checkbtn_askonclean;
2838         GtkWidget *checkbtn_warnqueued;
2839
2840         GtkWidget *label_iotimeout;
2841         GtkWidget *spinbtn_iotimeout;
2842         GtkObject *spinbtn_iotimeout_adj;
2843
2844 #if 0
2845 #ifdef USE_OPENSSL
2846         GtkWidget *frame_ssl;
2847         GtkWidget *vbox_ssl;
2848         GtkWidget *hbox_ssl;
2849         GtkWidget *checkbtn_ssl_ask_unknown_valid;
2850 #endif
2851 #endif
2852         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2853         gtk_widget_show (vbox1);
2854         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2855         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2856
2857         PACK_FRAME(vbox1, ext_frame,
2858                    _("External commands (%s will be replaced with file name / URI)"));
2859
2860         ext_table = gtk_table_new (3, 2, FALSE);
2861         gtk_widget_show (ext_table);
2862         gtk_container_add (GTK_CONTAINER (ext_frame), ext_table);
2863         gtk_container_set_border_width (GTK_CONTAINER (ext_table), 8);
2864         gtk_table_set_row_spacings (GTK_TABLE (ext_table), VSPACING_NARROW);
2865         gtk_table_set_col_spacings (GTK_TABLE (ext_table), 8);
2866
2867         uri_label = gtk_label_new (_("Web browser"));
2868         gtk_widget_show(uri_label);
2869         gtk_table_attach (GTK_TABLE (ext_table), uri_label, 0, 1, 0, 1,
2870                           GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2871         gtk_misc_set_alignment (GTK_MISC (uri_label), 1, 0.5);
2872
2873         uri_combo = gtk_combo_new ();
2874         gtk_widget_show (uri_combo);
2875         gtk_table_attach (GTK_TABLE (ext_table), uri_combo, 1, 2, 0, 1,
2876                           GTK_EXPAND | GTK_FILL, 0, 0, 0);
2877         gtkut_combo_set_items (GTK_COMBO (uri_combo),
2878                                DEFAULT_BROWSER_CMD,
2879                                "galeon --new-tab '%s'",
2880                                "galeon '%s'",
2881                                "mozilla -remote 'openurl(%s,new-window)'",
2882                                "netscape -remote 'openURL(%s, new-window)'",
2883                                "netscape '%s'",
2884                                "gnome-moz-remote --newwin '%s'",
2885                                "kfmclient openURL '%s'",
2886                                "opera -newwindow '%s'",
2887                                "kterm -e w3m '%s'",
2888                                "kterm -e lynx '%s'",
2889                                NULL);
2890         uri_entry = GTK_COMBO (uri_combo)->entry;
2891
2892         printcmd_label = gtk_label_new (_("Print"));
2893         gtk_widget_show (printcmd_label);
2894         gtk_table_attach (GTK_TABLE (ext_table), printcmd_label, 0, 1, 1, 2,
2895                           GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2896         gtk_misc_set_alignment (GTK_MISC (printcmd_label), 1, 0.5);
2897
2898         printcmd_entry = gtk_entry_new ();
2899         gtk_widget_show (printcmd_entry);
2900         gtk_table_attach (GTK_TABLE (ext_table), printcmd_entry, 1, 2, 1, 2,
2901                           GTK_EXPAND | GTK_FILL, 0, 0, 0);
2902
2903         exteditor_label = gtk_label_new (_("Editor"));
2904         gtk_widget_show (exteditor_label);
2905         gtk_table_attach (GTK_TABLE (ext_table), exteditor_label, 0, 1, 2, 3,
2906                           GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2907         gtk_misc_set_alignment (GTK_MISC (exteditor_label), 1, 0.5);
2908
2909         exteditor_combo = gtk_combo_new ();
2910         gtk_widget_show (exteditor_combo);
2911         gtk_table_attach (GTK_TABLE (ext_table), exteditor_combo, 1, 2, 2, 3,
2912                           GTK_EXPAND | GTK_FILL, 0, 0, 0);
2913         gtkut_combo_set_items (GTK_COMBO (exteditor_combo),
2914                                "gedit %s",
2915                                "kedit %s",
2916                                "mgedit --no-fork %s",
2917                                "emacs %s",
2918                                "xemacs %s",
2919                                "kterm -e jed %s",
2920                                "kterm -e vi %s",
2921                                NULL);
2922         exteditor_entry = GTK_COMBO (exteditor_combo)->entry;
2923
2924         PACK_FRAME (vbox1, frame_addr, _("Address book"));
2925
2926         vbox_addr = gtk_vbox_new (FALSE, 0);
2927         gtk_widget_show (vbox_addr);
2928         gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2929         gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2930
2931         PACK_CHECK_BUTTON
2932                 (vbox_addr, checkbtn_addaddrbyclick,
2933                  _("Add address to destination when double-clicked"));
2934
2935         /* Clip Log */
2936         PACK_FRAME (vbox1, frame_cliplog, _("Log Size"));
2937
2938         vbox_cliplog = gtk_vbox_new (FALSE, 0);
2939         gtk_widget_show (vbox_cliplog);
2940         gtk_container_add (GTK_CONTAINER (frame_cliplog), vbox_cliplog);
2941         gtk_container_set_border_width (GTK_CONTAINER (vbox_cliplog), 8);
2942         PACK_CHECK_BUTTON (vbox_cliplog, checkbtn_cliplog,
2943                            _("Clip the log size"));
2944         hbox_cliplog = gtk_hbox_new (FALSE, 3);
2945         gtk_container_add (GTK_CONTAINER (vbox_cliplog), hbox_cliplog);
2946         gtk_widget_show (hbox_cliplog);
2947         
2948         loglength_label = gtk_label_new (_("Log window length"));
2949         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
2950                             FALSE, TRUE, 0);
2951         gtk_widget_show (GTK_WIDGET (loglength_label));
2952         loglength_entry = gtk_entry_new ();
2953         gtk_widget_set_usize (GTK_WIDGET (loglength_entry), 64, -1);
2954         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_entry,
2955                             FALSE, TRUE, 0);
2956         gtk_widget_show (GTK_WIDGET (loglength_entry));
2957         loglength_label = gtk_label_new (_("(0 to stop logging in the log window)"));
2958         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
2959                             FALSE, TRUE, 0);
2960         SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_entry);
2961
2962 #if 0
2963 #ifdef USE_OPENSSL
2964         /* SSL */
2965         PACK_FRAME (vbox1, frame_ssl, _("Security"));
2966
2967         vbox_ssl = gtk_vbox_new (FALSE, 0);
2968         gtk_widget_show (vbox_ssl);
2969         gtk_container_add (GTK_CONTAINER (frame_ssl), vbox_ssl);
2970         gtk_container_set_border_width (GTK_CONTAINER (vbox_ssl), 8);
2971         PACK_CHECK_BUTTON (vbox_ssl, checkbtn_ssl_ask_unknown_valid, 
2972                            _("Ask before accepting SSL certificates"));
2973         hbox_ssl = gtk_hbox_new (FALSE, 3);
2974         gtk_container_add (GTK_CONTAINER (vbox_ssl), hbox_ssl);
2975         gtk_widget_show (hbox_ssl);
2976 #endif
2977 #endif
2978         
2979         /* On Exit */
2980         PACK_FRAME (vbox1, frame_exit, _("On exit"));
2981
2982         vbox_exit = gtk_vbox_new (FALSE, 0);
2983         gtk_widget_show (vbox_exit);
2984         gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2985         gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2986
2987         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2988                            _("Confirm on exit"));
2989
2990         hbox1 = gtk_hbox_new (FALSE, 32);
2991         gtk_widget_show (hbox1);
2992         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2993
2994         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2995                            _("Empty trash on exit"));
2996         PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2997                            _("Ask before emptying"));
2998         SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2999
3000         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
3001                            _("Warn if there are queued messages"));
3002
3003         hbox1 = gtk_hbox_new (FALSE, 8);
3004         gtk_widget_show (hbox1);
3005         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
3006
3007         label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
3008         gtk_widget_show (label_iotimeout);
3009         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
3010
3011         spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
3012         spinbtn_iotimeout = gtk_spin_button_new
3013                 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
3014         gtk_widget_show (spinbtn_iotimeout);
3015         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
3016                             FALSE, FALSE, 0);
3017         gtk_widget_set_usize (spinbtn_iotimeout, 64, -1);
3018         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
3019
3020         label_iotimeout = gtk_label_new (_("second(s)"));
3021         gtk_widget_show (label_iotimeout);
3022         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
3023
3024         other.uri_combo = uri_combo;
3025         other.uri_entry = uri_entry;
3026         other.printcmd_entry = printcmd_entry;
3027
3028         other.exteditor_combo = exteditor_combo;
3029         other.exteditor_entry = exteditor_entry;
3030
3031         other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
3032         
3033         other.checkbtn_cliplog     = checkbtn_cliplog;
3034         other.loglength_entry      = loglength_entry;
3035
3036         other.checkbtn_confonexit  = checkbtn_confonexit;
3037         other.checkbtn_cleanonexit = checkbtn_cleanonexit;
3038         other.checkbtn_askonclean  = checkbtn_askonclean;
3039         other.checkbtn_warnqueued  = checkbtn_warnqueued;
3040
3041         other.spinbtn_iotimeout     = spinbtn_iotimeout;
3042         other.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
3043         
3044 #if 0
3045 #ifdef USE_OPENSSL
3046         other.checkbtn_ssl_ask_unknown_valid = checkbtn_ssl_ask_unknown_valid;
3047 #endif
3048 #endif
3049 }
3050
3051 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
3052 {
3053         GtkWidget *datefmt_sample = NULL;
3054         gchar *text;
3055
3056         g_return_if_fail(widget != NULL);
3057         g_return_if_fail(*widget != NULL);
3058         g_return_if_fail(display.entry_datefmt != NULL);
3059
3060         datefmt_sample = GTK_WIDGET(gtk_object_get_data
3061                                     (GTK_OBJECT(*widget), "datefmt_sample"));
3062         g_return_if_fail(datefmt_sample != NULL);
3063
3064         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
3065         g_free(prefs_common.date_format);
3066         prefs_common.date_format = text;
3067         gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
3068
3069         gtk_widget_destroy(*widget);
3070         *widget = NULL;
3071 }
3072
3073 static void date_format_cancel_btn_clicked(GtkButton *button,
3074                                            GtkWidget **widget)
3075 {
3076         g_return_if_fail(widget != NULL);
3077         g_return_if_fail(*widget != NULL);
3078
3079         gtk_widget_destroy(*widget);
3080         *widget = NULL;
3081 }
3082
3083 static void date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
3084                                     GtkWidget **widget)
3085 {
3086         if (event && event->keyval == GDK_Escape)
3087                 date_format_cancel_btn_clicked(NULL, widget);
3088 }
3089
3090 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
3091                                       GdkEventAny *event, GtkWidget **widget)
3092 {
3093         g_return_val_if_fail(widget != NULL, FALSE);
3094         g_return_val_if_fail(*widget != NULL, FALSE);
3095
3096         *widget = NULL;
3097         return FALSE;
3098 }
3099
3100 static void date_format_entry_on_change(GtkEditable *editable,
3101                                         GtkLabel *example)
3102 {
3103         time_t cur_time;
3104         struct tm *cal_time;
3105         gchar buffer[100];
3106         gchar *text;
3107
3108         cur_time = time(NULL);
3109         cal_time = localtime(&cur_time);
3110         buffer[0] = 0;
3111         text = gtk_editable_get_chars(editable, 0, -1);
3112         if (text)
3113                 strftime(buffer, sizeof buffer, text, cal_time); 
3114         g_free(text);
3115         gtk_label_set_text(example, buffer);
3116 }
3117
3118 static void date_format_select_row(GtkWidget *date_format_list, gint row,
3119                                    gint column, GdkEventButton *event,
3120                                    GtkWidget *date_format)
3121 {
3122         gint cur_pos;
3123         gchar *format;
3124         gchar *old_format;
3125         gchar *new_format;
3126         GtkWidget *datefmt_sample;
3127
3128         /* only on double click */
3129         if (!event || event->type != GDK_2BUTTON_PRESS) return;
3130
3131
3132         datefmt_sample = GTK_WIDGET(gtk_object_get_data
3133                                     (GTK_OBJECT(date_format), "datefmt_sample"));
3134
3135         g_return_if_fail(date_format_list != NULL);
3136         g_return_if_fail(date_format != NULL);
3137         g_return_if_fail(datefmt_sample != NULL);
3138
3139         /* get format from clist */
3140         gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
3141
3142         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
3143         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
3144
3145         /* insert the format into the text entry */
3146         new_format = g_malloc(strlen(old_format) + 3);
3147
3148         strncpy(new_format, old_format, cur_pos);
3149         new_format[cur_pos] = '\0';
3150         strcat(new_format, format);
3151         strcat(new_format, &old_format[cur_pos]);
3152
3153         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
3154         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
3155
3156         g_free(new_format);
3157 }
3158
3159 static GtkWidget *date_format_create(GtkButton *button, void *data)
3160 {
3161         static GtkWidget *datefmt_win = NULL;
3162         GtkWidget *vbox1;
3163         GtkWidget *scrolledwindow1;
3164         GtkWidget *datefmt_clist;
3165         GtkWidget *table;
3166         GtkWidget *label1;
3167         GtkWidget *label2;
3168         GtkWidget *label3;
3169         GtkWidget *confirm_area;
3170         GtkWidget *ok_btn;
3171         GtkWidget *cancel_btn;
3172         GtkWidget *datefmt_entry;
3173
3174         struct {
3175                 gchar *fmt;
3176                 gchar *txt;
3177         } time_format[] = {
3178                 { "%a", NULL },
3179                 { "%A", NULL },
3180                 { "%b", NULL },
3181                 { "%B", NULL },
3182                 { "%c", NULL },
3183                 { "%C", NULL },
3184                 { "%d", NULL },
3185                 { "%H", NULL },
3186                 { "%I", NULL },
3187                 { "%j", NULL },
3188                 { "%m", NULL },
3189                 { "%M", NULL },
3190                 { "%p", NULL },
3191                 { "%S", NULL },
3192                 { "%w", NULL },
3193                 { "%x", NULL },
3194                 { "%y", NULL },
3195                 { "%Y", NULL },
3196                 { "%Z", NULL }
3197         };
3198
3199         gchar *titles[2];
3200         gint i;
3201         const gint TIME_FORMAT_ELEMS =
3202                 sizeof time_format / sizeof time_format[0];
3203
3204         time_format[0].txt  = _("the full abbreviated weekday name");
3205         time_format[1].txt  = _("the full weekday name");
3206         time_format[2].txt  = _("the abbreviated month name");
3207         time_format[3].txt  = _("the full month name");
3208         time_format[4].txt  = _("the preferred date and time for the current locale");
3209         time_format[5].txt  = _("the century number (year/100)");
3210         time_format[6].txt  = _("the day of the month as a decimal number");
3211         time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
3212         time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
3213         time_format[9].txt  = _("the day of the year as a decimal number");
3214         time_format[10].txt = _("the month as a decimal number");
3215         time_format[11].txt = _("the minute as a decimal number");
3216         time_format[12].txt = _("either AM or PM");
3217         time_format[13].txt = _("the second as a decimal number");
3218         time_format[14].txt = _("the day of the week as a decimal number");
3219         time_format[15].txt = _("the preferred date for the current locale");
3220         time_format[16].txt = _("the last two digits of a year");
3221         time_format[17].txt = _("the year as a decimal number");
3222         time_format[18].txt = _("the time zone or name or abbreviation");
3223
3224         if (datefmt_win) return datefmt_win;
3225
3226         datefmt_win = gtk_window_new(GTK_WINDOW_DIALOG);
3227         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
3228         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
3229         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3230         gtk_widget_set_usize(datefmt_win, 440, 280);
3231
3232         vbox1 = gtk_vbox_new(FALSE, 10);
3233         gtk_widget_show(vbox1);
3234         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
3235
3236         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
3237         gtk_scrolled_window_set_policy
3238                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
3239                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3240         gtk_widget_show(scrolledwindow1);
3241         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
3242
3243         titles[0] = _("Specifier");
3244         titles[1] = _("Description");
3245         datefmt_clist = gtk_clist_new_with_titles(2, titles);
3246         gtk_widget_show(datefmt_clist);
3247         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
3248         /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
3249         gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
3250                                      GTK_SELECTION_BROWSE);
3251
3252         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
3253                 gchar *text[2];
3254                 /* phoney casting necessary because of gtk... */
3255                 text[0] = (gchar *)time_format[i].fmt;
3256                 text[1] = (gchar *)time_format[i].txt;
3257                 gtk_clist_append(GTK_CLIST(datefmt_clist), text);
3258         }
3259
3260         table = gtk_table_new(2, 2, FALSE);
3261         gtk_widget_show(table);
3262         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
3263         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
3264         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
3265
3266         label1 = gtk_label_new(_("Date format"));
3267         gtk_widget_show(label1);
3268         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
3269                          GTK_FILL, 0, 0, 0);
3270         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
3271         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
3272
3273         datefmt_entry = gtk_entry_new_with_max_length(256);
3274         gtk_widget_show(datefmt_entry);
3275         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
3276                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3277
3278         /* we need the "sample" entry box; add it as data so callbacks can
3279          * get the entry box */
3280         gtk_object_set_data(GTK_OBJECT(datefmt_win), "datefmt_sample",
3281                             datefmt_entry);
3282
3283         label2 = gtk_label_new(_("Example"));
3284         gtk_widget_show(label2);
3285         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
3286                          GTK_FILL, 0, 0, 0);
3287         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
3288         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
3289
3290         label3 = gtk_label_new("");
3291         gtk_widget_show(label3);
3292         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
3293                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3294         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
3295         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
3296
3297         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
3298                                 &cancel_btn, _("Cancel"), NULL, NULL);
3299         gtk_widget_grab_default(ok_btn);
3300         gtk_widget_show(confirm_area);
3301
3302         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
3303
3304         /* set the current format */
3305         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
3306         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
3307                                     GTK_LABEL(label3));
3308
3309         gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
3310                            GTK_SIGNAL_FUNC(date_format_ok_btn_clicked),
3311                            &datefmt_win);
3312         gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked",
3313                            GTK_SIGNAL_FUNC(date_format_cancel_btn_clicked),
3314                            &datefmt_win);
3315         gtk_signal_connect(GTK_OBJECT(datefmt_win), "key_press_event",
3316                            GTK_SIGNAL_FUNC(date_format_key_pressed),
3317                            &datefmt_win);
3318         gtk_signal_connect(GTK_OBJECT(datefmt_win), "delete_event",
3319                            GTK_SIGNAL_FUNC(date_format_on_delete),
3320                            &datefmt_win);
3321         gtk_signal_connect(GTK_OBJECT(datefmt_entry), "changed",
3322                            GTK_SIGNAL_FUNC(date_format_entry_on_change),
3323                            label3);
3324
3325         gtk_signal_connect(GTK_OBJECT(datefmt_clist), "select_row",
3326                            GTK_SIGNAL_FUNC(date_format_select_row),
3327                            datefmt_win);
3328
3329         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3330         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
3331
3332         gtk_widget_show(datefmt_win);
3333         manage_window_set_transient(GTK_WINDOW(datefmt_win));
3334
3335         gtk_widget_grab_focus(ok_btn);
3336
3337         return datefmt_win;
3338 }
3339
3340 void prefs_quote_colors_dialog(void)
3341 {
3342         if (!quote_color_win)
3343                 prefs_quote_colors_dialog_create();
3344         gtk_widget_show(quote_color_win);
3345         manage_window_set_transient(GTK_WINDOW(quote_color_win));
3346
3347         gtk_main();
3348         gtk_widget_hide(quote_color_win);
3349
3350         textview_update_message_colors();
3351         main_window_reflect_prefs_all();
3352 }
3353
3354 static void prefs_quote_colors_dialog_create(void)
3355 {
3356         GtkWidget *window;
3357         GtkWidget *vbox;
3358         GtkWidget *table;
3359         GtkWidget *quotelevel1_label;
3360         GtkWidget *quotelevel2_label;
3361         GtkWidget *quotelevel3_label;
3362         GtkWidget *uri_label;
3363         GtkWidget *signature_label;
3364         GtkWidget *tgt_folder_label;
3365         GtkWidget *hbbox;
3366         GtkWidget *ok_btn;
3367         GtkWidget *recycle_colors_btn;
3368         GtkWidget *frame_colors;
3369
3370         window = gtk_window_new(GTK_WINDOW_DIALOG);
3371         gtk_container_set_border_width(GTK_CONTAINER(window), 2);
3372         gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
3373         gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
3374         gtk_window_set_modal(GTK_WINDOW(window), TRUE);
3375         gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
3376
3377         vbox = gtk_vbox_new (FALSE, VSPACING);
3378         gtk_container_add (GTK_CONTAINER (window), vbox);
3379         gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
3380         PACK_FRAME(vbox, frame_colors, _("Colors"));
3381
3382         table = gtk_table_new (5, 2, FALSE);
3383         gtk_container_add (GTK_CONTAINER (frame_colors), table);
3384         gtk_container_set_border_width (GTK_CONTAINER (table), 8);
3385         gtk_table_set_row_spacings (GTK_TABLE (table), 2);
3386         gtk_table_set_col_spacings (GTK_TABLE (table), 5);
3387
3388
3389         color_buttons.quote_level1_btn = gtk_button_new();
3390         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level1_btn,
3391                           0, 1, 0, 1, 0, 0, 0, 0);
3392         gtk_widget_set_usize (color_buttons.quote_level1_btn, 40, 30);
3393         gtk_container_set_border_width
3394                 (GTK_CONTAINER (color_buttons.quote_level1_btn), 5);
3395
3396         color_buttons.quote_level2_btn = gtk_button_new();
3397         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level2_btn,
3398                           0, 1, 1, 2, 0, 0, 0, 0);
3399         gtk_widget_set_usize (color_buttons.quote_level2_btn, 40, 30);
3400         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.quote_level2_btn), 5);
3401
3402         color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
3403         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
3404                           0, 1, 2, 3, 0, 0, 0, 0);
3405         gtk_widget_set_usize (color_buttons.quote_level3_btn, 40, 30);
3406         gtk_container_set_border_width
3407                 (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
3408
3409         color_buttons.uri_btn = gtk_button_new_with_label ("");
3410         gtk_table_attach (GTK_TABLE (table), color_buttons.uri_btn,
3411                           0, 1, 3, 4, 0, 0, 0, 0);
3412         gtk_widget_set_usize (color_buttons.uri_btn, 40, 30);
3413         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.uri_btn), 5);
3414
3415         color_buttons.tgt_folder_btn = gtk_button_new_with_label ("");
3416         gtk_table_attach (GTK_TABLE (table), color_buttons.tgt_folder_btn,
3417                           0, 1, 4, 5, 0, 0, 0, 0);
3418         gtk_widget_set_usize (color_buttons.tgt_folder_btn, 40, 30);
3419         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.tgt_folder_btn), 5);
3420
3421         color_buttons.signature_btn = gtk_button_new_with_label ("");
3422         gtk_table_attach (GTK_TABLE (table), color_buttons.signature_btn,
3423                           0, 1, 5, 6, 0, 0, 0, 0);
3424         gtk_widget_set_usize (color_buttons.signature_btn, 40, 30);
3425         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.signature_btn), 5);
3426
3427         quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
3428         gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
3429                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3430         gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
3431         gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
3432
3433         quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
3434         gtk_table_attach (GTK_TABLE (table), quotelevel2_label, 1, 2, 1, 2,
3435                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3436         gtk_label_set_justify (GTK_LABEL (quotelevel2_label), GTK_JUSTIFY_LEFT);
3437         gtk_misc_set_alignment (GTK_MISC (quotelevel2_label), 0, 0.5);
3438
3439         quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
3440         gtk_table_attach (GTK_TABLE (table), quotelevel3_label, 1, 2, 2, 3,
3441                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3442         gtk_label_set_justify (GTK_LABEL (quotelevel3_label), GTK_JUSTIFY_LEFT);
3443         gtk_misc_set_alignment (GTK_MISC (quotelevel3_label), 0, 0.5);
3444
3445         uri_label = gtk_label_new (_("URI link"));
3446         gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
3447                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3448         gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
3449         gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
3450
3451         tgt_folder_label = gtk_label_new (_("Target folder"));
3452         gtk_table_attach (GTK_TABLE (table), tgt_folder_label, 1, 2, 4, 5,
3453                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3454         gtk_label_set_justify (GTK_LABEL (tgt_folder_label), GTK_JUSTIFY_LEFT);
3455         gtk_misc_set_alignment (GTK_MISC (tgt_folder_label), 0, 0.5);
3456
3457         signature_label = gtk_label_new (_("Signatures"));
3458         gtk_table_attach (GTK_TABLE (table), signature_label, 1, 2, 5, 6,
3459                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3460         gtk_label_set_justify (GTK_LABEL (signature_label), GTK_JUSTIFY_LEFT);
3461         gtk_misc_set_alignment (GTK_MISC (signature_label), 0, 0.5);
3462
3463         PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
3464                            _("Recycle quote colors"));
3465
3466         gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
3467                                 NULL, NULL, NULL, NULL);
3468         gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3469
3470         gtk_widget_grab_default(ok_btn);
3471         MANAGE_WINDOW_SIGNALS_CONNECT(window);
3472         gtk_signal_connect(GTK_OBJECT(window), "delete_event",
3473                            GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
3474         gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
3475                            GTK_SIGNAL_FUNC(prefs_quote_colors_key_pressed),
3476                            NULL);
3477
3478         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level1_btn), "clicked",
3479                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL1");
3480         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level2_btn), "clicked",
3481                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL2");
3482         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level3_btn), "clicked",
3483                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL3");
3484         gtk_signal_connect(GTK_OBJECT(color_buttons.uri_btn), "clicked",
3485                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "URI");
3486         gtk_signal_connect(GTK_OBJECT(color_buttons.tgt_folder_btn), "clicked",
3487                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "TGTFLD");
3488         gtk_signal_connect(GTK_OBJECT(color_buttons.signature_btn), "clicked",
3489                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "SIGNATURE");
3490         gtk_signal_connect(GTK_OBJECT(recycle_colors_btn), "toggled",
3491