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