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