remove all gtk3 conditionals
[claws.git] / src / prefs_account.c
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2015 Hiroyuki Yamamoto and the Claws Mail team
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 3 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, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifdef HAVE_CONFIG_H
20 #  include "config.h"
21 #include "claws-features.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <glib/gi18n.h>
28 #include <gtk/gtk.h>
29 #include <gdk/gdkkeysyms.h>
30 #include <gtk/filesel.h>
31 #include <stdio.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <string.h>
35 #include <stdlib.h>
36 #include <ctype.h>
37 #include "gtkcmoptionmenu.h"
38 #include "main.h"
39 #include "prefs_gtk.h"
40 #include "prefs_account.h"
41 #include "prefs_receive.h"
42 #include "prefs_common.h"
43 #include "prefs_customheader.h"
44 #include "account.h"
45 #include "mainwindow.h"
46 #include "manage_window.h"
47 #include "folder.h"
48 #include "foldersel.h"
49 #include "inc.h"
50 #include "menu.h"
51 #include "gtkutils.h"
52 #include "utils.h"
53 #include "alertpanel.h"
54 #include "colorlabel.h"
55 #include "smtp.h"
56 #include "imap.h"
57 #include "remotefolder.h"
58 #include "combobox.h"
59 #include "setup.h"
60 #include "quote_fmt.h"
61 #include "hooks.h"
62 #include "privacy.h"
63 #include "inputdialog.h"
64 #include "ssl_certificate.h"
65 #include "passwordstore.h"
66 #include "file-utils.h"
67
68 static gboolean cancelled;
69 static gboolean new_account;
70
71 static PrefsAccount tmp_ac_prefs;
72
73 static GtkWidget *sigfile_radiobtn;
74 static GtkWidget *sigcmd_radiobtn;
75 static GtkWidget *entry_sigpath;
76 static GtkWidget *signature_browse_button;
77 static GtkWidget *signature_edit_button;
78
79 #ifdef USE_GNUTLS
80 static GtkWidget *entry_in_cert_file;
81 static GtkWidget *entry_out_cert_file;
82 static GtkWidget *in_ssl_cert_browse_button;
83 static GtkWidget *out_ssl_cert_browse_button;
84 #endif
85
86 struct AutocheckWidgets {
87         GtkWidget *autochk_hour_spinbtn;
88         GtkWidget *autochk_min_spinbtn;
89         GtkWidget *autochk_sec_spinbtn;
90 };
91
92 static GSList *prefs_pages = NULL;
93
94 typedef struct BasicPage
95 {
96     PrefsPage page;
97
98     GtkWidget *vbox;
99
100         GtkWidget *acname_entry;
101         GtkWidget *default_checkbtn;
102
103         GtkWidget *name_entry;
104         GtkWidget *addr_entry;
105         GtkWidget *org_entry;
106
107         GtkWidget *serv_frame;
108         GtkWidget *serv_table;
109         gpointer *protocol_optmenu;
110         GtkWidget *recvserv_label;
111         GtkWidget *smtpserv_label;
112         GtkWidget *nntpserv_label;
113         GtkWidget *localmbox_label;
114         GtkWidget *mailcmd_label;
115         GtkWidget *recvserv_entry;
116         GtkWidget *smtpserv_entry;
117         GtkWidget *nntpserv_entry;
118         GtkWidget *nntpauth_checkbtn;
119         GtkWidget *nntpauth_onconnect_checkbtn;
120         GtkWidget *localmbox_entry;
121         GtkWidget *mailcmd_checkbtn;
122         GtkWidget *mailcmd_entry;
123         GtkWidget *uid_label;
124         GtkWidget *pass_label;
125         GtkWidget *uid_entry;
126         GtkWidget *pass_entry;
127         GtkWidget *showpwd_checkbtn;
128         GtkWidget *auto_configure_btn;
129         GtkWidget *auto_configure_cancel_btn;
130         GtkWidget *auto_configure_lbl;
131 } BasicPage;
132
133 typedef struct ReceivePage
134 {
135     PrefsPage page;
136
137     GtkWidget *vbox;
138
139         GtkWidget *pop3_frame;
140         GtkWidget *use_apop_checkbtn;
141         GtkWidget *rmmail_checkbtn;
142         GtkWidget *leave_time_spinbtn;
143         GtkWidget *leave_hour_spinbtn;
144         GtkWidget *size_limit_checkbtn;
145         GtkWidget *size_limit_spinbtn;
146         GtkWidget *inbox_label;
147         GtkWidget *inbox_entry;
148         GtkWidget *inbox_btn;
149
150         GtkWidget *autochk_frame;
151
152         GtkWidget *local_frame;
153         GtkWidget *local_inbox_label;
154         GtkWidget *local_inbox_entry;
155         GtkWidget *local_inbox_btn;
156
157         GtkWidget *filter_on_recv_checkbtn;
158         GtkWidget *filterhook_on_recv_checkbtn;
159         GtkWidget *recvatgetall_checkbtn;
160         
161         GtkWidget *imap_frame;
162         GtkWidget *imap_auth_type_optmenu;
163         GtkWidget *imapdir_label;
164         GtkWidget *imapdir_entry;
165         GtkWidget *subsonly_checkbtn;
166         GtkWidget *low_bandwidth_checkbtn;
167
168         GtkWidget *frame_maxarticle;
169         GtkWidget *maxarticle_label;
170         GtkWidget *maxarticle_spinbtn;
171         GtkAdjustment *maxarticle_spinbtn_adj;
172
173         GtkWidget *autochk_checkbtn;
174         GtkWidget *autochk_use_default_checkbtn;
175         struct AutocheckWidgets *autochk_widgets;
176 } ReceivePage;
177
178 typedef struct SendPage
179 {
180     PrefsPage page;
181
182     GtkWidget *vbox;
183
184         GtkWidget *msgid_checkbtn;
185         GtkWidget *xmailer_checkbtn;
186         GtkWidget *customhdr_checkbtn;
187         GtkWidget *msgid_with_addr_checkbtn;
188         GtkWidget *smtp_auth_checkbtn;
189         GtkWidget *smtp_auth_type_optmenu;
190         GtkWidget *smtp_uid_entry;
191         GtkWidget *smtp_pass_entry;
192         GtkWidget *pop_bfr_smtp_checkbtn;
193         GtkWidget *pop_bfr_smtp_tm_spinbtn;
194         GtkWidget *pop_auth_timeout_lbl;
195         GtkWidget *pop_auth_minutes_lbl;
196 } SendPage;
197
198 typedef struct ComposePage
199 {
200     PrefsPage page;
201
202     GtkWidget *vbox;
203
204         GtkWidget *sigfile_radiobtn;
205         GtkWidget *entry_sigpath;
206         GtkWidget *checkbtn_autosig;
207         GtkWidget *entry_sigsep;
208         GtkWidget *autocc_checkbtn;
209         GtkWidget *autocc_entry;
210         GtkWidget *autobcc_checkbtn;
211         GtkWidget *autobcc_entry;
212         GtkWidget *autoreplyto_checkbtn;
213         GtkWidget *autoreplyto_entry;
214 #if USE_ENCHANT
215         GtkWidget *checkbtn_enable_default_dictionary;
216         GtkWidget *combo_default_dictionary;
217         GtkWidget *checkbtn_enable_default_alt_dictionary;
218         GtkWidget *combo_default_alt_dictionary;
219 #endif
220 } ComposePage;
221
222 typedef struct TemplatesPage
223 {
224     PrefsPage page;
225
226     GtkWidget *vbox;
227
228         GtkWidget *checkbtn_compose_with_format;
229         GtkWidget *compose_subject_format;
230         GtkWidget *compose_body_format;
231         GtkWidget *checkbtn_reply_with_format;
232         GtkWidget *reply_quotemark;
233         GtkWidget *reply_body_format;
234         GtkWidget *checkbtn_forward_with_format;
235         GtkWidget *forward_quotemark;
236         GtkWidget *forward_body_format;
237 } TemplatesPage;
238
239 typedef struct PrivacyPage
240 {
241     PrefsPage page;
242
243     GtkWidget *vbox;
244
245         GtkWidget *default_privacy_system;
246         GtkWidget *default_encrypt_checkbtn;
247         GtkWidget *default_encrypt_reply_checkbtn;
248         GtkWidget *default_sign_checkbtn;
249         GtkWidget *default_sign_reply_checkbtn;
250         GtkWidget *save_clear_text_checkbtn;
251         GtkWidget *encrypt_to_self_checkbtn;
252 } PrivacyPage;
253
254 typedef struct SSLPage
255 {
256     PrefsPage page;
257
258     GtkWidget *vbox;
259
260         GtkWidget *pop_frame;
261         GtkWidget *pop_nossl_radiobtn;
262         GtkWidget *pop_ssltunnel_radiobtn;
263         GtkWidget *pop_starttls_radiobtn;
264
265         GtkWidget *imap_frame;
266         GtkWidget *imap_nossl_radiobtn;
267         GtkWidget *imap_ssltunnel_radiobtn;
268         GtkWidget *imap_starttls_radiobtn;
269
270         GtkWidget *nntp_frame;
271         GtkWidget *nntp_nossl_radiobtn;
272         GtkWidget *nntp_ssltunnel_radiobtn;
273
274         GtkWidget *send_frame;
275         GtkWidget *smtp_nossl_radiobtn;
276         GtkWidget *smtp_ssltunnel_radiobtn;
277         GtkWidget *smtp_starttls_radiobtn;
278
279         GtkWidget *entry_in_cert_file;
280         GtkWidget *entry_in_cert_pass;
281         GtkWidget *entry_out_cert_file;
282         GtkWidget *entry_out_cert_pass;
283
284         GtkWidget *ssl_certs_auto_accept_checkbtn;
285         GtkWidget *use_nonblocking_ssl_checkbtn;
286 } SSLPage;
287
288 typedef struct ProxyPage
289 {
290         PrefsPage page;
291
292         GtkWidget *vbox;
293
294         GtkWidget *proxy_checkbtn;
295         GtkWidget *default_proxy_checkbtn;
296         GtkWidget *socks4_radiobtn;
297         GtkWidget *socks5_radiobtn;
298         GtkWidget *proxy_host_entry;
299         GtkWidget *proxy_port_spinbtn;
300         GtkWidget *proxy_auth_checkbtn;
301         GtkWidget *proxy_name_entry;
302         GtkWidget *proxy_pass_entry;
303         GtkWidget *proxy_send_checkbtn;
304 } ProxyPage;
305
306 typedef struct AdvancedPage
307 {
308     PrefsPage page;
309
310     GtkWidget *vbox;
311
312         GtkWidget *smtpport_checkbtn;
313         GtkWidget *smtpport_spinbtn;
314         GtkWidget *popport_hbox;
315         GtkWidget *popport_checkbtn;
316         GtkWidget *popport_spinbtn;
317         GtkWidget *imapport_hbox;
318         GtkWidget *imapport_checkbtn;
319         GtkWidget *imapport_spinbtn;
320         GtkWidget *nntpport_hbox;
321         GtkWidget *nntpport_checkbtn;
322         GtkWidget *nntpport_spinbtn;
323         GtkWidget *domain_checkbtn;
324         GtkWidget *domain_entry;
325         GtkWidget *crosspost_checkbtn;
326         GtkWidget *crosspost_colormenu;
327
328 #ifndef G_OS_WIN32
329         GtkWidget *tunnelcmd_checkbtn;
330         GtkWidget *tunnelcmd_entry;
331 #endif
332
333         GtkWidget *sent_folder_checkbtn;
334         GtkWidget *sent_folder_entry;
335         GtkWidget *queue_folder_checkbtn;
336         GtkWidget *queue_folder_entry;
337         GtkWidget *draft_folder_checkbtn;
338         GtkWidget *draft_folder_entry;
339         GtkWidget *trash_folder_checkbtn;
340         GtkWidget *trash_folder_entry;
341 } AdvancedPage;
342
343 static BasicPage basic_page;
344 static ReceivePage receive_page;
345 static SendPage send_page;
346 static ComposePage compose_page;
347 static TemplatesPage templates_page;
348 static PrivacyPage privacy_page;
349 #ifdef USE_GNUTLS
350 static SSLPage ssl_page;
351 #endif
352 static ProxyPage proxy_page;
353 static AdvancedPage advanced_page;
354
355 struct BasicProtocol {
356         GtkWidget *combobox;
357         GtkWidget *label;
358         GtkWidget *descrlabel;
359         GtkWidget *no_imap_warn_icon;
360         GtkWidget *no_imap_warn_label;
361 };
362
363 static char *protocol_names[] = {
364         N_("POP"),
365         N_("IMAP"),
366         N_("News (NNTP)"),
367         N_("Local mbox file"),
368         N_("None (SMTP only)")
369 };
370
371 static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam);
372 static void prefs_account_protocol_set_optmenu          (PrefParam *pparam);
373 static void prefs_account_protocol_changed              (GtkComboBox *combobox,
374                                                         gpointer data);
375
376 static void prefs_account_set_string_from_combobox (PrefParam *pparam);
377 static void prefs_account_set_privacy_combobox_from_string (PrefParam *pparam);
378
379 static void prefs_account_imap_auth_type_set_data_from_optmenu
380                                                         (PrefParam *pparam);
381 static void prefs_account_imap_auth_type_set_optmenu    (PrefParam *pparam);
382 static void prefs_account_smtp_auth_type_set_data_from_optmenu
383                                                         (PrefParam *pparam);
384 static void prefs_account_smtp_auth_type_set_optmenu    (PrefParam *pparam);
385
386 static void prefs_account_set_autochk_interval_from_widgets(PrefParam *pparam);
387 static void prefs_account_set_autochk_interval_to_widgets(PrefParam *pparam);
388
389 static void prefs_account_enum_set_data_from_radiobtn   (PrefParam *pparam);
390 static void prefs_account_enum_set_radiobtn             (PrefParam *pparam);
391
392 static void crosspost_color_toggled(void);
393 static void prefs_account_crosspost_set_data_from_colormenu(PrefParam *pparam);
394 static void prefs_account_crosspost_set_colormenu(PrefParam *pparam);
395
396 static void prefs_account_nntpauth_toggled(GtkToggleButton *button,
397                                            gpointer user_data);
398 static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
399                                           gpointer user_data);
400 static void prefs_account_showpwd_checkbtn_toggled(GtkToggleButton *button,
401                                           gpointer user_data);
402 static void prefs_account_entry_changed_newline_check_cb(GtkWidget *entry,
403                                                 gpointer user_data);
404 static void prefs_account_filter_on_recv_toggled(GtkToggleButton *button,
405                                           gpointer user_data);
406
407 #if USE_ENCHANT
408 static void prefs_account_compose_default_dictionary_set_string_from_optmenu
409                                                         (PrefParam *pparam);
410 static void prefs_account_compose_default_dictionary_set_optmenu_from_string
411                                                         (PrefParam *pparam);
412 #endif
413
414 static gchar *privacy_prefs;
415
416 static PrefParam basic_param[] = {
417         {"account_name", NULL, &tmp_ac_prefs.account_name, P_STRING,
418          &basic_page.acname_entry, prefs_set_data_from_entry, prefs_set_entry},
419
420         {"is_default", "FALSE", &tmp_ac_prefs.is_default, P_BOOL,
421          &basic_page.default_checkbtn,
422          prefs_set_data_from_toggle, prefs_set_toggle},
423
424         {"name", NULL, &tmp_ac_prefs.name, P_STRING,
425          &basic_page.name_entry, prefs_set_data_from_entry, prefs_set_entry},
426
427         {"address", NULL, &tmp_ac_prefs.address, P_STRING,
428          &basic_page.addr_entry, prefs_set_data_from_entry, prefs_set_entry},
429
430         {"organization", NULL, &tmp_ac_prefs.organization, P_STRING,
431          &basic_page.org_entry, prefs_set_data_from_entry, prefs_set_entry},
432
433         {"protocol", NULL, &tmp_ac_prefs.protocol, P_ENUM,
434          (GtkWidget **)&basic_page.protocol_optmenu,
435          prefs_account_protocol_set_data_from_optmenu,
436          prefs_account_protocol_set_optmenu},
437
438         {"receive_server", NULL, &tmp_ac_prefs.recv_server, P_STRING,
439          &basic_page.recvserv_entry, prefs_set_data_from_entry, prefs_set_entry},
440
441         {"smtp_server", NULL, &tmp_ac_prefs.smtp_server, P_STRING,
442          &basic_page.smtpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
443
444         {"nntp_server", NULL, &tmp_ac_prefs.nntp_server, P_STRING,
445          &basic_page.nntpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
446
447         {"local_mbox", "/var/mail", &tmp_ac_prefs.local_mbox, P_STRING,
448          &basic_page.localmbox_entry, prefs_set_data_from_entry, prefs_set_entry},
449
450         {"use_mail_command", "FALSE", &tmp_ac_prefs.use_mail_command, P_BOOL,
451          &basic_page.mailcmd_checkbtn, prefs_set_data_from_toggle, prefs_set_toggle},
452
453         {"mail_command", DEFAULT_SENDMAIL_CMD, &tmp_ac_prefs.mail_command, P_STRING,
454          &basic_page.mailcmd_entry, prefs_set_data_from_entry, prefs_set_entry},
455
456         {"use_nntp_auth", "FALSE", &tmp_ac_prefs.use_nntp_auth, P_BOOL,
457          &basic_page.nntpauth_checkbtn,
458          prefs_set_data_from_toggle, prefs_set_toggle},
459         
460         {"use_nntp_auth_onconnect", "FALSE", &tmp_ac_prefs.use_nntp_auth_onconnect, P_BOOL,
461          &basic_page.nntpauth_onconnect_checkbtn,
462          prefs_set_data_from_toggle, prefs_set_toggle},
463
464         {"user_id", "ENV_USER", &tmp_ac_prefs.userid, P_STRING,
465          &basic_page.uid_entry, prefs_set_data_from_entry, prefs_set_entry},
466
467         {"password", NULL, &tmp_ac_prefs.passwd, P_PASSWORD,
468          NULL, NULL, NULL},
469
470         {"config_version", "-1", &tmp_ac_prefs.config_version, P_INT,
471                 NULL, NULL, NULL},
472
473         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
474 };
475
476 static PrefParam receive_param[] = {
477         {"use_apop_auth", "FALSE", &tmp_ac_prefs.use_apop_auth, P_BOOL,
478          &receive_page.use_apop_checkbtn,
479          prefs_set_data_from_toggle, prefs_set_toggle},
480
481         {"remove_mail", "TRUE", &tmp_ac_prefs.rmmail, P_BOOL,
482          &receive_page.rmmail_checkbtn,
483          prefs_set_data_from_toggle, prefs_set_toggle},
484
485 #ifndef GENERIC_UMPC
486         {"message_leave_time", "7", &tmp_ac_prefs.msg_leave_time, P_INT,
487          &receive_page.leave_time_spinbtn,
488          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
489 #else
490         {"message_leave_time", "30", &tmp_ac_prefs.msg_leave_time, P_INT,
491          &receive_page.leave_time_spinbtn,
492          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
493 #endif
494         {"message_leave_hour", "0", &tmp_ac_prefs.msg_leave_hour, P_INT,
495          &receive_page.leave_hour_spinbtn,
496          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
497
498         {"enable_size_limit", "FALSE", &tmp_ac_prefs.enable_size_limit, P_BOOL,
499          &receive_page.size_limit_checkbtn,
500          prefs_set_data_from_toggle, prefs_set_toggle},
501         {"size_limit", "1024", &tmp_ac_prefs.size_limit, P_INT,
502          &receive_page.size_limit_spinbtn,
503          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
504
505         {"filter_on_receive", "TRUE", &tmp_ac_prefs.filter_on_recv, P_BOOL,
506          &receive_page.filter_on_recv_checkbtn,
507          prefs_set_data_from_toggle, prefs_set_toggle},
508
509         {"filterhook_on_receive", "TRUE", &tmp_ac_prefs.filterhook_on_recv, P_BOOL,
510          &receive_page.filterhook_on_recv_checkbtn,
511          prefs_set_data_from_toggle, prefs_set_toggle},
512
513         {"imap_auth_method", "0", &tmp_ac_prefs.imap_auth_type, P_ENUM,
514          &receive_page.imap_auth_type_optmenu,
515          prefs_account_imap_auth_type_set_data_from_optmenu,
516          prefs_account_imap_auth_type_set_optmenu},
517
518         {"receive_at_get_all", "TRUE", &tmp_ac_prefs.recv_at_getall, P_BOOL,
519          &receive_page.recvatgetall_checkbtn,
520          prefs_set_data_from_toggle, prefs_set_toggle},
521
522         {"max_news_articles", "300", &tmp_ac_prefs.max_articles, P_INT,
523          &receive_page.maxarticle_spinbtn,
524          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
525
526         {"inbox", "#mh/Mailbox/inbox", &tmp_ac_prefs.inbox, P_STRING,
527          &receive_page.inbox_entry, prefs_set_data_from_entry, prefs_set_entry},
528
529         {"local_inbox", "#mh/Mailbox/inbox", &tmp_ac_prefs.local_inbox, P_STRING,
530          &receive_page.local_inbox_entry, prefs_set_data_from_entry, prefs_set_entry},
531
532         {"imap_directory", NULL, &tmp_ac_prefs.imap_dir, P_STRING,
533          &receive_page.imapdir_entry, prefs_set_data_from_entry, prefs_set_entry},
534
535         {"imap_subsonly", "TRUE", &tmp_ac_prefs.imap_subsonly, P_BOOL,
536          &receive_page.subsonly_checkbtn,
537          prefs_set_data_from_toggle, prefs_set_toggle},
538
539         {"low_bandwidth", "FALSE", &tmp_ac_prefs.low_bandwidth, P_BOOL,
540          &receive_page.low_bandwidth_checkbtn,
541          prefs_set_data_from_toggle, prefs_set_toggle},
542
543         {"autochk_use_default", "TRUE", &tmp_ac_prefs.autochk_use_default, P_BOOL,
544                 &receive_page.autochk_use_default_checkbtn,
545                 prefs_set_data_from_toggle, prefs_set_toggle},
546
547         {"autochk_use_custom", "FALSE", &tmp_ac_prefs.autochk_use_custom, P_BOOL,
548                 &receive_page.autochk_checkbtn,
549                 prefs_set_data_from_toggle, prefs_set_toggle},
550
551         /* Here we lie a bit, passing a pointer to our custom struct,
552          * disguised as a GtkWidget pointer, to get around the
553          * inflexibility of PrefParam system. */
554         {"autochk_interval", "600", &tmp_ac_prefs.autochk_itv, P_INT,
555                 (GtkWidget **)&receive_page.autochk_widgets,
556                 prefs_account_set_autochk_interval_from_widgets,
557                 prefs_account_set_autochk_interval_to_widgets},
558
559         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
560 };
561
562 static PrefParam send_param[] = {
563         {"generate_msgid", "TRUE", &tmp_ac_prefs.gen_msgid, P_BOOL,
564          &send_page.msgid_checkbtn,
565          prefs_set_data_from_toggle, prefs_set_toggle},
566
567         {"generate_xmailer", "TRUE", &tmp_ac_prefs.gen_xmailer, P_BOOL,
568          &send_page.xmailer_checkbtn,
569          prefs_set_data_from_toggle, prefs_set_toggle},
570
571         {"add_custom_header", "FALSE", &tmp_ac_prefs.add_customhdr, P_BOOL,
572          &send_page.customhdr_checkbtn,
573          prefs_set_data_from_toggle, prefs_set_toggle},
574
575         {"msgid_with_addr", "FALSE", &tmp_ac_prefs.msgid_with_addr, P_BOOL,
576          &send_page.msgid_with_addr_checkbtn,
577          prefs_set_data_from_toggle, prefs_set_toggle},
578
579          {"use_smtp_auth", "FALSE", &tmp_ac_prefs.use_smtp_auth, P_BOOL,
580          &send_page.smtp_auth_checkbtn,
581          prefs_set_data_from_toggle, prefs_set_toggle},
582
583         {"smtp_auth_method", "0", &tmp_ac_prefs.smtp_auth_type, P_ENUM,
584          &send_page.smtp_auth_type_optmenu,
585          prefs_account_smtp_auth_type_set_data_from_optmenu,
586          prefs_account_smtp_auth_type_set_optmenu},
587
588         {"smtp_user_id", NULL, &tmp_ac_prefs.smtp_userid, P_STRING,
589          &send_page.smtp_uid_entry, prefs_set_data_from_entry, prefs_set_entry},
590         {"smtp_password", NULL, &tmp_ac_prefs.smtp_passwd, P_PASSWORD,
591          NULL, NULL, NULL},
592
593         {"pop_before_smtp", "FALSE", &tmp_ac_prefs.pop_before_smtp, P_BOOL,
594          &send_page.pop_bfr_smtp_checkbtn,
595          prefs_set_data_from_toggle, prefs_set_toggle},
596
597         {"pop_before_smtp_timeout", "5", &tmp_ac_prefs.pop_before_smtp_timeout, P_INT,
598          &send_page.pop_bfr_smtp_tm_spinbtn,
599          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
600
601         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
602 };
603
604 static PrefParam compose_param[] = {
605         {"signature_type", "0", &tmp_ac_prefs.sig_type, P_ENUM,
606          &compose_page.sigfile_radiobtn,
607          prefs_account_enum_set_data_from_radiobtn,
608          prefs_account_enum_set_radiobtn},
609         {"signature_path", "~" G_DIR_SEPARATOR_S DEFAULT_SIGNATURE,
610          &tmp_ac_prefs.sig_path, P_STRING, &compose_page.entry_sigpath,
611          prefs_set_data_from_entry, prefs_set_entry},
612
613         {"auto_signature", "TRUE", &tmp_ac_prefs.auto_sig, P_BOOL,
614          &compose_page.checkbtn_autosig,
615          prefs_set_data_from_toggle, prefs_set_toggle},
616          
617         {"signature_separator", "-- ", &tmp_ac_prefs.sig_sep, P_STRING,
618          &compose_page.entry_sigsep, 
619          prefs_set_data_from_entry, prefs_set_entry},
620
621         {"set_autocc", "FALSE", &tmp_ac_prefs.set_autocc, P_BOOL,
622          &compose_page.autocc_checkbtn,
623          prefs_set_data_from_toggle, prefs_set_toggle},
624
625         {"auto_cc", NULL, &tmp_ac_prefs.auto_cc, P_STRING,
626          &compose_page.autocc_entry,
627          prefs_set_data_from_entry, prefs_set_entry},
628
629         {"set_autobcc", "FALSE", &tmp_ac_prefs.set_autobcc, P_BOOL,
630          &compose_page.autobcc_checkbtn,
631          prefs_set_data_from_toggle, prefs_set_toggle},
632
633         {"auto_bcc", NULL, &tmp_ac_prefs.auto_bcc, P_STRING,
634          &compose_page.autobcc_entry,
635          prefs_set_data_from_entry, prefs_set_entry},
636
637         {"set_autoreplyto", "FALSE", &tmp_ac_prefs.set_autoreplyto, P_BOOL,
638          &compose_page.autoreplyto_checkbtn,
639          prefs_set_data_from_toggle, prefs_set_toggle},
640
641         {"auto_replyto", NULL, &tmp_ac_prefs.auto_replyto, P_STRING,
642          &compose_page.autoreplyto_entry,
643          prefs_set_data_from_entry, prefs_set_entry},
644
645 #if USE_ENCHANT
646         {"enable_default_dictionary", "", &tmp_ac_prefs.enable_default_dictionary, P_BOOL,
647          &compose_page.checkbtn_enable_default_dictionary,
648          prefs_set_data_from_toggle, prefs_set_toggle},
649
650         {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING,
651          &compose_page.combo_default_dictionary,
652          prefs_account_compose_default_dictionary_set_string_from_optmenu,
653          prefs_account_compose_default_dictionary_set_optmenu_from_string},
654
655         {"enable_default_alt_dictionary", "", &tmp_ac_prefs.enable_default_alt_dictionary, P_BOOL,
656          &compose_page.checkbtn_enable_default_alt_dictionary,
657          prefs_set_data_from_toggle, prefs_set_toggle},
658
659         {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING,
660          &compose_page.combo_default_alt_dictionary,
661          prefs_account_compose_default_dictionary_set_string_from_optmenu,
662          prefs_account_compose_default_dictionary_set_optmenu_from_string},
663 #else
664         {"enable_default_dictionary", "", &tmp_ac_prefs.enable_default_dictionary, P_BOOL,
665          NULL, NULL, NULL},
666
667         {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING,
668          NULL, NULL, NULL},
669
670         {"enable_default_alt_dictionary", "", &tmp_ac_prefs.enable_default_alt_dictionary, P_BOOL,
671          NULL, NULL, NULL},
672
673         {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING,
674          NULL, NULL, NULL},
675 #endif   
676
677         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
678 };
679
680 static PrefParam templates_param[] = {
681         {"compose_with_format", "FALSE", &tmp_ac_prefs.compose_with_format, P_BOOL,
682          &templates_page.checkbtn_compose_with_format,
683          prefs_set_data_from_toggle, prefs_set_toggle},
684
685         {"compose_subject_format", NULL, &tmp_ac_prefs.compose_subject_format, P_STRING,
686          &templates_page.compose_subject_format,
687          prefs_set_escaped_data_from_entry, prefs_set_entry_from_escaped},
688
689         {"compose_body_format", NULL, &tmp_ac_prefs.compose_body_format, P_STRING,
690          &templates_page.compose_body_format,
691          prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
692
693         {"reply_with_format", "FALSE", &tmp_ac_prefs.reply_with_format, P_BOOL,
694          &templates_page.checkbtn_reply_with_format,
695          prefs_set_data_from_toggle, prefs_set_toggle},
696
697         {"reply_quotemark", NULL, &tmp_ac_prefs.reply_quotemark, P_STRING,
698          &templates_page.reply_quotemark,
699          prefs_set_data_from_entry, prefs_set_entry_from_escaped},
700
701         {"reply_body_format", NULL, &tmp_ac_prefs.reply_body_format, P_STRING,
702          &templates_page.reply_body_format,
703          prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
704
705         {"forward_with_format", "FALSE", &tmp_ac_prefs.forward_with_format, P_BOOL,
706          &templates_page.checkbtn_forward_with_format,
707          prefs_set_data_from_toggle, prefs_set_toggle},
708
709         {"forward_quotemark", NULL, &tmp_ac_prefs.forward_quotemark, P_STRING,
710          &templates_page.forward_quotemark,
711          prefs_set_data_from_entry, prefs_set_entry_from_escaped},
712
713         {"forward_body_format", NULL, &tmp_ac_prefs.forward_body_format, P_STRING,
714          &templates_page.forward_body_format,
715          prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
716
717         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
718 };
719
720 static PrefParam privacy_param[] = {
721         {"default_privacy_system", "", &tmp_ac_prefs.default_privacy_system, P_STRING,
722          &privacy_page.default_privacy_system,
723          prefs_account_set_string_from_combobox,
724          prefs_account_set_privacy_combobox_from_string},
725
726         {"default_encrypt", "FALSE", &tmp_ac_prefs.default_encrypt, P_BOOL,
727          &privacy_page.default_encrypt_checkbtn,
728          prefs_set_data_from_toggle, prefs_set_toggle},
729
730         {"default_encrypt_reply", "TRUE", &tmp_ac_prefs.default_encrypt_reply, P_BOOL,
731          &privacy_page.default_encrypt_reply_checkbtn,
732          prefs_set_data_from_toggle, prefs_set_toggle},
733
734         {"default_sign", "FALSE", &tmp_ac_prefs.default_sign, P_BOOL,
735          &privacy_page.default_sign_checkbtn,
736          prefs_set_data_from_toggle, prefs_set_toggle},
737 #ifdef G_OS_UNIX
738         {"default_sign_reply", "TRUE", &tmp_ac_prefs.default_sign_reply, P_BOOL,
739          &privacy_page.default_sign_reply_checkbtn,
740          prefs_set_data_from_toggle, prefs_set_toggle},
741 #else
742         /* Bug 2367: disturbing for Win32 users with no keypair */
743         {"default_sign_reply", "FALSE", &tmp_ac_prefs.default_sign_reply, P_BOOL,
744          &privacy_page.default_sign_reply_checkbtn,
745          prefs_set_data_from_toggle, prefs_set_toggle},
746 #endif
747         {"save_clear_text", "FALSE", &tmp_ac_prefs.save_encrypted_as_clear_text, P_BOOL,
748          &privacy_page.save_clear_text_checkbtn,
749          prefs_set_data_from_toggle, prefs_set_toggle},
750
751         {"encrypt_to_self", "FALSE", &tmp_ac_prefs.encrypt_to_self, P_BOOL,
752          &privacy_page.encrypt_to_self_checkbtn,
753          prefs_set_data_from_toggle, prefs_set_toggle},
754
755         {"privacy_prefs", "", &privacy_prefs, P_STRING,
756          NULL, NULL, NULL},
757
758         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
759 };
760
761 static PrefParam ssl_param[] = {
762 #ifdef USE_GNUTLS
763         {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
764          &ssl_page.pop_nossl_radiobtn,
765          prefs_account_enum_set_data_from_radiobtn,
766          prefs_account_enum_set_radiobtn},
767
768         {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM,
769          &ssl_page.imap_nossl_radiobtn,
770          prefs_account_enum_set_data_from_radiobtn,
771          prefs_account_enum_set_radiobtn},
772
773         {"ssl_nntp", "0", &tmp_ac_prefs.ssl_nntp, P_ENUM,
774          &ssl_page.nntp_nossl_radiobtn,
775          prefs_account_enum_set_data_from_radiobtn,
776          prefs_account_enum_set_radiobtn},
777
778         {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM,
779          &ssl_page.smtp_nossl_radiobtn,
780          prefs_account_enum_set_data_from_radiobtn,
781          prefs_account_enum_set_radiobtn},
782
783         {"ssl_certs_auto_accept", "0", &tmp_ac_prefs.ssl_certs_auto_accept, P_BOOL,
784          &ssl_page.ssl_certs_auto_accept_checkbtn,
785          prefs_set_data_from_toggle, prefs_set_toggle},
786
787         {"use_nonblocking_ssl", "1", &tmp_ac_prefs.use_nonblocking_ssl, P_BOOL,
788          &ssl_page.use_nonblocking_ssl_checkbtn,
789          prefs_set_data_from_toggle, prefs_set_toggle},
790
791         {"in_ssl_client_cert_file", "", &tmp_ac_prefs.in_ssl_client_cert_file, P_STRING,
792          &ssl_page.entry_in_cert_file, prefs_set_data_from_entry, prefs_set_entry},
793
794         {"in_ssl_client_cert_pass", "", &tmp_ac_prefs.in_ssl_client_cert_pass, P_PASSWORD,
795          NULL, NULL, NULL},
796
797         {"out_ssl_client_cert_file", "", &tmp_ac_prefs.out_ssl_client_cert_file, P_STRING,
798          &ssl_page.entry_out_cert_file, prefs_set_data_from_entry, prefs_set_entry},
799
800         {"out_ssl_client_cert_pass", "", &tmp_ac_prefs.out_ssl_client_cert_pass, P_PASSWORD,
801          NULL, NULL, NULL},
802 #else
803         {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
804          NULL, NULL, NULL},
805
806         {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM,
807          NULL, NULL, NULL},
808
809         {"ssl_nntp", "0", &tmp_ac_prefs.ssl_nntp, P_ENUM,
810          NULL, NULL, NULL},
811
812         {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM,
813          NULL, NULL, NULL},
814
815         {"in_ssl_client_cert_file", "", &tmp_ac_prefs.in_ssl_client_cert_file, P_STRING,
816          NULL, NULL, NULL},
817
818         {"in_ssl_client_cert_pass", "", &tmp_ac_prefs.in_ssl_client_cert_pass, P_PASSWORD,
819          NULL, NULL, NULL},
820
821         {"out_ssl_client_cert_file", "", &tmp_ac_prefs.out_ssl_client_cert_file, P_STRING,
822          NULL, NULL, NULL},
823
824         {"out_ssl_client_cert_pass", "", &tmp_ac_prefs.out_ssl_client_cert_pass, P_PASSWORD,
825          NULL, NULL, NULL},
826
827         {"ssl_certs_auto_accept", "0", &tmp_ac_prefs.ssl_certs_auto_accept, P_BOOL,
828          NULL, NULL, NULL},
829
830         {"use_nonblocking_ssl", "1", &tmp_ac_prefs.use_nonblocking_ssl, P_BOOL,
831          NULL, NULL, NULL},
832 #endif /* USE_GNUTLS */
833
834         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
835 };
836
837 static PrefParam proxy_param[] = {
838         /* SOCKS proxy */
839         {"use_proxy", "FALSE", &tmp_ac_prefs.use_proxy, P_BOOL,
840         &proxy_page.proxy_checkbtn,
841         prefs_set_data_from_toggle, prefs_set_toggle},
842
843         {"use_default_proxy", "TRUE", &tmp_ac_prefs.use_default_proxy, P_BOOL,
844         &proxy_page.default_proxy_checkbtn,
845         prefs_set_data_from_toggle, prefs_set_toggle},
846
847         {"use_proxy_for_send", "TRUE", &tmp_ac_prefs.use_proxy_for_send, P_BOOL,
848         &proxy_page.proxy_send_checkbtn,
849         prefs_set_data_from_toggle, prefs_set_toggle},
850
851         {"proxy_type", "1", &tmp_ac_prefs.proxy_info.proxy_type, P_ENUM,
852         &proxy_page.socks4_radiobtn,
853         prefs_account_enum_set_data_from_radiobtn,
854         prefs_account_enum_set_radiobtn},
855
856         {"proxy_host", "localhost", &tmp_ac_prefs.proxy_info.proxy_host, P_STRING,
857         &proxy_page.proxy_host_entry,
858         prefs_set_data_from_entry, prefs_set_entry},
859
860         {"proxy_port", "1080", &tmp_ac_prefs.proxy_info.proxy_port, P_USHORT,
861         &proxy_page.proxy_port_spinbtn,
862         prefs_set_data_from_spinbtn, prefs_set_spinbtn},
863
864         {"use_proxy_auth", "FALSE", &tmp_ac_prefs.proxy_info.use_proxy_auth, P_BOOL,
865         &proxy_page.proxy_auth_checkbtn,
866         prefs_set_data_from_toggle, prefs_set_toggle},
867
868         {"proxy_name", "", &tmp_ac_prefs.proxy_info.proxy_name, P_STRING,
869         &proxy_page.proxy_name_entry,
870         prefs_set_data_from_entry, prefs_set_entry},
871
872         {"proxy_pass", NULL, &tmp_ac_prefs.proxy_info.proxy_pass, P_PASSWORD,
873         NULL, NULL, NULL},
874
875
876         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
877 };
878
879 static PrefParam advanced_param[] = {
880         {"set_smtpport", "FALSE", &tmp_ac_prefs.set_smtpport, P_BOOL,
881          &advanced_page.smtpport_checkbtn,
882          prefs_set_data_from_toggle, prefs_set_toggle},
883
884         {"smtp_port", "25", &tmp_ac_prefs.smtpport, P_USHORT,
885          &advanced_page.smtpport_spinbtn,
886          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
887
888         {"set_popport", "FALSE", &tmp_ac_prefs.set_popport, P_BOOL,
889          &advanced_page.popport_checkbtn,
890          prefs_set_data_from_toggle, prefs_set_toggle},
891
892         {"pop_port", "110", &tmp_ac_prefs.popport, P_USHORT,
893          &advanced_page.popport_spinbtn,
894          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
895
896         {"set_imapport", "FALSE", &tmp_ac_prefs.set_imapport, P_BOOL,
897          &advanced_page.imapport_checkbtn,
898          prefs_set_data_from_toggle, prefs_set_toggle},
899
900         {"imap_port", "143", &tmp_ac_prefs.imapport, P_USHORT,
901          &advanced_page.imapport_spinbtn,
902          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
903
904         {"set_nntpport", "FALSE", &tmp_ac_prefs.set_nntpport, P_BOOL,
905          &advanced_page.nntpport_checkbtn,
906          prefs_set_data_from_toggle, prefs_set_toggle},
907
908         {"nntp_port", "119", &tmp_ac_prefs.nntpport, P_USHORT,
909          &advanced_page.nntpport_spinbtn,
910          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
911
912         {"set_domain", "FALSE", &tmp_ac_prefs.set_domain, P_BOOL,
913          &advanced_page.domain_checkbtn,
914          prefs_set_data_from_toggle, prefs_set_toggle},
915
916         {"domain", NULL, &tmp_ac_prefs.domain, P_STRING,
917          &advanced_page.domain_entry,
918          prefs_set_data_from_entry, prefs_set_entry},
919
920 #ifdef USE_GNUTLS
921         {"gnutls_set_priority", "FALSE", &tmp_ac_prefs.set_gnutls_priority, P_BOOL,
922          NULL, NULL, NULL},
923
924         {"gnutls_priority", NULL, &tmp_ac_prefs.gnutls_priority, P_STRING,
925          NULL, NULL, NULL},
926 #endif
927
928 #ifndef G_OS_WIN32
929         {"set_tunnelcmd", "FALSE", &tmp_ac_prefs.set_tunnelcmd, P_BOOL,
930          &advanced_page.tunnelcmd_checkbtn,
931          prefs_set_data_from_toggle, prefs_set_toggle},
932
933         {"tunnelcmd", NULL, &tmp_ac_prefs.tunnelcmd, P_STRING,
934          &advanced_page.tunnelcmd_entry,
935          prefs_set_data_from_entry, prefs_set_entry},
936 #endif
937         {"mark_crosspost_read", "FALSE", &tmp_ac_prefs.mark_crosspost_read, P_BOOL,
938          &advanced_page.crosspost_checkbtn,
939          prefs_set_data_from_toggle, prefs_set_toggle},
940
941         {"crosspost_color", NULL, &tmp_ac_prefs.crosspost_col, P_ENUM,
942          &advanced_page.crosspost_colormenu,
943          prefs_account_crosspost_set_data_from_colormenu,
944          prefs_account_crosspost_set_colormenu},
945
946         {"set_sent_folder", "FALSE", &tmp_ac_prefs.set_sent_folder, P_BOOL,
947          &advanced_page.sent_folder_checkbtn,
948          prefs_set_data_from_toggle, prefs_set_toggle},
949         {"sent_folder", NULL, &tmp_ac_prefs.sent_folder, P_STRING,
950          &advanced_page.sent_folder_entry,
951          prefs_set_data_from_entry, prefs_set_entry},
952
953         {"set_queue_folder", "FALSE", &tmp_ac_prefs.set_queue_folder, P_BOOL,
954          &advanced_page.queue_folder_checkbtn,
955          prefs_set_data_from_toggle, prefs_set_toggle},
956         {"queue_folder", NULL, &tmp_ac_prefs.queue_folder, P_STRING,
957          &advanced_page.queue_folder_entry,
958          prefs_set_data_from_entry, prefs_set_entry},
959
960         {"set_draft_folder", "FALSE", &tmp_ac_prefs.set_draft_folder, P_BOOL,
961          &advanced_page.draft_folder_checkbtn,
962          prefs_set_data_from_toggle, prefs_set_toggle},
963         {"draft_folder", NULL, &tmp_ac_prefs.draft_folder, P_STRING,
964          &advanced_page.draft_folder_entry,
965          prefs_set_data_from_entry, prefs_set_entry},
966
967         {"set_trash_folder", "FALSE", &tmp_ac_prefs.set_trash_folder, P_BOOL,
968          &advanced_page.trash_folder_checkbtn,
969          prefs_set_data_from_toggle, prefs_set_toggle},
970         {"trash_folder", NULL, &tmp_ac_prefs.trash_folder, P_STRING,
971          &advanced_page.trash_folder_entry,
972          prefs_set_data_from_entry, prefs_set_entry},
973          
974
975         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
976 };
977
978 static gint prefs_account_get_new_id            (void);
979
980 static void prefs_account_select_folder_cb      (GtkWidget      *widget,
981                                                  gpointer        data);
982
983 static void prefs_account_sigfile_radiobtn_cb   (GtkWidget      *widget,
984                                                  gpointer        data);
985
986 static void prefs_account_sigcmd_radiobtn_cb    (GtkWidget      *widget,
987                                                  gpointer        data);
988
989 static void prefs_account_signature_browse_cb   (GtkWidget      *widget,
990                                                  gpointer        data);
991 #ifdef USE_GNUTLS
992 static void prefs_account_in_cert_browse_cb     (GtkWidget      *widget,
993                                                  gpointer        data);
994
995 static void prefs_account_out_cert_browse_cb    (GtkWidget      *widget,
996                                                  gpointer        data);
997 #endif
998 static void prefs_account_signature_edit_cb     (GtkWidget      *widget,
999                                                  gpointer        data);
1000
1001 static void pop_bfr_smtp_tm_set_sens            (GtkWidget      *widget,
1002                                                  gpointer        data);
1003
1004 #if (defined USE_GNUTLS)
1005 static void auto_configure_cb                   (GtkWidget      *widget,
1006                                                  gpointer        data);
1007
1008 #endif
1009 static void prefs_account_edit_custom_header    (void);
1010
1011 static void prefs_account_receive_itv_spinbutton_value_changed_cb(GtkWidget *w,
1012                                           gpointer data);
1013
1014 #define COMBOBOX_PRIVACY_PLUGIN_ID 3
1015
1016 /* Enable/disable necessary preference widgets based on current privacy
1017  * system choice. */
1018 static void privacy_system_activated(GtkWidget *combobox)
1019 {
1020         gtk_widget_set_sensitive (privacy_page.save_clear_text_checkbtn, 
1021                 !gtk_toggle_button_get_active(
1022                                 GTK_TOGGLE_BUTTON(privacy_page.encrypt_to_self_checkbtn)));
1023 }
1024
1025 /* Populate the privacy system choice combobox with valid choices */
1026 static void update_privacy_system_menu() {
1027         GtkListStore *menu;
1028         GtkTreeIter iter;
1029         GSList *system_ids, *cur;
1030
1031         menu = GTK_LIST_STORE(gtk_combo_box_get_model(
1032                         GTK_COMBO_BOX(privacy_page.default_privacy_system)));
1033
1034         /* First add "None", as that one is always available. :) */
1035         gtk_list_store_append(menu, &iter);
1036         gtk_list_store_set(menu, &iter,
1037                         COMBOBOX_TEXT, _("None"),
1038                         COMBOBOX_DATA, 0,
1039                         COMBOBOX_SENS, TRUE,
1040                         COMBOBOX_PRIVACY_PLUGIN_ID, "",
1041                         -1);
1042
1043         /* Now go through list of available privacy systems and add an entry
1044          * for each. */
1045         system_ids = privacy_get_system_ids();
1046         for (cur = system_ids; cur != NULL; cur = g_slist_next(cur)) {
1047                 gchar *id = (gchar *) cur->data;
1048                 const gchar *name;
1049                 
1050                 name = privacy_system_get_name(id);
1051                 gtk_list_store_append(menu, &iter);
1052                 gtk_list_store_set(menu, &iter,
1053                                 COMBOBOX_TEXT, name,
1054                                 COMBOBOX_DATA, 1,
1055                                 COMBOBOX_SENS, TRUE,
1056                                 COMBOBOX_PRIVACY_PLUGIN_ID, id,
1057                                 -1);
1058                 g_free(id);
1059         }
1060         g_slist_free(system_ids);
1061
1062 }
1063
1064 #define TABLE_YPAD 2
1065
1066 static void basic_create_widget_func(PrefsPage * _page,
1067                                            GtkWindow * window,
1068                                            gpointer data)
1069 {
1070         BasicPage *page = (BasicPage *) _page;
1071         PrefsAccount *ac_prefs = (PrefsAccount *) data;
1072
1073         GtkWidget *vbox1;
1074         GtkWidget *hbox;
1075         GtkWidget *label;
1076         GtkWidget *acname_entry;
1077         GtkWidget *default_checkbtn;
1078         GtkWidget *frame1;
1079         GtkWidget *table1;
1080         GtkWidget *name_entry;
1081         GtkWidget *addr_entry;
1082         GtkWidget *org_entry;
1083
1084         GtkWidget *serv_frame;
1085         GtkWidget *vbox2;
1086         GtkWidget *optmenubox;
1087         GtkWidget *optmenu;
1088         GtkWidget *optlabel;
1089         GtkWidget *no_imap_warn_icon;
1090         GtkWidget *no_imap_warn_label;
1091         GtkWidget *serv_table;
1092         GtkWidget *recvserv_label;
1093         GtkWidget *smtpserv_label;
1094         GtkWidget *nntpserv_label;
1095         GtkWidget *localmbox_label;
1096         GtkWidget *mailcmd_label;
1097         GtkWidget *recvserv_entry;
1098         GtkWidget *smtpserv_entry;
1099         GtkWidget *nntpserv_entry;
1100         GtkWidget *nntpauth_checkbtn;
1101         GtkWidget *nntpauth_onconnect_checkbtn;
1102         GtkWidget *localmbox_entry;
1103         GtkWidget *mailcmd_checkbtn;
1104         GtkWidget *mailcmd_entry;
1105         GtkWidget *uid_label;
1106         GtkWidget *pass_label;
1107         GtkWidget *uid_entry;
1108         GtkWidget *pass_entry;
1109         GtkWidget *auto_configure_btn;
1110         GtkWidget *auto_configure_cancel_btn;
1111         GtkWidget *auto_configure_lbl;
1112         GtkWidget *showpwd_checkbtn;
1113         GtkListStore *menu;
1114         GtkTreeIter iter;
1115         gchar *buf;
1116
1117         struct BasicProtocol *protocol_optmenu;
1118         gint i;
1119
1120         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1121         gtk_widget_show (vbox1);
1122         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1123
1124         hbox = gtk_hbox_new (FALSE, 8);
1125         gtk_widget_show (hbox);
1126         gtk_box_pack_start (GTK_BOX (vbox1), hbox, FALSE, FALSE, 0);
1127
1128         label = gtk_label_new (_("Name of account"));
1129         gtk_widget_show (label);
1130         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1131
1132         acname_entry = gtk_entry_new ();
1133         gtk_widget_show (acname_entry);
1134         gtk_widget_set_size_request (acname_entry, DEFAULT_ENTRY_WIDTH, -1);
1135         gtk_box_pack_start (GTK_BOX (hbox), acname_entry, TRUE, TRUE, 0);
1136
1137         default_checkbtn = gtk_check_button_new_with_label (_("Set as default"));
1138         gtk_widget_show (default_checkbtn);
1139 #ifndef GENERIC_UMPC
1140         gtk_box_pack_end (GTK_BOX (hbox), default_checkbtn, TRUE, FALSE, 0);
1141 #else
1142         gtk_box_pack_start (GTK_BOX (vbox1), default_checkbtn, FALSE, FALSE, 0);
1143         
1144 #endif
1145         PACK_FRAME (vbox1, frame1, _("Personal information"));
1146
1147         table1 = gtk_table_new (3, 2, FALSE);
1148         gtk_widget_show (table1);
1149         gtk_container_add (GTK_CONTAINER (frame1), table1);
1150         gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
1151         gtk_table_set_row_spacings (GTK_TABLE (table1), VSPACING_NARROW);
1152         gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
1153
1154         label = gtk_label_new (_("Full name"));
1155         gtk_widget_show (label);
1156         gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 0, 1,
1157                           GTK_FILL, 0, 0, 0);
1158         gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
1159
1160         label = gtk_label_new (_("Mail address"));
1161         gtk_widget_show (label);
1162         gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 1, 2,
1163                           GTK_FILL, 0, 0, 0);
1164         gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
1165
1166         label = gtk_label_new (_("Organization"));
1167         gtk_widget_show (label);
1168         gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 2, 3,
1169                           GTK_FILL, 0, 0, 0);
1170         gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
1171
1172         name_entry = gtk_entry_new ();
1173         gtk_widget_show (name_entry);
1174         gtk_table_attach (GTK_TABLE (table1), name_entry, 1, 2, 0, 1,
1175                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1176                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1177
1178         addr_entry = gtk_entry_new ();
1179         gtk_widget_show (addr_entry);
1180         gtk_table_attach (GTK_TABLE (table1), addr_entry, 1, 2, 1, 2,
1181                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1182                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1183
1184         org_entry = gtk_entry_new ();
1185         gtk_widget_show (org_entry);
1186         gtk_table_attach (GTK_TABLE (table1), org_entry, 1, 2, 2, 3,
1187                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1188                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1189
1190         vbox2 = gtkut_get_options_frame(vbox1, &serv_frame, _("Server information"));
1191
1192         hbox = gtk_hbox_new (FALSE, 8);
1193         gtk_widget_show (hbox);
1194         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1195
1196         label = gtk_label_new (_("Protocol"));
1197         gtk_widget_show (label);
1198         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1199
1200         /* Create GtkHBox for protocol combobox and label */
1201         optmenubox = gtk_hbox_new(FALSE, 20);
1202         gtk_widget_show(optmenubox);
1203         gtk_box_pack_start (GTK_BOX (hbox), optmenubox, FALSE, FALSE, 0);
1204
1205         /* Create and populate the combobox */
1206         optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1207         gtk_box_pack_start(GTK_BOX (optmenubox), optmenu, FALSE, FALSE, 0);
1208
1209         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1210         for( i = 0; i < NUM_RECV_PROTOCOLS; i++ )
1211                 if( protocol_names[i] != NULL )
1212                         COMBOBOX_ADD (menu, _(protocol_names[i]), i);
1213
1214         g_signal_connect(G_OBJECT(optmenu), "changed",
1215                         G_CALLBACK(prefs_account_protocol_changed), NULL);
1216
1217         /* Create protocol label, empty for now */
1218         optlabel = gtk_label_new("");
1219         gtk_label_set_use_markup(GTK_LABEL(optlabel), TRUE);
1220         gtk_label_set_justify(GTK_LABEL(optlabel), GTK_JUSTIFY_CENTER);
1221         gtk_box_pack_start(GTK_BOX (optmenubox), optlabel, FALSE, FALSE, 0);
1222
1223         auto_configure_btn = gtk_button_new_with_label(_("Auto-configure"));
1224         gtk_box_pack_start(GTK_BOX (optmenubox), auto_configure_btn, FALSE, FALSE, 0);
1225         auto_configure_cancel_btn = gtk_button_new_with_label(_("Cancel"));
1226         gtk_box_pack_start(GTK_BOX (optmenubox), auto_configure_cancel_btn, FALSE, FALSE, 0);
1227         auto_configure_lbl = gtk_label_new("");
1228         gtk_label_set_justify(GTK_LABEL(auto_configure_lbl), GTK_JUSTIFY_LEFT);
1229         gtk_box_pack_start(GTK_BOX (optmenubox), auto_configure_lbl, FALSE, FALSE, 0);
1230 #if (defined USE_GNUTLS)
1231         gtk_widget_show(auto_configure_btn);
1232         gtk_widget_show(auto_configure_lbl);
1233         g_signal_connect (G_OBJECT (auto_configure_btn), "clicked",
1234                           G_CALLBACK (auto_configure_cb), NULL);
1235         g_signal_connect (G_OBJECT (auto_configure_cancel_btn), "clicked",
1236                           G_CALLBACK (auto_configure_cb), NULL);
1237 #endif
1238
1239         no_imap_warn_icon = gtk_image_new_from_stock
1240                         (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1241         buf = g_strconcat("<span weight=\"bold\">",
1242                         _("Warning: this version of Claws Mail\n"
1243                           "has been built without IMAP and News support."), "</span>", NULL);
1244         no_imap_warn_label = gtk_label_new(buf);
1245         g_free(buf);
1246         gtk_label_set_use_markup(GTK_LABEL(no_imap_warn_label), TRUE);
1247
1248         gtk_box_pack_start(GTK_BOX (optmenubox), no_imap_warn_icon, FALSE, FALSE, 0);
1249         gtk_box_pack_start(GTK_BOX (optmenubox), no_imap_warn_label, FALSE, FALSE, 0);
1250         /* Set up a struct to store pointers to necessary widgets */
1251         protocol_optmenu = g_new(struct BasicProtocol, 1);
1252         protocol_optmenu->combobox = optmenu;
1253         protocol_optmenu->label = optlabel;
1254         protocol_optmenu->descrlabel = label;
1255         protocol_optmenu->no_imap_warn_icon = no_imap_warn_icon;
1256         protocol_optmenu->no_imap_warn_label = no_imap_warn_label;
1257
1258         serv_table = gtk_table_new (10, 4, FALSE);
1259         gtk_widget_show (serv_table);
1260         gtk_box_pack_start (GTK_BOX (vbox2), serv_table, FALSE, FALSE, 0);
1261         gtk_table_set_row_spacings (GTK_TABLE (serv_table), VSPACING_NARROW);
1262         gtk_table_set_row_spacing (GTK_TABLE (serv_table), 3, 0);
1263         gtk_table_set_col_spacings (GTK_TABLE (serv_table), 8);
1264
1265         nntpserv_entry = gtk_entry_new ();
1266         gtk_widget_show (nntpserv_entry);
1267         gtk_table_attach (GTK_TABLE (serv_table), nntpserv_entry, 1, 4, 0, 1,
1268                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1269                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1270 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 0, 0); */
1271
1272         nntpauth_checkbtn = gtk_check_button_new_with_label
1273                 (_("This server requires authentication"));
1274         gtk_widget_show (nntpauth_checkbtn);
1275         
1276         gtk_table_attach (GTK_TABLE (serv_table), nntpauth_checkbtn, 0, 2, 6, 7,
1277                           GTK_FILL, 0, 0, 0);
1278
1279         nntpauth_onconnect_checkbtn = gtk_check_button_new_with_label
1280                 (_("Authenticate on connect"));
1281         gtk_widget_show (nntpauth_onconnect_checkbtn);
1282
1283         gtk_table_attach (GTK_TABLE (serv_table), nntpauth_onconnect_checkbtn, 2, 4, 6, 7,
1284                           GTK_FILL, 0, 0, 0);
1285
1286         recvserv_entry = gtk_entry_new ();
1287         gtk_widget_show (recvserv_entry);
1288         gtk_table_attach (GTK_TABLE (serv_table), recvserv_entry, 1, 4, 2, 3,
1289                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1290                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1291
1292         localmbox_entry = gtk_entry_new ();
1293         gtk_widget_show (localmbox_entry);
1294         gtk_table_attach (GTK_TABLE (serv_table), localmbox_entry, 1, 4, 3, 4,
1295                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1296                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1297
1298         smtpserv_entry = gtk_entry_new ();
1299         gtk_widget_show (smtpserv_entry);
1300         gtk_table_attach (GTK_TABLE (serv_table), smtpserv_entry, 1, 4, 4, 5,
1301                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1302                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1303
1304         mailcmd_entry = gtk_entry_new ();
1305         gtk_widget_show (mailcmd_entry);
1306         gtk_table_attach (GTK_TABLE (serv_table), mailcmd_entry, 1, 4, 6, 7,
1307                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1308                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1309
1310         uid_entry = gtk_entry_new ();
1311         gtk_widget_show (uid_entry);
1312         gtk_widget_set_size_request (uid_entry, DEFAULT_ENTRY_WIDTH, -1);
1313         g_signal_connect(G_OBJECT(uid_entry), "changed",
1314                         G_CALLBACK(prefs_account_entry_changed_newline_check_cb),
1315                         GINT_TO_POINTER(ac_prefs->protocol));
1316
1317         pass_entry = gtk_entry_new ();
1318         gtk_widget_show (pass_entry);
1319         gtk_widget_set_size_request (pass_entry, DEFAULT_ENTRY_WIDTH, -1);
1320         g_signal_connect(G_OBJECT(pass_entry), "changed",
1321                         G_CALLBACK(prefs_account_entry_changed_newline_check_cb),
1322                         GINT_TO_POINTER(ac_prefs->protocol));
1323
1324 #ifndef GENERIC_UMPC
1325         gtk_table_attach (GTK_TABLE (serv_table), uid_entry, 1, 2, 7, 8,
1326                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1327                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1328
1329         gtk_table_attach (GTK_TABLE (serv_table), pass_entry, 3, 4, 7, 8,
1330                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1331                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1332 #else
1333         gtk_table_attach (GTK_TABLE (serv_table), uid_entry, 1, 4, 7, 8,
1334                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1335                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1336         gtk_table_attach (GTK_TABLE (serv_table), pass_entry, 1, 4, 8, 9,
1337                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1338                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1339 #endif
1340         gtk_entry_set_visibility (GTK_ENTRY (pass_entry), FALSE);
1341
1342         nntpserv_label = gtk_label_new (_("News server"));
1343         gtk_widget_show (nntpserv_label);
1344         gtk_table_attach (GTK_TABLE (serv_table), nntpserv_label, 0, 1, 0, 1,
1345                           GTK_FILL, 0, 0, 0);
1346         gtk_misc_set_alignment (GTK_MISC (nntpserv_label), 1, 0.5);
1347
1348         recvserv_label = gtk_label_new (_("Server for receiving"));
1349         gtk_widget_show (recvserv_label);
1350         gtk_table_attach (GTK_TABLE (serv_table), recvserv_label, 0, 1, 2, 3,
1351                           GTK_FILL, 0, 0, 0);
1352         gtk_misc_set_alignment (GTK_MISC (recvserv_label), 1, 0.5);
1353
1354         localmbox_label = gtk_label_new (_("Local mailbox"));
1355         gtk_widget_show (localmbox_label);
1356         gtk_table_attach (GTK_TABLE (serv_table), localmbox_label, 0, 1, 3, 4,
1357                           GTK_FILL, 0, 0, 0);
1358         gtk_misc_set_alignment (GTK_MISC (localmbox_label), 1, 0.5);
1359 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
1360
1361         smtpserv_label = gtk_label_new (_("SMTP server (send)"));
1362         gtk_widget_show (smtpserv_label);
1363         gtk_table_attach (GTK_TABLE (serv_table), smtpserv_label, 0, 1, 4, 5,
1364                           GTK_FILL, 0, 0, 0);
1365         gtk_misc_set_alignment (GTK_MISC (smtpserv_label), 1, 0.5);
1366 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
1367
1368         mailcmd_checkbtn = gtk_check_button_new_with_label
1369                 (_("Use mail command rather than SMTP server"));
1370         gtk_widget_show (mailcmd_checkbtn);
1371         gtk_table_attach (GTK_TABLE (serv_table), mailcmd_checkbtn, 0, 4, 5, 6,
1372                           GTK_EXPAND | GTK_FILL,
1373                           0, 0, TABLE_YPAD);
1374         g_signal_connect(G_OBJECT(mailcmd_checkbtn), "toggled",
1375                          G_CALLBACK(prefs_account_mailcmd_toggled),
1376                          NULL);
1377
1378         mailcmd_label = gtk_label_new (_("command to send mails"));
1379         gtk_widget_show (mailcmd_label);
1380         gtk_table_attach (GTK_TABLE (serv_table), mailcmd_label, 0, 1, 6, 7,
1381                           GTK_FILL, 0, 0, 0);
1382         gtk_misc_set_alignment (GTK_MISC (mailcmd_label), 1, 0.5);
1383 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
1384
1385         uid_label = gtk_label_new (_("User ID"));
1386         gtk_widget_show (uid_label);
1387         gtk_table_attach (GTK_TABLE (serv_table), uid_label, 0, 1, 7, 8,
1388                           GTK_FILL, 0, 0, 0);
1389         gtk_misc_set_alignment (GTK_MISC (uid_label), 1, 0.5);
1390
1391         pass_label = gtk_label_new (_("Password"));
1392         gtk_widget_show (pass_label);
1393 #ifndef GENERIC_UMPC
1394         gtk_table_attach (GTK_TABLE (serv_table), pass_label, 2, 3, 7, 8,
1395                           0, 0, 0, 0);
1396 #else
1397         gtk_misc_set_alignment (GTK_MISC (pass_label), 1, 0.5);
1398         gtk_table_attach (GTK_TABLE (serv_table), pass_label, 0, 1, 8, 9,
1399                           GTK_FILL, 0, 0, 0);
1400 #endif
1401
1402         showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password"));
1403         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE);
1404         gtk_widget_show(showpwd_checkbtn);
1405         gtk_table_attach (GTK_TABLE (serv_table), showpwd_checkbtn, 3, 4, 9, 10,
1406                         GTK_FILL, 0, 0, 0);
1407         g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled",
1408                         G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), pass_entry);
1409
1410         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, uid_label);
1411         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, pass_label);
1412         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, uid_entry);
1413         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, pass_entry);
1414         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, showpwd_checkbtn);
1415         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, nntpauth_onconnect_checkbtn);
1416
1417         page->acname_entry   = acname_entry;
1418         page->default_checkbtn = default_checkbtn;
1419
1420         page->name_entry = name_entry;
1421         page->addr_entry = addr_entry;
1422         page->org_entry  = org_entry;
1423
1424         page->serv_frame       = serv_frame;
1425         page->serv_table       = serv_table;
1426         page->protocol_optmenu = (gpointer)protocol_optmenu;
1427         page->recvserv_label   = recvserv_label;
1428         page->recvserv_entry   = recvserv_entry;
1429         page->smtpserv_label   = smtpserv_label;
1430         page->smtpserv_entry   = smtpserv_entry;
1431         page->nntpserv_label   = nntpserv_label;
1432         page->nntpserv_entry   = nntpserv_entry;
1433         page->nntpauth_checkbtn  = nntpauth_checkbtn;
1434         page->nntpauth_onconnect_checkbtn  = nntpauth_onconnect_checkbtn;
1435         page->localmbox_label   = localmbox_label;
1436         page->localmbox_entry   = localmbox_entry;
1437         page->mailcmd_checkbtn   = mailcmd_checkbtn;
1438         page->mailcmd_label   = mailcmd_label;
1439         page->mailcmd_entry   = mailcmd_entry;
1440         page->uid_label        = uid_label;
1441         page->pass_label       = pass_label;
1442         page->uid_entry        = uid_entry;
1443         page->pass_entry       = pass_entry;
1444         page->showpwd_checkbtn = showpwd_checkbtn;
1445         page->auto_configure_btn = auto_configure_btn;
1446         page->auto_configure_cancel_btn = auto_configure_cancel_btn;
1447         page->auto_configure_lbl = auto_configure_lbl;
1448
1449         if (new_account) {
1450                 PrefsAccount *def_ac;
1451
1452                 prefs_set_dialog_to_default(basic_param);
1453                 buf = g_strdup_printf(_("Account%d"), ac_prefs->account_id);
1454                 gtk_entry_set_text(GTK_ENTRY(basic_page.acname_entry), buf);
1455                 g_free(buf);
1456                 def_ac = account_get_default();
1457                 if (def_ac) {
1458                         FolderItem *item = folder_get_default_inbox_for_class(F_MH);
1459                         gtk_entry_set_text(GTK_ENTRY(basic_page.name_entry),
1460                                            def_ac->name ? def_ac->name : "");
1461                         gtk_entry_set_text(GTK_ENTRY(basic_page.addr_entry),
1462                                            def_ac->address ? def_ac->address : "");
1463                         gtk_entry_set_text(GTK_ENTRY(basic_page.org_entry),
1464                                            def_ac->organization ? def_ac->organization : "");
1465                         if (!item) {
1466                                 item = folder_get_default_inbox();
1467                         }
1468                         if (item) {
1469                                 gchar *id = folder_item_get_identifier(item);
1470                                 gtk_entry_set_text(GTK_ENTRY(receive_page.inbox_entry),
1471                                         id);
1472                                 gtk_entry_set_text(GTK_ENTRY(receive_page.local_inbox_entry),
1473                                         id);
1474                                 g_free(id);
1475                         }
1476                 }
1477         } else {
1478                 prefs_set_dialog(basic_param);
1479
1480                 /* Passwords are handled outside of PrefParams. */
1481                 buf = passwd_store_get_account(ac_prefs->account_id,
1482                                 PWS_ACCOUNT_RECV);
1483                 gtk_entry_set_text(GTK_ENTRY(page->pass_entry), buf != NULL ? buf : "");
1484                 if (buf != NULL) {
1485                         memset(buf, 0, strlen(buf));
1486                         g_free(buf);
1487                 }
1488         }
1489
1490         page->vbox = vbox1;
1491
1492         page->page.widget = vbox1;
1493 }
1494
1495 static void receive_create_widget_func(PrefsPage * _page,
1496                                            GtkWindow * window,
1497                                            gpointer data)
1498 {
1499         ReceivePage *page = (ReceivePage *) _page;
1500         PrefsAccount *ac_prefs = (PrefsAccount *) data;
1501
1502         GtkWidget *vbox1, *vbox2, *vbox3, *vbox4;
1503         GtkWidget *hbox1, *hbox2;
1504         GtkWidget *frame1;
1505         GtkWidget *use_apop_checkbtn;
1506         GtkWidget *rmmail_checkbtn;
1507         GtkWidget *hbox_spc;
1508         GtkWidget *leave_time_label;
1509         GtkWidget *leave_time_spinbtn;
1510         GtkWidget *leave_hour_label;
1511         GtkWidget *leave_hour_spinbtn;
1512         GtkWidget *size_limit_checkbtn;
1513         GtkWidget *size_limit_spinbtn;
1514         GtkWidget *label;
1515         GtkWidget *filter_on_recv_checkbtn;
1516         GtkWidget *filterhook_on_recv_checkbtn;
1517         GtkWidget *inbox_label;
1518         GtkWidget *inbox_entry;
1519         GtkWidget *inbox_btn;
1520         GtkWidget *imap_frame;
1521         GtkWidget *imapdir_label;
1522         GtkWidget *imapdir_entry;
1523         GtkWidget *subsonly_checkbtn;
1524         GtkWidget *low_bandwidth_checkbtn;
1525         GtkWidget *local_frame;
1526         GtkWidget *local_vbox;
1527         GtkWidget *local_hbox;
1528         GtkWidget *local_inbox_label;
1529         GtkWidget *local_inbox_entry;
1530         GtkWidget *local_inbox_btn;
1531         GtkWidget *autochk_checkbtn;
1532         GtkWidget *autochk_hour_spinbtn, *autochk_hour_label;
1533         GtkWidget *autochk_min_spinbtn, *autochk_min_label;
1534         GtkWidget *autochk_sec_spinbtn, *autochk_sec_label;
1535         GtkWidget *autochk_use_default_checkbtn;
1536         GtkObject *adj;
1537         struct AutocheckWidgets *autochk_widgets;
1538
1539         GtkWidget *optmenu;
1540         GtkListStore *menu;
1541         GtkTreeIter iter;
1542         GtkWidget *recvatgetall_checkbtn;
1543
1544         GtkWidget *frame, *frame2;
1545         GtkWidget *maxarticle_label;
1546         GtkWidget *maxarticle_spinbtn;
1547         GtkAdjustment *maxarticle_spinbtn_adj;
1548
1549         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1550         gtk_widget_show (vbox1);
1551         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1552
1553         local_vbox = gtkut_get_options_frame(vbox1, &local_frame, _("Local"));
1554
1555         local_hbox = gtk_hbox_new (FALSE, 8);
1556         gtk_widget_show (local_hbox);
1557         gtk_box_pack_start (GTK_BOX (local_vbox), local_hbox, FALSE, FALSE, 0);
1558
1559         local_inbox_label = gtk_label_new (_("Default Inbox"));
1560         gtk_widget_show (local_inbox_label);
1561         gtk_box_pack_start (GTK_BOX (local_hbox), local_inbox_label, FALSE, FALSE, 0);
1562
1563         local_inbox_entry = gtk_entry_new ();
1564         gtk_widget_show (local_inbox_entry);
1565         CLAWS_SET_TIP(local_inbox_entry,
1566                              _("Unfiltered messages will be stored in this folder"));
1567         gtk_widget_set_size_request (local_inbox_entry, DEFAULT_ENTRY_WIDTH, -1);
1568         gtk_box_pack_start (GTK_BOX (local_hbox), local_inbox_entry, TRUE, TRUE, 0);
1569
1570         local_inbox_btn = gtkut_get_browse_file_btn(_("Bro_wse"));
1571         gtk_widget_show (local_inbox_btn);
1572         CLAWS_SET_TIP(local_inbox_btn,
1573                              _("Unfiltered messages will be stored in this folder"));
1574         gtk_box_pack_start (GTK_BOX (local_hbox), local_inbox_btn, FALSE, FALSE, 0);
1575         g_signal_connect (G_OBJECT (local_inbox_btn), "clicked",
1576                           G_CALLBACK (prefs_account_select_folder_cb),
1577                           local_inbox_entry);
1578
1579         vbox2 = gtkut_get_options_frame(vbox1, &frame1, _("POP"));
1580         PACK_CHECK_BUTTON (vbox2, use_apop_checkbtn,
1581                            _("Use secure authentication (APOP)"));
1582
1583         PACK_CHECK_BUTTON (vbox2, rmmail_checkbtn,
1584                            _("Remove messages on server when received"));
1585
1586         hbox1 = gtk_hbox_new (FALSE, 8);
1587         gtk_widget_show (hbox1);
1588         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1589
1590         hbox_spc = gtk_hbox_new (FALSE, 0);
1591         gtk_widget_show (hbox_spc);
1592         gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1593         gtk_widget_set_size_request (hbox_spc, 12, -1);
1594
1595         leave_time_label = gtk_label_new (_("Remove after"));
1596         gtk_widget_show (leave_time_label);
1597         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1598
1599         leave_time_spinbtn = gtk_spin_button_new_with_range(0, 365, 1);
1600         gtk_widget_show (leave_time_spinbtn);
1601         CLAWS_SET_TIP(leave_time_spinbtn,
1602                              _("0 days and 0 hours : remove immediately"));
1603         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_spinbtn, FALSE, FALSE, 0);
1604
1605         leave_time_label = gtk_label_new (_("days"));
1606         gtk_widget_show (leave_time_label);
1607         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1608
1609         leave_hour_spinbtn = gtk_spin_button_new_with_range(0, 23, 1);
1610         gtk_widget_show (leave_hour_spinbtn);
1611         CLAWS_SET_TIP(leave_hour_spinbtn,
1612                              _("0 days and 0 hours : remove immediately"));
1613         gtk_box_pack_start (GTK_BOX (hbox1), leave_hour_spinbtn, FALSE, FALSE, 0);
1614
1615         leave_hour_label = gtk_label_new (_("hours"));
1616         gtk_widget_show (leave_hour_label);
1617         gtk_box_pack_start (GTK_BOX (hbox1), leave_hour_label, FALSE, FALSE, 0);
1618
1619         SET_TOGGLE_SENSITIVITY (rmmail_checkbtn, hbox1);
1620
1621         hbox1 = gtk_hbox_new (FALSE, 8);
1622         gtk_widget_show (hbox1);
1623         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1624
1625         PACK_CHECK_BUTTON (hbox1, size_limit_checkbtn, _("Receive size limit"));
1626
1627         CLAWS_SET_TIP(size_limit_checkbtn,
1628                              _("Messages over this limit will be partially retrieved. "
1629                                "When selecting them you will be able to download them fully "
1630                                "or delete them."));
1631
1632         size_limit_spinbtn = gtk_spin_button_new_with_range(0, 100000, 1);
1633         gtk_widget_show (size_limit_spinbtn);
1634         gtk_box_pack_start (GTK_BOX (hbox1), size_limit_spinbtn, FALSE, FALSE, 0);
1635
1636         label = gtk_label_new (_("KB"));
1637         gtk_widget_show (label);
1638         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1639
1640         SET_TOGGLE_SENSITIVITY (size_limit_checkbtn, size_limit_spinbtn);
1641
1642         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1643
1644         hbox1 = gtk_hbox_new (FALSE, 8);
1645         gtk_widget_show (hbox1);
1646         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1647
1648         inbox_label = gtk_label_new (_("Default Inbox"));
1649         gtk_widget_show (inbox_label);
1650         gtk_box_pack_start (GTK_BOX (hbox1), inbox_label, FALSE, FALSE, 0);
1651
1652         inbox_entry = gtk_entry_new ();
1653         gtk_widget_show (inbox_entry);
1654         CLAWS_SET_TIP(inbox_entry,
1655                              _("Unfiltered messages will be stored in this folder"));
1656         gtk_widget_set_size_request (inbox_entry, DEFAULT_ENTRY_WIDTH, -1);
1657         gtk_box_pack_start (GTK_BOX (hbox1), inbox_entry, TRUE, TRUE, 0);
1658
1659         inbox_btn = gtkut_get_browse_file_btn(_("Bro_wse"));
1660         gtk_widget_show (inbox_btn);
1661         CLAWS_SET_TIP(inbox_btn,
1662                              _("Unfiltered messages will be stored in this folder"));
1663         gtk_box_pack_start (GTK_BOX (hbox1), inbox_btn, FALSE, FALSE, 0);
1664         g_signal_connect (G_OBJECT (inbox_btn), "clicked",
1665                           G_CALLBACK (prefs_account_select_folder_cb),
1666                           inbox_entry);
1667
1668         vbox2 = gtkut_get_options_frame(vbox1, &frame2, _("NNTP"));
1669
1670         hbox2 = gtk_hbox_new (FALSE, 8);
1671         gtk_widget_show (hbox2);
1672         gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
1673
1674         maxarticle_label = gtk_label_new
1675                 (_("Maximum number of articles to download"));
1676         gtk_widget_show (maxarticle_label);
1677         gtk_box_pack_start (GTK_BOX (hbox2), maxarticle_label, FALSE, FALSE, 0);
1678
1679         maxarticle_spinbtn_adj =
1680                 GTK_ADJUSTMENT(gtk_adjustment_new (300, 0, 10000, 10, 100, 0));
1681         maxarticle_spinbtn = gtk_spin_button_new
1682                 (GTK_ADJUSTMENT (maxarticle_spinbtn_adj), 10, 0);
1683         gtk_widget_show (maxarticle_spinbtn);
1684         CLAWS_SET_TIP(maxarticle_spinbtn,
1685                              _("unlimited if 0 is specified"));
1686         gtk_box_pack_start (GTK_BOX (hbox2), maxarticle_spinbtn,
1687                             FALSE, FALSE, 0);
1688         gtk_widget_set_size_request (maxarticle_spinbtn, 64, -1);
1689         gtk_spin_button_set_numeric
1690                 (GTK_SPIN_BUTTON (maxarticle_spinbtn), TRUE);
1691
1692         vbox2 = gtkut_get_options_frame(vbox1, &imap_frame, _("IMAP"));
1693
1694         hbox1 = gtk_hbox_new (FALSE, 8);
1695         gtk_widget_show (hbox1);
1696         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1697
1698         label = gtk_label_new (_("Authentication method"));
1699         gtk_widget_show (label);
1700         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1701
1702
1703         optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1704         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1705         gtk_widget_show (optmenu);
1706         gtk_box_pack_start (GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
1707
1708         COMBOBOX_ADD (menu, _("Automatic"), 0);
1709         COMBOBOX_ADD (menu, NULL, 0);
1710         COMBOBOX_ADD (menu, _("Plain text"), IMAP_AUTH_PLAINTEXT);
1711         COMBOBOX_ADD (menu, "CRAM-MD5", IMAP_AUTH_CRAM_MD5);
1712         COMBOBOX_ADD (menu, "ANONYMOUS", IMAP_AUTH_ANON);
1713         COMBOBOX_ADD (menu, "GSSAPI", IMAP_AUTH_GSSAPI);
1714         COMBOBOX_ADD (menu, "DIGEST-MD5", IMAP_AUTH_DIGEST_MD5);
1715         COMBOBOX_ADD (menu, "SCRAM-SHA-1", IMAP_AUTH_SCRAM_SHA1);
1716         COMBOBOX_ADD (menu, "PLAIN", IMAP_AUTH_PLAIN);
1717         COMBOBOX_ADD (menu, "LOGIN", IMAP_AUTH_LOGIN);
1718
1719         hbox1 = gtk_hbox_new (FALSE, 8);
1720         gtk_widget_show (hbox1);
1721         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1722
1723         imapdir_label = gtk_label_new (_("IMAP server directory"));
1724         gtk_widget_show (imapdir_label);
1725         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
1726
1727         imapdir_label = gtk_label_new(_("(usually empty)"));
1728         gtk_widget_show (imapdir_label);
1729         gtkut_widget_set_small_font_size (imapdir_label);
1730         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
1731
1732         imapdir_entry = gtk_entry_new();
1733         gtk_widget_show (imapdir_entry);
1734         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_entry, FALSE, FALSE, 0);
1735
1736         hbox1 = gtk_hbox_new (FALSE, 8);
1737         gtk_widget_show (hbox1);
1738         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1739
1740         PACK_CHECK_BUTTON (hbox1, subsonly_checkbtn,
1741                            _("Show subscribed folders only"));
1742
1743         hbox1 = gtk_hbox_new (FALSE, 8);
1744         gtk_widget_show (hbox1);
1745         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1746
1747         PACK_CHECK_BUTTON (hbox1, low_bandwidth_checkbtn,
1748                            _("Bandwidth-efficient mode (prevents retrieving remote tags)"));
1749         CLAWS_SET_TIP(low_bandwidth_checkbtn,
1750                              _("This mode uses less bandwidth, but can be slower with some servers."));
1751
1752         hbox1 = gtk_hbox_new (FALSE, 8);
1753         gtk_widget_show (hbox1);
1754         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1755
1756         /* Auto-checking */
1757         vbox4 = gtkut_get_options_frame(vbox1, &frame, _("Automatic checking"));
1758
1759         PACK_CHECK_BUTTON(vbox4, autochk_use_default_checkbtn,
1760                         _("Use global settings"));
1761
1762         hbox2 = gtk_hbox_new(FALSE, 8);
1763         gtk_box_pack_start(GTK_BOX(vbox4), hbox2, FALSE, FALSE, 0);
1764
1765         PACK_CHECK_BUTTON(hbox2, autochk_checkbtn,
1766                         _("Check for new mail every"));
1767
1768         adj = gtk_adjustment_new(5, 0, 99, 1, 10, 0);
1769         autochk_hour_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
1770         gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(autochk_hour_spinbtn), TRUE);
1771         gtk_box_pack_start(GTK_BOX(hbox2), autochk_hour_spinbtn, FALSE, FALSE, 0);
1772         autochk_hour_label = gtk_label_new(_("hours"));
1773         gtk_box_pack_start(GTK_BOX(hbox2), autochk_hour_label, FALSE, FALSE, 0);
1774
1775         adj = gtk_adjustment_new(5, 0, 99, 1, 10, 0);
1776         autochk_min_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
1777         gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(autochk_min_spinbtn), TRUE);
1778         gtk_box_pack_start(GTK_BOX(hbox2), autochk_min_spinbtn, FALSE, FALSE, 0);
1779         autochk_min_label = gtk_label_new(_("minutes"));
1780         gtk_box_pack_start(GTK_BOX(hbox2), autochk_min_label, FALSE, FALSE, 0);
1781
1782         adj = gtk_adjustment_new(5, 0, 99, 1, 10, 0);
1783         autochk_sec_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
1784         gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(autochk_sec_spinbtn), TRUE);
1785         gtk_box_pack_start(GTK_BOX(hbox2), autochk_sec_spinbtn, FALSE, FALSE, 0);
1786         autochk_sec_label = gtk_label_new(_("seconds"));
1787         gtk_box_pack_start(GTK_BOX(hbox2), autochk_sec_label, FALSE, FALSE, 0);
1788
1789         autochk_widgets = g_new0(struct AutocheckWidgets, 1);
1790         autochk_widgets->autochk_hour_spinbtn = autochk_hour_spinbtn;
1791         autochk_widgets->autochk_min_spinbtn = autochk_min_spinbtn;
1792         autochk_widgets->autochk_sec_spinbtn = autochk_sec_spinbtn;
1793
1794         gtk_widget_show_all(vbox4);
1795
1796         SET_TOGGLE_SENSITIVITY_REVERSE(autochk_use_default_checkbtn, hbox2);
1797         SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_hour_spinbtn);
1798         SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_min_spinbtn);
1799         SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_sec_spinbtn);
1800         SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_hour_label);
1801         SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_min_label);
1802         SET_TOGGLE_SENSITIVITY(autochk_checkbtn, autochk_sec_label);
1803
1804         PACK_CHECK_BUTTON (vbox1, filter_on_recv_checkbtn,
1805                            _("Filter messages on receiving"));
1806
1807         g_signal_connect(G_OBJECT(filter_on_recv_checkbtn), "toggled",
1808                          G_CALLBACK(prefs_account_filter_on_recv_toggled),
1809                          NULL);
1810         g_signal_connect(G_OBJECT(autochk_hour_spinbtn), "value-changed",
1811                 G_CALLBACK(prefs_account_receive_itv_spinbutton_value_changed_cb),
1812                 (gpointer) page);
1813         g_signal_connect(G_OBJECT(autochk_min_spinbtn), "value-changed",
1814                 G_CALLBACK(prefs_account_receive_itv_spinbutton_value_changed_cb),
1815                 (gpointer) page);
1816         g_signal_connect(G_OBJECT(autochk_sec_spinbtn), "value-changed",
1817                 G_CALLBACK(prefs_account_receive_itv_spinbutton_value_changed_cb),
1818                 (gpointer) page);
1819
1820         PACK_CHECK_BUTTON (vbox1, filterhook_on_recv_checkbtn,
1821                            _("Allow filtering using plugins on receiving"));
1822
1823         PACK_CHECK_BUTTON
1824                 (vbox1, recvatgetall_checkbtn,
1825                  _("'Get Mail' checks for new messages on this account"));
1826
1827         page->pop3_frame               = frame1;
1828         page->use_apop_checkbtn          = use_apop_checkbtn;
1829         page->rmmail_checkbtn            = rmmail_checkbtn;
1830         page->leave_time_spinbtn         = leave_time_spinbtn;
1831         page->leave_hour_spinbtn         = leave_hour_spinbtn;
1832         page->size_limit_checkbtn        = size_limit_checkbtn;
1833         page->size_limit_spinbtn         = size_limit_spinbtn;
1834         page->filter_on_recv_checkbtn    = filter_on_recv_checkbtn;
1835         page->filterhook_on_recv_checkbtn = filterhook_on_recv_checkbtn;
1836         page->inbox_label              = inbox_label;
1837         page->inbox_entry              = inbox_entry;
1838         page->inbox_btn                = inbox_btn;
1839
1840         page->autochk_frame            = frame;
1841
1842         page->imap_frame               = imap_frame;
1843         page->imap_auth_type_optmenu   = optmenu;
1844
1845         page->imapdir_label             = imapdir_label;
1846         page->imapdir_entry             = imapdir_entry;
1847         page->subsonly_checkbtn         = subsonly_checkbtn;
1848         page->low_bandwidth_checkbtn    = low_bandwidth_checkbtn;
1849         page->local_frame               = local_frame;
1850         page->local_inbox_label = local_inbox_label;
1851         page->local_inbox_entry = local_inbox_entry;
1852         page->local_inbox_btn           = local_inbox_btn;
1853
1854         page->recvatgetall_checkbtn      = recvatgetall_checkbtn;
1855
1856         page->frame_maxarticle  = frame2;
1857         page->maxarticle_spinbtn        = maxarticle_spinbtn;
1858         page->maxarticle_spinbtn_adj    = maxarticle_spinbtn_adj;
1859
1860         page->autochk_checkbtn = autochk_checkbtn;
1861         page->autochk_widgets = autochk_widgets;
1862         page->autochk_use_default_checkbtn = autochk_use_default_checkbtn;
1863
1864         tmp_ac_prefs = *ac_prefs;
1865
1866         if (new_account) {
1867                 prefs_set_dialog_to_default(receive_param);
1868         } else
1869                 prefs_set_dialog(receive_param);
1870
1871         page->vbox = vbox1;
1872
1873         page->page.widget = vbox1;
1874 }
1875
1876 static void send_create_widget_func(PrefsPage * _page,
1877                                            GtkWindow * window,
1878                                            gpointer data)
1879 {
1880         SendPage *page = (SendPage *) _page;
1881         PrefsAccount *ac_prefs = (PrefsAccount *) data;
1882
1883         GtkWidget *vbox1;
1884         GtkWidget *vbox2;
1885         GtkWidget *frame;
1886         GtkWidget *msgid_checkbtn;
1887         GtkWidget *xmailer_checkbtn;
1888         GtkWidget *hbox;
1889         GtkWidget *customhdr_checkbtn;
1890         GtkWidget *customhdr_edit_btn;
1891         GtkWidget *checkbtn_msgid_with_addr;
1892         GtkWidget *vbox3;
1893         GtkWidget *smtp_auth_checkbtn;
1894         GtkWidget *showpwd_checkbtn;
1895         GtkWidget *optmenu;
1896         GtkListStore *menu;
1897         GtkTreeIter iter;
1898         GtkWidget *vbox4;
1899         GtkWidget *hbox_spc;
1900         GtkWidget *label;
1901         GtkWidget *smtp_uid_entry;
1902         GtkWidget *smtp_pass_entry;
1903         GtkWidget *vbox_spc;
1904         GtkWidget *pop_bfr_smtp_checkbtn;
1905         GtkWidget *pop_bfr_smtp_tm_spinbtn;
1906         GtkWidget *pop_auth_timeout_lbl;
1907         GtkWidget *pop_auth_minutes_lbl;
1908         gchar *buf;
1909
1910         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1911         gtk_widget_show (vbox1);
1912         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1913
1914         vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Header"));
1915
1916         PACK_CHECK_BUTTON (vbox2, msgid_checkbtn, _("Generate Message-ID"));
1917
1918         PACK_CHECK_BUTTON (vbox2, checkbtn_msgid_with_addr,
1919                            _("Send account mail address in Message-ID"));
1920
1921         PACK_CHECK_BUTTON (vbox2, xmailer_checkbtn,
1922                            _("Add user agent header"));
1923
1924         hbox = gtk_hbox_new (FALSE, 12);
1925         gtk_widget_show (hbox);
1926         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1927
1928         PACK_CHECK_BUTTON (hbox, customhdr_checkbtn,
1929                            _("Add user-defined header"));
1930
1931         customhdr_edit_btn = gtk_button_new_from_stock (GTK_STOCK_EDIT);
1932         gtk_widget_show (customhdr_edit_btn);
1933         gtk_box_pack_start (GTK_BOX (hbox), customhdr_edit_btn,
1934                             FALSE, FALSE, 0);
1935         g_signal_connect (G_OBJECT (customhdr_edit_btn), "clicked",
1936                           G_CALLBACK (prefs_account_edit_custom_header),
1937                           NULL);
1938
1939         SET_TOGGLE_SENSITIVITY (customhdr_checkbtn, customhdr_edit_btn);
1940
1941         vbox3 = gtkut_get_options_frame(vbox1, &frame, _("Authentication"));
1942
1943         PACK_CHECK_BUTTON (vbox3, smtp_auth_checkbtn,
1944                 _("SMTP Authentication (SMTP AUTH)"));
1945
1946         vbox4 = gtk_vbox_new (FALSE, 0);
1947         gtk_widget_show (vbox4);
1948         gtk_box_pack_start (GTK_BOX (vbox3), vbox4, FALSE, FALSE, 0);
1949
1950         hbox = gtk_hbox_new (FALSE, 8);
1951         gtk_widget_show (hbox);
1952         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1953
1954         hbox_spc = gtk_hbox_new (FALSE, 0);
1955         gtk_widget_show (hbox_spc);
1956         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1957         gtk_widget_set_size_request (hbox_spc, 12, -1);
1958
1959         label = gtk_label_new (_("Authentication method"));
1960         gtk_widget_show (label);
1961         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1962
1963         optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1964         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1965         gtk_widget_show (optmenu);
1966         gtk_box_pack_start (GTK_BOX (hbox), optmenu, FALSE, FALSE, 0);
1967
1968         COMBOBOX_ADD (menu, _("Automatic"), 0);
1969         COMBOBOX_ADD (menu, NULL, 0);
1970         COMBOBOX_ADD (menu, "PLAIN", SMTPAUTH_PLAIN);
1971         COMBOBOX_ADD (menu, "LOGIN", SMTPAUTH_LOGIN);
1972         COMBOBOX_ADD (menu, "CRAM-MD5", SMTPAUTH_CRAM_MD5);
1973         COMBOBOX_ADD (menu, "DIGEST-MD5", SMTPAUTH_DIGEST_MD5);
1974         gtk_list_store_set(menu, &iter, COMBOBOX_SENS, FALSE, -1);
1975
1976         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1977
1978         hbox = gtk_hbox_new (FALSE, 8);
1979         gtk_widget_show (hbox);
1980         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1981
1982         hbox_spc = gtk_hbox_new (FALSE, 0);
1983         gtk_widget_show (hbox_spc);
1984         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1985         gtk_widget_set_size_request (hbox_spc, 12, -1);
1986
1987         label = gtk_label_new (_("User ID"));
1988         gtk_widget_show (label);
1989         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1990
1991         smtp_uid_entry = gtk_entry_new ();
1992         gtk_widget_show (smtp_uid_entry);
1993         gtk_widget_set_size_request (smtp_uid_entry, DEFAULT_ENTRY_WIDTH, -1);
1994         gtk_box_pack_start (GTK_BOX (hbox), smtp_uid_entry, TRUE, TRUE, 0);
1995         g_signal_connect(G_OBJECT(smtp_uid_entry), "changed",
1996                         G_CALLBACK(prefs_account_entry_changed_newline_check_cb),
1997                         GINT_TO_POINTER(ac_prefs->protocol));
1998
1999 #ifdef GENERIC_UMPC
2000         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
2001         hbox = gtk_hbox_new (FALSE, 8);
2002         gtk_widget_show (hbox);
2003         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
2004
2005         hbox_spc = gtk_hbox_new (FALSE, 0);
2006         gtk_widget_show (hbox_spc);
2007         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2008         gtk_widget_set_size_request (hbox_spc, 12, -1);
2009 #endif
2010         label = gtk_label_new (_("Password"));
2011         gtk_widget_show (label);
2012         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2013
2014         smtp_pass_entry = gtk_entry_new ();
2015         gtk_widget_show (smtp_pass_entry);
2016         gtk_widget_set_size_request (smtp_pass_entry, DEFAULT_ENTRY_WIDTH, -1);
2017         gtk_box_pack_start (GTK_BOX (hbox), smtp_pass_entry, TRUE, TRUE, 0);
2018         gtk_entry_set_visibility (GTK_ENTRY (smtp_pass_entry), FALSE);
2019         g_signal_connect(G_OBJECT(smtp_pass_entry), "changed",
2020                         G_CALLBACK(prefs_account_entry_changed_newline_check_cb),
2021                         GINT_TO_POINTER(ac_prefs->protocol));
2022
2023         showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password"));
2024         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE);
2025         gtk_widget_show(showpwd_checkbtn);
2026         gtk_box_pack_start(GTK_BOX (hbox), showpwd_checkbtn, FALSE, FALSE, 0);
2027         g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled",
2028                         G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), smtp_pass_entry);
2029
2030         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
2031
2032         hbox = gtk_hbox_new (FALSE, 8);
2033         gtk_widget_show (hbox);
2034         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
2035
2036         hbox_spc = gtk_hbox_new (FALSE, 0);
2037         gtk_widget_show (hbox_spc);
2038         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2039         gtk_widget_set_size_request (hbox_spc, 12, -1);
2040
2041         label = gtk_label_new
2042                 (_("If you leave these entries empty, the same "
2043                    "user ID and password as receiving will be used."));
2044         gtk_widget_show (label);
2045         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2046         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2047         gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
2048         gtkut_widget_set_small_font_size (label);
2049
2050         SET_TOGGLE_SENSITIVITY (smtp_auth_checkbtn, vbox4);
2051
2052         PACK_CHECK_BUTTON (vbox3, pop_bfr_smtp_checkbtn,
2053                 _("Authenticate with POP before sending"));
2054         
2055         g_signal_connect (G_OBJECT (pop_bfr_smtp_checkbtn), "clicked",
2056                           G_CALLBACK (pop_bfr_smtp_tm_set_sens),
2057                           NULL);
2058
2059         hbox = gtk_hbox_new (FALSE, 8);
2060         gtk_widget_show (hbox);
2061         gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
2062
2063         hbox_spc = gtk_hbox_new (FALSE, 0);
2064         gtk_widget_show (hbox_spc);
2065         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2066         gtk_widget_set_size_request (hbox_spc, 12, -1);
2067
2068         pop_auth_timeout_lbl = gtk_label_new(_("POP authentication timeout"));
2069         gtk_widget_show (pop_auth_timeout_lbl);
2070         gtk_box_pack_start (GTK_BOX (hbox), pop_auth_timeout_lbl, FALSE, FALSE, 0);
2071
2072         pop_bfr_smtp_tm_spinbtn = gtk_spin_button_new_with_range(0, 1440, 1);
2073         gtk_widget_show (pop_bfr_smtp_tm_spinbtn);
2074         gtk_box_pack_start (GTK_BOX (hbox), pop_bfr_smtp_tm_spinbtn, FALSE, FALSE, 0);
2075
2076         pop_auth_minutes_lbl = gtk_label_new(_("minutes"));
2077         gtk_widget_show (pop_auth_minutes_lbl);
2078         gtk_box_pack_start (GTK_BOX (hbox), pop_auth_minutes_lbl, FALSE, FALSE, 0);
2079         
2080         page->msgid_checkbtn     = msgid_checkbtn;
2081         page->xmailer_checkbtn   = xmailer_checkbtn;
2082         page->customhdr_checkbtn = customhdr_checkbtn;
2083         page->msgid_with_addr_checkbtn  = checkbtn_msgid_with_addr;
2084
2085         page->smtp_auth_checkbtn       = smtp_auth_checkbtn;
2086         page->smtp_auth_type_optmenu = optmenu;
2087         page->smtp_uid_entry         = smtp_uid_entry;
2088         page->smtp_pass_entry        = smtp_pass_entry;
2089         page->pop_bfr_smtp_checkbtn    = pop_bfr_smtp_checkbtn;
2090         page->pop_bfr_smtp_tm_spinbtn  = pop_bfr_smtp_tm_spinbtn;
2091         page->pop_auth_timeout_lbl   = pop_auth_timeout_lbl;
2092         page->pop_auth_minutes_lbl   = pop_auth_minutes_lbl;
2093
2094         tmp_ac_prefs = *ac_prefs;
2095
2096         if (new_account) {
2097                 prefs_set_dialog_to_default(send_param);
2098         } else {
2099                 prefs_set_dialog(send_param);
2100
2101                 /* Passwords are handled outside of PrefParams. */
2102                 buf = passwd_store_get_account(ac_prefs->account_id,
2103                                 PWS_ACCOUNT_SEND);
2104                 gtk_entry_set_text(GTK_ENTRY(page->smtp_pass_entry), buf != NULL ? buf : "");
2105                 if (buf != NULL) {
2106                         memset(buf, 0, strlen(buf));
2107                         g_free(buf);
2108                 }
2109         }
2110
2111         pop_bfr_smtp_tm_set_sens (NULL, NULL);
2112
2113         page->vbox = vbox1;
2114
2115         page->page.widget = vbox1;
2116 }
2117         
2118 static void compose_create_widget_func(PrefsPage * _page,
2119                                            GtkWindow * window,
2120                                            gpointer data)
2121 {
2122         ComposePage *page = (ComposePage *) _page;
2123         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2124
2125         GtkWidget *vbox1;
2126         GtkWidget *sig_hbox;
2127         GtkWidget *hbox1;
2128         GtkWidget *hbox2;
2129         GtkWidget *frame_sig;
2130         GtkWidget *vbox_sig;
2131         GtkWidget *label_sigpath;
2132         GtkWidget *checkbtn_autosig;
2133         GtkWidget *label_sigsep;
2134         GtkWidget *entry_sigsep;
2135         GtkWidget *frame;
2136         GtkWidget *table;
2137         GtkWidget *autocc_checkbtn;
2138         GtkWidget *autocc_entry;
2139         GtkWidget *autobcc_checkbtn;
2140         GtkWidget *autobcc_entry;
2141         GtkWidget *autoreplyto_checkbtn;
2142         GtkWidget *autoreplyto_entry;
2143 #if USE_ENCHANT
2144         GtkWidget *frame_dict;
2145         GtkWidget *table_dict;
2146         GtkWidget *checkbtn_enable_default_dictionary = NULL;
2147         GtkWidget *combo_default_dictionary = NULL;
2148         GtkWidget *checkbtn_enable_default_alt_dictionary = NULL;
2149         GtkWidget *combo_default_alt_dictionary = NULL;
2150 #endif
2151
2152         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2153         gtk_widget_show (vbox1);
2154         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2155
2156         vbox_sig = gtkut_get_options_frame(vbox1, &frame_sig, _("Signature"));
2157
2158         PACK_CHECK_BUTTON (vbox_sig, checkbtn_autosig,
2159                            _("Automatically insert signature"));
2160
2161         hbox1 = gtk_hbox_new (FALSE, 8);
2162         gtk_widget_show (hbox1);
2163         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox1, TRUE, TRUE, 0);
2164         label_sigsep = gtk_label_new (_("Signature separator"));
2165         gtk_widget_show (label_sigsep);
2166         gtk_box_pack_start (GTK_BOX (hbox1), label_sigsep, FALSE, FALSE, 0);
2167
2168         entry_sigsep = gtk_entry_new ();
2169         gtk_widget_show (entry_sigsep);
2170         gtk_box_pack_start (GTK_BOX (hbox1), entry_sigsep, FALSE, FALSE, 0);
2171
2172         gtk_widget_set_size_request (entry_sigsep, 64, -1);
2173
2174         sig_hbox = gtk_hbox_new (FALSE, 8);
2175         gtk_widget_show (sig_hbox);
2176         gtk_box_pack_start (GTK_BOX (vbox_sig), sig_hbox, FALSE, FALSE, 0);
2177
2178         sigfile_radiobtn = gtk_radio_button_new_with_label (NULL, _("File"));
2179         gtk_widget_show (sigfile_radiobtn);
2180         gtk_box_pack_start (GTK_BOX (sig_hbox), sigfile_radiobtn,
2181                             FALSE, FALSE, 0);
2182         g_object_set_data (G_OBJECT (sigfile_radiobtn),
2183                            MENU_VAL_ID,
2184                            GINT_TO_POINTER (SIG_FILE));
2185         g_signal_connect(G_OBJECT(sigfile_radiobtn), "clicked",
2186                          G_CALLBACK(prefs_account_sigfile_radiobtn_cb), NULL);
2187
2188         sigcmd_radiobtn = gtk_radio_button_new_with_label_from_widget
2189                 (GTK_RADIO_BUTTON(sigfile_radiobtn), _("Command output"));
2190         gtk_widget_show (sigcmd_radiobtn);
2191         gtk_box_pack_start (GTK_BOX (sig_hbox), sigcmd_radiobtn,
2192                             FALSE, FALSE, 0);
2193         g_object_set_data (G_OBJECT (sigcmd_radiobtn),
2194                            MENU_VAL_ID,
2195                            GINT_TO_POINTER (SIG_COMMAND));
2196         g_signal_connect(G_OBJECT(sigcmd_radiobtn), "clicked",
2197                          G_CALLBACK(prefs_account_sigcmd_radiobtn_cb), NULL);
2198
2199         hbox2 = gtk_hbox_new (FALSE, 8);
2200         gtk_widget_show (hbox2);
2201         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox2, TRUE, TRUE, 0);
2202         label_sigpath = gtk_label_new (_("Signature"));
2203         gtk_widget_show (label_sigpath);
2204         gtk_box_pack_start (GTK_BOX (hbox2), label_sigpath, FALSE, FALSE, 0);
2205
2206         entry_sigpath = gtk_entry_new ();
2207         gtk_widget_show (entry_sigpath);
2208         gtk_box_pack_start (GTK_BOX (hbox2), entry_sigpath, TRUE, TRUE, 0);
2209
2210         signature_browse_button = gtkut_get_browse_file_btn(_("Bro_wse"));
2211         gtk_widget_show (signature_browse_button);
2212         gtk_box_pack_start (GTK_BOX (hbox2), signature_browse_button, FALSE, FALSE, 0);
2213         g_signal_connect(G_OBJECT(signature_browse_button), "clicked",
2214                          G_CALLBACK(prefs_account_signature_browse_cb), NULL);
2215
2216         signature_edit_button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
2217         gtk_widget_show (signature_edit_button);
2218         gtk_box_pack_start (GTK_BOX (hbox2), signature_edit_button, FALSE, FALSE, 0);
2219         g_signal_connect(G_OBJECT(signature_edit_button), "clicked",
2220                          G_CALLBACK(prefs_account_signature_edit_cb), entry_sigpath);
2221
2222         PACK_FRAME (vbox1, frame, _("Automatically set the following addresses"));
2223
2224         table =  gtk_table_new (3, 2, FALSE);
2225         gtk_widget_show (table);
2226         gtk_container_add (GTK_CONTAINER (frame), table);
2227         gtk_container_set_border_width (GTK_CONTAINER (table), 8);
2228         gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
2229         gtk_table_set_col_spacings (GTK_TABLE (table), 8);
2230
2231         autocc_checkbtn = gtk_check_button_new_with_label (
2232                                 prefs_common_translated_header_name("Cc:"));
2233         gtk_widget_show (autocc_checkbtn);
2234         gtk_table_attach (GTK_TABLE (table), autocc_checkbtn, 0, 1, 0, 1,
2235                           GTK_FILL, 0, 0, 0);
2236
2237         autocc_entry = gtk_entry_new ();
2238         gtk_widget_show (autocc_entry);
2239         gtk_table_attach (GTK_TABLE (table), autocc_entry, 1, 2, 0, 1,
2240                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2241                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
2242
2243         SET_TOGGLE_SENSITIVITY (autocc_checkbtn, autocc_entry);
2244
2245         autobcc_checkbtn = gtk_check_button_new_with_label (
2246                                 prefs_common_translated_header_name("Bcc:"));
2247         gtk_widget_show (autobcc_checkbtn);
2248         gtk_table_attach (GTK_TABLE (table), autobcc_checkbtn, 0, 1, 1, 2,
2249                           GTK_FILL, 0, 0, 0);
2250
2251         autobcc_entry = gtk_entry_new ();
2252         gtk_widget_show (autobcc_entry);
2253         gtk_table_attach (GTK_TABLE (table), autobcc_entry, 1, 2, 1, 2,
2254                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2255                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
2256
2257         SET_TOGGLE_SENSITIVITY (autobcc_checkbtn, autobcc_entry);
2258
2259         autoreplyto_checkbtn = gtk_check_button_new_with_label (
2260                                 prefs_common_translated_header_name("Reply-To:"));
2261         gtk_widget_show (autoreplyto_checkbtn);
2262         gtk_table_attach (GTK_TABLE (table), autoreplyto_checkbtn, 0, 1, 2, 3,
2263                           GTK_FILL, 0, 0, 0);
2264
2265         autoreplyto_entry = gtk_entry_new ();
2266         gtk_widget_show (autoreplyto_entry);
2267         gtk_table_attach (GTK_TABLE (table), autoreplyto_entry, 1, 2, 2, 3,
2268                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2269                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
2270
2271         SET_TOGGLE_SENSITIVITY (autoreplyto_checkbtn, autoreplyto_entry);
2272
2273 #if USE_ENCHANT
2274         PACK_FRAME (vbox1, frame_dict, _("Spell check dictionaries"));
2275
2276         table_dict =  gtk_table_new (2, 2, FALSE);
2277         gtk_widget_show (table_dict);
2278         gtk_container_add (GTK_CONTAINER (frame_dict), table_dict);
2279         gtk_container_set_border_width (GTK_CONTAINER (table_dict), 8);
2280         gtk_table_set_row_spacings (GTK_TABLE (table_dict), VSPACING_NARROW_2);
2281         gtk_table_set_col_spacings (GTK_TABLE (table_dict), 8);
2282
2283         /* Default dictionary */
2284         checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary"));
2285         gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_dictionary, 0, 1,
2286                         0, 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
2287         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
2288                         tmp_ac_prefs.enable_default_dictionary);
2289
2290         combo_default_dictionary = gtkaspell_dictionary_combo_new(TRUE);
2291         gtk_table_attach(GTK_TABLE(table_dict), combo_default_dictionary, 1, 2,
2292                         0, 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
2293
2294         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary);
2295
2296         /* Default dictionary */
2297         checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary"));
2298         gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_alt_dictionary, 0, 1,
2299                         1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
2300         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary),
2301                         tmp_ac_prefs.enable_default_alt_dictionary);
2302
2303         combo_default_alt_dictionary = gtkaspell_dictionary_combo_new(FALSE);
2304         gtk_table_attach(GTK_TABLE(table_dict), combo_default_alt_dictionary, 1, 2,
2305                         1, 2, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
2306
2307         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary);
2308
2309         gtk_widget_show_all(table_dict);
2310 #endif
2311
2312         page->sigfile_radiobtn = sigfile_radiobtn;
2313         page->entry_sigpath      = entry_sigpath;
2314         page->checkbtn_autosig   = checkbtn_autosig;
2315         page->entry_sigsep       = entry_sigsep;
2316
2317         page->autocc_checkbtn      = autocc_checkbtn;
2318         page->autocc_entry       = autocc_entry;
2319         page->autobcc_checkbtn     = autobcc_checkbtn;
2320         page->autobcc_entry      = autobcc_entry;
2321         page->autoreplyto_checkbtn = autoreplyto_checkbtn;
2322         page->autoreplyto_entry  = autoreplyto_entry;
2323 #ifdef USE_ENCHANT
2324         page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
2325         page->combo_default_dictionary = combo_default_dictionary;
2326         page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary;
2327         page->combo_default_alt_dictionary = combo_default_alt_dictionary;
2328 #endif
2329
2330 #ifdef USE_ENCHANT
2331         /* reset gtkaspell menus */
2332         if (compose_page.combo_default_dictionary != NULL) {
2333                 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_dictionary),
2334                                         gtkaspell_dictionary_store_new());
2335                 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_alt_dictionary),
2336                                         gtkaspell_dictionary_store_new_with_refresh(
2337                                                 FALSE));
2338         }
2339 #endif
2340
2341         tmp_ac_prefs = *ac_prefs;
2342
2343         if (new_account) {
2344                 prefs_set_dialog_to_default(compose_param);
2345         } else
2346                 prefs_set_dialog(compose_param);
2347
2348         page->vbox = vbox1;
2349
2350         page->page.widget = vbox1;
2351 }
2352         
2353 static void templates_create_widget_func(PrefsPage * _page,
2354                                            GtkWindow * window,
2355                                            gpointer data)
2356 {
2357         TemplatesPage *page = (TemplatesPage *) _page;
2358         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2359         GtkWidget *vbox;
2360         GtkWidget *vbox2;
2361         GtkWidget *notebook;
2362
2363         vbox = gtk_vbox_new(FALSE, 0);
2364         gtk_widget_show(vbox);
2365         
2366         notebook = gtk_notebook_new();
2367         gtk_widget_show(notebook);
2368         gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
2369
2370         /* compose format */
2371         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2372         gtk_widget_show (vbox2);
2373         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2374
2375         quotefmt_create_new_msg_fmt_widgets(
2376                                 window,
2377                                 vbox2,
2378                                 &page->checkbtn_compose_with_format,
2379                                 NULL,
2380                                 &page->compose_subject_format,
2381                                 &page->compose_body_format,
2382                                 TRUE, NULL);
2383         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Compose")));
2384
2385         /* reply format */      
2386         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2387         gtk_widget_show (vbox2);
2388         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2389         
2390         quotefmt_create_reply_fmt_widgets(
2391                                 window,
2392                                 vbox2,
2393                                 &page->checkbtn_reply_with_format,
2394                                 NULL,
2395                                 &page->reply_quotemark,
2396                                 &page->reply_body_format,
2397                                 TRUE, NULL);
2398         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Reply")));
2399
2400         /* forward format */    
2401         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2402         gtk_widget_show (vbox2);
2403         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2404
2405         quotefmt_create_forward_fmt_widgets(
2406                                 window,
2407                                 vbox2,
2408                                 &page->checkbtn_forward_with_format,
2409                                 NULL,
2410                                 &page->forward_quotemark,
2411                                 &page->forward_body_format,
2412                                 TRUE, NULL);
2413         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Forward")));
2414
2415         tmp_ac_prefs = *ac_prefs;
2416
2417         if (new_account) {
2418                 prefs_set_dialog_to_default(templates_param);
2419         } else
2420                 prefs_set_dialog(templates_param);
2421
2422         page->vbox = vbox;
2423
2424         page->page.widget = vbox;
2425 }
2426
2427 static void privacy_create_widget_func(PrefsPage * _page,
2428                                            GtkWindow * window,
2429                                            gpointer data)
2430 {
2431         PrivacyPage *page = (PrivacyPage *) _page;
2432         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2433
2434         GtkWidget *vbox1;
2435         GtkWidget *vbox2;
2436         GtkWidget *hbox1;
2437         GtkWidget *label;
2438         GtkWidget *default_privacy_system;
2439         GtkListStore *menu;
2440         GtkCellRenderer *rend;
2441         GtkWidget *default_encrypt_checkbtn;
2442         GtkWidget *default_encrypt_reply_checkbtn;
2443         GtkWidget *default_sign_checkbtn;
2444         GtkWidget *default_sign_reply_checkbtn;
2445         GtkWidget *save_clear_text_checkbtn;
2446         GtkWidget *encrypt_to_self_checkbtn;
2447
2448         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2449         gtk_widget_show (vbox1);
2450         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2451
2452         vbox2 = gtk_vbox_new (FALSE, 0);
2453         gtk_widget_show (vbox2);
2454         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2455
2456         hbox1 = gtk_hbox_new(FALSE, 8);
2457         gtk_widget_show (hbox1);
2458         gtk_container_add (GTK_CONTAINER(vbox2), hbox1);
2459
2460         label = gtk_label_new(_("Default privacy system"));
2461         gtk_widget_show(label);
2462         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2463
2464         /* Can't use gtkut_sc_combobox_create() here, because model for this
2465          * combobox needs an extra string column to store privacy plugin id. */
2466         menu = gtk_list_store_new(4,
2467                         G_TYPE_STRING,
2468                         G_TYPE_INT,
2469                         G_TYPE_BOOLEAN,
2470                         G_TYPE_STRING); /* This is where we store the privacy plugin id. */
2471         default_privacy_system = gtk_combo_box_new_with_model(GTK_TREE_MODEL(menu));
2472
2473         rend = gtk_cell_renderer_text_new();
2474         gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(default_privacy_system), rend, TRUE);
2475         gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(default_privacy_system), rend,
2476                         "text", COMBOBOX_TEXT,
2477                         "sensitive", COMBOBOX_SENS,
2478                         NULL);
2479         gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(default_privacy_system), FALSE);
2480
2481         gtk_widget_show (default_privacy_system);
2482         gtk_box_pack_start (GTK_BOX(hbox1), default_privacy_system, FALSE, TRUE, 0);
2483
2484         g_signal_connect(G_OBJECT(default_privacy_system), "changed",
2485                          G_CALLBACK(privacy_system_activated),
2486                          NULL);
2487
2488         PACK_CHECK_BUTTON (vbox2, default_sign_checkbtn,
2489                            _("Always sign messages"));
2490         PACK_CHECK_BUTTON (vbox2, default_encrypt_checkbtn,
2491                            _("Always encrypt messages"));
2492         PACK_CHECK_BUTTON (vbox2, default_sign_reply_checkbtn,
2493                            _("Always sign messages when replying to a "
2494                              "signed message"));
2495         PACK_CHECK_BUTTON (vbox2, default_encrypt_reply_checkbtn,
2496                            _("Always encrypt messages when replying to an "
2497                              "encrypted message"));
2498         PACK_CHECK_BUTTON (vbox2, encrypt_to_self_checkbtn,
2499                            _("Encrypt sent messages with your own key in addition to recipient's"));
2500         PACK_CHECK_BUTTON (vbox2, save_clear_text_checkbtn,
2501                            _("Save sent encrypted messages as clear text"));
2502
2503         SET_TOGGLE_SENSITIVITY_REVERSE(encrypt_to_self_checkbtn, save_clear_text_checkbtn);
2504         SET_TOGGLE_SENSITIVITY_REVERSE(save_clear_text_checkbtn, encrypt_to_self_checkbtn);
2505
2506         page->default_privacy_system = default_privacy_system;
2507         page->default_encrypt_checkbtn = default_encrypt_checkbtn;
2508         page->default_encrypt_reply_checkbtn = default_encrypt_reply_checkbtn;
2509         page->default_sign_reply_checkbtn = default_sign_reply_checkbtn;
2510         page->default_sign_checkbtn    = default_sign_checkbtn;
2511         page->save_clear_text_checkbtn = save_clear_text_checkbtn;
2512         page->encrypt_to_self_checkbtn = encrypt_to_self_checkbtn;
2513
2514         update_privacy_system_menu();
2515
2516         tmp_ac_prefs = *ac_prefs;
2517
2518         if (new_account) {
2519                 prefs_set_dialog_to_default(privacy_param);
2520         } else
2521                 prefs_set_dialog(privacy_param);
2522
2523         page->vbox = vbox1;
2524
2525         page->page.widget = vbox1;
2526 }
2527
2528 #define CREATE_RADIO_BUTTON(box, btn, btn_p, label, data)               \
2529 {                                                                       \
2530         btn = gtk_radio_button_new_with_label_from_widget               \
2531                 (GTK_RADIO_BUTTON (btn_p), label);                      \
2532         gtk_widget_show (btn);                                          \
2533         gtk_box_pack_start (GTK_BOX (box), btn, FALSE, FALSE, 0);       \
2534         g_object_set_data (G_OBJECT (btn),                              \
2535                            MENU_VAL_ID,                                 \
2536                            GINT_TO_POINTER (data));                     \
2537 }
2538
2539 #ifdef USE_GNUTLS
2540
2541 #define CREATE_RADIO_BUTTONS(box,                                       \
2542                              btn1, btn1_label, btn1_data,               \
2543                              btn2, btn2_label, btn2_data,               \
2544                              btn3, btn3_label, btn3_data)               \
2545 {                                                                       \
2546         btn1 = gtk_radio_button_new_with_label(NULL, btn1_label);       \
2547         gtk_widget_show (btn1);                                         \
2548         gtk_box_pack_start (GTK_BOX (box), btn1, FALSE, FALSE, 0);      \
2549         g_object_set_data (G_OBJECT (btn1),                             \
2550                            MENU_VAL_ID,                                 \
2551                            GINT_TO_POINTER (btn1_data));                \
2552                                                                         \
2553         CREATE_RADIO_BUTTON(box, btn2, btn1, btn2_label, btn2_data);    \
2554         CREATE_RADIO_BUTTON(box, btn3, btn1, btn3_label, btn3_data);    \
2555 }
2556
2557 static void pop_ssltunnel_toggled(GtkToggleButton *button,
2558                                         gpointer data)
2559 {
2560         gboolean active = gtk_toggle_button_get_active(button);
2561         
2562         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2563                         advanced_page.popport_checkbtn)) == TRUE)
2564                 return;
2565         gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.popport_spinbtn),
2566                                   active ? 995 : 110);
2567 }
2568
2569 static void imap_ssltunnel_toggled(GtkToggleButton *button,
2570                                         gpointer data)
2571 {
2572         gboolean active = gtk_toggle_button_get_active(button);
2573         
2574         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2575                         advanced_page.imapport_checkbtn)) == TRUE)
2576                 return;
2577         gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.imapport_spinbtn),
2578                                   active ? 993 : 143);
2579 }
2580
2581 static void nntp_ssltunnel_toggled(GtkToggleButton *button,
2582                                         gpointer data)
2583 {
2584         gboolean active = gtk_toggle_button_get_active(button);
2585         
2586         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2587                         advanced_page.nntpport_checkbtn)) == TRUE)
2588                 return;
2589         gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.nntpport_spinbtn),
2590                                   active ? 563 : 119);
2591 }       
2592
2593 static void smtp_ssltunnel_toggled(GtkToggleButton *button,
2594                                         gpointer data)
2595 {
2596         gboolean active = gtk_toggle_button_get_active(button);
2597         
2598         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2599                         advanced_page.smtpport_checkbtn)) == TRUE)
2600                 return;
2601         gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.smtpport_spinbtn),
2602                                   active ? 465 : 25);   
2603 }
2604
2605 static void ssl_create_widget_func(PrefsPage * _page,
2606                                            GtkWindow * window,
2607                                            gpointer data)
2608 {
2609         SSLPage *page = (SSLPage *) _page;
2610         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2611
2612         GtkWidget *vbox1;
2613
2614         GtkWidget *pop_frame;
2615         GtkWidget *vbox2;
2616         GtkWidget *pop_nossl_radiobtn;
2617         GtkWidget *pop_ssltunnel_radiobtn;
2618         GtkWidget *pop_starttls_radiobtn;
2619
2620         GtkWidget *imap_frame;
2621         GtkWidget *vbox3;
2622         GtkWidget *imap_nossl_radiobtn;
2623         GtkWidget *imap_ssltunnel_radiobtn;
2624         GtkWidget *imap_starttls_radiobtn;
2625
2626         GtkWidget *nntp_frame;
2627         GtkWidget *vbox4;
2628         GtkWidget *nntp_nossl_radiobtn;
2629         GtkWidget *nntp_ssltunnel_radiobtn;
2630
2631         GtkWidget *send_frame;
2632         GtkWidget *vbox5;
2633         GtkWidget *smtp_nossl_radiobtn;
2634         GtkWidget *smtp_ssltunnel_radiobtn;
2635         GtkWidget *smtp_starttls_radiobtn;
2636
2637         GtkWidget *cert_frame;
2638         GtkWidget *cert_table;
2639         GtkWidget *entry_in_cert_pass;
2640         GtkWidget *entry_out_cert_pass;
2641         GtkWidget *showpwd_checkbtn;
2642
2643         GtkWidget *vbox7;
2644         GtkWidget *ssl_certs_auto_accept_checkbtn;
2645         GtkWidget *use_nonblocking_ssl_checkbtn;
2646         GtkWidget *hbox;
2647         GtkWidget *hbox_spc;
2648         GtkWidget *label;
2649         gchar *buf;
2650
2651         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2652         gtk_widget_show (vbox1);
2653         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2654
2655         vbox2 = gtkut_get_options_frame(vbox1, &pop_frame, _("POP"));
2656
2657         CREATE_RADIO_BUTTONS(vbox2,
2658                              pop_nossl_radiobtn,
2659                              _("Don't use SSL/TLS"),
2660                              SSL_NONE,
2661                              pop_ssltunnel_radiobtn,
2662                              _("Use SSL/TLS"),
2663                              SSL_TUNNEL,
2664                              pop_starttls_radiobtn,
2665                              _("Use STARTTLS command to start encrypted session"),
2666                              SSL_STARTTLS);
2667         g_signal_connect(G_OBJECT(pop_ssltunnel_radiobtn), "toggled",
2668                          G_CALLBACK(pop_ssltunnel_toggled), NULL);
2669         
2670         vbox3 = gtkut_get_options_frame(vbox1, &imap_frame, _("IMAP"));
2671
2672         CREATE_RADIO_BUTTONS(vbox3,
2673                              imap_nossl_radiobtn,
2674                              _("Don't use SSL/TLS"),
2675                              SSL_NONE,
2676                              imap_ssltunnel_radiobtn,
2677                              _("Use SSL/TLS"),
2678                              SSL_TUNNEL,
2679                              imap_starttls_radiobtn,
2680                              _("Use STARTTLS command to start encrypted session"),
2681                              SSL_STARTTLS);
2682         g_signal_connect(G_OBJECT(imap_ssltunnel_radiobtn), "toggled",
2683                          G_CALLBACK(imap_ssltunnel_toggled), NULL);
2684
2685         vbox4 = gtkut_get_options_frame(vbox1, &nntp_frame, _("NNTP"));
2686
2687         nntp_nossl_radiobtn =
2688                 gtk_radio_button_new_with_label (NULL, _("Don't use SSL/TLS"));
2689         gtk_widget_show (nntp_nossl_radiobtn);
2690         gtk_box_pack_start (GTK_BOX (vbox4), nntp_nossl_radiobtn,
2691                             FALSE, FALSE, 0);
2692         g_object_set_data (G_OBJECT (nntp_nossl_radiobtn),
2693                            MENU_VAL_ID,
2694                            GINT_TO_POINTER (SSL_NONE));
2695
2696         CREATE_RADIO_BUTTON(vbox4, nntp_ssltunnel_radiobtn, nntp_nossl_radiobtn,
2697                             _("Use SSL/TLS"), SSL_TUNNEL);
2698         g_signal_connect(G_OBJECT(nntp_ssltunnel_radiobtn), "toggled",
2699                          G_CALLBACK(nntp_ssltunnel_toggled), NULL);
2700
2701         vbox5 = gtkut_get_options_frame(vbox1, &send_frame, _("Send (SMTP)"));
2702
2703         CREATE_RADIO_BUTTONS(vbox5,
2704                              smtp_nossl_radiobtn,
2705                              _("Don't use SSL/TLS (but, if necessary, use STARTTLS)"),
2706                              SSL_NONE,
2707                              smtp_ssltunnel_radiobtn,
2708                              _("Use SSL/TLS"),
2709                              SSL_TUNNEL,
2710                              smtp_starttls_radiobtn,
2711                              _("Use STARTTLS command to start encrypted session"),
2712                              SSL_STARTTLS);
2713         g_signal_connect(G_OBJECT(smtp_ssltunnel_radiobtn), "toggled",
2714                          G_CALLBACK(smtp_ssltunnel_toggled), NULL);
2715
2716         PACK_FRAME(vbox1, cert_frame, _("Client certificates"));
2717
2718         cert_table = gtk_table_new(4,3, FALSE);
2719         gtk_container_add(GTK_CONTAINER(cert_frame), cert_table);
2720         gtk_container_set_border_width(GTK_CONTAINER(cert_table), 8);
2721         gtk_table_set_row_spacings(GTK_TABLE(cert_table), VSPACING_NARROW_2);
2722         gtk_table_set_col_spacings(GTK_TABLE(cert_table), 8);
2723         
2724         label = gtk_label_new(_("Certificate for receiving"));
2725         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2726         entry_in_cert_file = gtk_entry_new();
2727         in_ssl_cert_browse_button = gtkut_get_browse_file_btn(_("Browse"));
2728         CLAWS_SET_TIP(label,
2729                              _("Client certificate file as a PKCS12 or PEM file"));
2730         CLAWS_SET_TIP(entry_in_cert_file,
2731                              _("Client certificate file as a PKCS12 or PEM file"));     
2732         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
2733         gtk_table_attach(GTK_TABLE(cert_table), entry_in_cert_file, 1, 2, 0, 1,
2734                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
2735         gtk_table_attach(GTK_TABLE(cert_table), in_ssl_cert_browse_button, 2, 3, 0, 1,
2736                          GTK_FILL, 0, 0, 0);
2737
2738         label = gtk_label_new(_("Password"));
2739         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2740         entry_in_cert_pass = gtk_entry_new();
2741         gtk_entry_set_visibility(GTK_ENTRY(entry_in_cert_pass), FALSE);
2742         showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password"));
2743         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE);
2744         g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled",
2745                         G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), entry_in_cert_pass);
2746         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
2747         gtk_table_attach(GTK_TABLE(cert_table), entry_in_cert_pass, 1, 2, 1, 2,
2748                          GTK_FILL, 0, 0, 0);
2749         gtk_table_attach(GTK_TABLE(cert_table), showpwd_checkbtn, 2, 3, 1, 2,
2750                         GTK_FILL, 0, 0, 0);
2751
2752         label = gtk_label_new(_("Certificate for sending"));
2753         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2754         entry_out_cert_file = gtk_entry_new();
2755         out_ssl_cert_browse_button = gtkut_get_browse_file_btn(_("Browse"));
2756         CLAWS_SET_TIP(label,
2757                              _("Client certificate file as a PKCS12 or PEM file"));
2758         CLAWS_SET_TIP(entry_out_cert_file,
2759                              _("Client certificate file as a PKCS12 or PEM file"));
2760         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
2761         gtk_table_attach(GTK_TABLE(cert_table), entry_out_cert_file, 1, 2, 2, 3,
2762                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
2763         gtk_table_attach(GTK_TABLE(cert_table), out_ssl_cert_browse_button, 2, 3, 2, 3,
2764                          GTK_FILL, 0, 0, 0);
2765
2766         label = gtk_label_new(_("Password"));
2767         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2768         entry_out_cert_pass = gtk_entry_new();
2769         gtk_entry_set_visibility(GTK_ENTRY(entry_out_cert_pass), FALSE);
2770         showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password"));
2771         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE);
2772         g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled",
2773                         G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), entry_out_cert_pass);
2774         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
2775         gtk_table_attach(GTK_TABLE(cert_table), entry_out_cert_pass, 1, 2, 3, 4,
2776                          GTK_FILL, 0, 0, 0);
2777         gtk_table_attach(GTK_TABLE(cert_table), showpwd_checkbtn, 2, 3, 3, 4,
2778                         GTK_FILL, 0, 0, 0);
2779
2780         gtk_widget_show_all(cert_table);
2781
2782         g_signal_connect(G_OBJECT(in_ssl_cert_browse_button), "clicked",
2783                          G_CALLBACK(prefs_account_in_cert_browse_cb), NULL);
2784         g_signal_connect(G_OBJECT(out_ssl_cert_browse_button), "clicked",
2785                          G_CALLBACK(prefs_account_out_cert_browse_cb), NULL);
2786         
2787         vbox7 = gtk_vbox_new (FALSE, 0);
2788         gtk_widget_show (vbox7);
2789         gtk_box_pack_start (GTK_BOX (vbox1), vbox7, FALSE, FALSE, 0);
2790
2791         PACK_CHECK_BUTTON(vbox7, ssl_certs_auto_accept_checkbtn,
2792                           _("Automatically accept valid SSL/TLS certificates"));
2793
2794         PACK_CHECK_BUTTON(vbox7, use_nonblocking_ssl_checkbtn,
2795                           _("Use non-blocking SSL/TLS"));
2796
2797         hbox = gtk_hbox_new (FALSE, 0);
2798         gtk_widget_show (hbox);
2799         gtk_box_pack_start (GTK_BOX (vbox7), hbox, FALSE, FALSE, 0);
2800
2801         hbox_spc = gtk_hbox_new (FALSE, 0);
2802         gtk_widget_show (hbox_spc);
2803         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2804         gtk_widget_set_size_request (hbox_spc, 16, -1);
2805
2806         label = gtk_label_new
2807                 (_("Turn this off if you have SSL/TLS connection problems"));
2808         gtk_widget_show (label);
2809         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2810         gtkut_widget_set_small_font_size (label);
2811
2812         page->pop_frame               = pop_frame;
2813         page->pop_nossl_radiobtn      = pop_nossl_radiobtn;
2814         page->pop_ssltunnel_radiobtn  = pop_ssltunnel_radiobtn;
2815         page->pop_starttls_radiobtn   = pop_starttls_radiobtn;
2816
2817         page->imap_frame              = imap_frame;
2818         page->imap_nossl_radiobtn     = imap_nossl_radiobtn;
2819         page->imap_ssltunnel_radiobtn = imap_ssltunnel_radiobtn;
2820         page->imap_starttls_radiobtn  = imap_starttls_radiobtn;
2821
2822         page->nntp_frame              = nntp_frame;
2823         page->nntp_nossl_radiobtn     = nntp_nossl_radiobtn;
2824         page->nntp_ssltunnel_radiobtn = nntp_ssltunnel_radiobtn;
2825
2826         page->send_frame              = send_frame;
2827         page->smtp_nossl_radiobtn     = smtp_nossl_radiobtn;
2828         page->smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn;
2829         page->smtp_starttls_radiobtn  = smtp_starttls_radiobtn;
2830
2831         page->entry_in_cert_file      = entry_in_cert_file;
2832         page->entry_in_cert_pass      = entry_in_cert_pass;
2833         page->entry_out_cert_file     = entry_out_cert_file;
2834         page->entry_out_cert_pass     = entry_out_cert_pass;
2835
2836         page->ssl_certs_auto_accept_checkbtn = ssl_certs_auto_accept_checkbtn;
2837         page->use_nonblocking_ssl_checkbtn = use_nonblocking_ssl_checkbtn;
2838
2839         tmp_ac_prefs = *ac_prefs;
2840
2841         if (new_account) {
2842                 prefs_set_dialog_to_default(ssl_param);
2843         } else {
2844                 prefs_set_dialog(ssl_param);
2845
2846                 /* Passwords are handled outside of PrefParams. */
2847                 buf = passwd_store_get_account(ac_prefs->account_id,
2848                                 PWS_ACCOUNT_RECV_CERT);
2849                 gtk_entry_set_text(GTK_ENTRY(page->entry_in_cert_pass), buf != NULL ? buf : "");
2850                 if (buf != NULL) {
2851                         memset(buf, 0, strlen(buf));
2852                         g_free(buf);
2853                 }
2854
2855                 buf = passwd_store_get_account(ac_prefs->account_id,
2856                                 PWS_ACCOUNT_SEND_CERT);
2857                 gtk_entry_set_text(GTK_ENTRY(page->entry_out_cert_pass), buf != NULL ? buf : "");
2858                 if (buf != NULL) {
2859                         memset(buf, 0, strlen(buf));
2860                         g_free(buf);
2861                 }
2862         }
2863
2864         page->vbox = vbox1;
2865
2866         page->page.widget = vbox1;
2867 }
2868
2869 #undef CREATE_RADIO_BUTTONS
2870 #endif /* USE_GNUTLS */
2871
2872 static void proxy_create_widget_func(PrefsPage * _page,
2873                                            GtkWindow * window,
2874                                            gpointer data)
2875 {
2876         ProxyPage *page = (ProxyPage *) _page;
2877         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2878         GtkWidget *vbox1, *vbox2, *vbox3, *vbox4;
2879         GtkWidget *proxy_frame;
2880         GtkWidget *proxy_checkbtn;
2881         GtkWidget *default_proxy_checkbtn;
2882         GtkWidget *hbox;
2883         GtkWidget *label;
2884         GtkWidget *socks4_radiobtn;
2885         GtkWidget *socks5_radiobtn;
2886         GtkWidget *proxy_host_entry;
2887         GtkWidget *proxy_port_spinbtn;
2888         GtkWidget *proxy_auth_checkbtn;
2889         GtkWidget *proxy_name_entry;
2890         GtkWidget *proxy_pass_entry;
2891         GtkWidget *proxy_send_checkbtn;
2892         GtkWidget *table;
2893         GtkWidget *button;
2894         gchar *buf;
2895
2896         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2897         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2898
2899         proxy_checkbtn = gtk_check_button_new_with_label (_("Use proxy server"));
2900         PACK_FRAME (vbox1, proxy_frame, NULL);
2901         gtk_frame_set_label_widget (GTK_FRAME(proxy_frame), proxy_checkbtn);
2902
2903         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2904         gtk_container_add (GTK_CONTAINER (proxy_frame), vbox2);
2905         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2906
2907         default_proxy_checkbtn =
2908                 gtk_check_button_new_with_label (C_("In account preferences, referring to whether or not use proxy settings from common preferences", "Use default settings"));
2909         CLAWS_SET_TIP(default_proxy_checkbtn,
2910                         _("Use global proxy server settings"));
2911         gtk_box_pack_start (GTK_BOX (vbox2), default_proxy_checkbtn, FALSE, FALSE, 0);
2912
2913         vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2914         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2915
2916         hbox = gtk_hbox_new (FALSE, 8);
2917         gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
2918
2919         socks4_radiobtn = gtk_radio_button_new_with_label(NULL, "SOCKS4");
2920         gtk_box_pack_start (GTK_BOX (hbox), socks4_radiobtn, FALSE, FALSE, 0);
2921         g_object_set_data(G_OBJECT(socks4_radiobtn), MENU_VAL_ID,
2922                           GINT_TO_POINTER(PROXY_SOCKS4));
2923
2924         CREATE_RADIO_BUTTON(hbox, socks5_radiobtn, socks4_radiobtn, "SOCKS5",
2925                             PROXY_SOCKS5);
2926
2927         hbox = gtk_hbox_new (FALSE, 8);
2928         gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
2929
2930         label = gtk_label_new(_("Hostname"));
2931         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2932
2933         proxy_host_entry = gtk_entry_new();
2934         gtk_widget_set_size_request(proxy_host_entry, DEFAULT_ENTRY_WIDTH, -1);
2935         gtk_box_pack_start(GTK_BOX(hbox), proxy_host_entry, TRUE, TRUE, 0);
2936
2937         label = gtk_label_new(_("Port"));
2938         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2939
2940         proxy_port_spinbtn = gtk_spin_button_new_with_range(0, 65535, 1080);
2941         gtk_widget_set_size_request(proxy_port_spinbtn, 64, -1);
2942         gtk_box_pack_start(GTK_BOX(hbox), proxy_port_spinbtn, FALSE, FALSE, 0);
2943
2944         vbox4 = gtk_vbox_new (FALSE, VSPACING_NARROW);
2945         gtk_box_pack_start(GTK_BOX(vbox3), vbox4, FALSE, FALSE, 0);
2946
2947         PACK_CHECK_BUTTON (vbox4, proxy_auth_checkbtn, _("Use authentication"));
2948
2949         table = gtk_table_new(2, 4, FALSE);
2950         gtk_box_pack_start (GTK_BOX (vbox4), table, FALSE, FALSE, 0);
2951
2952         label = gtk_label_new(_("Username"));
2953         gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
2954                         GTK_SHRINK | GTK_FILL,
2955                         GTK_SHRINK | GTK_FILL, 0, 0);
2956
2957         proxy_name_entry = gtk_entry_new();
2958         gtk_widget_set_size_request(proxy_name_entry, DEFAULT_ENTRY_WIDTH, -1);
2959         gtk_table_attach(GTK_TABLE(table), proxy_name_entry, 1, 2, 0, 1,
2960                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2961                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
2962
2963         label = gtk_label_new(_("Password"));
2964         gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1,
2965                         GTK_SHRINK | GTK_FILL,
2966                         GTK_SHRINK | GTK_FILL, 0, 0);
2967
2968         proxy_pass_entry = gtk_entry_new();
2969         gtk_widget_set_size_request(proxy_pass_entry, DEFAULT_ENTRY_WIDTH, -1);
2970         gtk_entry_set_visibility(GTK_ENTRY(proxy_pass_entry), FALSE);
2971         gtk_table_attach(GTK_TABLE(table), proxy_pass_entry, 3, 4, 0, 1,
2972                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2973                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
2974
2975         button = gtk_check_button_new_with_label(_("Show password"));
2976         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
2977         gtk_table_attach(GTK_TABLE(table), button, 3, 4, 1, 2,
2978                         GTK_SHRINK | GTK_FILL,
2979                         GTK_SHRINK | GTK_FILL, 0, 0);
2980         g_signal_connect(G_OBJECT(button), "toggled",
2981                         G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), proxy_pass_entry);
2982
2983         gtk_box_pack_start(GTK_BOX(vbox2), gtk_hseparator_new(), FALSE, FALSE, 0);
2984
2985         PACK_CHECK_BUTTON(vbox2, proxy_send_checkbtn,
2986                           _("Use proxy server for sending"));
2987         CLAWS_SET_TIP(proxy_send_checkbtn,
2988                         _("If disabled, messages will be sent using direct connection to configured outgoing server, bypassing any configured proxy server."));
2989
2990         SET_TOGGLE_SENSITIVITY(proxy_auth_checkbtn, table);
2991         SET_TOGGLE_SENSITIVITY(socks5_radiobtn, vbox4);
2992         SET_TOGGLE_SENSITIVITY(proxy_checkbtn, vbox2);
2993         SET_TOGGLE_SENSITIVITY_REVERSE(default_proxy_checkbtn, vbox3);
2994
2995         gtk_widget_show_all(vbox1);
2996
2997         page->proxy_checkbtn = proxy_checkbtn;
2998         page->default_proxy_checkbtn = default_proxy_checkbtn;
2999         page->socks4_radiobtn = socks4_radiobtn;
3000         page->socks5_radiobtn = socks5_radiobtn;
3001         page->proxy_host_entry = proxy_host_entry;
3002         page->proxy_port_spinbtn = proxy_port_spinbtn;
3003         page->proxy_auth_checkbtn = proxy_auth_checkbtn;
3004         page->proxy_name_entry = proxy_name_entry;
3005         page->proxy_pass_entry = proxy_pass_entry;
3006         page->proxy_send_checkbtn = proxy_send_checkbtn;
3007         page->vbox = vbox1;
3008         page->page.widget = vbox1;
3009
3010         tmp_ac_prefs = *ac_prefs;
3011
3012         if (new_account) {
3013                 prefs_set_dialog_to_default(proxy_param);
3014         } else
3015                 prefs_set_dialog(proxy_param);
3016
3017                 /* Passwords are handled outside of PrefParams. */
3018                 buf = passwd_store_get_account(ac_prefs->account_id,
3019                                 PWS_ACCOUNT_PROXY_PASS);
3020                 gtk_entry_set_text(GTK_ENTRY(page->proxy_pass_entry),
3021                                 buf != NULL ? buf : "");
3022                 if (buf != NULL) {
3023                         memset(buf, 0, strlen(buf));
3024                         g_free(buf);
3025                 }
3026
3027         page->vbox = vbox1;
3028
3029         page->page.widget = vbox1;
3030 }
3031
3032 static void advanced_create_widget_func(PrefsPage * _page,
3033                                            GtkWindow * window,
3034                                            gpointer data)
3035 {
3036         AdvancedPage *page = (AdvancedPage *) _page;
3037         PrefsAccount *ac_prefs = (PrefsAccount *) data;
3038
3039         GtkWidget *vbox1;
3040         GtkWidget *vbox2;
3041         GtkWidget *hbox1;
3042         GtkWidget *checkbtn_smtpport;
3043         GtkWidget *spinbtn_smtpport;
3044         GtkWidget *hbox_popport;
3045         GtkWidget *checkbtn_popport;
3046         GtkWidget *spinbtn_popport;
3047         GtkWidget *hbox_imapport;
3048         GtkWidget *checkbtn_imapport;
3049         GtkWidget *spinbtn_imapport;
3050         GtkWidget *hbox_nntpport;
3051         GtkWidget *checkbtn_nntpport;
3052         GtkWidget *spinbtn_nntpport;
3053         GtkWidget *checkbtn_domain;
3054         GtkWidget *entry_domain;
3055         gchar *tip_domain;
3056         GtkWidget *checkbtn_crosspost;
3057         GtkWidget *colormenu_crosspost;
3058         GtkWidget *menu;
3059 #ifndef G_OS_WIN32
3060         GtkWidget *checkbtn_tunnelcmd;
3061         GtkWidget *entry_tunnelcmd;
3062 #endif
3063         GtkWidget *folder_frame;
3064         GtkWidget *vbox3;
3065         GtkWidget *table;
3066         GtkWidget *sent_folder_checkbtn;
3067         GtkWidget *sent_folder_entry;
3068         GtkWidget *queue_folder_checkbtn;
3069         GtkWidget *queue_folder_entry;
3070         GtkWidget *draft_folder_checkbtn;
3071         GtkWidget *draft_folder_entry;
3072         GtkWidget *trash_folder_checkbtn;
3073         GtkWidget *trash_folder_entry;
3074         GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
3075
3076 #define PACK_HBOX(hbox) \
3077         { \
3078         hbox = gtk_hbox_new (FALSE, 8); \
3079         gtk_widget_show (hbox); \
3080         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); \
3081         }
3082
3083 #define PACK_PORT_SPINBTN(box, spinbtn) \
3084         { \
3085         spinbtn = gtk_spin_button_new_with_range(0, 65535, 1); \
3086         gtk_widget_show (spinbtn); \
3087         gtk_box_pack_start (GTK_BOX (box), spinbtn, FALSE, FALSE, 0); \
3088         }
3089
3090         vbox1 = gtk_vbox_new (FALSE, VSPACING);
3091         gtk_widget_show (vbox1);
3092         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
3093
3094         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW_2);
3095         gtk_widget_show (vbox2);
3096         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
3097
3098         PACK_HBOX (hbox1);
3099         PACK_CHECK_BUTTON (hbox1, checkbtn_smtpport, _("SMTP port"));
3100         PACK_PORT_SPINBTN (hbox1, spinbtn_smtpport);
3101         SET_TOGGLE_SENSITIVITY (checkbtn_smtpport, spinbtn_smtpport);
3102         gtk_size_group_add_widget(size_group, checkbtn_smtpport);
3103         
3104         PACK_HBOX (hbox_popport);
3105         PACK_CHECK_BUTTON (hbox_popport, checkbtn_popport,
3106                            _("POP port"));
3107         PACK_PORT_SPINBTN (hbox_popport, spinbtn_popport);
3108         SET_TOGGLE_SENSITIVITY (checkbtn_popport, spinbtn_popport);
3109         gtk_size_group_add_widget(size_group, checkbtn_popport);
3110
3111         PACK_HBOX (hbox_imapport);
3112         PACK_CHECK_BUTTON (hbox_imapport, checkbtn_imapport,
3113                            _("IMAP port"));
3114         PACK_PORT_SPINBTN (hbox_imapport, spinbtn_imapport);
3115         SET_TOGGLE_SENSITIVITY (checkbtn_imapport, spinbtn_imapport);
3116         gtk_size_group_add_widget(size_group, checkbtn_imapport);
3117
3118         PACK_HBOX (hbox_nntpport);
3119         PACK_CHECK_BUTTON (hbox_nntpport, checkbtn_nntpport,
3120                            _("NNTP port"));
3121         PACK_PORT_SPINBTN (hbox_nntpport, spinbtn_nntpport);
3122         SET_TOGGLE_SENSITIVITY (checkbtn_nntpport, spinbtn_nntpport);
3123         gtk_size_group_add_widget(size_group, checkbtn_nntpport);
3124
3125         PACK_HBOX (hbox1);
3126         PACK_CHECK_BUTTON (hbox1, checkbtn_domain, _("Domain name"));
3127         gtk_size_group_add_widget(size_group, checkbtn_domain); 
3128
3129         tip_domain = _("The domain name will be used in the generated "
3130                         "Message-ID, and when connecting to SMTP servers.");
3131
3132         CLAWS_SET_TIP(checkbtn_domain, tip_domain);
3133
3134         entry_domain = gtk_entry_new ();
3135         gtk_widget_show (entry_domain);
3136         gtk_box_pack_start (GTK_BOX (hbox1), entry_domain, TRUE, TRUE, 0);
3137         SET_TOGGLE_SENSITIVITY (checkbtn_domain, entry_domain);
3138         CLAWS_SET_TIP(entry_domain, tip_domain);
3139
3140 #ifndef G_OS_WIN32      
3141         PACK_HBOX (hbox1);
3142         PACK_CHECK_BUTTON (hbox1, checkbtn_tunnelcmd,
3143                            _("Use command to communicate with server"));
3144         entry_tunnelcmd = gtk_entry_new ();
3145         gtk_widget_show (entry_tunnelcmd);
3146         gtk_box_pack_start (GTK_BOX (hbox1), entry_tunnelcmd, TRUE, TRUE, 0);
3147         SET_TOGGLE_SENSITIVITY (checkbtn_tunnelcmd, entry_tunnelcmd);
3148 #endif
3149
3150         PACK_HBOX (hbox1);
3151         PACK_CHECK_BUTTON (hbox1, checkbtn_crosspost, 
3152                            _("Mark cross-posted messages as read and color:"));
3153         g_signal_connect (G_OBJECT (checkbtn_crosspost), "toggled",
3154                           G_CALLBACK (crosspost_color_toggled),
3155                           NULL);
3156
3157         colormenu_crosspost = gtk_cmoption_menu_new();
3158         gtk_widget_show (colormenu_crosspost);
3159         gtk_box_pack_start (GTK_BOX (hbox1), colormenu_crosspost, FALSE, FALSE, 0);
3160
3161         menu = colorlabel_create_color_menu();
3162         gtk_cmoption_menu_set_menu (GTK_CMOPTION_MENU(colormenu_crosspost), menu);
3163         SET_TOGGLE_SENSITIVITY(checkbtn_crosspost, colormenu_crosspost);
3164 #undef PACK_HBOX
3165 #undef PACK_PORT_SPINBTN
3166
3167         /* special folder setting (maybe these options are redundant) */
3168
3169         vbox3 = gtkut_get_options_frame(vbox1, &folder_frame, _("Folder"));
3170
3171         table = gtk_table_new (4, 3, FALSE);
3172         gtk_widget_show (table);
3173         gtk_container_add (GTK_CONTAINER (vbox3), table);
3174         gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
3175         gtk_table_set_col_spacings (GTK_TABLE (table), 4);
3176
3177 #define SET_CHECK_BTN_AND_ENTRY(label, checkbtn, entry, n)              \
3178 {                                                                       \
3179         GtkWidget *button;                                              \
3180                                                                         \
3181         checkbtn = gtk_check_button_new_with_label (label);             \
3182         gtk_widget_show (checkbtn);                                     \
3183         gtk_table_attach (GTK_TABLE (table), checkbtn,                  \
3184                           0, 1, n, n + 1, GTK_FILL, 0, 0, 0);           \
3185                                                                         \
3186         entry = gtk_entry_new ();                                       \
3187         gtk_widget_show (entry);                                        \
3188         gtk_table_attach (GTK_TABLE (table), entry, 1, 2, n, n + 1,     \
3189                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,           \
3190                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);    \
3191                                                                         \
3192         button = gtkut_get_browse_file_btn(_("Browse"));                \
3193         gtk_widget_show (button);                                       \
3194         gtk_table_attach (GTK_TABLE (table), button,                    \
3195                           2, 3, n, n + 1, GTK_FILL, 0, 0, 0);           \
3196         g_signal_connect                                                \
3197                 (G_OBJECT (button), "clicked",                  \
3198                  G_CALLBACK (prefs_account_select_folder_cb),           \
3199                  entry);                                                \
3200                                                                         \
3201         SET_TOGGLE_SENSITIVITY (checkbtn, entry);                               \
3202         SET_TOGGLE_SENSITIVITY (checkbtn, button);                      \
3203 }
3204
3205         SET_CHECK_BTN_AND_ENTRY(_("Put sent messages in"),
3206                                 sent_folder_checkbtn, sent_folder_entry, 0);
3207         SET_CHECK_BTN_AND_ENTRY(_("Put queued messages in"),
3208                                 queue_folder_checkbtn, queue_folder_entry, 1);
3209         SET_CHECK_BTN_AND_ENTRY(_("Put draft messages in"),
3210                                 draft_folder_checkbtn, draft_folder_entry, 2);
3211         SET_CHECK_BTN_AND_ENTRY(_("Put deleted messages in"),
3212                                 trash_folder_checkbtn, trash_folder_entry, 3);
3213
3214         page->smtpport_checkbtn = checkbtn_smtpport;
3215         page->smtpport_spinbtn          = spinbtn_smtpport;
3216         page->popport_hbox              = hbox_popport;
3217         page->popport_checkbtn          = checkbtn_popport;
3218         page->popport_spinbtn           = spinbtn_popport;
3219         page->imapport_hbox             = hbox_imapport;
3220         page->imapport_checkbtn = checkbtn_imapport;
3221         page->imapport_spinbtn          = spinbtn_imapport;
3222         page->nntpport_hbox             = hbox_nntpport;
3223         page->nntpport_checkbtn = checkbtn_nntpport;
3224         page->nntpport_spinbtn          = spinbtn_nntpport;
3225         page->domain_checkbtn           = checkbtn_domain;
3226         page->domain_entry              = entry_domain;
3227         page->crosspost_checkbtn        = checkbtn_crosspost;
3228         page->crosspost_colormenu       = colormenu_crosspost;
3229
3230 #ifndef G_OS_WIN32
3231         page->tunnelcmd_checkbtn        = checkbtn_tunnelcmd;
3232         page->tunnelcmd_entry   = entry_tunnelcmd;
3233 #endif
3234         page->sent_folder_checkbtn  = sent_folder_checkbtn;
3235         page->sent_folder_entry   = sent_folder_entry;
3236         page->queue_folder_checkbtn  = queue_folder_checkbtn;
3237         page->queue_folder_entry   = queue_folder_entry;
3238         page->draft_folder_checkbtn = draft_folder_checkbtn;
3239         page->draft_folder_entry  = draft_folder_entry;
3240         page->trash_folder_checkbtn = trash_folder_checkbtn;
3241         page->trash_folder_entry  = trash_folder_entry;
3242
3243         tmp_ac_prefs = *ac_prefs;
3244
3245         if (new_account) {
3246                 prefs_set_dialog_to_default(advanced_param);
3247         } else
3248                 prefs_set_dialog(advanced_param);
3249
3250         page->vbox = vbox1;
3251
3252         page->page.widget = vbox1;
3253         
3254         g_object_unref(G_OBJECT(size_group));
3255 }
3256         
3257 static gint prefs_basic_apply(void)
3258 {
3259         RecvProtocol protocol;
3260         gchar *old_id = NULL;
3261         gchar *new_id = NULL;
3262         struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *) basic_page.protocol_optmenu;
3263         GtkWidget *optmenu = protocol_optmenu->combobox;
3264
3265         protocol = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
3266
3267         if (*gtk_entry_get_text(GTK_ENTRY(basic_page.acname_entry)) == '\0') {
3268                 alertpanel_error(_("Account name is not entered."));
3269                 return -1;
3270         }
3271         if (*gtk_entry_get_text(GTK_ENTRY(basic_page.addr_entry)) == '\0') {
3272                 alertpanel_error(_("Mail address is not entered."));
3273                 return -1;
3274         }
3275
3276         if (((protocol == A_POP3) || 
3277              (protocol == A_LOCAL && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn))) || 
3278              (protocol == A_NONE)) &&
3279            *gtk_entry_get_text(GTK_ENTRY(basic_page.smtpserv_entry)) == '\0') {
3280                 alertpanel_error(_("SMTP server is not entered."));
3281                 return -1;
3282         }
3283         if ((protocol == A_POP3 || protocol == A_IMAP4) &&
3284             *gtk_entry_get_text(GTK_ENTRY(basic_page.uid_entry)) == '\0') {
3285                 alertpanel_error(_("User ID is not entered."));
3286                 return -1;
3287         }
3288         if (protocol == A_POP3 &&
3289             *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
3290                 alertpanel_error(_("POP server is not entered."));
3291                 return -1;
3292         }
3293         if (protocol == A_POP3 || protocol == A_LOCAL) {
3294                 GtkWidget *inbox_entry = (protocol == A_POP3 ? receive_page.inbox_entry : receive_page.local_inbox_entry );
3295                 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
3296                 FolderItem *inbox =  folder_find_item_from_identifier(mailbox);
3297                 if (!inbox) {
3298                         gchar *id = NULL;
3299                         setup_write_mailbox_path(mainwindow_get_mainwindow(), "Mail");
3300                         id = folder_item_get_identifier(folder_get_default_inbox_for_class(F_MH));
3301                         gtk_entry_set_text(GTK_ENTRY(receive_page.inbox_entry),
3302                                 id);
3303                         gtk_entry_set_text(GTK_ENTRY(receive_page.local_inbox_entry),
3304                                 id);
3305                         g_free(id);
3306                         mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
3307                         inbox =  folder_find_item_from_identifier(mailbox);
3308                 }
3309                 if (inbox == NULL) {
3310                         alertpanel_error(_("The default Inbox folder doesn't exist."));
3311                         return -1;
3312                 }
3313         }
3314         if (protocol == A_IMAP4 &&
3315             *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
3316                 alertpanel_error(_("IMAP server is not entered."));
3317                 return -1;
3318         }
3319         if (protocol == A_NNTP &&
3320             *gtk_entry_get_text(GTK_ENTRY(basic_page.nntpserv_entry)) == '\0') {
3321                 alertpanel_error(_("NNTP server is not entered."));
3322                 return -1;
3323         }
3324
3325         if (protocol == A_LOCAL &&
3326             *gtk_entry_get_text(GTK_ENTRY(basic_page.localmbox_entry)) == '\0') {
3327                 alertpanel_error(_("local mailbox filename is not entered."));
3328                 return -1;
3329         }
3330
3331         if (protocol == A_LOCAL &&
3332             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn)) && *gtk_entry_get_text(GTK_ENTRY(basic_page.mailcmd_entry)) == '\0') {
3333                 alertpanel_error(_("mail command is not entered."));
3334                 return -1;
3335         }
3336         
3337         if (protocol == A_IMAP4 || protocol == A_NNTP) 
3338                 old_id = g_strdup_printf("#%s/%s",
3339                                 protocol == A_IMAP4 ? "imap":"news",
3340                                 tmp_ac_prefs.account_name ? tmp_ac_prefs.account_name : "(null)");
3341         
3342         if (strchr(gtk_entry_get_text(GTK_ENTRY(basic_page.uid_entry)), '\n') != NULL) {
3343                 alertpanel_error(_("User ID cannot contain a newline character."));
3344                 return -1;
3345         }
3346
3347         if (strchr(gtk_entry_get_text(GTK_ENTRY(basic_page.pass_entry)), '\n') != NULL) {
3348                 alertpanel_error(_("Password cannot contain a newline character."));
3349                 return -1;
3350         }
3351
3352         prefs_set_data_from_dialog(basic_param);
3353
3354         /* Passwords are stored outside of PrefParams. */
3355         passwd_store_set_account(tmp_ac_prefs.account_id,
3356                         PWS_ACCOUNT_RECV,
3357                         gtk_entry_get_text(GTK_ENTRY(basic_page.pass_entry)),
3358                         FALSE);
3359         
3360         if (protocol == A_IMAP4 || protocol == A_NNTP) {
3361                 new_id = g_strdup_printf("#%s/%s",
3362                                 protocol == A_IMAP4 ? "imap":"news",
3363                                 tmp_ac_prefs.account_name);
3364                 if (old_id != NULL && new_id != NULL)
3365                         prefs_filtering_rename_path(old_id, new_id);
3366                 g_free(old_id);
3367                 g_free(new_id);
3368         }
3369         
3370         return 0;
3371 }
3372
3373 static gint prefs_receive_apply(void)
3374 {
3375         if (strchr(gtk_entry_get_text(GTK_ENTRY(send_page.smtp_uid_entry)), '\n') != NULL) {
3376                 alertpanel_error(_("SMTP user ID cannot contain a newline character."));
3377                 return -1;
3378         }
3379
3380         if (strchr(gtk_entry_get_text(GTK_ENTRY(send_page.smtp_pass_entry)), '\n') != NULL) {
3381                 alertpanel_error(_("SMTP password cannot contain a newline character."));
3382                 return -1;
3383         }
3384
3385         prefs_set_data_from_dialog(receive_param);
3386
3387         return 0;
3388 }
3389
3390 static gint prefs_send_apply(void)
3391 {
3392         prefs_set_data_from_dialog(send_param);
3393
3394         /* Passwords are stored outside of PrefParams. */
3395         passwd_store_set_account(tmp_ac_prefs.account_id,
3396                         PWS_ACCOUNT_SEND,
3397                         gtk_entry_get_text(GTK_ENTRY(send_page.smtp_pass_entry)),
3398                         FALSE);
3399
3400         return 0;
3401 }
3402
3403 static gint prefs_compose_apply(void)
3404 {
3405         prefs_set_data_from_dialog(compose_param);
3406         return 0;
3407 }
3408
3409 static gint prefs_templates_apply(void)
3410 {
3411         prefs_set_data_from_dialog(templates_param);
3412         return 0;
3413 }
3414
3415 static gint prefs_privacy_apply(void)
3416 {
3417         prefs_set_data_from_dialog(privacy_param);
3418         return 0;
3419 }
3420
3421 #ifdef USE_GNUTLS
3422 static gint prefs_ssl_apply(void)
3423 {
3424         prefs_set_data_from_dialog(ssl_param);
3425
3426         /* Passwords are stored outside of PrefParams. */
3427         passwd_store_set_account(tmp_ac_prefs.account_id,
3428                         PWS_ACCOUNT_RECV_CERT,
3429                         gtk_entry_get_text(GTK_ENTRY(ssl_page.entry_in_cert_pass)),
3430                         FALSE);
3431         passwd_store_set_account(tmp_ac_prefs.account_id,
3432                         PWS_ACCOUNT_SEND_CERT,
3433                         gtk_entry_get_text(GTK_ENTRY(ssl_page.entry_out_cert_pass)),
3434                         FALSE);
3435
3436         return 0;
3437 }
3438 #endif
3439
3440 static gint prefs_proxy_apply(void)
3441 {
3442         prefs_set_data_from_dialog(proxy_param);
3443
3444         /* Passwords are stored outside of PrefParams. */
3445         passwd_store_set_account(tmp_ac_prefs.account_id,
3446