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