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