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