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