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