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