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