9def1b443310186b6f038da64a7861e8f73b1c5c
[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_entry;
120         GtkWidget *size_limit_checkbtn;
121         GtkWidget *size_limit_entry;
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_entry;
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_entry;
257         GtkWidget *popport_hbox;
258         GtkWidget *popport_checkbtn;
259         GtkWidget *popport_entry;
260         GtkWidget *imapport_hbox;
261         GtkWidget *imapport_checkbtn;
262         GtkWidget *imapport_entry;
263         GtkWidget *nntpport_hbox;
264         GtkWidget *nntpport_checkbtn;
265         GtkWidget *nntpport_entry;
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_entry,
422          prefs_set_data_from_entry, prefs_set_entry},
423 #else
424         {"message_leave_time", "30", &tmp_ac_prefs.msg_leave_time, P_INT,
425          &receive_page.leave_time_entry,
426          prefs_set_data_from_entry, prefs_set_entry},
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_entry,
434          prefs_set_data_from_entry, prefs_set_entry},
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_entry,
506          prefs_set_data_from_entry, prefs_set_entry},
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_entry,
711          prefs_set_data_from_entry, prefs_set_entry},
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_entry,
719          prefs_set_data_from_entry, prefs_set_entry},
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_entry,
727          prefs_set_data_from_entry, prefs_set_entry},
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_entry,
735          prefs_set_data_from_entry, prefs_set_entry},
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_entry;
1285         GtkWidget *hbox1;
1286         GtkWidget *size_limit_checkbtn;
1287         GtkWidget *size_limit_entry;
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_entry = gtk_entry_new ();
1379         gtk_widget_show (leave_time_entry);
1380         gtk_tooltips_set_tip(GTK_TOOLTIPS(leave_time_tooltip), leave_time_entry,
1381                              _("0 days: remove immediately"), NULL);
1382         gtk_widget_set_size_request (leave_time_entry, 64, -1);
1383         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_entry, FALSE, FALSE, 0);
1384
1385         leave_time_label = gtk_label_new (_("days"));
1386         gtk_widget_show (leave_time_label);
1387         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1388
1389         SET_TOGGLE_SENSITIVITY (rmmail_checkbtn, hbox1);
1390
1391         hbox1 = gtk_hbox_new (FALSE, 8);
1392         gtk_widget_show (hbox1);
1393         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1394
1395         PACK_CHECK_BUTTON (hbox1, size_limit_checkbtn, _("Receive size limit"));
1396
1397         gtk_tooltips_set_tip(GTK_TOOLTIPS(size_limit_tooltip), size_limit_checkbtn,
1398                              _("Messages over this limit will be partially retrieved. "
1399                                "When selecting them you will be able to download them fully "
1400                                "or delete them."),
1401                              NULL);
1402
1403         size_limit_entry = gtk_entry_new ();
1404         gtk_widget_show (size_limit_entry);
1405         gtk_widget_set_size_request (size_limit_entry, 64, -1);
1406         gtk_box_pack_start (GTK_BOX (hbox1), size_limit_entry, FALSE, FALSE, 0);
1407
1408         label = gtk_label_new (_("KB"));
1409         gtk_widget_show (label);
1410         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1411
1412         SET_TOGGLE_SENSITIVITY (size_limit_checkbtn, size_limit_entry);
1413
1414         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1415
1416         hbox1 = gtk_hbox_new (FALSE, 8);
1417         gtk_widget_show (hbox1);
1418         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1419
1420         inbox_label = gtk_label_new (_("Default Inbox"));
1421         gtk_widget_show (inbox_label);
1422         gtk_box_pack_start (GTK_BOX (hbox1), inbox_label, FALSE, FALSE, 0);
1423
1424         inbox_entry = gtk_entry_new ();
1425         gtk_widget_show (inbox_entry);
1426         gtk_tooltips_set_tip(GTK_TOOLTIPS(inbox_tooltip), inbox_entry,
1427                              _("Unfiltered messages will be stored in this folder"),
1428                              NULL);
1429         gtk_widget_set_size_request (inbox_entry, DEFAULT_ENTRY_WIDTH, -1);
1430         gtk_box_pack_start (GTK_BOX (hbox1), inbox_entry, TRUE, TRUE, 0);
1431
1432         inbox_btn = gtkut_get_browse_file_btn(_("Bro_wse"));
1433         gtk_widget_show (inbox_btn);
1434         gtk_tooltips_set_tip(GTK_TOOLTIPS(inbox_tooltip), inbox_btn,
1435                              _("Unfiltered messages will be stored in this folder"),
1436                              NULL);
1437         gtk_box_pack_start (GTK_BOX (hbox1), inbox_btn, FALSE, FALSE, 0);
1438         g_signal_connect (G_OBJECT (inbox_btn), "clicked",
1439                           G_CALLBACK (prefs_account_select_folder_cb),
1440                           inbox_entry);
1441
1442         vbox2 = gtkut_get_options_frame(vbox1, &frame2, _("NNTP"));
1443
1444         hbox2 = gtk_hbox_new (FALSE, 8);
1445         gtk_widget_show (hbox2);
1446         gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
1447
1448         maxarticle_label = gtk_label_new
1449                 (_("Maximum number of articles to download"));
1450         gtk_widget_show (maxarticle_label);
1451         gtk_box_pack_start (GTK_BOX (hbox2), maxarticle_label, FALSE, FALSE, 0);
1452
1453         maxarticle_tool_tip = gtk_tooltips_new();
1454
1455         maxarticle_spinbtn_adj =
1456                 gtk_adjustment_new (300, 0, 10000, 10, 100, 100);
1457         maxarticle_spinbtn = gtk_spin_button_new
1458                 (GTK_ADJUSTMENT (maxarticle_spinbtn_adj), 10, 0);
1459         gtk_widget_show (maxarticle_spinbtn);
1460         gtk_tooltips_set_tip(maxarticle_tool_tip, maxarticle_spinbtn,
1461                              _("unlimited if 0 is specified"), NULL);
1462         gtk_box_pack_start (GTK_BOX (hbox2), maxarticle_spinbtn,
1463                             FALSE, FALSE, 0);
1464         gtk_widget_set_size_request (maxarticle_spinbtn, 64, -1);
1465         gtk_spin_button_set_numeric
1466                 (GTK_SPIN_BUTTON (maxarticle_spinbtn), TRUE);
1467
1468         vbox2 = gtkut_get_options_frame(vbox1, &imap_frame, _("IMAP4"));
1469
1470         hbox1 = gtk_hbox_new (FALSE, 8);
1471         gtk_widget_show (hbox1);
1472         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1473
1474         label = gtk_label_new (_("Authentication method"));
1475         gtk_widget_show (label);
1476         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1477
1478
1479         optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1480         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1481         gtk_widget_show (optmenu);
1482         gtk_box_pack_start (GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
1483
1484         COMBOBOX_ADD (menu, _("Automatic"), 0);
1485         COMBOBOX_ADD (menu, "LOGIN", IMAP_AUTH_LOGIN);
1486         COMBOBOX_ADD (menu, "CRAM-MD5", IMAP_AUTH_CRAM_MD5);
1487         COMBOBOX_ADD (menu, "ANONYMOUS", IMAP_AUTH_ANON);
1488         COMBOBOX_ADD (menu, "GSSAPI", IMAP_AUTH_GSSAPI);
1489
1490         hbox1 = gtk_hbox_new (FALSE, 8);
1491         gtk_widget_show (hbox1);
1492         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1493
1494         imapdir_label = gtk_label_new (_("IMAP server directory"));
1495         gtk_widget_show (imapdir_label);
1496         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
1497
1498         imapdir_label = gtk_label_new(_("(usually empty)"));
1499         gtk_widget_show (imapdir_label);
1500         gtkut_widget_set_small_font_size (imapdir_label);
1501         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
1502
1503         imapdir_entry = gtk_entry_new();
1504         gtk_widget_show (imapdir_entry);
1505         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_entry, FALSE, FALSE, 0);
1506
1507         hbox1 = gtk_hbox_new (FALSE, 8);
1508         gtk_widget_show (hbox1);
1509         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1510
1511         PACK_CHECK_BUTTON (hbox1, subsonly_checkbtn,
1512                            _("Show subscribed folders only"));
1513
1514         hbox1 = gtk_hbox_new (FALSE, 8);
1515         gtk_widget_show (hbox1);
1516         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1517
1518         PACK_CHECK_BUTTON (hbox1, low_bandwidth_checkbtn,
1519                            _("Bandwidth-efficient mode (prevents retrieving remote tags)"));
1520         gtk_tooltips_set_tip(GTK_TOOLTIPS(inbox_tooltip), low_bandwidth_checkbtn,
1521                              _("This mode uses less bandwidth, but can be slower with some servers."),
1522                              NULL);
1523
1524         PACK_CHECK_BUTTON (vbox1, filter_on_recv_checkbtn,
1525                            _("Filter messages on receiving"));
1526
1527         g_signal_connect(G_OBJECT(filter_on_recv_checkbtn), "toggled",
1528                          G_CALLBACK(prefs_account_filter_on_recv_toggled),
1529                          NULL);
1530
1531         PACK_CHECK_BUTTON (vbox1, filterhook_on_recv_checkbtn,
1532                            _("Allow filtering using plugins on receiving"));
1533
1534         PACK_CHECK_BUTTON
1535                 (vbox1, recvatgetall_checkbtn,
1536                  _("'Get Mail' checks for new messages on this account"));
1537
1538         page->pop3_frame               = frame1;
1539         page->use_apop_checkbtn          = use_apop_checkbtn;
1540         page->rmmail_checkbtn            = rmmail_checkbtn;
1541         page->leave_time_entry         = leave_time_entry;
1542         page->size_limit_checkbtn        = size_limit_checkbtn;
1543         page->size_limit_entry         = size_limit_entry;
1544         page->filter_on_recv_checkbtn    = filter_on_recv_checkbtn;
1545         page->filterhook_on_recv_checkbtn = filterhook_on_recv_checkbtn;
1546         page->inbox_label              = inbox_label;
1547         page->inbox_entry              = inbox_entry;
1548         page->inbox_btn                = inbox_btn;
1549
1550         page->imap_frame               = imap_frame;
1551         page->imap_auth_type_optmenu   = optmenu;
1552
1553         page->imapdir_label             = imapdir_label;
1554         page->imapdir_entry           = imapdir_entry;
1555         page->subsonly_checkbtn         = subsonly_checkbtn;
1556         page->low_bandwidth_checkbtn            = low_bandwidth_checkbtn;
1557         page->local_frame               = local_frame;
1558         page->local_inbox_label = local_inbox_label;
1559         page->local_inbox_entry = local_inbox_entry;
1560         page->local_inbox_btn           = local_inbox_btn;
1561
1562         page->recvatgetall_checkbtn      = recvatgetall_checkbtn;
1563
1564         page->frame_maxarticle  = frame2;
1565         page->maxarticle_spinbtn        = maxarticle_spinbtn;
1566         page->maxarticle_spinbtn_adj    = maxarticle_spinbtn_adj;
1567
1568         tmp_ac_prefs = *ac_prefs;
1569
1570         if (new_account) {
1571                 prefs_set_dialog_to_default(receive_param);
1572         } else
1573                 prefs_set_dialog(receive_param);
1574
1575         page->vbox = vbox1;
1576
1577         page->page.widget = vbox1;
1578 }
1579
1580 static void send_create_widget_func(PrefsPage * _page,
1581                                            GtkWindow * window,
1582                                            gpointer data)
1583 {
1584         SendPage *page = (SendPage *) _page;
1585         PrefsAccount *ac_prefs = (PrefsAccount *) data;
1586
1587         GtkWidget *vbox1;
1588         GtkWidget *vbox2;
1589         GtkWidget *frame;
1590         GtkWidget *msgid_checkbtn;
1591         GtkWidget *hbox;
1592         GtkWidget *customhdr_checkbtn;
1593         GtkWidget *customhdr_edit_btn;
1594         GtkWidget *vbox3;
1595         GtkWidget *smtp_auth_checkbtn;
1596         GtkWidget *optmenu;
1597         GtkListStore *menu;
1598         GtkTreeIter iter;
1599         GtkWidget *vbox4;
1600         GtkWidget *hbox_spc;
1601         GtkWidget *label;
1602         GtkWidget *smtp_uid_entry;
1603         GtkWidget *smtp_pass_entry;
1604         GtkWidget *vbox_spc;
1605         GtkWidget *pop_bfr_smtp_checkbtn;
1606         GtkWidget *pop_bfr_smtp_tm_entry;
1607         GtkWidget *pop_auth_timeout_lbl;
1608         GtkWidget *pop_auth_minutes_lbl;
1609
1610         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1611         gtk_widget_show (vbox1);
1612         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1613
1614         vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Header"));
1615
1616         PACK_CHECK_BUTTON (vbox2, msgid_checkbtn, _("Generate Message-ID"));
1617
1618         hbox = gtk_hbox_new (FALSE, 12);
1619         gtk_widget_show (hbox);
1620         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1621
1622         PACK_CHECK_BUTTON (hbox, customhdr_checkbtn,
1623                            _("Add user-defined header"));
1624
1625         customhdr_edit_btn = gtk_button_new_from_stock (GTK_STOCK_EDIT);
1626         gtk_widget_show (customhdr_edit_btn);
1627         gtk_box_pack_start (GTK_BOX (hbox), customhdr_edit_btn,
1628                             FALSE, FALSE, 0);
1629         g_signal_connect (G_OBJECT (customhdr_edit_btn), "clicked",
1630                           G_CALLBACK (prefs_account_edit_custom_header),
1631                           NULL);
1632
1633         SET_TOGGLE_SENSITIVITY (customhdr_checkbtn, customhdr_edit_btn);
1634
1635         vbox3 = gtkut_get_options_frame(vbox1, &frame, _("Authentication"));
1636
1637         PACK_CHECK_BUTTON (vbox3, smtp_auth_checkbtn,
1638                 _("SMTP Authentication (SMTP AUTH)"));
1639
1640         vbox4 = gtk_vbox_new (FALSE, 0);
1641         gtk_widget_show (vbox4);
1642         gtk_box_pack_start (GTK_BOX (vbox3), vbox4, FALSE, FALSE, 0);
1643
1644         hbox = gtk_hbox_new (FALSE, 8);
1645         gtk_widget_show (hbox);
1646         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1647
1648         hbox_spc = gtk_hbox_new (FALSE, 0);
1649         gtk_widget_show (hbox_spc);
1650         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1651         gtk_widget_set_size_request (hbox_spc, 12, -1);
1652
1653         label = gtk_label_new (_("Authentication method"));
1654         gtk_widget_show (label);
1655         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1656
1657         optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1658         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1659         gtk_widget_show (optmenu);
1660         gtk_box_pack_start (GTK_BOX (hbox), optmenu, FALSE, FALSE, 0);
1661
1662         COMBOBOX_ADD (menu, _("Automatic"), 0);
1663         COMBOBOX_ADD (menu, "PLAIN", SMTPAUTH_PLAIN);
1664         COMBOBOX_ADD (menu, "LOGIN", SMTPAUTH_LOGIN);
1665         COMBOBOX_ADD (menu, "CRAM-MD5", SMTPAUTH_CRAM_MD5);
1666         COMBOBOX_ADD (menu, "DIGEST-MD5", SMTPAUTH_DIGEST_MD5);
1667         gtk_list_store_set(menu, &iter, COMBOBOX_SENS, FALSE, -1);
1668
1669         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1670
1671         hbox = gtk_hbox_new (FALSE, 8);
1672         gtk_widget_show (hbox);
1673         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1674
1675         hbox_spc = gtk_hbox_new (FALSE, 0);
1676         gtk_widget_show (hbox_spc);
1677         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1678         gtk_widget_set_size_request (hbox_spc, 12, -1);
1679
1680         label = gtk_label_new (_("User ID"));
1681         gtk_widget_show (label);
1682         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1683
1684         smtp_uid_entry = gtk_entry_new ();
1685         gtk_widget_show (smtp_uid_entry);
1686         gtk_widget_set_size_request (smtp_uid_entry, DEFAULT_ENTRY_WIDTH, -1);
1687         gtk_box_pack_start (GTK_BOX (hbox), smtp_uid_entry, TRUE, TRUE, 0);
1688
1689 #ifdef MAEMO
1690         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1691         hbox = gtk_hbox_new (FALSE, 8);
1692         gtk_widget_show (hbox);
1693         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1694
1695         hbox_spc = gtk_hbox_new (FALSE, 0);
1696         gtk_widget_show (hbox_spc);
1697         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1698         gtk_widget_set_size_request (hbox_spc, 12, -1);
1699 #endif
1700         label = gtk_label_new (_("Password"));
1701         gtk_widget_show (label);
1702         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1703
1704         smtp_pass_entry = gtk_entry_new ();
1705         gtk_widget_show (smtp_pass_entry);
1706         gtk_widget_set_size_request (smtp_pass_entry, DEFAULT_ENTRY_WIDTH, -1);
1707         gtk_box_pack_start (GTK_BOX (hbox), smtp_pass_entry, TRUE, TRUE, 0);
1708
1709         gtk_entry_set_visibility (GTK_ENTRY (smtp_pass_entry), FALSE);
1710         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1711
1712         hbox = gtk_hbox_new (FALSE, 8);
1713         gtk_widget_show (hbox);
1714         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1715
1716         hbox_spc = gtk_hbox_new (FALSE, 0);
1717         gtk_widget_show (hbox_spc);
1718         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1719         gtk_widget_set_size_request (hbox_spc, 12, -1);
1720
1721         label = gtk_label_new
1722                 (_("If you leave these entries empty, the same "
1723                    "user ID and password as receiving will be used."));
1724         gtk_widget_show (label);
1725         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1726         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1727         gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1728         gtkut_widget_set_small_font_size (label);
1729
1730         SET_TOGGLE_SENSITIVITY (smtp_auth_checkbtn, vbox4);
1731
1732         PACK_CHECK_BUTTON (vbox3, pop_bfr_smtp_checkbtn,
1733                 _("Authenticate with POP3 before sending"));
1734         
1735         g_signal_connect (G_OBJECT (pop_bfr_smtp_checkbtn), "clicked",
1736                           G_CALLBACK (pop_bfr_smtp_tm_set_sens),
1737                           NULL);
1738
1739         hbox = gtk_hbox_new (FALSE, 8);
1740         gtk_widget_show (hbox);
1741         gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
1742
1743         hbox_spc = gtk_hbox_new (FALSE, 0);
1744         gtk_widget_show (hbox_spc);
1745         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1746         gtk_widget_set_size_request (hbox_spc, 12, -1);
1747
1748         pop_auth_timeout_lbl = gtk_label_new(_("POP authentication timeout: "));
1749         gtk_widget_show (pop_auth_timeout_lbl);
1750         gtk_box_pack_start (GTK_BOX (hbox), pop_auth_timeout_lbl, FALSE, FALSE, 0);
1751
1752         pop_bfr_smtp_tm_entry = gtk_entry_new ();
1753         gtk_widget_show (pop_bfr_smtp_tm_entry);
1754         gtk_widget_set_size_request (pop_bfr_smtp_tm_entry, 30, -1);
1755         gtk_box_pack_start (GTK_BOX (hbox), pop_bfr_smtp_tm_entry, FALSE, FALSE, 0);
1756
1757         pop_auth_minutes_lbl = gtk_label_new(_("minutes"));
1758         gtk_widget_show (pop_auth_minutes_lbl);
1759         gtk_box_pack_start (GTK_BOX (hbox), pop_auth_minutes_lbl, FALSE, FALSE, 0);
1760         
1761         page->msgid_checkbtn     = msgid_checkbtn;
1762         page->customhdr_checkbtn = customhdr_checkbtn;
1763
1764         page->smtp_auth_checkbtn       = smtp_auth_checkbtn;
1765         page->smtp_auth_type_optmenu = optmenu;
1766         page->smtp_uid_entry         = smtp_uid_entry;
1767         page->smtp_pass_entry        = smtp_pass_entry;
1768         page->pop_bfr_smtp_checkbtn    = pop_bfr_smtp_checkbtn;
1769         page->pop_bfr_smtp_tm_entry  = pop_bfr_smtp_tm_entry;
1770         page->pop_auth_timeout_lbl   = pop_auth_timeout_lbl;
1771         page->pop_auth_minutes_lbl   = pop_auth_minutes_lbl;
1772
1773         tmp_ac_prefs = *ac_prefs;
1774
1775         if (new_account) {
1776                 prefs_set_dialog_to_default(send_param);
1777         } else
1778                 prefs_set_dialog(send_param);
1779
1780         pop_bfr_smtp_tm_set_sens (NULL, NULL);
1781
1782         page->vbox = vbox1;
1783
1784         page->page.widget = vbox1;
1785 }
1786         
1787 static void compose_create_widget_func(PrefsPage * _page,
1788                                            GtkWindow * window,
1789                                            gpointer data)
1790 {
1791         ComposePage *page = (ComposePage *) _page;
1792         PrefsAccount *ac_prefs = (PrefsAccount *) data;
1793
1794         GtkWidget *vbox1;
1795         GtkWidget *sig_hbox;
1796         GtkWidget *hbox1;
1797         GtkWidget *hbox2;
1798         GtkWidget *frame_sig;
1799         GtkWidget *vbox_sig;
1800         GtkWidget *label_sigpath;
1801         GtkWidget *checkbtn_autosig;
1802         GtkWidget *label_sigsep;
1803         GtkWidget *entry_sigsep;
1804         GtkWidget *frame;
1805         GtkWidget *table;
1806         GtkWidget *autocc_checkbtn;
1807         GtkWidget *autocc_entry;
1808         GtkWidget *autobcc_checkbtn;
1809         GtkWidget *autobcc_entry;
1810         GtkWidget *autoreplyto_checkbtn;
1811         GtkWidget *autoreplyto_entry;
1812 #if USE_ASPELL
1813         GtkWidget *frame_dict;
1814         GtkWidget *table_dict;
1815         GtkWidget *checkbtn_enable_default_dictionary = NULL;
1816         GtkWidget *combo_default_dictionary = NULL;
1817         GtkWidget *checkbtn_enable_default_alt_dictionary = NULL;
1818         GtkWidget *combo_default_alt_dictionary = NULL;
1819 #endif
1820
1821         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1822         gtk_widget_show (vbox1);
1823         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1824
1825         vbox_sig = gtkut_get_options_frame(vbox1, &frame_sig, _("Signature"));
1826
1827         PACK_CHECK_BUTTON (vbox_sig, checkbtn_autosig,
1828                            _("Insert signature automatically"));
1829
1830         hbox1 = gtk_hbox_new (FALSE, 8);
1831         gtk_widget_show (hbox1);
1832         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox1, TRUE, TRUE, 0);
1833         label_sigsep = gtk_label_new (_("Signature separator"));
1834         gtk_widget_show (label_sigsep);
1835         gtk_box_pack_start (GTK_BOX (hbox1), label_sigsep, FALSE, FALSE, 0);
1836
1837         entry_sigsep = gtk_entry_new ();
1838         gtk_widget_show (entry_sigsep);
1839         gtk_box_pack_start (GTK_BOX (hbox1), entry_sigsep, FALSE, FALSE, 0);
1840
1841         gtk_widget_set_size_request (entry_sigsep, 64, -1);
1842
1843         sig_hbox = gtk_hbox_new (FALSE, 8);
1844         gtk_widget_show (sig_hbox);
1845         gtk_box_pack_start (GTK_BOX (vbox_sig), sig_hbox, FALSE, FALSE, 0);
1846
1847         sigfile_radiobtn = gtk_radio_button_new_with_label (NULL, _("File"));
1848         gtk_widget_show (sigfile_radiobtn);
1849         gtk_box_pack_start (GTK_BOX (sig_hbox), sigfile_radiobtn,
1850                             FALSE, FALSE, 0);
1851         g_object_set_data (G_OBJECT (sigfile_radiobtn),
1852                            MENU_VAL_ID,
1853                            GINT_TO_POINTER (SIG_FILE));
1854         g_signal_connect(G_OBJECT(sigfile_radiobtn), "clicked",
1855                          G_CALLBACK(prefs_account_sigfile_radiobtn_cb), NULL);
1856
1857         sigcmd_radiobtn = gtk_radio_button_new_with_label_from_widget
1858                 (GTK_RADIO_BUTTON(sigfile_radiobtn), _("Command output"));
1859         gtk_widget_show (sigcmd_radiobtn);
1860         gtk_box_pack_start (GTK_BOX (sig_hbox), sigcmd_radiobtn,
1861                             FALSE, FALSE, 0);
1862         g_object_set_data (G_OBJECT (sigcmd_radiobtn),
1863                            MENU_VAL_ID,
1864                            GINT_TO_POINTER (SIG_COMMAND));
1865         g_signal_connect(G_OBJECT(sigcmd_radiobtn), "clicked",
1866                          G_CALLBACK(prefs_account_sigcmd_radiobtn_cb), NULL);
1867
1868         hbox2 = gtk_hbox_new (FALSE, 8);
1869         gtk_widget_show (hbox2);
1870         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox2, TRUE, TRUE, 0);
1871         label_sigpath = gtk_label_new (_("Signature"));
1872         gtk_widget_show (label_sigpath);
1873         gtk_box_pack_start (GTK_BOX (hbox2), label_sigpath, FALSE, FALSE, 0);
1874
1875         entry_sigpath = gtk_entry_new ();
1876         gtk_widget_show (entry_sigpath);
1877         gtk_box_pack_start (GTK_BOX (hbox2), entry_sigpath, TRUE, TRUE, 0);
1878
1879         signature_browse_button = gtkut_get_browse_file_btn(_("Bro_wse"));
1880         gtk_widget_show (signature_browse_button);
1881         gtk_box_pack_start (GTK_BOX (hbox2), signature_browse_button, FALSE, FALSE, 0);
1882         g_signal_connect(G_OBJECT(signature_browse_button), "clicked",
1883                          G_CALLBACK(prefs_account_signature_browse_cb), NULL);
1884
1885         signature_edit_button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
1886         gtk_widget_show (signature_edit_button);
1887         gtk_box_pack_start (GTK_BOX (hbox2), signature_edit_button, FALSE, FALSE, 0);
1888         g_signal_connect(G_OBJECT(signature_edit_button), "clicked",
1889                          G_CALLBACK(prefs_account_signature_edit_cb), entry_sigpath);
1890
1891         PACK_FRAME (vbox1, frame, _("Automatically set the following addresses"));
1892
1893         table =  gtk_table_new (3, 2, FALSE);
1894         gtk_widget_show (table);
1895         gtk_container_add (GTK_CONTAINER (frame), table);
1896         gtk_container_set_border_width (GTK_CONTAINER (table), 8);
1897         gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
1898         gtk_table_set_col_spacings (GTK_TABLE (table), 8);
1899
1900         autocc_checkbtn = gtk_check_button_new_with_label (_("Cc"));
1901         gtk_widget_show (autocc_checkbtn);
1902         gtk_table_attach (GTK_TABLE (table), autocc_checkbtn, 0, 1, 0, 1,
1903                           GTK_FILL, 0, 0, 0);
1904
1905         autocc_entry = gtk_entry_new ();
1906         gtk_widget_show (autocc_entry);
1907         gtk_table_attach (GTK_TABLE (table), autocc_entry, 1, 2, 0, 1,
1908                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1909                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1910
1911         SET_TOGGLE_SENSITIVITY (autocc_checkbtn, autocc_entry);
1912
1913         autobcc_checkbtn = gtk_check_button_new_with_label (_("Bcc"));
1914         gtk_widget_show (autobcc_checkbtn);
1915         gtk_table_attach (GTK_TABLE (table), autobcc_checkbtn, 0, 1, 1, 2,
1916                           GTK_FILL, 0, 0, 0);
1917
1918         autobcc_entry = gtk_entry_new ();
1919         gtk_widget_show (autobcc_entry);
1920         gtk_table_attach (GTK_TABLE (table), autobcc_entry, 1, 2, 1, 2,
1921                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1922                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1923
1924         SET_TOGGLE_SENSITIVITY (autobcc_checkbtn, autobcc_entry);
1925
1926         autoreplyto_checkbtn = gtk_check_button_new_with_label (_("Reply-To"));
1927         gtk_widget_show (autoreplyto_checkbtn);
1928         gtk_table_attach (GTK_TABLE (table), autoreplyto_checkbtn, 0, 1, 2, 3,
1929                           GTK_FILL, 0, 0, 0);
1930
1931         autoreplyto_entry = gtk_entry_new ();
1932         gtk_widget_show (autoreplyto_entry);
1933         gtk_table_attach (GTK_TABLE (table), autoreplyto_entry, 1, 2, 2, 3,
1934                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1935                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1936
1937         SET_TOGGLE_SENSITIVITY (autoreplyto_checkbtn, autoreplyto_entry);
1938
1939 #if USE_ASPELL
1940         PACK_FRAME (vbox1, frame_dict, _("Spell check dictionaries"));
1941
1942         table_dict =  gtk_table_new (2, 2, FALSE);
1943         gtk_widget_show (table_dict);
1944         gtk_container_add (GTK_CONTAINER (frame_dict), table_dict);
1945         gtk_container_set_border_width (GTK_CONTAINER (table_dict), 8);
1946         gtk_table_set_row_spacings (GTK_TABLE (table_dict), VSPACING_NARROW_2);
1947         gtk_table_set_col_spacings (GTK_TABLE (table_dict), 8);
1948
1949         /* Default dictionary */
1950         checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary"));
1951         gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_dictionary, 0, 1,
1952                         0, 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1953         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
1954                         tmp_ac_prefs.enable_default_dictionary);
1955
1956         combo_default_dictionary = gtkaspell_dictionary_combo_new(
1957                                                 prefs_common.aspell_path, TRUE);
1958         gtk_table_attach(GTK_TABLE(table_dict), combo_default_dictionary, 1, 2,
1959                         0, 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1960
1961         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary);
1962
1963         /* Default dictionary */
1964         checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary"));
1965         gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_alt_dictionary, 0, 1,
1966                         1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
1967         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary),
1968                         tmp_ac_prefs.enable_default_alt_dictionary);
1969
1970         combo_default_alt_dictionary = gtkaspell_dictionary_combo_new(
1971                                                 prefs_common.aspell_path, FALSE);
1972         gtk_table_attach(GTK_TABLE(table_dict), combo_default_alt_dictionary, 1, 2,
1973                         1, 2, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
1974
1975         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary);
1976
1977         gtk_widget_show_all(table_dict);
1978 #endif
1979
1980         page->sigfile_radiobtn = sigfile_radiobtn;
1981         page->entry_sigpath      = entry_sigpath;
1982         page->checkbtn_autosig   = checkbtn_autosig;
1983         page->entry_sigsep       = entry_sigsep;
1984
1985         page->autocc_checkbtn      = autocc_checkbtn;
1986         page->autocc_entry       = autocc_entry;
1987         page->autobcc_checkbtn     = autobcc_checkbtn;
1988         page->autobcc_entry      = autobcc_entry;
1989         page->autoreplyto_checkbtn = autoreplyto_checkbtn;
1990         page->autoreplyto_entry  = autoreplyto_entry;
1991 #ifdef USE_ASPELL
1992         page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
1993         page->combo_default_dictionary = combo_default_dictionary;
1994         page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary;
1995         page->combo_default_alt_dictionary = combo_default_alt_dictionary;
1996 #endif
1997
1998 #ifdef USE_ASPELL
1999         /* reset gtkaspell menus */
2000         if (compose_page.combo_default_dictionary != NULL) {
2001                 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_dictionary),
2002                                         gtkaspell_dictionary_store_new(prefs_common.aspell_path));
2003                 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_alt_dictionary),
2004                                         gtkaspell_dictionary_store_new_with_refresh(
2005                                                 prefs_common.aspell_path, FALSE));
2006         }
2007 #endif
2008
2009         tmp_ac_prefs = *ac_prefs;
2010
2011         if (new_account) {
2012                 prefs_set_dialog_to_default(compose_param);
2013         } else
2014                 prefs_set_dialog(compose_param);
2015
2016         page->vbox = vbox1;
2017
2018         page->page.widget = vbox1;
2019 }
2020         
2021 static void templates_create_widget_func(PrefsPage * _page,
2022                                            GtkWindow * window,
2023                                            gpointer data)
2024 {
2025         TemplatesPage *page = (TemplatesPage *) _page;
2026         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2027         GtkWidget *vbox;
2028         GtkWidget *vbox2;
2029         GtkWidget *notebook;
2030
2031         vbox = gtk_vbox_new(FALSE, 0);
2032         gtk_widget_show(vbox);
2033         
2034         notebook = gtk_notebook_new();
2035         gtk_widget_show(notebook);
2036         gtk_notebook_set_homogeneous_tabs(GTK_NOTEBOOK(notebook), TRUE);
2037         gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
2038
2039         /* compose format */
2040         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2041         gtk_widget_show (vbox2);
2042         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2043
2044         quotefmt_create_new_msg_fmt_widgets(
2045                                 window,
2046                                 vbox2,
2047                                 &page->checkbtn_compose_with_format,
2048                                 &page->compose_subject_format,
2049                                 &page->compose_body_format,
2050                                 FALSE);
2051         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Compose")));
2052
2053         /* reply format */      
2054         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2055         gtk_widget_show (vbox2);
2056         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2057         
2058         quotefmt_create_reply_fmt_widgets(
2059                                 window,
2060                                 vbox2,
2061                                 &page->checkbtn_reply_with_format,
2062                                 &page->reply_quotemark,
2063                                 &page->reply_body_format,
2064                                 FALSE);
2065         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Reply")));
2066
2067         /* forward format */    
2068         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2069         gtk_widget_show (vbox2);
2070         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2071
2072         quotefmt_create_forward_fmt_widgets(
2073                                 window,
2074                                 vbox2,
2075                                 &page->checkbtn_forward_with_format,
2076                                 &page->forward_quotemark,
2077                                 &page->forward_body_format,
2078                                 FALSE);
2079         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Forward")));
2080
2081         quotefmt_add_info_button(window, vbox);
2082
2083         tmp_ac_prefs = *ac_prefs;
2084
2085         if (new_account) {
2086                 prefs_set_dialog_to_default(templates_param);
2087         } else
2088                 prefs_set_dialog(templates_param);
2089
2090         page->vbox = vbox;
2091
2092         page->page.widget = vbox;
2093 }
2094
2095 static void privacy_create_widget_func(PrefsPage * _page,
2096                                            GtkWindow * window,
2097                                            gpointer data)
2098 {
2099         PrivacyPage *page = (PrivacyPage *) _page;
2100         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2101
2102         GtkWidget *vbox1;
2103         GtkWidget *vbox2;
2104         GtkWidget *hbox1;
2105         GtkWidget *label;
2106         GtkWidget *default_privacy_system;
2107         GtkListStore *menu;
2108         GtkCellRenderer *rend;
2109         GtkWidget *default_encrypt_checkbtn;
2110         GtkWidget *default_encrypt_reply_checkbtn;
2111         GtkWidget *default_sign_checkbtn;
2112         GtkWidget *save_clear_text_checkbtn;
2113         GtkWidget *encrypt_to_self_checkbtn;
2114
2115         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2116         gtk_widget_show (vbox1);
2117         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2118
2119         vbox2 = gtk_vbox_new (FALSE, 0);
2120         gtk_widget_show (vbox2);
2121         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2122
2123         hbox1 = gtk_hbox_new(FALSE, 8);
2124         gtk_widget_show (hbox1);
2125         gtk_container_add (GTK_CONTAINER(vbox2), hbox1);
2126
2127         label = gtk_label_new(_("Default privacy system"));
2128         gtk_widget_show(label);
2129         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2130
2131         /* Can't use gtkut_sc_combobox_create() here, because model for this
2132          * combobox needs an extra string column to store privacy plugin id. */
2133         menu = gtk_list_store_new(4,
2134                         G_TYPE_STRING,
2135                         G_TYPE_INT,
2136                         G_TYPE_BOOLEAN,
2137                         G_TYPE_STRING); /* This is where we store the privacy plugin id. */
2138         default_privacy_system = gtk_combo_box_new_with_model(GTK_TREE_MODEL(menu));
2139
2140         rend = gtk_cell_renderer_text_new();
2141         gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(default_privacy_system), rend, TRUE);
2142         gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(default_privacy_system), rend,
2143                         "text", COMBOBOX_TEXT,
2144                         "sensitive", COMBOBOX_SENS,
2145                         NULL);
2146         gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(default_privacy_system), FALSE);
2147
2148         gtk_widget_show (default_privacy_system);
2149         gtk_box_pack_start (GTK_BOX(hbox1), default_privacy_system, FALSE, TRUE, 0);
2150
2151         g_signal_connect(G_OBJECT(default_privacy_system), "changed",
2152                          G_CALLBACK(privacy_system_activated),
2153                          NULL);
2154
2155         PACK_CHECK_BUTTON (vbox2, default_sign_checkbtn,
2156                            _("Always sign messages"));
2157         PACK_CHECK_BUTTON (vbox2, default_encrypt_checkbtn,
2158                            _("Always encrypt messages"));
2159         PACK_CHECK_BUTTON (vbox2, default_encrypt_reply_checkbtn,
2160                            _("Always encrypt messages when replying to an "
2161                              "encrypted message"));
2162         PACK_CHECK_BUTTON (vbox2, encrypt_to_self_checkbtn,
2163                            _("Encrypt sent messages with your own key in addition to recipient's"));
2164         PACK_CHECK_BUTTON (vbox2, save_clear_text_checkbtn,
2165                            _("Save sent encrypted messages as clear text"));
2166
2167         SET_TOGGLE_SENSITIVITY_REVERSE(encrypt_to_self_checkbtn, save_clear_text_checkbtn);
2168         SET_TOGGLE_SENSITIVITY_REVERSE(save_clear_text_checkbtn, encrypt_to_self_checkbtn);
2169
2170         page->default_privacy_system = default_privacy_system;
2171         page->default_encrypt_checkbtn = default_encrypt_checkbtn;
2172         page->default_encrypt_reply_checkbtn = default_encrypt_reply_checkbtn;
2173         page->default_sign_checkbtn    = default_sign_checkbtn;
2174         page->save_clear_text_checkbtn = save_clear_text_checkbtn;
2175         page->encrypt_to_self_checkbtn = encrypt_to_self_checkbtn;
2176
2177         update_privacy_system_menu();
2178
2179         tmp_ac_prefs = *ac_prefs;
2180
2181         if (new_account) {
2182                 prefs_set_dialog_to_default(privacy_param);
2183         } else
2184                 prefs_set_dialog(privacy_param);
2185
2186         page->vbox = vbox1;
2187
2188         page->page.widget = vbox1;
2189 }
2190         
2191 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
2192
2193 #define CREATE_RADIO_BUTTON(box, btn, btn_p, label, data)               \
2194 {                                                                       \
2195         btn = gtk_radio_button_new_with_label_from_widget               \
2196                 (GTK_RADIO_BUTTON (btn_p), label);                      \
2197         gtk_widget_show (btn);                                          \
2198         gtk_box_pack_start (GTK_BOX (box), btn, FALSE, FALSE, 0);       \
2199         g_object_set_data (G_OBJECT (btn),                              \
2200                            MENU_VAL_ID,                                 \
2201                            GINT_TO_POINTER (data));                     \
2202 }
2203
2204 #define CREATE_RADIO_BUTTONS(box,                                       \
2205                              btn1, btn1_label, btn1_data,               \
2206                              btn2, btn2_label, btn2_data,               \
2207                              btn3, btn3_label, btn3_data)               \
2208 {                                                                       \
2209         btn1 = gtk_radio_button_new_with_label(NULL, btn1_label);       \
2210         gtk_widget_show (btn1);                                         \
2211         gtk_box_pack_start (GTK_BOX (box), btn1, FALSE, FALSE, 0);      \
2212         g_object_set_data (G_OBJECT (btn1),                             \
2213                            MENU_VAL_ID,                                 \
2214                            GINT_TO_POINTER (btn1_data));                \
2215                                                                         \
2216         CREATE_RADIO_BUTTON(box, btn2, btn1, btn2_label, btn2_data);    \
2217         CREATE_RADIO_BUTTON(box, btn3, btn1, btn3_label, btn3_data);    \
2218 }
2219
2220 static void ssl_create_widget_func(PrefsPage * _page,
2221                                            GtkWindow * window,
2222                                            gpointer data)
2223 {
2224         SSLPage *page = (SSLPage *) _page;
2225         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2226
2227         GtkWidget *vbox1;
2228
2229         GtkWidget *pop_frame;
2230         GtkWidget *vbox2;
2231         GtkWidget *pop_nossl_radiobtn;
2232         GtkWidget *pop_ssltunnel_radiobtn;
2233         GtkWidget *pop_starttls_radiobtn;
2234
2235         GtkWidget *imap_frame;
2236         GtkWidget *vbox3;
2237         GtkWidget *imap_nossl_radiobtn;
2238         GtkWidget *imap_ssltunnel_radiobtn;
2239         GtkWidget *imap_starttls_radiobtn;
2240
2241         GtkWidget *nntp_frame;
2242         GtkWidget *vbox4;
2243         GtkWidget *nntp_nossl_radiobtn;
2244         GtkWidget *nntp_ssltunnel_radiobtn;
2245
2246         GtkWidget *send_frame;
2247         GtkWidget *vbox5;
2248         GtkWidget *smtp_nossl_radiobtn;
2249         GtkWidget *smtp_ssltunnel_radiobtn;
2250         GtkWidget *smtp_starttls_radiobtn;
2251
2252         GtkWidget *vbox6;
2253         GtkWidget *use_nonblocking_ssl_checkbtn;
2254         GtkWidget *hbox;
2255         GtkWidget *hbox_spc;
2256         GtkWidget *label;
2257
2258         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2259         gtk_widget_show (vbox1);
2260         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2261
2262         vbox2 = gtkut_get_options_frame(vbox1, &pop_frame, _("POP3"));
2263
2264         CREATE_RADIO_BUTTONS(vbox2,
2265                              pop_nossl_radiobtn,
2266                              _("Don't use SSL"),
2267                              SSL_NONE,
2268                              pop_ssltunnel_radiobtn,
2269                              _("Use SSL for POP3 connection"),
2270                              SSL_TUNNEL,
2271                              pop_starttls_radiobtn,
2272                              _("Use STARTTLS command to start SSL session"),
2273                              SSL_STARTTLS);
2274
2275         vbox3 = gtkut_get_options_frame(vbox1, &imap_frame, _("IMAP4"));
2276
2277         CREATE_RADIO_BUTTONS(vbox3,
2278                              imap_nossl_radiobtn,
2279                              _("Don't use SSL"),
2280                              SSL_NONE,
2281                              imap_ssltunnel_radiobtn,
2282                              _("Use SSL for IMAP4 connection"),
2283                              SSL_TUNNEL,
2284                              imap_starttls_radiobtn,
2285                              _("Use STARTTLS command to start SSL session"),
2286                              SSL_STARTTLS);
2287
2288         vbox4 = gtkut_get_options_frame(vbox1, &nntp_frame, _("NNTP"));
2289
2290         nntp_nossl_radiobtn =
2291                 gtk_radio_button_new_with_label (NULL, _("Don't use SSL"));
2292         gtk_widget_show (nntp_nossl_radiobtn);
2293         gtk_box_pack_start (GTK_BOX (vbox4), nntp_nossl_radiobtn,
2294                             FALSE, FALSE, 0);
2295         g_object_set_data (G_OBJECT (nntp_nossl_radiobtn),
2296                            MENU_VAL_ID,
2297                            GINT_TO_POINTER (SSL_NONE));
2298
2299         CREATE_RADIO_BUTTON(vbox4, nntp_ssltunnel_radiobtn, nntp_nossl_radiobtn,
2300                             _("Use SSL for NNTP connection"), SSL_TUNNEL);
2301
2302         vbox5 = gtkut_get_options_frame(vbox1, &send_frame, _("Send (SMTP)"));
2303
2304         CREATE_RADIO_BUTTONS(vbox5,
2305                              smtp_nossl_radiobtn,
2306                              _("Don't use SSL (but, if necessary, use STARTTLS)"),
2307                              SSL_NONE,
2308                              smtp_ssltunnel_radiobtn,
2309                              _("Use SSL for SMTP connection"),
2310                              SSL_TUNNEL,
2311                              smtp_starttls_radiobtn,
2312                              _("Use STARTTLS command to start SSL session"),
2313                              SSL_STARTTLS);
2314
2315         vbox6 = gtk_vbox_new (FALSE, 0);
2316         gtk_widget_show (vbox6);
2317         gtk_box_pack_start (GTK_BOX (vbox1), vbox6, FALSE, FALSE, 0);
2318
2319         PACK_CHECK_BUTTON(vbox6, use_nonblocking_ssl_checkbtn,
2320                           _("Use non-blocking SSL"));
2321
2322         hbox = gtk_hbox_new (FALSE, 0);
2323         gtk_widget_show (hbox);
2324         gtk_box_pack_start (GTK_BOX (vbox6), hbox, FALSE, FALSE, 0);
2325
2326         hbox_spc = gtk_hbox_new (FALSE, 0);
2327         gtk_widget_show (hbox_spc);
2328         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2329         gtk_widget_set_size_request (hbox_spc, 16, -1);
2330
2331         label = gtk_label_new
2332                 (_("Turn this off if you have SSL connection problems"));
2333         gtk_widget_show (label);
2334         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2335         gtkut_widget_set_small_font_size (label);
2336
2337         page->pop_frame               = pop_frame;
2338         page->pop_nossl_radiobtn      = pop_nossl_radiobtn;
2339         page->pop_ssltunnel_radiobtn  = pop_ssltunnel_radiobtn;
2340         page->pop_starttls_radiobtn   = pop_starttls_radiobtn;
2341
2342         page->imap_frame              = imap_frame;
2343         page->imap_nossl_radiobtn     = imap_nossl_radiobtn;
2344         page->imap_ssltunnel_radiobtn = imap_ssltunnel_radiobtn;
2345         page->imap_starttls_radiobtn  = imap_starttls_radiobtn;
2346
2347         page->nntp_frame              = nntp_frame;
2348         page->nntp_nossl_radiobtn     = nntp_nossl_radiobtn;
2349         page->nntp_ssltunnel_radiobtn = nntp_ssltunnel_radiobtn;
2350
2351         page->send_frame              = send_frame;
2352         page->smtp_nossl_radiobtn     = smtp_nossl_radiobtn;
2353         page->smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn;
2354         page->smtp_starttls_radiobtn  = smtp_starttls_radiobtn;
2355
2356         page->use_nonblocking_ssl_checkbtn = use_nonblocking_ssl_checkbtn;
2357
2358         tmp_ac_prefs = *ac_prefs;
2359
2360         if (new_account) {
2361                 prefs_set_dialog_to_default(ssl_param);
2362         } else
2363                 prefs_set_dialog(ssl_param);
2364
2365         page->vbox = vbox1;
2366
2367         page->page.widget = vbox1;
2368 }
2369
2370 #undef CREATE_RADIO_BUTTONS
2371 #undef CREATE_RADIO_BUTTON
2372 #endif /* USE_OPENSSL */
2373         
2374 static void advanced_create_widget_func(PrefsPage * _page,
2375                                            GtkWindow * window,
2376                                            gpointer data)
2377 {
2378         AdvancedPage *page = (AdvancedPage *) _page;
2379         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2380
2381         GtkWidget *vbox1;
2382         GtkWidget *vbox2;
2383         GtkWidget *hbox1;
2384         GtkWidget *checkbtn_smtpport;
2385         GtkWidget *entry_smtpport;
2386         GtkWidget *hbox_popport;
2387         GtkWidget *checkbtn_popport;
2388         GtkWidget *entry_popport;
2389         GtkWidget *hbox_imapport;
2390         GtkWidget *checkbtn_imapport;
2391         GtkWidget *entry_imapport;
2392         GtkWidget *hbox_nntpport;
2393         GtkWidget *checkbtn_nntpport;
2394         GtkWidget *entry_nntpport;
2395         GtkWidget *checkbtn_domain;
2396         GtkWidget *entry_domain;
2397         GtkWidget *checkbtn_crosspost;
2398         GtkWidget *colormenu_crosspost;
2399         GtkWidget *menu;
2400 #ifndef G_OS_WIN32
2401         GtkWidget *checkbtn_tunnelcmd;
2402         GtkWidget *entry_tunnelcmd;
2403 #endif
2404         GtkWidget *folder_frame;
2405         GtkWidget *vbox3;
2406         GtkWidget *table;
2407         GtkWidget *sent_folder_checkbtn;
2408         GtkWidget *sent_folder_entry;
2409         GtkWidget *queue_folder_checkbtn;
2410         GtkWidget *queue_folder_entry;
2411         GtkWidget *draft_folder_checkbtn;
2412         GtkWidget *draft_folder_entry;
2413         GtkWidget *trash_folder_checkbtn;
2414         GtkWidget *trash_folder_entry;
2415         GtkTooltips *tips = gtk_tooltips_new();
2416 #define PACK_HBOX(hbox) \
2417         { \
2418         hbox = gtk_hbox_new (FALSE, 8); \
2419         gtk_widget_show (hbox); \
2420         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); \
2421         }
2422
2423 #define PACK_PORT_ENTRY(box, entry) \
2424         { \
2425         entry = gtk_entry_new (); \
2426         gtk_entry_set_max_length  (GTK_ENTRY(entry), 5); \
2427         gtk_widget_show (entry); \
2428         gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 0); \
2429         gtk_widget_set_size_request (entry, 64, -1); \
2430         }
2431
2432         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2433         gtk_widget_show (vbox1);
2434         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2435
2436         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW_2);
2437         gtk_widget_show (vbox2);
2438         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2439
2440         PACK_HBOX (hbox1);
2441         PACK_CHECK_BUTTON (hbox1, checkbtn_smtpport, _("SMTP port"));
2442         PACK_PORT_ENTRY (hbox1, entry_smtpport);
2443         SET_TOGGLE_SENSITIVITY (checkbtn_smtpport, entry_smtpport);
2444
2445         PACK_HBOX (hbox_popport);
2446         PACK_CHECK_BUTTON (hbox_popport, checkbtn_popport,
2447                            _("POP3 port"));
2448         PACK_PORT_ENTRY (hbox_popport, entry_popport);
2449         SET_TOGGLE_SENSITIVITY (checkbtn_popport, entry_popport);
2450
2451         PACK_HBOX (hbox_imapport);
2452         PACK_CHECK_BUTTON (hbox_imapport, checkbtn_imapport,
2453                            _("IMAP4 port"));
2454         PACK_PORT_ENTRY (hbox_imapport, entry_imapport);
2455         SET_TOGGLE_SENSITIVITY (checkbtn_imapport, entry_imapport);
2456
2457         PACK_HBOX (hbox_nntpport);
2458         PACK_CHECK_BUTTON (hbox_nntpport, checkbtn_nntpport,
2459                            _("NNTP port"));
2460         PACK_PORT_ENTRY (hbox_nntpport, entry_nntpport);
2461         SET_TOGGLE_SENSITIVITY (checkbtn_nntpport, entry_nntpport);
2462
2463         PACK_HBOX (hbox1);
2464         PACK_CHECK_BUTTON (hbox1, checkbtn_domain, _("Domain name"));
2465         
2466         gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), checkbtn_domain,
2467                              _("The domain name will be used in the right part of "
2468                                "the generated Message-Ids, and when connecting to "
2469                                "SMTP servers."),
2470                              NULL);
2471
2472         entry_domain = gtk_entry_new ();
2473         gtk_widget_show (entry_domain);
2474         gtk_box_pack_start (GTK_BOX (hbox1), entry_domain, TRUE, TRUE, 0);
2475         SET_TOGGLE_SENSITIVITY (checkbtn_domain, entry_domain);
2476         gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), entry_domain,
2477                              _("The domain name will be used in the right part of "
2478                                "the generated Message-Ids, and when connecting to "
2479                                "SMTP servers."),
2480                              NULL);
2481
2482
2483 #ifndef G_OS_WIN32      
2484         PACK_HBOX (hbox1);
2485         PACK_CHECK_BUTTON (hbox1, checkbtn_tunnelcmd,
2486                            _("Use command to communicate with server"));
2487         entry_tunnelcmd = gtk_entry_new ();
2488         gtk_widget_show (entry_tunnelcmd);
2489         gtk_box_pack_start (GTK_BOX (hbox1), entry_tunnelcmd, TRUE, TRUE, 0);
2490         SET_TOGGLE_SENSITIVITY (checkbtn_tunnelcmd, entry_tunnelcmd);
2491 #endif
2492         PACK_HBOX (hbox1);
2493         PACK_CHECK_BUTTON (hbox1, checkbtn_crosspost, 
2494                            _("Mark cross-posted messages as read and color:"));
2495         g_signal_connect (G_OBJECT (checkbtn_crosspost), "toggled",
2496                           G_CALLBACK (crosspost_color_toggled),
2497                           NULL);
2498
2499         colormenu_crosspost = gtk_option_menu_new();
2500         gtk_widget_show (colormenu_crosspost);
2501         gtk_box_pack_start (GTK_BOX (hbox1), colormenu_crosspost, FALSE, FALSE, 0);
2502
2503         menu = colorlabel_create_color_menu();
2504         gtk_option_menu_set_menu (GTK_OPTION_MENU(colormenu_crosspost), menu);
2505         SET_TOGGLE_SENSITIVITY(checkbtn_crosspost, colormenu_crosspost);
2506
2507         PACK_HBOX (hbox1);
2508 #undef PACK_HBOX
2509 #undef PACK_PORT_ENTRY
2510
2511         /* special folder setting (maybe these options are redundant) */
2512
2513         vbox3 = gtkut_get_options_frame(vbox1, &folder_frame, _("Folder"));
2514
2515         table = gtk_table_new (4, 3, FALSE);
2516         gtk_widget_show (table);
2517         gtk_container_add (GTK_CONTAINER (vbox3), table);
2518         gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
2519         gtk_table_set_col_spacings (GTK_TABLE (table), 4);
2520
2521 #define SET_CHECK_BTN_AND_ENTRY(label, checkbtn, entry, n)              \
2522 {                                                                       \
2523         GtkWidget *button;                                              \
2524                                                                         \
2525         checkbtn = gtk_check_button_new_with_label (label);             \
2526         gtk_widget_show (checkbtn);                                     \
2527         gtk_table_attach (GTK_TABLE (table), checkbtn,                  \
2528                           0, 1, n, n + 1, GTK_FILL, 0, 0, 0);           \
2529                                                                         \
2530         entry = gtk_entry_new ();                                       \
2531         gtk_widget_show (entry);                                        \
2532         gtk_table_attach (GTK_TABLE (table), entry, 1, 2, n, n + 1,     \
2533                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,           \
2534                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);    \
2535                                                                         \
2536         button = gtkut_get_browse_file_btn(_("Browse"));                \
2537         gtk_widget_show (button);                                       \
2538         gtk_table_attach (GTK_TABLE (table), button,                    \
2539                           2, 3, n, n + 1, GTK_FILL, 0, 0, 0);           \
2540         g_signal_connect                                                \
2541                 (G_OBJECT (button), "clicked",                  \
2542                  G_CALLBACK (prefs_account_select_folder_cb),           \
2543                  entry);                                                \
2544                                                                         \
2545         SET_TOGGLE_SENSITIVITY (checkbtn, entry);                               \
2546         SET_TOGGLE_SENSITIVITY (checkbtn, button);                      \
2547 }
2548
2549         SET_CHECK_BTN_AND_ENTRY(_("Put sent messages in"),
2550                                 sent_folder_checkbtn, sent_folder_entry, 0);
2551         SET_CHECK_BTN_AND_ENTRY(_("Put queued messages in"),
2552                                 queue_folder_checkbtn, queue_folder_entry, 1);
2553         SET_CHECK_BTN_AND_ENTRY(_("Put draft messages in"),
2554                                 draft_folder_checkbtn, draft_folder_entry, 2);
2555         SET_CHECK_BTN_AND_ENTRY(_("Put deleted messages in"),
2556                                 trash_folder_checkbtn, trash_folder_entry, 3);
2557
2558         page->smtpport_checkbtn = checkbtn_smtpport;
2559         page->smtpport_entry            = entry_smtpport;
2560         page->popport_hbox              = hbox_popport;
2561         page->popport_checkbtn          = checkbtn_popport;
2562         page->popport_entry             = entry_popport;
2563         page->imapport_hbox             = hbox_imapport;
2564         page->imapport_checkbtn = checkbtn_imapport;
2565         page->imapport_entry            = entry_imapport;
2566         page->nntpport_hbox             = hbox_nntpport;
2567         page->nntpport_checkbtn = checkbtn_nntpport;
2568         page->nntpport_entry            = entry_nntpport;
2569         page->domain_checkbtn           = checkbtn_domain;
2570         page->domain_entry              = entry_domain;
2571         page->crosspost_checkbtn        = checkbtn_crosspost;
2572         page->crosspost_colormenu       = colormenu_crosspost;
2573
2574 #ifndef G_OS_WIN32
2575         page->tunnelcmd_checkbtn        = checkbtn_tunnelcmd;
2576         page->tunnelcmd_entry   = entry_tunnelcmd;
2577 #endif
2578         page->sent_folder_checkbtn  = sent_folder_checkbtn;
2579         page->sent_folder_entry   = sent_folder_entry;
2580         page->queue_folder_checkbtn  = queue_folder_checkbtn;
2581         page->queue_folder_entry   = queue_folder_entry;
2582         page->draft_folder_checkbtn = draft_folder_checkbtn;
2583         page->draft_folder_entry  = draft_folder_entry;
2584         page->trash_folder_checkbtn = trash_folder_checkbtn;
2585         page->trash_folder_entry  = trash_folder_entry;
2586
2587         tmp_ac_prefs = *ac_prefs;
2588
2589         if (new_account) {
2590                 prefs_set_dialog_to_default(advanced_param);
2591         } else
2592                 prefs_set_dialog(advanced_param);
2593
2594         page->vbox = vbox1;
2595
2596         page->page.widget = vbox1;
2597 }
2598         
2599 static gint prefs_basic_apply(void)
2600 {
2601         RecvProtocol protocol;
2602         gchar *old_id = NULL;
2603         gchar *new_id = NULL;
2604         struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *) basic_page.protocol_optmenu;
2605         GtkWidget *optmenu = protocol_optmenu->combobox;
2606
2607         protocol = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
2608
2609         if (*gtk_entry_get_text(GTK_ENTRY(basic_page.acname_entry)) == '\0') {
2610                 alertpanel_error(_("Account name is not entered."));
2611                 return -1;
2612         }
2613         if (*gtk_entry_get_text(GTK_ENTRY(basic_page.addr_entry)) == '\0') {
2614                 alertpanel_error(_("Mail address is not entered."));
2615                 return -1;
2616         }
2617         if (((protocol == A_POP3) || 
2618              (protocol == A_LOCAL && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn))) || 
2619              (protocol == A_NONE)) &&
2620            *gtk_entry_get_text(GTK_ENTRY(basic_page.smtpserv_entry)) == '\0') {
2621                 alertpanel_error(_("SMTP server is not entered."));
2622                 return -1;
2623         }
2624         if ((protocol == A_POP3 || protocol == A_IMAP4) &&
2625             *gtk_entry_get_text(GTK_ENTRY(basic_page.uid_entry)) == '\0') {
2626                 alertpanel_error(_("User ID is not entered."));
2627                 return -1;
2628         }
2629         if (protocol == A_POP3 &&
2630             *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
2631                 alertpanel_error(_("POP3 server is not entered."));
2632                 return -1;
2633         }
2634         if (protocol == A_POP3 || protocol == A_LOCAL) {
2635                 GtkWidget *inbox_entry = (protocol == A_POP3 ? receive_page.inbox_entry : receive_page.local_inbox_entry );
2636                 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
2637                 FolderItem *inbox =  folder_find_item_from_identifier(mailbox);
2638                 if (!inbox && create_mailbox) {
2639                         gchar *id = NULL;
2640                         setup_write_mailbox_path(mainwindow_get_mainwindow(), "Mail");
2641                         id = folder_item_get_identifier(folder_get_default_inbox_for_class(F_MH));
2642                         gtk_entry_set_text(GTK_ENTRY(receive_page.inbox_entry),
2643                                 id);
2644                         gtk_entry_set_text(GTK_ENTRY(receive_page.local_inbox_entry),
2645                                 id);
2646                         g_free(id);
2647                         mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
2648                         create_mailbox = FALSE;
2649                         inbox =  folder_find_item_from_identifier(mailbox);
2650                 }
2651                 if (inbox == NULL) {
2652                         alertpanel_error(_("The default Inbox folder doesn't exist."));
2653                         return -1;
2654                 }
2655         }
2656         if (protocol == A_IMAP4 &&
2657             *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
2658                 alertpanel_error(_("IMAP4 server is not entered."));
2659                 return -1;
2660         }
2661         if (protocol == A_NNTP &&
2662             *gtk_entry_get_text(GTK_ENTRY(basic_page.nntpserv_entry)) == '\0') {
2663                 alertpanel_error(_("NNTP server is not entered."));
2664                 return -1;
2665         }
2666
2667         if (protocol == A_LOCAL &&
2668             *gtk_entry_get_text(GTK_ENTRY(basic_page.localmbox_entry)) == '\0') {
2669                 alertpanel_error(_("local mailbox filename is not entered."));
2670                 return -1;
2671         }
2672
2673         if (protocol == A_LOCAL &&
2674             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn)) && *gtk_entry_get_text(GTK_ENTRY(basic_page.mailcmd_entry)) == '\0') {
2675                 alertpanel_error(_("mail command is not entered."));
2676                 return -1;
2677         }
2678         
2679         if (protocol == A_IMAP4 || protocol == A_NNTP) 
2680                 old_id = g_strdup_printf("#%s/%s",
2681                                 protocol == A_IMAP4 ? "imap":"nntp",
2682                                 tmp_ac_prefs.account_name ? tmp_ac_prefs.account_name : "(null)");
2683         
2684         prefs_set_data_from_dialog(basic_param);
2685         
2686         if (protocol == A_IMAP4 || protocol == A_NNTP) {
2687                 new_id = g_strdup_printf("#%s/%s",
2688                                 protocol == A_IMAP4 ? "imap":"nntp",
2689                                 tmp_ac_prefs.account_name);
2690                 if (old_id != NULL && new_id != NULL)
2691                         prefs_filtering_rename_path(old_id, new_id);
2692                 g_free(old_id);
2693                 g_free(new_id);
2694         }
2695         
2696         return 0;
2697 }
2698
2699 static gint prefs_receive_apply(void)
2700 {
2701         prefs_set_data_from_dialog(receive_param);
2702         return 0;
2703 }
2704
2705 static gint prefs_send_apply(void)
2706 {
2707         prefs_set_data_from_dialog(send_param);
2708         return 0;
2709 }
2710
2711 static gint prefs_compose_apply(void)
2712 {
2713         prefs_set_data_from_dialog(compose_param);
2714         return 0;
2715 }
2716
2717 static gint prefs_templates_apply(void)
2718 {
2719         prefs_set_data_from_dialog(templates_param);
2720         return 0;
2721 }
2722
2723 static gint prefs_privacy_apply(void)
2724 {
2725         prefs_set_data_from_dialog(privacy_param);
2726         return 0;
2727 }
2728
2729 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
2730 static gint prefs_ssl_apply(void)
2731 {
2732         prefs_set_data_from_dialog(ssl_param);
2733         return 0;
2734 }
2735 #endif
2736
2737 static gint prefs_advanced_apply(void)
2738 {
2739         prefs_set_data_from_dialog(advanced_param);
2740         return 0;
2741 }
2742
2743 static void basic_destroy_widget_func(PrefsPage *_page)
2744 {
2745         /* BasicPage *page = (BasicPage *) _page; */
2746 }
2747
2748 static void receive_destroy_widget_func(PrefsPage *_page)
2749 {
2750         /* ReceivePage *page = (ReceivePage *) _page; */
2751 }
2752
2753 static void send_destroy_widget_func(PrefsPage *_page)
2754 {
2755         /* SendPage *page = (SendPage *) _page; */
2756 }
2757
2758 static void compose_destroy_widget_func(PrefsPage *_page)
2759 {
2760         /* ComposePage *page = (ComposePage *) _page; */
2761 }
2762
2763 static void templates_destroy_widget_func(PrefsPage *_page)
2764 {
2765         /* TemplatesPage *page = (TemplatesPage *) _page; */
2766 }
2767
2768 static void privacy_destroy_widget_func(PrefsPage *_page)
2769 {
2770         /* PrivacyPage *page = (PrivacyPage *) _page; */
2771 }
2772
2773 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
2774 static void ssl_destroy_widget_func(PrefsPage *_page)
2775 {
2776         /* SSLPage *page = (SSLPage *) _page; */
2777 }
2778 #endif
2779
2780 static void advanced_destroy_widget_func(PrefsPage *_page)
2781 {
2782         /* AdvancedPage *page = (AdvancedPage *) _page; */
2783 }
2784
2785 static gboolean basic_can_close_func(PrefsPage *_page)
2786 {       
2787         BasicPage *page = (BasicPage *) _page;
2788
2789         if (!page->page.page_open)
2790                 return TRUE;
2791
2792         return prefs_basic_apply() >= 0;
2793 }
2794
2795 static gboolean receive_can_close_func(PrefsPage *_page)
2796 {       
2797         ReceivePage *page = (ReceivePage *) _page;
2798
2799         if (!page->page.page_open)
2800                 return TRUE;
2801
2802         return prefs_receive_apply() >= 0;
2803 }
2804
2805 static gboolean send_can_close_func(PrefsPage *_page)
2806 {       
2807         SendPage *page = (SendPage *) _page;
2808
2809         if (!page->page.page_open)
2810                 return TRUE;
2811
2812         return prefs_send_apply() >= 0;
2813 }
2814
2815 static gboolean compose_can_close_func(PrefsPage *_page)
2816 {       
2817         ComposePage *page = (ComposePage *) _page;
2818
2819         if (!page->page.page_open)
2820                 return TRUE;
2821
2822         return prefs_compose_apply() >= 0;
2823 }
2824
2825 static gboolean templates_can_close_func(PrefsPage *_page)
2826 {
2827         TemplatesPage *page = (TemplatesPage *) _page;
2828
2829         if (!page->page.page_open)
2830                 return TRUE;
2831
2832         return prefs_templates_apply() >= 0;
2833 }
2834
2835 static gboolean privacy_can_close_func(PrefsPage *_page)
2836 {
2837         PrivacyPage *page = (PrivacyPage *) _page;
2838
2839         if (!page->page.page_open)
2840                 return TRUE;
2841
2842         return prefs_privacy_apply() >= 0;
2843 }
2844
2845 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
2846 static gboolean ssl_can_close_func(PrefsPage *_page)
2847 {
2848         SSLPage *page = (SSLPage *) _page;
2849
2850         if (!page->page.page_open)
2851                 return TRUE;
2852
2853         return prefs_ssl_apply() >= 0;
2854 }
2855 #endif
2856
2857 static gboolean advanced_can_close_func(PrefsPage *_page)
2858 {
2859         AdvancedPage *page = (AdvancedPage *) _page;
2860
2861         if (!page->page.page_open)
2862                 return TRUE;
2863
2864         return prefs_advanced_apply() >= 0;
2865 }
2866
2867 static void basic_save_func(PrefsPage *_page)
2868 {
2869         BasicPage *page = (BasicPage *) _page;
2870
2871         if (!page->page.page_open)
2872                 return;
2873
2874         if (prefs_basic_apply() >= 0)
2875                 cancelled = FALSE;
2876 }
2877
2878 static void receive_save_func(PrefsPage *_page)
2879 {
2880         ReceivePage *page = (ReceivePage *) _page;
2881
2882         if (!page->page.page_open)
2883                 return;
2884
2885         if (prefs_receive_apply() >= 0)
2886                 cancelled = FALSE;
2887 }
2888
2889 static void send_save_func(PrefsPage *_page)
2890 {
2891         SendPage *page = (SendPage *) _page;
2892
2893         if (!page->page.page_open)
2894                 return;
2895
2896         if (prefs_send_apply() >= 0)
2897                 cancelled = FALSE;
2898 }
2899
2900 static void compose_save_func(PrefsPage *_page)
2901 {
2902         ComposePage *page = (ComposePage *) _page;
2903
2904         if (!page->page.page_open)
2905                 return;
2906
2907         if (prefs_compose_apply() >= 0)
2908                 cancelled = FALSE;
2909 }
2910
2911 static void templates_save_func(PrefsPage *_page)
2912 {
2913         TemplatesPage *page = (TemplatesPage *) _page;
2914
2915         if (!page->page.page_open)
2916                 return;
2917
2918         quotefmt_check_new_msg_formats(tmp_ac_prefs.compose_with_format,
2919                                                                         tmp_ac_prefs.compose_subject_format,
2920                                                                         tmp_ac_prefs.compose_body_format);
2921         quotefmt_check_reply_formats(tmp_ac_prefs.reply_with_format,
2922                                                                         tmp_ac_prefs.reply_quotemark,
2923                                                                         tmp_ac_prefs.reply_body_format);
2924         quotefmt_check_forward_formats(tmp_ac_prefs.forward_with_format,
2925                                                                         tmp_ac_prefs.forward_quotemark,
2926                                                                         tmp_ac_prefs.forward_body_format);
2927         if (prefs_templates_apply() >= 0)
2928                 cancelled = FALSE;
2929 }
2930
2931 static void privacy_save_func(PrefsPage *_page)
2932 {
2933         PrivacyPage *page = (PrivacyPage *) _page;
2934
2935         if (!page->page.page_open)
2936                 return;
2937
2938         if (prefs_privacy_apply() >= 0)
2939                 cancelled = FALSE;
2940 }
2941
2942 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
2943 static void ssl_save_func(PrefsPage *_page)
2944 {
2945         SSLPage *page = (SSLPage *) _page;
2946
2947         if (!page->page.page_open)
2948                 return;
2949
2950         if (prefs_ssl_apply() >= 0)
2951                 cancelled = FALSE;
2952 }
2953 #endif
2954
2955 static void advanced_save_func(PrefsPage *_page)
2956 {
2957         AdvancedPage *page = (AdvancedPage *) _page;
2958
2959         if (!page->page.page_open)
2960                 return;
2961
2962         if (prefs_advanced_apply() >= 0)
2963                 cancelled = FALSE;
2964 }
2965
2966 static void register_basic_page(void)
2967 {
2968         static gchar *path[3];
2969
2970         path[0] = _("Account");
2971         path[1] = _("Basic");
2972         path[2] = NULL;
2973         
2974         basic_page.page.path = path;
2975         basic_page.page.weight = 1000.0;
2976         basic_page.page.create_widget = basic_create_widget_func;
2977         basic_page.page.destroy_widget = basic_destroy_widget_func;
2978         basic_page.page.save_page = basic_save_func;
2979         basic_page.page.can_close = basic_can_close_func;
2980
2981         prefs_account_register_page((PrefsPage *) &basic_page);
2982 }
2983
2984 static void register_receive_page(void)
2985 {
2986         static gchar *path[3];
2987
2988         path[0] = _("Account");
2989         path[1] = _("Receive");
2990         path[2] = NULL;
2991         
2992         receive_page.page.path = path;
2993         receive_page.page.weight = 1000.0;
2994         receive_page.page.create_widget = receive_create_widget_func;
2995         receive_page.page.destroy_widget = receive_destroy_widget_func;
2996         receive_page.page.save_page = receive_save_func;
2997         receive_page.page.can_close = receive_can_close_func;
2998
2999         prefs_account_register_page((PrefsPage *) &receive_page);
3000 }
3001
3002 static void register_send_page(void)
3003 {
3004         static gchar *path[3];
3005
3006         path[0] = _("Account");
3007         path[1] = _("Send");
3008         path[2] = NULL;
3009         
3010         send_page.page.path = path;
3011         send_page.page.weight = 1000.0;
3012         send_page.page.create_widget = send_create_widget_func;
3013         send_page.page.destroy_widget = send_destroy_widget_func;
3014         send_page.page.save_page = send_save_func;
3015         send_page.page.can_close = send_can_close_func;
3016
3017         prefs_account_register_page((PrefsPage *) &send_page);
3018 }
3019
3020 static void register_compose_page(void)
3021 {
3022         static gchar *path[3];
3023
3024         path[0] = _("Account");
3025         path[1] = _("Compose");
3026         path[2] = NULL;
3027         
3028         compose_page.page.path = path;
3029         compose_page.page.weight = 1000.0;
3030         compose_page.page.create_widget = compose_create_widget_func;
3031         compose_page.page.destroy_widget = compose_destroy_widget_func;
3032         compose_page.page.save_page = compose_save_func;
3033         compose_page.page.can_close = compose_can_close_func;
3034
3035         prefs_account_register_page((PrefsPage *) &compose_page);
3036 }
3037
3038 static void register_templates_page(void)
3039 {
3040         static gchar *path[3];
3041
3042         path[0] = _("Account");
3043         path[1] = _("Templates");
3044         path[2] = NULL;
3045         
3046         templates_page.page.path = path;
3047         templates_page.page.weight = 1000.0;
3048         templates_page.page.create_widget = templates_create_widget_func;
3049         templates_page.page.destroy_widget = templates_destroy_widget_func;
3050         templates_page.page.save_page = templates_save_func;
3051         templates_page.page.can_close = templates_can_close_func;
3052
3053         prefs_account_register_page((PrefsPage *) &templates_page);
3054 }
3055
3056 static void register_privacy_page(void)
3057 {
3058         static gchar *path[3];
3059
3060         path[0] = _("Account");
3061         path[1] = _("Privacy");
3062         path[2] = NULL;
3063         
3064         privacy_page.page.path = path;
3065         privacy_page.page.weight = 1000.0;
3066         privacy_page.page.create_widget = privacy_create_widget_func;
3067         privacy_page.page.destroy_widget = privacy_destroy_widget_func;
3068         privacy_page.page.save_page = privacy_save_func;
3069         privacy_page.page.can_close = privacy_can_close_func;
3070
3071         prefs_account_register_page((PrefsPage *) &privacy_page);
3072 }
3073
3074 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
3075 static void register_ssl_page(void)
3076 {
3077         static gchar *path[3];
3078
3079         path[0] = _("Account");
3080         path[1] = _("SSL");
3081         path[2] = NULL;
3082         
3083         ssl_page.page.path = path;
3084         ssl_page.page.weight = 1000.0;
3085         ssl_page.page.create_widget = ssl_create_widget_func;
3086         ssl_page.page.destroy_widget = ssl_destroy_widget_func;
3087         ssl_page.page.save_page = ssl_save_func;
3088         ssl_page.page.can_close = ssl_can_close_func;
3089
3090         prefs_account_register_page((PrefsPage *) &ssl_page);
3091 }
3092 #endif
3093
3094 static void register_advanced_page(void)
3095 {
3096         static gchar *path[3];
3097
3098         path[0] = _("Account");
3099         path[1] = _("Advanced");
3100         path[2] = NULL;
3101         
3102         advanced_page.page.path = path;
3103         advanced_page.page.weight = 1000.0;
3104         advanced_page.page.create_widget = advanced_create_widget_func;
3105         advanced_page.page.destroy_widget = advanced_destroy_widget_func;
3106         advanced_page.page.save_page = advanced_save_func;
3107         advanced_page.page.can_close = advanced_can_close_func;
3108
3109         prefs_account_register_page((PrefsPage *) &advanced_page);
3110 }
3111
3112 void prefs_account_init()
3113 {
3114         register_basic_page();
3115         register_receive_page();
3116         register_send_page();
3117         register_compose_page();
3118         register_templates_page();
3119         register_privacy_page();
3120 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
3121         register_ssl_page();
3122 #endif
3123         register_advanced_page();
3124 }
3125
3126 PrefsAccount *prefs_account_new(void)
3127 {
3128         PrefsAccount *ac_prefs;
3129
3130         ac_prefs = g_new0(PrefsAccount, 1);
3131         memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
3132         prefs_set_default(basic_param);
3133         prefs_set_default(receive_param);
3134         prefs_set_default(send_param);
3135         prefs_set_default(compose_param);
3136         prefs_set_default(templates_param);
3137         prefs_set_default(privacy_param);
3138         prefs_set_default(ssl_param);
3139         prefs_set_default(advanced_param);
3140         *ac_prefs = tmp_ac_prefs;
3141         ac_prefs->account_id = prefs_account_get_new_id();
3142
3143         ac_prefs->privacy_prefs = g_hash_table_new(g_str_hash, g_str_equal);
3144
3145         return ac_prefs;
3146 }
3147
3148 void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
3149 {
3150         const gchar *p = label;
3151         gchar *rcpath;
3152         gint id;
3153         gchar **strv, **cur;
3154
3155         g_return_if_fail(ac_prefs != NULL);
3156         g_return_if_fail(label != NULL);
3157
3158         memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
3159         tmp_ac_prefs.privacy_prefs = ac_prefs->privacy_prefs;
3160
3161         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
3162         prefs_read_config(basic_param, label, rcpath, NULL);
3163         prefs_read_config(receive_param, label, rcpath, NULL);
3164         prefs_read_config(send_param, label, rcpath, NULL);
3165         prefs_read_config(compose_param, label, rcpath, NULL);
3166         prefs_read_config(templates_param, label, rcpath, NULL);
3167         prefs_read_config(privacy_param, label, rcpath, NULL);
3168         prefs_read_config(ssl_param, label, rcpath, NULL);
3169         prefs_read_config(advanced_param, label, rcpath, NULL);
3170         g_free(rcpath);
3171
3172         *ac_prefs = tmp_ac_prefs;
3173         while (*p && !g_ascii_isdigit(*p)) p++;
3174         id = atoi(p);
3175         if (id < 0) g_warning("wrong account id: %d\n", id);
3176         ac_prefs->account_id = id;
3177
3178         if (ac_prefs->protocol == A_APOP) {
3179                 debug_print("converting protocol A_APOP to new prefs.\n");
3180                 ac_prefs->protocol = A_POP3;
3181                 ac_prefs->use_apop_auth = TRUE;
3182         }
3183
3184         if (privacy_prefs != NULL) {
3185                 strv = g_strsplit(privacy_prefs, ",", 0);
3186                 for (cur = strv; *cur != NULL; cur++) {
3187                         gchar *encvalue, *value;
3188
3189                         encvalue = strchr(*cur, '=');
3190                         if (encvalue == NULL)
3191                                 continue;
3192                         encvalue[0] = '\0';
3193                         encvalue++;
3194
3195                         value = g_malloc0(strlen(encvalue));
3196                         if (base64_decode(value, encvalue, strlen(encvalue)) > 0)
3197                                 g_hash_table_insert(ac_prefs->privacy_prefs, g_strdup(*cur), g_strdup(value));
3198                         g_free(value);
3199                 }
3200                 g_strfreev(strv);
3201                 g_free(privacy_prefs);
3202                 privacy_prefs = NULL;
3203         }
3204
3205         prefs_custom_header_read_config(ac_prefs);
3206 }
3207
3208 static void create_privacy_prefs(gpointer key, gpointer _value, gpointer user_data)
3209 {
3210         GString *str = (GString *) user_data;
3211         gchar *encvalue;
3212         gchar *value = (gchar *) _value;
3213
3214         if (str->len > 0)
3215                 g_string_append_c(str, ',');
3216
3217         encvalue = g_malloc0(B64LEN(strlen(value)) + 1);
3218         base64_encode(encvalue, (gchar *) value, strlen(value));
3219         g_string_append_printf(str, "%s=%s", (gchar *) key, encvalue);
3220         g_free(encvalue);
3221 }
3222
3223 #define WRITE_PARAM(PARAM_TABLE) \
3224                 if (prefs_write_param(PARAM_TABLE, pfile->fp) < 0) { \
3225                         g_warning("failed to write configuration to file\n"); \
3226                         prefs_file_close_revert(pfile); \
3227                         g_free(privacy_prefs); \
3228                         privacy_prefs = NULL; \
3229                         return; \
3230                 }
3231
3232 void prefs_account_write_config_all(GList *account_list)
3233 {
3234         GList *cur;
3235         gchar *rcpath;
3236         PrefFile *pfile;
3237
3238         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
3239         if ((pfile = prefs_write_open(rcpath)) == NULL) {
3240                 g_free(rcpath);
3241                 return;
3242         }
3243         g_free(rcpath);
3244
3245         for (cur = account_list; cur != NULL; cur = cur->next) {
3246                 GString *str;
3247
3248                 tmp_ac_prefs = *(PrefsAccount *)cur->data;
3249                 if (fprintf(pfile->fp, "[Account: %d]\n",
3250                             tmp_ac_prefs.account_id) <= 0)
3251                         return;
3252
3253                 str = g_string_sized_new(32);
3254                 g_hash_table_foreach(tmp_ac_prefs.privacy_prefs, create_privacy_prefs, str);
3255                 privacy_prefs = str->str;                   
3256                 g_string_free(str, FALSE);
3257
3258                 WRITE_PARAM(basic_param)
3259                 WRITE_PARAM(receive_param)
3260                 WRITE_PARAM(send_param)
3261                 WRITE_PARAM(compose_param)
3262                 WRITE_PARAM(templates_param)
3263                 WRITE_PARAM(privacy_param)
3264                 WRITE_PARAM(ssl_param)
3265                 WRITE_PARAM(advanced_param)
3266
3267                 g_free(privacy_prefs);
3268                 privacy_prefs = NULL;
3269
3270                 if (cur->next) {
3271                         if (fputc('\n', pfile->fp) == EOF) {
3272                                 FILE_OP_ERROR(rcpath, "fputc");
3273                                 prefs_file_close_revert(pfile);
3274                                 return;
3275                         }
3276                 }
3277         }
3278
3279         if (prefs_file_close(pfile) < 0)
3280                 g_warning("failed to write configuration to file\n");
3281 }
3282 #undef WRITE_PARAM
3283
3284 static gboolean free_privacy_prefs(gpointer key, gpointer value, gpointer user_data)
3285 {
3286         g_free(key);
3287         g_free(value);
3288
3289         return TRUE;
3290 }
3291
3292 void prefs_account_free(PrefsAccount *ac_prefs)
3293 {
3294         if (!ac_prefs) return;
3295
3296         g_hash_table_foreach_remove(ac_prefs->privacy_prefs, free_privacy_prefs, NULL);
3297
3298         tmp_ac_prefs = *ac_prefs;
3299         prefs_free(basic_param);
3300         prefs_free(receive_param);
3301         prefs_free(send_param);
3302         prefs_free(compose_param);
3303         prefs_free(templates_param);
3304         prefs_free(privacy_param);
3305         prefs_free(ssl_param);
3306         prefs_free(advanced_param);
3307 }
3308
3309 const gchar *prefs_account_get_privacy_prefs(PrefsAccount *account, gchar *id)
3310 {
3311         return g_hash_table_lookup(account->privacy_prefs, id);
3312 }
3313
3314 void prefs_account_set_privacy_prefs(PrefsAccount *account, gchar *id, gchar *new_value)
3315 {
3316         gchar *orig_key = NULL, *value;
3317
3318         if (g_hash_table_lookup_extended(account->privacy_prefs, id, (gpointer *)(gchar *) &orig_key, (gpointer *)(gchar *) &value)) {
3319                 g_hash_table_remove(account->privacy_prefs, id);
3320
3321                 g_free(orig_key);
3322                 g_free(value);
3323         }
3324
3325         if (new_value != NULL)
3326                 g_hash_table_insert(account->privacy_prefs, g_strdup(id), g_strdup(new_value));
3327 }
3328
3329 static gint prefs_account_get_new_id(void)
3330 {
3331         GList *ac_list;
3332         PrefsAccount *ac;
3333         static gint last_id = 0;
3334
3335         for (ac_list = account_get_list(); ac_list != NULL;
3336              ac_list = ac_list->next) {
3337                 ac = (PrefsAccount *)ac_list->data;
3338                 if (last_id < ac->account_id)
3339                         last_id = ac->account_id;
3340         }
3341
3342         return last_id + 1;
3343 }
3344
3345 static void destroy_dialog(gpointer data)
3346 {
3347         PrefsAccount *ac_prefs = (PrefsAccount *) data;
3348         if (!cancelled) {
3349                 gboolean update_fld_list = FALSE;
3350                 if (ac_prefs->protocol == A_IMAP4 && !new_account) {
3351                         if ((&tmp_ac_prefs)->imap_subsonly != ac_prefs->imap_subsonly) {
3352                                 update_fld_list = TRUE;
3353                         } 
3354                 }
3355                 *ac_prefs = tmp_ac_prefs;
3356                 if (update_fld_list)
3357                         folderview_rescan_tree(ac_prefs->folder, FALSE);
3358         } else /* the customhdr_list may have changed, update it anyway */
3359                 ac_prefs->customhdr_list = (&tmp_ac_prefs)->customhdr_list;
3360
3361         
3362         gtk_main_quit();
3363 }
3364
3365 PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs, gboolean *dirty)
3366 {
3367         gchar *title;
3368
3369         if (prefs_rc_is_readonly(ACCOUNT_RC))
3370                 return ac_prefs;
3371
3372         debug_print("Opening account preferences window...\n");
3373
3374         inc_lock();
3375
3376         cancelled = TRUE;
3377
3378         if (!ac_prefs) {
3379                 ac_prefs = prefs_account_new();
3380                 new_account = TRUE;
3381         } else
3382                 new_account = FALSE;
3383
3384         if (new_account)
3385                 title = g_strdup (_("Preferences for new account"));
3386         else
3387                 title = g_strdup_printf (_("%s - Account preferences"),
3388                                 ac_prefs->account_name);
3389
3390         prefswindow_open_full(title, prefs_pages, ac_prefs, destroy_dialog,
3391                         &prefs_common.editaccountwin_width, &prefs_common.editaccountwin_height,
3392                         TRUE, TRUE);
3393         g_free(title);
3394         gtk_main();
3395
3396         inc_unlock();
3397
3398         if (!cancelled && dirty != NULL)
3399                 *dirty = TRUE;
3400         if (cancelled && new_account) {
3401                 prefs_account_free(ac_prefs);
3402                 return NULL;
3403         } else 
3404                 return ac_prefs;
3405 }
3406
3407 static void crosspost_color_toggled(void)
3408 {
3409         gboolean is_active;
3410
3411         is_active = gtk_toggle_button_get_active
3412                 (GTK_TOGGLE_BUTTON(advanced_page.crosspost_checkbtn));
3413         gtk_widget_set_sensitive(advanced_page.crosspost_colormenu, is_active);
3414 }
3415
3416 static void prefs_account_crosspost_set_data_from_colormenu(PrefParam *pparam)
3417 {
3418         GtkWidget *menu;
3419         GtkWidget *menuitem;
3420
3421         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(advanced_page.crosspost_colormenu));
3422         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3423         *((gint *)pparam->data) = GPOINTER_TO_INT
3424                 (g_object_get_data(G_OBJECT(menuitem), "color"));
3425 }
3426
3427 static void prefs_account_crosspost_set_colormenu(PrefParam *pparam)
3428 {
3429         gint colorlabel = *((gint *)pparam->data);
3430         GtkOptionMenu *colormenu = GTK_OPTION_MENU(*pparam->widget);
3431         GtkWidget *menu;
3432         GtkWidget *menuitem;
3433
3434         gtk_option_menu_set_history(colormenu, colorlabel);
3435         menu = gtk_option_menu_get_menu(colormenu);
3436         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3437         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3438 }
3439
3440 static void pop_bfr_smtp_tm_set_sens(GtkWidget *widget, gpointer data)
3441 {
3442         gtk_widget_set_sensitive(send_page.pop_bfr_smtp_tm_entry, 
3443                                  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn)));
3444         gtk_widget_set_sensitive(send_page.pop_auth_timeout_lbl, 
3445                                  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn)));
3446         gtk_widget_set_sensitive(send_page.pop_auth_minutes_lbl, 
3447                                  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn)));
3448 }
3449
3450 static void prefs_account_select_folder_cb(GtkWidget *widget, gpointer data)
3451 {
3452         FolderItem *item;
3453         gchar *id;
3454
3455         item = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
3456         if (item && item->path) {
3457                 id = folder_item_get_identifier(item);
3458                 if (id) {
3459                         gtk_entry_set_text(GTK_ENTRY(data), id);
3460                         g_free(id);
3461                 }
3462         }
3463 }
3464
3465 static void prefs_account_sigfile_radiobtn_cb(GtkWidget *widget, gpointer data)
3466 {
3467         gtk_widget_set_sensitive(GTK_WIDGET(signature_browse_button), TRUE);
3468         gtk_widget_set_sensitive(GTK_WIDGET(signature_edit_button), TRUE);
3469 }
3470
3471 static void prefs_account_sigcmd_radiobtn_cb(GtkWidget *widget, gpointer data)
3472 {
3473         gtk_widget_set_sensitive(GTK_WIDGET(signature_browse_button), FALSE);
3474         gtk_widget_set_sensitive(GTK_WIDGET(signature_edit_button), FALSE);
3475 }
3476
3477 static void prefs_account_signature_browse_cb(GtkWidget *widget, gpointer data)
3478 {
3479         gchar *filename;
3480         gchar *utf8_filename;
3481
3482         filename = filesel_select_file_open(_("Select signature file"), NULL);
3483         if (!filename) return;
3484
3485         utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
3486         if (!utf8_filename) {
3487                 g_warning("prefs_account_signature_browse_cb(): failed to convert character set.");
3488                 utf8_filename = g_strdup(filename);
3489         }
3490         gtk_entry_set_text(GTK_ENTRY(entry_sigpath), utf8_filename);
3491         g_free(utf8_filename);
3492 }
3493
3494 static void prefs_account_signature_edit_cb(GtkWidget *widget, gpointer data)
3495 {
3496         const gchar *sigpath = gtk_entry_get_text(GTK_ENTRY(data));
3497         if (!is_file_exist(sigpath))
3498                 str_write_to_file(sigpath, "");
3499         open_txt_editor(sigpath, prefs_common_get_ext_editor_cmd());
3500 }
3501
3502 static void prefs_account_edit_custom_header(void)
3503 {
3504         prefs_custom_header_open(&tmp_ac_prefs);
3505 }
3506
3507 static void prefs_account_enum_set_data_from_radiobtn(PrefParam *pparam)
3508 {
3509         GtkRadioButton *radiobtn;
3510         GSList *group;
3511
3512         radiobtn = GTK_RADIO_BUTTON (*pparam->widget);
3513         group = gtk_radio_button_get_group (radiobtn);
3514         while (group != NULL) {
3515                 GtkToggleButton *btn = GTK_TOGGLE_BUTTON (group->data);
3516                 if (gtk_toggle_button_get_active (btn)) {
3517                         *((gint *)pparam->data) = GPOINTER_TO_INT
3518                                 (g_object_get_data (G_OBJECT (btn), MENU_VAL_ID));
3519                         break;
3520                 }
3521                 group = group->next;
3522         }
3523 }
3524
3525 static void prefs_account_enum_set_radiobtn(PrefParam *pparam)
3526 {
3527         GtkRadioButton *radiobtn;
3528         GSList *group;
3529         gpointer data;
3530
3531         data = GINT_TO_POINTER (*((gint *)pparam->data));
3532         radiobtn = GTK_RADIO_BUTTON (*pparam->widget);
3533         group = gtk_radio_button_get_group (radiobtn);
3534         while (group != NULL) {
3535                 GtkToggleButton *btn = GTK_TOGGLE_BUTTON (group->data);
3536                 gpointer data1 = g_object_get_data (G_OBJECT (btn), MENU_VAL_ID);
3537                 if (data1 == data) {
3538                         gtk_toggle_button_set_active (btn, TRUE);
3539                         break;
3540                 }
3541                 group = group->next;
3542         }
3543 }
3544
3545 static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam)
3546 {
3547         struct BasicProtocol *protocol_optmenu =
3548                 (struct BasicProtocol *)*pparam->widget;
3549         GtkWidget *optmenu = protocol_optmenu->combobox;
3550
3551         *((RecvProtocol *)pparam->data) =
3552                 combobox_get_active_data(GTK_COMBO_BOX(optmenu));
3553 }
3554
3555 static void prefs_account_protocol_set_optmenu(PrefParam *pparam)
3556 {
3557         RecvProtocol protocol;
3558         struct BasicProtocol *protocol_optmenu =
3559                 (struct BasicProtocol *)*pparam->widget;
3560         GtkWidget *optmenu = protocol_optmenu->combobox;
3561         GtkWidget *optlabel = protocol_optmenu->label;
3562         GtkWidget *descrlabel = protocol_optmenu->descrlabel;
3563         gchar *label = NULL;
3564
3565         protocol = *((RecvProtocol *)pparam->data);
3566
3567         /* Set combobox to correct value even if it will be hidden, so
3568          * we won't break existing accounts when saving. */
3569         combobox_select_by_data(GTK_COMBO_BOX(optmenu), protocol);
3570
3571         /* Set up widgets accordingly */
3572         if( new_account ) {
3573                 gtk_label_set_text(GTK_LABEL(descrlabel), _("Protocol"));
3574                 gtk_widget_hide(optlabel);
3575                 gtk_widget_show(optmenu);
3576         } else {
3577                 gtk_label_set_text(GTK_LABEL(descrlabel), _("Protocol:"));
3578                 label = g_markup_printf_escaped("<b>%s</b>", protocol_names[protocol]);
3579                 gtk_label_set_markup(GTK_LABEL(optlabel), label);
3580                 g_free(label);
3581                 gtk_widget_hide(optmenu);
3582                 gtk_widget_show(optlabel);
3583 #ifndef HAVE_LIBETPAN
3584                 if (protocol == A_IMAP4 || protocol == A_NNTP) {
3585                         gtk_widget_show(protocol_optmenu->no_imap_warn_icon);
3586                         gtk_widget_show(protocol_optmenu->no_imap_warn_label);
3587                 } else {
3588                         gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
3589                         gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
3590                 }
3591 #endif
3592                 if (protocol == A_IMAP4) {
3593                         if (new_account)
3594                                 gtk_toggle_button_set_active(
3595                                         GTK_TOGGLE_BUTTON(send_page.msgid_checkbtn), 
3596                                         TRUE);
3597                         gtk_widget_hide(send_page.msgid_checkbtn);
3598                 } else {
3599                         gtk_widget_show(send_page.msgid_checkbtn);
3600                 }
3601         }
3602 }
3603
3604 static void prefs_account_imap_auth_type_set_data_from_optmenu(PrefParam *pparam)
3605 {
3606         *((RecvProtocol *)pparam->data) =
3607                         combobox_get_active_data(GTK_COMBO_BOX(*pparam->widget));
3608 }
3609
3610 static void prefs_account_imap_auth_type_set_optmenu(PrefParam *pparam)
3611 {
3612         IMAPAuthType type = *((IMAPAuthType *)pparam->data);
3613         GtkComboBox *optmenu = GTK_COMBO_BOX(*pparam->widget);
3614
3615         combobox_select_by_data(optmenu, type);
3616 }
3617
3618 static void prefs_account_smtp_auth_type_set_data_from_optmenu(PrefParam *pparam)
3619 {
3620         *((RecvProtocol *)pparam->data) =
3621                 combobox_get_active_data(GTK_COMBO_BOX(*pparam->widget));
3622 }
3623
3624 static void prefs_account_smtp_auth_type_set_optmenu(PrefParam *pparam)
3625 {
3626         SMTPAuthType type = *((SMTPAuthType *)pparam->data);
3627         GtkComboBox *optmenu = GTK_COMBO_BOX(*pparam->widget);
3628
3629         combobox_select_by_data(optmenu, type);
3630 }
3631
3632 static void prefs_account_set_string_from_combobox(PrefParam *pparam)
3633 {
3634         GtkWidget *combobox;
3635         GtkListStore *menu;
3636         GtkTreeIter iter;
3637         gchar **str;
3638
3639         g_return_if_fail(*pparam->widget != NULL);
3640
3641         combobox = *pparam->widget;
3642         g_return_if_fail(gtk_combo_box_get_active_iter(
3643                                 GTK_COMBO_BOX(combobox), &iter));
3644
3645         str = (gchar **)pparam->data;
3646         g_free(*str);
3647         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combobox)));
3648         gtk_tree_model_get(GTK_TREE_MODEL(menu), &iter,
3649                         COMBOBOX_PRIVACY_PLUGIN_ID, &(*str),
3650                         -1);
3651 }
3652
3653 /* Context struct and internal function called by gtk_tree_model_foreach().
3654  * This is used in prefs_account_set_privacy_combobox_from_string() to find
3655  * correct combobox entry to activate when account preferences are displayed
3656  * and their values are set according to preferences. */
3657 typedef struct _privacy_system_set_ctx {
3658         GtkWidget *combobox;
3659         gchar *prefsid;
3660         gboolean found;
3661 } PrivacySystemSetCtx;
3662
3663 static gboolean _privacy_system_set_func(GtkTreeModel *model, GtkTreePath *path,
3664                 GtkTreeIter *iter, PrivacySystemSetCtx *ctx)
3665 {
3666         GtkWidget *combobox = ctx->combobox;
3667         gchar *prefsid = ctx->prefsid;
3668         gchar *curid;
3669
3670         /* We're searching for correct privacy plugin ID. */
3671         gtk_tree_model_get(model, iter, COMBOBOX_PRIVACY_PLUGIN_ID, &curid, -1);
3672         if( strcmp(prefsid, curid) == 0 ) {
3673                 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combobox), iter);
3674                 g_free(curid);
3675                 ctx->found = TRUE;
3676                 return TRUE;
3677         }
3678
3679         g_free(curid);
3680         return FALSE;
3681 }
3682
3683 static void prefs_account_set_privacy_combobox_from_string(PrefParam *pparam)
3684 {
3685         GtkWidget *optionmenu;
3686         GtkListStore *menu;
3687         GtkTreeIter iter;
3688         gboolean found = FALSE;
3689         gchar *prefsid;
3690         PrivacySystemSetCtx *ctx = NULL;
3691
3692         g_return_if_fail(*pparam->widget != NULL);
3693
3694         prefsid = *((gchar **) pparam->data);
3695         if (prefsid == NULL)
3696                 return;
3697
3698         optionmenu = *pparam->widget;
3699         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optionmenu)));
3700
3701         ctx = g_new(PrivacySystemSetCtx, sizeof(PrivacySystemSetCtx));
3702         ctx->combobox = optionmenu;
3703         ctx->prefsid = prefsid;
3704         ctx->found = FALSE;
3705
3706         gtk_tree_model_foreach(GTK_TREE_MODEL(menu),
3707                         (GtkTreeModelForeachFunc)_privacy_system_set_func, ctx);
3708         found = ctx->found;
3709         g_free(ctx);
3710
3711         /* If chosen privacy system is not available, add a dummy entry with
3712          * "not loaded" note and make it active. */
3713         if (!found) {
3714                 gchar *name;
3715
3716                 name = g_strdup_printf(_("%s (plugin not loaded)"), prefsid);
3717                 gtk_list_store_append(menu, &iter);
3718                 gtk_list_store_set(menu, &iter,
3719                                 COMBOBOX_TEXT, name,
3720                                 COMBOBOX_DATA, 0,
3721                                 COMBOBOX_SENS, TRUE,
3722                                 COMBOBOX_PRIVACY_PLUGIN_ID, prefsid,
3723                                 -1);
3724                 g_free(name);
3725
3726                 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(optionmenu), &iter);
3727         }
3728 }
3729
3730 static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data)
3731 {
3732         RecvProtocol protocol;
3733         struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *)basic_page.protocol_optmenu;
3734
3735         protocol = combobox_get_active_data(combobox);
3736
3737         gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
3738         gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
3739         switch(protocol) {
3740         case A_NNTP:
3741 #ifndef HAVE_LIBETPAN
3742                 gtk_widget_show(protocol_optmenu->no_imap_warn_icon);
3743                 gtk_widget_show(protocol_optmenu->no_imap_warn_label);
3744 #else
3745                 gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
3746                 gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
3747 #endif
3748                 gtk_widget_show(send_page.msgid_checkbtn);
3749                 gtk_widget_show(basic_page.nntpserv_label);
3750                 gtk_widget_show(basic_page.nntpserv_entry);
3751                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3752                                            0, VSPACING_NARROW);
3753
3754                 gtk_widget_set_sensitive(basic_page.nntpauth_checkbtn, TRUE);
3755                 gtk_widget_show(basic_page.nntpauth_checkbtn);
3756
3757                 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, TRUE);
3758                 gtk_widget_show(basic_page.nntpauth_onconnect_checkbtn);
3759
3760                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3761                                            1, VSPACING_NARROW);
3762                 gtk_widget_hide(basic_page.recvserv_label);
3763                 gtk_widget_hide(basic_page.recvserv_entry);
3764                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3765                                            2, 0);
3766                 gtk_widget_show(basic_page.smtpserv_label);
3767                 gtk_widget_show(basic_page.smtpserv_entry);
3768                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3769                                            4, VSPACING_NARROW);
3770                 gtk_widget_hide(basic_page.localmbox_label);
3771                 gtk_widget_hide(basic_page.localmbox_entry);
3772                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3773                                            3, 0);
3774                 gtk_widget_hide(basic_page.mailcmd_label);
3775                 gtk_widget_hide(basic_page.mailcmd_entry);
3776                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3777                                            6, 0);
3778                 gtk_widget_hide(basic_page.mailcmd_checkbtn);
3779                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3780                                            5, 0);
3781                 gtk_widget_show(basic_page.uid_label);
3782                 gtk_widget_show(basic_page.pass_label);
3783                 gtk_widget_show(basic_page.uid_entry);
3784                 gtk_widget_show(basic_page.pass_entry);
3785                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3786                                            7, VSPACING_NARROW);
3787
3788                 gtk_widget_set_sensitive(basic_page.uid_label,  TRUE);
3789                 gtk_widget_set_sensitive(basic_page.pass_label, TRUE);
3790                 gtk_widget_set_sensitive(basic_page.uid_entry,  TRUE);
3791                 gtk_widget_set_sensitive(basic_page.pass_entry, TRUE);
3792
3793                 /* update userid/passwd sensitive state */
3794
3795                 prefs_account_nntpauth_toggled
3796                         (GTK_TOGGLE_BUTTON(basic_page.nntpauth_checkbtn), NULL);
3797                 gtk_widget_hide(receive_page.pop3_frame);
3798                 gtk_widget_hide(receive_page.imap_frame);
3799                 gtk_widget_hide(receive_page.local_frame);
3800                 gtk_widget_show(receive_page.frame_maxarticle);
3801                 gtk_widget_set_sensitive(receive_page.filter_on_recv_checkbtn, TRUE);
3802                 prefs_account_filter_on_recv_toggled
3803                         (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), NULL);
3804                 gtk_widget_set_sensitive(receive_page.recvatgetall_checkbtn, TRUE);
3805                 /* update pop_before_smtp sensitivity */
3806                 gtk_toggle_button_set_active
3807                         (GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn), FALSE);
3808                 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_checkbtn, FALSE);
3809                 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_tm_entry, FALSE);
3810                 
3811                 if (!tmp_ac_prefs.account_name) {
3812                         gtk_toggle_button_set_active
3813                                 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), 
3814                                 TRUE);
3815                         gtk_toggle_button_set_active
3816                                 (GTK_TOGGLE_BUTTON(receive_page.filterhook_on_recv_checkbtn), 
3817                                 TRUE);
3818                         gtk_toggle_button_set_active
3819                                 (GTK_TOGGLE_BUTTON(receive_page.recvatgetall_checkbtn),
3820                                  FALSE);
3821                 }
3822
3823 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
3824                 gtk_widget_hide(ssl_page.pop_frame);
3825                 gtk_widget_hide(ssl_page.imap_frame);
3826                 gtk_widget_show(ssl_page.nntp_frame);
3827                 gtk_widget_show(ssl_page.send_frame);
3828 #endif
3829                 gtk_widget_hide(advanced_page.popport_hbox);
3830                 gtk_widget_hide(advanced_page.imapport_hbox);
3831                 gtk_widget_show(advanced_page.nntpport_hbox);
3832                 gtk_widget_show(advanced_page.crosspost_checkbtn);
3833                 gtk_widget_show(advanced_page.crosspost_colormenu);
3834 #ifndef G_OS_WIN32
3835                 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
3836                 gtk_widget_hide(advanced_page.tunnelcmd_entry);
3837 #endif
3838                 gtk_widget_hide(receive_page.imapdir_label);
3839                 gtk_widget_hide(receive_page.imapdir_entry);
3840                 gtk_widget_hide(receive_page.subsonly_checkbtn);
3841                 gtk_widget_hide(receive_page.low_bandwidth_checkbtn);
3842                 break;
3843         case A_LOCAL:
3844                 gtk_widget_show(send_page.msgid_checkbtn);
3845                 gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
3846                 gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
3847                 gtk_widget_hide(basic_page.nntpserv_label);
3848                 gtk_widget_hide(basic_page.nntpserv_entry);
3849                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3850                                            0, 0);
3851                 gtk_widget_set_sensitive(basic_page.nntpauth_checkbtn, FALSE);
3852                 gtk_widget_hide(basic_page.nntpauth_checkbtn);
3853
3854                 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, FALSE);
3855                 gtk_widget_hide(basic_page.nntpauth_onconnect_checkbtn);
3856                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3857                                            1, 0);
3858                 gtk_widget_hide(basic_page.recvserv_label);
3859                 gtk_widget_hide(basic_page.recvserv_entry);
3860                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3861                                            2, 0);
3862                 gtk_widget_show(basic_page.smtpserv_label);
3863                 gtk_widget_show(basic_page.smtpserv_entry);
3864                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3865                                            4, VSPACING_NARROW);
3866                 gtk_widget_show(basic_page.localmbox_label);
3867                 gtk_widget_show(basic_page.localmbox_entry);
3868                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3869                                            3, VSPACING_NARROW);
3870                 gtk_widget_show(basic_page.mailcmd_label);
3871                 gtk_widget_show(basic_page.mailcmd_entry);
3872                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3873                                            6, VSPACING_NARROW);
3874                 gtk_widget_show(basic_page.mailcmd_checkbtn);
3875                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3876                                            5, VSPACING_NARROW);
3877                 gtk_widget_hide(basic_page.uid_label);
3878                 gtk_widget_hide(basic_page.pass_label);
3879                 gtk_widget_hide(basic_page.uid_entry);
3880                 gtk_widget_hide(basic_page.pass_entry);
3881                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3882                                            7, 0);
3883
3884                 gtk_widget_set_sensitive(basic_page.uid_label,  TRUE);
3885                 gtk_widget_set_sensitive(basic_page.pass_label, TRUE);
3886                 gtk_widget_set_sensitive(basic_page.uid_entry,  TRUE);
3887                 gtk_widget_set_sensitive(basic_page.pass_entry, TRUE);
3888                 gtk_widget_hide(receive_page.pop3_frame);
3889                 gtk_widget_hide(receive_page.imap_frame);
3890                 gtk_widget_show(receive_page.local_frame);
3891                 gtk_widget_hide(receive_page.frame_maxarticle);
3892                 gtk_widget_set_sensitive(receive_page.filter_on_recv_checkbtn, TRUE);
3893                 prefs_account_filter_on_recv_toggled
3894                         (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), NULL);
3895                 gtk_widget_set_sensitive(receive_page.recvatgetall_checkbtn, TRUE);
3896                 prefs_account_mailcmd_toggled
3897                         (GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn), NULL);
3898
3899                 /* update pop_before_smtp sensitivity */
3900                 gtk_toggle_button_set_active
3901                         (GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn), FALSE);
3902                 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_checkbtn, FALSE);
3903                 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_tm_entry, FALSE);
3904
3905                 if (!tmp_ac_prefs.account_name) {
3906                         gtk_toggle_button_set_active
3907                                 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), 
3908                                 TRUE);
3909                         gtk_toggle_button_set_active
3910                                 (GTK_TOGGLE_BUTTON(receive_page.filterhook_on_recv_checkbtn), 
3911                                 TRUE);
3912                         gtk_toggle_button_set_active
3913                                 (GTK_TOGGLE_BUTTON(receive_page.recvatgetall_checkbtn),
3914                                  TRUE);
3915                 }
3916
3917 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
3918                 gtk_widget_hide(ssl_page.pop_frame);
3919                 gtk_widget_hide(ssl_page.imap_frame);
3920                 gtk_widget_hide(ssl_page.nntp_frame);
3921                 gtk_widget_show(ssl_page.send_frame);
3922 #endif
3923                 gtk_widget_hide(advanced_page.popport_hbox);
3924                 gtk_widget_hide(advanced_page.imapport_hbox);
3925                 gtk_widget_hide(advanced_page.nntpport_hbox);
3926                 gtk_widget_hide(advanced_page.crosspost_checkbtn);
3927                 gtk_widget_hide(advanced_page.crosspost_colormenu);
3928 #ifndef G_OS_WIN32
3929                 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn);
3930                 gtk_widget_hide(advanced_page.tunnelcmd_entry);
3931 #endif
3932                 gtk_widget_hide(receive_page.imapdir_label);
3933                 gtk_widget_hide(receive_page.imapdir_entry);
3934                 gtk_widget_hide(receive_page.subsonly_checkbtn);
3935                 gtk_widget_hide(receive_page.low_bandwidth_checkbtn);
3936                 break;
3937         case A_IMAP4:
3938 #ifndef HAVE_LIBETPAN
3939                 gtk_widget_show(protocol_optmenu->no_imap_warn_icon);
3940                 gtk_widget_show(protocol_optmenu->no_imap_warn_label);
3941 #endif
3942                 if (new_account)
3943                         gtk_toggle_button_set_active(
3944                                 GTK_TOGGLE_BUTTON(send_page.msgid_checkbtn), 
3945                                 TRUE);
3946                 gtk_widget_hide(send_page.msgid_checkbtn);
3947                 gtk_widget_hide(basic_page.nntpserv_label);
3948                 gtk_widget_hide(basic_page.nntpserv_entry);
3949                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3950                                            0, 0);
3951                 gtk_widget_set_sensitive(basic_page.nntpauth_checkbtn, FALSE);
3952                 gtk_widget_hide(basic_page.nntpauth_checkbtn);
3953
3954                 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, FALSE);
3955                 gtk_widget_hide(basic_page.nntpauth_onconnect_checkbtn);
3956
3957                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3958                                            1, 0);
3959                 gtk_widget_set_sensitive(basic_page.recvserv_label, TRUE);
3960                 gtk_widget_set_sensitive(basic_page.recvserv_entry, TRUE);
3961                 gtk_widget_show(basic_page.recvserv_label);
3962                 gtk_widget_show(basic_page.recvserv_entry);
3963                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3964                                            2, VSPACING_NARROW);
3965                 gtk_widget_show(basic_page.smtpserv_label);
3966                 gtk_widget_show(basic_page.smtpserv_entry);
3967                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3968                                            4, VSPACING_NARROW);
3969                 gtk_widget_hide(basic_page.localmbox_label);
3970                 gtk_widget_hide(basic_page.localmbox_entry);
3971                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3972                                            3, 0);
3973                 gtk_widget_hide(basic_page.mailcmd_label);
3974                 gtk_widget_hide(basic_page.mailcmd_entry);
3975                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3976                                            6, 0);
3977                 gtk_widget_hide(basic_page.mailcmd_checkbtn);
3978                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3979                                            5, 0);
3980                 gtk_widget_show(basic_page.uid_label);
3981                 gtk_widget_show(basic_page.pass_label);
3982                 gtk_widget_show(basic_page.uid_entry);
3983                 gtk_widget_show(basic_page.pass_entry);
3984                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
3985                                            7, VSPACING_NARROW);
3986
3987                 gtk_widget_set_sensitive(basic_page.uid_label,  TRUE);
3988                 gtk_widget_set_sensitive(basic_page.pass_label, TRUE);
3989                 gtk_widget_set_sensitive(basic_page.uid_entry,  TRUE);
3990                 gtk_widget_set_sensitive(basic_page.pass_entry, TRUE);
3991                 gtk_widget_hide(receive_page.pop3_frame);
3992                 gtk_widget_show(receive_page.imap_frame);
3993                 gtk_widget_hide(receive_page.local_frame);
3994                 gtk_widget_hide(receive_page.frame_maxarticle);
3995                 gtk_widget_set_sensitive(receive_page.filter_on_recv_checkbtn, TRUE);
3996                 prefs_account_filter_on_recv_toggled
3997                         (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), NULL);
3998                 gtk_widget_set_sensitive(receive_page.recvatgetall_checkbtn, TRUE);
3999                 gtk_widget_set_sensitive(basic_page.smtpserv_entry, TRUE);
4000                 gtk_widget_set_sensitive(basic_page.smtpserv_label, TRUE);
4001
4002                 /* update pop_before_smtp sensitivity */
4003                 gtk_toggle_button_set_active
4004                         (GTK_TOGGLE_BUTTON(send_page.pop_bfr_smtp_checkbtn), FALSE);
4005                 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_checkbtn, FALSE);
4006                 gtk_widget_set_sensitive(send_page.pop_bfr_smtp_tm_entry, FALSE);
4007
4008                 if (!tmp_ac_prefs.account_name) {
4009                         gtk_toggle_button_set_active
4010                                 (GTK_TOGGLE_BUTTON(receive_page.filter_on_recv_checkbtn), 
4011                                 TRUE);
4012                         gtk_toggle_button_set_active
4013                                 (GTK_TOGGLE_BUTTON(receive_page.filterhook_on_recv_checkbtn), 
4014                                 TRUE);
4015                         gtk_toggle_button_set_active
4016                                 (GTK_TOGGLE_BUTTON(receive_page.recvatgetall_checkbtn),
4017                                  FALSE);
4018                 }
4019
4020 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
4021                 gtk_widget_hide(ssl_page.pop_frame);
4022                 gtk_widget_show(ssl_page.imap_frame);
4023                 gtk_widget_hide(ssl_page.nntp_frame);
4024                 gtk_widget_show(ssl_page.send_frame);
4025 #endif
4026                 gtk_widget_hide(advanced_page.popport_hbox);
4027                 gtk_widget_show(advanced_page.imapport_hbox);
4028                 gtk_widget_hide(advanced_page.nntpport_hbox);
4029                 gtk_widget_hide(advanced_page.crosspost_checkbtn);
4030                 gtk_widget_hide(advanced_page.crosspost_colormenu);
4031 #ifndef G_OS_WIN32
4032                 gtk_widget_show(advanced_page.tunnelcmd_checkbtn);
4033                 gtk_widget_show(advanced_page.tunnelcmd_entry);
4034 #endif
4035                 gtk_widget_show(receive_page.imapdir_label);
4036                 gtk_widget_show(receive_page.imapdir_entry);
4037                 gtk_widget_show(receive_page.subsonly_checkbtn);
4038                 gtk_widget_show(receive_page.low_bandwidth_checkbtn);
4039                 break;
4040         case A_NONE:
4041                 gtk_widget_show(send_page.msgid_checkbtn);
4042                 gtk_widget_hide(protocol_optmenu->no_imap_warn_icon);
4043                 gtk_widget_hide(protocol_optmenu->no_imap_warn_label);
4044                 gtk_widget_hide(basic_page.nntpserv_label);
4045                 gtk_widget_hide(basic_page.nntpserv_entry);
4046                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
4047                                            0, 0);
4048                 gtk_widget_set_sensitive(basic_page.nntpauth_checkbtn, FALSE);
4049                 gtk_widget_hide(basic_page.nntpauth_checkbtn);
4050
4051                 gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, FALSE);
4052                 gtk_widget_hide(basic_page.nntpauth_onconnect_checkbtn);
4053
4054                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
4055                                            1, 0);
4056                 gtk_widget_set_sensitive(basic_page.recvserv_label, FALSE);
4057                 gtk_widget_set_sensitive(basic_page.recvserv_entry, FALSE);
4058                 gtk_widget_hide(basic_page.recvserv_label);
4059                 gtk_widget_hide(basic_page.recvserv_entry);
4060                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
4061                                            2, VSPACING_NARROW);
4062                 gtk_widget_show(basic_page.smtpserv_label);
4063                 gtk_widget_show(basic_page.smtpserv_entry);
4064                 gtk_table_set_row_spacing (GTK_TABLE (basic_page.serv_table),
4065                                            4, VSPACING_NARROW);
4066                 gtk_widget_hide(basic_page.localmbox_label);
4067                 gtk_widget_hide(basic_page.localmbox_entry);