* src/summaryview.c
[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_noerrorpanel;
82         GtkWidget *checkbtn_scan_after_inc;
83
84
85         GtkWidget *checkbtn_newmail_auto;
86         GtkWidget *checkbtn_newmail_manu;
87         GtkWidget *entry_newmail_notify_cmd;
88         GtkWidget *hbox_newmail_notify;
89
90         GtkWidget *spinbtn_maxarticle;
91         GtkObject *spinbtn_maxarticle_adj;
92 } receive;
93
94 static struct Send {
95         GtkWidget *checkbtn_extsend;
96         GtkWidget *entry_extsend;
97         GtkWidget *button_extsend;
98
99         GtkWidget *checkbtn_savemsg;
100         GtkWidget *checkbtn_queuemsg;
101
102         GtkWidget *optmenu_charset;
103         
104         GtkWidget *checkbtn_returnreceipt;
105 } send;
106
107 static struct Compose {
108         GtkWidget *checkbtn_autosig;
109         GtkWidget *entry_sigsep;
110
111         GtkWidget *entry_fw_quotemark;
112         GtkWidget *text_fw_quotefmt;
113
114         GtkWidget *checkbtn_autoextedit;
115         GtkWidget *spinbtn_undolevel;
116         GtkObject *spinbtn_undolevel_adj;
117         GtkWidget *spinbtn_linewrap;
118         GtkObject *spinbtn_linewrap_adj;
119         GtkWidget *checkbtn_wrapquote;
120         GtkWidget *checkbtn_autowrap;
121         GtkWidget *checkbtn_wrapatsend;
122
123         GtkWidget *checkbtn_reply_account_autosel;
124         GtkWidget *checkbtn_forward_account_autosel;
125         GtkWidget *checkbtn_reedit_account_autosel;
126         GtkWidget *checkbtn_quote;
127         GtkWidget *checkbtn_forward_as_attachment;
128         GtkWidget *checkbtn_redirect_keep_from;
129         GtkWidget *checkbtn_smart_wrapping;
130         GtkWidget *checkbtn_block_cursor;
131         GtkWidget *checkbtn_reply_with_quote;
132 } compose;
133
134         /* spelling */
135 #if USE_PSPELL
136 static struct Spelling {
137         GtkWidget *checkbtn_enable_pspell;
138         GtkWidget *entry_pspell_path;
139         GtkWidget *btn_pspell_path;
140         GtkWidget *optmenu_dictionary;
141         GtkWidget *optmenu_sugmode;
142         GtkWidget *misspelled_btn;
143         GtkWidget *checkbtn_use_alternate;
144         GtkWidget *checkbtn_check_while_typing;
145 } spelling;
146 #endif
147
148 static struct Quote {
149         GtkWidget *entry_quotemark;
150         GtkWidget *text_quotefmt;
151
152         GtkWidget *entry_fw_quotemark;
153         GtkWidget *text_fw_quotefmt;
154         
155         GtkWidget *entry_quote_chars;
156 } quote;
157
158 static struct Display {
159         GtkWidget *entry_textfont;
160         GtkWidget *button_textfont;
161
162         GtkWidget *entry_smallfont;
163         GtkWidget *entry_normalfont;
164         GtkWidget *entry_boldfont;
165
166         GtkWidget *chkbtn_folder_unread;
167         GtkWidget *chkbtn_display_img;
168         GtkWidget *entry_ng_abbrev_len;
169         GtkWidget *spinbtn_ng_abbrev_len;
170         GtkObject *spinbtn_ng_abbrev_len_adj;
171
172         GtkWidget *chkbtn_transhdr;
173
174         GtkWidget *chkbtn_swapfrom;
175         GtkWidget *chkbtn_hscrollbar;
176         GtkWidget *chkbtn_useaddrbook;
177         GtkWidget *chkbtn_expand_thread;
178         GtkWidget *chkbtn_bold_unread;
179         GtkWidget *entry_datefmt;
180 } display;
181
182 static struct Message {
183         GtkWidget *chkbtn_enablecol;
184         GtkWidget *button_edit_col;
185         GtkWidget *chkbtn_mbalnum;
186         GtkWidget *chkbtn_disphdrpane;
187         GtkWidget *chkbtn_disphdr;
188         GtkWidget *spinbtn_linespc;
189         GtkObject *spinbtn_linespc_adj;
190         GtkWidget *chkbtn_headspc;
191
192         GtkWidget *chkbtn_smoothscroll;
193         GtkWidget *spinbtn_scrollstep;
194         GtkObject *spinbtn_scrollstep_adj;
195         GtkWidget *chkbtn_halfpage;
196 } message;
197
198 #if USE_GPGME
199 static struct Privacy {
200         GtkWidget *checkbtn_auto_check_signatures;
201         GtkWidget *checkbtn_gpg_signature_popup;
202         GtkWidget *checkbtn_store_passphrase;
203         GtkWidget *spinbtn_store_passphrase;
204         GtkObject *spinbtn_store_passphrase_adj;
205         GtkWidget *checkbtn_passphrase_grab;
206         GtkWidget *checkbtn_gpg_warning;
207         GtkWidget *optmenu_default_signkey;
208 } privacy;
209 #endif
210
211 static struct Interface {
212         /* GtkWidget *checkbtn_emacs; */
213         GtkWidget *checkbtn_show_msg_with_cursor;
214         GtkWidget *checkbtn_openunread;
215         GtkWidget *checkbtn_openinbox;
216         GtkWidget *checkbtn_immedexec;
217         GtkWidget *checkbtn_addaddrbyclick;
218         GtkWidget *optmenu_recvdialog;
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         {"noerrorpanel", "FALSE", &prefs_common.noerrorpanel, P_BOOL,
315          &receive.checkbtn_noerrorpanel,
316          prefs_set_data_from_toggle, prefs_set_toggle},
317         {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
318          P_BOOL, &receive.checkbtn_scan_after_inc,
319          prefs_set_data_from_toggle, prefs_set_toggle},
320         {"newmail_notify_manu", "FALSE", &prefs_common.newmail_notify_manu,
321          P_BOOL, &receive.checkbtn_newmail_manu,
322          prefs_set_data_from_toggle, prefs_set_toggle},
323         {"newmail_notify_auto", "FALSE", &prefs_common.newmail_notify_auto,
324         P_BOOL, &receive.checkbtn_newmail_auto,
325          prefs_set_data_from_toggle, prefs_set_toggle},
326         {"newmail_notify_cmd", "", &prefs_common.newmail_notify_cmd, P_STRING,
327          &receive.entry_newmail_notify_cmd,
328          prefs_set_data_from_entry, prefs_set_entry},
329  
330         {"max_news_articles", "300", &prefs_common.max_articles, P_INT,
331          &receive.spinbtn_maxarticle,
332          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
333
334         /* Send */
335         {"use_ext_sendmail", "FALSE", &prefs_common.use_extsend, P_BOOL,
336          &send.checkbtn_extsend,
337          prefs_set_data_from_toggle, prefs_set_toggle},
338         {"ext_sendmail_cmd", DEFAULT_SENDMAIL_CMD,
339          &prefs_common.extsend_cmd, P_STRING,
340          &send.entry_extsend, prefs_set_data_from_entry, prefs_set_entry},
341         {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL,
342          &send.checkbtn_savemsg,
343          prefs_set_data_from_toggle, prefs_set_toggle},
344         {"queue_message", "FALSE", &prefs_common.queue_msg, P_BOOL,
345          &send.checkbtn_queuemsg,
346          prefs_set_data_from_toggle, prefs_set_toggle},
347
348         {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
349          &send.optmenu_charset,
350          prefs_common_charset_set_data_from_optmenu,
351          prefs_common_charset_set_optmenu},
352
353         /* Compose */
354         {"auto_signature", "TRUE", &prefs_common.auto_sig, P_BOOL,
355          &compose.checkbtn_autosig,
356          prefs_set_data_from_toggle, prefs_set_toggle},
357         {"signature_separator", "-- ", &prefs_common.sig_sep, P_STRING,
358          &compose.entry_sigsep, prefs_set_data_from_entry, prefs_set_entry},
359
360         {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL,
361          &compose.checkbtn_autoextedit,
362          prefs_set_data_from_toggle, prefs_set_toggle},
363         {"forward_as_attachment", "FALSE", &prefs_common.forward_as_attachment,
364          P_BOOL, &compose.checkbtn_forward_as_attachment,
365          prefs_set_data_from_toggle, prefs_set_toggle},
366         {"redirect_keep_from", "FALSE",
367          &prefs_common.redirect_keep_from, P_BOOL,
368          &compose.checkbtn_redirect_keep_from,
369          prefs_set_data_from_toggle, prefs_set_toggle},
370         {"undo_level", "50", &prefs_common.undolevels, P_INT,
371          &compose.spinbtn_undolevel,
372          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
373         {"block_cursor", "FALSE", &prefs_common.block_cursor,
374          P_BOOL, &compose.checkbtn_block_cursor,
375          prefs_set_data_from_toggle, prefs_set_toggle},
376
377         {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT,
378          &compose.spinbtn_linewrap,
379          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
380         {"linewrap_quotation", "FALSE", &prefs_common.linewrap_quote, P_BOOL,
381          &compose.checkbtn_wrapquote,
382          prefs_set_data_from_toggle, prefs_set_toggle},
383         {"linewrap_auto", "FALSE", &prefs_common.autowrap, P_BOOL,
384          &compose.checkbtn_autowrap,
385          prefs_set_data_from_toggle, prefs_set_toggle},
386         {"linewrap_before_sending", "FALSE",
387          &prefs_common.linewrap_at_send, P_BOOL,
388          &compose.checkbtn_wrapatsend,
389          prefs_set_data_from_toggle, prefs_set_toggle},
390         {"smart_wrapping", "TRUE", &prefs_common.smart_wrapping,
391          P_BOOL, &compose.checkbtn_smart_wrapping,
392          prefs_set_data_from_toggle, prefs_set_toggle},
393 #if USE_PSPELL
394         {"enable_pspell", "TRUE", &prefs_common.enable_pspell,
395          P_BOOL, &spelling.checkbtn_enable_pspell,
396          prefs_set_data_from_toggle, prefs_set_toggle},
397         {"pspell_path", PSPELL_PATH, &prefs_common.pspell_path, 
398          P_STRING, &spelling.entry_pspell_path, 
399          prefs_set_data_from_entry, prefs_set_entry},
400         {"dictionary",  "", &prefs_common.dictionary,
401          P_STRING, &spelling.optmenu_dictionary, 
402          prefs_dictionary_set_data_from_optmenu, prefs_dictionary_set_optmenu },
403         {"pspell_sugmode",  "1", &prefs_common.pspell_sugmode,
404          P_INT, &spelling.optmenu_sugmode, 
405          prefs_speller_sugmode_set_data_from_optmenu, prefs_speller_sugmode_set_optmenu },
406         {"use_alternate_dict", "FALSE", &prefs_common.use_alternate,
407          P_BOOL, &spelling.checkbtn_use_alternate,
408          prefs_set_data_from_toggle, prefs_set_toggle},
409         {"check_while_typing", "TRUE", &prefs_common.check_while_typing,
410          P_BOOL, &spelling.checkbtn_check_while_typing,
411          prefs_set_data_from_toggle, prefs_set_toggle},
412         {"misspelled_color", "16711680", &prefs_common.misspelled_col, P_INT,
413          NULL, NULL, NULL},
414 #endif
415         {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
416          &compose.checkbtn_reply_with_quote, prefs_set_data_from_toggle, prefs_set_toggle},
417
418         /* Account autoselection */
419         {"reply_account_autoselect", "TRUE",
420          &prefs_common.reply_account_autosel, P_BOOL,
421          &compose.checkbtn_reply_account_autosel,
422          prefs_set_data_from_toggle, prefs_set_toggle},
423         {"forward_account_autoselect", "TRUE",
424          &prefs_common.forward_account_autosel, P_BOOL,
425          &compose.checkbtn_forward_account_autosel,
426          prefs_set_data_from_toggle, prefs_set_toggle},
427         {"reedit_account_autoselect", "TRUE",
428          &prefs_common.reedit_account_autosel, P_BOOL,
429          &compose.checkbtn_reedit_account_autosel,
430          prefs_set_data_from_toggle, prefs_set_toggle},
431
432         {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
433          NULL, NULL, NULL},
434
435         /* Quote */
436         {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
437          &quote.entry_quotemark, prefs_set_data_from_entry, prefs_set_entry},
438         {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q",
439          &prefs_common.quotefmt, P_STRING, &quote.text_quotefmt,
440          prefs_set_data_from_text, prefs_set_text},
441
442         {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING,
443          &quote.entry_fw_quotemark,
444          prefs_set_data_from_entry, prefs_set_entry},
445         {"forward_quote_format",
446          "\\n\\nBegin forwarded message:\\n\\n"
447          "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
448          "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M",
449          &prefs_common.fw_quotefmt, P_STRING, &quote.text_fw_quotefmt,
450          prefs_set_data_from_text, prefs_set_text},
451         {"quote_chars", ">", &prefs_common.quote_chars, P_STRING,
452          &quote.entry_quote_chars, prefs_set_data_from_entry, prefs_set_entry},
453
454         /* Display */
455         {"widget_font", NULL, &prefs_common.widgetfont, P_STRING,
456          NULL, NULL, NULL},
457         {"message_font", "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*",
458          &prefs_common.textfont, P_STRING,
459          &display.entry_textfont,
460          prefs_set_data_from_entry, prefs_set_entry},
461         {"small_font",   "-*-helvetica-medium-r-normal--10-*-*-*-*-*-*-*",
462          &prefs_common.smallfont,   P_STRING,
463          &display.entry_smallfont,
464          prefs_set_data_from_entry, prefs_set_entry},
465         {"bold_font",    "-*-helvetica-bold-r-normal--12-*-*-*-*-*-*-*",
466          &prefs_common.boldfont,    P_STRING,
467          &display.entry_boldfont,
468          prefs_set_data_from_entry, prefs_set_entry},
469         {"normal_font",  "-*-helvetica-medium-r-normal--12-*-*-*-*-*-*-*",
470          &prefs_common.normalfont,  P_STRING,
471          &display.entry_normalfont, 
472          prefs_set_data_from_entry, prefs_set_entry},
473
474
475         {"display_folder_unread_num", "TRUE",
476          &prefs_common.display_folder_unread, P_BOOL,
477          &display.chkbtn_folder_unread,
478          prefs_set_data_from_toggle, prefs_set_toggle},
479
480         {"display_img", "TRUE",
481          &prefs_common.display_img, P_BOOL,
482          &display.chkbtn_display_img,
483          prefs_set_data_from_toggle, prefs_set_toggle},
484         {"newsgroup_abbrev_len", "16",
485          &prefs_common.ng_abbrev_len, P_INT,
486          &display.spinbtn_ng_abbrev_len,
487          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
488
489         {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL,
490          &display.chkbtn_transhdr,
491          prefs_set_data_from_toggle, prefs_set_toggle},
492
493         /* Display: Summary View */
494         {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
495          &display.chkbtn_swapfrom,
496          prefs_set_data_from_toggle, prefs_set_toggle},
497         {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
498          &display.chkbtn_hscrollbar,
499          prefs_set_data_from_toggle, prefs_set_toggle},
500         {"use_address_book", "TRUE", &prefs_common.use_addr_book, P_BOOL,
501          &display.chkbtn_useaddrbook,
502          prefs_set_data_from_toggle, prefs_set_toggle},
503         {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
504          P_STRING, &display.entry_datefmt,
505          prefs_set_data_from_entry, prefs_set_entry},
506         {"expand_thread", "TRUE", &prefs_common.expand_thread, P_BOOL,
507          &display.chkbtn_expand_thread,
508          prefs_set_data_from_toggle, prefs_set_toggle},
509         {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL,
510          &display.chkbtn_bold_unread,
511          prefs_set_data_from_toggle, prefs_set_toggle},
512
513         {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL,
514          NULL, NULL, NULL},
515         {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM,
516          NULL, NULL, NULL},
517         {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
518          NULL, NULL, NULL},
519
520         {"folderview_vscrollbar_policy", "0",
521          &prefs_common.folderview_vscrollbar_policy, P_ENUM,
522          NULL, NULL, NULL},
523
524         {"summary_col_show_mark", "TRUE",
525          &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL, NULL, NULL, NULL},
526         {"summary_col_show_unread", "TRUE",
527          &prefs_common.summary_col_visible[S_COL_UNREAD], P_BOOL, NULL, NULL, NULL},
528         {"summary_col_show_mime", "TRUE",
529          &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
530         {"summary_col_show_subject", "TRUE",
531          &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL, NULL, NULL, NULL},
532         {"summary_col_show_from", "TRUE",
533          &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL, NULL, NULL, NULL},
534         {"summary_col_show_date", "TRUE",
535          &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL, NULL, NULL, NULL},
536         {"summary_col_show_size", "TRUE",
537          &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL, NULL, NULL, NULL},
538         {"summary_col_show_number", "FALSE",
539          &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL, NULL, NULL, NULL},
540         {"summary_col_show_score", "FALSE",
541          &prefs_common.summary_col_visible[S_COL_SCORE], P_BOOL, NULL, NULL, NULL},
542         {"summary_col_show_locked", "FALSE",
543          &prefs_common.summary_col_visible[S_COL_LOCKED], P_BOOL, NULL, NULL, NULL},
544
545         {"summary_col_pos_mark", "0",
546           &prefs_common.summary_col_pos[S_COL_MARK], P_INT, NULL, NULL, NULL},
547         {"summary_col_pos_unread", "1",
548           &prefs_common.summary_col_pos[S_COL_UNREAD], P_INT, NULL, NULL, NULL},
549         {"summary_col_pos_mime", "2",
550           &prefs_common.summary_col_pos[S_COL_MIME], P_INT, NULL, NULL, NULL},
551         {"summary_col_pos_subject", "3",
552           &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
553         {"summary_col_pos_from", "4",
554           &prefs_common.summary_col_pos[S_COL_FROM], P_INT, NULL, NULL, NULL},
555         {"summary_col_pos_date", "5",
556           &prefs_common.summary_col_pos[S_COL_DATE], P_INT, NULL, NULL, NULL},
557         {"summary_col_pos_size", "6",
558           &prefs_common.summary_col_pos[S_COL_SIZE], P_INT, NULL, NULL, NULL},
559         {"summary_col_pos_number", "7",
560           &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
561         {"summary_col_pos_score", "8",
562          &prefs_common.summary_col_pos[S_COL_SCORE], P_INT, NULL, NULL, NULL},
563         {"summary_col_pos_locked", "9",
564          &prefs_common.summary_col_pos[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
565
566         {"summary_col_size_mark", "10",
567          &prefs_common.summary_col_size[S_COL_MARK], P_INT, NULL, NULL, NULL},
568         {"summary_col_size_unread", "13",
569          &prefs_common.summary_col_size[S_COL_UNREAD], P_INT, NULL, NULL, NULL},
570         {"summary_col_size_mime", "10",
571          &prefs_common.summary_col_size[S_COL_MIME], P_INT, NULL, NULL, NULL},
572         {"summary_col_size_subject", "200",
573          &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
574         {"summary_col_size_from", "120",
575          &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
576         {"summary_col_size_date", "118",
577          &prefs_common.summary_col_size[S_COL_DATE], P_INT, NULL, NULL, NULL},
578         {"summary_col_size_size", "45",
579          &prefs_common.summary_col_size[S_COL_SIZE], P_INT, NULL, NULL, NULL},
580         {"summary_col_size_number", "40",
581          &prefs_common.summary_col_size[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
582         {"summary_col_size_score", "40",
583          &prefs_common.summary_col_size[S_COL_SCORE], P_INT, NULL, NULL, NULL},
584         {"summary_col_size_locked", "13",
585          &prefs_common.summary_col_size[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
586
587         /* Widget size */
588         {"folderview_width", "179", &prefs_common.folderview_width, P_INT,
589          NULL, NULL, NULL},
590         {"folderview_height", "600", &prefs_common.folderview_height, P_INT,
591          NULL, NULL, NULL},
592         {"folder_col_folder", "150", &prefs_common.folder_col_folder, P_INT,
593          NULL, NULL, NULL},
594         {"folder_col_new", "32", &prefs_common.folder_col_new, P_INT,
595          NULL, NULL, NULL},
596         {"folder_col_unread", "32", &prefs_common.folder_col_unread, P_INT,
597          NULL, NULL, NULL},
598         {"folder_col_total", "32", &prefs_common.folder_col_total, P_INT,
599          NULL, NULL, NULL},
600
601         {"summaryview_width", "600", &prefs_common.summaryview_width, P_INT,
602          NULL, NULL, NULL},
603         {"summaryview_height", "173", &prefs_common.summaryview_height, P_INT,
604          NULL, NULL, NULL},
605
606         {"mainview_x", "64", &prefs_common.mainview_x, P_INT,
607          NULL, NULL, NULL},
608         {"mainview_y", "64", &prefs_common.mainview_y, P_INT,
609          NULL, NULL, NULL},
610         {"mainview_width", "600", &prefs_common.mainview_width, P_INT,
611          NULL, NULL, NULL},
612         {"mainview_height", "600", &prefs_common.mainview_height, P_INT,
613          NULL, NULL, NULL},
614         {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT,
615          NULL, NULL, NULL},
616         {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT,
617          NULL, NULL, NULL},
618         {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT,
619          NULL, NULL, NULL},
620         {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT,
621          NULL, NULL, NULL},
622         {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT,
623          NULL, NULL, NULL},
624         {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT,
625          NULL, NULL, NULL},
626         {"compose_width", "600", &prefs_common.compose_width, P_INT,
627          NULL, NULL, NULL},
628         {"compose_height", "560", &prefs_common.compose_height, P_INT,
629          NULL, NULL, NULL},
630
631         /* Message */
632         {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
633          &message.chkbtn_enablecol,
634          prefs_set_data_from_toggle, prefs_set_toggle},
635
636         {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_INT,
637          NULL, NULL, NULL},
638         {"quote_level2_color", "179", &prefs_common.quote_level2_col, P_INT,
639          NULL, NULL, NULL},
640         {"quote_level3_color", "179", &prefs_common.quote_level3_col, P_INT,
641          NULL, NULL, NULL},
642         {"uri_color", "32512", &prefs_common.uri_col, P_INT,
643          NULL, NULL, NULL},
644         {"target_folder_color", "14294218", &prefs_common.tgt_folder_col, P_INT,
645          NULL, NULL, NULL},
646         {"signature_color", "0", &prefs_common.sig_col, P_USHORT,
647          NULL, NULL, NULL},
648         {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
649          P_BOOL, NULL, NULL, NULL},
650
651         {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL,
652          &message.chkbtn_mbalnum,
653          prefs_set_data_from_toggle, prefs_set_toggle},
654         {"display_header_pane", "TRUE", &prefs_common.display_header_pane,
655          P_BOOL, &message.chkbtn_disphdrpane,
656          prefs_set_data_from_toggle, prefs_set_toggle},
657         {"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
658          &message.chkbtn_disphdr,
659          prefs_set_data_from_toggle, prefs_set_toggle},
660         {"line_space", "2", &prefs_common.line_space, P_INT,
661          &message.spinbtn_linespc,
662          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
663         {"enable_head_space", "FALSE", &prefs_common.head_space, P_BOOL,
664          &message.chkbtn_headspc,
665          prefs_set_data_from_toggle, prefs_set_toggle},
666
667         {"enable_smooth_scroll", "FALSE",
668          &prefs_common.enable_smooth_scroll, P_BOOL,
669          &message.chkbtn_smoothscroll,
670          prefs_set_data_from_toggle, prefs_set_toggle},
671         {"scroll_step", "1", &prefs_common.scroll_step, P_INT,
672          &message.spinbtn_scrollstep,
673          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
674         {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL,
675          &message.chkbtn_halfpage,
676          prefs_set_data_from_toggle, prefs_set_toggle},
677
678         {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
679          NULL, NULL, NULL},
680
681         /* MIME viewer */
682         {"mime_image_viewer", "display '%s'",
683          &prefs_common.mime_image_viewer, P_STRING, NULL, NULL, NULL},
684         {"mime_audio_player", "play '%s'",
685          &prefs_common.mime_audio_player, P_STRING, NULL, NULL, NULL},
686         {"mime_open_command", "gedit '%s'",
687          &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL},
688
689 #if USE_GPGME
690         /* Privacy */
691         {"auto_check_signatures", "TRUE",
692          &prefs_common.auto_check_signatures, P_BOOL,
693          &privacy.checkbtn_auto_check_signatures,
694          prefs_set_data_from_toggle, prefs_set_toggle},
695         {"gpg_signature_popup", "FALSE",
696          &prefs_common.gpg_signature_popup, P_BOOL,
697          &privacy.checkbtn_gpg_signature_popup,
698          prefs_set_data_from_toggle, prefs_set_toggle},
699         {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL,
700          &privacy.checkbtn_store_passphrase,
701          prefs_set_data_from_toggle, prefs_set_toggle},
702         {"store_passphrase_timeout", "0", &prefs_common.store_passphrase_timeout,
703          P_INT, &privacy.spinbtn_store_passphrase, 
704          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
705 #ifndef __MINGW32__
706         {"passphrase_grab", "FALSE", &prefs_common.passphrase_grab, P_BOOL,
707          &privacy.checkbtn_passphrase_grab,
708          prefs_set_data_from_toggle, prefs_set_toggle},
709 #endif /* __MINGW32__ */
710         {"gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL,
711          &privacy.checkbtn_gpg_warning,
712          prefs_set_data_from_toggle, prefs_set_toggle},
713         {"default_signkey", CS_AUTO, &prefs_common.default_signkey, P_STRING,
714          &privacy.optmenu_default_signkey,
715          prefs_common_default_signkey_set_data_from_optmenu,
716          prefs_common_default_signkey_set_optmenu},
717 #endif /* USE_GPGME */
718
719         /* Interface */
720         {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL,
721          NULL, NULL, NULL},
722         {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL,
723          NULL, NULL, NULL},
724
725         /* {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
726          NULL, NULL, NULL}, */
727         {"show_message_with_cursor_key", "FALSE",
728          &prefs_common.show_msg_with_cursor_key,
729          P_BOOL, &interface.checkbtn_show_msg_with_cursor,
730          prefs_set_data_from_toggle, prefs_set_toggle},
731         {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter,
732          P_BOOL, &interface.checkbtn_openunread,
733          prefs_set_data_from_toggle, prefs_set_toggle},
734         {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc,
735          P_BOOL, &interface.checkbtn_openinbox,
736          prefs_set_data_from_toggle, prefs_set_toggle},
737         {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL,
738          &interface.checkbtn_immedexec,
739          prefs_set_data_from_toggle, prefs_set_toggle},
740         {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM,
741          &interface.optmenu_recvdialog,
742          prefs_common_recv_dialog_set_data_from_optmenu,
743          prefs_common_recv_dialog_set_optmenu},
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_noerrorpanel;
1040         GtkWidget *checkbtn_scan_after_inc;
1041
1042
1043         GtkWidget *frame_newmail;
1044         GtkWidget *hbox_newmail_notify;
1045         GtkWidget *checkbtn_newmail_auto;
1046         GtkWidget *checkbtn_newmail_manu;
1047         GtkWidget *entry_newmail_notify_cmd;
1048         GtkWidget *label_newmail_notify_cmd;
1049
1050         GtkWidget *frame_news;
1051         GtkWidget *label_maxarticle;
1052         GtkWidget *spinbtn_maxarticle;
1053         GtkObject *spinbtn_maxarticle_adj;
1054
1055         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1056         gtk_widget_show (vbox1);
1057         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1058         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1059
1060         PACK_FRAME(vbox1, frame_incext, _("External program"));
1061
1062         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1063         gtk_widget_show (vbox2);
1064         gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
1065         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1066
1067         /* Use of external incorporation program */
1068         PACK_CHECK_BUTTON (vbox2, checkbtn_incext,
1069                            _("Use external program for incorporation"));
1070
1071         hbox = gtk_hbox_new (FALSE, 8);
1072         gtk_widget_show (hbox);
1073         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1074         SET_TOGGLE_SENSITIVITY (checkbtn_incext, hbox);
1075
1076         label_incext = gtk_label_new (_("Command"));
1077         gtk_widget_show (label_incext);
1078         gtk_box_pack_start (GTK_BOX (hbox), label_incext, FALSE, FALSE, 0);
1079
1080         entry_incext = gtk_entry_new ();
1081         gtk_widget_show (entry_incext);
1082         gtk_box_pack_start (GTK_BOX (hbox), entry_incext, TRUE, TRUE, 0);
1083
1084 #if 0
1085         button_incext = gtk_button_new_with_label ("... ");
1086         gtk_widget_show (button_incext);
1087         gtk_box_pack_start (GTK_BOX (hbox), button_incext, FALSE, FALSE, 0);
1088 #endif
1089
1090         PACK_FRAME(vbox1, frame_spool, _("Local spool"));
1091
1092         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1093         gtk_widget_show (vbox2);
1094         gtk_container_add (GTK_CONTAINER (frame_spool), vbox2);
1095         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1096
1097         hbox = gtk_hbox_new (FALSE, 32);
1098         gtk_widget_show (hbox);
1099         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1100
1101         PACK_CHECK_BUTTON (hbox, checkbtn_local, _("Incorporate from spool"));
1102         PACK_CHECK_BUTTON (hbox, checkbtn_filter_on_inc,
1103                            _("Filter on incorporation"));
1104         SET_TOGGLE_SENSITIVITY (checkbtn_local, checkbtn_filter_on_inc);
1105
1106         hbox = gtk_hbox_new (FALSE, 8);
1107         gtk_widget_show (hbox);
1108         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1109         SET_TOGGLE_SENSITIVITY (checkbtn_local, hbox);
1110
1111         label_spool = gtk_label_new (_("Spool directory"));
1112         gtk_widget_show (label_spool);
1113         gtk_box_pack_start (GTK_BOX (hbox), label_spool, FALSE, FALSE, 0);
1114
1115         entry_spool = gtk_entry_new ();
1116         gtk_widget_show (entry_spool);
1117         gtk_box_pack_start (GTK_BOX (hbox), entry_spool, TRUE, TRUE, 0);
1118
1119         vbox2 = gtk_vbox_new (FALSE, 0);
1120         gtk_widget_show (vbox2);
1121         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1122
1123         /* Auto-checking */
1124         hbox_autochk = gtk_hbox_new (FALSE, 8);
1125         gtk_widget_show (hbox_autochk);
1126         gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
1127
1128         PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
1129                            _("Auto-check new mail"));
1130
1131         label_autochk1 = gtk_label_new (_("every"));
1132         gtk_widget_show (label_autochk1);
1133         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
1134
1135         spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
1136         spinbtn_autochk = gtk_spin_button_new
1137                 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
1138         gtk_widget_show (spinbtn_autochk);
1139         gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
1140         gtk_widget_set_usize (spinbtn_autochk, 64, -1);
1141         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
1142
1143         label_autochk2 = gtk_label_new (_("minute(s)"));
1144         gtk_widget_show (label_autochk2);
1145         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
1146
1147         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
1148         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
1149         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
1150
1151         PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
1152                            _("Check new mail on startup"));
1153
1154         PACK_CHECK_BUTTON (vbox2, checkbtn_noerrorpanel,
1155                            _("No error popup on receive error"));
1156         PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
1157                            _("Update all local folders after incorporation"));
1158
1159         
1160         PACK_FRAME(vbox1, frame_newmail, _("Run command when new mail "
1161                                            "arrives"));
1162         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1163         gtk_widget_show (vbox2);
1164         gtk_container_add (GTK_CONTAINER (frame_newmail), vbox2);
1165         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1166
1167         hbox = gtk_hbox_new (TRUE, 8);
1168         gtk_widget_show (hbox);
1169         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_auto,
1170                            _("after autochecking"));
1171         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_manu,
1172                            _("after manual checking"));
1173         gtk_box_pack_start (GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
1174         gtk_signal_connect(GTK_OBJECT(checkbtn_newmail_auto), "toggled",
1175                            GTK_SIGNAL_FUNC(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1176                            NULL);
1177         gtk_signal_connect(GTK_OBJECT(checkbtn_newmail_manu), "toggled",
1178                            GTK_SIGNAL_FUNC(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1179                            NULL);
1180
1181         hbox_newmail_notify = gtk_hbox_new (FALSE, 8);
1182         gtk_widget_show (hbox);
1183         gtk_box_pack_start (GTK_BOX (vbox2), hbox_newmail_notify, FALSE, 
1184                             FALSE, 0);
1185
1186         label_newmail_notify_cmd = gtk_label_new (_("Command  to execute:\n"
1187                                                     "(use %d as number of new "
1188                                                     "mails)"));
1189         gtk_label_set_justify(GTK_LABEL(label_newmail_notify_cmd), 
1190                               GTK_JUSTIFY_RIGHT);
1191         gtk_widget_show (label_newmail_notify_cmd);
1192         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1193                             label_newmail_notify_cmd, FALSE, FALSE, 0);
1194
1195         entry_newmail_notify_cmd = gtk_entry_new ();
1196         gtk_widget_show (entry_newmail_notify_cmd);
1197         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1198                             entry_newmail_notify_cmd, TRUE, TRUE, 0);
1199
1200         gtk_widget_set_sensitive(hbox_newmail_notify, 
1201                                  prefs_common.newmail_notify_auto || 
1202                                  prefs_common.newmail_notify_manu);
1203
1204         PACK_FRAME(vbox1, frame_news, _("News"));
1205
1206         hbox = gtk_hbox_new (FALSE, 8);
1207         gtk_widget_show (hbox);
1208         gtk_container_add (GTK_CONTAINER (frame_news), hbox);
1209         gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
1210
1211         label_maxarticle = gtk_label_new
1212                 (_("Maximum number of articles to download\n"
1213                    "(unlimited if 0 is specified)"));
1214         gtk_widget_show (label_maxarticle);
1215         gtk_box_pack_start (GTK_BOX (hbox), label_maxarticle, FALSE, FALSE, 0);
1216         gtk_label_set_justify (GTK_LABEL (label_maxarticle), GTK_JUSTIFY_LEFT);
1217
1218         spinbtn_maxarticle_adj =
1219                 gtk_adjustment_new (300, 0, 10000, 10, 100, 100);
1220         spinbtn_maxarticle = gtk_spin_button_new
1221                 (GTK_ADJUSTMENT (spinbtn_maxarticle_adj), 10, 0);
1222         gtk_widget_show (spinbtn_maxarticle);
1223         gtk_box_pack_start (GTK_BOX (hbox), spinbtn_maxarticle,
1224                             FALSE, FALSE, 0);
1225         gtk_widget_set_usize (spinbtn_maxarticle, 64, -1);
1226         gtk_spin_button_set_numeric
1227                 (GTK_SPIN_BUTTON (spinbtn_maxarticle), TRUE);
1228
1229         receive.checkbtn_incext = checkbtn_incext;
1230         receive.entry_incext    = entry_incext;
1231         /* receive.button_incext   = button_incext; */
1232
1233         receive.checkbtn_local         = checkbtn_local;
1234         receive.checkbtn_filter_on_inc = checkbtn_filter_on_inc;
1235         receive.entry_spool            = entry_spool;
1236
1237         receive.checkbtn_autochk    = checkbtn_autochk;
1238         receive.spinbtn_autochk     = spinbtn_autochk;
1239         receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1240
1241         receive.checkbtn_chkonstartup = checkbtn_chkonstartup;
1242         receive.checkbtn_noerrorpanel = checkbtn_noerrorpanel;
1243         receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1244
1245
1246         receive.checkbtn_newmail_auto  = checkbtn_newmail_auto;
1247         receive.checkbtn_newmail_manu  = checkbtn_newmail_manu;
1248         receive.hbox_newmail_notify    = hbox_newmail_notify;
1249         receive.entry_newmail_notify_cmd = entry_newmail_notify_cmd;
1250
1251         receive.spinbtn_maxarticle     = spinbtn_maxarticle;
1252         receive.spinbtn_maxarticle_adj = spinbtn_maxarticle_adj;
1253 }
1254
1255 static void prefs_send_create(void)
1256 {
1257         GtkWidget *vbox1;
1258         GtkWidget *vbox2;
1259         GtkWidget *frame_extsend;
1260         GtkWidget *vbox_extsend;
1261         GtkWidget *checkbtn_extsend;
1262         GtkWidget *hbox1;
1263         GtkWidget *label_extsend;
1264         GtkWidget *entry_extsend;
1265         /* GtkWidget *button_extsend; */
1266         GtkWidget *checkbtn_savemsg;
1267         GtkWidget *checkbtn_queuemsg;
1268         GtkWidget *label_outcharset;
1269         GtkWidget *optmenu;
1270         GtkWidget *optmenu_menu;
1271         GtkWidget *menuitem;
1272         GtkWidget *checkbtn_returnreceipt;
1273         GtkWidget *label_charset_desc;
1274
1275         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1276         gtk_widget_show (vbox1);
1277         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1278         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1279
1280         PACK_FRAME(vbox1, frame_extsend, _("External program"));
1281
1282         vbox_extsend = gtk_vbox_new (FALSE, VSPACING_NARROW);
1283         gtk_widget_show (vbox_extsend);
1284         gtk_container_add (GTK_CONTAINER (frame_extsend), vbox_extsend);
1285         gtk_container_set_border_width (GTK_CONTAINER (vbox_extsend), 8);
1286
1287         PACK_CHECK_BUTTON (vbox_extsend, checkbtn_extsend,
1288                            _("Use external program for sending"));
1289
1290         hbox1 = gtk_hbox_new (FALSE, 8);
1291         gtk_widget_show (hbox1);
1292         gtk_box_pack_start (GTK_BOX (vbox_extsend), hbox1, FALSE, FALSE, 0);
1293         SET_TOGGLE_SENSITIVITY(checkbtn_extsend, hbox1);
1294
1295         label_extsend = gtk_label_new (_("Command"));
1296         gtk_widget_show (label_extsend);
1297         gtk_box_pack_start (GTK_BOX (hbox1), label_extsend, FALSE, FALSE, 0);
1298
1299         entry_extsend = gtk_entry_new ();
1300         gtk_widget_show (entry_extsend);
1301         gtk_box_pack_start (GTK_BOX (hbox1), entry_extsend, TRUE, TRUE, 0);
1302
1303 #if 0
1304         button_extsend = gtk_button_new_with_label ("... ");
1305         gtk_widget_show (button_extsend);
1306         gtk_box_pack_start (GTK_BOX (hbox1), button_extsend, FALSE, FALSE, 0);
1307 #endif
1308
1309         vbox2 = gtk_vbox_new (FALSE, 0);
1310         gtk_widget_show (vbox2);
1311         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1312
1313         PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1314                            _("Save sent messages to Sent"));
1315         PACK_CHECK_BUTTON (vbox2, checkbtn_queuemsg,
1316                            _("Queue messages that fail to send"));
1317         PACK_CHECK_BUTTON (vbox2, checkbtn_returnreceipt,
1318                            _("Send return receipt on request"));
1319
1320         hbox1 = gtk_hbox_new (FALSE, 8);
1321         gtk_widget_show (hbox1);
1322         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1323
1324         label_outcharset = gtk_label_new (_("Outgoing codeset"));
1325         gtk_widget_show (label_outcharset);
1326         gtk_box_pack_start (GTK_BOX (hbox1), label_outcharset, FALSE, FALSE, 0);
1327
1328         optmenu = gtk_option_menu_new ();
1329         gtk_widget_show (optmenu);
1330         gtk_box_pack_start (GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
1331
1332         optmenu_menu = gtk_menu_new ();
1333
1334 #define SET_MENUITEM(str, charset) \
1335 { \
1336         MENUITEM_ADD(optmenu_menu, menuitem, str, charset); \
1337 }
1338
1339         SET_MENUITEM(_("Automatic (Recommended)"),       CS_AUTO);
1340         SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
1341 #if HAVE_LIBJCONV
1342         SET_MENUITEM(_("Unicode (UTF-8)"),               CS_UTF_8);
1343 #endif
1344         SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
1345         SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
1346         SET_MENUITEM(_("Central European (ISO-8859-2)"),  CS_ISO_8859_2);
1347         SET_MENUITEM(_("Baltic (ISO-8859-13)"),           CS_ISO_8859_13);
1348         SET_MENUITEM(_("Baltic (ISO-8859-4)"),            CS_ISO_8859_4);
1349         SET_MENUITEM(_("Greek (ISO-8859-7)"),             CS_ISO_8859_7);
1350         SET_MENUITEM(_("Turkish (ISO-8859-9)"),           CS_ISO_8859_9);
1351 #if HAVE_LIBJCONV
1352         SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
1353 #endif
1354         SET_MENUITEM(_("Cyrillic (KOI8-R)"),             CS_KOI8_R);
1355 #if HAVE_LIBJCONV
1356         SET_MENUITEM(_("Cyrillic (Windows-1251)"),       CS_WINDOWS_1251);
1357         SET_MENUITEM(_("Cyrillic (KOI8-U)"),             CS_KOI8_U);
1358 #endif
1359         SET_MENUITEM(_("Japanese (ISO-2022-JP)"),        CS_ISO_2022_JP);
1360 #if 0
1361         SET_MENUITEM(_("Japanese (EUC-JP)"),             CS_EUC_JP);
1362         SET_MENUITEM(_("Japanese (Shift_JIS)"),          CS_SHIFT_JIS);
1363 #endif /* 0 */
1364         SET_MENUITEM(_("Simplified Chinese (GB2312)"),   CS_GB2312);
1365         SET_MENUITEM(_("Traditional Chinese (Big5)"),    CS_BIG5);
1366 #if 0
1367         SET_MENUITEM(_("Traditional Chinese (EUC-TW)"),  CS_EUC_TW);
1368         SET_MENUITEM(_("Chinese (ISO-2022-CN)"),         CS_ISO_2022_CN);
1369 #endif /* 0 */
1370         SET_MENUITEM(_("Korean (EUC-KR)"),               CS_EUC_KR);
1371         SET_MENUITEM(_("Thai (TIS-620)"),                CS_TIS_620);
1372         SET_MENUITEM(_("Thai (Windows-874)"),            CS_WINDOWS_874);
1373
1374         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
1375
1376         hbox1 = gtk_hbox_new (FALSE, 8);
1377         gtk_widget_show (hbox1);
1378         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1379
1380         label_charset_desc = gtk_label_new
1381                 (_("If `Automatic' is selected, the optimal encoding\n"
1382                    "for the current locale will be used."));
1383         gtk_widget_show (label_charset_desc);
1384         gtk_box_pack_start (GTK_BOX (hbox1), label_charset_desc,
1385                             FALSE, FALSE, 0);
1386         gtk_label_set_justify(GTK_LABEL (label_charset_desc), GTK_JUSTIFY_LEFT);
1387
1388         send.checkbtn_extsend = checkbtn_extsend;
1389         send.entry_extsend    = entry_extsend;
1390         /* send.button_extsend   = button_extsend; */
1391
1392         send.checkbtn_savemsg  = checkbtn_savemsg;
1393         send.checkbtn_queuemsg = checkbtn_queuemsg;
1394         send.checkbtn_returnreceipt = checkbtn_returnreceipt;
1395
1396         send.optmenu_charset = optmenu;
1397 }
1398
1399 static void prefs_common_recv_dialog_newmail_notify_toggle_cb(GtkWidget *w, gpointer data)
1400 {
1401         gboolean toggled;
1402
1403         toggled = gtk_toggle_button_get_active
1404                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_manu)) ||
1405                   gtk_toggle_button_get_active
1406                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_auto));
1407         gtk_widget_set_sensitive(receive.hbox_newmail_notify, toggled);
1408 }
1409
1410 #if USE_PSPELL
1411 static void prefs_dictionary_set_data_from_optmenu(PrefParam *param)
1412 {
1413         gchar *str;
1414         gchar *dict_fullname;
1415         
1416         g_return_if_fail(param);
1417         g_return_if_fail(param->data);
1418         g_return_if_fail(param->widget);
1419         g_return_if_fail(*(param->widget));
1420
1421         dict_fullname = gtkpspell_get_dictionary_menu_active_item
1422                 (gtk_option_menu_get_menu(GTK_OPTION_MENU(*(param->widget))));
1423         str = *((gchar **) param->data);
1424         if (str)
1425                 g_free(str);
1426         *((gchar **) param->data) = dict_fullname;
1427 }
1428
1429 static void prefs_dictionary_set_optmenu(PrefParam *pparam)
1430 {
1431         GList *cur;
1432         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
1433         GtkWidget *menu;
1434         GtkWidget *menuitem;
1435         gchar *dict_name;
1436         gint n = 0;
1437
1438         g_return_if_fail(optmenu != NULL);
1439         g_return_if_fail(pparam->data != NULL);
1440
1441         if (*(gchar **) pparam->data) {
1442                 menu = gtk_option_menu_get_menu(optmenu);
1443                 for (cur = GTK_MENU_SHELL(menu)->children;
1444                      cur != NULL; cur = cur->next) {
1445                         menuitem = GTK_WIDGET(cur->data);
1446                         dict_name = gtk_object_get_data(GTK_OBJECT(menuitem), 
1447                                                         "dict_name");
1448                         if (!strcmp2(dict_name, *((gchar **)pparam->data))) {
1449                                 gtk_option_menu_set_history(optmenu, n);
1450                                 return;
1451                         }
1452                         n++;
1453                 }
1454         }               
1455
1456         gtk_option_menu_set_history(optmenu, 0);
1457         prefs_dictionary_set_data_from_optmenu(pparam);
1458 }
1459
1460 static void prefs_speller_sugmode_set_data_from_optmenu(PrefParam *param)
1461 {
1462         gint sugmode;
1463         g_return_if_fail(param);
1464         g_return_if_fail(param->data);
1465         g_return_if_fail(param->widget);
1466         g_return_if_fail(*(param->widget));
1467
1468         sugmode = gtkpspell_get_sugmode_from_option_menu
1469                 (GTK_OPTION_MENU(*(param->widget)));
1470         *((gint *) param->data) = sugmode;
1471 }
1472
1473 static void prefs_speller_sugmode_set_optmenu(PrefParam *pparam)
1474 {
1475         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
1476         gint sugmode;
1477
1478         g_return_if_fail(optmenu != NULL);
1479         g_return_if_fail(pparam->data != NULL);
1480
1481         sugmode = *(gint *) pparam->data;
1482         gtkpspell_sugmode_option_menu_set(optmenu, sugmode);
1483 }
1484         
1485         
1486 static void prefs_spelling_checkbtn_enable_pspell_toggle_cb
1487         (GtkWidget *widget,
1488          gpointer data)
1489 {
1490         gboolean toggled;
1491
1492         toggled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
1493
1494         gtk_widget_set_sensitive(spelling.entry_pspell_path,   toggled);
1495         gtk_widget_set_sensitive(spelling.optmenu_dictionary,  toggled);
1496         gtk_widget_set_sensitive(spelling.optmenu_sugmode,     toggled);
1497         gtk_widget_set_sensitive(spelling.btn_pspell_path,     toggled);
1498         gtk_widget_set_sensitive(spelling.misspelled_btn,      toggled);
1499         gtk_widget_set_sensitive(spelling.checkbtn_use_alternate,      toggled);
1500         gtk_widget_set_sensitive(spelling.checkbtn_check_while_typing, toggled);
1501 }
1502
1503 static void prefs_spelling_btn_pspell_path_clicked_cb(GtkWidget *widget,
1504                                                      gpointer data)
1505 {
1506         gchar *file_path, *tmp;
1507         GtkWidget *new_menu;
1508
1509         file_path = filesel_select_file(_("Select dictionaries location"),
1510                                         prefs_common.pspell_path);
1511         if (file_path == NULL) {
1512                 /* don't change */      
1513         }
1514         else {
1515           tmp=g_dirname(file_path);
1516           
1517                 if (prefs_common.pspell_path)
1518                         g_free(prefs_common.pspell_path);
1519                 prefs_common.pspell_path = g_strdup_printf("%s%s",tmp,
1520                                                            G_DIR_SEPARATOR_S);
1521
1522                 new_menu = gtkpspell_dictionary_option_menu_new(prefs_common.pspell_path);
1523                 gtk_option_menu_set_menu(GTK_OPTION_MENU(spelling.optmenu_dictionary),
1524                                          new_menu);
1525
1526                 gtk_entry_set_text(GTK_ENTRY(spelling.entry_pspell_path), 
1527                                    prefs_common.pspell_path);                                    
1528                 /* select first one */
1529                 gtk_option_menu_set_history(GTK_OPTION_MENU(
1530                                         spelling.optmenu_dictionary), 0);
1531         
1532                 if (prefs_common.dictionary)
1533                         g_free(prefs_common.dictionary);
1534
1535                 prefs_common.dictionary = 
1536                         gtkpspell_get_dictionary_menu_active_item(
1537                                 gtk_option_menu_get_menu(
1538                                         GTK_OPTION_MENU(
1539                                                 spelling.optmenu_dictionary)));
1540                 g_free(tmp);
1541
1542         }
1543 }
1544
1545 static void prefs_spelling_create()
1546 {
1547         GtkWidget *vbox1;
1548         GtkWidget *frame_spell;
1549         GtkWidget *vbox_spell;
1550         GtkWidget *hbox_pspell_path;
1551         GtkWidget *checkbtn_enable_pspell;
1552         GtkWidget *label_pspell_path;
1553         GtkWidget *entry_pspell_path;
1554         GtkWidget *btn_pspell_path;
1555         GtkWidget *spell_table;
1556         GtkWidget *label_dictionary;
1557         GtkWidget *optmenu_dictionary;
1558         GtkWidget *sugmode_label;
1559         GtkWidget *sugmode_optmenu;
1560         GtkWidget *checkbtn_use_alternate;
1561         GtkWidget *help_label;
1562         GtkWidget *checkbtn_check_while_typing;
1563         GtkWidget *color_label;
1564         GtkWidget *col_align;
1565
1566         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1567         gtk_widget_show (vbox1);
1568         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1569         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1570
1571         /* spell checker defaults */                       
1572         PACK_FRAME(vbox1, frame_spell, _("Global spelling checker settings"));
1573         vbox_spell = gtk_vbox_new(FALSE, VSPACING_NARROW);
1574         gtk_widget_show (vbox_spell);
1575         gtk_container_add(GTK_CONTAINER(frame_spell), vbox_spell);
1576         gtk_container_set_border_width(GTK_CONTAINER(vbox_spell), 8);
1577
1578         PACK_CHECK_BUTTON(vbox_spell, checkbtn_enable_pspell, 
1579                           _("Enable spell checker (EXPERIMENTAL)"));
1580
1581         gtk_signal_connect(GTK_OBJECT(checkbtn_enable_pspell), "toggled",
1582                            GTK_SIGNAL_FUNC(prefs_spelling_checkbtn_enable_pspell_toggle_cb),
1583                            NULL);
1584
1585         /* Check while typing */
1586         PACK_CHECK_BUTTON(vbox_spell, checkbtn_check_while_typing, 
1587                           _("Check while typing"));
1588
1589         PACK_CHECK_BUTTON(vbox_spell, checkbtn_use_alternate, 
1590                           _("Enable alternate dictionary"));
1591
1592         help_label = gtk_label_new(_("Enabling alternate dictionary makes switching\nwith the last used dictionary faster."));
1593         gtk_widget_show(help_label);
1594         gtk_box_pack_start(GTK_BOX(vbox_spell), help_label, FALSE, TRUE, 0);
1595         
1596         spell_table = gtk_table_new(4, 3, FALSE);
1597         gtk_container_set_border_width (GTK_CONTAINER (spell_table), VSPACING);
1598         gtk_table_set_row_spacings(GTK_TABLE(spell_table), 8);
1599         gtk_table_set_col_spacings(GTK_TABLE(spell_table), 8);
1600
1601         gtk_box_pack_start(GTK_BOX(vbox_spell), spell_table, TRUE, TRUE, 0);
1602
1603         label_pspell_path = gtk_label_new (_("Dictionaries path:"));
1604         gtk_misc_set_alignment(GTK_MISC(label_pspell_path), 1.0, 0.5);
1605         gtk_widget_show(label_pspell_path);
1606         gtk_table_attach (GTK_TABLE (spell_table), label_pspell_path, 0, 1, 0,
1607                           1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1608         
1609         hbox_pspell_path = gtk_hbox_new (FALSE, 8);
1610         gtk_table_attach (GTK_TABLE (spell_table), hbox_pspell_path, 1, 2, 0,
1611                           1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1612         gtk_widget_show(hbox_pspell_path);
1613
1614         entry_pspell_path = gtk_entry_new();
1615         gtk_widget_show(entry_pspell_path);
1616         gtk_box_pack_start(GTK_BOX(hbox_pspell_path), entry_pspell_path, TRUE,
1617                            TRUE, 0);    
1618         
1619         gtk_widget_set_sensitive(entry_pspell_path, prefs_common.enable_pspell);
1620
1621         btn_pspell_path = gtk_button_new_with_label(" ... ");
1622         gtk_widget_show(btn_pspell_path);
1623         gtk_box_pack_start(GTK_BOX(hbox_pspell_path), btn_pspell_path, FALSE, FALSE, 0);
1624         gtk_widget_set_sensitive(btn_pspell_path, prefs_common.enable_pspell);
1625
1626         gtk_signal_connect(GTK_OBJECT(btn_pspell_path), "clicked", 
1627                            GTK_SIGNAL_FUNC(prefs_spelling_btn_pspell_path_clicked_cb),
1628                            NULL);
1629
1630         label_dictionary = gtk_label_new(_("Default dictionary:"));
1631         gtk_misc_set_alignment(GTK_MISC(label_dictionary), 1.0, 0.5);
1632         gtk_widget_show(label_dictionary);
1633         gtk_table_attach (GTK_TABLE (spell_table), label_dictionary, 0, 1, 1, 2,
1634                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1635
1636         optmenu_dictionary = gtk_option_menu_new();
1637         gtk_widget_show(optmenu_dictionary);
1638         gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_dictionary), 
1639                                  gtkpspell_dictionary_option_menu_new(
1640                                          prefs_common.pspell_path));
1641         gtk_table_attach (GTK_TABLE (spell_table), optmenu_dictionary, 1, 2, 1,
1642                           2, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1643         gtk_widget_set_sensitive(optmenu_dictionary, prefs_common.enable_pspell);
1644
1645         /* Suggestion mode */
1646         sugmode_label = gtk_label_new(_("Default suggestion mode"));
1647         gtk_misc_set_alignment(GTK_MISC(sugmode_label), 1.0, 0.5);
1648         gtk_widget_show(sugmode_label);
1649         gtk_table_attach(GTK_TABLE (spell_table), sugmode_label, 0, 1, 2, 3,
1650                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1651
1652         sugmode_optmenu = gtk_option_menu_new();
1653         gtk_widget_show(sugmode_optmenu);
1654         gtk_option_menu_set_menu(GTK_OPTION_MENU(sugmode_optmenu),
1655                             gtkpspell_sugmode_option_menu_new(prefs_common.pspell_sugmode));
1656         gtk_table_attach(GTK_TABLE(spell_table), sugmode_optmenu, 1, 2, 2, 3,
1657                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1658         gtk_widget_set_sensitive(sugmode_optmenu, prefs_common.enable_pspell);
1659
1660         /* Color */
1661         color_label = gtk_label_new(_("Misspelled word color:"));
1662         gtk_misc_set_alignment(GTK_MISC(color_label), 1.0, 0.5);
1663         gtk_table_attach (GTK_TABLE (spell_table), color_label, 0, 1, 3, 4,
1664                           GTK_FILL, GTK_SHRINK, 0, 0);
1665         gtk_widget_show(color_label);
1666         
1667         col_align = gtk_alignment_new(0.0, 0.5, 0, 0);
1668         gtk_widget_show(col_align);
1669         gtk_table_attach (GTK_TABLE (spell_table), col_align, 1, 2, 3, 4,
1670                           GTK_FILL, GTK_SHRINK, 0, 0);
1671
1672         spelling.misspelled_btn = gtk_button_new_with_label ("");
1673         set_button_bg_color(spelling.misspelled_btn,
1674                             prefs_common.misspelled_col);
1675         gtk_widget_set_usize (spelling.misspelled_btn, 30, 20);
1676         gtk_widget_set_sensitive(spelling.misspelled_btn, prefs_common.enable_pspell);
1677         gtk_signal_connect (GTK_OBJECT (spelling.misspelled_btn), "clicked",
1678                             GTK_SIGNAL_FUNC(quote_color_set_dialog), "Misspelled word");
1679         gtk_container_add(GTK_CONTAINER(col_align), spelling.misspelled_btn);
1680
1681
1682         spelling.checkbtn_enable_pspell = checkbtn_enable_pspell;
1683         spelling.entry_pspell_path      = entry_pspell_path;
1684         spelling.btn_pspell_path        = btn_pspell_path;
1685         spelling.optmenu_dictionary     = optmenu_dictionary;
1686         spelling.optmenu_sugmode        = sugmode_optmenu;
1687         spelling.checkbtn_use_alternate = checkbtn_use_alternate;
1688         spelling.checkbtn_check_while_typing = checkbtn_check_while_typing;
1689 }
1690
1691 #endif
1692
1693
1694 static void prefs_compose_create(void)
1695 {
1696         GtkWidget *vbox1;
1697         GtkWidget *vbox2;
1698         GtkWidget *vbox3;
1699         GtkWidget *hbox1;
1700         GtkWidget *hbox2;
1701         GtkWidget *btn_quotefmt;
1702
1703         GtkWidget *frame_sig;
1704         GtkWidget *vbox_sig;
1705         GtkWidget *checkbtn_autosig;
1706         GtkWidget *label_sigsep;
1707         GtkWidget *entry_sigsep;
1708
1709         GtkWidget *frame_editor;
1710         GtkWidget *hbox_editor;
1711         GtkWidget *checkbtn_autoextedit;
1712
1713         GtkWidget *frame_autosel;
1714         GtkWidget *hbox_autosel;
1715         GtkWidget *vbox_autosel;
1716         GtkWidget *checkbtn_reply_account_autosel;
1717         GtkWidget *checkbtn_forward_account_autosel;
1718         GtkWidget *checkbtn_reedit_account_autosel;
1719
1720         GtkWidget *hbox_undolevel;
1721         GtkWidget *label_undolevel;
1722         GtkObject *spinbtn_undolevel_adj;
1723         GtkWidget *spinbtn_undolevel;
1724
1725         GtkWidget *vbox_linewrap;
1726
1727         GtkWidget *hbox3;
1728         GtkWidget *hbox4;
1729         GtkWidget *hbox5;
1730         GtkWidget *label_linewrap;
1731         GtkObject *spinbtn_linewrap_adj;
1732         GtkWidget *spinbtn_linewrap;
1733         GtkWidget *checkbtn_wrapquote;
1734         GtkWidget *checkbtn_autowrap;
1735         GtkWidget *checkbtn_wrapatsend;
1736
1737         GtkWidget *frame_reply;
1738         GtkWidget *checkbtn_quote;
1739         GtkWidget *checkbtn_forward_as_attachment;
1740         GtkWidget *checkbtn_redirect_keep_from;
1741         GtkWidget *checkbtn_smart_wrapping;
1742         GtkWidget *checkbtn_block_cursor;
1743         GtkWidget *frame_msgwrap;
1744
1745         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1746         gtk_widget_show (vbox1);
1747         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1748         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1749
1750         PACK_FRAME(vbox1, frame_sig, _("Signature"));
1751
1752         vbox_sig = gtk_vbox_new (FALSE, VSPACING_NARROW);
1753         gtk_widget_show (vbox_sig);
1754         gtk_container_add (GTK_CONTAINER (frame_sig), vbox_sig);
1755         gtk_container_set_border_width (GTK_CONTAINER (vbox_sig), 8);
1756
1757         PACK_CHECK_BUTTON (vbox_sig, checkbtn_autosig,
1758                            _("Insert signature automatically"));
1759
1760         hbox1 = gtk_hbox_new (FALSE, 8);
1761         gtk_widget_show (hbox1);
1762         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox1, TRUE, TRUE, 0);
1763         label_sigsep = gtk_label_new (_("Signature separator"));
1764         gtk_widget_show (label_sigsep);
1765         gtk_box_pack_start (GTK_BOX (hbox1), label_sigsep, FALSE, FALSE, 0);
1766
1767         entry_sigsep = gtk_entry_new ();
1768         gtk_widget_show (entry_sigsep);
1769         gtk_box_pack_start (GTK_BOX (hbox1), entry_sigsep, FALSE, FALSE, 0);
1770
1771         gtk_widget_set_usize (entry_sigsep, 64, -1);
1772
1773         /* Account autoselection */
1774         PACK_FRAME(vbox1, frame_autosel, _("Automatic account selection"));
1775
1776         hbox_autosel = gtk_hbox_new (FALSE, VSPACING_NARROW);
1777         gtk_widget_show (hbox_autosel);
1778         gtk_container_add (GTK_CONTAINER (frame_autosel), hbox_autosel);
1779         gtk_container_set_border_width (GTK_CONTAINER (hbox_autosel), 8);
1780
1781         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reply_account_autosel,
1782                            _("when replying"));
1783         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_forward_account_autosel,
1784                            _("when forwarding"));
1785         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reedit_account_autosel,
1786                            _("when re-editing"));
1787
1788         vbox2 = gtk_vbox_new (FALSE, 0);
1789         gtk_widget_show (vbox2);
1790         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1791
1792         PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1793                            _("Automatically launch the external editor"));
1794
1795         hbox5 = gtk_hbox_new (FALSE, 8);
1796         gtk_widget_show (hbox5);
1797         gtk_box_pack_start (GTK_BOX (vbox2), hbox5, FALSE, FALSE, 0);
1798
1799         PACK_CHECK_BUTTON (hbox5, checkbtn_forward_as_attachment,
1800                            _("Forward as attachment"));
1801
1802         PACK_CHECK_BUTTON (hbox5, checkbtn_block_cursor,
1803                           _("Block cursor"));
1804
1805         PACK_CHECK_BUTTON (vbox2, checkbtn_redirect_keep_from,
1806                            _("Keep the original 'From' header when redirecting"));
1807
1808         hbox_undolevel = gtk_hbox_new (FALSE, 8);
1809         gtk_widget_show (hbox_undolevel);
1810         gtk_box_pack_start (GTK_BOX (vbox1), hbox_undolevel, FALSE, FALSE, 0);
1811
1812         label_undolevel = gtk_label_new (_("Undo level"));
1813         gtk_widget_show (label_undolevel);
1814         gtk_box_pack_start (GTK_BOX (hbox_undolevel), label_undolevel, FALSE, FALSE, 0);
1815
1816         spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 10);
1817         spinbtn_undolevel = gtk_spin_button_new
1818                 (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1819         gtk_widget_show (spinbtn_undolevel);
1820         gtk_box_pack_start (GTK_BOX (hbox_undolevel), spinbtn_undolevel, FALSE, FALSE, 0);
1821         gtk_widget_set_usize (spinbtn_undolevel, 64, -1);
1822         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1823
1824         /* line-wrapping */
1825         PACK_FRAME(vbox1, frame_msgwrap, _("Message wrapping"));
1826
1827         vbox_linewrap = gtk_vbox_new (FALSE, VSPACING_NARROW);
1828         gtk_widget_show (vbox_linewrap);
1829         gtk_container_add (GTK_CONTAINER (frame_msgwrap), vbox_linewrap);
1830         gtk_container_set_border_width (GTK_CONTAINER (vbox_linewrap), 8);
1831
1832         hbox3 = gtk_hbox_new (FALSE, 8);
1833         gtk_widget_show (hbox3);
1834         gtk_box_pack_start (GTK_BOX (vbox_linewrap), hbox3, FALSE, FALSE, 0);
1835
1836
1837         label_linewrap = gtk_label_new (_("Wrap messages at"));
1838         gtk_widget_show (label_linewrap);
1839         gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1840
1841         spinbtn_linewrap_adj = gtk_adjustment_new (72, 20, 1024, 1, 10, 10);
1842         spinbtn_linewrap = gtk_spin_button_new
1843                 (GTK_ADJUSTMENT (spinbtn_linewrap_adj), 1, 0);
1844         gtk_widget_show (spinbtn_linewrap);
1845         gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_linewrap, FALSE, FALSE, 0);
1846         gtk_widget_set_usize (spinbtn_linewrap, 64, -1);
1847         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
1848
1849         label_linewrap = gtk_label_new (_("characters"));
1850         gtk_widget_show (label_linewrap);
1851         gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1852
1853         hbox4 = gtk_hbox_new (FALSE, VSPACING);
1854         gtk_widget_show (hbox4);
1855         gtk_box_pack_start (GTK_BOX (vbox_linewrap), hbox4, FALSE, FALSE, 0);
1856
1857         PACK_CHECK_BUTTON (hbox4, checkbtn_wrapquote, _("Wrap quotation"));
1858
1859         PACK_CHECK_BUTTON (hbox4, checkbtn_autowrap, _("Wrap on input"));
1860
1861         PACK_CHECK_BUTTON
1862                 (hbox4, checkbtn_wrapatsend, _("Wrap before sending"));
1863
1864         PACK_CHECK_BUTTON (vbox_linewrap, checkbtn_smart_wrapping,
1865                            _("Smart wrapping (EXPERIMENTAL)"));
1866         
1867        /*
1868         compose.checkbtn_quote   = checkbtn_quote;
1869         compose.entry_quotemark  = entry_quotemark;
1870         compose.text_quotefmt    = text_quotefmt;
1871         */
1872         compose.checkbtn_autosig = checkbtn_autosig;
1873         compose.entry_sigsep     = entry_sigsep;
1874
1875         compose.checkbtn_autoextedit = checkbtn_autoextedit;
1876
1877         compose.checkbtn_reply_account_autosel   = checkbtn_reply_account_autosel;
1878         compose.checkbtn_forward_account_autosel = checkbtn_forward_account_autosel;
1879         compose.checkbtn_reedit_account_autosel  = checkbtn_reedit_account_autosel;
1880
1881         compose.spinbtn_undolevel     = spinbtn_undolevel;
1882         compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1883
1884         compose.spinbtn_linewrap     = spinbtn_linewrap;
1885         compose.spinbtn_linewrap_adj = spinbtn_linewrap_adj;
1886         compose.checkbtn_wrapquote   = checkbtn_wrapquote;
1887         compose.checkbtn_autowrap    = checkbtn_autowrap;
1888         compose.checkbtn_wrapatsend  = checkbtn_wrapatsend;
1889
1890         compose.checkbtn_forward_as_attachment =
1891                 checkbtn_forward_as_attachment;
1892         compose.checkbtn_redirect_keep_from =
1893                 checkbtn_redirect_keep_from;
1894         compose.checkbtn_smart_wrapping = 
1895                 checkbtn_smart_wrapping;
1896         compose.checkbtn_block_cursor   =
1897                 checkbtn_block_cursor;
1898
1899 }
1900
1901 static void prefs_quote_create(void)
1902 {
1903         GtkWidget *vbox1;
1904         GtkWidget *frame_quote;
1905         GtkWidget *vbox_quote;
1906         GtkWidget *hbox1;
1907         GtkWidget *hbox2;
1908         GtkWidget *label_quotemark;
1909         GtkWidget *entry_quotemark;
1910         GtkWidget *scrolledwin_quotefmt;
1911         GtkWidget *text_quotefmt;
1912
1913         GtkWidget *entry_fw_quotemark;
1914         GtkWidget *text_fw_quotefmt;
1915
1916         GtkWidget *entry_quote_chars;
1917         GtkWidget *label_quote_chars;
1918         
1919         GtkWidget *btn_quotedesc;
1920
1921         GtkWidget *checkbtn_reply_with_quote;
1922
1923         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1924         gtk_widget_show (vbox1);
1925         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1926         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1927
1928         /* reply */
1929
1930         PACK_CHECK_BUTTON (vbox1, checkbtn_reply_with_quote, _("Reply will quote by default"));
1931
1932         PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1933
1934         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1935         gtk_widget_show (vbox_quote);
1936         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1937         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1938
1939         hbox1 = gtk_hbox_new (FALSE, 32);
1940         gtk_widget_show (hbox1);
1941         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1942
1943         hbox2 = gtk_hbox_new (FALSE, 8);
1944         gtk_widget_show (hbox2);
1945         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1946
1947         label_quotemark = gtk_label_new (_("Quotation mark"));
1948         gtk_widget_show (label_quotemark);
1949         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1950
1951         entry_quotemark = gtk_entry_new ();
1952         gtk_widget_show (entry_quotemark);
1953         gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1954         gtk_widget_set_usize (entry_quotemark, 64, -1);
1955
1956         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1957         gtk_widget_show (scrolledwin_quotefmt);
1958         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1959         gtk_scrolled_window_set_policy
1960                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1961                  GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1962
1963         text_quotefmt = gtk_text_new (NULL, NULL);
1964         gtk_widget_show (text_quotefmt);
1965         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1966         gtk_text_set_editable (GTK_TEXT (text_quotefmt), TRUE);
1967         gtk_widget_set_usize(text_quotefmt, -1, 60);
1968
1969         /* forward */
1970
1971         PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1972
1973         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1974         gtk_widget_show (vbox_quote);
1975         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1976         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1977
1978         hbox1 = gtk_hbox_new (FALSE, 32);
1979         gtk_widget_show (hbox1);
1980         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1981
1982         hbox2 = gtk_hbox_new (FALSE, 8);
1983         gtk_widget_show (hbox2);
1984         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1985
1986         label_quotemark = gtk_label_new (_("Quotation mark"));
1987         gtk_widget_show (label_quotemark);
1988         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1989
1990         entry_fw_quotemark = gtk_entry_new ();
1991         gtk_widget_show (entry_fw_quotemark);
1992         gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1993                             FALSE, FALSE, 0);
1994         gtk_widget_set_usize (entry_fw_quotemark, 64, -1);
1995
1996         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1997         gtk_widget_show (scrolledwin_quotefmt);
1998         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1999         gtk_scrolled_window_set_policy
2000                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
2001                  GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
2002
2003         text_fw_quotefmt = gtk_text_new (NULL, NULL);
2004         gtk_widget_show (text_fw_quotefmt);
2005         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
2006                           text_fw_quotefmt);
2007         gtk_text_set_editable (GTK_TEXT (text_fw_quotefmt), TRUE);
2008         gtk_widget_set_usize(text_fw_quotefmt, -1, 60);
2009
2010         hbox1 = gtk_hbox_new (FALSE, 32);
2011         gtk_widget_show (hbox1);
2012         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2013
2014         btn_quotedesc =
2015                 gtk_button_new_with_label (_(" Description of symbols "));
2016         gtk_widget_show (btn_quotedesc);
2017         gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
2018         gtk_signal_connect(GTK_OBJECT(btn_quotedesc), "clicked",
2019                            GTK_SIGNAL_FUNC(quote_fmt_quote_description), NULL);
2020
2021         /* quote chars */
2022
2023         PACK_FRAME (vbox1, frame_quote, _("Quoting characters"));
2024
2025         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
2026         gtk_widget_show (vbox_quote);
2027         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
2028         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
2029
2030         hbox1 = gtk_hbox_new (FALSE, 32);
2031         gtk_widget_show (hbox1);
2032         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
2033
2034         hbox2 = gtk_hbox_new (FALSE, 8);
2035         gtk_widget_show (hbox2);
2036         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
2037
2038         label_quote_chars = gtk_label_new (_("Treat these characters as quotation marks: "));
2039         gtk_widget_show (label_quote_chars);
2040         gtk_box_pack_start (GTK_BOX (hbox2), label_quote_chars, FALSE, FALSE, 0);
2041
2042         entry_quote_chars = gtk_entry_new ();
2043         gtk_widget_show (entry_quote_chars);
2044         gtk_box_pack_start (GTK_BOX (hbox2), entry_quote_chars,
2045                             FALSE, FALSE, 0);
2046         gtk_widget_set_usize (entry_quote_chars, 64, -1);
2047
2048
2049         compose.checkbtn_reply_with_quote= checkbtn_reply_with_quote;
2050         quote.entry_quotemark    = entry_quotemark;
2051         quote.text_quotefmt      = text_quotefmt;
2052         quote.entry_fw_quotemark = entry_fw_quotemark;
2053         quote.text_fw_quotefmt   = text_fw_quotefmt;
2054         quote.entry_quote_chars  = entry_quote_chars;
2055 }
2056
2057 static void prefs_display_create(void)
2058 {
2059         GtkWidget *vbox1;
2060         GtkWidget *frame_font;
2061         GtkWidget *table1;
2062         GtkWidget *label_textfont;
2063         GtkWidget *entry_textfont;
2064         GtkWidget *button_textfont;
2065         GtkWidget *chkbtn_display_img;
2066         GtkWidget *chkbtn_transhdr;
2067         GtkWidget *chkbtn_folder_unread;
2068         GtkWidget *hbox1;
2069         GtkWidget *label_ng_abbrev;
2070         GtkWidget *spinbtn_ng_abbrev_len;
2071         GtkObject *spinbtn_ng_abbrev_len_adj;
2072         GtkWidget *frame_summary;
2073         GtkWidget *vbox2;
2074         GtkWidget *chkbtn_swapfrom;
2075         GtkWidget *chkbtn_hscrollbar;
2076         GtkWidget *chkbtn_useaddrbook;
2077         GtkWidget *chkbtn_expand_thread;
2078         GtkWidget *chkbtn_bold_unread;
2079         GtkWidget *vbox3;
2080         GtkWidget *label_datefmt;
2081         GtkWidget *button_datefmt;
2082         GtkWidget *entry_datefmt;
2083         GtkWidget *button_dispitem;
2084         GtkWidget *tmplabel, *tmpbutton, *tmpentry;
2085
2086         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2087         gtk_widget_show (vbox1);
2088         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2089         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2090
2091         PACK_FRAME(vbox1, frame_font, _("Font"));
2092
2093         table1 = gtk_table_new (4, 3, FALSE);
2094
2095         gtk_widget_show (table1);
2096         gtk_container_add (GTK_CONTAINER (frame_font), table1);
2097         gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
2098         gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
2099         gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
2100
2101         label_textfont = gtk_label_new (_("Text"));
2102         gtk_misc_set_alignment(GTK_MISC(label_textfont), 0, 0.5);
2103         gtk_widget_show (label_textfont);
2104         gtk_table_attach (GTK_TABLE (table1), label_textfont, 0, 1, 0, 1,
2105                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
2106
2107         entry_textfont = gtk_entry_new ();
2108         gtk_widget_show (entry_textfont);
2109         gtk_table_attach (GTK_TABLE (table1), entry_textfont, 1, 2, 0, 1,
2110                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2111
2112         button_textfont = gtk_button_new_with_label (" ... ");
2113
2114         gtk_widget_show (button_textfont);
2115         gtk_table_attach (GTK_TABLE (table1), button_textfont, 2, 3, 0, 1,
2116                           0, 0, 0, 0);
2117         gtk_signal_connect (GTK_OBJECT (button_textfont), "clicked",
2118                             GTK_SIGNAL_FUNC (prefs_font_select), entry_textfont);
2119
2120         tmplabel = gtk_label_new (_("Small"));
2121         gtk_misc_set_alignment(GTK_MISC(tmplabel), 0, 0.5);
2122         gtk_widget_show (tmplabel);
2123         gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 1, 2,
2124                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
2125
2126         tmpentry = gtk_entry_new ();
2127         gtk_widget_show (tmpentry);
2128         gtk_table_attach (GTK_TABLE (table1), tmpentry, 1, 2, 1, 2,
2129                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2130
2131         tmpbutton = gtk_button_new_with_label (" ... ");
2132         gtk_widget_show (tmpbutton);
2133         gtk_table_attach (GTK_TABLE (table1), tmpbutton, 2, 3, 1, 2,
2134                           0, 0, 0, 0);
2135         gtk_signal_connect (GTK_OBJECT(tmpbutton), "clicked",
2136                             GTK_SIGNAL_FUNC(prefs_font_select), tmpentry);
2137         display.entry_smallfont = tmpentry;                       
2138
2139         tmplabel = gtk_label_new (_("Normal"));
2140         gtk_misc_set_alignment(GTK_MISC(tmplabel), 0, 0.5);
2141         gtk_widget_show (tmplabel);
2142         gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 2, 3,
2143                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
2144
2145         tmpentry = gtk_entry_new ();
2146         gtk_widget_show (tmpentry);
2147         gtk_table_attach (GTK_TABLE (table1), tmpentry, 1, 2, 2, 3,
2148                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2149
2150         tmpbutton = gtk_button_new_with_label (" ... ");
2151         gtk_widget_show (tmpbutton);
2152         gtk_table_attach (GTK_TABLE (table1), tmpbutton, 2, 3, 2, 3,
2153                           0, 0, 0, 0);
2154         gtk_signal_connect (GTK_OBJECT(tmpbutton), "clicked",
2155                                 GTK_SIGNAL_FUNC(prefs_font_select), tmpentry);
2156         display.entry_normalfont = tmpentry;                      
2157
2158         tmplabel = gtk_label_new (_("Bold"));
2159         gtk_misc_set_alignment(GTK_MISC(tmplabel), 0, 0.5);
2160         gtk_widget_show (tmplabel);
2161         gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 3, 4,
2162                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
2163
2164         tmpentry = gtk_entry_new ();
2165         gtk_widget_show (tmpentry);
2166         gtk_table_attach (GTK_TABLE (table1), tmpentry, 1, 2, 3, 4,
2167                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2168
2169         tmpbutton = gtk_button_new_with_label (" ... ");
2170         gtk_widget_show (tmpbutton);
2171         gtk_table_attach (GTK_TABLE (table1), tmpbutton, 2, 3, 3, 4,
2172                           0, 0, 0, 0);
2173         gtk_signal_connect (GTK_OBJECT(tmpbutton), "clicked",
2174                                 GTK_SIGNAL_FUNC(prefs_font_select), tmpentry);
2175         display.entry_boldfont = tmpentry;
2176
2177         vbox2 = gtk_vbox_new (FALSE, 0);
2178         gtk_widget_show (vbox2);
2179         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
2180
2181         PACK_CHECK_BUTTON
2182                 (vbox2, chkbtn_transhdr,
2183                  _("Translate header name (such as `From:', `Subject:')"));
2184
2185         PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
2186                            _("Display unread number next to folder name"));
2187
2188         PACK_CHECK_BUTTON (vbox2, chkbtn_display_img,
2189                            _("Automatically display images"));
2190
2191         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
2192
2193         hbox1 = gtk_hbox_new (FALSE, 8);
2194         gtk_widget_show (hbox1);
2195         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2196
2197         label_ng_abbrev = gtk_label_new
2198                 (_("Abbreviate newsgroups longer than"));
2199         gtk_widget_show (label_ng_abbrev);
2200         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
2201
2202         spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
2203         spinbtn_ng_abbrev_len = gtk_spin_button_new
2204                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
2205         gtk_widget_show (spinbtn_ng_abbrev_len);
2206         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
2207                             FALSE, FALSE, 0);
2208         gtk_widget_set_usize (spinbtn_ng_abbrev_len, 56, -1);
2209         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
2210                                      TRUE);
2211
2212         label_ng_abbrev = gtk_label_new
2213                 (_("letters"));
2214         gtk_widget_show (label_ng_abbrev);
2215         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
2216
2217         /* ---- Summary ---- */
2218
2219         PACK_FRAME(vbox1, frame_summary, _("Summary View"));
2220
2221         vbox2 = gtk_vbox_new (FALSE, 0);
2222         gtk_widget_show (vbox2);
2223         gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
2224         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2225
2226         PACK_CHECK_BUTTON
2227                 (vbox2, chkbtn_swapfrom,
2228                  _("Display recipient on `From' column if sender is yourself"));
2229         PACK_CHECK_BUTTON
2230                 (vbox2, chkbtn_useaddrbook,
2231                  _("Display sender using address book"));
2232         PACK_CHECK_BUTTON
2233                 (vbox2, chkbtn_hscrollbar, _("Enable horizontal scroll bar"));
2234         PACK_CHECK_BUTTON
2235                 (vbox2, chkbtn_expand_thread, _("Expand threads"));
2236         PACK_CHECK_BUTTON
2237                 (vbox2, chkbtn_bold_unread,
2238                  _("Display unread messages with bold font"));
2239
2240         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
2241
2242         hbox1 = gtk_hbox_new (FALSE, 8);
2243         gtk_widget_show (hbox1);
2244         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2245
2246         label_datefmt = gtk_label_new (_("Date format"));
2247         gtk_widget_show (label_datefmt);
2248         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
2249
2250         entry_datefmt = gtk_entry_new ();
2251         gtk_widget_show (entry_datefmt);
2252         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
2253
2254         button_datefmt = gtk_button_new_with_label (" ... ");
2255
2256         gtk_widget_show (button_datefmt);
2257         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
2258         gtk_signal_connect (GTK_OBJECT (button_datefmt), "clicked",
2259                             GTK_SIGNAL_FUNC (date_format_create), NULL);
2260
2261         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
2262
2263         hbox1 = gtk_hbox_new (FALSE, 8);
2264         gtk_widget_show (hbox1);
2265         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2266
2267         button_dispitem = gtk_button_new_with_label
2268                 (_(" Set display item of summary... "));
2269         gtk_widget_show (button_dispitem);
2270         gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
2271         gtk_signal_connect (GTK_OBJECT (button_dispitem), "clicked",
2272                             GTK_SIGNAL_FUNC (prefs_summary_column_open),
2273                             NULL);
2274
2275         display.entry_textfont  = entry_textfont;
2276         display.button_textfont = button_textfont;
2277
2278         display.chkbtn_display_img   = chkbtn_display_img;
2279         display.chkbtn_transhdr           = chkbtn_transhdr;
2280         display.chkbtn_folder_unread      = chkbtn_folder_unread;
2281         display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
2282         display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
2283
2284         display.chkbtn_swapfrom      = chkbtn_swapfrom;
2285         display.chkbtn_hscrollbar    = chkbtn_hscrollbar;
2286         display.chkbtn_expand_thread = chkbtn_expand_thread;
2287         display.chkbtn_bold_unread   = chkbtn_bold_unread;
2288         display.chkbtn_useaddrbook   = chkbtn_useaddrbook;
2289         display.entry_datefmt        = entry_datefmt;
2290 }
2291
2292 static void prefs_message_create(void)
2293 {
2294         GtkWidget *vbox1;
2295         GtkWidget *vbox2;
2296         GtkWidget *vbox3;
2297         GtkWidget *hbox1;
2298         GtkWidget *chkbtn_enablecol;
2299         GtkWidget *button_edit_col;
2300         GtkWidget *chkbtn_mbalnum;
2301         GtkWidget *chkbtn_disphdrpane;
2302         GtkWidget *chkbtn_disphdr;
2303         GtkWidget *button_edit_disphdr;
2304         GtkWidget *hbox_linespc;
2305         GtkWidget *label_linespc;
2306         GtkObject *spinbtn_linespc_adj;
2307         GtkWidget *spinbtn_linespc;
2308         GtkWidget *chkbtn_headspc;
2309
2310         GtkWidget *frame_scr;
2311         GtkWidget *vbox_scr;
2312         GtkWidget *chkbtn_smoothscroll;
2313         GtkWidget *hbox_scr;
2314         GtkWidget *label_scr;
2315         GtkObject *spinbtn_scrollstep_adj;
2316         GtkWidget *spinbtn_scrollstep;
2317         GtkWidget *chkbtn_halfpage;
2318
2319         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2320         gtk_widget_show (vbox1);
2321         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2322         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2323
2324         hbox1 = gtk_hbox_new (FALSE, 8);
2325         gtk_widget_show (hbox1);
2326         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0);
2327
2328         PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
2329                            _("Enable coloration of message"));
2330         gtk_signal_connect (GTK_OBJECT (chkbtn_enablecol), "toggled",
2331                                                 GTK_SIGNAL_FUNC (prefs_enable_message_color_toggled),
2332                                                 NULL);
2333
2334         button_edit_col = gtk_button_new_with_label (_(" Edit... "));
2335         gtk_widget_show (button_edit_col);
2336         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_col, FALSE, TRUE, 0);
2337         gtk_signal_connect (GTK_OBJECT (button_edit_col), "clicked",
2338                             GTK_SIGNAL_FUNC (prefs_quote_colors_dialog), NULL);
2339
2340         SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
2341
2342         vbox2 = gtk_vbox_new (FALSE, 0);
2343         gtk_widget_show (vbox2);
2344         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2345
2346         PACK_CHECK_BUTTON
2347                 (vbox2, chkbtn_mbalnum,
2348                  _("Display 2-byte alphabet and numeric with 1-byte character"));
2349         PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
2350                           _("Display header pane above message view"));
2351
2352         hbox1 = gtk_hbox_new (FALSE, 8);
2353         gtk_widget_show (hbox1);
2354         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2355
2356         PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
2357                           _("Display short headers on message view"));
2358
2359         button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
2360         gtk_widget_show (button_edit_disphdr);
2361         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
2362                           FALSE, TRUE, 0);
2363         gtk_signal_connect (GTK_OBJECT (button_edit_disphdr), "clicked",
2364                             GTK_SIGNAL_FUNC (prefs_display_header_open),
2365                             NULL);
2366
2367         SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
2368
2369         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
2370
2371         hbox1 = gtk_hbox_new (FALSE, 32);
2372         gtk_widget_show (hbox1);
2373         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2374
2375         hbox_linespc = gtk_hbox_new (FALSE, 8);
2376         gtk_widget_show (hbox1);
2377         gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
2378
2379         label_linespc = gtk_label_new (_("Line space"));
2380         gtk_widget_show (label_linespc);
2381         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
2382                             FALSE, FALSE, 0);
2383
2384         spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
2385         spinbtn_linespc = gtk_spin_button_new
2386                 (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
2387         gtk_widget_show (spinbtn_linespc);
2388         gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
2389                             FALSE, FALSE, 0);
2390         gtk_widget_set_usize (spinbtn_linespc, 64, -1);
2391         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
2392
2393         label_linespc = gtk_label_new (_("pixel(s)"));
2394         gtk_widget_show (label_linespc);
2395         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
2396                             FALSE, FALSE, 0);
2397
2398         PACK_CHECK_BUTTON(hbox1, chkbtn_headspc, _("Leave space on head"));
2399
2400         PACK_FRAME(vbox1, frame_scr, _("Scroll"));
2401
2402         vbox_scr = gtk_vbox_new (FALSE, 0);
2403         gtk_widget_show (vbox_scr);
2404         gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
2405         gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
2406
2407         PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
2408
2409         hbox1 = gtk_hbox_new (FALSE, 32);
2410         gtk_widget_show (hbox1);
2411         gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
2412
2413         PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
2414
2415         hbox_scr = gtk_hbox_new (FALSE, 8);
2416         gtk_widget_show (hbox_scr);
2417         gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
2418
2419         label_scr = gtk_label_new (_("Step"));
2420         gtk_widget_show (label_scr);
2421         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2422
2423         spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
2424         spinbtn_scrollstep = gtk_spin_button_new
2425                 (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
2426         gtk_widget_show (spinbtn_scrollstep);
2427         gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
2428                             FALSE, FALSE, 0);
2429         gtk_widget_set_usize (spinbtn_scrollstep, 64, -1);
2430         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
2431                                      TRUE);
2432
2433         label_scr = gtk_label_new (_("pixel(s)"));
2434         gtk_widget_show (label_scr);
2435         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2436
2437         SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
2438
2439         message.chkbtn_enablecol   = chkbtn_enablecol;
2440         message.button_edit_col    = button_edit_col;
2441         message.chkbtn_mbalnum     = chkbtn_mbalnum;
2442         message.chkbtn_disphdrpane = chkbtn_disphdrpane;
2443         message.chkbtn_disphdr     = chkbtn_disphdr;
2444         message.spinbtn_linespc    = spinbtn_linespc;
2445         message.chkbtn_headspc     = chkbtn_headspc;
2446
2447         message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
2448         message.spinbtn_scrollstep     = spinbtn_scrollstep;
2449         message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
2450         message.chkbtn_halfpage        = chkbtn_halfpage;
2451 }
2452
2453 #if USE_GPGME
2454 static void prefs_privacy_create(void)
2455 {
2456         GtkWidget *vbox1;
2457         GtkWidget *vbox2;
2458         GtkWidget *hbox1;
2459         GtkWidget *checkbtn_auto_check_signatures;
2460         GtkWidget *checkbtn_gpg_signature_popup;
2461         GtkWidget *hbox_stpass;
2462         GtkWidget *checkbtn_store_passphrase;
2463         GtkWidget *label_stpass1;
2464         GtkObject *spinbtn_store_passphrase_adj;
2465         GtkWidget *spinbtn_store_passphrase;
2466         GtkWidget *label_stpass2;
2467         GtkWidget *hbox_stpassinfo;
2468         GtkWidget *label_stpassinfo;
2469         GtkWidget *checkbtn_passphrase_grab;
2470         GtkWidget *checkbtn_gpg_warning;
2471         GtkWidget *label;
2472         GtkWidget *menuitem;
2473         GtkWidget *optmenu;
2474         GtkWidget *optmenu_menu;
2475
2476         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2477         gtk_widget_show (vbox1);
2478         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2479         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2480
2481         vbox2 = gtk_vbox_new (FALSE, 0);
2482         gtk_widget_show (vbox2);
2483         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2484
2485         PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
2486                            _("Automatically check signatures"));
2487
2488         PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup,
2489                            _("Show signature check result in a popup window"));
2490
2491         hbox_stpass = gtk_hbox_new(FALSE, 8);
2492         gtk_box_pack_start(GTK_BOX(vbox2), hbox_stpass, FALSE, FALSE, 0);
2493
2494         PACK_CHECK_BUTTON (hbox_stpass, checkbtn_store_passphrase,
2495                            _("Store passphrase temporarily"));
2496
2497         label_stpass1 = gtk_label_new(_("- remove after"));
2498         gtk_box_pack_start(GTK_BOX(hbox_stpass), label_stpass1, FALSE, FALSE, 0);
2499
2500         spinbtn_store_passphrase_adj = gtk_adjustment_new(0, 0, 1440, 1, 5, 5);
2501         spinbtn_store_passphrase = gtk_spin_button_new(
2502                         GTK_ADJUSTMENT(spinbtn_store_passphrase_adj), 1, 0);
2503         gtk_box_pack_start(GTK_BOX(hbox_stpass), spinbtn_store_passphrase, FALSE, 
2504                            FALSE, 0);
2505         gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbtn_store_passphrase), 
2506                                     TRUE);
2507         gtk_widget_set_usize(spinbtn_store_passphrase, 50, -1);
2508     
2509         label_stpass2 = gtk_label_new(_("minute(s)"));
2510         gtk_box_pack_start(GTK_BOX(hbox_stpass), label_stpass2, FALSE, FALSE, 0);
2511         gtk_widget_show_all(hbox_stpass);
2512
2513         hbox_stpassinfo = gtk_hbox_new(FALSE, 8);
2514         gtk_box_pack_start(GTK_BOX(vbox2), hbox_stpassinfo, FALSE, FALSE, 0);
2515
2516         label_stpassinfo = gtk_label_new
2517                 (_("(A setting of '0' will store the passphrase\n"
2518                    " for the whole session)"));
2519         gtk_box_pack_start (GTK_BOX (hbox_stpassinfo), label_stpassinfo, FALSE, FALSE, 0);
2520         gtk_label_set_justify (GTK_LABEL (label_stpassinfo), GTK_JUSTIFY_LEFT);
2521         gtk_widget_show_all(hbox_stpassinfo);
2522
2523         SET_TOGGLE_SENSITIVITY(checkbtn_store_passphrase, label_stpass1);
2524         SET_TOGGLE_SENSITIVITY(checkbtn_store_passphrase, spinbtn_store_passphrase); 
2525         SET_TOGGLE_SENSITIVITY(checkbtn_store_passphrase, label_stpass2);
2526         SET_TOGGLE_SENSITIVITY(checkbtn_store_passphrase, label_stpassinfo);
2527
2528 #ifndef __MINGW32__
2529         PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
2530                            _("Grab input while entering a passphrase"));
2531 #endif
2532
2533         PACK_CHECK_BUTTON
2534                 (vbox2, checkbtn_gpg_warning,
2535                  _("Display warning on startup if GnuPG doesn't work"));
2536
2537         hbox1 = gtk_hbox_new (FALSE, 8);
2538         gtk_widget_show (hbox1);
2539         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2540
2541         /* create default signkey box */
2542         label = gtk_label_new (_("Default Sign Key"));
2543         gtk_widget_show (label);
2544         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2545         optmenu = gtk_option_menu_new ();
2546         gtk_widget_show (optmenu);
2547         gtk_box_pack_start(GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
2548         optmenu_menu = gtk_menu_new ();
2549
2550         MENUITEM_ADD(optmenu_menu, menuitem, "Default Key", "def_key");
2551         MENUITEM_ADD(optmenu_menu, menuitem, "Second Key", "2nd_key");
2552         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
2553         /* FIXME: disabled because not implemented */
2554         gtk_widget_set_sensitive(optmenu, FALSE);
2555
2556         privacy.checkbtn_auto_check_signatures
2557                                          = checkbtn_auto_check_signatures;
2558         privacy.checkbtn_gpg_signature_popup
2559                                          = checkbtn_gpg_signature_popup;
2560         privacy.checkbtn_store_passphrase    = checkbtn_store_passphrase;
2561         privacy.spinbtn_store_passphrase     = spinbtn_store_passphrase;
2562         privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
2563         privacy.checkbtn_passphrase_grab = checkbtn_passphrase_grab;
2564         privacy.checkbtn_gpg_warning     = checkbtn_gpg_warning;
2565         privacy.optmenu_default_signkey  = optmenu;
2566 }
2567
2568 static void
2569 prefs_common_default_signkey_set_data_from_optmenu(PrefParam *pparam)
2570 {
2571 #if 0
2572         GtkWidget *menu;
2573         GtkWidget *menuitem;
2574         gchar *charset;
2575
2576         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2577         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2578         charset = gtk_object_get_user_data(GTK_OBJECT(menuitem));
2579         g_free(*((gchar **)pparam->data));
2580         *((gchar **)pparam->data) = g_strdup(charset);
2581 #endif
2582 }
2583
2584 static void prefs_common_default_signkey_set_optmenu(PrefParam *pparam)
2585 {
2586 #if 0
2587         GList *cur;
2588         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2589         GtkWidget *menu;
2590         GtkWidget *menuitem;
2591         gchar *charset;
2592         gint n = 0;
2593
2594         g_return_if_fail(optmenu != NULL);
2595         g_return_if_fail(*((gchar **)pparam->data) != NULL);
2596
2597         menu = gtk_option_menu_get_menu(optmenu);
2598         for (cur = GTK_MENU_SHELL(menu)->children;
2599              cur != NULL; cur = cur->next) {
2600                 menuitem = GTK_WIDGET(cur->data);
2601                 charset = gtk_object_get_user_data(GTK_OBJECT(menuitem));
2602                 if (!strcmp(charset, *((gchar **)pparam->data))) {
2603                         gtk_option_menu_set_history(optmenu, n);
2604                         return;
2605                 }
2606                 n++;
2607         }
2608
2609         gtk_option_menu_set_history(optmenu, 0);
2610         prefs_common_charset_set_data_from_optmenu(pparam);
2611 #endif
2612 }
2613 #endif /* USE_GPGME */
2614
2615 static void prefs_interface_create(void)
2616 {
2617         GtkWidget *vbox1;
2618         GtkWidget *vbox2;
2619         GtkWidget *vbox3;
2620         /* GtkWidget *checkbtn_emacs; */
2621         GtkWidget *checkbtn_show_msg_with_cursor;
2622         GtkWidget *checkbtn_openunread;
2623         GtkWidget *checkbtn_openinbox;
2624         GtkWidget *checkbtn_immedexec;
2625         GtkWidget *hbox1;
2626         GtkWidget *label;
2627         GtkWidget *optmenu_recvdialog;
2628         GtkWidget *menu;
2629         GtkWidget *menuitem;
2630
2631         GtkWidget *frame_addr;
2632         GtkWidget *vbox_addr;
2633         GtkWidget *checkbtn_addaddrbyclick;
2634
2635         GtkWidget *button_keybind;
2636
2637         GtkWidget *hbox2;
2638         GtkWidget *optmenu_nextunreadmsgdialog;
2639         GtkWidget *optmenu_nextunreadmsgdialog_menu;
2640         GtkWidget *nextunreadmsgdialog_menuitem;
2641
2642         GtkWidget *frame_pixmap_theme;
2643         GtkWidget *vbox_pixmap_theme;
2644         GtkWidget *entry_pixmap_theme;
2645         GtkWidget *combo_pixmap_theme;
2646         GList *avail_pixmap_themes = NULL;
2647
2648         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2649         gtk_widget_show (vbox1);
2650         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2651         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2652
2653         vbox2 = gtk_vbox_new (FALSE, 0);
2654         gtk_widget_show (vbox2);
2655         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2656
2657         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
2658                            _("Emulate the behavior of mouse operation of\n"
2659                              "Emacs-based mailer"));
2660         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
2661                                GTK_JUSTIFY_LEFT);   */
2662
2663         PACK_CHECK_BUTTON
2664                 (vbox2, checkbtn_show_msg_with_cursor,
2665                  _("Open message when cursor keys are pressed on summary"));
2666
2667         PACK_CHECK_BUTTON
2668                 (vbox2, checkbtn_openunread,
2669                  _("Open first unread message when entering a folder"));
2670
2671         PACK_CHECK_BUTTON
2672                 (vbox2, checkbtn_openinbox,
2673                  _("Go to inbox after receiving new mail"));
2674
2675         vbox3 = gtk_vbox_new (FALSE, 0);
2676         gtk_widget_show (vbox3);
2677         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2678
2679         PACK_CHECK_BUTTON
2680                 (vbox3, checkbtn_immedexec,
2681                  _("Execute immediately when moving or deleting messages"));
2682
2683         hbox1 = gtk_hbox_new (FALSE, 0);
2684         gtk_widget_show (hbox1);
2685         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2686
2687         label = gtk_label_new
2688                 (_("(Messages will be marked until execution\n"
2689                    " if this is turned off)"));
2690         gtk_widget_show (label);
2691         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 8);
2692         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2693
2694         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
2695
2696         hbox1 = gtk_hbox_new (FALSE, 8);
2697         gtk_widget_show (hbox1);
2698         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2699
2700         label = gtk_label_new (_("Show receive dialog"));
2701         gtk_widget_show (label);
2702         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2703
2704         optmenu_recvdialog = gtk_option_menu_new ();
2705         gtk_widget_show (optmenu_recvdialog);
2706         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_recvdialog,
2707                             FALSE, FALSE, 0);
2708
2709         menu = gtk_menu_new ();
2710         MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
2711         MENUITEM_ADD (menu, menuitem, _("Only if a window is active"),
2712                       RECV_DIALOG_ACTIVE);
2713         MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
2714
2715         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
2716
2717         PACK_FRAME (vbox1, frame_addr, _("Address book"));
2718
2719         vbox_addr = gtk_vbox_new (FALSE, 0);
2720         gtk_widget_show (vbox_addr);
2721         gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2722         gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2723
2724         PACK_CHECK_BUTTON
2725                 (vbox_addr, checkbtn_addaddrbyclick,
2726                  _("Add address to destination when double-clicked"));
2727
2728         /* Next Unread Message Dialog */
2729         hbox2 = gtk_hbox_new (FALSE, 8);
2730         gtk_widget_show (hbox2);
2731         gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
2732
2733         label = gtk_label_new (_("Show no-unread-message dialog"));
2734         gtk_widget_show (label);
2735         gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
2736
2737         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
2738         gtk_widget_show (optmenu_nextunreadmsgdialog);
2739         gtk_box_pack_start (GTK_BOX (hbox2), optmenu_nextunreadmsgdialog,
2740                             FALSE, FALSE, 0);
2741
2742         optmenu_nextunreadmsgdialog_menu = gtk_menu_new ();
2743         MENUITEM_ADD (optmenu_nextunreadmsgdialog_menu, nextunreadmsgdialog_menuitem,
2744                       _("Always"),  NEXTUNREADMSGDIALOG_ALWAYS);
2745         MENUITEM_ADD (optmenu_nextunreadmsgdialog_menu, nextunreadmsgdialog_menuitem,
2746                       _("Assume 'Yes'"),  NEXTUNREADMSGDIALOG_ASSUME_YES);
2747         MENUITEM_ADD (optmenu_nextunreadmsgdialog_menu, nextunreadmsgdialog_menuitem,
2748                       _("Assume 'No'"), NEXTUNREADMSGDIALOG_ASSUME_NO);
2749
2750         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog),
2751                                   optmenu_nextunreadmsgdialog_menu);
2752
2753
2754         /* Receive Dialog */
2755 /*      hbox = gtk_hbox_new (FALSE, 8);
2756         gtk_widget_show (hbox);
2757         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2758
2759         label = gtk_label_new (_("Show receive Dialog"));
2760         gtk_widget_show (label);
2761         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2762
2763         recvdialog_optmenu = gtk_option_menu_new ();
2764         gtk_widget_show (recvdialog_optmenu);
2765         gtk_box_pack_start (GTK_BOX (hbox), recvdialog_optmenu, FALSE, FALSE, 0);
2766
2767         recvdialog_optmenu_menu = gtk_menu_new ();
2768
2769         MENUITEM_ADD (recvdialog_optmenu_menu, recvdialog_menuitem, _("Always"),  RECVDIALOG_ALWAYS);
2770         MENUITEM_ADD (recvdialog_optmenu_menu, recvdialog_menuitem, _("Only if a sylpheed window is active"),  RECVDIALOG_WINDOW_ACTIVE);
2771         MENUITEM_ADD (recvdialog_optmenu_menu, recvdialog_menuitem, _("Never"), RECVDIALOG_NEVER);
2772
2773         gtk_option_menu_set_menu (GTK_OPTION_MENU (recvdialog_optmenu), recvdialog_optmenu_menu);     */
2774
2775         hbox1 = gtk_hbox_new (FALSE, 8);
2776         gtk_widget_show (hbox1);
2777         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2778
2779         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2780         gtk_widget_show (button_keybind);
2781         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2782         gtk_signal_connect (GTK_OBJECT (button_keybind), "clicked",
2783                             GTK_SIGNAL_FUNC (prefs_keybind_select), NULL);
2784
2785         PACK_FRAME(vbox1, frame_pixmap_theme, _("Pixmap theme"));
2786         
2787         vbox_pixmap_theme = gtk_vbox_new(FALSE, 0);
2788         gtk_widget_show(vbox_pixmap_theme);
2789         gtk_container_add(GTK_CONTAINER(frame_pixmap_theme), vbox_pixmap_theme);
2790         gtk_container_set_border_width(GTK_CONTAINER(vbox_pixmap_theme), 8);
2791  
2792         avail_pixmap_themes = stock_pixmap_themes_list_new(); 
2793  
2794         combo_pixmap_theme = gtk_combo_new ();
2795         gtk_widget_show (combo_pixmap_theme);
2796         gtk_box_pack_start (GTK_BOX (vbox_pixmap_theme), combo_pixmap_theme, TRUE, TRUE, 0);
2797         gtk_combo_set_popdown_strings(GTK_COMBO(combo_pixmap_theme), avail_pixmap_themes);
2798         entry_pixmap_theme = GTK_COMBO (combo_pixmap_theme)->entry;
2799
2800         stock_pixmap_themes_list_free(avail_pixmap_themes);
2801
2802         /* interface.checkbtn_emacs          = checkbtn_emacs; */
2803         interface.checkbtn_show_msg_with_cursor
2804                                               = checkbtn_show_msg_with_cursor;
2805         interface.checkbtn_openunread         = checkbtn_openunread;
2806         interface.checkbtn_openinbox          = checkbtn_openinbox;
2807         interface.checkbtn_immedexec          = checkbtn_immedexec;
2808         interface.optmenu_recvdialog          = optmenu_recvdialog;
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 }     */