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