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