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_set_as_default(PrefsAccount *ac_prefs)
364 for (cur = account_list; cur != NULL; cur = cur->next) {
365 ap = (PrefsAccount *)cur->data;
367 ap->is_default = FALSE;
370 ac_prefs->is_default = TRUE;
373 PrefsAccount *account_get_default(void)
378 for (cur = account_list; cur != NULL; cur = cur->next) {
379 ap = (PrefsAccount *)cur->data;
387 void account_set_missing_folder(void)
392 for (cur = account_list; cur != NULL; cur = cur->next) {
393 ap = (PrefsAccount *)cur->data;
394 if ((ap->protocol == A_IMAP4 || ap->protocol == A_NNTP) &&
398 if (ap->protocol == A_IMAP4) {
399 folder = folder_new(F_IMAP, ap->account_name,
402 folder = folder_new(F_NEWS, ap->account_name,
406 folder->account = ap;
407 ap->folder = REMOTE_FOLDER(folder);
409 if (ap->protocol == A_IMAP4)
410 folder->create_tree(folder);
415 FolderItem *account_get_special_folder(PrefsAccount *ac_prefs,
416 SpecialFolderItemType type)
418 FolderItem *item = NULL;
420 g_return_val_if_fail(ac_prefs != NULL, NULL);
422 if (type == F_OUTBOX) {
423 if (ac_prefs->set_sent_folder && ac_prefs->sent_folder) {
424 item = folder_find_item_from_identifier
425 (ac_prefs->sent_folder);
428 if (ac_prefs->folder)
429 item = FOLDER(ac_prefs->folder)->outbox;
431 item = folder_get_default_outbox();
433 } else if (type == F_DRAFT) {
434 if (ac_prefs->set_draft_folder && ac_prefs->draft_folder) {
435 item = folder_find_item_from_identifier
436 (ac_prefs->draft_folder);
439 if (ac_prefs->folder)
440 item = FOLDER(ac_prefs->folder)->draft;
442 item = folder_get_default_draft();
444 } else if (type == F_QUEUE) {
445 if (ac_prefs->folder)
446 item = FOLDER(ac_prefs->folder)->queue;
448 item = folder_get_default_queue();
449 } else if (type == F_TRASH) {
450 if (ac_prefs->set_trash_folder && ac_prefs->trash_folder) {
451 item = folder_find_item_from_identifier
452 (ac_prefs->trash_folder);
455 if (ac_prefs->folder)
456 item = FOLDER(ac_prefs->folder)->trash;
458 item = folder_get_default_trash();
465 void account_destroy(PrefsAccount *ac_prefs)
467 g_return_if_fail(ac_prefs != NULL);
469 prefs_account_free(ac_prefs);
470 account_list = g_list_remove(account_list, ac_prefs);
472 if (cur_account == ac_prefs) cur_account = NULL;
473 if (!cur_account && account_list) {
474 cur_account = account_get_default();
476 ac_prefs = (PrefsAccount *)account_list->data;
477 account_set_as_default(ac_prefs);
478 cur_account = ac_prefs;
484 static void account_edit_create(void)
490 GtkWidget *scrolledwin;
492 gchar *titles[N_EDIT_ACCOUNT_COLS];
502 GtkWidget *default_btn;
505 GtkWidget *close_btn;
507 debug_print("Creating account edit window...\n");
509 window = gtk_window_new (GTK_WINDOW_DIALOG);
510 gtk_widget_set_usize (window, 500, 320);
511 gtk_container_set_border_width (GTK_CONTAINER (window), 8);
512 gtk_window_set_title (GTK_WINDOW (window), _("Edit accounts"));
513 gtk_window_set_modal (GTK_WINDOW (window), TRUE);
514 gtk_signal_connect (GTK_OBJECT (window), "delete_event",
515 GTK_SIGNAL_FUNC (account_delete_event), NULL);
516 gtk_signal_connect (GTK_OBJECT (window), "key_press_event",
517 GTK_SIGNAL_FUNC (account_key_pressed), NULL);
518 MANAGE_WINDOW_SIGNALS_CONNECT (window);
519 gtk_widget_realize(window);
521 vbox = gtk_vbox_new (FALSE, 10);
522 gtk_widget_show (vbox);
523 gtk_container_add (GTK_CONTAINER (window), vbox);
525 hbox = gtk_hbox_new (FALSE, 0);
526 gtk_widget_show (hbox);
527 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
529 label = gtk_label_new
530 (_("New messages will be checked in this order. Check the boxes\n"
531 "on the `G' column to enable message retrieval by `Get all'."));
532 gtk_widget_show (label);
533 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
534 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
536 hbox = gtk_hbox_new (FALSE, 8);
537 gtk_widget_show (hbox);
538 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
539 gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
541 scrolledwin = gtk_scrolled_window_new (NULL, NULL);
542 gtk_widget_show (scrolledwin);
543 gtk_box_pack_start (GTK_BOX (hbox), scrolledwin, TRUE, TRUE, 0);
544 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwin),
545 GTK_POLICY_AUTOMATIC,
546 GTK_POLICY_AUTOMATIC);
548 titles[COL_DEFAULT] = "D";
549 titles[COL_GETALL] = "G";
550 titles[COL_NAME] = _("Name");
551 titles[COL_PROTOCOL] = _("Protocol");
552 titles[COL_SERVER] = _("Server");
554 clist = gtk_clist_new_with_titles (N_EDIT_ACCOUNT_COLS, titles);
555 gtk_widget_show (clist);
556 gtk_container_add (GTK_CONTAINER (scrolledwin), clist);
557 gtk_clist_set_column_width (GTK_CLIST(clist), COL_DEFAULT , 10);
558 gtk_clist_set_column_width (GTK_CLIST(clist), COL_GETALL , 11);
559 gtk_clist_set_column_width (GTK_CLIST(clist), COL_NAME , 100);
560 gtk_clist_set_column_width (GTK_CLIST(clist), COL_PROTOCOL, 100);
561 gtk_clist_set_column_width (GTK_CLIST(clist), COL_SERVER , 100);
562 gtk_clist_set_column_justification (GTK_CLIST(clist), COL_DEFAULT,
564 gtk_clist_set_column_justification (GTK_CLIST(clist), COL_GETALL,
566 gtk_clist_set_selection_mode (GTK_CLIST(clist), GTK_SELECTION_BROWSE);
568 for (i = 0; i < N_EDIT_ACCOUNT_COLS; i++)
569 GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(clist)->column[i].button,
572 gtk_signal_connect (GTK_OBJECT (clist), "select_row",
573 GTK_SIGNAL_FUNC (account_selected), NULL);
574 gtk_signal_connect (GTK_OBJECT (clist), "row_move",
575 GTK_SIGNAL_FUNC (account_row_moved), NULL);
577 vbox2 = gtk_vbox_new (FALSE, 0);
578 gtk_widget_show (vbox2);
579 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
581 add_btn = gtk_button_new_with_label (_("Add"));
582 gtk_widget_show (add_btn);
583 gtk_box_pack_start (GTK_BOX (vbox2), add_btn, FALSE, FALSE, 4);
584 gtk_signal_connect (GTK_OBJECT(add_btn), "clicked",
585 GTK_SIGNAL_FUNC (account_add), NULL);
587 edit_btn = gtk_button_new_with_label (_("Edit"));
588 gtk_widget_show (edit_btn);
589 gtk_box_pack_start (GTK_BOX (vbox2), edit_btn, FALSE, FALSE, 4);
590 gtk_signal_connect (GTK_OBJECT(edit_btn), "clicked",
591 GTK_SIGNAL_FUNC (account_edit_prefs), NULL);
593 del_btn = gtk_button_new_with_label (_(" Delete "));
594 gtk_widget_show (del_btn);
595 gtk_box_pack_start (GTK_BOX (vbox2), del_btn, FALSE, FALSE, 4);
596 gtk_signal_connect (GTK_OBJECT(del_btn), "clicked",
597 GTK_SIGNAL_FUNC (account_delete), NULL);
599 down_btn = gtk_button_new_with_label (_("Down"));
600 gtk_widget_show (down_btn);
601 gtk_box_pack_end (GTK_BOX (vbox2), down_btn, FALSE, FALSE, 4);
602 gtk_signal_connect (GTK_OBJECT(down_btn), "clicked",
603 GTK_SIGNAL_FUNC (account_down), NULL);
605 up_btn = gtk_button_new_with_label (_("Up"));
606 gtk_widget_show (up_btn);
607 gtk_box_pack_end (GTK_BOX (vbox2), up_btn, FALSE, FALSE, 4);
608 gtk_signal_connect (GTK_OBJECT(up_btn), "clicked",
609 GTK_SIGNAL_FUNC (account_up), NULL);
611 hbox = gtk_hbox_new (FALSE, 8);
612 gtk_widget_show (hbox);
613 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
615 vbox2 = gtk_vbox_new(FALSE, 0);
616 gtk_widget_show (vbox2);
617 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
619 default_btn = gtk_button_new_with_label (_(" Set as default account "));
620 gtk_widget_show (default_btn);
621 gtk_box_pack_start (GTK_BOX (vbox2), default_btn, TRUE, FALSE, 0);
622 gtk_signal_connect (GTK_OBJECT(default_btn), "clicked",
623 GTK_SIGNAL_FUNC (account_set_default), NULL);
625 gtkut_button_set_create(&hbbox, &close_btn, _("Close"),
626 NULL, NULL, NULL, NULL);
627 gtk_widget_show(hbbox);
628 gtk_box_pack_end (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
629 gtk_widget_grab_default (close_btn);
631 gtk_signal_connect (GTK_OBJECT (close_btn), "clicked",
632 GTK_SIGNAL_FUNC (account_edit_close),
635 stock_pixmap_gdk(clist, STOCK_PIXMAP_MARK, &markxpm, &markxpmmask);
636 stock_pixmap_gdk(clist, STOCK_PIXMAP_CHECKBOX_ON,
637 &checkboxonxpm, &checkboxonxpmmask);
638 stock_pixmap_gdk(clist, STOCK_PIXMAP_CHECKBOX_OFF,
639 &checkboxoffxpm, &checkboxoffxpmmask);
641 edit_account.window = window;
642 edit_account.clist = clist;
643 edit_account.close_btn = close_btn;
646 static void account_edit_prefs(void)
648 GtkCList *clist = GTK_CLIST(edit_account.clist);
649 PrefsAccount *ac_prefs;
651 gboolean prev_default;
654 if (!clist->selection) return;
656 row = GPOINTER_TO_INT(clist->selection->data);
657 ac_prefs = gtk_clist_get_row_data(clist, row);
658 prev_default = ac_prefs->is_default;
659 Xstrdup_a(ac_name, ac_prefs->account_name ? ac_prefs->account_name : "",
662 prefs_account_open(ac_prefs);
664 if (!prev_default && ac_prefs->is_default)
665 account_set_as_default(ac_prefs);
667 if ((ac_prefs->protocol == A_IMAP4 || ac_prefs->protocol == A_NNTP) &&
668 ac_prefs->folder && strcmp2(ac_name, ac_prefs->account_name) != 0) {
669 folder_set_name(FOLDER(ac_prefs->folder),
670 ac_prefs->account_name);
671 folderview_set_all();
677 static gboolean account_delete_references_func(GNode *node, gpointer data)
682 g_return_val_if_fail(node->data != NULL, FALSE);
684 item = FOLDER_ITEM(node->data);
685 account = GPOINTER_TO_INT(data);
687 if(!item->prefs) /* && item->prefs->stype == F_NORMAL */
689 if(item->prefs->default_account != account)
692 item->prefs->enable_default_account = FALSE;
693 item->prefs->default_account = 0;
694 prefs_folder_item_save_config(item);
699 static void account_delete(void)
701 GtkCList *clist = GTK_CLIST(edit_account.clist);
702 PrefsAccount *ac_prefs;
707 if (!clist->selection) return;
709 if (alertpanel(_("Delete account"),
710 _("Do you really want to delete this account?"),
711 _("Yes"), _("+No"), NULL) != G_ALERTDEFAULT)
714 row = GPOINTER_TO_INT(clist->selection->data);
715 ac_prefs = gtk_clist_get_row_data(clist, row);
716 if (ac_prefs->folder) {
717 folder_destroy(FOLDER(ac_prefs->folder));
718 folderview_set_all();
720 account_destroy(ac_prefs);
723 debug_print("Removing deleted account references for all the folders...\n");
724 list = folder_get_list();
725 for (; list != NULL; list = list->next) {
726 folder = FOLDER(list->data);
727 if (folder->node) /* && folder->type == F_? */
728 g_node_traverse(folder->node, G_PRE_ORDER,
730 account_delete_references_func,
731 GINT_TO_POINTER(ac_prefs->account_id));
735 static void account_up(void)
737 GtkCList *clist = GTK_CLIST(edit_account.clist);
740 if (!clist->selection) return;
742 row = GPOINTER_TO_INT(clist->selection->data);
744 gtk_clist_row_move(clist, row, row - 1);
747 static void account_down(void)
749 GtkCList *clist = GTK_CLIST(edit_account.clist);
752 if (!clist->selection) return;
754 row = GPOINTER_TO_INT(clist->selection->data);
755 if (row < clist->rows - 1)
756 gtk_clist_row_move(clist, row, row + 1);
759 static void account_set_default(void)
761 GtkCList *clist = GTK_CLIST(edit_account.clist);
763 PrefsAccount *ac_prefs;
765 if (!clist->selection) return;
767 row = GPOINTER_TO_INT(clist->selection->data);
768 ac_prefs = gtk_clist_get_row_data(clist, row);
769 account_set_as_default(ac_prefs);
772 cur_account = ac_prefs;
774 main_window_reflect_prefs_all();
777 static void account_edit_close(void)
780 account_save_config_all();
782 if (!cur_account && account_list) {
783 PrefsAccount *ac_prefs = (PrefsAccount *)account_list->data;
784 account_set_as_default(ac_prefs);
785 cur_account = ac_prefs;
789 main_window_reflect_prefs_all();
791 gtk_widget_hide(edit_account.window);
796 static gint account_delete_event(GtkWidget *widget, GdkEventAny *event,
799 account_edit_close();
803 static void account_selected(GtkCList *clist, gint row, gint column,
804 GdkEvent *event, gpointer data)
806 if (event && event->type == GDK_2BUTTON_PRESS)
807 account_edit_prefs();
809 if (column == COL_GETALL) {
812 ac = gtk_clist_get_row_data(clist, row);
813 if (ac->protocol == A_POP3 || ac->protocol == A_APOP ||
814 ac->protocol == A_IMAP4 || ac->protocol == A_NNTP ||
815 ac->protocol == A_LOCAL) {
816 ac->recv_at_getall ^= TRUE;
817 account_clist_set_row(ac, row);
822 static void account_row_moved(GtkCList *clist, gint source_row, gint dest_row)
825 if (gtk_clist_row_is_visible(clist, dest_row) != GTK_VISIBILITY_FULL) {
826 gtk_clist_moveto(clist, dest_row, -1,
827 source_row < dest_row ? 1.0 : 0.0, 0.0);
831 static void account_key_pressed(GtkWidget *widget, GdkEventKey *event,
834 if (event && event->keyval == GDK_Escape)
835 account_edit_close();
838 /* set one CList row or add new row */
839 static gint account_clist_set_row(PrefsAccount *ac_prefs, gint row)
841 GtkCList *clist = GTK_CLIST(edit_account.clist);
842 gchar *text[N_EDIT_ACCOUNT_COLS];
843 gboolean has_getallbox;
846 text[COL_DEFAULT] = "";
847 text[COL_GETALL] = "";
848 text[COL_NAME] = ac_prefs->account_name;
850 text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ?
851 (ac_prefs->ssl_pop == SSL_TUNNEL ?
853 ac_prefs->ssl_pop == SSL_STARTTLS ?
854 "POP3 (TLS)" : "POP3") :
855 ac_prefs->protocol == A_APOP ?
856 (ac_prefs->ssl_pop == SSL_TUNNEL ?
858 ac_prefs->ssl_pop == SSL_STARTTLS ?
859 "POP3 (APOP, TLS)" : "POP3 (APOP)") :
860 ac_prefs->protocol == A_IMAP4 ?
861 (ac_prefs->ssl_imap == SSL_TUNNEL ?
863 ac_prefs->ssl_imap == SSL_STARTTLS ?
864 "IMAP4 (TLS)" : "IMAP4") :
865 ac_prefs->protocol == A_NNTP ?
866 (ac_prefs->ssl_nntp == SSL_TUNNEL ?
867 "NNTP (SSL)" : "NNTP") :
870 text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ? "POP3" :
871 ac_prefs->protocol == A_APOP ? "POP3 (APOP)" :
872 ac_prefs->protocol == A_IMAP4 ? "IMAP4" :
873 ac_prefs->protocol == A_LOCAL ? "Local" :
874 ac_prefs->protocol == A_NNTP ? "NNTP" : "";
876 text[COL_SERVER] = ac_prefs->protocol == A_NNTP
877 ? ac_prefs->nntp_server : ac_prefs->recv_server;
880 row = gtk_clist_append(clist, text);
882 gtk_clist_set_text(clist, row, COL_DEFAULT, text[COL_DEFAULT]);
883 gtk_clist_set_text(clist, row, COL_GETALL, text[COL_GETALL]);
884 gtk_clist_set_text(clist, row, COL_NAME, text[COL_NAME]);
885 gtk_clist_set_text(clist, row, COL_PROTOCOL, text[COL_PROTOCOL]);
886 gtk_clist_set_text(clist, row, COL_SERVER, text[COL_SERVER]);
889 has_getallbox = (ac_prefs->protocol == A_POP3 ||
890 ac_prefs->protocol == A_APOP ||
891 ac_prefs->protocol == A_IMAP4 ||
892 ac_prefs->protocol == A_NNTP ||
893 ac_prefs->protocol == A_LOCAL);
894 getall = has_getallbox && ac_prefs->recv_at_getall;
896 if (ac_prefs->is_default)
897 gtk_clist_set_pixmap(clist, row, COL_DEFAULT,
898 markxpm, markxpmmask);
900 gtk_clist_set_pixmap(clist, row, COL_GETALL,
901 checkboxonxpm, checkboxonxpmmask);
902 else if (has_getallbox)
903 gtk_clist_set_pixmap(clist, row, COL_GETALL,
904 checkboxoffxpm, checkboxoffxpmmask);
906 gtk_clist_set_row_data(clist, row, ac_prefs);
911 /* set CList from account list */
912 static void account_clist_set(void)
914 GtkCList *clist = GTK_CLIST(edit_account.clist);
916 gint row = -1, prev_row = -1;
918 if (clist->selection)
919 prev_row = GPOINTER_TO_INT(clist->selection->data);
921 gtk_clist_freeze(clist);
922 gtk_clist_clear(clist);
924 for (cur = account_list; cur != NULL; cur = cur->next) {
925 row = account_clist_set_row((PrefsAccount *)cur->data, -1);
926 if ((PrefsAccount *)cur->data == cur_account) {
927 gtk_clist_select_row(clist, row, -1);
928 gtkut_clist_set_focus_row(clist, row);
934 gtk_clist_select_row(clist, row, -1);
935 gtkut_clist_set_focus_row(clist, row);
939 gtk_clist_row_is_visible(clist, row) != GTK_VISIBILITY_FULL)
940 gtk_clist_moveto(clist, row, -1, 0.5, 0);
942 gtk_clist_thaw(clist);
945 /* set account list from CList */
946 static void account_list_set(void)
948 GtkCList *clist = GTK_CLIST(edit_account.clist);
950 PrefsAccount *ac_prefs;
953 account_list = g_list_remove(account_list, account_list->data);
955 for (row = 0; (ac_prefs = gtk_clist_get_row_data(clist, row)) != NULL;
957 account_list = g_list_append(account_list, ac_prefs);