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