2004-11-18 [paul] 0.9.12cvs158.1
[claws.git] / src / prefs_common.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2004 Hiroyuki Yamamoto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28 #include <gdk/gdkkeysyms.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <unistd.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <errno.h>
36
37 #include "intl.h"
38 #include "main.h"
39 #include "prefs_gtk.h"
40 #include "prefs_common.h"
41 #include "prefs_display_header.h"
42 #include "prefs_summary_column.h"
43 #include "mainwindow.h"
44 #include "summaryview.h"
45 #include "messageview.h"
46 #include "manage_window.h"
47 #include "inc.h"
48 #include "menu.h"
49 #include "codeconv.h"
50 #include "utils.h"
51 #include "gtkutils.h"
52 #include "alertpanel.h"
53 #include "folder.h"
54 #include "socket.h"
55 #include "filesel.h"
56 #include "folderview.h"
57 #include "stock_pixmap.h"
58 #include "quote_fmt.h"
59 #include "prefswindow.h"
60
61 PrefsCommon prefs_common;
62
63 GtkWidget *notebook;
64
65 static struct Receive {
66         GtkWidget *checkbtn_incext;
67         GtkWidget *entry_incext;
68         GtkWidget *button_incext;
69
70         GtkWidget *checkbtn_autochk;
71         GtkWidget *spinbtn_autochk;
72         GtkObject *spinbtn_autochk_adj;
73
74         GtkWidget *checkbtn_chkonstartup;
75         GtkWidget *checkbtn_scan_after_inc;
76
77
78         GtkWidget *checkbtn_newmail_auto;
79         GtkWidget *checkbtn_newmail_manu;
80         GtkWidget *entry_newmail_notify_cmd;
81         GtkWidget *hbox_newmail_notify;
82         GtkWidget *optmenu_recvdialog;
83         GtkWidget *checkbtn_no_recv_err_panel;
84         GtkWidget *checkbtn_close_recv_dialog;
85 } receive;
86
87 static struct Send {
88         GtkWidget *checkbtn_savemsg;
89         GtkWidget *optmenu_senddialog;
90
91         GtkWidget *optmenu_charset;
92         GtkWidget *optmenu_encoding_method;
93 } p_send;
94
95 static struct Compose {
96         GtkWidget *entry_fw_quotemark;
97         GtkWidget *text_fw_quotefmt;
98
99         GtkWidget *checkbtn_autoextedit;
100         GtkWidget *spinbtn_undolevel;
101         GtkObject *spinbtn_undolevel_adj;
102
103         GtkWidget *checkbtn_reply_account_autosel;
104         GtkWidget *checkbtn_forward_account_autosel;
105         GtkWidget *checkbtn_reedit_account_autosel;
106         GtkWidget *checkbtn_quote;
107         GtkWidget *checkbtn_default_reply_list;
108         GtkWidget *checkbtn_forward_as_attachment;
109         GtkWidget *checkbtn_redirect_keep_from;
110         GtkWidget *checkbtn_reply_with_quote;
111         
112         GtkWidget *checkbtn_autosave;
113         GtkWidget *entry_autosave_length;
114 } compose;
115
116 static struct Quote {
117         GtkWidget *entry_quotemark;
118         GtkWidget *text_quotefmt;
119
120         GtkWidget *entry_fw_quotemark;
121         GtkWidget *text_fw_quotefmt;
122         
123         GtkWidget *entry_quote_chars;
124 } quote;
125
126 static struct Display {
127         GtkWidget *chkbtn_folder_unread;
128         GtkWidget *entry_ng_abbrev_len;
129         GtkWidget *spinbtn_ng_abbrev_len;
130         GtkObject *spinbtn_ng_abbrev_len_adj;
131
132         GtkWidget *chkbtn_transhdr;
133
134         GtkWidget *chkbtn_swapfrom;
135         GtkWidget *chkbtn_useaddrbook;
136         GtkWidget *chkbtn_threadsubj;
137         GtkWidget *entry_datefmt;
138 } display;
139
140 static struct Message {
141         GtkWidget *chkbtn_mbalnum;
142         GtkWidget *chkbtn_disphdrpane;
143         GtkWidget *chkbtn_disphdr;
144         GtkWidget *spinbtn_linespc;
145         GtkObject *spinbtn_linespc_adj;
146         GtkWidget *chkbtn_headspc;
147
148         GtkWidget *chkbtn_smoothscroll;
149         GtkWidget *spinbtn_scrollstep;
150         GtkObject *spinbtn_scrollstep_adj;
151         GtkWidget *chkbtn_halfpage;
152
153         GtkWidget *chkbtn_attach_desc;
154 } message;
155
156 static struct Interface {
157         /* GtkWidget *checkbtn_emacs; */
158         GtkWidget *checkbtn_always_show_msg;
159         GtkWidget *checkbtn_openunread;
160         GtkWidget *checkbtn_mark_as_read_on_newwin;
161         GtkWidget *checkbtn_openinbox;
162         GtkWidget *checkbtn_immedexec;
163         GtkWidget *optmenu_nextunreadmsgdialog;
164 } interface;
165
166 static struct Other {
167         GtkWidget *checkbtn_addaddrbyclick;
168         GtkWidget *checkbtn_confonexit;
169         GtkWidget *checkbtn_cleanonexit;
170         GtkWidget *checkbtn_askonclean;
171         GtkWidget *checkbtn_warnqueued;
172         GtkWidget *checkbtn_cliplog;
173         GtkWidget *loglength_entry;
174 #if 0
175 #ifdef USE_OPENSSL
176         GtkWidget *checkbtn_ssl_ask_unknown_valid;
177 #endif
178 #endif
179
180         GtkWidget *spinbtn_iotimeout;
181         GtkObject *spinbtn_iotimeout_adj;
182 } other;
183
184 static struct KeybindDialog {
185         GtkWidget *window;
186         GtkWidget *combo;
187 } keybind;
188
189 static void prefs_common_charset_set_data_from_optmenu     (PrefParam *pparam);
190 static void prefs_common_charset_set_optmenu               (PrefParam *pparam);
191 static void prefs_common_encoding_set_data_from_optmenu    (PrefParam *pparam);
192 static void prefs_common_encoding_set_optmenu              (PrefParam *pparam);
193 static void prefs_common_recv_dialog_set_data_from_optmenu (PrefParam *pparam);
194 static void prefs_common_recv_dialog_set_optmenu           (PrefParam *pparam);
195 static void prefs_common_recv_dialog_newmail_notify_toggle_cb   (GtkWidget *w,
196                                                                  gpointer data);
197 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam);
198 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam);
199 static void prefs_common_send_dialog_set_data_from_optmenu(PrefParam *pparam);
200 static void prefs_common_send_dialog_set_optmenu(PrefParam *pparam);
201 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam);
202 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam);
203
204 /*
205    parameter name, default value, pointer to the prefs variable, data type,
206    pointer to the widget pointer,
207    pointer to the function for data setting,
208    pointer to the function for widget setting
209  */
210
211 static PrefParam param[] = {
212         /* Receive */
213         {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL,
214          &receive.checkbtn_incext,
215          prefs_set_data_from_toggle, prefs_set_toggle},
216         {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING,
217          &receive.entry_incext,
218          prefs_set_data_from_entry, prefs_set_entry},
219
220         {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL,
221          &receive.checkbtn_autochk,
222          prefs_set_data_from_toggle, prefs_set_toggle},
223         {"autochk_interval", "10", &prefs_common.autochk_itv, P_INT,
224          &receive.spinbtn_autochk,
225          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
226         {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL,
227          &receive.checkbtn_chkonstartup,
228          prefs_set_data_from_toggle, prefs_set_toggle},
229         {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
230          P_BOOL, &receive.checkbtn_scan_after_inc,
231          prefs_set_data_from_toggle, prefs_set_toggle},
232         {"newmail_notify_manu", "FALSE", &prefs_common.newmail_notify_manu,
233          P_BOOL, &receive.checkbtn_newmail_manu,
234          prefs_set_data_from_toggle, prefs_set_toggle},
235         {"newmail_notify_auto", "FALSE", &prefs_common.newmail_notify_auto,
236         P_BOOL, &receive.checkbtn_newmail_auto,
237          prefs_set_data_from_toggle, prefs_set_toggle},
238         {"newmail_notify_cmd", "", &prefs_common.newmail_notify_cmd, P_STRING,
239          &receive.entry_newmail_notify_cmd,
240          prefs_set_data_from_entry, prefs_set_entry},
241         {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM,
242          &receive.optmenu_recvdialog,
243          prefs_common_recv_dialog_set_data_from_optmenu,
244          prefs_common_recv_dialog_set_optmenu},
245         {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel,
246          P_BOOL, &receive.checkbtn_no_recv_err_panel,
247          prefs_set_data_from_toggle, prefs_set_toggle},
248         {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog,
249          P_BOOL, &receive.checkbtn_close_recv_dialog,
250          prefs_set_data_from_toggle, prefs_set_toggle},
251  
252         /* Send */
253         {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL,
254          &p_send.checkbtn_savemsg,
255          prefs_set_data_from_toggle, prefs_set_toggle},
256         {"send_dialog_mode", "0", &prefs_common.send_dialog_mode, P_ENUM,
257          &p_send.optmenu_senddialog,
258          prefs_common_send_dialog_set_data_from_optmenu,
259          prefs_common_send_dialog_set_optmenu},
260
261         {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
262          &p_send.optmenu_charset,
263          prefs_common_charset_set_data_from_optmenu,
264          prefs_common_charset_set_optmenu},
265         {"encoding_method", "0", &prefs_common.encoding_method, P_ENUM,
266          &p_send.optmenu_encoding_method,
267          prefs_common_encoding_set_data_from_optmenu,
268          prefs_common_encoding_set_optmenu},
269
270         {"allow_jisx0201_kana", "FALSE", &prefs_common.allow_jisx0201_kana,
271          P_BOOL, NULL, NULL, NULL},
272
273         /* Compose */
274         {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL,
275          &compose.checkbtn_autoextedit,
276          prefs_set_data_from_toggle, prefs_set_toggle},
277         {"forward_as_attachment", "FALSE", &prefs_common.forward_as_attachment,
278          P_BOOL, &compose.checkbtn_forward_as_attachment,
279          prefs_set_data_from_toggle, prefs_set_toggle},
280         {"redirect_keep_from", "FALSE",
281          &prefs_common.redirect_keep_from, P_BOOL,
282          &compose.checkbtn_redirect_keep_from,
283          prefs_set_data_from_toggle, prefs_set_toggle},
284         {"undo_level", "50", &prefs_common.undolevels, P_INT,
285          &compose.spinbtn_undolevel,
286          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
287
288         {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT,
289          NULL, NULL, NULL},
290         {"linewrap_quotation", "TRUE", &prefs_common.linewrap_quote, P_BOOL,
291          NULL, NULL, NULL},
292         {"linewrap_auto", "TRUE", &prefs_common.autowrap, P_BOOL,
293          NULL, NULL, NULL},
294         {"linewrap_before_sending", "FALSE", &prefs_common.linewrap_at_send, P_BOOL, 
295          NULL, NULL, NULL},
296         {"autosave", "FALSE", &prefs_common.autosave,
297          P_BOOL, &compose.checkbtn_autosave,
298          prefs_set_data_from_toggle, prefs_set_toggle},
299         {"autosave_length", "50", &prefs_common.autosave_length,
300          P_INT, &compose.entry_autosave_length,
301          prefs_set_data_from_entry, prefs_set_entry},
302 #if USE_ASPELL
303         {"enable_aspell", "TRUE", &prefs_common.enable_aspell, P_BOOL,
304          NULL, NULL, NULL},
305         {"aspell_path", ASPELL_PATH, &prefs_common.aspell_path, P_STRING,
306          NULL, NULL, NULL},
307         {"dictionary",  "", &prefs_common.dictionary, P_STRING,
308          NULL, NULL, NULL},
309         {"aspell_sugmode", "1", &prefs_common.aspell_sugmode, P_INT,
310          NULL, NULL, NULL},
311         {"use_alternate_dict", "FALSE", &prefs_common.use_alternate, P_BOOL,
312          NULL, NULL, NULL},
313         {"check_while_typing", "TRUE", &prefs_common.check_while_typing, P_BOOL,
314          NULL, NULL, NULL},
315         {"misspelled_color", "16711680", &prefs_common.misspelled_col, P_COLOR,
316          NULL, NULL, NULL},
317 #endif
318         {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
319          &compose.checkbtn_reply_with_quote, prefs_set_data_from_toggle, prefs_set_toggle},
320
321         /* Account autoselection */
322         {"reply_account_autoselect", "TRUE",
323          &prefs_common.reply_account_autosel, P_BOOL,
324          &compose.checkbtn_reply_account_autosel,
325          prefs_set_data_from_toggle, prefs_set_toggle},
326         {"forward_account_autoselect", "TRUE",
327          &prefs_common.forward_account_autosel, P_BOOL,
328          &compose.checkbtn_forward_account_autosel,
329          prefs_set_data_from_toggle, prefs_set_toggle},
330         {"reedit_account_autoselect", "TRUE",
331          &prefs_common.reedit_account_autosel, P_BOOL,
332          &compose.checkbtn_reedit_account_autosel,
333          prefs_set_data_from_toggle, prefs_set_toggle},
334
335         {"default_reply_list", "TRUE", &prefs_common.default_reply_list, P_BOOL,
336          &compose.checkbtn_default_reply_list,
337          prefs_set_data_from_toggle, prefs_set_toggle},
338
339         {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
340          NULL, NULL, NULL},
341
342         /* Quote */
343         {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
344          &quote.entry_quotemark, prefs_set_data_from_entry, prefs_set_entry},
345         {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q",
346          &prefs_common.quotefmt, P_STRING, &quote.text_quotefmt,
347          prefs_set_data_from_text, prefs_set_text},
348
349         {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING,
350          &quote.entry_fw_quotemark,
351          prefs_set_data_from_entry, prefs_set_entry},
352         {"forward_quote_format",
353          "\\n\\nBegin forwarded message:\\n\\n"
354          "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
355          "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M",
356          &prefs_common.fw_quotefmt, P_STRING, &quote.text_fw_quotefmt,
357          prefs_set_data_from_text, prefs_set_text},
358         {"quote_chars", ">", &prefs_common.quote_chars, P_STRING,
359          &quote.entry_quote_chars, prefs_set_data_from_entry, prefs_set_entry},
360
361         /* Display */
362         /* Obsolete fonts. For coexisting with Gtk+-1.2 version */
363         {"widget_font",         NULL,
364           &prefs_common.widgetfont_gtk1,        P_STRING, NULL, NULL, NULL},
365         {"message_font",        "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*",
366          &prefs_common.textfont_gtk1,           P_STRING, NULL, NULL, NULL},
367         {"small_font",          "-*-helvetica-medium-r-normal--10-*-*-*-*-*-*-*",
368           &prefs_common.smallfont_gtk1,         P_STRING, NULL, NULL, NULL},
369         {"bold_font",           "-*-helvetica-bold-r-normal--12-*-*-*-*-*-*-*",
370           &prefs_common.boldfont_gtk1,          P_STRING, NULL, NULL, NULL},
371         {"normal_font",         "-*-helvetica-medium-r-normal--12-*-*-*-*-*-*-*",
372           &prefs_common.normalfont_gtk1,        P_STRING, NULL, NULL, NULL},
373
374         /* new fonts */
375         {"widget_font_gtk2",    NULL,
376           &prefs_common.widgetfont,             P_STRING, NULL, NULL, NULL},
377         {"message_font_gtk2",   "fixed 9",
378          &prefs_common.textfont,                P_STRING, NULL, NULL, NULL},
379         {"small_font_gtk2",     "Sans 9",
380           &prefs_common.smallfont,              P_STRING, NULL, NULL, NULL},
381         {"bold_font_gtk2",      "Sans Bold 9",
382           &prefs_common.boldfont,               P_STRING, NULL, NULL, NULL},
383         {"normal_font_gtk2",    "Sans 9", 
384           &prefs_common.normalfont,             P_STRING, NULL, NULL, NULL},
385
386         {"display_folder_unread_num", "TRUE",
387          &prefs_common.display_folder_unread, P_BOOL,
388          &display.chkbtn_folder_unread,
389          prefs_set_data_from_toggle, prefs_set_toggle},
390         {"newsgroup_abbrev_len", "16",
391          &prefs_common.ng_abbrev_len, P_INT,
392          &display.spinbtn_ng_abbrev_len,
393          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
394
395         {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL,
396          &display.chkbtn_transhdr,
397          prefs_set_data_from_toggle, prefs_set_toggle},
398
399         /* Display: Summary View */
400         {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
401          &display.chkbtn_swapfrom,
402          prefs_set_data_from_toggle, prefs_set_toggle},
403         {"use_address_book", "TRUE", &prefs_common.use_addr_book, P_BOOL,
404          &display.chkbtn_useaddrbook,
405          prefs_set_data_from_toggle, prefs_set_toggle},
406         {"thread_by_subject", "TRUE", &prefs_common.thread_by_subject, P_BOOL,
407          &display.chkbtn_threadsubj,
408          prefs_set_data_from_toggle, prefs_set_toggle},
409         {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
410          P_STRING, &display.entry_datefmt,
411          prefs_set_data_from_entry, prefs_set_entry},
412
413         {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
414          NULL, NULL, NULL},
415         {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL,
416          NULL, NULL, NULL},
417         {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
418         P_INT, NULL, NULL, NULL },
419
420         {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL,
421          NULL, NULL, NULL},
422         {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM,
423          NULL, NULL, NULL},
424         {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
425          NULL, NULL, NULL},
426         {"show_searchbar", "TRUE", &prefs_common.show_searchbar, P_BOOL,
427          NULL, NULL, NULL},
428
429         {"folderview_vscrollbar_policy", "0",
430          &prefs_common.folderview_vscrollbar_policy, P_ENUM,
431          NULL, NULL, NULL},
432
433         {"summary_col_show_mark", "TRUE",
434          &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL, NULL, NULL, NULL},
435         {"summary_col_show_unread", "TRUE",
436          &prefs_common.summary_col_visible[S_COL_STATUS], P_BOOL, NULL, NULL, NULL},
437         {"summary_col_show_mime", "TRUE",
438          &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
439         {"summary_col_show_subject", "TRUE",
440          &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL, NULL, NULL, NULL},
441         {"summary_col_show_from", "TRUE",
442          &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL, NULL, NULL, NULL},
443         {"summary_col_show_date", "TRUE",
444          &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL, NULL, NULL, NULL},
445         {"summary_col_show_size", "TRUE",
446          &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL, NULL, NULL, NULL},
447         {"summary_col_show_number", "FALSE",
448          &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL, NULL, NULL, NULL},
449         {"summary_col_show_score", "FALSE",
450          &prefs_common.summary_col_visible[S_COL_SCORE], P_BOOL, NULL, NULL, NULL},
451         {"summary_col_show_locked", "FALSE",
452          &prefs_common.summary_col_visible[S_COL_LOCKED], P_BOOL, NULL, NULL, NULL},
453
454         {"summary_col_pos_mark", "0",
455           &prefs_common.summary_col_pos[S_COL_MARK], P_INT, NULL, NULL, NULL},
456         {"summary_col_pos_unread", "1",
457           &prefs_common.summary_col_pos[S_COL_STATUS], P_INT, NULL, NULL, NULL},
458         {"summary_col_pos_mime", "2",
459           &prefs_common.summary_col_pos[S_COL_MIME], P_INT, NULL, NULL, NULL},
460         {"summary_col_pos_subject", "3",
461           &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
462         {"summary_col_pos_from", "4",
463           &prefs_common.summary_col_pos[S_COL_FROM], P_INT, NULL, NULL, NULL},
464         {"summary_col_pos_date", "5",
465           &prefs_common.summary_col_pos[S_COL_DATE], P_INT, NULL, NULL, NULL},
466         {"summary_col_pos_size", "6",
467           &prefs_common.summary_col_pos[S_COL_SIZE], P_INT, NULL, NULL, NULL},
468         {"summary_col_pos_number", "7",
469           &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
470         {"summary_col_pos_score", "8",
471          &prefs_common.summary_col_pos[S_COL_SCORE], P_INT, NULL, NULL, NULL},
472         {"summary_col_pos_locked", "9",
473          &prefs_common.summary_col_pos[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
474
475         {"summary_col_size_mark", "10",
476          &prefs_common.summary_col_size[S_COL_MARK], P_INT, NULL, NULL, NULL},
477         {"summary_col_size_unread", "13",
478          &prefs_common.summary_col_size[S_COL_STATUS], P_INT, NULL, NULL, NULL},
479         {"summary_col_size_mime", "10",
480          &prefs_common.summary_col_size[S_COL_MIME], P_INT, NULL, NULL, NULL},
481         {"summary_col_size_subject", "200",
482          &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
483         {"summary_col_size_from", "120",
484          &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
485         {"summary_col_size_date", "118",
486          &prefs_common.summary_col_size[S_COL_DATE], P_INT, NULL, NULL, NULL},
487         {"summary_col_size_size", "45",
488          &prefs_common.summary_col_size[S_COL_SIZE], P_INT, NULL, NULL, NULL},
489         {"summary_col_size_number", "40",
490          &prefs_common.summary_col_size[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
491         {"summary_col_size_score", "40",
492          &prefs_common.summary_col_size[S_COL_SCORE], P_INT, NULL, NULL, NULL},
493         {"summary_col_size_locked", "13",
494          &prefs_common.summary_col_size[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
495
496         /* Widget size */
497         {"folderwin_x", "16", &prefs_common.folderwin_x, P_INT,
498          NULL, NULL, NULL},
499         {"folderwin_y", "16", &prefs_common.folderwin_y, P_INT,
500          NULL, NULL, NULL},
501         {"folderview_width", "179", &prefs_common.folderview_width, P_INT,
502          NULL, NULL, NULL},
503         {"folderview_height", "450", &prefs_common.folderview_height, P_INT,
504          NULL, NULL, NULL},
505         {"folderview_visible", "TRUE", &prefs_common.folderview_visible, P_BOOL,
506          NULL, NULL, NULL},
507
508         {"folder_col_folder", "150", &prefs_common.folder_col_folder, P_INT,
509          NULL, NULL, NULL},
510         {"folder_col_new", "32", &prefs_common.folder_col_new, P_INT,
511          NULL, NULL, NULL},
512         {"folder_col_unread", "32", &prefs_common.folder_col_unread, P_INT,
513          NULL, NULL, NULL},
514         {"folder_col_total", "32", &prefs_common.folder_col_total, P_INT,
515          NULL, NULL, NULL},
516
517         {"summaryview_width", "600", &prefs_common.summaryview_width, P_INT,
518          NULL, NULL, NULL},
519         {"summaryview_height", "157", &prefs_common.summaryview_height, P_INT,
520          NULL, NULL, NULL},
521
522         {"main_messagewin_x", "256", &prefs_common.main_msgwin_x, P_INT,
523          NULL, NULL, NULL},
524         {"main_messagewin_y", "210", &prefs_common.main_msgwin_y, P_INT,
525          NULL, NULL, NULL},
526         {"messageview_width", "600", &prefs_common.msgview_width, P_INT,
527          NULL, NULL, NULL},
528         {"messageview_height", "300", &prefs_common.msgview_height, P_INT,
529          NULL, NULL, NULL},
530         {"messageview_visible", "TRUE", &prefs_common.msgview_visible, P_BOOL,
531          NULL, NULL, NULL},
532
533         {"mainview_x", "64", &prefs_common.mainview_x, P_INT,
534          NULL, NULL, NULL},
535         {"mainview_y", "64", &prefs_common.mainview_y, P_INT,
536          NULL, NULL, NULL},
537         {"mainview_width", "600", &prefs_common.mainview_width, P_INT,
538          NULL, NULL, NULL},
539         {"mainview_height", "600", &prefs_common.mainview_height, P_INT,
540          NULL, NULL, NULL},
541         {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT,
542          NULL, NULL, NULL},
543         {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT,
544          NULL, NULL, NULL},
545         {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT,
546          NULL, NULL, NULL},
547         {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT,
548          NULL, NULL, NULL},
549         {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT,
550          NULL, NULL, NULL},
551         {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT,
552          NULL, NULL, NULL},
553         {"sourcewin_width", "600", &prefs_common.sourcewin_width, P_INT,
554          NULL, NULL, NULL},
555         {"sourcewin_height", "500", &prefs_common.sourcewin_height, P_INT,
556          NULL, NULL, NULL},
557         {"compose_width", "600", &prefs_common.compose_width, P_INT,
558          NULL, NULL, NULL},
559         {"compose_height", "560", &prefs_common.compose_height, P_INT,
560          NULL, NULL, NULL},
561         {"compose_x", "0", &prefs_common.compose_x, P_INT,
562          NULL, NULL, NULL},
563         {"compose_y", "0", &prefs_common.compose_y, P_INT,
564          NULL, NULL, NULL},
565         /* Message */
566         {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
567          NULL, NULL, NULL},
568
569         {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_COLOR,
570          NULL, NULL, NULL},
571         {"quote_level2_color", "179", &prefs_common.quote_level2_col, P_COLOR,
572          NULL, NULL, NULL},
573         {"quote_level3_color", "179", &prefs_common.quote_level3_col, P_COLOR,
574          NULL, NULL, NULL},
575         {"uri_color", "32512", &prefs_common.uri_col, P_COLOR,
576          NULL, NULL, NULL},
577         {"target_folder_color", "14294218", &prefs_common.tgt_folder_col, P_COLOR,
578          NULL, NULL, NULL},
579         {"signature_color", "7960953", &prefs_common.signature_col, P_COLOR,
580          NULL, NULL, NULL},
581         {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
582          P_BOOL, NULL, NULL, NULL},
583
584         {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL,
585          &message.chkbtn_mbalnum,
586          prefs_set_data_from_toggle, prefs_set_toggle},
587         {"display_header_pane", "TRUE", &prefs_common.display_header_pane,
588          P_BOOL, &message.chkbtn_disphdrpane,
589          prefs_set_data_from_toggle, prefs_set_toggle},
590         {"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
591          &message.chkbtn_disphdr,
592          prefs_set_data_from_toggle, prefs_set_toggle},
593         {"line_space", "2", &prefs_common.line_space, P_INT,
594          &message.spinbtn_linespc,
595          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
596         {"enable_head_space", "FALSE", &prefs_common.head_space, P_BOOL,
597          &message.chkbtn_headspc,
598          prefs_set_data_from_toggle, prefs_set_toggle},
599
600         {"enable_smooth_scroll", "FALSE",
601          &prefs_common.enable_smooth_scroll, P_BOOL,
602          &message.chkbtn_smoothscroll,
603          prefs_set_data_from_toggle, prefs_set_toggle},
604         {"scroll_step", "1", &prefs_common.scroll_step, P_INT,
605          &message.spinbtn_scrollstep,
606          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
607         {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL,
608          &message.chkbtn_halfpage,
609          prefs_set_data_from_toggle, prefs_set_toggle},
610
611         {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
612          NULL, NULL, NULL},
613
614         {"attach_desc", "TRUE", &prefs_common.attach_desc, P_BOOL,
615          &message.chkbtn_attach_desc,
616          prefs_set_data_from_toggle, prefs_set_toggle},
617         {"attach_save_directory", NULL,
618          &prefs_common.attach_save_dir, P_STRING, NULL, NULL, NULL},
619
620         /* MIME viewer */
621         {"mime_image_viewer", "display '%s'",
622          &prefs_common.mime_image_viewer, P_STRING, NULL, NULL, NULL},
623         {"mime_audio_player", "play '%s'",
624          &prefs_common.mime_audio_player, P_STRING, NULL, NULL, NULL},
625         {"mime_open_command", "gedit '%s'",
626          &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL},
627
628         /* Interface */
629         {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL,
630          NULL, NULL, NULL},
631         {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL,
632          NULL, NULL, NULL},
633
634         /* {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
635          NULL, NULL, NULL}, */
636         {"always_show_message_when_selected", "FALSE",
637          &prefs_common.always_show_msg,
638          P_BOOL, &interface.checkbtn_always_show_msg,
639          prefs_set_data_from_toggle, prefs_set_toggle},
640         {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter,
641          P_BOOL, &interface.checkbtn_openunread,
642          prefs_set_data_from_toggle, prefs_set_toggle},
643         {"mark_as_read_on_new_window", "FALSE",
644          &prefs_common.mark_as_read_on_new_window,
645          P_BOOL, &interface.checkbtn_mark_as_read_on_newwin,
646          prefs_set_data_from_toggle, prefs_set_toggle},
647         {"mark_as_read_delay", "0",
648          &prefs_common.mark_as_read_delay, P_INT, 
649          NULL, NULL, NULL},
650         {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc,
651          P_BOOL, &interface.checkbtn_openinbox,
652          prefs_set_data_from_toggle, prefs_set_toggle},
653         {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL,
654          &interface.checkbtn_immedexec,
655          prefs_set_data_from_toggle, prefs_set_toggle},
656         {"nextunreadmsg_dialog", NULL, &prefs_common.next_unread_msg_dialog, P_ENUM,
657          &interface.optmenu_nextunreadmsgdialog,
658          prefs_nextunreadmsgdialog_set_data_from_optmenu,
659          prefs_nextunreadmsgdialog_set_optmenu},
660
661         {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
662          &prefs_common.pixmap_theme_path, P_STRING,
663          NULL, NULL, NULL},
664
665         {"hover_timeout", "500", &prefs_common.hover_timeout, P_INT,
666          NULL, NULL, NULL},
667         
668         /* Other */
669         {"uri_open_command", DEFAULT_BROWSER_CMD,
670          &prefs_common.uri_cmd, P_STRING, NULL, NULL, NULL},
671         {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING,
672          NULL, NULL, NULL},
673         {"ext_editor_command", "gedit %s",
674          &prefs_common.ext_editor_cmd, P_STRING, NULL, NULL, NULL},
675
676         {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
677          P_BOOL, &other.checkbtn_addaddrbyclick,
678          prefs_set_data_from_toggle, prefs_set_toggle},
679
680         {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL,
681          &other.checkbtn_confonexit,
682          prefs_set_data_from_toggle, prefs_set_toggle},
683         {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL,
684          &other.checkbtn_cleanonexit,
685          prefs_set_data_from_toggle, prefs_set_toggle},
686         {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL,
687          &other.checkbtn_askonclean,
688          prefs_set_data_from_toggle, prefs_set_toggle},
689         {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
690          P_BOOL, &other.checkbtn_warnqueued,
691          prefs_set_data_from_toggle, prefs_set_toggle},
692 #if 0
693 #ifdef USE_OPENSSL
694         {"ssl_ask_unknown_valid", "TRUE", &prefs_common.ssl_ask_unknown_valid,
695          P_BOOL, &other.checkbtn_ssl_ask_unknown_valid,
696          prefs_set_data_from_toggle, prefs_set_toggle},
697 #endif
698 #endif
699         {"work_offline", "FALSE", &prefs_common.work_offline, P_BOOL,
700          NULL, NULL, NULL},
701         {"summary_quicksearch_type", "0", &prefs_common.summary_quicksearch_type, P_INT,
702          NULL, NULL, NULL},
703         {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
704          NULL, NULL, NULL},
705
706         {"io_timeout_secs", "60", &prefs_common.io_timeout_secs,
707          P_INT, &other.spinbtn_iotimeout,
708          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
709         {"hide_score", "-9999", &prefs_common.kill_score, P_INT,
710          NULL, NULL, NULL},
711         {"important_score", "1", &prefs_common.important_score, P_INT,
712          NULL, NULL, NULL},
713         {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
714          &other.checkbtn_cliplog,
715          prefs_set_data_from_toggle, prefs_set_toggle},
716         {"log_length", "500", &prefs_common.loglength, P_INT,
717          &other.loglength_entry,
718          prefs_set_data_from_entry, prefs_set_entry},
719
720         {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
721          NULL, NULL, NULL},
722         {"cache_min_keep_time", "15", &prefs_common.cache_min_keep_time, P_INT,
723          NULL, NULL, NULL},
724
725         {"color_new", "179", &prefs_common.color_new, P_COLOR,
726          NULL, NULL, NULL},
727
728         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
729 };
730
731 /* widget creating functions */
732 static void prefs_common_create         (void);
733 static void prefs_receive_create        (void);
734 static void prefs_send_create           (void);
735 static void prefs_compose_create        (void);
736 static void prefs_quote_create          (void);
737 static void prefs_display_create        (void);
738 static void prefs_message_create        (void);
739 static void prefs_interface_create      (void);
740 static void prefs_other_create          (void);
741
742 static void date_format_ok_btn_clicked          (GtkButton      *button,
743                                                  GtkWidget     **widget);
744 static void date_format_cancel_btn_clicked      (GtkButton      *button,
745                                                  GtkWidget     **widget);
746 static gboolean date_format_key_pressed         (GtkWidget      *keywidget,
747                                                  GdkEventKey    *event,
748                                                  GtkWidget     **widget);
749 static gboolean date_format_on_delete           (GtkWidget      *dialogwidget,
750                                                  GdkEventAny    *event,
751                                                  GtkWidget     **widget);
752 static void date_format_entry_on_change         (GtkEditable    *editable,
753                                                  GtkLabel       *example);
754 static void date_format_select_row              (GtkWidget      *date_format_list,
755                                                  gint            row,
756                                                  gint            column,
757                                                  GdkEventButton *event,
758                                                  GtkWidget      *date_format);
759 static GtkWidget *date_format_create            (GtkButton      *button,
760                                                  void           *data);
761
762 static void prefs_keybind_select                (void);
763 static gint prefs_keybind_deleted               (GtkWidget      *widget,
764                                                  GdkEventAny    *event,
765                                                  gpointer        data);
766 static gboolean prefs_keybind_key_pressed       (GtkWidget      *widget,
767                                                  GdkEventKey    *event,
768                                                  gpointer        data);
769 static void prefs_keybind_cancel                (void);
770 static void prefs_keybind_apply_clicked         (GtkWidget      *widget);
771
772 static void prefs_common_apply          (void);
773
774 typedef struct CommonPage
775 {
776         PrefsPage page;
777  
778         GtkWidget *vbox;
779 } CommonPage;
780
781 static CommonPage common_page;
782
783 static void create_widget_func(PrefsPage * _page,
784                                            GtkWindow * window,
785                                            gpointer data)
786 {
787         CommonPage *page = (CommonPage *) _page;
788         GtkWidget *vbox;
789
790         vbox = gtk_vbox_new(FALSE, 6);
791         gtk_widget_show(vbox);
792
793         if (notebook == NULL)
794                 prefs_common_create();
795         gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
796         gtk_notebook_set_page(GTK_NOTEBOOK(notebook), 0);
797
798         prefs_set_dialog(param);
799
800         page->vbox = vbox;
801
802         page->page.widget = vbox;
803 }
804
805 static void destroy_widget_func(PrefsPage *_page)
806 {
807         CommonPage *page = (CommonPage *) _page;
808
809         gtk_container_remove(GTK_CONTAINER (page->vbox), notebook);
810 }
811
812 static void save_func(PrefsPage * _page)
813 {
814         prefs_common_apply();
815 }
816
817 void prefs_common_init(void) 
818 {
819         static gchar *path[2];
820
821         prefs_common.disphdr_list = NULL;
822             
823         path[0] = _("Common");
824         path[2] = NULL;
825         
826         common_page.page.path = path;
827         common_page.page.weight = 1000.0;
828         common_page.page.create_widget = create_widget_func;
829         common_page.page.destroy_widget = destroy_widget_func;
830         common_page.page.save_page = save_func;
831
832         prefs_gtk_register_page((PrefsPage *) &common_page);
833 }
834
835 PrefsCommon *prefs_common_get(void)
836 {
837         return &prefs_common;
838 }
839
840 /*
841  * Read history list from the specified history file
842  */
843 GList *prefs_common_read_history(const gchar *history) 
844 {
845         FILE *fp;
846         gchar *path;
847         gchar buf[PREFSBUFSIZE];
848         GList *tmp = NULL;
849
850         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
851                            NULL);
852         if ((fp = fopen(path, "rb")) == NULL) {
853                 if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
854                 g_free(path);
855                 return NULL;
856         }
857         g_free(path);
858         while (fgets(buf, sizeof(buf), fp) != NULL) {
859                 g_strstrip(buf);
860                 if (buf[0] == '\0') continue;
861                 tmp = add_history(tmp, buf);
862         }
863         fclose(fp);
864
865         tmp = g_list_reverse(tmp);
866
867         return tmp;
868 }
869
870 void prefs_common_read_config(void)
871 {
872         prefs_read_config(param, "Common", COMMON_RC);
873
874         prefs_common.mime_open_cmd_history =
875                 prefs_common_read_history(COMMAND_HISTORY);
876         prefs_common.summary_quicksearch_history =
877                 prefs_common_read_history(QUICKSEARCH_HISTORY);
878 }
879
880 /*
881  * Save history list to the specified history file
882  */
883 void prefs_common_save_history(const gchar *history, GList *list)
884 {
885         GList *cur;
886         FILE *fp;
887         gchar *path;
888
889         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
890                            NULL);
891         if ((fp = fopen(path, "wb")) == NULL) {
892                 FILE_OP_ERROR(path, "fopen");
893                 g_free(path);
894                 return;
895         }
896
897         for (cur = list; cur != NULL; cur = cur->next) {
898                 fputs((gchar *)cur->data, fp);
899                 fputc('\n', fp);
900         }
901
902         fclose(fp);
903         g_free(path);
904 }
905
906 void prefs_common_write_config(void)
907 {
908         prefs_write_config(param, "Common", COMMON_RC);
909
910         prefs_common_save_history(COMMAND_HISTORY, 
911                 prefs_common.mime_open_cmd_history);
912         prefs_common_save_history(QUICKSEARCH_HISTORY, 
913                 prefs_common.summary_quicksearch_history);
914 }
915
916 static void prefs_common_create(void)
917 {
918         gint page = 0;
919
920         debug_print("Creating common preferences window...\n");
921
922         notebook = gtk_notebook_new ();
923         gtk_widget_show(notebook);
924         gtk_container_set_border_width (GTK_CONTAINER (notebook), 2);
925         /* GTK_WIDGET_UNSET_FLAGS (notebook, GTK_CAN_FOCUS); */
926         gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
927         
928         gtk_notebook_popup_enable (GTK_NOTEBOOK (notebook));
929
930         gtk_widget_ref(notebook);
931
932         /* create all widgets on notebook */
933         prefs_receive_create();
934         SET_NOTEBOOK_LABEL(notebook, _("Receive"),   page++);
935         prefs_send_create();
936         SET_NOTEBOOK_LABEL(notebook, _("Send"),      page++);
937         prefs_compose_create();
938         SET_NOTEBOOK_LABEL(notebook, _("Compose"),   page++);
939         prefs_quote_create();
940         SET_NOTEBOOK_LABEL(notebook, _("Quote"),     page++);
941         prefs_display_create();
942         SET_NOTEBOOK_LABEL(notebook, _("Display"),   page++);
943         prefs_message_create();
944         SET_NOTEBOOK_LABEL(notebook, _("Message"),   page++);
945         prefs_interface_create();
946         SET_NOTEBOOK_LABEL(notebook, _("Interface"), page++);
947         prefs_other_create();
948         SET_NOTEBOOK_LABEL(notebook, _("Other"),     page++);
949
950         gtk_widget_show_all(notebook);
951 }
952
953 static void prefs_receive_create(void)
954 {
955         GtkWidget *vbox1;
956         GtkWidget *vbox2;
957         GtkWidget *frame_incext;
958         GtkWidget *checkbtn_incext;
959         GtkWidget *hbox;
960         GtkWidget *label_incext;
961         GtkWidget *entry_incext;
962         /* GtkWidget *button_incext; */
963
964         GtkWidget *hbox_autochk;
965         GtkWidget *checkbtn_autochk;
966         GtkWidget *label_autochk1;
967         GtkObject *spinbtn_autochk_adj;
968         GtkWidget *spinbtn_autochk;
969         GtkWidget *label_autochk2;
970         GtkWidget *checkbtn_chkonstartup;
971         GtkWidget *checkbtn_scan_after_inc;
972
973
974         GtkWidget *frame_newmail;
975         GtkWidget *hbox_newmail_notify;
976         GtkWidget *checkbtn_newmail_auto;
977         GtkWidget *checkbtn_newmail_manu;
978         GtkWidget *entry_newmail_notify_cmd;
979         GtkWidget *label_newmail_notify_cmd;
980
981         GtkWidget *hbox_recvdialog;
982         GtkWidget *label_recvdialog;
983         GtkWidget *menu;
984         GtkWidget *menuitem;
985         GtkWidget *optmenu_recvdialog;
986         GtkWidget *checkbtn_no_recv_err_panel;
987         GtkWidget *checkbtn_close_recv_dialog;
988
989         vbox1 = gtk_vbox_new (FALSE, VSPACING);
990         gtk_widget_show (vbox1);
991         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
992         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
993
994         PACK_FRAME(vbox1, frame_incext, _("External program"));
995
996         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
997         gtk_widget_show (vbox2);
998         gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
999         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1000
1001         /* Use of external incorporation program */
1002         PACK_CHECK_BUTTON (vbox2, checkbtn_incext,
1003                            _("Use external program for incorporation"));
1004
1005         hbox = gtk_hbox_new (FALSE, 8);
1006         gtk_widget_show (hbox);
1007         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1008         SET_TOGGLE_SENSITIVITY (checkbtn_incext, hbox);
1009
1010         label_incext = gtk_label_new (_("Command"));
1011         gtk_widget_show (label_incext);
1012         gtk_box_pack_start (GTK_BOX (hbox), label_incext, FALSE, FALSE, 0);
1013
1014         entry_incext = gtk_entry_new ();
1015         gtk_widget_show (entry_incext);
1016         gtk_box_pack_start (GTK_BOX (hbox), entry_incext, TRUE, TRUE, 0);
1017
1018 #if 0
1019         button_incext = gtk_button_new_with_label ("... ");
1020         gtk_widget_show (button_incext);
1021         gtk_box_pack_start (GTK_BOX (hbox), button_incext, FALSE, FALSE, 0);
1022 #endif
1023
1024         vbox2 = gtk_vbox_new (FALSE, 0);
1025         gtk_widget_show (vbox2);
1026         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1027
1028         /* Auto-checking */
1029         hbox_autochk = gtk_hbox_new (FALSE, 8);
1030         gtk_widget_show (hbox_autochk);
1031         gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
1032
1033         PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
1034                            _("Auto-check new mail"));
1035
1036         label_autochk1 = gtk_label_new (_("every"));
1037         gtk_widget_show (label_autochk1);
1038         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
1039
1040         spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
1041         spinbtn_autochk = gtk_spin_button_new
1042                 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
1043         gtk_widget_show (spinbtn_autochk);
1044         gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
1045         gtk_widget_set_size_request (spinbtn_autochk, 64, -1);
1046         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
1047
1048         label_autochk2 = gtk_label_new (_("minute(s)"));
1049         gtk_widget_show (label_autochk2);
1050         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
1051
1052         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
1053         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
1054         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
1055
1056         PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
1057                            _("Check new mail on startup"));
1058         PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
1059                            _("Update all local folders after incorporation"));
1060
1061
1062         /* receive dialog */
1063         hbox_recvdialog = gtk_hbox_new (FALSE, 8);
1064         gtk_widget_show (hbox_recvdialog);
1065         gtk_box_pack_start (GTK_BOX (vbox2), hbox_recvdialog, FALSE, FALSE, 0);
1066
1067         label_recvdialog = gtk_label_new (_("Show receive dialog"));
1068         gtk_misc_set_alignment(GTK_MISC(label_recvdialog), 0, 0.5);
1069         gtk_widget_show (label_recvdialog);
1070         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), label_recvdialog, FALSE, FALSE, 0);
1071
1072         optmenu_recvdialog = gtk_option_menu_new ();
1073         gtk_widget_show (optmenu_recvdialog);
1074         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), optmenu_recvdialog, FALSE, FALSE, 0);
1075
1076         menu = gtk_menu_new ();
1077         MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
1078         MENUITEM_ADD (menu, menuitem, _("Only on manual receiving"),
1079                       RECV_DIALOG_MANUAL);
1080         MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
1081
1082         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
1083
1084         PACK_CHECK_BUTTON (vbox2, checkbtn_no_recv_err_panel,
1085                            _("Don't popup error dialog on receive error"));
1086
1087         PACK_CHECK_BUTTON (vbox2, checkbtn_close_recv_dialog,
1088                            _("Close receive dialog when finished"));
1089         
1090         PACK_FRAME(vbox1, frame_newmail, _("Run command when new mail "
1091                                            "arrives"));
1092         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1093         gtk_widget_show (vbox2);
1094         gtk_container_add (GTK_CONTAINER (frame_newmail), vbox2);
1095         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1096
1097         hbox = gtk_hbox_new (TRUE, 8);
1098         gtk_widget_show (hbox);
1099         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_auto,
1100                            _("after autochecking"));
1101         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_manu,
1102                            _("after manual checking"));
1103         gtk_box_pack_start (GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
1104         g_signal_connect(G_OBJECT(checkbtn_newmail_auto), "toggled",
1105                          G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1106                          NULL);
1107         g_signal_connect(G_OBJECT(checkbtn_newmail_manu), "toggled",
1108                          G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1109                          NULL);
1110
1111         hbox_newmail_notify = gtk_hbox_new (FALSE, 8);
1112         gtk_widget_show (hbox);
1113         gtk_box_pack_start (GTK_BOX (vbox2), hbox_newmail_notify, FALSE, 
1114                             FALSE, 0);
1115
1116         label_newmail_notify_cmd = gtk_label_new (_("Command to execute:\n"
1117                                                     "(use %d as number of new "
1118                                                     "mails)"));
1119         gtk_label_set_justify(GTK_LABEL(label_newmail_notify_cmd), 
1120                               GTK_JUSTIFY_RIGHT);
1121         gtk_widget_show (label_newmail_notify_cmd);
1122         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1123                             label_newmail_notify_cmd, FALSE, FALSE, 0);
1124
1125         entry_newmail_notify_cmd = gtk_entry_new ();
1126         gtk_widget_show (entry_newmail_notify_cmd);
1127         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1128                             entry_newmail_notify_cmd, TRUE, TRUE, 0);
1129
1130         gtk_widget_set_sensitive(hbox_newmail_notify, 
1131                                  prefs_common.newmail_notify_auto || 
1132                                  prefs_common.newmail_notify_manu);
1133
1134         receive.checkbtn_incext = checkbtn_incext;
1135         receive.entry_incext    = entry_incext;
1136         /* receive.button_incext   = button_incext; */
1137
1138         receive.checkbtn_autochk    = checkbtn_autochk;
1139         receive.spinbtn_autochk     = spinbtn_autochk;
1140         receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1141
1142         receive.checkbtn_chkonstartup = checkbtn_chkonstartup;
1143         receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1144
1145
1146         receive.checkbtn_newmail_auto  = checkbtn_newmail_auto;
1147         receive.checkbtn_newmail_manu  = checkbtn_newmail_manu;
1148         receive.hbox_newmail_notify    = hbox_newmail_notify;
1149         receive.entry_newmail_notify_cmd = entry_newmail_notify_cmd;
1150         receive.optmenu_recvdialog          = optmenu_recvdialog;
1151         receive.checkbtn_no_recv_err_panel  = checkbtn_no_recv_err_panel;
1152         receive.checkbtn_close_recv_dialog  = checkbtn_close_recv_dialog;
1153 }
1154
1155 static void prefs_send_create(void)
1156 {
1157         GtkWidget *vbox1;
1158         GtkWidget *vbox2;
1159         GtkWidget *hbox1;
1160         GtkWidget *checkbtn_savemsg;
1161         GtkWidget *label_outcharset;
1162         GtkWidget *optmenu_charset;
1163         GtkWidget *optmenu_menu;
1164         GtkWidget *menuitem;
1165         GtkTooltips *charset_tooltip;
1166         GtkWidget *optmenu_encoding;
1167         GtkWidget *label_encoding;
1168         GtkTooltips *encoding_tooltip;
1169         GtkWidget *label_senddialog;
1170         GtkWidget *menu;
1171         GtkWidget *optmenu_senddialog;
1172         GtkWidget *hbox_senddialog;
1173
1174         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1175         gtk_widget_show (vbox1);
1176         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1177         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1178
1179         vbox2 = gtk_vbox_new (FALSE, 0);
1180         gtk_widget_show (vbox2);
1181         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1182
1183         PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1184                            _("Save sent messages to Sent folder"));
1185
1186         hbox_senddialog = gtk_hbox_new (FALSE, 8);
1187         gtk_box_pack_start (GTK_BOX (vbox1), hbox_senddialog, FALSE, FALSE, 0);
1188
1189         label_senddialog = gtk_label_new (_("Show send dialog"));
1190         gtk_widget_show (label_senddialog);
1191         gtk_box_pack_start (GTK_BOX (hbox_senddialog), label_senddialog, FALSE, FALSE, 0);
1192
1193         optmenu_senddialog = gtk_option_menu_new ();
1194         gtk_widget_show (optmenu_senddialog);
1195         gtk_box_pack_start (GTK_BOX (hbox_senddialog), optmenu_senddialog, FALSE, FALSE, 0);
1196         
1197         menu = gtk_menu_new ();
1198         MENUITEM_ADD (menu, menuitem, _("Always"), SEND_DIALOG_ALWAYS);
1199         MENUITEM_ADD (menu, menuitem, _("Never"), SEND_DIALOG_NEVER);
1200
1201         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_senddialog), menu);
1202
1203         hbox1 = gtk_hbox_new (FALSE, 8);
1204         gtk_widget_show (hbox1);
1205         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1206
1207         label_outcharset = gtk_label_new (_("Outgoing codeset"));
1208         gtk_widget_show (label_outcharset);
1209         gtk_box_pack_start (GTK_BOX (hbox1), label_outcharset, FALSE, FALSE, 0);
1210
1211         charset_tooltip = gtk_tooltips_new();
1212
1213         optmenu_charset = gtk_option_menu_new ();
1214         gtk_widget_show (optmenu_charset);
1215         gtk_tooltips_set_tip(GTK_TOOLTIPS(charset_tooltip), optmenu_charset,
1216                              _("If `Automatic' is selected, the optimal encoding"
1217                                " for the current locale will be used"),
1218                              NULL);
1219         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_charset, FALSE, FALSE, 0);
1220
1221         optmenu_menu = gtk_menu_new ();
1222
1223 #define SET_MENUITEM(str, data) \
1224 { \
1225         MENUITEM_ADD(optmenu_menu, menuitem, str, data); \
1226 }
1227
1228         SET_MENUITEM(_("Automatic (Recommended)"),       CS_AUTO);
1229         SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
1230 #if HAVE_ICONV
1231         SET_MENUITEM(_("Unicode (UTF-8)"),               CS_UTF_8);
1232 #endif
1233         SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
1234         SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
1235         SET_MENUITEM(_("Central European (ISO-8859-2)"),  CS_ISO_8859_2);
1236         SET_MENUITEM(_("Baltic (ISO-8859-13)"),           CS_ISO_8859_13);
1237         SET_MENUITEM(_("Baltic (ISO-8859-4)"),            CS_ISO_8859_4);
1238         SET_MENUITEM(_("Greek (ISO-8859-7)"),             CS_ISO_8859_7);
1239         SET_MENUITEM(_("Turkish (ISO-8859-9)"),           CS_ISO_8859_9);
1240 #if HAVE_ICONV
1241         SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
1242 #endif
1243         SET_MENUITEM(_("Cyrillic (KOI8-R)"),             CS_KOI8_R);
1244 #if HAVE_ICONV
1245         SET_MENUITEM(_("Cyrillic (Windows-1251)"),       CS_WINDOWS_1251);
1246         SET_MENUITEM(_("Cyrillic (KOI8-U)"),             CS_KOI8_U);
1247 #endif
1248         SET_MENUITEM(_("Japanese (ISO-2022-JP)"),        CS_ISO_2022_JP);
1249 #if 0
1250         SET_MENUITEM(_("Japanese (EUC-JP)"),             CS_EUC_JP);
1251         SET_MENUITEM(_("Japanese (Shift_JIS)"),          CS_SHIFT_JIS);
1252 #endif /* 0 */
1253         SET_MENUITEM(_("Simplified Chinese (GB2312)"),   CS_GB2312);
1254         SET_MENUITEM(_("Traditional Chinese (Big5)"),    CS_BIG5);
1255 #if 0
1256         SET_MENUITEM(_("Traditional Chinese (EUC-TW)"),  CS_EUC_TW);
1257         SET_MENUITEM(_("Chinese (ISO-2022-CN)"),         CS_ISO_2022_CN);
1258 #endif /* 0 */
1259         SET_MENUITEM(_("Korean (EUC-KR)"),               CS_EUC_KR);
1260         SET_MENUITEM(_("Thai (TIS-620)"),                CS_TIS_620);
1261         SET_MENUITEM(_("Thai (Windows-874)"),            CS_WINDOWS_874);
1262
1263         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_charset),
1264                                   optmenu_menu);
1265
1266         hbox1 = gtk_hbox_new (FALSE, 8);
1267         gtk_widget_show (hbox1);
1268         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1269
1270         hbox1 = gtk_hbox_new (FALSE, 8);
1271         gtk_widget_show (hbox1);
1272         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1273
1274         label_encoding = gtk_label_new (_("Transfer encoding"));
1275         gtk_widget_show (label_encoding);
1276         gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
1277
1278         encoding_tooltip = gtk_tooltips_new();
1279
1280         optmenu_encoding = gtk_option_menu_new ();
1281         gtk_widget_show (optmenu_encoding);
1282         gtk_tooltips_set_tip(GTK_TOOLTIPS(encoding_tooltip), optmenu_encoding,
1283                              _("Specify Content-Transfer-Encoding used when"
1284                                " message body contains non-ASCII characters"),
1285                              NULL);
1286         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_encoding, FALSE, FALSE, 0);
1287
1288         optmenu_menu = gtk_menu_new ();
1289
1290         SET_MENUITEM(_("Automatic"),     CTE_AUTO);
1291         SET_MENUITEM("base64",           CTE_BASE64);
1292         SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
1293         SET_MENUITEM("8bit",             CTE_8BIT);
1294
1295         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_encoding),
1296                                   optmenu_menu);
1297
1298         hbox1 = gtk_hbox_new (FALSE, 8);
1299         gtk_widget_show (hbox1);
1300         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1301
1302         p_send.checkbtn_savemsg  = checkbtn_savemsg;
1303         p_send.optmenu_senddialog = optmenu_senddialog;
1304
1305         p_send.optmenu_charset = optmenu_charset;
1306         p_send.optmenu_encoding_method = optmenu_encoding;
1307 }
1308
1309 static void prefs_common_recv_dialog_newmail_notify_toggle_cb(GtkWidget *w, gpointer data)
1310 {
1311         gboolean toggled;
1312
1313         toggled = gtk_toggle_button_get_active
1314                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_manu)) ||
1315                   gtk_toggle_button_get_active
1316                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_auto));
1317         gtk_widget_set_sensitive(receive.hbox_newmail_notify, toggled);
1318 }
1319
1320 static void prefs_compose_create(void)
1321 {
1322         GtkWidget *vbox1;
1323         GtkWidget *vbox2;
1324
1325         GtkWidget *checkbtn_autoextedit;
1326
1327         GtkWidget *frame_autosel;
1328         GtkWidget *hbox_autosel;
1329         GtkWidget *checkbtn_reply_account_autosel;
1330         GtkWidget *checkbtn_forward_account_autosel;
1331         GtkWidget *checkbtn_reedit_account_autosel;
1332
1333         GtkWidget *hbox_undolevel;
1334         GtkWidget *label_undolevel;
1335         GtkObject *spinbtn_undolevel_adj;
1336         GtkWidget *spinbtn_undolevel;
1337
1338         GtkWidget *hbox5;
1339
1340         GtkWidget *checkbtn_default_reply_list;
1341
1342         GtkWidget *checkbtn_forward_as_attachment;
1343         GtkWidget *checkbtn_redirect_keep_from;
1344
1345         GtkWidget *hbox_autosave;
1346         GtkWidget *checkbtn_autosave;
1347         GtkWidget *entry_autosave_length;
1348         GtkWidget *label_autosave_length;
1349         
1350         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1351         gtk_widget_show (vbox1);
1352         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1353         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1354
1355         /* Account autoselection */
1356         PACK_FRAME(vbox1, frame_autosel, _("Automatic account selection"));
1357
1358         hbox_autosel = gtk_hbox_new (FALSE, VSPACING_NARROW);
1359         gtk_widget_show (hbox_autosel);
1360         gtk_container_add (GTK_CONTAINER (frame_autosel), hbox_autosel);
1361         gtk_container_set_border_width (GTK_CONTAINER (hbox_autosel), 8);
1362
1363         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reply_account_autosel,
1364                            _("when replying"));
1365         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_forward_account_autosel,
1366                            _("when forwarding"));
1367         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reedit_account_autosel,
1368                            _("when re-editing"));
1369
1370         vbox2 = gtk_vbox_new (FALSE, 0);
1371         gtk_widget_show (vbox2);
1372         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1373
1374         PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
1375                            _("Reply button invokes mailing list reply"));
1376
1377         PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1378                            _("Automatically launch the external editor"));
1379
1380         hbox5 = gtk_hbox_new (FALSE, 8);
1381         gtk_widget_show (hbox5);
1382         gtk_box_pack_start (GTK_BOX (vbox2), hbox5, FALSE, FALSE, 0);
1383
1384         PACK_CHECK_BUTTON (hbox5, checkbtn_forward_as_attachment,
1385                            _("Forward as attachment"));
1386
1387         PACK_CHECK_BUTTON (vbox2, checkbtn_redirect_keep_from,
1388                            _("Keep the original 'From' header when redirecting"));
1389
1390         
1391         hbox_autosave = gtk_hbox_new (FALSE, 8);
1392         gtk_widget_show (hbox_autosave);
1393         gtk_box_pack_start (GTK_BOX (vbox1), hbox_autosave, FALSE, FALSE, 0);
1394         
1395         PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
1396                            _("Autosave to Drafts folder every "));
1397
1398         entry_autosave_length = gtk_entry_new();
1399         gtk_widget_set_size_request (entry_autosave_length, 64, -1);    
1400         gtk_widget_show (entry_autosave_length);
1401         gtk_box_pack_start (GTK_BOX (hbox_autosave), entry_autosave_length, FALSE, FALSE, 0);
1402         
1403         label_autosave_length = gtk_label_new(_("characters"));
1404         gtk_widget_show (label_autosave_length);
1405         gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave_length, FALSE, FALSE, 0);
1406         
1407         hbox_undolevel = gtk_hbox_new (FALSE, 8);
1408         gtk_widget_show (hbox_undolevel);
1409         gtk_box_pack_start (GTK_BOX (vbox1), hbox_undolevel, FALSE, FALSE, 0);
1410
1411         label_undolevel = gtk_label_new (_("Undo level"));
1412         gtk_widget_show (label_undolevel);
1413         gtk_box_pack_start (GTK_BOX (hbox_undolevel), label_undolevel, FALSE, FALSE, 0);
1414
1415         spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 10);
1416         spinbtn_undolevel = gtk_spin_button_new
1417                 (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1418         gtk_widget_show (spinbtn_undolevel);
1419         gtk_box_pack_start (GTK_BOX (hbox_undolevel), spinbtn_undolevel, FALSE, FALSE, 0);
1420         gtk_widget_set_size_request (spinbtn_undolevel, 64, -1);
1421         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1422
1423        /*
1424         compose.checkbtn_quote   = checkbtn_quote;
1425         compose.entry_quotemark  = entry_quotemark;
1426         compose.text_quotefmt    = text_quotefmt;
1427         */
1428
1429         compose.checkbtn_autoextedit = checkbtn_autoextedit;
1430
1431         compose.checkbtn_reply_account_autosel   = checkbtn_reply_account_autosel;
1432         compose.checkbtn_forward_account_autosel = checkbtn_forward_account_autosel;
1433         compose.checkbtn_reedit_account_autosel  = checkbtn_reedit_account_autosel;
1434
1435         compose.spinbtn_undolevel     = spinbtn_undolevel;
1436         compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1437
1438         compose.checkbtn_autosave     = checkbtn_autosave;
1439         compose.entry_autosave_length = entry_autosave_length;
1440         
1441         compose.checkbtn_forward_as_attachment =
1442                 checkbtn_forward_as_attachment;
1443         compose.checkbtn_redirect_keep_from =
1444                 checkbtn_redirect_keep_from;
1445         compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
1446 }
1447
1448 static void prefs_quote_create(void)
1449 {
1450         GtkWidget *vbox1;
1451         GtkWidget *frame_quote;
1452         GtkWidget *vbox_quote;
1453         GtkWidget *hbox1;
1454         GtkWidget *hbox2;
1455         GtkWidget *label_quotemark;
1456         GtkWidget *entry_quotemark;
1457         GtkWidget *scrolledwin_quotefmt;
1458         GtkWidget *text_quotefmt;
1459
1460         GtkWidget *entry_fw_quotemark;
1461         GtkWidget *text_fw_quotefmt;
1462
1463         GtkWidget *entry_quote_chars;
1464         GtkWidget *label_quote_chars;
1465         
1466         GtkWidget *btn_quotedesc;
1467
1468         GtkWidget *checkbtn_reply_with_quote;
1469
1470         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1471         gtk_widget_show (vbox1);
1472         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1473         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1474
1475         /* reply */
1476
1477         PACK_CHECK_BUTTON (vbox1, checkbtn_reply_with_quote, _("Reply will quote by default"));
1478
1479         PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1480
1481         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1482         gtk_widget_show (vbox_quote);
1483         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1484         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1485
1486         hbox1 = gtk_hbox_new (FALSE, 32);
1487         gtk_widget_show (hbox1);
1488         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1489
1490         hbox2 = gtk_hbox_new (FALSE, 8);
1491         gtk_widget_show (hbox2);
1492         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1493
1494         label_quotemark = gtk_label_new (_("Quotation mark"));
1495         gtk_widget_show (label_quotemark);
1496         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1497
1498         entry_quotemark = gtk_entry_new ();
1499         gtk_widget_show (entry_quotemark);
1500         gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1501         gtk_widget_set_size_request (entry_quotemark, 64, -1);
1502
1503         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1504         gtk_widget_show (scrolledwin_quotefmt);
1505         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1506         gtk_scrolled_window_set_policy
1507                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1508                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1509
1510         text_quotefmt = gtk_text_view_new ();
1511         gtk_widget_show (text_quotefmt);
1512         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1513         gtk_text_view_set_editable (GTK_TEXT_VIEW(text_quotefmt), TRUE);
1514         gtk_widget_set_size_request(text_quotefmt, -1, 60);
1515
1516         /* forward */
1517
1518         PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1519
1520         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1521         gtk_widget_show (vbox_quote);
1522         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1523         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1524
1525         hbox1 = gtk_hbox_new (FALSE, 32);
1526         gtk_widget_show (hbox1);
1527         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1528
1529         hbox2 = gtk_hbox_new (FALSE, 8);
1530         gtk_widget_show (hbox2);
1531         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1532
1533         label_quotemark = gtk_label_new (_("Quotation mark"));
1534         gtk_widget_show (label_quotemark);
1535         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1536
1537         entry_fw_quotemark = gtk_entry_new ();
1538         gtk_widget_show (entry_fw_quotemark);
1539         gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1540                             FALSE, FALSE, 0);
1541         gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
1542
1543         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1544         gtk_widget_show (scrolledwin_quotefmt);
1545         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1546         gtk_scrolled_window_set_policy
1547                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1548                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1549
1550         text_fw_quotefmt = gtk_text_view_new ();
1551         gtk_widget_show (text_fw_quotefmt);
1552         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1553                           text_fw_quotefmt);
1554         gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
1555         gtk_widget_set_size_request(text_fw_quotefmt, -1, 60);
1556
1557         hbox1 = gtk_hbox_new (FALSE, 32);
1558         gtk_widget_show (hbox1);
1559         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1560
1561         btn_quotedesc =
1562                 gtk_button_new_with_label (_(" Description of symbols "));
1563         gtk_widget_show (btn_quotedesc);
1564         gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
1565         g_signal_connect(G_OBJECT(btn_quotedesc), "clicked",
1566                          G_CALLBACK(quote_fmt_quote_description), NULL);
1567
1568         /* quote chars */
1569
1570         PACK_FRAME (vbox1, frame_quote, _("Quotation characters"));
1571
1572         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1573         gtk_widget_show (vbox_quote);
1574         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1575         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1576
1577         hbox1 = gtk_hbox_new (FALSE, 32);
1578         gtk_widget_show (hbox1);
1579         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1580
1581         hbox2 = gtk_hbox_new (FALSE, 8);
1582         gtk_widget_show (hbox2);
1583         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1584
1585         label_quote_chars = gtk_label_new (_("Treat these characters as quotation marks: "));
1586         gtk_widget_show (label_quote_chars);
1587         gtk_box_pack_start (GTK_BOX (hbox2), label_quote_chars, FALSE, FALSE, 0);
1588
1589         entry_quote_chars = gtk_entry_new ();
1590         gtk_widget_show (entry_quote_chars);
1591         gtk_box_pack_start (GTK_BOX (hbox2), entry_quote_chars,
1592                             FALSE, FALSE, 0);
1593         gtk_widget_set_size_request (entry_quote_chars, 64, -1);
1594
1595
1596         compose.checkbtn_reply_with_quote= checkbtn_reply_with_quote;
1597         quote.entry_quotemark    = entry_quotemark;
1598         quote.text_quotefmt      = text_quotefmt;
1599         quote.entry_fw_quotemark = entry_fw_quotemark;
1600         quote.text_fw_quotefmt   = text_fw_quotefmt;
1601         quote.entry_quote_chars  = entry_quote_chars;
1602 }
1603
1604 static void prefs_display_create(void)
1605 {
1606         GtkWidget *vbox1;
1607         GtkWidget *chkbtn_transhdr;
1608         GtkWidget *chkbtn_folder_unread;
1609         GtkWidget *hbox1;
1610         GtkWidget *label_ng_abbrev;
1611         GtkWidget *spinbtn_ng_abbrev_len;
1612         GtkObject *spinbtn_ng_abbrev_len_adj;
1613         GtkWidget *frame_summary;
1614         GtkWidget *vbox2;
1615         GtkWidget *chkbtn_swapfrom;
1616         GtkWidget *chkbtn_useaddrbook;
1617         GtkWidget *chkbtn_threadsubj;
1618         GtkWidget *vbox3;
1619         GtkWidget *label_datefmt;
1620         GtkWidget *button_datefmt;
1621         GtkWidget *entry_datefmt;
1622         GtkWidget *button_dispitem;
1623
1624         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1625         gtk_widget_show (vbox1);
1626         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1627         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1628
1629         vbox2 = gtk_vbox_new (FALSE, 0);
1630         gtk_widget_show (vbox2);
1631         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
1632
1633         PACK_CHECK_BUTTON
1634                 (vbox2, chkbtn_transhdr,
1635                  _("Translate header name (such as `From:', `Subject:')"));
1636
1637         PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1638                            _("Display unread number next to folder name"));
1639
1640         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1641
1642         hbox1 = gtk_hbox_new (FALSE, 8);
1643         gtk_widget_show (hbox1);
1644         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1645
1646         label_ng_abbrev = gtk_label_new
1647                 (_("Abbreviate newsgroup names longer than"));
1648         gtk_widget_show (label_ng_abbrev);
1649         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1650
1651         spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
1652         spinbtn_ng_abbrev_len = gtk_spin_button_new
1653                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
1654         gtk_widget_show (spinbtn_ng_abbrev_len);
1655         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
1656                             FALSE, FALSE, 0);
1657         gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
1658         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
1659                                      TRUE);
1660
1661         label_ng_abbrev = gtk_label_new
1662                 (_("letters"));
1663         gtk_widget_show (label_ng_abbrev);
1664         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1665
1666         /* ---- Summary ---- */
1667
1668         PACK_FRAME(vbox1, frame_summary, _("Summary View"));
1669
1670         vbox2 = gtk_vbox_new (FALSE, 0);
1671         gtk_widget_show (vbox2);
1672         gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1673         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1674
1675         PACK_CHECK_BUTTON
1676                 (vbox2, chkbtn_swapfrom,
1677                  _("Display recipient in `From' column if sender is yourself"));
1678         PACK_CHECK_BUTTON
1679                 (vbox2, chkbtn_useaddrbook,
1680                  _("Display sender using address book"));
1681         PACK_CHECK_BUTTON
1682                 (vbox2, chkbtn_threadsubj,
1683                  _("Thread using subject in addition to standard headers"));
1684
1685         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1686
1687         hbox1 = gtk_hbox_new (FALSE, 8);
1688         gtk_widget_show (hbox1);
1689         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1690
1691         label_datefmt = gtk_label_new (_("Date format"));
1692         gtk_widget_show (label_datefmt);
1693         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1694
1695         entry_datefmt = gtk_entry_new ();
1696         gtk_widget_show (entry_datefmt);
1697         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1698
1699         button_datefmt = gtk_button_new_with_label (" ... ");
1700
1701         gtk_widget_show (button_datefmt);
1702         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
1703         g_signal_connect (G_OBJECT (button_datefmt), "clicked",
1704                           G_CALLBACK (date_format_create), NULL);
1705
1706         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1707
1708         hbox1 = gtk_hbox_new (FALSE, 8);
1709         gtk_widget_show (hbox1);
1710         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1711
1712         button_dispitem = gtk_button_new_with_label
1713                 (_(" Set displayed items in summary... "));
1714         gtk_widget_show (button_dispitem);
1715         gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
1716         g_signal_connect (G_OBJECT (button_dispitem), "clicked",
1717                           G_CALLBACK (prefs_summary_column_open),
1718                           NULL);
1719
1720         display.chkbtn_transhdr           = chkbtn_transhdr;
1721         display.chkbtn_folder_unread      = chkbtn_folder_unread;
1722         display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
1723         display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
1724
1725         display.chkbtn_swapfrom      = chkbtn_swapfrom;
1726         display.chkbtn_useaddrbook   = chkbtn_useaddrbook;
1727         display.chkbtn_threadsubj    = chkbtn_threadsubj;
1728         display.entry_datefmt        = entry_datefmt;
1729 }
1730
1731 static void prefs_message_create(void)
1732 {
1733         GtkWidget *vbox1;
1734         GtkWidget *vbox2;
1735         GtkWidget *vbox3;
1736         GtkWidget *hbox1;
1737         GtkWidget *chkbtn_mbalnum;
1738         GtkWidget *chkbtn_disphdrpane;
1739         GtkWidget *chkbtn_disphdr;
1740         GtkWidget *button_edit_disphdr;
1741         GtkWidget *hbox_linespc;
1742         GtkWidget *label_linespc;
1743         GtkObject *spinbtn_linespc_adj;
1744         GtkWidget *spinbtn_linespc;
1745         GtkWidget *chkbtn_headspc;
1746
1747         GtkWidget *frame_scr;
1748         GtkWidget *vbox_scr;
1749         GtkWidget *chkbtn_smoothscroll;
1750         GtkWidget *hbox_scr;
1751         GtkWidget *label_scr;
1752         GtkObject *spinbtn_scrollstep_adj;
1753         GtkWidget *spinbtn_scrollstep;
1754         GtkWidget *chkbtn_halfpage;
1755
1756         GtkWidget *chkbtn_attach_desc;
1757
1758         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1759         gtk_widget_show (vbox1);
1760         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1761         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1762
1763         vbox2 = gtk_vbox_new (FALSE, 0);
1764         gtk_widget_show (vbox2);
1765         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1766
1767         PACK_CHECK_BUTTON
1768                 (vbox2, chkbtn_mbalnum,
1769                  _("Display multi-byte alphanumeric as\n"
1770                    "ASCII character (Japanese only)"));
1771         gtk_label_set_justify (GTK_LABEL (GTK_BIN(chkbtn_mbalnum)->child),
1772                                GTK_JUSTIFY_LEFT);
1773
1774         PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1775                           _("Display header pane above message view"));
1776
1777         hbox1 = gtk_hbox_new (FALSE, 8);
1778         gtk_widget_show (hbox1);
1779         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1780
1781         PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1782                           _("Display short headers on message view"));
1783
1784         button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
1785         gtk_widget_show (button_edit_disphdr);
1786         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
1787                           FALSE, TRUE, 0);
1788         g_signal_connect (G_OBJECT (button_edit_disphdr), "clicked",
1789                           G_CALLBACK (prefs_display_header_open),
1790                           NULL);
1791
1792         SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1793
1794         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1795
1796         hbox1 = gtk_hbox_new (FALSE, 32);
1797         gtk_widget_show (hbox1);
1798         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1799
1800         hbox_linespc = gtk_hbox_new (FALSE, 8);
1801         gtk_widget_show (hbox1);
1802         gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
1803
1804         label_linespc = gtk_label_new (_("Line space"));
1805         gtk_widget_show (label_linespc);
1806         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1807                             FALSE, FALSE, 0);
1808
1809         spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
1810         spinbtn_linespc = gtk_spin_button_new
1811                 (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
1812         gtk_widget_show (spinbtn_linespc);
1813         gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
1814                             FALSE, FALSE, 0);
1815         gtk_widget_set_size_request (spinbtn_linespc, 64, -1);
1816         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
1817
1818         label_linespc = gtk_label_new (_("pixel(s)"));
1819         gtk_widget_show (label_linespc);
1820         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1821                             FALSE, FALSE, 0);
1822
1823         PACK_CHECK_BUTTON(hbox1, chkbtn_headspc, _("Indent text"));
1824
1825         PACK_FRAME(vbox1, frame_scr, _("Scroll"));
1826
1827         vbox_scr = gtk_vbox_new (FALSE, 0);
1828         gtk_widget_show (vbox_scr);
1829         gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
1830         gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
1831
1832         PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
1833
1834         hbox1 = gtk_hbox_new (FALSE, 32);
1835         gtk_widget_show (hbox1);
1836         gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
1837
1838         PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
1839
1840         hbox_scr = gtk_hbox_new (FALSE, 8);
1841         gtk_widget_show (hbox_scr);
1842         gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
1843
1844         label_scr = gtk_label_new (_("Step"));
1845         gtk_widget_show (label_scr);
1846         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1847
1848         spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
1849         spinbtn_scrollstep = gtk_spin_button_new
1850                 (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
1851         gtk_widget_show (spinbtn_scrollstep);
1852         gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
1853                             FALSE, FALSE, 0);
1854         gtk_widget_set_size_request (spinbtn_scrollstep, 64, -1);
1855         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
1856                                      TRUE);
1857
1858         label_scr = gtk_label_new (_("pixel(s)"));
1859         gtk_widget_show (label_scr);
1860         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1861
1862         SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
1863
1864         vbox3 = gtk_vbox_new (FALSE, 0);
1865         gtk_widget_show (vbox3);
1866         gtk_box_pack_start (GTK_BOX (vbox1), vbox3, FALSE, FALSE, 0);
1867
1868         PACK_CHECK_BUTTON(vbox3, chkbtn_attach_desc,
1869                           _("Show attachment descriptions (rather than names)"));
1870
1871         message.chkbtn_mbalnum     = chkbtn_mbalnum;
1872         message.chkbtn_disphdrpane = chkbtn_disphdrpane;
1873         message.chkbtn_disphdr     = chkbtn_disphdr;
1874         message.spinbtn_linespc    = spinbtn_linespc;
1875         message.chkbtn_headspc     = chkbtn_headspc;
1876
1877         message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
1878         message.spinbtn_scrollstep     = spinbtn_scrollstep;
1879         message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
1880         message.chkbtn_halfpage        = chkbtn_halfpage;
1881
1882         message.chkbtn_attach_desc  = chkbtn_attach_desc;
1883 }
1884
1885 static void prefs_interface_create(void)
1886 {
1887         GtkWidget *vbox1;
1888         GtkWidget *vbox2;
1889         GtkWidget *vbox3;
1890         /* GtkWidget *checkbtn_emacs; */
1891         GtkWidget *checkbtn_always_show_msg;
1892         GtkWidget *checkbtn_openunread;
1893         GtkWidget *checkbtn_mark_as_read_on_newwin;
1894         GtkWidget *checkbtn_openinbox;
1895         GtkWidget *checkbtn_immedexec;
1896         GtkTooltips *immedexec_tooltip;
1897         GtkWidget *hbox1;
1898         GtkWidget *label;
1899         GtkWidget *menu;
1900         GtkWidget *menuitem;
1901
1902         GtkWidget *button_keybind;
1903
1904         GtkWidget *hbox_nextunreadmsgdialog;
1905         GtkWidget *optmenu_nextunreadmsgdialog;
1906
1907         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1908         gtk_widget_show (vbox1);
1909         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1910         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1911
1912         vbox2 = gtk_vbox_new (FALSE, 0);
1913         gtk_widget_show (vbox2);
1914         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1915
1916         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
1917                            _("Emulate the behavior of mouse operation of\n"
1918                              "Emacs-based mailer"));
1919         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
1920                                GTK_JUSTIFY_LEFT);   */
1921
1922         PACK_CHECK_BUTTON
1923                 (vbox2, checkbtn_always_show_msg,
1924                  _("Always open messages in summary when selected"));
1925
1926         PACK_CHECK_BUTTON
1927                 (vbox2, checkbtn_openunread,
1928                  _("Open first unread message when entering a folder"));
1929
1930         PACK_CHECK_BUTTON
1931                 (vbox2, checkbtn_mark_as_read_on_newwin,
1932                  _("Only mark message as read when opened in new window"));
1933
1934         PACK_CHECK_BUTTON
1935                 (vbox2, checkbtn_openinbox,
1936                  _("Go to inbox after receiving new mail"));
1937
1938         vbox3 = gtk_vbox_new (FALSE, 0);
1939         gtk_widget_show (vbox3);
1940         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
1941
1942         immedexec_tooltip = gtk_tooltips_new();
1943
1944         PACK_CHECK_BUTTON
1945                 (vbox3, checkbtn_immedexec,
1946                  _("Execute immediately when moving or deleting messages"));
1947         gtk_tooltips_set_tip(GTK_TOOLTIPS(immedexec_tooltip), checkbtn_immedexec,
1948                              _("Messages will be marked until execution"
1949                                " if this is turned off"),
1950                              NULL);
1951
1952         hbox1 = gtk_hbox_new (FALSE, 0);
1953         gtk_widget_show (hbox1);
1954         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
1955
1956         /* Next Unread Message Dialog */
1957         hbox_nextunreadmsgdialog = gtk_hbox_new (FALSE, 8);
1958         gtk_widget_show (hbox1);
1959         gtk_box_pack_start (GTK_BOX (vbox1), hbox_nextunreadmsgdialog, FALSE, FALSE, 0);
1960
1961         label = gtk_label_new (_("Show no-unread-message dialog"));
1962         gtk_widget_show (label);
1963         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), label, FALSE, FALSE, 8);
1964
1965         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
1966         gtk_widget_show (optmenu_nextunreadmsgdialog);
1967         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), optmenu_nextunreadmsgdialog, FALSE, FALSE, 8);
1968         
1969         menu = gtk_menu_new ();
1970         MENUITEM_ADD (menu, menuitem, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
1971         MENUITEM_ADD (menu, menuitem, _("Assume 'Yes'"), 
1972                       NEXTUNREADMSGDIALOG_ASSUME_YES);
1973         MENUITEM_ADD (menu, menuitem, _("Assume 'No'"), 
1974                       NEXTUNREADMSGDIALOG_ASSUME_NO);
1975
1976         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog), menu);
1977
1978         hbox1 = gtk_hbox_new (FALSE, 8);
1979         gtk_widget_show (hbox1);
1980         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1981
1982         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
1983         gtk_widget_show (button_keybind);
1984         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
1985         g_signal_connect (G_OBJECT (button_keybind), "clicked",
1986                           G_CALLBACK (prefs_keybind_select), NULL);
1987
1988         /* interface.checkbtn_emacs          = checkbtn_emacs; */
1989         interface.checkbtn_always_show_msg    = checkbtn_always_show_msg;
1990         interface.checkbtn_openunread         = checkbtn_openunread;
1991         interface.checkbtn_mark_as_read_on_newwin
1992                                               = checkbtn_mark_as_read_on_newwin;
1993         interface.checkbtn_openinbox          = checkbtn_openinbox;
1994         interface.checkbtn_immedexec          = checkbtn_immedexec;
1995         interface.optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
1996 }
1997
1998 static void prefs_other_create(void)
1999 {
2000         GtkWidget *vbox1;
2001         GtkWidget *hbox1;
2002
2003         GtkWidget *frame_addr;
2004         GtkWidget *vbox_addr;
2005         GtkWidget *checkbtn_addaddrbyclick;
2006         
2007         GtkWidget *frame_cliplog;
2008         GtkWidget *vbox_cliplog;
2009         GtkWidget *hbox_cliplog;
2010         GtkWidget *checkbtn_cliplog;
2011         GtkWidget *loglength_label;
2012         GtkWidget *loglength_entry;
2013         GtkTooltips *loglength_tooltip;
2014
2015         GtkWidget *frame_exit;
2016         GtkWidget *vbox_exit;
2017         GtkWidget *checkbtn_confonexit;
2018         GtkWidget *checkbtn_cleanonexit;
2019         GtkWidget *checkbtn_askonclean;
2020         GtkWidget *checkbtn_warnqueued;
2021
2022         GtkWidget *label_iotimeout;
2023         GtkWidget *spinbtn_iotimeout;
2024         GtkObject *spinbtn_iotimeout_adj;
2025
2026 #if 0
2027 #ifdef USE_OPENSSL
2028         GtkWidget *frame_ssl;
2029         GtkWidget *vbox_ssl;
2030         GtkWidget *hbox_ssl;
2031         GtkWidget *checkbtn_ssl_ask_unknown_valid;
2032 #endif
2033 #endif
2034         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2035         gtk_widget_show (vbox1);
2036         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
2037         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2038
2039         PACK_FRAME (vbox1, frame_addr, _("Address book"));
2040
2041         vbox_addr = gtk_vbox_new (FALSE, 0);
2042         gtk_widget_show (vbox_addr);
2043         gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2044         gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2045
2046         PACK_CHECK_BUTTON
2047                 (vbox_addr, checkbtn_addaddrbyclick,
2048                  _("Add address to destination when double-clicked"));
2049
2050         /* Clip Log */
2051         PACK_FRAME (vbox1, frame_cliplog, _("Log Size"));
2052
2053         vbox_cliplog = gtk_vbox_new (FALSE, 0);
2054         gtk_widget_show (vbox_cliplog);
2055         gtk_container_add (GTK_CONTAINER (frame_cliplog), vbox_cliplog);
2056         gtk_container_set_border_width (GTK_CONTAINER (vbox_cliplog), 8);
2057         PACK_CHECK_BUTTON (vbox_cliplog, checkbtn_cliplog,
2058                            _("Clip the log size"));
2059         hbox_cliplog = gtk_hbox_new (FALSE, 3);
2060         gtk_container_add (GTK_CONTAINER (vbox_cliplog), hbox_cliplog);
2061         gtk_widget_show (hbox_cliplog);
2062         
2063         loglength_label = gtk_label_new (_("Log window length"));
2064         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
2065                             FALSE, TRUE, 0);
2066         gtk_widget_show (GTK_WIDGET (loglength_label));
2067         
2068         loglength_tooltip = gtk_tooltips_new();
2069         
2070         loglength_entry = gtk_entry_new ();
2071         gtk_widget_set_size_request (GTK_WIDGET (loglength_entry), 64, -1);
2072         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_entry,
2073                             FALSE, TRUE, 0);
2074         gtk_widget_show (GTK_WIDGET (loglength_entry));
2075         gtk_tooltips_set_tip(GTK_TOOLTIPS(loglength_tooltip), loglength_entry,
2076                              _("0 to stop logging in the log window"),
2077                              NULL);
2078         SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_entry);
2079
2080 #if 0
2081 #ifdef USE_OPENSSL
2082         /* SSL */
2083         PACK_FRAME (vbox1, frame_ssl, _("Security"));
2084
2085         vbox_ssl = gtk_vbox_new (FALSE, 0);
2086         gtk_widget_show (vbox_ssl);
2087         gtk_container_add (GTK_CONTAINER (frame_ssl), vbox_ssl);
2088         gtk_container_set_border_width (GTK_CONTAINER (vbox_ssl), 8);
2089         PACK_CHECK_BUTTON (vbox_ssl, checkbtn_ssl_ask_unknown_valid, 
2090                            _("Ask before accepting SSL certificates"));
2091         hbox_ssl = gtk_hbox_new (FALSE, 3);
2092         gtk_container_add (GTK_CONTAINER (vbox_ssl), hbox_ssl);
2093         gtk_widget_show (hbox_ssl);
2094 #endif
2095 #endif
2096         
2097         /* On Exit */
2098         PACK_FRAME (vbox1, frame_exit, _("On exit"));
2099
2100         vbox_exit = gtk_vbox_new (FALSE, 0);
2101         gtk_widget_show (vbox_exit);
2102         gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2103         gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2104
2105         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2106                            _("Confirm on exit"));
2107
2108         hbox1 = gtk_hbox_new (FALSE, 32);
2109         gtk_widget_show (hbox1);
2110         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2111
2112         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2113                            _("Empty trash on exit"));
2114         PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2115                            _("Ask before emptying"));
2116         SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2117
2118         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2119                            _("Warn if there are queued messages"));
2120
2121         hbox1 = gtk_hbox_new (FALSE, 8);
2122         gtk_widget_show (hbox1);
2123         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2124
2125         label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
2126         gtk_widget_show (label_iotimeout);
2127         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2128
2129         spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
2130         spinbtn_iotimeout = gtk_spin_button_new
2131                 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
2132         gtk_widget_show (spinbtn_iotimeout);
2133         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
2134                             FALSE, FALSE, 0);
2135         gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
2136         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
2137
2138         label_iotimeout = gtk_label_new (_("seconds"));
2139         gtk_widget_show (label_iotimeout);
2140         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2141
2142         other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
2143         
2144         other.checkbtn_cliplog     = checkbtn_cliplog;
2145         other.loglength_entry      = loglength_entry;
2146
2147         other.checkbtn_confonexit  = checkbtn_confonexit;
2148         other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2149         other.checkbtn_askonclean  = checkbtn_askonclean;
2150         other.checkbtn_warnqueued  = checkbtn_warnqueued;
2151
2152         other.spinbtn_iotimeout     = spinbtn_iotimeout;
2153         other.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
2154         
2155 #if 0
2156 #ifdef USE_OPENSSL
2157         other.checkbtn_ssl_ask_unknown_valid = checkbtn_ssl_ask_unknown_valid;
2158 #endif
2159 #endif
2160 }
2161
2162 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
2163 {
2164         GtkWidget *datefmt_sample = NULL;
2165         gchar *text;
2166
2167         g_return_if_fail(widget != NULL);
2168         g_return_if_fail(*widget != NULL);
2169         g_return_if_fail(display.entry_datefmt != NULL);
2170
2171         datefmt_sample = GTK_WIDGET(g_object_get_data
2172                                     (G_OBJECT(*widget), "datefmt_sample"));
2173         g_return_if_fail(datefmt_sample != NULL);
2174
2175         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
2176         g_free(prefs_common.date_format);
2177         prefs_common.date_format = text;
2178         gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
2179
2180         gtk_widget_destroy(*widget);
2181         *widget = NULL;
2182 }
2183
2184 static void date_format_cancel_btn_clicked(GtkButton *button,
2185                                            GtkWidget **widget)
2186 {
2187         g_return_if_fail(widget != NULL);
2188         g_return_if_fail(*widget != NULL);
2189
2190         gtk_widget_destroy(*widget);
2191         *widget = NULL;
2192 }
2193
2194 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
2195                                         GtkWidget **widget)
2196 {
2197         if (event && event->keyval == GDK_Escape)
2198                 date_format_cancel_btn_clicked(NULL, widget);
2199         return FALSE;
2200 }
2201
2202 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
2203                                       GdkEventAny *event, GtkWidget **widget)
2204 {
2205         g_return_val_if_fail(widget != NULL, FALSE);
2206         g_return_val_if_fail(*widget != NULL, FALSE);
2207
2208         *widget = NULL;
2209         return FALSE;
2210 }
2211
2212 static void date_format_entry_on_change(GtkEditable *editable,
2213                                         GtkLabel *example)
2214 {
2215         time_t cur_time;
2216         struct tm *cal_time;
2217         gchar buffer[100];
2218         gchar *text;
2219
2220         cur_time = time(NULL);
2221         cal_time = localtime(&cur_time);
2222         buffer[0] = 0;
2223         text = gtk_editable_get_chars(editable, 0, -1);
2224         if (text)
2225                 strftime(buffer, sizeof buffer, text, cal_time); 
2226         g_free(text);
2227
2228         text = conv_codeset_strdup(buffer,
2229                                    conv_get_current_charset_str(),
2230                                    CS_UTF_8);
2231         if (!text)
2232                 text = g_strdup(buffer);
2233
2234         gtk_label_set_text(example, text);
2235
2236         g_free(text);
2237 }
2238
2239 static void date_format_select_row(GtkWidget *date_format_list, gint row,
2240                                    gint column, GdkEventButton *event,
2241                                    GtkWidget *date_format)
2242 {
2243         gint cur_pos;
2244         gchar *format;
2245         const gchar *old_format;
2246         gchar *new_format;
2247         GtkWidget *datefmt_sample;
2248
2249         /* only on double click */
2250         if (!event || event->type != GDK_2BUTTON_PRESS) return;
2251
2252
2253         datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format), 
2254                                                       "datefmt_sample"));
2255
2256         g_return_if_fail(date_format_list != NULL);
2257         g_return_if_fail(date_format != NULL);
2258         g_return_if_fail(datefmt_sample != NULL);
2259
2260         /* get format from clist */
2261         gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
2262
2263         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
2264         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
2265
2266         /* insert the format into the text entry */
2267         new_format = g_malloc(strlen(old_format) + 3);
2268
2269         strncpy(new_format, old_format, cur_pos);
2270         new_format[cur_pos] = '\0';
2271         strcat(new_format, format);
2272         strcat(new_format, &old_format[cur_pos]);
2273
2274         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
2275         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
2276
2277         g_free(new_format);
2278 }
2279
2280 static GtkWidget *date_format_create(GtkButton *button, void *data)
2281 {
2282         static GtkWidget *datefmt_win = NULL;
2283         GtkWidget *vbox1;
2284         GtkWidget *scrolledwindow1;
2285         GtkWidget *datefmt_clist;
2286         GtkWidget *table;
2287         GtkWidget *label1;
2288         GtkWidget *label2;
2289         GtkWidget *label3;
2290         GtkWidget *confirm_area;
2291         GtkWidget *ok_btn;
2292         GtkWidget *cancel_btn;
2293         GtkWidget *datefmt_entry;
2294
2295         struct {
2296                 gchar *fmt;
2297                 gchar *txt;
2298         } time_format[] = {
2299                 { "%a", NULL },
2300                 { "%A", NULL },
2301                 { "%b", NULL },
2302                 { "%B", NULL },
2303                 { "%c", NULL },
2304                 { "%C", NULL },
2305                 { "%d", NULL },
2306                 { "%H", NULL },
2307                 { "%I", NULL },
2308                 { "%j", NULL },
2309                 { "%m", NULL },
2310                 { "%M", NULL },
2311                 { "%p", NULL },
2312                 { "%S", NULL },
2313                 { "%w", NULL },
2314                 { "%x", NULL },
2315                 { "%y", NULL },
2316                 { "%Y", NULL },
2317                 { "%Z", NULL }
2318         };
2319
2320         gchar *titles[2];
2321         gint i;
2322         const gint TIME_FORMAT_ELEMS =
2323                 sizeof time_format / sizeof time_format[0];
2324
2325         time_format[0].txt  = _("the full abbreviated weekday name");
2326         time_format[1].txt  = _("the full weekday name");
2327         time_format[2].txt  = _("the abbreviated month name");
2328         time_format[3].txt  = _("the full month name");
2329         time_format[4].txt  = _("the preferred date and time for the current locale");
2330         time_format[5].txt  = _("the century number (year/100)");
2331         time_format[6].txt  = _("the day of the month as a decimal number");
2332         time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
2333         time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
2334         time_format[9].txt  = _("the day of the year as a decimal number");
2335         time_format[10].txt = _("the month as a decimal number");
2336         time_format[11].txt = _("the minute as a decimal number");
2337         time_format[12].txt = _("either AM or PM");
2338         time_format[13].txt = _("the second as a decimal number");
2339         time_format[14].txt = _("the day of the week as a decimal number");
2340         time_format[15].txt = _("the preferred date for the current locale");
2341         time_format[16].txt = _("the last two digits of a year");
2342         time_format[17].txt = _("the year as a decimal number");
2343         time_format[18].txt = _("the time zone or name or abbreviation");
2344
2345         if (datefmt_win) return datefmt_win;
2346
2347         datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2348         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
2349         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
2350         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2351         gtk_widget_set_size_request(datefmt_win, 440, 280);
2352
2353         vbox1 = gtk_vbox_new(FALSE, 10);
2354         gtk_widget_show(vbox1);
2355         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
2356
2357         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
2358         gtk_scrolled_window_set_policy
2359                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
2360                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
2361         gtk_widget_show(scrolledwindow1);
2362         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
2363
2364         titles[0] = _("Specifier");
2365         titles[1] = _("Description");
2366         datefmt_clist = gtk_clist_new_with_titles(2, titles);
2367         gtk_widget_show(datefmt_clist);
2368         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
2369         /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
2370         gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
2371                                      GTK_SELECTION_BROWSE);
2372
2373         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
2374                 gchar *text[2];
2375                 /* phoney casting necessary because of gtk... */
2376                 text[0] = (gchar *)time_format[i].fmt;
2377                 text[1] = (gchar *)time_format[i].txt;
2378                 gtk_clist_append(GTK_CLIST(datefmt_clist), text);
2379         }
2380
2381         table = gtk_table_new(2, 2, FALSE);
2382         gtk_widget_show(table);
2383         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
2384         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
2385         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
2386
2387         label1 = gtk_label_new(_("Date format"));
2388         gtk_widget_show(label1);
2389         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
2390                          GTK_FILL, 0, 0, 0);
2391         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
2392         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
2393
2394         datefmt_entry = gtk_entry_new();
2395         gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
2396         gtk_widget_show(datefmt_entry);
2397         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
2398                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2399
2400         /* we need the "sample" entry box; add it as data so callbacks can
2401          * get the entry box */
2402         g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
2403                           datefmt_entry);
2404
2405         label2 = gtk_label_new(_("Example"));
2406         gtk_widget_show(label2);
2407         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
2408                          GTK_FILL, 0, 0, 0);
2409         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
2410         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
2411
2412         label3 = gtk_label_new("");
2413         gtk_widget_show(label3);
2414         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
2415                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2416         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
2417         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
2418
2419         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
2420                                 &cancel_btn, _("Cancel"), NULL, NULL);
2421         gtk_widget_grab_default(ok_btn);
2422         gtk_widget_show(confirm_area);
2423
2424         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
2425
2426         /* set the current format */
2427         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
2428         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
2429                                     GTK_LABEL(label3));
2430
2431         g_signal_connect(G_OBJECT(ok_btn), "clicked",
2432                          G_CALLBACK(date_format_ok_btn_clicked),
2433                          &datefmt_win);
2434         g_signal_connect(G_OBJECT(cancel_btn), "clicked",
2435                          G_CALLBACK(date_format_cancel_btn_clicked),
2436                          &datefmt_win);
2437         g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
2438                          G_CALLBACK(date_format_key_pressed),
2439                          &datefmt_win);
2440         g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
2441                          G_CALLBACK(date_format_on_delete),
2442                          &datefmt_win);
2443         g_signal_connect(G_OBJECT(datefmt_entry), "changed",
2444                          G_CALLBACK(date_format_entry_on_change),
2445                          label3);
2446
2447         g_signal_connect(G_OBJECT(datefmt_clist), "select_row",
2448                          G_CALLBACK(date_format_select_row),
2449                          datefmt_win);
2450
2451         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2452         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
2453
2454         gtk_widget_show(datefmt_win);
2455         manage_window_set_transient(GTK_WINDOW(datefmt_win));
2456
2457         gtk_widget_grab_focus(ok_btn);
2458
2459         return datefmt_win;
2460 }
2461
2462 static void prefs_keybind_select(void)
2463 {
2464         GtkWidget *window;
2465         GtkWidget *vbox1;
2466         GtkWidget *hbox1;
2467         GtkWidget *label;
2468         GtkWidget *combo;
2469         GtkWidget *confirm_area;
2470         GtkWidget *ok_btn;
2471         GtkWidget *cancel_btn;
2472
2473         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2474         gtk_container_set_border_width (GTK_CONTAINER (window), 8);
2475         gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
2476         gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
2477         gtk_window_set_modal (GTK_WINDOW (window), TRUE);
2478         gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
2479         manage_window_set_transient (GTK_WINDOW (window));
2480
2481         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2482         gtk_container_add (GTK_CONTAINER (window), vbox1);
2483         gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
2484
2485         hbox1 = gtk_hbox_new (FALSE, 8);
2486         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2487
2488         label = gtk_label_new
2489                 (_("Select preset:"));
2490         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2491         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2492
2493         hbox1 = gtk_hbox_new (FALSE, 8);
2494         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2495
2496         combo = gtk_combo_new ();
2497         gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
2498         gtkut_combo_set_items (GTK_COMBO (combo),
2499                                _("Default"),
2500                                "Mew / Wanderlust",
2501                                "Mutt",
2502                                _("Old Sylpheed"),
2503                                NULL);
2504         gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO (combo)->entry), FALSE);
2505
2506         hbox1 = gtk_hbox_new (FALSE, 8);
2507         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2508
2509         label = gtk_label_new
2510                 (_("You can also modify each menu shortcut by pressing\n"
2511                    "any key(s) when placing the mouse pointer on the item."));
2512         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2513         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2514
2515         hbox1 = gtk_hbox_new (FALSE, 8);
2516         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2517
2518         gtkut_button_set_create (&confirm_area, &ok_btn, _("OK"),
2519                                  &cancel_btn, _("Cancel"), NULL, NULL);
2520         gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
2521         gtk_widget_grab_default (ok_btn);
2522
2523         MANAGE_WINDOW_SIGNALS_CONNECT(window);
2524         g_signal_connect (G_OBJECT (window), "delete_event",
2525                           G_CALLBACK (prefs_keybind_deleted), NULL);
2526         g_signal_connect (G_OBJECT (window), "key_press_event",
2527                           G_CALLBACK (prefs_keybind_key_pressed), NULL);
2528         g_signal_connect (G_OBJECT (ok_btn), "clicked",
2529                           G_CALLBACK (prefs_keybind_apply_clicked),
2530                           NULL);
2531         g_signal_connect (G_OBJECT (cancel_btn), "clicked",
2532                           G_CALLBACK (prefs_keybind_cancel),
2533                           NULL);
2534
2535         gtk_widget_show_all(window);
2536
2537         keybind.window = window;
2538         keybind.combo = combo;
2539 }
2540
2541 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
2542                                           gpointer data)
2543 {
2544         if (event && event->keyval == GDK_Escape)
2545                 prefs_keybind_cancel();
2546         return FALSE;
2547 }
2548
2549 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
2550                                   gpointer data)
2551 {
2552         prefs_keybind_cancel();
2553         return TRUE;
2554 }
2555
2556 static void prefs_keybind_cancel(void)
2557 {
2558         gtk_widget_destroy(keybind.window);
2559         keybind.window = NULL;
2560         keybind.combo = NULL;
2561 }
2562   
2563 struct KeyBind {
2564         const gchar *accel_path;
2565         const gchar *accel_key;
2566 };
2567
2568 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
2569 {
2570         gint i;
2571         guint key;
2572         GdkModifierType mods;
2573
2574         for (i = 0; i < num; i++) {
2575                 const gchar *accel_key
2576                         = keybind[i].accel_key ? keybind[i].accel_key : "";
2577                 gtk_accelerator_parse(accel_key, &key, &mods);
2578                 gtk_accel_map_change_entry(keybind[i].accel_path,
2579                                            key, mods, TRUE);
2580         }
2581 }
2582
2583 static void prefs_keybind_apply_clicked(GtkWidget *widget)
2584 {
2585         GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
2586         const gchar *text;
2587         struct KeyBind *menurc;
2588         gint n_menurc;
2589
2590         static struct KeyBind default_menurc[] = {
2591                 {"<Main>/File/Empty trash",                     ""},
2592                 {"<Main>/File/Save as...",                      "<control>S"},
2593                 {"<Main>/File/Print...",                        ""},
2594                 {"<Main>/File/Exit",                            "<control>Q"},
2595
2596                 {"<Main>/Edit/Copy",                            "<control>C"},
2597                 {"<Main>/Edit/Select all",                      "<control>A"},
2598                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2599                 {"<Main>/Edit/Search folder...",                "<shift><control>F"},
2600
2601                 {"<Main>/View/Expand Summary View",             "V"},
2602                 {"<Main>/View/Expand Message View",             "<shift>V"},
2603                 {"<Main>/View/Thread view",                     "<control>T"},
2604                 {"<Main>/View/Go to/Prev message",              "P"},
2605                 {"<Main>/View/Go to/Next message",              "N"},
2606                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2607                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2608                 {"<Main>/View/Go to/Other folder...",           "G"},
2609                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2610                 {"<Main>/View/View source",                     "<control>U"},
2611                 {"<Main>/View/Show all headers",                "<control>H"},
2612                 {"<Main>/View/Update",                          "<control><alt>U"},
2613
2614                 {"<Main>/Message/Receive/Get new mail",         "<control>I"},
2615                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
2616                 {"<Main>/Message/Compose an email message",     "<control>M"},
2617                 {"<Main>/Message/Reply",                        "<control>R"},
2618                 {"<Main>/Message/Reply to/all",                 "<shift><control>R"},
2619                 {"<Main>/Message/Reply to/sender",              ""},
2620                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2621                 {"<Main>/Message/Forward",                      "<control><alt>F"},
2622                 /* {"<Main>/Message/Forward as attachment",      ""}, */
2623                 {"<Main>/Message/Move...",                      "<control>O"},
2624                 {"<Main>/Message/Copy...",                      "<shift><control>O"},
2625                 {"<Main>/Message/Delete",                       "<control>D"},
2626                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2627                 {"<Main>/Message/Mark/Unmark",                  "U"},
2628                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2629                 {"<Main>/Message/Mark/Mark as read",            ""},
2630
2631                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2632                 {"<Main>/Tools/Execute",                        "X"},
2633                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2634
2635                 {"<Compose>/File/Close",                                "<control>W"},
2636                 {"<Compose>/Edit/Select all",                           "<control>A"},
2637                 {"<Compose>/Edit/Advanced/Move a word backward",        ""},
2638                 {"<Compose>/Edit/Advanced/Move a word forward",         ""},
2639                 {"<Compose>/Edit/Advanced/Move to beginning of line",   ""},
2640                 {"<Compose>/Edit/Advanced/Delete a word backward",      ""},
2641                 {"<Compose>/Edit/Advanced/Delete a word forward",       ""},
2642         };
2643
2644         static struct KeyBind mew_wl_menurc[] = {
2645                 {"<Main>/File/Empty trash",                     "<shift>D"},
2646                 {"<Main>/File/Save as...",                      "Y"},
2647                 {"<Main>/File/Print...",                        "<shift>numbersign"},
2648                 {"<Main>/File/Exit",                            "<shift>Q"},
2649
2650                 {"<Main>/Edit/Copy",                            "<control>C"},
2651                 {"<Main>/Edit/Select all",                      "<control>A"},
2652                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2653                 {"<Main>/Edit/Search folder...",                "<control>S"},
2654
2655                 {"<Main>/View/Expand Summary View",             ""},
2656                 {"<Main>/View/Expand Message View",             ""},
2657                 {"<Main>/View/Thread view",                     "<shift>T"},
2658                 {"<Main>/View/Go to/Prev message",              "P"},
2659                 {"<Main>/View/Go to/Next message",              "N"},
2660                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2661                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2662                 {"<Main>/View/Go to/Other folder...",           "G"},
2663                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2664                 {"<Main>/View/View source",                     "<control>U"},
2665                 {"<Main>/View/Show all headers",                "<shift>H"},
2666                 {"<Main>/View/Update",                          "<shift>S"},
2667
2668                 {"<Main>/Message/Receive/Get new mail",         "<control>I"},
2669                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
2670                 {"<Main>/Message/Compose an email message",     "W"},
2671                 {"<Main>/Message/Reply",                        "<control>R"},
2672                 {"<Main>/Message/Reply to/all",                 "<shift>A"},
2673                 {"<Main>/Message/Reply to/sender",              ""},
2674                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2675                 {"<Main>/Message/Forward",                      "F"},
2676                 /* {"<Main>/Message/Forward as attachment", "<shift>F"}, */
2677                 {"<Main>/Message/Move...",                      "O"},
2678                 {"<Main>/Message/Copy...",                      "<shift>O"},
2679                 {"<Main>/Message/Delete",                       "D"},
2680                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2681                 {"<Main>/Message/Mark/Unmark",                  "U"},
2682                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2683                 {"<Main>/Message/Mark/Mark as read",            "<shift>R"},
2684
2685                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2686                 {"<Main>/Tools/Execute",                        "X"},
2687                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2688
2689                 {"<Compose>/File/Close",                                "<alt>W"},
2690                 {"<Compose>/Edit/Select all",                           ""},
2691                 {"<Compose>/Edit/Advanced/Move a word backward,"        "<alt>B"},
2692                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2693                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2694                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2695                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2696         };
2697
2698         static struct KeyBind mutt_menurc[] = {
2699                 {"<Main>/File/Empty trash",                     ""},
2700                 {"<Main>/File/Save as...",                      "S"},
2701                 {"<Main>/File/Print...",                        "P"},
2702                 {"<Main>/File/Exit",                            "Q"},
2703
2704                 {"<Main>/Edit/Copy",                            "<control>C"},
2705                 {"<Main>/Edit/Select all",                      "<control>A"},
2706                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2707                 {"<Main>/Edit/Search messages...",              "slash"},
2708
2709                 {"<Main>/View/Toggle summary view",             "V"},
2710                 {"<Main>/View/Thread view",                     "<control>T"},
2711                 {"<Main>/View/Go to/Prev message",              ""},
2712                 {"<Main>/View/Go to/Next message",              ""},
2713                 {"<Main>/View/Go to/Prev unread message",       ""},
2714                 {"<Main>/View/Go to/Next unread message",       ""},
2715                 {"<Main>/View/Go to/Other folder...",           "C"},
2716                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2717                 {"<Main>/View/View source",                     "<control>U"},
2718                 {"<Main>/View/Show all headers",                "<control>H"},
2719                 {"<Main>/View/Update",                          "<control><alt>U"},
2720
2721                 {"<Main>/Message/Receive/Get new mail",                 "<control>I"},
2722                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
2723                 {"<Main>/Message/Compose an email message",             "M"},
2724                 {"<Main>/Message/Reply",                        "R"},
2725                 {"<Main>/Message/Reply to/all",                 "G"},
2726                 {"<Main>/Message/Reply to/sender",              ""},
2727                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2728                 {"<Main>/Message/Forward",                      "F"},
2729                 {"<Main>/Message/Forward as attachment",        ""},
2730                 {"<Main>/Message/Move...",                      "<control>O"},
2731                 {"<Main>/Message/Copy...",                      "<shift>C"},
2732                 {"<Main>/Message/Delete",                       "D"},
2733                 {"<Main>/Message/Mark/Mark",                    "<shift>F"},
2734                 {"<Main>/Message/Mark/Unmark",                  "U"},
2735                 {"<Main>/Message/Mark/Mark as unread",          "<shift>N"},
2736                 {"<Main>/Message/Mark/Mark as read",            ""},
2737
2738                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2739                 {"<Main>/Tools/Execute",                        "X"},
2740                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2741
2742                 {"<Compose>/File/Close",                                "<alt>W"},
2743                 {"<Compose>/Edit/Select all",                           ""},
2744                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
2745                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2746                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2747                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2748                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2749         };
2750
2751         static struct KeyBind old_sylpheed_menurc[] = {
2752                 {"<Main>/File/Empty trash",                     ""},
2753                 {"<Main>/File/Save as...",                      ""},
2754                 {"<Main>/File/Print...",                        "<alt>P"},
2755                 {"<Main>/File/Exit",                            "<alt>Q"},
2756
2757                 {"<Main>/Edit/Copy",                            "<control>C"},
2758                 {"<Main>/Edit/Select all",                      "<control>A"},
2759                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2760                 {"<Main>/Edit/Search folder...",                "<control>S"},
2761
2762                 {"<Main>/View/Expand Summary View",             ""},
2763                 {"<Main>/View/Expand Message View",             ""},
2764                 {"<Main>/View/Thread view",                     "<control>T"},
2765                 {"<Main>/View/Go to/Prev message",              "P"},
2766                 {"<Main>/View/Go to/Next message",              "N"},
2767                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2768                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2769                 {"<Main>/View/Go to/Other folder...",           "<alt>G"},
2770                 {"<Main>/View/Open in new window",              "<shift><control>N"},
2771                 {"<Main>/View/View source",                     "<control>U"},
2772                 {"<Main>/View/Show all headers",                "<control>H"},
2773                 {"<Main>/View/Update",                          "<alt>U"},
2774
2775                 {"<Main>/Message/Receive/Get new mail",                 "<alt>I"},
2776                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><alt>I"},
2777                 {"<Main>/Message/Compose an email message",     "<alt>N"},
2778                 {"<Main>/Message/Reply",                        "<alt>R"},
2779                 {"<Main>/Message/Reply to/all",                 "<shift><alt>R"},
2780                 {"<Main>/Message/Reply to/sender",              "<control><alt>R"},
2781                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2782                 {"<Main>/Message/Forward",                       "<shift><alt>F"},
2783                 /* "(menu-path \"<Main>/Message/Forward as attachment", "<shift><control>F"}, */
2784                 {"<Main>/Message/Move...",                      "<alt>O"},
2785                 {"<Main>/Message/Copy...",                      ""},
2786                 {"<Main>/Message/Delete",                       "<alt>D"},
2787                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2788                 {"<Main>/Message/Mark/Unmark",                  "U"},
2789                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2790                 {"<Main>/Message/Mark/Mark as read",            ""},
2791
2792                 {"<Main>/Tools/Address book",                   "<alt>A"},
2793                 {"<Main>/Tools/Execute",                        "<alt>X"},
2794                 {"<Main>/Tools/Log window",                     "<alt>L"},
2795
2796                 {"<Compose>/File/Close",                                "<alt>W"},
2797                 {"<Compose>/Edit/Select all",                           ""},
2798                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
2799                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2800                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2801                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2802                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2803         };
2804   
2805         text = gtk_entry_get_text(entry);
2806   
2807         if (!strcmp(text, _("Default"))) {
2808                 menurc = default_menurc;
2809                 n_menurc = G_N_ELEMENTS(default_menurc);
2810         } else if (!strcmp(text, "Mew / Wanderlust")) {
2811                 menurc = mew_wl_menurc;
2812                 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
2813         } else if (!strcmp(text, "Mutt")) {
2814                 menurc = mutt_menurc;
2815                 n_menurc = G_N_ELEMENTS(mutt_menurc);
2816         } else if (!strcmp(text, _("Old Sylpheed"))) {
2817                 menurc = old_sylpheed_menurc;
2818                 n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
2819         } else {
2820                 return;
2821         }
2822
2823         /* prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc)); */
2824         prefs_keybind_apply(menurc, n_menurc);
2825
2826         gtk_widget_destroy(keybind.window);
2827         keybind.window = NULL;
2828         keybind.combo = NULL;
2829 }
2830
2831 static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
2832 {
2833         GtkWidget *menu;
2834         GtkWidget *menuitem;
2835         gchar *charset;
2836
2837         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2838         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2839         charset = g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
2840         g_free(*((gchar **)pparam->data));
2841         *((gchar **)pparam->data) = g_strdup(charset);
2842 }
2843
2844 static void prefs_common_charset_set_optmenu(PrefParam *pparam)
2845 {
2846         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2847         gint index;
2848
2849         g_return_if_fail(optmenu != NULL);
2850         g_return_if_fail(*((gchar **)pparam->data) != NULL);
2851
2852         index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
2853                                             (GCompareFunc)strcmp);
2854         if (index >= 0)
2855                 gtk_option_menu_set_history(optmenu, index);
2856         else {
2857                 gtk_option_menu_set_history(optmenu, 0);
2858                 prefs_common_charset_set_data_from_optmenu(pparam);
2859         }
2860 }
2861
2862 static void prefs_common_encoding_set_data_from_optmenu(PrefParam *pparam)
2863 {
2864         GtkWidget *menu;
2865         GtkWidget *menuitem;
2866
2867         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2868         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2869         *((TransferEncodingMethod *)pparam->data) = GPOINTER_TO_INT
2870                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2871 }
2872
2873 static void prefs_common_encoding_set_optmenu(PrefParam *pparam)
2874 {
2875         TransferEncodingMethod method =
2876                 *((TransferEncodingMethod *)pparam->data);
2877         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2878         gint index;
2879
2880         g_return_if_fail(optmenu != NULL);
2881
2882         index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(method),
2883                                             NULL);
2884         if (index >= 0)
2885                 gtk_option_menu_set_history(optmenu, index);
2886         else {
2887                 gtk_option_menu_set_history(optmenu, 0);
2888                 prefs_common_encoding_set_data_from_optmenu(pparam);
2889         }
2890 }
2891
2892 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam)
2893 {
2894         GtkWidget *menu;
2895         GtkWidget *menuitem;
2896
2897         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2898         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2899         *((RecvDialogMode *)pparam->data) = GPOINTER_TO_INT
2900                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2901 }
2902
2903 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
2904 {
2905         RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
2906         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2907         GtkWidget *menu;
2908         GtkWidget *menuitem;
2909         gint index;
2910
2911         index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(mode),
2912                                             NULL);
2913         if (index >= 0)
2914                 gtk_option_menu_set_history(optmenu, index);
2915         else {
2916                 gtk_option_menu_set_history(optmenu, 0);
2917                 prefs_common_recv_dialog_set_data_from_optmenu(pparam);
2918         }
2919
2920         menu = gtk_option_menu_get_menu(optmenu);
2921         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2922         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2923 }
2924
2925 static void prefs_common_send_dialog_set_data_from_optmenu(PrefParam *pparam)
2926 {
2927         GtkWidget *menu;
2928         GtkWidget *menuitem;
2929
2930         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2931         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2932         *((SendDialogMode *)pparam->data) = GPOINTER_TO_INT
2933                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2934 }
2935
2936 static void prefs_common_send_dialog_set_optmenu(PrefParam *pparam)
2937 {
2938         SendDialogMode mode = *((SendDialogMode *)pparam->data);
2939         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2940         GtkWidget *menu;
2941         GtkWidget *menuitem;
2942
2943         switch (mode) {
2944         case SEND_DIALOG_ALWAYS:
2945                 gtk_option_menu_set_history(optmenu, 0);
2946                 break;
2947         case SEND_DIALOG_NEVER:
2948                 gtk_option_menu_set_history(optmenu, 1);
2949                 break;
2950         default:
2951                 break;
2952         }
2953
2954         menu = gtk_option_menu_get_menu(optmenu);
2955         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2956         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2957 }
2958
2959 static void prefs_common_apply(void)
2960 {
2961         MainWindow *mainwindow;
2962
2963         prefs_set_data_from_dialog(param);
2964         sock_set_io_timeout(prefs_common.io_timeout_secs);
2965         main_window_reflect_prefs_all_real(FALSE);
2966         prefs_common_write_config();
2967
2968         mainwindow = mainwindow_get_mainwindow();
2969         log_window_set_clipping(mainwindow->logwin, prefs_common.cliplog,
2970                                 prefs_common.loglength);
2971         
2972         inc_autocheck_timer_remove();
2973         inc_autocheck_timer_set();
2974 }
2975
2976 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam)
2977 {
2978         GtkWidget *menu;
2979         GtkWidget *menuitem;
2980
2981         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2982         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2983         *((NextUnreadMsgDialogShow *)pparam->data) = GPOINTER_TO_INT
2984                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2985 }
2986
2987 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam)
2988 {
2989         NextUnreadMsgDialogShow dialog_show;
2990         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2991         GtkWidget *menu;
2992         GtkWidget *menuitem;
2993
2994         dialog_show = *((NextUnreadMsgDialogShow *)pparam->data);
2995
2996         switch (dialog_show) {
2997         case NEXTUNREADMSGDIALOG_ALWAYS:
2998                 gtk_option_menu_set_history(optmenu, 0);
2999                 break;
3000         case NEXTUNREADMSGDIALOG_ASSUME_YES:
3001                 gtk_option_menu_set_history(optmenu, 1);
3002                 break;
3003         case NEXTUNREADMSGDIALOG_ASSUME_NO:
3004                 gtk_option_menu_set_history(optmenu, 2);
3005                 break;
3006         }
3007
3008         menu = gtk_option_menu_get_menu(optmenu);
3009         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3010         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3011 }
3012
3013 /*
3014 static void prefs_common_cancel(void)
3015 {
3016         gtk_widget_hide(dialog.window);
3017         inc_unlock();
3018 }
3019 */
3020
3021 /* static void prefs_recvdialog_set_data_from_optmenu(PrefParam *pparam)
3022 {
3023         GtkWidget *menu;
3024         GtkWidget *menuitem;
3025
3026         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3027         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3028         *((RecvDialogShow *)pparam->data) = GPOINTER_TO_INT
3029                 (gtk_object_get_user_data(GTK_OBJECT(menuitem)));
3030 }  */
3031
3032 /* static void prefs_recvdialog_set_optmenu(PrefParam *pparam)
3033 {
3034         RecvDialogShow dialog_show;
3035         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3036         GtkWidget *menu;
3037         GtkWidget *menuitem;
3038
3039         dialog_show = *((RecvDialogShow *)pparam->data);
3040
3041         switch (dialog_show) {
3042         case RECVDIALOG_ALWAYS:
3043                 gtk_option_menu_set_history(optmenu, 0);
3044                 break;
3045         case RECVDIALOG_WINDOW_ACTIVE:
3046                 gtk_option_menu_set_history(optmenu, 1);
3047                 break;
3048         case RECVDIALOG_NEVER:
3049                 gtk_option_menu_set_history(optmenu, 2);
3050                 break;
3051         default:
3052         }
3053
3054         menu = gtk_option_menu_get_menu(optmenu);
3055         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3056         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3057 }     */