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