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