2004-11-12 [paul] 0.9.12cvs146.1
[claws.git] / src / prefs_account.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2003 Hiroyuki Yamamoto
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <gtk/gtk.h>
27 #include <gdk/gdkkeysyms.h>
28 #include <stdio.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <string.h>
32 #include <stdlib.h>
33 #include <ctype.h>
34
35 #include "intl.h"
36 #include "main.h"
37 #include "prefs_gtk.h"
38 #include "prefs_account.h"
39 #include "prefs_customheader.h"
40 #include "account.h"
41 #include "mainwindow.h"
42 #include "manage_window.h"
43 #include "foldersel.h"
44 #include "inc.h"
45 #include "menu.h"
46 #include "gtkutils.h"
47 #include "utils.h"
48 #include "alertpanel.h"
49 #include "colorlabel.h"
50 #include "smtp.h"
51 #include "imap.h"
52 #include "remotefolder.h"
53
54 static gboolean cancelled;
55
56 static PrefsAccount tmp_ac_prefs;
57
58 static PrefsDialog dialog;
59
60 static struct Basic {
61         GtkWidget *acname_entry;
62         GtkWidget *default_chkbtn;
63
64         GtkWidget *name_entry;
65         GtkWidget *addr_entry;
66         GtkWidget *org_entry;
67
68         GtkWidget *serv_frame;
69         GtkWidget *serv_table;
70         GtkWidget *protocol_optmenu;
71         GtkWidget *recvserv_label;
72         GtkWidget *smtpserv_label;
73         GtkWidget *nntpserv_label;
74         GtkWidget *localmbox_label;
75         GtkWidget *mailcmd_label;
76         GtkWidget *recvserv_entry;
77         GtkWidget *smtpserv_entry;
78         GtkWidget *nntpserv_entry;
79         GtkWidget *nntpauth_chkbtn;
80         GtkWidget *nntpauth_onconnect_chkbtn;
81         GtkWidget *localmbox_entry;
82         GtkWidget *mailcmd_chkbtn;
83         GtkWidget *mailcmd_entry;
84         GtkWidget *uid_label;
85         GtkWidget *pass_label;
86         GtkWidget *uid_entry;
87         GtkWidget *pass_entry;
88 } basic;
89
90 static struct Receive {
91         GtkWidget *pop3_frame;
92         GtkWidget *use_apop_chkbtn;
93         GtkWidget *rmmail_chkbtn;
94         GtkWidget *leave_time_entry;
95         GtkWidget *getall_chkbtn;
96         GtkWidget *size_limit_chkbtn;
97         GtkWidget *size_limit_entry;
98         GtkWidget *inbox_label;
99         GtkWidget *inbox_entry;
100         GtkWidget *inbox_btn;
101
102         GtkWidget *filter_on_recv_chkbtn;
103         GtkWidget *recvatgetall_chkbtn;
104         
105         GtkWidget *imap_frame;
106         GtkWidget *imap_auth_type_optmenu;
107
108         GtkWidget *frame_maxarticle;
109         GtkWidget *label_maxarticle;
110         GtkWidget *spinbtn_maxarticle;
111         GtkObject *spinbtn_maxarticle_adj;
112 } receive;
113
114 static struct Send {
115         GtkWidget *date_chkbtn;
116         GtkWidget *msgid_chkbtn;
117         GtkWidget *customhdr_chkbtn;
118         GtkWidget *smtp_auth_chkbtn;
119         GtkWidget *smtp_auth_type_optmenu;
120         GtkWidget *smtp_uid_entry;
121         GtkWidget *smtp_pass_entry;
122         GtkWidget *pop_bfr_smtp_chkbtn;
123         GtkWidget *pop_bfr_smtp_tm_entry;
124 } p_send;
125
126 static struct Compose {
127         GtkWidget *sigfile_radiobtn;
128         GtkWidget *entry_sigpath;
129         GtkWidget *checkbtn_autosig;
130         GtkWidget *entry_sigsep;
131         GtkWidget *autocc_chkbtn;
132         GtkWidget *autocc_entry;
133         GtkWidget *autobcc_chkbtn;
134         GtkWidget *autobcc_entry;
135         GtkWidget *autoreplyto_chkbtn;
136         GtkWidget *autoreplyto_entry;
137 } compose;
138
139 static struct Privacy {
140         GtkWidget *default_privacy_system;
141         GtkWidget *default_encrypt_chkbtn;
142         GtkWidget *default_sign_chkbtn;
143 } privacy;
144
145 #if USE_OPENSSL
146 static struct SSLPrefs {
147         GtkWidget *pop_frame;
148         GtkWidget *pop_nossl_radiobtn;
149         GtkWidget *pop_ssltunnel_radiobtn;
150         GtkWidget *pop_starttls_radiobtn;
151
152         GtkWidget *imap_frame;
153         GtkWidget *imap_nossl_radiobtn;
154         GtkWidget *imap_ssltunnel_radiobtn;
155         GtkWidget *imap_starttls_radiobtn;
156
157         GtkWidget *nntp_frame;
158         GtkWidget *nntp_nossl_radiobtn;
159         GtkWidget *nntp_ssltunnel_radiobtn;
160
161         GtkWidget *send_frame;
162         GtkWidget *smtp_nossl_radiobtn;
163         GtkWidget *smtp_ssltunnel_radiobtn;
164         GtkWidget *smtp_starttls_radiobtn;
165
166         GtkWidget *use_nonblocking_ssl_chkbtn;
167 } ssl;
168 #endif /* USE_OPENSSL */
169
170 static struct Advanced {
171         GtkWidget *smtpport_chkbtn;
172         GtkWidget *smtpport_entry;
173         GtkWidget *popport_hbox;
174         GtkWidget *popport_chkbtn;
175         GtkWidget *popport_entry;
176         GtkWidget *imapport_hbox;
177         GtkWidget *imapport_chkbtn;
178         GtkWidget *imapport_entry;
179         GtkWidget *nntpport_hbox;
180         GtkWidget *nntpport_chkbtn;
181         GtkWidget *nntpport_entry;
182         GtkWidget *domain_chkbtn;
183         GtkWidget *domain_entry;
184         GtkWidget *crosspost_chkbtn;
185         GtkWidget *crosspost_colormenu;
186
187         GtkWidget *tunnelcmd_chkbtn;
188         GtkWidget *tunnelcmd_entry;
189         GtkWidget *imapdir_label;
190         GtkWidget *imapdir_entry;
191
192         GtkWidget *sent_folder_chkbtn;
193         GtkWidget *sent_folder_entry;
194         GtkWidget *draft_folder_chkbtn;
195         GtkWidget *draft_folder_entry;
196         GtkWidget *trash_folder_chkbtn;
197         GtkWidget *trash_folder_entry;
198 } advanced;
199
200 static void prefs_account_fix_size                      (void);
201
202 static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam);
203 static void prefs_account_protocol_set_optmenu          (PrefParam *pparam);
204 static void prefs_account_protocol_activated            (GtkMenuItem *menuitem);
205
206 static void prefs_account_set_string_from_optmenu       (PrefParam *pparam);
207 static void prefs_account_set_optmenu_from_string       (PrefParam *pparam);
208
209 static void prefs_account_imap_auth_type_set_data_from_optmenu
210                                                         (PrefParam *pparam);
211 static void prefs_account_imap_auth_type_set_optmenu    (PrefParam *pparam);
212 static void prefs_account_smtp_auth_type_set_data_from_optmenu
213                                                         (PrefParam *pparam);
214 static void prefs_account_smtp_auth_type_set_optmenu    (PrefParam *pparam);
215
216 static void prefs_account_enum_set_data_from_radiobtn   (PrefParam *pparam);
217 static void prefs_account_enum_set_radiobtn             (PrefParam *pparam);
218
219 static void prefs_account_crosspost_set_data_from_colormenu(PrefParam *pparam);
220 static void prefs_account_crosspost_set_colormenu(PrefParam *pparam);
221
222 static void prefs_account_nntpauth_toggled(GtkToggleButton *button,
223                                            gpointer user_data);
224 static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
225                                           gpointer user_data);
226
227 static PrefParam param[] = {
228         /* Basic */
229         {"account_name", NULL, &tmp_ac_prefs.account_name, P_STRING,
230          &basic.acname_entry, prefs_set_data_from_entry, prefs_set_entry},
231
232         {"is_default", "FALSE", &tmp_ac_prefs.is_default, P_BOOL,
233          &basic.default_chkbtn,
234          prefs_set_data_from_toggle, prefs_set_toggle},
235
236         {"name", NULL, &tmp_ac_prefs.name, P_STRING,
237          &basic.name_entry, prefs_set_data_from_entry, prefs_set_entry},
238
239         {"address", NULL, &tmp_ac_prefs.address, P_STRING,
240          &basic.addr_entry, prefs_set_data_from_entry, prefs_set_entry},
241
242         {"organization", NULL, &tmp_ac_prefs.organization, P_STRING,
243          &basic.org_entry, prefs_set_data_from_entry, prefs_set_entry},
244
245         {"protocol", NULL, &tmp_ac_prefs.protocol, P_ENUM,
246          &basic.protocol_optmenu,
247          prefs_account_protocol_set_data_from_optmenu,
248          prefs_account_protocol_set_optmenu},
249
250         {"receive_server", NULL, &tmp_ac_prefs.recv_server, P_STRING,
251          &basic.recvserv_entry, prefs_set_data_from_entry, prefs_set_entry},
252
253         {"smtp_server", NULL, &tmp_ac_prefs.smtp_server, P_STRING,
254          &basic.smtpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
255
256         {"nntp_server", NULL, &tmp_ac_prefs.nntp_server, P_STRING,
257          &basic.nntpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
258
259         {"local_mbox", "/var/mail", &tmp_ac_prefs.local_mbox, P_STRING,
260          &basic.localmbox_entry, prefs_set_data_from_entry, prefs_set_entry},
261
262         {"use_mail_command", "FALSE", &tmp_ac_prefs.use_mail_command, P_BOOL,
263          &basic.mailcmd_chkbtn, prefs_set_data_from_toggle, prefs_set_toggle},
264
265         {"mail_command", DEFAULT_SENDMAIL_CMD, &tmp_ac_prefs.mail_command, P_STRING,
266          &basic.mailcmd_entry, prefs_set_data_from_entry, prefs_set_entry},
267
268         {"use_nntp_auth", "FALSE", &tmp_ac_prefs.use_nntp_auth, P_BOOL,
269          &basic.nntpauth_chkbtn,
270          prefs_set_data_from_toggle, prefs_set_toggle},
271         
272         {"use_nntp_auth_onconnect", "FALSE", &tmp_ac_prefs.use_nntp_auth_onconnect, P_BOOL,
273          &basic.nntpauth_onconnect_chkbtn,
274          prefs_set_data_from_toggle, prefs_set_toggle},
275
276         {"user_id", "ENV_USER", &tmp_ac_prefs.userid, P_STRING,
277          &basic.uid_entry, prefs_set_data_from_entry, prefs_set_entry},
278
279         {"password", NULL, &tmp_ac_prefs.passwd, P_PASSWORD,
280          &basic.pass_entry, prefs_set_data_from_entry, prefs_set_entry},
281
282         {"inbox", "inbox", &tmp_ac_prefs.inbox, P_STRING,
283          &receive.inbox_entry, prefs_set_data_from_entry, prefs_set_entry},
284
285         /* Receive */
286         {"use_apop_auth", "FALSE", &tmp_ac_prefs.use_apop_auth, P_BOOL,
287          &receive.use_apop_chkbtn,
288          prefs_set_data_from_toggle, prefs_set_toggle},
289
290         {"remove_mail", "TRUE", &tmp_ac_prefs.rmmail, P_BOOL,
291          &receive.rmmail_chkbtn,
292          prefs_set_data_from_toggle, prefs_set_toggle},
293
294         {"message_leave_time", "0", &tmp_ac_prefs.msg_leave_time, P_INT,
295          &receive.leave_time_entry,
296          prefs_set_data_from_entry, prefs_set_entry},
297
298         {"get_all_mail", "FALSE", &tmp_ac_prefs.getall, P_BOOL,
299          &receive.getall_chkbtn,
300          prefs_set_data_from_toggle, prefs_set_toggle},
301
302         {"enable_size_limit", "FALSE", &tmp_ac_prefs.enable_size_limit, P_BOOL,
303          &receive.size_limit_chkbtn,
304          prefs_set_data_from_toggle, prefs_set_toggle},
305         {"size_limit", "1024", &tmp_ac_prefs.size_limit, P_INT,
306          &receive.size_limit_entry,
307          prefs_set_data_from_entry, prefs_set_entry},
308
309         {"filter_on_receive", "TRUE", &tmp_ac_prefs.filter_on_recv, P_BOOL,
310          &receive.filter_on_recv_chkbtn,
311          prefs_set_data_from_toggle, prefs_set_toggle},
312
313         {"imap_auth_method", "0", &tmp_ac_prefs.imap_auth_type, P_ENUM,
314          &receive.imap_auth_type_optmenu,
315          prefs_account_imap_auth_type_set_data_from_optmenu,
316          prefs_account_imap_auth_type_set_optmenu},
317
318         {"receive_at_get_all", "TRUE", &tmp_ac_prefs.recv_at_getall, P_BOOL,
319          &receive.recvatgetall_chkbtn,
320          prefs_set_data_from_toggle, prefs_set_toggle},
321
322         {"max_news_articles", "300", &tmp_ac_prefs.max_articles, P_INT,
323          &receive.spinbtn_maxarticle,
324          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
325
326         /* Send */
327         {"add_date", "TRUE", &tmp_ac_prefs.add_date, P_BOOL,
328          &p_send.date_chkbtn,
329          prefs_set_data_from_toggle, prefs_set_toggle},
330
331         {"generate_msgid", "TRUE", &tmp_ac_prefs.gen_msgid, P_BOOL,
332          &p_send.msgid_chkbtn,
333          prefs_set_data_from_toggle, prefs_set_toggle},
334
335         {"add_custom_header", "FALSE", &tmp_ac_prefs.add_customhdr, P_BOOL,
336          &p_send.customhdr_chkbtn,
337          prefs_set_data_from_toggle, prefs_set_toggle},
338
339         {"use_smtp_auth", "FALSE", &tmp_ac_prefs.use_smtp_auth, P_BOOL,
340          &p_send.smtp_auth_chkbtn,
341          prefs_set_data_from_toggle, prefs_set_toggle},
342
343         {"smtp_auth_method", "0", &tmp_ac_prefs.smtp_auth_type, P_ENUM,
344          &p_send.smtp_auth_type_optmenu,
345          prefs_account_smtp_auth_type_set_data_from_optmenu,
346          prefs_account_smtp_auth_type_set_optmenu},
347
348         {"smtp_user_id", NULL, &tmp_ac_prefs.smtp_userid, P_STRING,
349          &p_send.smtp_uid_entry, prefs_set_data_from_entry, prefs_set_entry},
350         {"smtp_password", NULL, &tmp_ac_prefs.smtp_passwd, P_PASSWORD,
351          &p_send.smtp_pass_entry, prefs_set_data_from_entry, prefs_set_entry},
352
353         {"pop_before_smtp", "FALSE", &tmp_ac_prefs.pop_before_smtp, P_BOOL,
354          &p_send.pop_bfr_smtp_chkbtn,
355          prefs_set_data_from_toggle, prefs_set_toggle},
356
357         {"pop_before_smtp_timeout", "5", &tmp_ac_prefs.pop_before_smtp_timeout, P_INT,
358          &p_send.pop_bfr_smtp_tm_entry,
359          prefs_set_data_from_entry, prefs_set_entry},
360
361         /* Compose */
362         {"signature_type", "0", &tmp_ac_prefs.sig_type, P_ENUM,
363          &compose.sigfile_radiobtn,
364          prefs_account_enum_set_data_from_radiobtn,
365          prefs_account_enum_set_radiobtn},
366         {"signature_path", "~/"DEFAULT_SIGNATURE, &tmp_ac_prefs.sig_path, P_STRING,
367          &compose.entry_sigpath,
368          prefs_set_data_from_entry, prefs_set_entry},
369
370         {"auto_signature", "TRUE", &tmp_ac_prefs.auto_sig, P_BOOL,
371          &compose.checkbtn_autosig,
372          prefs_set_data_from_toggle, prefs_set_toggle},
373          
374         {"signature_separator", "-- ", &tmp_ac_prefs.sig_sep, P_STRING,
375          &compose.entry_sigsep, 
376          prefs_set_data_from_entry, prefs_set_entry},
377
378         {"set_autocc", "FALSE", &tmp_ac_prefs.set_autocc, P_BOOL,
379          &compose.autocc_chkbtn,
380          prefs_set_data_from_toggle, prefs_set_toggle},
381
382         {"auto_cc", NULL, &tmp_ac_prefs.auto_cc, P_STRING,
383          &compose.autocc_entry,
384          prefs_set_data_from_entry, prefs_set_entry},
385
386         {"set_autobcc", "FALSE", &tmp_ac_prefs.set_autobcc, P_BOOL,
387          &compose.autobcc_chkbtn,
388          prefs_set_data_from_toggle, prefs_set_toggle},
389
390         {"auto_bcc", NULL, &tmp_ac_prefs.auto_bcc, P_STRING,
391          &compose.autobcc_entry,
392          prefs_set_data_from_entry, prefs_set_entry},
393
394         {"set_autoreplyto", "FALSE", &tmp_ac_prefs.set_autoreplyto, P_BOOL,
395          &compose.autoreplyto_chkbtn,
396          prefs_set_data_from_toggle, prefs_set_toggle},
397
398         {"auto_replyto", NULL, &tmp_ac_prefs.auto_replyto, P_STRING,
399          &compose.autoreplyto_entry,
400          prefs_set_data_from_entry, prefs_set_entry},
401
402         /* Privacy */
403         {"default_privacy_system", "", &tmp_ac_prefs.default_privacy_system, P_STRING,
404          &privacy.default_privacy_system,
405          prefs_account_set_string_from_optmenu, prefs_account_set_optmenu_from_string},
406         {"default_encrypt", "FALSE", &tmp_ac_prefs.default_encrypt, P_BOOL,
407          &privacy.default_encrypt_chkbtn,
408          prefs_set_data_from_toggle, prefs_set_toggle},
409         {"default_sign", "FALSE", &tmp_ac_prefs.default_sign, P_BOOL,
410          &privacy.default_sign_chkbtn,
411          prefs_set_data_from_toggle, prefs_set_toggle},
412
413 #if USE_OPENSSL
414         /* SSL */
415         {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
416          &ssl.pop_nossl_radiobtn,
417          prefs_account_enum_set_data_from_radiobtn,
418          prefs_account_enum_set_radiobtn},
419         {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM,
420          &ssl.imap_nossl_radiobtn,
421          prefs_account_enum_set_data_from_radiobtn,
422          prefs_account_enum_set_radiobtn},
423         {"ssl_nntp", "0", &tmp_ac_prefs.ssl_nntp, P_ENUM,
424          &ssl.nntp_nossl_radiobtn,
425          prefs_account_enum_set_data_from_radiobtn,
426          prefs_account_enum_set_radiobtn},
427         {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM,
428          &ssl.smtp_nossl_radiobtn,
429          prefs_account_enum_set_data_from_radiobtn,
430          prefs_account_enum_set_radiobtn},
431
432         {"use_nonblocking_ssl", "1", &tmp_ac_prefs.use_nonblocking_ssl, P_BOOL,
433          &ssl.use_nonblocking_ssl_chkbtn,
434          prefs_set_data_from_toggle, prefs_set_toggle},
435 #endif /* USE_OPENSSL */
436
437         /* Advanced */
438         {"set_smtpport", "FALSE", &tmp_ac_prefs.set_smtpport, P_BOOL,
439          &advanced.smtpport_chkbtn,
440          prefs_set_data_from_toggle, prefs_set_toggle},
441
442         {"smtp_port", "25", &tmp_ac_prefs.smtpport, P_USHORT,
443          &advanced.smtpport_entry,
444          prefs_set_data_from_entry, prefs_set_entry},
445
446         {"set_popport", "FALSE", &tmp_ac_prefs.set_popport, P_BOOL,
447          &advanced.popport_chkbtn,
448          prefs_set_data_from_toggle, prefs_set_toggle},
449
450         {"pop_port", "110", &tmp_ac_prefs.popport, P_USHORT,
451          &advanced.popport_entry,
452          prefs_set_data_from_entry, prefs_set_entry},
453
454         {"set_imapport", "FALSE", &tmp_ac_prefs.set_imapport, P_BOOL,
455          &advanced.imapport_chkbtn,
456          prefs_set_data_from_toggle, prefs_set_toggle},
457
458         {"imap_port", "143", &tmp_ac_prefs.imapport, P_USHORT,
459          &advanced.imapport_entry,
460          prefs_set_data_from_entry, prefs_set_entry},
461
462         {"set_nntpport", "FALSE", &tmp_ac_prefs.set_nntpport, P_BOOL,
463          &advanced.nntpport_chkbtn,
464          prefs_set_data_from_toggle, prefs_set_toggle},
465
466         {"nntp_port", "119", &tmp_ac_prefs.nntpport, P_USHORT,
467          &advanced.nntpport_entry,
468          prefs_set_data_from_entry, prefs_set_entry},
469
470         {"set_domain", "FALSE", &tmp_ac_prefs.set_domain, P_BOOL,
471          &advanced.domain_chkbtn,
472          prefs_set_data_from_toggle, prefs_set_toggle},
473
474         {"domain", NULL, &tmp_ac_prefs.domain, P_STRING,
475          &advanced.domain_entry,
476          prefs_set_data_from_entry, prefs_set_entry},
477
478         {"set_tunnelcmd", "FALSE", &tmp_ac_prefs.set_tunnelcmd, P_BOOL,
479          &advanced.tunnelcmd_chkbtn,
480          prefs_set_data_from_toggle, prefs_set_toggle},
481
482         {"tunnelcmd", NULL, &tmp_ac_prefs.tunnelcmd, P_STRING,
483          &advanced.tunnelcmd_entry,
484          prefs_set_data_from_entry, prefs_set_entry},
485
486         {"mark_crosspost_read", "FALSE", &tmp_ac_prefs.mark_crosspost_read, P_BOOL,
487          &advanced.crosspost_chkbtn,
488          prefs_set_data_from_toggle, prefs_set_toggle},
489
490         {"crosspost_color", NULL, &tmp_ac_prefs.crosspost_col, P_ENUM,
491          &advanced.crosspost_colormenu,
492          prefs_account_crosspost_set_data_from_colormenu,
493          prefs_account_crosspost_set_colormenu},
494
495         {"imap_directory", NULL, &tmp_ac_prefs.imap_dir, P_STRING,
496          &advanced.imapdir_entry, prefs_set_data_from_entry, prefs_set_entry},
497
498         {"set_sent_folder", "FALSE", &tmp_ac_prefs.set_sent_folder, P_BOOL,
499          &advanced.sent_folder_chkbtn,
500          prefs_set_data_from_toggle, prefs_set_toggle},
501         {"sent_folder", NULL, &tmp_ac_prefs.sent_folder, P_STRING,
502          &advanced.sent_folder_entry,
503          prefs_set_data_from_entry, prefs_set_entry},
504
505         {"set_draft_folder", "FALSE", &tmp_ac_prefs.set_draft_folder, P_BOOL,
506          &advanced.draft_folder_chkbtn,
507          prefs_set_data_from_toggle, prefs_set_toggle},
508         {"draft_folder", NULL, &tmp_ac_prefs.draft_folder, P_STRING,
509          &advanced.draft_folder_entry,
510          prefs_set_data_from_entry, prefs_set_entry},
511
512         {"set_trash_folder", "FALSE", &tmp_ac_prefs.set_trash_folder, P_BOOL,
513          &advanced.trash_folder_chkbtn,
514          prefs_set_data_from_toggle, prefs_set_toggle},
515         {"trash_folder", NULL, &tmp_ac_prefs.trash_folder, P_STRING,
516          &advanced.trash_folder_entry,
517          prefs_set_data_from_entry, prefs_set_entry},
518
519         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
520 };
521
522 static gint prefs_account_get_new_id            (void);
523
524 static void prefs_account_create                (void);
525 static void prefs_account_basic_create          (void);
526 static void prefs_account_receive_create        (void);
527 static void prefs_account_send_create           (void);
528 static void prefs_account_compose_create        (void);
529 static void prefs_account_privacy_create        (void);
530 #if USE_OPENSSL
531 static void prefs_account_ssl_create            (void);
532 #endif /* USE_OPENSSL */
533 static void prefs_account_advanced_create       (void);
534
535 static void prefs_account_select_folder_cb      (GtkWidget      *widget,
536                                                  gpointer        data);
537
538 static void pop_bfr_smtp_tm_set_sens            (GtkWidget      *widget,
539                                                  gpointer        data);
540
541 static void prefs_account_edit_custom_header    (void);
542
543 static gint prefs_account_deleted               (GtkWidget      *widget,
544                                                  GdkEventAny    *event,
545                                                  gpointer        data);
546 static gboolean prefs_account_key_pressed       (GtkWidget      *widget,
547                                                  GdkEventKey    *event,
548                                                  gpointer        data);
549 static void prefs_account_ok                    (void);
550 static gint prefs_account_apply                 (void);
551 static void prefs_account_cancel                (void);
552
553 PrefsAccount *prefs_account_new(void)
554 {
555         PrefsAccount *ac_prefs;
556
557         ac_prefs = g_new0(PrefsAccount, 1);
558         memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
559         prefs_set_default(param);
560         *ac_prefs = tmp_ac_prefs;
561         ac_prefs->account_id = prefs_account_get_new_id();
562
563         return ac_prefs;
564 }
565
566 void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
567 {
568         const guchar *p = label;
569         gint id;
570
571         g_return_if_fail(ac_prefs != NULL);
572         g_return_if_fail(label != NULL);
573
574         memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
575         prefs_read_config(param, label, ACCOUNT_RC);
576         *ac_prefs = tmp_ac_prefs;
577         while (*p && !isdigit(*p)) p++;
578         id = atoi(p);
579         if (id < 0) g_warning("wrong account id: %d\n", id);
580         ac_prefs->account_id = id;
581
582         if (ac_prefs->protocol == A_APOP) {
583                 debug_print("converting protocol A_APOP to new prefs.\n");
584                 ac_prefs->protocol = A_POP3;
585                 ac_prefs->use_apop_auth = TRUE;
586         }
587
588         prefs_custom_header_read_config(ac_prefs);
589 }
590
591 void prefs_account_write_config_all(GList *account_list)
592 {
593         GList *cur;
594         gchar *rcpath;
595         PrefFile *pfile;
596
597         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
598         if ((pfile = prefs_write_open(rcpath)) == NULL) {
599                 g_free(rcpath);
600                 return;
601         }
602         g_free(rcpath);
603
604         for (cur = account_list; cur != NULL; cur = cur->next) {
605                 tmp_ac_prefs = *(PrefsAccount *)cur->data;
606                 if (fprintf(pfile->fp, "[Account: %d]\n",
607                             tmp_ac_prefs.account_id) <= 0 ||
608                     prefs_write_param(param, pfile->fp) < 0) {
609                         g_warning("failed to write configuration to file\n");
610                         prefs_file_close_revert(pfile);
611                         return;
612                 }
613                 if (cur->next) {
614                         if (fputc('\n', pfile->fp) == EOF) {
615                                 FILE_OP_ERROR(rcpath, "fputc");
616                                 prefs_file_close_revert(pfile);
617                                 return;
618                         }
619                 }
620         }
621
622         if (prefs_file_close(pfile) < 0)
623                 g_warning("failed to write configuration to file\n");
624 }
625
626 void prefs_account_free(PrefsAccount *ac_prefs)
627 {
628         if (!ac_prefs) return;
629
630         tmp_ac_prefs = *ac_prefs;
631         prefs_free(param);
632 }
633
634 static gint prefs_account_get_new_id(void)
635 {
636         GList *ac_list;
637         PrefsAccount *ac;
638         static gint last_id = 0;
639
640         for (ac_list = account_get_list(); ac_list != NULL;
641              ac_list = ac_list->next) {
642                 ac = (PrefsAccount *)ac_list->data;
643                 if (last_id < ac->account_id)
644                         last_id = ac->account_id;
645         }
646
647         return last_id + 1;
648 }
649
650 void update_privacy_system_menu() {
651         GtkWidget *menu;
652         GtkWidget *menuitem;
653         GSList *system_ids, *cur;
654
655         menu = gtk_menu_new();
656
657         menuitem = gtk_menu_item_new_with_label(_("None"));
658         gtk_widget_show(menuitem);
659         g_object_set_data(G_OBJECT(menuitem), MENU_VAL_ID, "");
660         gtk_menu_append(GTK_MENU(menu), menuitem);
661
662         system_ids = privacy_get_system_ids();
663         for (cur = system_ids; cur != NULL; cur = g_slist_next(cur)) {
664                 gchar *id = (gchar *) cur->data;
665                 const gchar *name;
666                 
667                 name = privacy_system_get_name(id);
668                 menuitem = gtk_menu_item_new_with_label(name);
669                 gtk_widget_show(menuitem);
670                 g_object_set_data_full(G_OBJECT(menuitem), MENU_VAL_ID, id, g_free);
671                 gtk_menu_append(GTK_MENU(menu), menuitem);
672         }
673
674         gtk_option_menu_set_menu(GTK_OPTION_MENU(privacy.default_privacy_system), menu);
675 }
676
677 PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs)
678 {
679         gboolean new_account = FALSE;
680
681         if (prefs_rc_is_readonly(ACCOUNT_RC))
682                 return ac_prefs;
683
684         debug_print("Opening account preferences window...\n");
685
686         inc_lock();
687
688         cancelled = FALSE;
689
690         if (!ac_prefs) {
691                 ac_prefs = prefs_account_new();
692                 new_account = TRUE;
693         }
694
695         if (!dialog.window) {
696                 prefs_account_create();
697         }
698
699         manage_window_set_transient(GTK_WINDOW(dialog.window));
700         gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog.notebook), 0);
701         gtk_widget_grab_focus(dialog.ok_btn);
702
703         tmp_ac_prefs = *ac_prefs;
704
705         update_privacy_system_menu();
706
707         if (new_account) {
708                 PrefsAccount *def_ac;
709                 gchar *buf;
710
711                 prefs_set_dialog_to_default(param);
712                 buf = g_strdup_printf(_("Account%d"), ac_prefs->account_id);
713                 gtk_entry_set_text(GTK_ENTRY(basic.acname_entry), buf);
714                 g_free(buf);
715                 def_ac = account_get_default();
716                 if (def_ac) {
717                         gtk_entry_set_text(GTK_ENTRY(basic.name_entry),
718                                            def_ac->name ? def_ac->name : "");
719                         gtk_entry_set_text(GTK_ENTRY(basic.addr_entry),
720                                            def_ac->address ? def_ac->address : "");
721                         gtk_entry_set_text(GTK_ENTRY(basic.org_entry),
722                                            def_ac->organization ? def_ac->organization : "");
723                 }
724                 menu_set_sensitive_all
725                         (GTK_MENU_SHELL
726                                 (gtk_option_menu_get_menu
727                                         (GTK_OPTION_MENU
728                                                 (basic.protocol_optmenu))),
729                          TRUE);
730                 gtk_window_set_title(GTK_WINDOW(dialog.window),
731                                      _("Preferences for new account"));
732                 gtk_widget_hide(dialog.apply_btn);
733         } else {
734                 gchar *title;
735                 prefs_set_dialog(param);
736                 title = g_strdup_printf (_("%s - Account preferences"),
737                                 ac_prefs->account_name);
738                 gtk_window_set_title(GTK_WINDOW(dialog.window), title);
739                 g_free (title);
740                 gtk_widget_show(dialog.apply_btn);
741         }
742
743         pop_bfr_smtp_tm_set_sens (NULL, NULL);
744         
745         gtk_widget_show(dialog.window);
746         gtk_main();
747         gtk_widget_hide(dialog.window);
748
749         inc_unlock();
750
751         if (cancelled && new_account) {
752                 g_free(ac_prefs);
753                 return NULL;
754         } else {
755                 *ac_prefs = tmp_ac_prefs;
756                 return ac_prefs;
757         }
758 }
759
760 static void prefs_account_create(void)
761 {
762         gint page = 0;
763
764         debug_print("Creating account preferences window...\n");
765
766         /* create dialog */
767         prefs_dialog_create(&dialog);
768         g_signal_connect(G_OBJECT(dialog.window), "delete_event",
769                          G_CALLBACK(prefs_account_deleted), NULL);
770         g_signal_connect(G_OBJECT(dialog.window), "key_press_event",
771                          G_CALLBACK(prefs_account_key_pressed), NULL);
772         MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
773
774         g_signal_connect(G_OBJECT(dialog.ok_btn), "clicked",
775                          G_CALLBACK(prefs_account_ok), NULL);
776         g_signal_connect(G_OBJECT(dialog.apply_btn), "clicked",
777                          G_CALLBACK(prefs_account_apply), NULL);
778         g_signal_connect(G_OBJECT(dialog.cancel_btn), "clicked",
779                          G_CALLBACK(prefs_account_cancel), NULL);
780
781         prefs_account_basic_create();
782         SET_NOTEBOOK_LABEL(dialog.notebook, _("Basic"), page++);
783         prefs_account_receive_create();
784         SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"), page++);
785         prefs_account_send_create();
786         SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"), page++);
787         prefs_account_compose_create();
788         SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"), page++);
789         prefs_account_privacy_create();
790         SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"), page++);
791 #if USE_OPENSSL
792         prefs_account_ssl_create();
793         SET_NOTEBOOK_LABEL(dialog.notebook, _("SSL"), page++);
794 #endif /* USE_OPENSSL */
795         prefs_account_advanced_create();
796         SET_NOTEBOOK_LABEL(dialog.notebook, _("Advanced"), page++);
797
798         prefs_account_fix_size();
799 }
800
801 /**
802  * prefs_account_fix_size:
803  * 
804  * Fix the window size after creating widgets by selecting "Local"
805  * protocol (currently it has the largest size of parameter widgets).
806  * Without this the window gets too large.
807  **/
808 static void prefs_account_fix_size(void)
809 {
810         GtkOptionMenu *optmenu = GTK_OPTION_MENU (basic.protocol_optmenu);
811         GtkWidget *menu;
812         GtkWidget *menuitem;
813
814         gtk_option_menu_set_history (optmenu, 4); /* local */
815         menu = gtk_option_menu_get_menu (optmenu);
816         menuitem = gtk_menu_get_active (GTK_MENU (menu));
817         gtk_menu_item_activate (GTK_MENU_ITEM (menuitem));
818 }
819
820 #define SET_ACTIVATE(menuitem) \
821 { \
822         g_signal_connect(G_OBJECT(menuitem), "activate", \
823                          G_CALLBACK(prefs_account_protocol_activated), \
824                          NULL); \
825 }
826
827 #define TABLE_YPAD 2
828
829 static void prefs_account_basic_create(void)
830 {
831         GtkWidget *vbox1;
832         GtkWidget *hbox;
833         GtkWidget *label;
834         GtkWidget *acname_entry;
835         GtkWidget *default_chkbtn;
836         GtkWidget *frame1;
837         GtkWidget *table1;
838         GtkWidget *name_entry;
839         GtkWidget *addr_entry;
840         GtkWidget *org_entry;
841
842         GtkWidget *serv_frame;
843         GtkWidget *vbox2;
844         GtkWidget *optmenu;
845         GtkWidget *optmenu_menu;
846         GtkWidget *menuitem;
847         GtkWidget *serv_table;
848         GtkWidget *recvserv_label;
849         GtkWidget *smtpserv_label;
850         GtkWidget *nntpserv_label;
851         GtkWidget *localmbox_label;
852         GtkWidget *mailcmd_label;
853         GtkWidget *recvserv_entry;
854         GtkWidget *smtpserv_entry;
855         GtkWidget *nntpserv_entry;
856         GtkWidget *nntpauth_chkbtn;
857         GtkWidget *nntpauth_onconnect_chkbtn;
858         GtkWidget *localmbox_entry;
859         GtkWidget *mailcmd_chkbtn;
860         GtkWidget *mailcmd_entry;
861         GtkWidget *uid_label;
862         GtkWidget *pass_label;
863         GtkWidget *uid_entry;
864         GtkWidget *pass_entry;
865
866         vbox1 = gtk_vbox_new (FALSE, VSPACING);
867         gtk_widget_show (vbox1);
868         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
869         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
870
871         hbox = gtk_hbox_new (FALSE, 8);
872         gtk_widget_show (hbox);
873         gtk_box_pack_start (GTK_BOX (vbox1), hbox, FALSE, FALSE, 0);
874
875         label = gtk_label_new (_("Name of account"));
876         gtk_widget_show (label);
877         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
878
879         acname_entry = gtk_entry_new ();
880         gtk_widget_show (acname_entry);
881         gtk_widget_set_size_request (acname_entry, DEFAULT_ENTRY_WIDTH, -1);
882         gtk_box_pack_start (GTK_BOX (hbox), acname_entry, TRUE, TRUE, 0);
883
884         default_chkbtn = gtk_check_button_new_with_label (_("Set as default"));
885         gtk_widget_show (default_chkbtn);
886         gtk_box_pack_end (GTK_BOX (hbox), default_chkbtn, FALSE, FALSE, 0);
887
888         PACK_FRAME (vbox1, frame1, _("Personal information"));
889
890         table1 = gtk_table_new (3, 2, FALSE);
891         gtk_widget_show (table1);
892         gtk_container_add (GTK_CONTAINER (frame1), table1);
893         gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
894         gtk_table_set_row_spacings (GTK_TABLE (table1), VSPACING_NARROW);
895         gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
896
897         label = gtk_label_new (_("Full name"));
898         gtk_widget_show (label);
899         gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 0, 1,
900                           GTK_FILL, 0, 0, 0);
901         gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
902
903         label = gtk_label_new (_("Mail address"));
904         gtk_widget_show (label);
905         gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 1, 2,
906                           GTK_FILL, 0, 0, 0);
907         gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
908
909         label = gtk_label_new (_("Organization"));
910         gtk_widget_show (label);
911         gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 2, 3,
912                           GTK_FILL, 0, 0, 0);
913         gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
914
915         name_entry = gtk_entry_new ();
916         gtk_widget_show (name_entry);
917         gtk_table_attach (GTK_TABLE (table1), name_entry, 1, 2, 0, 1,
918                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
919                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
920
921         addr_entry = gtk_entry_new ();
922         gtk_widget_show (addr_entry);
923         gtk_table_attach (GTK_TABLE (table1), addr_entry, 1, 2, 1, 2,
924                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
925                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
926
927         org_entry = gtk_entry_new ();
928         gtk_widget_show (org_entry);
929         gtk_table_attach (GTK_TABLE (table1), org_entry, 1, 2, 2, 3,
930                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
931                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
932
933         PACK_FRAME (vbox1, serv_frame, _("Server information"));
934
935         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
936         gtk_widget_show (vbox2);
937         gtk_container_add (GTK_CONTAINER (serv_frame), vbox2);
938         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
939
940         hbox = gtk_hbox_new (FALSE, 8);
941         gtk_widget_show (hbox);
942         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
943
944         label = gtk_label_new (_("Protocol"));
945         gtk_widget_show (label);
946         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
947
948         optmenu = gtk_option_menu_new ();
949         gtk_widget_show (optmenu);
950         gtk_box_pack_start (GTK_BOX (hbox), optmenu, FALSE, FALSE, 0);
951
952         optmenu_menu = gtk_menu_new ();
953
954         MENUITEM_ADD (optmenu_menu, menuitem, _("POP3"),  A_POP3);
955         SET_ACTIVATE (menuitem);
956         MENUITEM_ADD (optmenu_menu, menuitem, _("IMAP4"), A_IMAP4);
957         SET_ACTIVATE (menuitem);
958         MENUITEM_ADD (optmenu_menu, menuitem, _("News (NNTP)"), A_NNTP);
959         SET_ACTIVATE (menuitem);
960         MENUITEM_ADD (optmenu_menu, menuitem, _("Local mbox file"), A_LOCAL);
961         SET_ACTIVATE (menuitem);
962         MENUITEM_ADD (optmenu_menu, menuitem, _("None (SMTP only)"), A_NONE);
963         SET_ACTIVATE (menuitem);
964
965         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
966
967         serv_table = gtk_table_new (6, 4, FALSE);
968         gtk_widget_show (serv_table);
969         gtk_box_pack_start (GTK_BOX (vbox2), serv_table, FALSE, FALSE, 0);
970         gtk_table_set_row_spacings (GTK_TABLE (serv_table), VSPACING_NARROW);
971         gtk_table_set_row_spacing (GTK_TABLE (serv_table), 3, 0);
972         gtk_table_set_col_spacings (GTK_TABLE (serv_table), 8);
973
974         nntpserv_entry = gtk_entry_new ();
975         gtk_widget_show (nntpserv_entry);
976         gtk_table_attach (GTK_TABLE (serv_table), nntpserv_entry, 1, 4, 0, 1,
977                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
978                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
979 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 0, 0); */
980
981         nntpauth_chkbtn = gtk_check_button_new_with_label
982                 (_("This server requires authentication"));
983         gtk_widget_show (nntpauth_chkbtn);
984         
985         gtk_table_attach (GTK_TABLE (serv_table), nntpauth_chkbtn, 0, 2, 1, 2,
986                           GTK_FILL, 0, 0, 0);
987
988         nntpauth_onconnect_chkbtn = gtk_check_button_new_with_label
989                 (_("Authenticate on connect"));
990         gtk_widget_show (nntpauth_onconnect_chkbtn);
991
992         gtk_table_attach (GTK_TABLE (serv_table), nntpauth_onconnect_chkbtn, 2, 4, 1, 2,
993                           GTK_FILL, 0, 0, 0);
994
995         recvserv_entry = gtk_entry_new ();
996         gtk_widget_show (recvserv_entry);
997         gtk_table_attach (GTK_TABLE (serv_table), recvserv_entry, 1, 4, 2, 3,
998                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
999                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1000
1001         localmbox_entry = gtk_entry_new ();
1002         gtk_widget_show (localmbox_entry);
1003         gtk_table_attach (GTK_TABLE (serv_table), localmbox_entry, 1, 4, 3, 4,
1004                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1005                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1006
1007         smtpserv_entry = gtk_entry_new ();
1008         gtk_widget_show (smtpserv_entry);
1009         gtk_table_attach (GTK_TABLE (serv_table), smtpserv_entry, 1, 4, 4, 5,
1010                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1011                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1012
1013         mailcmd_entry = gtk_entry_new ();
1014         gtk_widget_show (mailcmd_entry);
1015         gtk_table_attach (GTK_TABLE (serv_table), mailcmd_entry, 1, 4, 6, 7,
1016                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1017                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1018
1019         uid_entry = gtk_entry_new ();
1020         gtk_widget_show (uid_entry);
1021         gtk_widget_set_size_request (uid_entry, DEFAULT_ENTRY_WIDTH, -1);
1022         gtk_table_attach (GTK_TABLE (serv_table), uid_entry, 1, 2, 7, 8,
1023                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1024                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1025
1026         pass_entry = gtk_entry_new ();
1027         gtk_widget_show (pass_entry);
1028         gtk_widget_set_size_request (pass_entry, DEFAULT_ENTRY_WIDTH, -1);
1029         gtk_table_attach (GTK_TABLE (serv_table), pass_entry, 3, 4, 7, 8,
1030                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1031                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1032         gtk_entry_set_visibility (GTK_ENTRY (pass_entry), FALSE);
1033
1034         nntpserv_label = gtk_label_new (_("News server"));
1035         gtk_widget_show (nntpserv_label);
1036         gtk_table_attach (GTK_TABLE (serv_table), nntpserv_label, 0, 1, 0, 1,
1037                           GTK_FILL, 0, 0, 0);
1038         gtk_misc_set_alignment (GTK_MISC (nntpserv_label), 1, 0.5);
1039
1040         recvserv_label = gtk_label_new (_("Server for receiving"));
1041         gtk_widget_show (recvserv_label);
1042         gtk_table_attach (GTK_TABLE (serv_table), recvserv_label, 0, 1, 2, 3,
1043                           GTK_FILL, 0, 0, 0);
1044         gtk_misc_set_alignment (GTK_MISC (recvserv_label), 1, 0.5);
1045
1046         localmbox_label = gtk_label_new (_("Local mailbox"));
1047         gtk_widget_show (localmbox_label);
1048         gtk_table_attach (GTK_TABLE (serv_table), localmbox_label, 0, 1, 3, 4,
1049                           GTK_FILL, 0, 0, 0);
1050         gtk_misc_set_alignment (GTK_MISC (localmbox_label), 1, 0.5);
1051 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
1052
1053         smtpserv_label = gtk_label_new (_("SMTP server (send)"));
1054         gtk_widget_show (smtpserv_label);
1055         gtk_table_attach (GTK_TABLE (serv_table), smtpserv_label, 0, 1, 4, 5,
1056                           GTK_FILL, 0, 0, 0);
1057         gtk_misc_set_alignment (GTK_MISC (smtpserv_label), 1, 0.5);
1058 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
1059
1060         mailcmd_chkbtn = gtk_check_button_new_with_label
1061                 (_("Use mail command rather than SMTP server"));
1062         gtk_widget_show (mailcmd_chkbtn);
1063         gtk_table_attach (GTK_TABLE (serv_table), mailcmd_chkbtn, 0, 4, 5, 6,
1064                           GTK_EXPAND | GTK_FILL,
1065                           0, 0, TABLE_YPAD);
1066         g_signal_connect(G_OBJECT(mailcmd_chkbtn), "toggled",
1067                          G_CALLBACK(prefs_account_mailcmd_toggled),
1068                          NULL);
1069
1070         mailcmd_label = gtk_label_new (_("command to send mails"));
1071         gtk_widget_show (mailcmd_label);
1072         gtk_table_attach (GTK_TABLE (serv_table), mailcmd_label, 0, 1, 6, 7,
1073                           GTK_FILL, 0, 0, 0);
1074         gtk_misc_set_alignment (GTK_MISC (mailcmd_label), 1, 0.5);
1075 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
1076
1077         uid_label = gtk_label_new (_("User ID"));
1078         gtk_widget_show (uid_label);
1079         gtk_table_attach (GTK_TABLE (serv_table), uid_label, 0, 1, 7, 8,
1080                           GTK_FILL, 0, 0, 0);
1081         gtk_misc_set_alignment (GTK_MISC (uid_label), 1, 0.5);
1082
1083         pass_label = gtk_label_new (_("Password"));
1084         gtk_widget_show (pass_label);
1085         gtk_table_attach (GTK_TABLE (serv_table), pass_label, 2, 3, 7, 8,
1086                           0, 0, 0, 0);
1087
1088         SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, uid_label);
1089         SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, pass_label);
1090         SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, uid_entry);
1091         SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, pass_entry);
1092         SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, nntpauth_onconnect_chkbtn);
1093
1094         basic.acname_entry   = acname_entry;
1095         basic.default_chkbtn = default_chkbtn;
1096
1097         basic.name_entry = name_entry;
1098         basic.addr_entry = addr_entry;
1099         basic.org_entry  = org_entry;
1100
1101         basic.serv_frame       = serv_frame;
1102         basic.serv_table       = serv_table;
1103         basic.protocol_optmenu = optmenu;
1104         basic.recvserv_label   = recvserv_label;
1105         basic.recvserv_entry   = recvserv_entry;
1106         basic.smtpserv_label   = smtpserv_label;
1107         basic.smtpserv_entry   = smtpserv_entry;
1108         basic.nntpserv_label   = nntpserv_label;
1109         basic.nntpserv_entry   = nntpserv_entry;
1110         basic.nntpauth_chkbtn  = nntpauth_chkbtn;
1111         basic.nntpauth_onconnect_chkbtn  = nntpauth_onconnect_chkbtn;
1112         basic.localmbox_label   = localmbox_label;
1113         basic.localmbox_entry   = localmbox_entry;
1114         basic.mailcmd_chkbtn   = mailcmd_chkbtn;
1115         basic.mailcmd_label   = mailcmd_label;
1116         basic.mailcmd_entry   = mailcmd_entry;
1117         basic.uid_label        = uid_label;
1118         basic.pass_label       = pass_label;
1119         basic.uid_entry        = uid_entry;
1120         basic.pass_entry       = pass_entry;
1121 }
1122
1123 static void prefs_account_receive_create(void)
1124 {
1125         GtkWidget *vbox1;
1126         GtkWidget *frame1;
1127         GtkWidget *vbox2;
1128         GtkWidget *use_apop_chkbtn;
1129         GtkWidget *rmmail_chkbtn;
1130         GtkWidget *hbox_spc;
1131         GtkWidget *leave_time_label;
1132         GtkWidget *leave_time_entry;
1133         GtkWidget *getall_chkbtn;
1134         GtkWidget *hbox1;
1135         GtkWidget *size_limit_chkbtn;
1136         GtkWidget *size_limit_entry;
1137         GtkWidget *label;
1138         GtkWidget *filter_on_recv_chkbtn;
1139         GtkWidget *vbox3;
1140         GtkWidget *inbox_label;
1141         GtkWidget *inbox_entry;
1142         GtkWidget *inbox_btn;
1143         GtkWidget *imap_frame;
1144         GtkWidget *optmenu;
1145         GtkWidget *optmenu_menu;
1146         GtkWidget *menuitem;
1147         GtkWidget *recvatgetall_chkbtn;
1148
1149         GtkWidget *hbox2;
1150         GtkWidget *frame2;
1151         GtkWidget *label_maxarticle;
1152         GtkWidget *spinbtn_maxarticle;
1153         GtkObject *spinbtn_maxarticle_adj;
1154
1155         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1156         gtk_widget_show (vbox1);
1157         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1158         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1159
1160         PACK_FRAME (vbox1, frame1, _("POP3"));
1161
1162         vbox2 = gtk_vbox_new (FALSE, 0);
1163         gtk_widget_show (vbox2);
1164         gtk_container_add (GTK_CONTAINER (frame1), vbox2);
1165         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1166
1167         PACK_CHECK_BUTTON (vbox2, use_apop_chkbtn,
1168                            _("Use secure authentication (APOP)"));
1169
1170         PACK_CHECK_BUTTON (vbox2, rmmail_chkbtn,
1171                            _("Remove messages on server when received"));
1172
1173         hbox1 = gtk_hbox_new (FALSE, 8);
1174         gtk_widget_show (hbox1);
1175         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1176
1177         hbox_spc = gtk_hbox_new (FALSE, 0);
1178         gtk_widget_show (hbox_spc);
1179         gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1180         gtk_widget_set_size_request (hbox_spc, 12, -1);
1181
1182         leave_time_label = gtk_label_new (_("Remove after"));
1183         gtk_widget_show (leave_time_label);
1184         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1185
1186         leave_time_entry = gtk_entry_new ();
1187         gtk_widget_show (leave_time_entry);
1188         gtk_widget_set_size_request (leave_time_entry, 64, -1);
1189         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_entry, FALSE, FALSE, 0);
1190
1191         leave_time_label = gtk_label_new (_("days"));
1192         gtk_widget_show (leave_time_label);
1193         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1194
1195         SET_TOGGLE_SENSITIVITY (rmmail_chkbtn, hbox1);
1196
1197         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1198
1199         hbox1 = gtk_hbox_new (FALSE, 8);
1200         gtk_widget_show (hbox1);
1201         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1202
1203         hbox_spc = gtk_hbox_new (FALSE, 0);
1204         gtk_widget_show (hbox_spc);
1205         gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1206         gtk_widget_set_size_request (hbox_spc, 12, -1);
1207
1208         leave_time_label = gtk_label_new (_("(0 days: remove immediately)"));
1209         gtk_widget_show (leave_time_label);
1210         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1211
1212         SET_TOGGLE_SENSITIVITY (rmmail_chkbtn, hbox1);
1213
1214         PACK_CHECK_BUTTON (vbox2, getall_chkbtn,
1215                            _("Download all messages on server"));
1216
1217         hbox1 = gtk_hbox_new (FALSE, 8);
1218         gtk_widget_show (hbox1);
1219         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1220
1221         PACK_CHECK_BUTTON (hbox1, size_limit_chkbtn, _("Receive size limit"));
1222
1223         size_limit_entry = gtk_entry_new ();
1224         gtk_widget_show (size_limit_entry);
1225         gtk_widget_set_size_request (size_limit_entry, 64, -1);
1226         gtk_box_pack_start (GTK_BOX (hbox1), size_limit_entry, FALSE, FALSE, 0);
1227
1228         label = gtk_label_new (_("KB"));
1229         gtk_widget_show (label);
1230         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1231
1232         SET_TOGGLE_SENSITIVITY (size_limit_chkbtn, size_limit_entry);
1233
1234         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1235
1236         hbox1 = gtk_hbox_new (FALSE, 8);
1237         gtk_widget_show (hbox1);
1238         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1239
1240         inbox_label = gtk_label_new (_("Default inbox"));
1241         gtk_widget_show (inbox_label);
1242         gtk_box_pack_start (GTK_BOX (hbox1), inbox_label, FALSE, FALSE, 0);
1243
1244         inbox_entry = gtk_entry_new ();
1245         gtk_widget_show (inbox_entry);
1246         gtk_widget_set_size_request (inbox_entry, DEFAULT_ENTRY_WIDTH, -1);
1247         gtk_box_pack_start (GTK_BOX (hbox1), inbox_entry, TRUE, TRUE, 0);
1248
1249         inbox_btn = gtk_button_new_with_label (_(" Select... "));
1250         gtk_widget_show (inbox_btn);
1251         gtk_box_pack_start (GTK_BOX (hbox1), inbox_btn, FALSE, FALSE, 0);
1252         g_signal_connect (G_OBJECT (inbox_btn), "clicked",
1253                           G_CALLBACK (prefs_account_select_folder_cb),
1254                           inbox_entry);
1255
1256         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1257
1258         hbox1 = gtk_hbox_new (FALSE, 8);
1259         gtk_widget_show (hbox1);
1260         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1261
1262         label = gtk_label_new
1263                 (_("(Unfiltered messages will be stored in this folder)"));
1264         gtk_widget_show (label);
1265         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1266         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1267
1268         PACK_FRAME(vbox1, frame2, _("Maximum number of articles to download"));
1269
1270         hbox2 = gtk_hbox_new (FALSE, 8);
1271         gtk_widget_show (hbox2);
1272         gtk_container_add (GTK_CONTAINER (frame2), hbox2);
1273         gtk_container_set_border_width (GTK_CONTAINER (hbox2), 8);
1274
1275         spinbtn_maxarticle_adj =
1276                 gtk_adjustment_new (300, 0, 10000, 10, 100, 100);
1277         spinbtn_maxarticle = gtk_spin_button_new
1278                 (GTK_ADJUSTMENT (spinbtn_maxarticle_adj), 10, 0);
1279         gtk_widget_show (spinbtn_maxarticle);
1280         gtk_box_pack_start (GTK_BOX (hbox2), spinbtn_maxarticle,
1281                             FALSE, FALSE, 0);
1282         gtk_widget_set_size_request (spinbtn_maxarticle, 64, -1);
1283         gtk_spin_button_set_numeric
1284                 (GTK_SPIN_BUTTON (spinbtn_maxarticle), TRUE);
1285
1286         label_maxarticle = gtk_label_new
1287                 (_("unlimited if 0 is specified"));
1288         gtk_widget_show (label_maxarticle);
1289         gtk_box_pack_start (GTK_BOX (hbox2), label_maxarticle, FALSE, FALSE, 0);
1290         gtk_label_set_justify (GTK_LABEL (label_maxarticle), GTK_JUSTIFY_LEFT);
1291
1292         PACK_FRAME (vbox1, imap_frame, _("IMAP4"));
1293
1294         vbox2 = gtk_vbox_new (FALSE, 0);
1295         gtk_widget_show (vbox2);
1296         gtk_container_add (GTK_CONTAINER (imap_frame), vbox2);
1297         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1298
1299         hbox1 = gtk_hbox_new (FALSE, 8);
1300         gtk_widget_show (hbox1);
1301         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1302
1303         label = gtk_label_new (_("Authentication method"));
1304         gtk_widget_show (label);
1305         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1306
1307         optmenu = gtk_option_menu_new ();
1308         gtk_widget_show (optmenu);
1309         gtk_box_pack_start (GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
1310
1311         optmenu_menu = gtk_menu_new ();
1312
1313         MENUITEM_ADD (optmenu_menu, menuitem, _("Automatic"), 0);
1314         MENUITEM_ADD (optmenu_menu, menuitem, "LOGIN", IMAP_AUTH_LOGIN);
1315         MENUITEM_ADD (optmenu_menu, menuitem, "CRAM-MD5", IMAP_AUTH_CRAM_MD5);
1316
1317         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
1318
1319         PACK_CHECK_BUTTON (vbox1, filter_on_recv_chkbtn,
1320                            _("Filter messages on receiving"));
1321
1322         PACK_CHECK_BUTTON
1323                 (vbox1, recvatgetall_chkbtn,
1324                  _("`Get all' checks for new messages on this account"));
1325
1326         receive.pop3_frame               = frame1;
1327         receive.use_apop_chkbtn          = use_apop_chkbtn;
1328         receive.rmmail_chkbtn            = rmmail_chkbtn;
1329         receive.leave_time_entry         = leave_time_entry;
1330         receive.getall_chkbtn            = getall_chkbtn;
1331         receive.size_limit_chkbtn        = size_limit_chkbtn;
1332         receive.size_limit_entry         = size_limit_entry;
1333         receive.filter_on_recv_chkbtn    = filter_on_recv_chkbtn;
1334         receive.inbox_label              = inbox_label;
1335         receive.inbox_entry              = inbox_entry;
1336         receive.inbox_btn                = inbox_btn;
1337
1338         receive.imap_frame               = imap_frame;
1339         receive.imap_auth_type_optmenu   = optmenu;
1340
1341         receive.recvatgetall_chkbtn      = recvatgetall_chkbtn;
1342
1343         receive.frame_maxarticle        = frame2;
1344         receive.spinbtn_maxarticle      = spinbtn_maxarticle;
1345         receive.spinbtn_maxarticle_adj  = spinbtn_maxarticle_adj;
1346 }
1347
1348 static void prefs_account_send_create(void)
1349 {
1350         GtkWidget *vbox1;
1351         GtkWidget *vbox2;
1352         GtkWidget *frame;
1353         GtkWidget *date_chkbtn;
1354         GtkWidget *msgid_chkbtn;
1355         GtkWidget *hbox;
1356         GtkWidget *customhdr_chkbtn;
1357         GtkWidget *customhdr_edit_btn;
1358         GtkWidget *vbox3;
1359         GtkWidget *smtp_auth_chkbtn;
1360         GtkWidget *optmenu;
1361         GtkWidget *optmenu_menu;
1362         GtkWidget *menuitem;
1363         GtkWidget *vbox4;
1364         GtkWidget *hbox_spc;
1365         GtkWidget *label;
1366         GtkWidget *smtp_uid_entry;
1367         GtkWidget *smtp_pass_entry;
1368         GtkWidget *vbox_spc;
1369         GtkWidget *pop_bfr_smtp_chkbtn;
1370         GtkWidget *pop_bfr_smtp_tm_entry;
1371
1372         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1373         gtk_widget_show (vbox1);
1374         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1375         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1376
1377         PACK_FRAME (vbox1, frame, _("Header"));
1378
1379         vbox2 = gtk_vbox_new (FALSE, 0);
1380         gtk_widget_show (vbox2);
1381         gtk_container_add (GTK_CONTAINER (frame), vbox2);
1382         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1383
1384         PACK_CHECK_BUTTON (vbox2, date_chkbtn, _("Add Date"));
1385         PACK_CHECK_BUTTON (vbox2, msgid_chkbtn, _("Generate Message-ID"));
1386
1387         hbox = gtk_hbox_new (FALSE, 12);
1388         gtk_widget_show (hbox);
1389         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1390
1391         PACK_CHECK_BUTTON (hbox, customhdr_chkbtn,
1392                            _("Add user-defined header"));
1393
1394         customhdr_edit_btn = gtk_button_new_with_label (_(" Edit... "));
1395         gtk_widget_show (customhdr_edit_btn);
1396         gtk_box_pack_start (GTK_BOX (hbox), customhdr_edit_btn,
1397                             FALSE, FALSE, 0);
1398         g_signal_connect (G_OBJECT (customhdr_edit_btn), "clicked",
1399                           G_CALLBACK (prefs_account_edit_custom_header),
1400                           NULL);
1401
1402         SET_TOGGLE_SENSITIVITY (customhdr_chkbtn, customhdr_edit_btn);
1403
1404         PACK_FRAME (vbox1, frame, _("Authentication"));
1405
1406         vbox3 = gtk_vbox_new (FALSE, 0);
1407         gtk_widget_show (vbox3);
1408         gtk_container_add (GTK_CONTAINER (frame), vbox3);
1409         gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
1410
1411         PACK_CHECK_BUTTON (vbox3, smtp_auth_chkbtn,
1412                 _("SMTP Authentication (SMTP AUTH)"));
1413
1414         vbox4 = gtk_vbox_new (FALSE, 0);
1415         gtk_widget_show (vbox4);
1416         gtk_box_pack_start (GTK_BOX (vbox3), vbox4, FALSE, FALSE, 0);
1417
1418         hbox = gtk_hbox_new (FALSE, 8);
1419         gtk_widget_show (hbox);
1420         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1421
1422         hbox_spc = gtk_hbox_new (FALSE, 0);
1423         gtk_widget_show (hbox_spc);
1424         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1425         gtk_widget_set_size_request (hbox_spc, 12, -1);
1426
1427         label = gtk_label_new (_("Authentication method"));
1428         gtk_widget_show (label);
1429         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1430
1431         optmenu = gtk_option_menu_new ();
1432         gtk_widget_show (optmenu);
1433         gtk_box_pack_start (GTK_BOX (hbox), optmenu, FALSE, FALSE, 0);
1434
1435         optmenu_menu = gtk_menu_new ();
1436
1437         MENUITEM_ADD (optmenu_menu, menuitem, _("Automatic"), 0);
1438         MENUITEM_ADD (optmenu_menu, menuitem, "LOGIN", SMTPAUTH_LOGIN);
1439         MENUITEM_ADD (optmenu_menu, menuitem, "CRAM-MD5", SMTPAUTH_CRAM_MD5);
1440         MENUITEM_ADD (optmenu_menu, menuitem, "DIGEST-MD5", SMTPAUTH_DIGEST_MD5);
1441         gtk_widget_set_sensitive (menuitem, FALSE);
1442
1443         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
1444
1445         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1446
1447         hbox = gtk_hbox_new (FALSE, 8);
1448         gtk_widget_show (hbox);
1449         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1450
1451         hbox_spc = gtk_hbox_new (FALSE, 0);
1452         gtk_widget_show (hbox_spc);
1453         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1454         gtk_widget_set_size_request (hbox_spc, 12, -1);
1455
1456         label = gtk_label_new (_("User ID"));
1457         gtk_widget_show (label);
1458         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1459
1460         smtp_uid_entry = gtk_entry_new ();
1461         gtk_widget_show (smtp_uid_entry);
1462         gtk_widget_set_size_request (smtp_uid_entry, DEFAULT_ENTRY_WIDTH, -1);
1463         gtk_box_pack_start (GTK_BOX (hbox), smtp_uid_entry, TRUE, TRUE, 0);
1464
1465         label = gtk_label_new (_("Password"));
1466         gtk_widget_show (label);
1467         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1468
1469         smtp_pass_entry = gtk_entry_new ();
1470         gtk_widget_show (smtp_pass_entry);
1471         gtk_widget_set_size_request (smtp_pass_entry, DEFAULT_ENTRY_WIDTH, -1);
1472         gtk_box_pack_start (GTK_BOX (hbox), smtp_pass_entry, TRUE, TRUE, 0);
1473         gtk_entry_set_visibility (GTK_ENTRY (smtp_pass_entry), FALSE);
1474
1475         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1476
1477         hbox = gtk_hbox_new (FALSE, 8);
1478         gtk_widget_show (hbox);
1479         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1480
1481         hbox_spc = gtk_hbox_new (FALSE, 0);
1482         gtk_widget_show (hbox_spc);
1483         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1484         gtk_widget_set_size_request (hbox_spc, 12, -1);
1485
1486         label = gtk_label_new
1487                 (_("If you leave these entries empty, the same\n"
1488                    "user ID and password as receiving will be used."));
1489         gtk_widget_show (label);
1490         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1491         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1492
1493         SET_TOGGLE_SENSITIVITY (smtp_auth_chkbtn, vbox4);
1494
1495         PACK_CHECK_BUTTON (vbox3, pop_bfr_smtp_chkbtn,
1496                 _("Authenticate with POP3 before sending"));
1497         
1498         g_signal_connect (G_OBJECT (pop_bfr_smtp_chkbtn), "clicked",
1499                           G_CALLBACK (pop_bfr_smtp_tm_set_sens),
1500                           NULL);
1501
1502         hbox = gtk_hbox_new (FALSE, 8);
1503         gtk_widget_show (hbox);
1504         gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
1505
1506         hbox_spc = gtk_hbox_new (FALSE, 0);
1507         gtk_widget_show (hbox_spc);
1508         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1509         gtk_widget_set_size_request (hbox_spc, 12, -1);
1510
1511         label = gtk_label_new(_("POP authentication timeout: "));
1512         gtk_widget_show (label);
1513         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1514
1515         pop_bfr_smtp_tm_entry = gtk_entry_new ();
1516         gtk_widget_show (pop_bfr_smtp_tm_entry);
1517         gtk_widget_set_size_request (pop_bfr_smtp_tm_entry, 30, -1);
1518         gtk_box_pack_start (GTK_BOX (hbox), pop_bfr_smtp_tm_entry, FALSE, FALSE, 0);
1519
1520         label = gtk_label_new(_("minutes"));
1521         gtk_widget_show (label);
1522         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1523
1524
1525         
1526         p_send.date_chkbtn      = date_chkbtn;
1527         p_send.msgid_chkbtn     = msgid_chkbtn;
1528         p_send.customhdr_chkbtn = customhdr_chkbtn;
1529
1530         p_send.smtp_auth_chkbtn       = smtp_auth_chkbtn;
1531         p_send.smtp_auth_type_optmenu = optmenu;
1532         p_send.smtp_uid_entry         = smtp_uid_entry;
1533         p_send.smtp_pass_entry        = smtp_pass_entry;
1534         p_send.pop_bfr_smtp_chkbtn    = pop_bfr_smtp_chkbtn;
1535         p_send.pop_bfr_smtp_tm_entry  = pop_bfr_smtp_tm_entry;
1536 }
1537
1538 static void prefs_account_compose_create(void)
1539 {
1540         GtkWidget *vbox1;
1541         GtkWidget *sig_hbox;
1542         GtkWidget *hbox1;
1543         GtkWidget *hbox2;
1544         GtkWidget *frame_sig;
1545         GtkWidget *vbox_sig;
1546         GtkWidget *label_sigpath;
1547         GtkWidget *entry_sigpath;
1548         GtkWidget *checkbtn_autosig;
1549         GtkWidget *label_sigsep;
1550         GtkWidget *entry_sigsep;
1551         GtkWidget *sigfile_radiobtn;
1552         GtkWidget *sigcmd_radiobtn;
1553         GtkWidget *frame;
1554         GtkWidget *table;
1555         GtkWidget *autocc_chkbtn;
1556         GtkWidget *autocc_entry;
1557         GtkWidget *autobcc_chkbtn;
1558         GtkWidget *autobcc_entry;
1559         GtkWidget *autoreplyto_chkbtn;
1560         GtkWidget *autoreplyto_entry;
1561
1562         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1563         gtk_widget_show (vbox1);
1564         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1565         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1566
1567         PACK_FRAME(vbox1, frame_sig, _("Signature"));
1568
1569         vbox_sig = gtk_vbox_new (FALSE, VSPACING_NARROW);
1570         gtk_widget_show (vbox_sig);
1571         gtk_container_add (GTK_CONTAINER (frame_sig), vbox_sig);
1572         gtk_container_set_border_width (GTK_CONTAINER (vbox_sig), 8);
1573
1574         PACK_CHECK_BUTTON (vbox_sig, checkbtn_autosig,
1575                            _("Insert signature automatically"));
1576
1577         hbox1 = gtk_hbox_new (FALSE, 8);
1578         gtk_widget_show (hbox1);
1579         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox1, TRUE, TRUE, 0);
1580         label_sigsep = gtk_label_new (_("Signature separator"));
1581         gtk_widget_show (label_sigsep);
1582         gtk_box_pack_start (GTK_BOX (hbox1), label_sigsep, FALSE, FALSE, 0);
1583
1584         entry_sigsep = gtk_entry_new ();
1585         gtk_widget_show (entry_sigsep);
1586         gtk_box_pack_start (GTK_BOX (hbox1), entry_sigsep, FALSE, FALSE, 0);
1587
1588         gtk_widget_set_size_request (entry_sigsep, 64, -1);
1589
1590         sig_hbox = gtk_hbox_new (FALSE, 8);
1591         gtk_widget_show (sig_hbox);
1592         gtk_box_pack_start (GTK_BOX (vbox_sig), sig_hbox, FALSE, FALSE, 0);
1593
1594         sigfile_radiobtn = gtk_radio_button_new_with_label (NULL, _("File"));
1595         gtk_widget_show (sigfile_radiobtn);
1596         gtk_box_pack_start (GTK_BOX (sig_hbox), sigfile_radiobtn,
1597                             FALSE, FALSE, 0);
1598         g_object_set_data (G_OBJECT (sigfile_radiobtn),
1599                            MENU_VAL_ID,
1600                            GINT_TO_POINTER (SIG_FILE));
1601
1602         sigcmd_radiobtn = gtk_radio_button_new_with_label_from_widget
1603                 (GTK_RADIO_BUTTON(sigfile_radiobtn), _("Command output"));
1604         gtk_widget_show (sigcmd_radiobtn);
1605         gtk_box_pack_start (GTK_BOX (sig_hbox), sigcmd_radiobtn,
1606                             FALSE, FALSE, 0);
1607         g_object_set_data (G_OBJECT (sigcmd_radiobtn),
1608                            MENU_VAL_ID,
1609                            GINT_TO_POINTER (SIG_COMMAND));
1610
1611         hbox2 = gtk_hbox_new (FALSE, 8);
1612         gtk_widget_show (hbox2);
1613         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox2, TRUE, TRUE, 0);
1614         label_sigpath = gtk_label_new (_("Signature"));
1615         gtk_widget_show (label_sigpath);
1616         gtk_box_pack_start (GTK_BOX (hbox2), label_sigpath, FALSE, FALSE, 0);
1617
1618         entry_sigpath = gtk_entry_new ();
1619         gtk_widget_show (entry_sigpath);
1620         gtk_box_pack_start (GTK_BOX (hbox2), entry_sigpath, TRUE, TRUE, 0);
1621
1622         PACK_FRAME (vbox1, frame, _("Automatically set the following addresses"));
1623
1624         table =  gtk_table_new (3, 2, FALSE);
1625         gtk_widget_show (table);
1626         gtk_container_add (GTK_CONTAINER (frame), table);
1627         gtk_container_set_border_width (GTK_CONTAINER (table), 8);
1628         gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
1629         gtk_table_set_col_spacings (GTK_TABLE (table), 8);
1630
1631         autocc_chkbtn = gtk_check_button_new_with_label (_("Cc"));
1632         gtk_widget_show (autocc_chkbtn);
1633         gtk_table_attach (GTK_TABLE (table), autocc_chkbtn, 0, 1, 0, 1,
1634                           GTK_FILL, 0, 0, 0);
1635
1636         autocc_entry = gtk_entry_new ();
1637         gtk_widget_show (autocc_entry);
1638         gtk_table_attach (GTK_TABLE (table), autocc_entry, 1, 2, 0, 1,
1639                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1640                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1641
1642         SET_TOGGLE_SENSITIVITY (autocc_chkbtn, autocc_entry);
1643
1644         autobcc_chkbtn = gtk_check_button_new_with_label (_("Bcc"));
1645         gtk_widget_show (autobcc_chkbtn);
1646         gtk_table_attach (GTK_TABLE (table), autobcc_chkbtn, 0, 1, 1, 2,
1647                           GTK_FILL, 0, 0, 0);
1648
1649         autobcc_entry = gtk_entry_new ();
1650         gtk_widget_show (autobcc_entry);
1651         gtk_table_attach (GTK_TABLE (table), autobcc_entry, 1, 2, 1, 2,
1652                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1653                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1654
1655         SET_TOGGLE_SENSITIVITY (autobcc_chkbtn, autobcc_entry);
1656
1657         autoreplyto_chkbtn = gtk_check_button_new_with_label (_("Reply-To"));
1658         gtk_widget_show (autoreplyto_chkbtn);
1659         gtk_table_attach (GTK_TABLE (table), autoreplyto_chkbtn, 0, 1, 2, 3,
1660                           GTK_FILL, 0, 0, 0);
1661
1662         autoreplyto_entry = gtk_entry_new ();
1663         gtk_widget_show (autoreplyto_entry);
1664         gtk_table_attach (GTK_TABLE (table), autoreplyto_entry, 1, 2, 2, 3,
1665                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1666                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1667
1668         SET_TOGGLE_SENSITIVITY (autoreplyto_chkbtn, autoreplyto_entry);
1669
1670         compose.sigfile_radiobtn = sigfile_radiobtn;
1671         compose.entry_sigpath      = entry_sigpath;
1672         compose.checkbtn_autosig   = checkbtn_autosig;
1673         compose.entry_sigsep       = entry_sigsep;
1674
1675         compose.autocc_chkbtn      = autocc_chkbtn;
1676         compose.autocc_entry       = autocc_entry;
1677         compose.autobcc_chkbtn     = autobcc_chkbtn;
1678         compose.autobcc_entry      = autobcc_entry;
1679         compose.autoreplyto_chkbtn = autoreplyto_chkbtn;
1680         compose.autoreplyto_entry  = autoreplyto_entry;
1681 }
1682
1683 static void prefs_account_privacy_create(void)
1684 {
1685         GtkWidget *vbox1;
1686         GtkWidget *vbox2;
1687         GtkWidget *hbox1;
1688         GtkWidget *label;
1689         GtkWidget *default_privacy_system;
1690         GtkWidget *default_encrypt_chkbtn;
1691         GtkWidget *default_sign_chkbtn;
1692
1693         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1694         gtk_widget_show (vbox1);
1695         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1696         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1697
1698         vbox2 = gtk_vbox_new (FALSE, 0);
1699         gtk_widget_show (vbox2);
1700         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1701
1702         hbox1 = gtk_hbox_new(FALSE, 8);
1703         gtk_widget_show (hbox1);
1704         gtk_container_add (GTK_CONTAINER(vbox2), hbox1);
1705
1706         label = gtk_label_new(_("Default privacy system"));
1707         gtk_widget_show(label);
1708         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1709
1710         default_privacy_system = gtk_option_menu_new();
1711         gtk_widget_show (default_privacy_system);
1712         gtk_box_pack_start (GTK_BOX(hbox1), default_privacy_system, TRUE, TRUE, 0);
1713
1714         PACK_CHECK_BUTTON (vbox2, default_encrypt_chkbtn,
1715                            _("Encrypt message by default"));
1716         PACK_CHECK_BUTTON (vbox2, default_sign_chkbtn,
1717                            _("Sign message by default"));
1718                             
1719         privacy.default_privacy_system = default_privacy_system;
1720         privacy.default_encrypt_chkbtn = default_encrypt_chkbtn;
1721         privacy.default_sign_chkbtn    = default_sign_chkbtn;
1722 }
1723
1724 #if USE_OPENSSL
1725
1726 #define CREATE_RADIO_BUTTON(box, btn, btn_p, label, data)               \
1727 {                                                                       \
1728         btn = gtk_radio_button_new_with_label_from_widget               \
1729                 (GTK_RADIO_BUTTON (btn_p), label);                      \
1730         gtk_widget_show (btn);                                          \
1731         gtk_box_pack_start (GTK_BOX (box), btn, FALSE, FALSE, 0);       \
1732         g_object_set_data (G_OBJECT (btn),                              \
1733                            MENU_VAL_ID,                                 \
1734                            GINT_TO_POINTER (data));                     \
1735 }
1736
1737 #define CREATE_RADIO_BUTTONS(box,                                       \
1738                              btn1, btn1_label, btn1_data,               \
1739                              btn2, btn2_label, btn2_data,               \
1740                              btn3, btn3_label, btn3_data)               \
1741 {                                                                       \
1742         btn1 = gtk_radio_button_new_with_label(NULL, btn1_label);       \
1743         gtk_widget_show (btn1);                                         \
1744         gtk_box_pack_start (GTK_BOX (box), btn1, FALSE, FALSE, 0);      \
1745         g_object_set_data (G_OBJECT (btn1),                             \
1746                            MENU_VAL_ID,                                 \
1747                            GINT_TO_POINTER (btn1_data));                \
1748                                                                         \
1749         CREATE_RADIO_BUTTON(box, btn2, btn1, btn2_label, btn2_data);    \
1750         CREATE_RADIO_BUTTON(box, btn3, btn1, btn3_label, btn3_data);    \
1751 }
1752
1753 static void prefs_account_ssl_create(void)
1754 {
1755         GtkWidget *vbox1;
1756
1757         GtkWidget *pop_frame;
1758         GtkWidget *vbox2;
1759         GtkWidget *pop_nossl_radiobtn;
1760         GtkWidget *pop_ssltunnel_radiobtn;
1761         GtkWidget *pop_starttls_radiobtn;
1762
1763         GtkWidget *imap_frame;
1764         GtkWidget *vbox3;
1765         GtkWidget *imap_nossl_radiobtn;
1766         GtkWidget *imap_ssltunnel_radiobtn;
1767         GtkWidget *imap_starttls_radiobtn;
1768
1769         GtkWidget *nntp_frame;
1770         GtkWidget *vbox4;
1771         GtkWidget *nntp_nossl_radiobtn;
1772         GtkWidget *nntp_ssltunnel_radiobtn;
1773
1774         GtkWidget *send_frame;
1775         GtkWidget *vbox5;
1776         GtkWidget *smtp_nossl_radiobtn;
1777         GtkWidget *smtp_ssltunnel_radiobtn;
1778         GtkWidget *smtp_starttls_radiobtn;
1779
1780         GtkWidget *vbox6;
1781         GtkWidget *use_nonblocking_ssl_chkbtn;
1782         GtkWidget *hbox;
1783         GtkWidget *hbox_spc;
1784         GtkWidget *label;
1785
1786         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1787         gtk_widget_show (vbox1);
1788         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1789         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1790
1791         PACK_FRAME (vbox1, pop_frame, _("POP3"));
1792         vbox2 = gtk_vbox_new (FALSE, 0);
1793         gtk_widget_show (vbox2);
1794         gtk_container_add (GTK_CONTAINER (pop_frame), vbox2);
1795         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1796
1797         CREATE_RADIO_BUTTONS(vbox2,
1798                              pop_nossl_radiobtn,
1799                              _("Don't use SSL"),
1800                              SSL_NONE,
1801                              pop_ssltunnel_radiobtn,
1802                              _("Use SSL for POP3 connection"),
1803                              SSL_TUNNEL,
1804                              pop_starttls_radiobtn,
1805                              _("Use STARTTLS command to start SSL session"),
1806                              SSL_STARTTLS);
1807
1808         PACK_FRAME (vbox1, imap_frame, _("IMAP4"));
1809         vbox3 = gtk_vbox_new (FALSE, 0);
1810         gtk_widget_show (vbox3);
1811         gtk_container_add (GTK_CONTAINER (imap_frame), vbox3);
1812         gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
1813
1814         CREATE_RADIO_BUTTONS(vbox3,
1815                              imap_nossl_radiobtn,
1816                              _("Don't use SSL"),
1817                              SSL_NONE,
1818                              imap_ssltunnel_radiobtn,
1819                              _("Use SSL for IMAP4 connection"),
1820                              SSL_TUNNEL,
1821                              imap_starttls_radiobtn,
1822                              _("Use STARTTLS command to start SSL session"),
1823                              SSL_STARTTLS);
1824
1825         PACK_FRAME (vbox1, nntp_frame, _("NNTP"));
1826         vbox4 = gtk_vbox_new (FALSE, 0);
1827         gtk_widget_show (vbox4);
1828         gtk_container_add (GTK_CONTAINER (nntp_frame), vbox4);
1829         gtk_container_set_border_width (GTK_CONTAINER (vbox4), 8);
1830
1831         nntp_nossl_radiobtn =
1832                 gtk_radio_button_new_with_label (NULL, _("Don't use SSL"));
1833         gtk_widget_show (nntp_nossl_radiobtn);
1834         gtk_box_pack_start (GTK_BOX (vbox4), nntp_nossl_radiobtn,
1835                             FALSE, FALSE, 0);
1836         g_object_set_data (G_OBJECT (nntp_nossl_radiobtn),
1837                            MENU_VAL_ID,
1838                            GINT_TO_POINTER (SSL_NONE));
1839
1840         CREATE_RADIO_BUTTON(vbox4, nntp_ssltunnel_radiobtn, nntp_nossl_radiobtn,
1841                             _("Use SSL for NNTP connection"), SSL_TUNNEL);
1842
1843         PACK_FRAME (vbox1, send_frame, _("Send (SMTP)"));
1844         vbox5 = gtk_vbox_new (FALSE, 0);
1845         gtk_widget_show (vbox5);
1846         gtk_container_add (GTK_CONTAINER (send_frame), vbox5);
1847         gtk_container_set_border_width (GTK_CONTAINER (vbox5), 8);
1848
1849         CREATE_RADIO_BUTTONS(vbox5,
1850                              smtp_nossl_radiobtn,
1851                              _("Don't use SSL (but, if necessary, use STARTTLS)"),
1852                              SSL_NONE,
1853                              smtp_ssltunnel_radiobtn,
1854                              _("Use SSL for SMTP connection"),
1855                              SSL_TUNNEL,
1856                              smtp_starttls_radiobtn,
1857                              _("Use STARTTLS command to start SSL session"),
1858                              SSL_STARTTLS);
1859
1860         vbox6 = gtk_vbox_new (FALSE, 0);
1861         gtk_widget_show (vbox6);
1862         gtk_box_pack_start (GTK_BOX (vbox1), vbox6, FALSE, FALSE, 0);
1863
1864         PACK_CHECK_BUTTON(vbox6, use_nonblocking_ssl_chkbtn,
1865                           _("Use non-blocking SSL"));
1866
1867         hbox = gtk_hbox_new (FALSE, 0);
1868         gtk_widget_show (hbox);
1869         gtk_box_pack_start (GTK_BOX (vbox6), hbox, FALSE, FALSE, 0);
1870
1871         hbox_spc = gtk_hbox_new (FALSE, 0);
1872         gtk_widget_show (hbox_spc);
1873         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1874         gtk_widget_set_size_request (hbox_spc, 16, -1);
1875
1876         label = gtk_label_new
1877                 (_("(Turn this off if you have SSL connection problems)"));
1878         gtk_widget_show (label);
1879         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1880
1881         ssl.pop_frame               = pop_frame;
1882         ssl.pop_nossl_radiobtn      = pop_nossl_radiobtn;
1883         ssl.pop_ssltunnel_radiobtn  = pop_ssltunnel_radiobtn;
1884         ssl.pop_starttls_radiobtn   = pop_starttls_radiobtn;
1885
1886         ssl.imap_frame              = imap_frame;
1887         ssl.imap_nossl_radiobtn     = imap_nossl_radiobtn;
1888         ssl.imap_ssltunnel_radiobtn = imap_ssltunnel_radiobtn;
1889         ssl.imap_starttls_radiobtn  = imap_starttls_radiobtn;
1890
1891         ssl.nntp_frame              = nntp_frame;
1892         ssl.nntp_nossl_radiobtn     = nntp_nossl_radiobtn;
1893         ssl.nntp_ssltunnel_radiobtn = nntp_ssltunnel_radiobtn;
1894
1895         ssl.send_frame              = send_frame;
1896         ssl.smtp_nossl_radiobtn     = smtp_nossl_radiobtn;
1897         ssl.smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn;
1898         ssl.smtp_starttls_radiobtn  = smtp_starttls_radiobtn;
1899
1900         ssl.use_nonblocking_ssl_chkbtn = use_nonblocking_ssl_chkbtn;
1901 }
1902
1903 #undef CREATE_RADIO_BUTTONS
1904 #undef CREATE_RADIO_BUTTON
1905 #endif /* USE_OPENSSL */
1906
1907 static void crosspost_color_toggled(void)
1908 {
1909         gboolean is_active;
1910
1911         is_active = gtk_toggle_button_get_active
1912                 (GTK_TOGGLE_BUTTON(advanced.crosspost_chkbtn));
1913         gtk_widget_set_sensitive(advanced.crosspost_colormenu, is_active);
1914 }
1915
1916 static void prefs_account_crosspost_set_data_from_colormenu(PrefParam *pparam)
1917 {
1918         GtkWidget *menu;
1919         GtkWidget *menuitem;
1920
1921         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(advanced.crosspost_colormenu));
1922         menuitem = gtk_menu_get_active(GTK_MENU(menu));
1923         *((gint *)pparam->data) = GPOINTER_TO_INT
1924                 (g_object_get_data(G_OBJECT(menuitem), "color"));
1925 }
1926
1927 static void prefs_account_crosspost_set_colormenu(PrefParam *pparam)
1928 {
1929         gint colorlabel = *((gint *)pparam->data);
1930         GtkOptionMenu *colormenu = GTK_OPTION_MENU(*pparam->widget);
1931         GtkWidget *menu;
1932         GtkWidget *menuitem;
1933
1934         gtk_option_menu_set_history(colormenu, colorlabel);
1935         menu = gtk_option_menu_get_menu(colormenu);
1936         menuitem = gtk_menu_get_active(GTK_MENU(menu));
1937         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
1938 }
1939
1940
1941 static void prefs_account_advanced_create(void)
1942 {
1943         GtkWidget *vbox1;
1944         GtkWidget *vbox2;
1945         GtkWidget *hbox1;
1946         GtkWidget *checkbtn_smtpport;
1947         GtkWidget *entry_smtpport;
1948         GtkWidget *hbox_popport;
1949         GtkWidget *checkbtn_popport;
1950         GtkWidget *entry_popport;
1951         GtkWidget *hbox_imapport;
1952         GtkWidget *checkbtn_imapport;
1953         GtkWidget *entry_imapport;
1954         GtkWidget *hbox_nntpport;
1955         GtkWidget *checkbtn_nntpport;
1956         GtkWidget *entry_nntpport;
1957         GtkWidget *checkbtn_domain;
1958         GtkWidget *entry_domain;
1959         GtkWidget *checkbtn_crosspost;
1960         GtkWidget *colormenu_crosspost;
1961         GtkWidget *menu;
1962         GtkWidget *checkbtn_tunnelcmd;
1963         GtkWidget *entry_tunnelcmd;
1964         GtkWidget *imapdir_label;
1965         GtkWidget *imapdir_entry;
1966         GtkWidget *folder_frame;
1967         GtkWidget *vbox3;
1968         GtkWidget *table;
1969         GtkWidget *sent_folder_chkbtn;
1970         GtkWidget *sent_folder_entry;
1971         GtkWidget *draft_folder_chkbtn;
1972         GtkWidget *draft_folder_entry;
1973         GtkWidget *trash_folder_chkbtn;
1974         GtkWidget *trash_folder_entry;
1975
1976 #define PACK_HBOX(hbox) \
1977         { \
1978         hbox = gtk_hbox_new (FALSE, 8); \
1979         gtk_widget_show (hbox); \
1980         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); \
1981         }
1982
1983 #define PACK_PORT_ENTRY(box, entry) \
1984         { \
1985         entry = gtk_entry_new (); \
1986         gtk_entry_set_max_length  (GTK_ENTRY(entry), 5); \
1987         gtk_widget_show (entry); \
1988         gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 0); \
1989         gtk_widget_set_size_request (entry, 64, -1); \
1990         }
1991
1992         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1993         gtk_widget_show (vbox1);
1994         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1995         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1996
1997         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW_2);
1998         gtk_widget_show (vbox2);
1999         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2000
2001         PACK_HBOX (hbox1);
2002         PACK_CHECK_BUTTON (hbox1, checkbtn_smtpport, _("Specify SMTP port"));
2003         PACK_PORT_ENTRY (hbox1, entry_smtpport);
2004         SET_TOGGLE_SENSITIVITY (checkbtn_smtpport, entry_smtpport);
2005
2006         PACK_HBOX (hbox_popport);
2007         PACK_CHECK_BUTTON (hbox_popport, checkbtn_popport,
2008                            _("Specify POP3 port"));
2009         PACK_PORT_ENTRY (hbox_popport, entry_popport);
2010         SET_TOGGLE_SENSITIVITY (checkbtn_popport, entry_popport);
2011
2012         PACK_HBOX (hbox_imapport);
2013         PACK_CHECK_BUTTON (hbox_imapport, checkbtn_imapport,
2014                            _("Specify IMAP4 port"));
2015         PACK_PORT_ENTRY (hbox_imapport, entry_imapport);
2016         SET_TOGGLE_SENSITIVITY (checkbtn_imapport, entry_imapport);
2017
2018         PACK_HBOX (hbox_nntpport);
2019         PACK_CHECK_BUTTON (hbox_nntpport, checkbtn_nntpport,
2020                            _("Specify NNTP port"));
2021         PACK_PORT_ENTRY (hbox_nntpport, entry_nntpport);
2022         SET_TOGGLE_SENSITIVITY (checkbtn_nntpport, entry_nntpport);
2023
2024         PACK_HBOX (hbox1);
2025         PACK_CHECK_BUTTON (hbox1, checkbtn_domain, _("Specify domain name"));
2026
2027         entry_domain = gtk_entry_new ();
2028         gtk_widget_show (entry_domain);
2029         gtk_box_pack_start (GTK_BOX (hbox1), entry_domain, TRUE, TRUE, 0);
2030         SET_TOGGLE_SENSITIVITY (checkbtn_domain, entry_domain);
2031
2032         
2033         PACK_HBOX (hbox1);
2034         PACK_CHECK_BUTTON (hbox1, checkbtn_tunnelcmd,
2035                            _("Use command to communicate with server"));
2036         entry_tunnelcmd = gtk_entry_new ();
2037         gtk_widget_show (entry_tunnelcmd);
2038         gtk_box_pack_start (GTK_BOX (hbox1), entry_tunnelcmd, TRUE, TRUE, 0);
2039         SET_TOGGLE_SENSITIVITY (checkbtn_tunnelcmd, entry_tunnelcmd);
2040
2041         PACK_HBOX (hbox1);
2042         PACK_CHECK_BUTTON (hbox1, checkbtn_crosspost, 
2043                            _("Mark cross-posted messages as read and color:"));
2044         g_signal_connect (G_OBJECT (checkbtn_crosspost), "toggled",
2045                           G_CALLBACK (crosspost_color_toggled),
2046                           NULL);
2047
2048         colormenu_crosspost = gtk_option_menu_new();
2049         gtk_widget_show (colormenu_crosspost);
2050         gtk_box_pack_start (GTK_BOX (hbox1), colormenu_crosspost, FALSE, FALSE, 0);
2051
2052         menu = colorlabel_create_color_menu();
2053         gtk_option_menu_set_menu (GTK_OPTION_MENU(colormenu_crosspost), menu);
2054         SET_TOGGLE_SENSITIVITY(checkbtn_crosspost, colormenu_crosspost);
2055
2056         PACK_HBOX (hbox1);
2057         imapdir_label = gtk_label_new (_("IMAP server directory"));
2058         gtk_widget_show (imapdir_label);
2059         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
2060
2061         imapdir_entry = gtk_entry_new();
2062         gtk_widget_show (imapdir_entry);
2063         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_entry, TRUE, TRUE, 0);
2064
2065 #undef PACK_HBOX
2066 #undef PACK_PORT_ENTRY
2067
2068         /* special folder setting (maybe these options are redundant) */
2069
2070         PACK_FRAME (vbox1, folder_frame, _("Folder"));
2071
2072         vbox3 = gtk_vbox_new (FALSE, 0);
2073         gtk_widget_show (vbox3);
2074         gtk_container_add (GTK_CONTAINER (folder_frame), vbox3);
2075         gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
2076
2077         table = gtk_table_new (3, 3, FALSE);
2078         gtk_widget_show (table);
2079         gtk_container_add (GTK_CONTAINER (vbox3), table);
2080         gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
2081         gtk_table_set_col_spacings (GTK_TABLE (table), 4);
2082
2083 #define SET_CHECK_BTN_AND_ENTRY(label, chkbtn, entry, n)                \
2084 {                                                                       \
2085         GtkWidget *button;                                              \
2086                                                                         \
2087         chkbtn = gtk_check_button_new_with_label (label);               \
2088         gtk_widget_show (chkbtn);                                       \
2089         gtk_table_attach (GTK_TABLE (table), chkbtn,                    \
2090                           0, 1, n, n + 1, GTK_FILL, 0, 0, 0);           \
2091                                                                         \
2092         entry = gtk_entry_new ();                                       \
2093         gtk_widget_show (entry);                                        \
2094         gtk_table_attach (GTK_TABLE (table), entry, 1, 2, n, n + 1,     \
2095                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,           \
2096                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);    \
2097                                                                         \
2098         button = gtk_button_new_with_label (_(" ... "));                \
2099         gtk_widget_show (button);                                       \
2100         gtk_table_attach (GTK_TABLE (table), button,                    \
2101                           2, 3, n, n + 1, GTK_FILL, 0, 0, 0);           \
2102         g_signal_connect                                                \
2103                 (G_OBJECT (button), "clicked",                  \
2104                  G_CALLBACK (prefs_account_select_folder_cb),           \
2105                  entry);                                                \
2106                                                                         \
2107         SET_TOGGLE_SENSITIVITY (chkbtn, entry);                         \
2108         SET_TOGGLE_SENSITIVITY (chkbtn, button);                        \
2109 }
2110
2111         SET_CHECK_BTN_AND_ENTRY(_("Put sent messages in"),
2112                                 sent_folder_chkbtn, sent_folder_entry, 0);
2113         SET_CHECK_BTN_AND_ENTRY(_("Put draft messages in"),
2114                                 draft_folder_chkbtn, draft_folder_entry, 1);
2115         SET_CHECK_BTN_AND_ENTRY(_("Put deleted messages in"),
2116                                 trash_folder_chkbtn, trash_folder_entry, 2);
2117
2118         advanced.smtpport_chkbtn        = checkbtn_smtpport;
2119         advanced.smtpport_entry         = entry_smtpport;
2120         advanced.popport_hbox           = hbox_popport;
2121         advanced.popport_chkbtn         = checkbtn_popport;
2122         advanced.popport_entry          = entry_popport;
2123         advanced.imapport_hbox          = hbox_imapport;
2124         advanced.imapport_chkbtn        = checkbtn_imapport;
2125         advanced.imapport_entry         = entry_imapport;
2126         advanced.nntpport_hbox          = hbox_nntpport;
2127         advanced.nntpport_chkbtn        = checkbtn_nntpport;
2128         advanced.nntpport_entry         = entry_nntpport;
2129         advanced.domain_chkbtn          = checkbtn_domain;
2130         advanced.domain_entry           = entry_domain;
2131         advanced.crosspost_chkbtn       = checkbtn_crosspost;
2132         advanced.crosspost_colormenu    = colormenu_crosspost;
2133
2134         advanced.tunnelcmd_chkbtn       = checkbtn_tunnelcmd;
2135         advanced.tunnelcmd_entry        = entry_tunnelcmd;
2136         advanced.imapdir_label          = imapdir_label;
2137         advanced.imapdir_entry          = imapdir_entry;
2138
2139         advanced.sent_folder_chkbtn  = sent_folder_chkbtn;
2140         advanced.sent_folder_entry   = sent_folder_entry;
2141         advanced.draft_folder_chkbtn = draft_folder_chkbtn;
2142         advanced.draft_folder_entry  = draft_folder_entry;
2143         advanced.trash_folder_chkbtn = trash_folder_chkbtn;
2144         advanced.trash_folder_entry  = trash_folder_entry;
2145 }
2146
2147 static gint prefs_account_deleted(GtkWidget *widget, GdkEventAny *event,
2148                                   gpointer data)
2149 {
2150         prefs_account_cancel();
2151         return TRUE;
2152 }
2153
2154 static gboolean prefs_account_key_pressed(GtkWidget *widget, GdkEventKey *event,
2155                                           gpointer data)
2156 {
2157         if (event && event->keyval == GDK_Escape)
2158                 prefs_account_cancel();
2159         return FALSE;
2160 }
2161
2162 static void prefs_account_ok(void)
2163 {
2164         if (prefs_account_apply() == 0)
2165                 gtk_main_quit();
2166 }
2167
2168 static gint prefs_account_apply(void)
2169 {
2170         RecvProtocol protocol;
2171         GtkWidget *menu;
2172         GtkWidget *menuitem;
2173
2174         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(basic.protocol_optmenu));
2175         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2176         protocol = GPOINTER_TO_INT
2177                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2178
2179         if (*gtk_entry_get_text(GTK_ENTRY(basic.acname_entry)) == '\0') {
2180                 alertpanel_error(_("Account name is not entered."));
2181                 return -1;
2182         }
2183         if (*gtk_entry_get_text(GTK_ENTRY(basic.addr_entry)) == '\0') {
2184                 alertpanel_error(_("Mail address is not entered."));
2185                 return -1;
2186         }
2187         if (((protocol == A_POP3) || 
2188              (protocol == A_LOCAL && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic.mailcmd_chkbtn))) || 
2189              (protocol == A_NONE)) &&
2190            *gtk_entry_get_text(GTK_ENTRY(basic.smtpserv_entry)) == '\0') {
2191                 alertpanel_error(_("SMTP server is not entered."));
2192                 return -1;
2193         }
2194         if ((protocol == A_POP3 || protocol == A_IMAP4) &&
2195             *gtk_entry_get_text(GTK_ENTRY(basic.uid_entry)) == '\0') {
2196                 alertpanel_error(_("User ID is not entered."));
2197                 return -1;
2198         }
2199         if (protocol == A_POP3 &&
2200             *gtk_entry_get_text(GTK_ENTRY(basic.recvserv_entry)) == '\0') {
2201                 alertpanel_error(_("POP3 server is not entered."));
2202                 return -1;
2203         }
2204         if (protocol == A_IMAP4 &&
2205             *gtk_entry_get_text(GTK_ENTRY(basic.recvserv_entry)) == '\0') {
2206                 alertpanel_error(_("IMAP4 server is not entered."));
2207                 return -1;
2208         }
2209         if (protocol == A_NNTP &&
2210             *gtk_entry_get_text(GTK_ENTRY(basic.nntpserv_entry)) == '\0') {
2211                 alertpanel_error(_("NNTP server is not entered."));
2212                 return -1;
2213         }
2214
2215         if (protocol == A_LOCAL &&
2216             *gtk_entry_get_text(GTK_ENTRY(basic.localmbox_entry)) == '\0') {
2217                 alertpanel_error(_("local mailbox filename is not entered."));
2218                 return -1;
2219         }
2220
2221         if (protocol == A_LOCAL &&
2222             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic.mailcmd_chkbtn)) && *gtk_entry_get_text(GTK_ENTRY(basic.mailcmd_entry)) == '\0') {
2223                 alertpanel_error(_("mail command is not entered."));
2224                 return -1;
2225         }
2226
2227         prefs_set_data_from_dialog(param);
2228         return 0;
2229 }
2230
2231 static void prefs_account_cancel(void)
2232 {
2233         cancelled = TRUE;
2234         gtk_main_quit();
2235 }
2236
2237 static void pop_bfr_smtp_tm_set_sens(GtkWidget *widget, gpointer data)
2238 {
2239         gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, 
2240                                  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_send.pop_bfr_smtp_chkbtn)));
2241 }
2242
2243 static void prefs_account_select_folder_cb(GtkWidget *widget, gpointer data)
2244 {
2245         FolderItem *item;
2246         gchar *id;
2247
2248         item = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
2249         if (item && item->path) {
2250                 id = folder_item_get_identifier(item);
2251                 if (id) {
2252                         gtk_entry_set_text(GTK_ENTRY(data), id);
2253                         g_free(id);
2254                 }
2255         }
2256 }
2257
2258 static void prefs_account_edit_custom_header(void)
2259 {
2260         prefs_custom_header_open(&tmp_ac_prefs);
2261 }
2262
2263 static void prefs_account_enum_set_data_from_radiobtn(PrefParam *pparam)
2264 {
2265         GtkRadioButton *radiobtn;
2266         GSList *group;
2267
2268         radiobtn = GTK_RADIO_BUTTON (*pparam->widget);
2269         group = gtk_radio_button_get_group (radiobtn);
2270         while (group != NULL) {
2271                 GtkToggleButton *btn = GTK_TOGGLE_BUTTON (group->data);
2272                 if (gtk_toggle_button_get_active (btn)) {
2273                         *((gint *)pparam->data) = GPOINTER_TO_INT
2274                                 (g_object_get_data (G_OBJECT (btn), MENU_VAL_ID));
2275                         break;
2276                 }
2277                 group = group->next;
2278         }
2279 }
2280
2281 static void prefs_account_enum_set_radiobtn(PrefParam *pparam)
2282 {
2283         GtkRadioButton *radiobtn;
2284         GSList *group;
2285         gpointer data;
2286
2287         data = GINT_TO_POINTER (*((gint *)pparam->data));
2288         radiobtn = GTK_RADIO_BUTTON (*pparam->widget);
2289         group = gtk_radio_button_get_group (radiobtn);
2290         while (group != NULL) {
2291                 GtkToggleButton *btn = GTK_TOGGLE_BUTTON (group->data);
2292                 gpointer data1 = g_object_get_data (G_OBJECT (btn), MENU_VAL_ID);
2293                 if (data1 == data) {
2294                         gtk_toggle_button_set_active (btn, TRUE);
2295                         break;
2296                 }
2297                 group = group->next;
2298         }
2299 }
2300
2301 static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam)
2302 {
2303         GtkWidget *menu;
2304         GtkWidget *menuitem;
2305
2306         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2307         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2308         *((RecvProtocol *)pparam->data) = GPOINTER_TO_INT
2309                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2310 }
2311
2312 static void prefs_account_protocol_set_optmenu(PrefParam *pparam)
2313 {
2314         RecvProtocol protocol;
2315         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2316         GtkWidget *menu;
2317         GtkWidget *menuitem;
2318         gint index;
2319
2320         protocol = *((RecvProtocol *)pparam->data);
2321         index = menu_find_option_menu_index
2322                 (optmenu, GINT_TO_POINTER(protocol), NULL);
2323         if (index < 0) return;
2324         gtk_option_menu_set_history(optmenu, index);
2325
2326         menu = gtk_option_menu_get_menu(optmenu);
2327         menu_set_insensitive_all(GTK_MENU_SHELL(menu));
2328
2329         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2330         gtk_widget_set_sensitive(menuitem, TRUE);
2331         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2332 }
2333
2334 static void prefs_account_imap_auth_type_set_data_from_optmenu(PrefParam *pparam)
2335 {
2336         GtkWidget *menu;
2337         GtkWidget *menuitem;
2338
2339         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2340         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2341         *((RecvProtocol *)pparam->data) = GPOINTER_TO_INT
2342                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2343 }
2344
2345 static void prefs_account_imap_auth_type_set_optmenu(PrefParam *pparam)
2346 {
2347         IMAPAuthType type = *((IMAPAuthType *)pparam->data);
2348         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2349         GtkWidget *menu;
2350         GtkWidget *menuitem;
2351
2352         switch (type) {
2353         case IMAP_AUTH_LOGIN:
2354                 gtk_option_menu_set_history(optmenu, 1);
2355                 break;
2356         case IMAP_AUTH_CRAM_MD5:
2357                 gtk_option_menu_set_history(optmenu, 2);
2358                 break;
2359         case 0:
2360         default:
2361                 gtk_option_menu_set_history(optmenu, 0);
2362         }
2363
2364         menu = gtk_option_menu_get_menu(optmenu);
2365         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2366         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2367 }
2368
2369 static void prefs_account_smtp_auth_type_set_data_from_optmenu(PrefParam *pparam)
2370 {
2371         GtkWidget *menu;
2372         GtkWidget *menuitem;
2373
2374         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2375         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2376         *((RecvProtocol *)pparam->data) = GPOINTER_TO_INT
2377                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2378 }
2379
2380 static void prefs_account_smtp_auth_type_set_optmenu(PrefParam *pparam)
2381 {
2382         SMTPAuthType type = *((SMTPAuthType *)pparam->data);
2383         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2384         GtkWidget *menu;
2385         GtkWidget *menuitem;
2386
2387         switch (type) {
2388         case SMTPAUTH_LOGIN:
2389                 gtk_option_menu_set_history(optmenu, 1);
2390                 break;
2391         case SMTPAUTH_CRAM_MD5:
2392                 gtk_option_menu_set_history(optmenu, 2);
2393                 break;
2394         case SMTPAUTH_DIGEST_MD5:
2395                 gtk_option_menu_set_history(optmenu, 3);
2396                 break;
2397         case 0:
2398         default:
2399                 gtk_option_menu_set_history(optmenu, 0);
2400         }
2401
2402         menu = gtk_option_menu_get_menu(optmenu);
2403         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2404         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2405 }
2406
2407 static void prefs_account_set_string_from_optmenu(PrefParam *pparam)
2408 {
2409         GtkWidget *menu;
2410         GtkWidget *menuitem;
2411         gchar **str;
2412
2413         g_return_if_fail(*pparam->widget != NULL);
2414
2415         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2416         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2417         if (menuitem == NULL)
2418                 return;
2419
2420         str = (gchar **) pparam->data;
2421         g_free(*str);
2422         *str = g_strdup(g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2423 }
2424
2425 static void prefs_account_set_optmenu_from_string(PrefParam *pparam)
2426 {
2427         GtkWidget *optionmenu;
2428         GtkWidget *menu;
2429         gboolean found = FALSE;
2430         GList *children, *cur;
2431         gchar *prefsid;
2432         guint i = 0;
2433
2434         g_return_if_fail(*pparam->widget != NULL);
2435
2436         prefsid = *((gchar **) pparam->data);
2437         if (prefsid == NULL)
2438                 return;
2439
2440         optionmenu = *pparam->widget;
2441         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optionmenu));
2442         children = gtk_container_children(GTK_CONTAINER(menu));
2443         for (cur = children; cur != NULL; cur = g_list_next(cur)) {
2444                 GtkWidget *item = (GtkWidget *) cur->data;
2445                 gchar *id;
2446
2447                 id = g_object_get_data(G_OBJECT(item), MENU_VAL_ID);
2448                 if (id != NULL && strcmp(id, prefsid) == 0) {
2449                         found = TRUE;
2450                         gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu), i);
2451                 }
2452                 i++;
2453         }
2454
2455         if (!found) {
2456                 gchar *name;
2457                 GtkWidget *menuitem;
2458
2459                 name = g_strdup_printf(_("Unsupported (%s)"), prefsid);
2460                 menuitem = gtk_menu_item_new_with_label(name);
2461                 gtk_widget_show(menuitem);
2462                 g_object_set_data_full(G_OBJECT(menuitem), MENU_VAL_ID, g_strdup(prefsid), g_free);
2463                 gtk_menu_append(GTK_MENU(menu), menuitem);
2464                 g_free(name);
2465
2466                 gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu), i);
2467         }
2468
2469         g_list_free(children);
2470 }
2471
2472 static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
2473 {
2474         RecvProtocol protocol;
2475
2476         protocol = GPOINTER_TO_INT
2477                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2478
2479         switch(protocol) {
2480         case A_NNTP:
2481                 gtk_widget_show(basic.nntpserv_label);
2482                 gtk_widget_show(basic.nntpserv_entry);
2483                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2484                                            0, VSPACING_NARROW);
2485
2486                 gtk_widget_set_sensitive(basic.nntpauth_chkbtn, TRUE);
2487                 gtk_widget_show(basic.nntpauth_chkbtn);
2488
2489                 gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, TRUE);
2490                 gtk_widget_show(basic.nntpauth_onconnect_chkbtn);
2491
2492                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2493                                            1, VSPACING_NARROW);
2494                 gtk_widget_hide(basic.recvserv_label);
2495                 gtk_widget_hide(basic.recvserv_entry);
2496                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2497                                            2, 0);
2498                 gtk_widget_show(basic.smtpserv_label);
2499                 gtk_widget_show(basic.smtpserv_entry);
2500                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2501                                            4, VSPACING_NARROW);
2502                 gtk_widget_hide(basic.localmbox_label);
2503                 gtk_widget_hide(basic.localmbox_entry);
2504                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2505                                            3, 0);
2506                 gtk_widget_hide(basic.mailcmd_label);
2507                 gtk_widget_hide(basic.mailcmd_entry);
2508                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2509                                            6, 0);
2510                 gtk_widget_hide(basic.mailcmd_chkbtn);
2511                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2512                                            5, 0);
2513                 gtk_widget_show(basic.uid_label);
2514                 gtk_widget_show(basic.pass_label);
2515                 gtk_widget_show(basic.uid_entry);
2516                 gtk_widget_show(basic.pass_entry);
2517                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2518                                            7, VSPACING_NARROW);
2519
2520                 gtk_widget_set_sensitive(basic.uid_label,  TRUE);
2521                 gtk_widget_set_sensitive(basic.pass_label, TRUE);
2522                 gtk_widget_set_sensitive(basic.uid_entry,  TRUE);
2523                 gtk_widget_set_sensitive(basic.pass_entry, TRUE);
2524
2525                 /* update userid/passwd sensitive state */
2526
2527                 prefs_account_nntpauth_toggled
2528                         (GTK_TOGGLE_BUTTON(basic.nntpauth_chkbtn), NULL);
2529                 gtk_widget_hide(receive.pop3_frame);
2530                 gtk_widget_hide(receive.imap_frame);
2531                 gtk_widget_show(receive.frame_maxarticle);
2532                 gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, TRUE);
2533                 /* update pop_before_smtp sensitivity */
2534                 gtk_toggle_button_set_active
2535                         (GTK_TOGGLE_BUTTON(p_send.pop_bfr_smtp_chkbtn), FALSE);
2536                 gtk_widget_set_sensitive(p_send.pop_bfr_smtp_chkbtn, FALSE);
2537                 gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, FALSE);
2538                 
2539                 if (!tmp_ac_prefs.account_name) {
2540                         gtk_toggle_button_set_active
2541                                 (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn),
2542                                  FALSE);
2543                 }
2544
2545 #if USE_OPENSSL
2546                 gtk_widget_hide(ssl.pop_frame);
2547                 gtk_widget_hide(ssl.imap_frame);
2548                 gtk_widget_show(ssl.nntp_frame);
2549                 gtk_widget_hide(ssl.send_frame);
2550 #endif
2551                 gtk_widget_hide(advanced.popport_hbox);
2552                 gtk_widget_hide(advanced.imapport_hbox);
2553                 gtk_widget_show(advanced.nntpport_hbox);
2554                 gtk_widget_show(advanced.crosspost_chkbtn);
2555                 gtk_widget_show(advanced.crosspost_colormenu);
2556                 gtk_widget_hide(advanced.tunnelcmd_chkbtn);
2557                 gtk_widget_hide(advanced.tunnelcmd_entry);
2558                 gtk_widget_hide(advanced.imapdir_label);
2559                 gtk_widget_hide(advanced.imapdir_entry);
2560                 break;
2561         case A_LOCAL:
2562                 gtk_widget_hide(basic.nntpserv_label);
2563                 gtk_widget_hide(basic.nntpserv_entry);
2564                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2565                                            0, 0);
2566                 gtk_widget_set_sensitive(basic.nntpauth_chkbtn, FALSE);
2567                 gtk_widget_hide(basic.nntpauth_chkbtn);
2568
2569                 gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, FALSE);
2570                 gtk_widget_hide(basic.nntpauth_onconnect_chkbtn);
2571                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2572                                            1, 0);
2573                 gtk_widget_hide(basic.recvserv_label);
2574                 gtk_widget_hide(basic.recvserv_entry);
2575                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2576                                            2, 0);
2577                 gtk_widget_show(basic.smtpserv_label);
2578                 gtk_widget_show(basic.smtpserv_entry);
2579                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2580                                            4, VSPACING_NARROW);
2581                 gtk_widget_show(basic.localmbox_label);
2582                 gtk_widget_show(basic.localmbox_entry);
2583                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2584                                            3, VSPACING_NARROW);
2585                 gtk_widget_show(basic.mailcmd_label);
2586                 gtk_widget_show(basic.mailcmd_entry);
2587                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2588                                            6, VSPACING_NARROW);
2589                 gtk_widget_show(basic.mailcmd_chkbtn);
2590                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2591                                            5, VSPACING_NARROW);
2592                 gtk_widget_hide(basic.uid_label);
2593                 gtk_widget_hide(basic.pass_label);
2594                 gtk_widget_hide(basic.uid_entry);
2595                 gtk_widget_hide(basic.pass_entry);
2596                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2597                                            7, 0);
2598
2599                 gtk_widget_set_sensitive(basic.uid_label,  TRUE);
2600                 gtk_widget_set_sensitive(basic.pass_label, TRUE);
2601                 gtk_widget_set_sensitive(basic.uid_entry,  TRUE);
2602                 gtk_widget_set_sensitive(basic.pass_entry, TRUE);
2603                 gtk_widget_hide(receive.pop3_frame);
2604                 gtk_widget_hide(receive.imap_frame);
2605                 gtk_widget_hide(receive.frame_maxarticle);
2606                 gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, TRUE);
2607                 prefs_account_mailcmd_toggled
2608                         (GTK_TOGGLE_BUTTON(basic.mailcmd_chkbtn), NULL);
2609
2610                 /* update pop_before_smtp sensitivity */
2611                 gtk_toggle_button_set_active
2612                         (GTK_TOGGLE_BUTTON(p_send.pop_bfr_smtp_chkbtn), FALSE);
2613                 gtk_widget_set_sensitive(p_send.pop_bfr_smtp_chkbtn, FALSE);
2614                 gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, FALSE);
2615
2616                 if (!tmp_ac_prefs.account_name) {
2617                         gtk_toggle_button_set_active
2618                                 (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn),
2619                                  TRUE);
2620                 }
2621
2622 #if USE_OPENSSL
2623                 gtk_widget_hide(ssl.pop_frame);
2624                 gtk_widget_hide(ssl.imap_frame);
2625                 gtk_widget_hide(ssl.nntp_frame);
2626                 gtk_widget_show(ssl.send_frame);
2627 #endif
2628                 gtk_widget_hide(advanced.popport_hbox);
2629                 gtk_widget_hide(advanced.imapport_hbox);
2630                 gtk_widget_hide(advanced.nntpport_hbox);
2631                 gtk_widget_hide(advanced.crosspost_chkbtn);
2632                 gtk_widget_hide(advanced.crosspost_colormenu);
2633                 gtk_widget_hide(advanced.tunnelcmd_chkbtn);
2634                 gtk_widget_hide(advanced.tunnelcmd_entry);
2635                 gtk_widget_hide(advanced.imapdir_label);
2636                 gtk_widget_hide(advanced.imapdir_entry);
2637                 break;
2638         case A_IMAP4:
2639                 gtk_widget_hide(basic.nntpserv_label);
2640                 gtk_widget_hide(basic.nntpserv_entry);
2641                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2642                                            0, 0);
2643                 gtk_widget_set_sensitive(basic.nntpauth_chkbtn, FALSE);
2644                 gtk_widget_hide(basic.nntpauth_chkbtn);
2645
2646                 gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, FALSE);
2647                 gtk_widget_hide(basic.nntpauth_onconnect_chkbtn);
2648
2649                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2650                                            1, 0);
2651                 gtk_widget_set_sensitive(basic.recvserv_label, TRUE);
2652                 gtk_widget_set_sensitive(basic.recvserv_entry, TRUE);
2653                 gtk_widget_show(basic.recvserv_label);
2654                 gtk_widget_show(basic.recvserv_entry);
2655                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2656                                            2, VSPACING_NARROW);
2657                 gtk_widget_show(basic.smtpserv_label);
2658                 gtk_widget_show(basic.smtpserv_entry);
2659                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2660                                            4, VSPACING_NARROW);
2661                 gtk_widget_hide(basic.localmbox_label);
2662                 gtk_widget_hide(basic.localmbox_entry);
2663                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2664                                            3, 0);
2665                 gtk_widget_hide(basic.mailcmd_label);
2666                 gtk_widget_hide(basic.mailcmd_entry);
2667                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2668                                            6, 0);
2669                 gtk_widget_hide(basic.mailcmd_chkbtn);
2670                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2671                                            5, 0);
2672                 gtk_widget_show(basic.uid_label);
2673                 gtk_widget_show(basic.pass_label);
2674                 gtk_widget_show(basic.uid_entry);
2675                 gtk_widget_show(basic.pass_entry);
2676                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2677                                            7, VSPACING_NARROW);
2678
2679                 gtk_widget_set_sensitive(basic.uid_label,  TRUE);
2680                 gtk_widget_set_sensitive(basic.pass_label, TRUE);
2681                 gtk_widget_set_sensitive(basic.uid_entry,  TRUE);
2682                 gtk_widget_set_sensitive(basic.pass_entry, TRUE);
2683                 gtk_widget_hide(receive.pop3_frame);
2684                 gtk_widget_show(receive.imap_frame);
2685                 gtk_widget_hide(receive.frame_maxarticle);
2686                 gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, TRUE);
2687                 gtk_widget_set_sensitive(basic.smtpserv_entry, TRUE);
2688                 gtk_widget_set_sensitive(basic.smtpserv_label, TRUE);
2689
2690                 /* update pop_before_smtp sensitivity */
2691                 gtk_toggle_button_set_active
2692                         (GTK_TOGGLE_BUTTON(p_send.pop_bfr_smtp_chkbtn), FALSE);
2693                 gtk_widget_set_sensitive(p_send.pop_bfr_smtp_chkbtn, FALSE);
2694                 gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, FALSE);
2695
2696                 if (!tmp_ac_prefs.account_name) {
2697                         gtk_toggle_button_set_active
2698                                 (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn),
2699                                  FALSE);
2700                 }
2701
2702 #if USE_OPENSSL
2703                 gtk_widget_hide(ssl.pop_frame);
2704                 gtk_widget_show(ssl.imap_frame);
2705                 gtk_widget_hide(ssl.nntp_frame);
2706                 gtk_widget_show(ssl.send_frame);
2707 #endif
2708                 gtk_widget_hide(advanced.popport_hbox);
2709                 gtk_widget_show(advanced.imapport_hbox);
2710                 gtk_widget_hide(advanced.nntpport_hbox);
2711                 gtk_widget_hide(advanced.crosspost_chkbtn);
2712                 gtk_widget_hide(advanced.crosspost_colormenu);
2713                 gtk_widget_show(advanced.tunnelcmd_chkbtn);
2714                 gtk_widget_show(advanced.tunnelcmd_entry);
2715                 gtk_widget_show(advanced.imapdir_label);
2716                 gtk_widget_show(advanced.imapdir_entry);
2717                 break;
2718         case A_NONE:
2719                 gtk_widget_hide(basic.nntpserv_label);
2720                 gtk_widget_hide(basic.nntpserv_entry);
2721                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2722                                            0, 0);
2723                 gtk_widget_set_sensitive(basic.nntpauth_chkbtn, FALSE);
2724                 gtk_widget_hide(basic.nntpauth_chkbtn);
2725
2726                 gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, FALSE);
2727                 gtk_widget_hide(basic.nntpauth_onconnect_chkbtn);
2728
2729                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2730                                            1, 0);
2731                 gtk_widget_set_sensitive(basic.recvserv_label, FALSE);
2732                 gtk_widget_set_sensitive(basic.recvserv_entry, FALSE);
2733                 gtk_widget_hide(basic.recvserv_label);
2734                 gtk_widget_hide(basic.recvserv_entry);
2735                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2736                                            2, VSPACING_NARROW);
2737                 gtk_widget_show(basic.smtpserv_label);
2738                 gtk_widget_show(basic.smtpserv_entry);
2739                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2740                                            4, VSPACING_NARROW);
2741                 gtk_widget_hide(basic.localmbox_label);
2742                 gtk_widget_hide(basic.localmbox_entry);
2743                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2744                                            3, 0);
2745                 gtk_widget_hide(basic.mailcmd_label);
2746                 gtk_widget_hide(basic.mailcmd_entry);
2747                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2748                                            6, 0);
2749                 gtk_widget_hide(basic.mailcmd_chkbtn);
2750                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2751                                            5, 0);
2752                 gtk_widget_hide(basic.uid_label);
2753                 gtk_widget_hide(basic.pass_label);
2754                 gtk_widget_hide(basic.uid_entry);
2755                 gtk_widget_hide(basic.pass_entry);
2756                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2757                                            7, VSPACING_NARROW);
2758
2759                 gtk_widget_set_sensitive(basic.uid_label,  FALSE);
2760                 gtk_widget_set_sensitive(basic.pass_label, FALSE);
2761                 gtk_widget_set_sensitive(basic.uid_entry,  FALSE);
2762                 gtk_widget_set_sensitive(basic.pass_entry, FALSE);
2763                 gtk_widget_set_sensitive(receive.pop3_frame, FALSE);
2764                 gtk_widget_hide(receive.pop3_frame);
2765                 gtk_widget_hide(receive.imap_frame);
2766                 gtk_widget_hide(receive.frame_maxarticle);
2767                 gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, FALSE);
2768
2769                 gtk_widget_set_sensitive(basic.smtpserv_entry, TRUE);
2770                 gtk_widget_set_sensitive(basic.smtpserv_label, TRUE);
2771
2772                 /* update pop_before_smtp sensitivity */
2773                 gtk_widget_set_sensitive(p_send.pop_bfr_smtp_chkbtn, FALSE);
2774                 pop_bfr_smtp_tm_set_sens(NULL, NULL);
2775                 
2776                 gtk_toggle_button_set_active
2777                         (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn), FALSE);
2778
2779 #if USE_OPENSSL
2780                 gtk_widget_hide(ssl.pop_frame);
2781                 gtk_widget_hide(ssl.imap_frame);
2782                 gtk_widget_hide(ssl.nntp_frame);
2783                 gtk_widget_show(ssl.send_frame);
2784 #endif
2785                 gtk_widget_hide(advanced.popport_hbox);
2786                 gtk_widget_hide(advanced.imapport_hbox);
2787                 gtk_widget_hide(advanced.nntpport_hbox);
2788                 gtk_widget_hide(advanced.crosspost_chkbtn);
2789                 gtk_widget_hide(advanced.crosspost_colormenu);
2790                 gtk_widget_hide(advanced.tunnelcmd_chkbtn);
2791                 gtk_widget_hide(advanced.tunnelcmd_entry);
2792                 gtk_widget_hide(advanced.imapdir_label);
2793                 gtk_widget_hide(advanced.imapdir_entry);
2794                 break;
2795         case A_POP3:
2796         default:
2797                 gtk_widget_hide(basic.nntpserv_label);
2798                 gtk_widget_hide(basic.nntpserv_entry);
2799                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2800                                            0, 0);
2801                 gtk_widget_set_sensitive(basic.nntpauth_chkbtn, FALSE);
2802                 gtk_widget_hide(basic.nntpauth_chkbtn);
2803
2804                 gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, FALSE);
2805                 gtk_widget_hide(basic.nntpauth_onconnect_chkbtn);
2806
2807                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2808                                            1, 0);
2809                 gtk_widget_set_sensitive(basic.recvserv_label, TRUE);
2810                 gtk_widget_set_sensitive(basic.recvserv_entry, TRUE);
2811                 gtk_widget_show(basic.recvserv_label);
2812                 gtk_widget_show(basic.recvserv_entry);
2813                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2814                                            2, VSPACING_NARROW);
2815                 gtk_widget_show(basic.smtpserv_label);
2816                 gtk_widget_show(basic.smtpserv_entry);
2817                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2818                                            4, VSPACING_NARROW);
2819                 gtk_widget_hide(basic.localmbox_label);
2820                 gtk_widget_hide(basic.localmbox_entry);
2821                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2822                                            3, 0);
2823                 gtk_widget_hide(basic.mailcmd_label);
2824                 gtk_widget_hide(basic.mailcmd_entry);
2825                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2826                                            6, 0);
2827                 gtk_widget_hide(basic.mailcmd_chkbtn);
2828                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2829                                            5, 0);
2830                 gtk_widget_show(basic.uid_label);
2831                 gtk_widget_show(basic.pass_label);
2832                 gtk_widget_show(basic.uid_entry);
2833                 gtk_widget_show(basic.pass_entry);
2834                 gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table),
2835                                            7, VSPACING_NARROW);
2836
2837                 gtk_widget_set_sensitive(basic.uid_label,  TRUE);
2838                 gtk_widget_set_sensitive(basic.pass_label, TRUE);
2839                 gtk_widget_set_sensitive(basic.uid_entry,  TRUE);
2840                 gtk_widget_set_sensitive(basic.pass_entry, TRUE);
2841                 gtk_widget_set_sensitive(receive.pop3_frame, TRUE);
2842                 gtk_widget_show(receive.pop3_frame);
2843                 gtk_widget_hide(receive.imap_frame);
2844                 gtk_widget_hide(receive.frame_maxarticle);
2845                 gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, TRUE);
2846
2847                 gtk_widget_set_sensitive(basic.smtpserv_entry, TRUE);
2848                 gtk_widget_set_sensitive(basic.smtpserv_label, TRUE);
2849
2850                 /* update pop_before_smtp sensitivity */
2851                 gtk_widget_set_sensitive(p_send.pop_bfr_smtp_chkbtn, TRUE);
2852                 pop_bfr_smtp_tm_set_sens(NULL, NULL);
2853                 
2854                 if (!tmp_ac_prefs.account_name) {
2855                         gtk_toggle_button_set_active
2856                                 (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn),
2857                                  TRUE);
2858                 }
2859
2860 #if USE_OPENSSL
2861                 gtk_widget_show(ssl.pop_frame);
2862                 gtk_widget_hide(ssl.imap_frame);
2863                 gtk_widget_hide(ssl.nntp_frame);
2864                 gtk_widget_show(ssl.send_frame);
2865 #endif
2866                 gtk_widget_show(advanced.popport_hbox);
2867                 gtk_widget_hide(advanced.imapport_hbox);
2868                 gtk_widget_hide(advanced.nntpport_hbox);
2869                 gtk_widget_hide(advanced.crosspost_chkbtn);
2870                 gtk_widget_hide(advanced.crosspost_colormenu);
2871                 gtk_widget_hide(advanced.tunnelcmd_chkbtn);
2872                 gtk_widget_hide(advanced.tunnelcmd_entry);
2873                 gtk_widget_hide(advanced.imapdir_label);
2874                 gtk_widget_hide(advanced.imapdir_entry);
2875                 break;
2876         }
2877
2878         gtk_widget_queue_resize(basic.serv_frame);
2879 }
2880
2881 static void prefs_account_nntpauth_toggled(GtkToggleButton *button,
2882                                            gpointer user_data)
2883 {
2884         gboolean auth;
2885
2886         if (!GTK_WIDGET_SENSITIVE (GTK_WIDGET (button)))
2887                 return;
2888         auth = gtk_toggle_button_get_active (button);
2889         gtk_widget_set_sensitive(basic.uid_label,  auth);
2890         gtk_widget_set_sensitive(basic.pass_label, auth);
2891         gtk_widget_set_sensitive(basic.uid_entry,  auth);
2892         gtk_widget_set_sensitive(basic.pass_entry, auth);
2893         gtk_widget_set_sensitive(basic.nntpauth_onconnect_chkbtn, auth);
2894 }
2895
2896 static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
2897                                           gpointer user_data)
2898 {
2899         gboolean use_mailcmd;
2900
2901         use_mailcmd = gtk_toggle_button_get_active (button);
2902
2903         gtk_widget_set_sensitive(basic.mailcmd_entry,  use_mailcmd);
2904         gtk_widget_set_sensitive(basic.mailcmd_label, use_mailcmd);
2905         gtk_widget_set_sensitive(basic.smtpserv_entry, !use_mailcmd);
2906         gtk_widget_set_sensitive(basic.smtpserv_label, !use_mailcmd);
2907         gtk_widget_set_sensitive(basic.uid_entry,  !use_mailcmd);
2908         gtk_widget_set_sensitive(basic.pass_entry, !use_mailcmd);
2909 }