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