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