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