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