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