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