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