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