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