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