2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
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.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #include <gdk/gdkkeysyms.h>
34 #include "mainwindow.h"
35 #include "folderview.h"
39 #include "prefs_account.h"
40 #include "prefs_folder_item.h"
42 #include "manage_window.h"
43 #include "stock_pixmap.h"
47 #include "alertpanel.h"
56 } EditAccountColumnPos;
58 # define N_EDIT_ACCOUNT_COLS 5
60 #define PREFSBUFSIZE 1024
62 PrefsAccount *cur_account;
64 static GList *account_list = NULL;
66 static struct EditAccount {
72 static GdkPixmap *markxpm;
73 static GdkBitmap *markxpmmask;
74 static GdkPixmap *checkboxonxpm;
75 static GdkPixmap *checkboxonxpmmask;
76 static GdkPixmap *checkboxoffxpm;
77 static GdkPixmap *checkboxoffxpmmask;
79 static void account_edit_create (void);
81 static void account_edit_prefs (void);
82 static void account_delete (void);
84 static void account_up (void);
85 static void account_down (void);
87 static void account_set_default (void);
89 static void account_edit_close (void);
90 static gint account_delete_event (GtkWidget *widget,
93 static void account_selected (GtkCList *clist,
98 static void account_row_moved (GtkCList *clist,
101 static void account_key_pressed (GtkWidget *widget,
105 static gint account_clist_set_row (PrefsAccount *ac_prefs,
107 static void account_clist_set (void);
109 static void account_list_set (void);
111 void account_read_config_all(void)
113 GSList *ac_label_list = NULL, *cur;
116 gchar buf[PREFSBUFSIZE];
117 PrefsAccount *ac_prefs;
119 debug_print("Reading all config for each account...\n");
121 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
122 if ((fp = fopen(rcpath, "rb")) == NULL) {
123 if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
129 while (fgets(buf, sizeof(buf), fp) != NULL) {
130 if (!strncmp(buf, "[Account: ", 10)) {
132 memmove(buf, buf + 1, strlen(buf));
133 buf[strlen(buf) - 1] = '\0';
134 debug_print("Found label: %s\n", buf);
135 ac_label_list = g_slist_append(ac_label_list,
141 /* read config data from file */
143 for (cur = ac_label_list; cur != NULL; cur = cur->next) {
144 ac_prefs = prefs_account_new();
145 prefs_account_read_config(ac_prefs, (gchar *)cur->data);
146 account_list = g_list_append(account_list, ac_prefs);
147 if (ac_prefs->is_default)
148 cur_account = ac_prefs;
150 /* if default is not set, assume first account as default */
151 if (!cur_account && account_list) {
152 ac_prefs = (PrefsAccount *)account_list->data;
153 account_set_as_default(ac_prefs);
154 cur_account = ac_prefs;
158 main_window_reflect_prefs_all();
160 while (ac_label_list) {
161 g_free(ac_label_list->data);
162 ac_label_list = g_slist_remove(ac_label_list,
163 ac_label_list->data);
167 void account_save_config_all(void)
169 prefs_account_save_config_all(account_list);
173 * account_find_all_from_address:
174 * @ac_list: initial list of accounts. NULL to create a new one.
175 * Accounts found in the @address will be appended to this list.
176 * @address: Email address string.
178 * Find all the mail (not news) accounts within the specified address.
180 * Return value: the original accounts list with the found accounts appended.
182 GList *account_find_all_from_address(GList *ac_list, const gchar *address)
190 for (cur = account_list; cur != NULL; cur = cur->next) {
191 ac = (PrefsAccount *)cur->data;
192 if (ac->protocol != A_NNTP && ac->address &&
193 strcasestr(address, ac->address) != NULL)
194 ac_list = g_list_append(ac_list, ac);
199 PrefsAccount *account_find_from_smtp_server(const gchar *address,
200 const gchar *smtp_server)
205 g_return_val_if_fail(address != NULL, NULL);
206 g_return_val_if_fail(smtp_server != NULL, NULL);
208 for (cur = account_list; cur != NULL; cur = cur->next) {
209 ac = (PrefsAccount *)cur->data;
210 if (!strcmp2(address, ac->address) &&
211 !strcmp2(smtp_server, ac->smtp_server))
219 * account_find_from_address:
220 * @address: Email address string.
222 * Find a mail (not news) account with the specified email address.
224 * Return value: The found account, or NULL if not found.
226 PrefsAccount *account_find_from_address(const gchar *address)
231 g_return_val_if_fail(address != NULL, NULL);
233 for (cur = account_list; cur != NULL; cur = cur->next) {
234 ac = (PrefsAccount *)cur->data;
235 if (ac->protocol != A_NNTP && ac->address &&
236 strcasestr(address, ac->address) != NULL)
243 PrefsAccount *account_find_from_id(gint id)
248 for (cur = account_list; cur != NULL; cur = cur->next) {
249 ac = (PrefsAccount *)cur->data;
250 if (id == ac->account_id)
257 PrefsAccount *account_find_from_item(FolderItem *item)
261 g_return_val_if_fail(item != NULL, NULL);
265 FolderItem *cur_item = item->parent;
266 while (cur_item != NULL) {
267 if (cur_item->account && cur_item->apply_sub) {
268 ac = cur_item->account;
271 cur_item = cur_item->parent;
275 ac = item->folder->account;
280 void account_set_menu(void)
282 main_window_set_account_menu(account_list);
285 void account_foreach(AccountFunc func, gpointer user_data)
289 for (cur = account_list; cur != NULL; cur = cur->next)
290 if (func((PrefsAccount *)cur->data, user_data) != 0)
294 GList *account_get_list(void)
299 void account_edit_open(void)
303 if (compose_get_compose_list()) {
304 alertpanel_notice(_("Some composing windows are open.\n"
305 "Please close all the composing windows before editing the accounts."));
310 debug_print("Opening account edit window...\n");
312 if (!edit_account.window)
313 account_edit_create();
317 manage_window_set_transient(GTK_WINDOW(edit_account.window));
318 gtk_widget_grab_focus(edit_account.close_btn);
319 gtk_widget_show(edit_account.window);
321 manage_window_focus_in(edit_account.window, NULL, NULL);
324 void account_add(void)
326 PrefsAccount *ac_prefs;
328 ac_prefs = prefs_account_open(NULL);
330 if (!ac_prefs) return;
332 account_list = g_list_append(account_list, ac_prefs);
334 if (ac_prefs->is_default)
335 account_set_as_default(ac_prefs);
339 if (ac_prefs->protocol == A_IMAP4 || ac_prefs->protocol == A_NNTP) {
342 if (ac_prefs->protocol == A_IMAP4) {
343 folder = folder_new(F_IMAP, ac_prefs->account_name,
344 ac_prefs->recv_server);
346 folder = folder_new(F_NEWS, ac_prefs->account_name,
347 ac_prefs->nntp_server);
350 folder->account = ac_prefs;
351 ac_prefs->folder = REMOTE_FOLDER(folder);
353 if (ac_prefs->protocol == A_IMAP4)
354 folder->create_tree(folder);
355 folderview_set_all();
359 void account_open(PrefsAccount *ac_prefs)
361 gboolean prev_default;
364 g_return_if_fail(ac_prefs != NULL);
366 prev_default = ac_prefs->is_default;
367 Xstrdup_a(ac_name, ac_prefs->account_name ? ac_prefs->account_name : "",
370 prefs_account_open(ac_prefs);
372 if (!prev_default && ac_prefs->is_default)
373 account_set_as_default(ac_prefs);
375 if (ac_prefs->folder && strcmp2(ac_name, ac_prefs->account_name) != 0) {
376 folder_set_name(FOLDER(ac_prefs->folder),
377 ac_prefs->account_name);
378 folderview_set_all();
381 account_save_config_all();
383 main_window_reflect_prefs_all();
386 void account_set_as_default(PrefsAccount *ac_prefs)
391 for (cur = account_list; cur != NULL; cur = cur->next) {
392 ap = (PrefsAccount *)cur->data;
394 ap->is_default = FALSE;
397 ac_prefs->is_default = TRUE;
400 PrefsAccount *account_get_default(void)
405 for (cur = account_list; cur != NULL; cur = cur->next) {
406 ap = (PrefsAccount *)cur->data;
414 void account_set_missing_folder(void)
419 for (cur = account_list; cur != NULL; cur = cur->next) {
420 ap = (PrefsAccount *)cur->data;
421 if ((ap->protocol == A_IMAP4 || ap->protocol == A_NNTP) &&
425 if (ap->protocol == A_IMAP4) {
426 folder = folder_new(F_IMAP, ap->account_name,
429 folder = folder_new(F_NEWS, ap->account_name,
433 folder->account = ap;
434 ap->folder = REMOTE_FOLDER(folder);
436 if (ap->protocol == A_IMAP4)
437 folder->create_tree(folder);
442 FolderItem *account_get_special_folder(PrefsAccount *ac_prefs,
443 SpecialFolderItemType type)
445 FolderItem *item = NULL;
447 g_return_val_if_fail(ac_prefs != NULL, NULL);
451 if (ac_prefs->folder)
452 item = FOLDER(ac_prefs->folder)->inbox;
454 item = folder_get_default_inbox();
457 if (ac_prefs->set_sent_folder && ac_prefs->sent_folder) {
458 item = folder_find_item_from_identifier
459 (ac_prefs->sent_folder);
462 if (ac_prefs->folder)
463 item = FOLDER(ac_prefs->folder)->outbox;
465 item = folder_get_default_outbox();
469 if (ac_prefs->set_draft_folder && ac_prefs->draft_folder) {
470 item = folder_find_item_from_identifier
471 (ac_prefs->draft_folder);
474 if (ac_prefs->folder)
475 item = FOLDER(ac_prefs->folder)->draft;
477 item = folder_get_default_draft();
481 if (ac_prefs->folder)
482 item = FOLDER(ac_prefs->folder)->queue;
484 item = folder_get_default_queue();
487 if (ac_prefs->set_trash_folder && ac_prefs->trash_folder) {
488 item = folder_find_item_from_identifier
489 (ac_prefs->trash_folder);
492 if (ac_prefs->folder)
493 item = FOLDER(ac_prefs->folder)->trash;
495 item = folder_get_default_trash();
505 void account_destroy(PrefsAccount *ac_prefs)
507 g_return_if_fail(ac_prefs != NULL);
509 folder_unref_account_all(ac_prefs);
511 prefs_account_free(ac_prefs);
512 account_list = g_list_remove(account_list, ac_prefs);
514 if (cur_account == ac_prefs) cur_account = NULL;
515 if (!cur_account && account_list) {
516 cur_account = account_get_default();
518 ac_prefs = (PrefsAccount *)account_list->data;
519 account_set_as_default(ac_prefs);
520 cur_account = ac_prefs;
526 static void account_edit_create(void)
532 GtkWidget *scrolledwin;
534 gchar *titles[N_EDIT_ACCOUNT_COLS];
544 GtkWidget *default_btn;
547 GtkWidget *close_btn;
549 debug_print("Creating account edit window...\n");
551 window = gtk_window_new (GTK_WINDOW_DIALOG);
552 gtk_widget_set_usize (window, 500, 320);
553 gtk_container_set_border_width (GTK_CONTAINER (window), 8);
554 gtk_window_set_title (GTK_WINDOW (window), _("Edit accounts"));
555 gtk_window_set_modal (GTK_WINDOW (window), TRUE);
556 gtk_signal_connect (GTK_OBJECT (window), "delete_event",
557 GTK_SIGNAL_FUNC (account_delete_event), NULL);
558 gtk_signal_connect (GTK_OBJECT (window), "key_press_event",
559 GTK_SIGNAL_FUNC (account_key_pressed), NULL);
560 MANAGE_WINDOW_SIGNALS_CONNECT (window);
561 gtk_widget_realize(window);
563 vbox = gtk_vbox_new (FALSE, 10);
564 gtk_widget_show (vbox);
565 gtk_container_add (GTK_CONTAINER (window), vbox);
567 hbox = gtk_hbox_new (FALSE, 0);
568 gtk_widget_show (hbox);
569 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
571 label = gtk_label_new
572 (_("New messages will be checked in this order. Check the boxes\n"
573 "on the `G' column to enable message retrieval by `Get all'."));
574 gtk_widget_show (label);
575 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
576 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
578 hbox = gtk_hbox_new (FALSE, 8);
579 gtk_widget_show (hbox);
580 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
581 gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
583 scrolledwin = gtk_scrolled_window_new (NULL, NULL);
584 gtk_widget_show (scrolledwin);
585 gtk_box_pack_start (GTK_BOX (hbox), scrolledwin, TRUE, TRUE, 0);
586 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwin),
587 GTK_POLICY_AUTOMATIC,
588 GTK_POLICY_AUTOMATIC);
590 titles[COL_DEFAULT] = "D";
591 titles[COL_GETALL] = "G";
592 titles[COL_NAME] = _("Name");
593 titles[COL_PROTOCOL] = _("Protocol");
594 titles[COL_SERVER] = _("Server");
596 clist = gtk_clist_new_with_titles (N_EDIT_ACCOUNT_COLS, titles);
597 gtk_widget_show (clist);
598 gtk_container_add (GTK_CONTAINER (scrolledwin), clist);
599 gtk_clist_set_column_width (GTK_CLIST(clist), COL_DEFAULT , 10);
600 gtk_clist_set_column_width (GTK_CLIST(clist), COL_GETALL , 11);
601 gtk_clist_set_column_width (GTK_CLIST(clist), COL_NAME , 100);
602 gtk_clist_set_column_width (GTK_CLIST(clist), COL_PROTOCOL, 100);
603 gtk_clist_set_column_width (GTK_CLIST(clist), COL_SERVER , 100);
604 gtk_clist_set_column_justification (GTK_CLIST(clist), COL_DEFAULT,
606 gtk_clist_set_column_justification (GTK_CLIST(clist), COL_GETALL,
608 gtk_clist_set_selection_mode (GTK_CLIST(clist), GTK_SELECTION_BROWSE);
610 for (i = 0; i < N_EDIT_ACCOUNT_COLS; i++)
611 GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(clist)->column[i].button,
614 gtk_signal_connect (GTK_OBJECT (clist), "select_row",
615 GTK_SIGNAL_FUNC (account_selected), NULL);
616 gtk_signal_connect (GTK_OBJECT (clist), "row_move",
617 GTK_SIGNAL_FUNC (account_row_moved), NULL);
619 vbox2 = gtk_vbox_new (FALSE, 0);
620 gtk_widget_show (vbox2);
621 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
623 add_btn = gtk_button_new_with_label (_("Add"));
624 gtk_widget_show (add_btn);
625 gtk_box_pack_start (GTK_BOX (vbox2), add_btn, FALSE, FALSE, 4);
626 gtk_signal_connect (GTK_OBJECT(add_btn), "clicked",
627 GTK_SIGNAL_FUNC (account_add), NULL);
629 edit_btn = gtk_button_new_with_label (_("Edit"));
630 gtk_widget_show (edit_btn);
631 gtk_box_pack_start (GTK_BOX (vbox2), edit_btn, FALSE, FALSE, 4);
632 gtk_signal_connect (GTK_OBJECT(edit_btn), "clicked",
633 GTK_SIGNAL_FUNC (account_edit_prefs), NULL);
635 del_btn = gtk_button_new_with_label (_(" Delete "));
636 gtk_widget_show (del_btn);
637 gtk_box_pack_start (GTK_BOX (vbox2), del_btn, FALSE, FALSE, 4);
638 gtk_signal_connect (GTK_OBJECT(del_btn), "clicked",
639 GTK_SIGNAL_FUNC (account_delete), NULL);
641 down_btn = gtk_button_new_with_label (_("Down"));
642 gtk_widget_show (down_btn);
643 gtk_box_pack_end (GTK_BOX (vbox2), down_btn, FALSE, FALSE, 4);
644 gtk_signal_connect (GTK_OBJECT(down_btn), "clicked",
645 GTK_SIGNAL_FUNC (account_down), NULL);
647 up_btn = gtk_button_new_with_label (_("Up"));
648 gtk_widget_show (up_btn);
649 gtk_box_pack_end (GTK_BOX (vbox2), up_btn, FALSE, FALSE, 4);
650 gtk_signal_connect (GTK_OBJECT(up_btn), "clicked",
651 GTK_SIGNAL_FUNC (account_up), NULL);
653 hbox = gtk_hbox_new (FALSE, 8);
654 gtk_widget_show (hbox);
655 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
657 vbox2 = gtk_vbox_new(FALSE, 0);
658 gtk_widget_show (vbox2);
659 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
661 default_btn = gtk_button_new_with_label (_(" Set as default account "));
662 gtk_widget_show (default_btn);
663 gtk_box_pack_start (GTK_BOX (vbox2), default_btn, TRUE, FALSE, 0);
664 gtk_signal_connect (GTK_OBJECT(default_btn), "clicked",
665 GTK_SIGNAL_FUNC (account_set_default), NULL);
667 gtkut_button_set_create(&hbbox, &close_btn, _("Close"),
668 NULL, NULL, NULL, NULL);
669 gtk_widget_show(hbbox);
670 gtk_box_pack_end (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
671 gtk_widget_grab_default (close_btn);
673 gtk_signal_connect (GTK_OBJECT (close_btn), "clicked",
674 GTK_SIGNAL_FUNC (account_edit_close),
677 stock_pixmap_gdk(clist, STOCK_PIXMAP_MARK, &markxpm, &markxpmmask);
678 stock_pixmap_gdk(clist, STOCK_PIXMAP_CHECKBOX_ON,
679 &checkboxonxpm, &checkboxonxpmmask);
680 stock_pixmap_gdk(clist, STOCK_PIXMAP_CHECKBOX_OFF,
681 &checkboxoffxpm, &checkboxoffxpmmask);
683 edit_account.window = window;
684 edit_account.clist = clist;
685 edit_account.close_btn = close_btn;
688 static void account_edit_prefs(void)
690 GtkCList *clist = GTK_CLIST(edit_account.clist);
691 PrefsAccount *ac_prefs;
694 if (!clist->selection) return;
696 row = GPOINTER_TO_INT(clist->selection->data);
697 ac_prefs = gtk_clist_get_row_data(clist, row);
698 account_open(ac_prefs);
703 static gboolean account_delete_references_func(GNode *node, gpointer data)
708 g_return_val_if_fail(node->data != NULL, FALSE);
710 item = FOLDER_ITEM(node->data);
711 account = GPOINTER_TO_INT(data);
713 if(!item->prefs) /* && item->prefs->stype == F_NORMAL */
715 if(item->prefs->default_account != account)
718 item->prefs->enable_default_account = FALSE;
719 item->prefs->default_account = 0;
720 prefs_folder_item_save_config(item);
725 static void account_delete(void)
727 GtkCList *clist = GTK_CLIST(edit_account.clist);
728 PrefsAccount *ac_prefs;
733 if (!clist->selection) return;
735 if (alertpanel(_("Delete account"),
736 _("Do you really want to delete this account?"),
737 _("Yes"), _("+No"), NULL) != G_ALERTDEFAULT)
740 row = GPOINTER_TO_INT(clist->selection->data);
741 ac_prefs = gtk_clist_get_row_data(clist, row);
742 if (ac_prefs->folder) {
743 folder_destroy(FOLDER(ac_prefs->folder));
744 folderview_set_all();
746 account_destroy(ac_prefs);
749 debug_print("Removing deleted account references for all the folders...\n");
750 list = folder_get_list();
751 for (; list != NULL; list = list->next) {
752 folder = FOLDER(list->data);
753 if (folder->node) /* && folder->type == F_? */
754 g_node_traverse(folder->node, G_PRE_ORDER,
756 account_delete_references_func,
757 GINT_TO_POINTER(ac_prefs->account_id));
761 static void account_up(void)
763 GtkCList *clist = GTK_CLIST(edit_account.clist);
766 if (!clist->selection) return;
768 row = GPOINTER_TO_INT(clist->selection->data);
770 gtk_clist_row_move(clist, row, row - 1);
773 static void account_down(void)
775 GtkCList *clist = GTK_CLIST(edit_account.clist);
778 if (!clist->selection) return;
780 row = GPOINTER_TO_INT(clist->selection->data);
781 if (row < clist->rows - 1)
782 gtk_clist_row_move(clist, row, row + 1);
785 static void account_set_default(void)
787 GtkCList *clist = GTK_CLIST(edit_account.clist);
789 PrefsAccount *ac_prefs;
791 if (!clist->selection) return;
793 row = GPOINTER_TO_INT(clist->selection->data);
794 ac_prefs = gtk_clist_get_row_data(clist, row);
795 account_set_as_default(ac_prefs);
798 cur_account = ac_prefs;
800 main_window_reflect_prefs_all();
803 static void account_edit_close(void)
806 account_save_config_all();
808 if (!cur_account && account_list) {
809 PrefsAccount *ac_prefs = (PrefsAccount *)account_list->data;
810 account_set_as_default(ac_prefs);
811 cur_account = ac_prefs;
815 main_window_reflect_prefs_all();
817 gtk_widget_hide(edit_account.window);
822 static gint account_delete_event(GtkWidget *widget, GdkEventAny *event,
825 account_edit_close();
829 static void account_selected(GtkCList *clist, gint row, gint column,
830 GdkEvent *event, gpointer data)
832 if (event && event->type == GDK_2BUTTON_PRESS)
833 account_edit_prefs();
835 if (column == COL_GETALL) {
838 ac = gtk_clist_get_row_data(clist, row);
839 if (ac->protocol == A_POP3 || ac->protocol == A_APOP ||
840 ac->protocol == A_IMAP4 || ac->protocol == A_NNTP ||
841 ac->protocol == A_LOCAL) {
842 ac->recv_at_getall ^= TRUE;
843 account_clist_set_row(ac, row);
848 static void account_row_moved(GtkCList *clist, gint source_row, gint dest_row)
851 if (gtk_clist_row_is_visible(clist, dest_row) != GTK_VISIBILITY_FULL) {
852 gtk_clist_moveto(clist, dest_row, -1,
853 source_row < dest_row ? 1.0 : 0.0, 0.0);
857 static void account_key_pressed(GtkWidget *widget, GdkEventKey *event,
860 if (event && event->keyval == GDK_Escape)
861 account_edit_close();
864 /* set one CList row or add new row */
865 static gint account_clist_set_row(PrefsAccount *ac_prefs, gint row)
867 GtkCList *clist = GTK_CLIST(edit_account.clist);
868 gchar *text[N_EDIT_ACCOUNT_COLS];
869 gboolean has_getallbox;
872 text[COL_DEFAULT] = "";
873 text[COL_GETALL] = "";
874 text[COL_NAME] = ac_prefs->account_name;
876 text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ?
877 (ac_prefs->ssl_pop == SSL_TUNNEL ?
879 ac_prefs->ssl_pop == SSL_STARTTLS ?
880 "POP3 (TLS)" : "POP3") :
881 ac_prefs->protocol == A_APOP ?
882 (ac_prefs->ssl_pop == SSL_TUNNEL ?
884 ac_prefs->ssl_pop == SSL_STARTTLS ?
885 "POP3 (APOP, TLS)" : "POP3 (APOP)") :
886 ac_prefs->protocol == A_IMAP4 ?
887 (ac_prefs->ssl_imap == SSL_TUNNEL ?
889 ac_prefs->ssl_imap == SSL_STARTTLS ?
890 "IMAP4 (TLS)" : "IMAP4") :
891 ac_prefs->protocol == A_NNTP ?
892 (ac_prefs->ssl_nntp == SSL_TUNNEL ?
893 "NNTP (SSL)" : "NNTP") :
896 text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ? "POP3" :
897 ac_prefs->protocol == A_APOP ? "POP3 (APOP)" :
898 ac_prefs->protocol == A_IMAP4 ? "IMAP4" :
899 ac_prefs->protocol == A_LOCAL ? "Local" :
900 ac_prefs->protocol == A_NNTP ? "NNTP" : "";
902 text[COL_SERVER] = ac_prefs->protocol == A_NNTP
903 ? ac_prefs->nntp_server : ac_prefs->recv_server;
906 row = gtk_clist_append(clist, text);
908 gtk_clist_set_text(clist, row, COL_DEFAULT, text[COL_DEFAULT]);
909 gtk_clist_set_text(clist, row, COL_GETALL, text[COL_GETALL]);
910 gtk_clist_set_text(clist, row, COL_NAME, text[COL_NAME]);
911 gtk_clist_set_text(clist, row, COL_PROTOCOL, text[COL_PROTOCOL]);
912 gtk_clist_set_text(clist, row, COL_SERVER, text[COL_SERVER]);
915 has_getallbox = (ac_prefs->protocol == A_POP3 ||
916 ac_prefs->protocol == A_APOP ||
917 ac_prefs->protocol == A_IMAP4 ||
918 ac_prefs->protocol == A_NNTP ||
919 ac_prefs->protocol == A_LOCAL);
920 getall = has_getallbox && ac_prefs->recv_at_getall;
922 if (ac_prefs->is_default)
923 gtk_clist_set_pixmap(clist, row, COL_DEFAULT,
924 markxpm, markxpmmask);
926 gtk_clist_set_pixmap(clist, row, COL_GETALL,
927 checkboxonxpm, checkboxonxpmmask);
928 else if (has_getallbox)
929 gtk_clist_set_pixmap(clist, row, COL_GETALL,
930 checkboxoffxpm, checkboxoffxpmmask);
932 gtk_clist_set_row_data(clist, row, ac_prefs);
937 /* set CList from account list */
938 static void account_clist_set(void)
940 GtkCList *clist = GTK_CLIST(edit_account.clist);
942 gint row = -1, prev_row = -1;
944 if (clist->selection)
945 prev_row = GPOINTER_TO_INT(clist->selection->data);
947 gtk_clist_freeze(clist);
948 gtk_clist_clear(clist);
950 for (cur = account_list; cur != NULL; cur = cur->next) {
951 row = account_clist_set_row((PrefsAccount *)cur->data, -1);
952 if ((PrefsAccount *)cur->data == cur_account) {
953 gtk_clist_select_row(clist, row, -1);
954 gtkut_clist_set_focus_row(clist, row);
960 gtk_clist_select_row(clist, row, -1);
961 gtkut_clist_set_focus_row(clist, row);
965 gtk_clist_row_is_visible(clist, row) != GTK_VISIBILITY_FULL)
966 gtk_clist_moveto(clist, row, -1, 0.5, 0);
968 gtk_clist_thaw(clist);
971 /* set account list from CList */
972 static void account_list_set(void)
974 GtkCList *clist = GTK_CLIST(edit_account.clist);
976 PrefsAccount *ac_prefs;
979 account_list = g_list_remove(account_list, account_list->data);
981 for (row = 0; (ac_prefs = gtk_clist_get_row_data(clist, row)) != NULL;
983 account_list = g_list_append(account_list, ac_prefs);