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