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