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