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 = g_new0(PrefsAccount, 1);
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);
172 PrefsAccount *account_find_from_smtp_server(const gchar *address,
173 const gchar *smtp_server)
178 g_return_val_if_fail(address != NULL, NULL);
179 g_return_val_if_fail(smtp_server != NULL, NULL);
181 for (cur = account_list; cur != NULL; cur = cur->next) {
182 ac = (PrefsAccount *)cur->data;
183 if (!strcmp2(address, ac->address) &&
184 !strcmp2(smtp_server, ac->smtp_server))
192 * account_find_from_address:
193 * @address: Email address string.
195 * Find a mail (not news) account with the specified email address.
197 * Return value: The found account, or NULL if not found.
199 PrefsAccount *account_find_from_address(const gchar *address)
204 g_return_val_if_fail(address != NULL, NULL);
206 for (cur = account_list; cur != NULL; cur = cur->next) {
207 ac = (PrefsAccount *)cur->data;
208 if (ac->protocol != A_NNTP && ac->address &&
209 strcasestr(address, ac->address))
216 PrefsAccount *account_find_from_id(gint id)
221 for (cur = account_list; cur != NULL; cur = cur->next) {
222 ac = (PrefsAccount *)cur->data;
223 if (id == ac->account_id)
230 void account_set_menu(void)
232 main_window_set_account_menu(account_list);
235 void account_foreach(AccountFunc func, gpointer user_data)
239 for (cur = account_list; cur != NULL; cur = cur->next)
240 if (func((PrefsAccount *)cur->data, user_data) != 0)
244 GList *account_get_list(void)
249 void account_edit_open(void)
253 if (compose_get_compose_list()) {
254 alertpanel_notice(_("Some composing windows are open.\n"
255 "Please close all the composing windows before editing the accounts."));
260 debug_print(_("Opening account edit window...\n"));
262 if (!edit_account.window)
263 account_edit_create();
267 manage_window_set_transient(GTK_WINDOW(edit_account.window));
268 gtk_widget_grab_focus(edit_account.close_btn);
269 gtk_widget_show(edit_account.window);
271 manage_window_focus_in(edit_account.window, NULL, NULL);
274 void account_add(void)
276 PrefsAccount *ac_prefs;
278 ac_prefs = prefs_account_open(NULL);
280 if (!ac_prefs) return;
282 account_list = g_list_append(account_list, ac_prefs);
284 if (ac_prefs->is_default)
285 account_set_as_default(ac_prefs);
289 if (ac_prefs->protocol == A_IMAP4 || ac_prefs->protocol == A_NNTP) {
292 if (ac_prefs->protocol == A_IMAP4) {
293 folder = folder_new(F_IMAP, ac_prefs->account_name,
294 ac_prefs->recv_server);
296 folder = folder_new(F_NEWS, ac_prefs->account_name,
297 ac_prefs->nntp_server);
300 folder->account = ac_prefs;
301 ac_prefs->folder = REMOTE_FOLDER(folder);
303 if (ac_prefs->protocol == A_IMAP4)
304 folder->create_tree(folder);
305 folderview_set_all();
309 void account_set_as_default(PrefsAccount *ac_prefs)
314 for (cur = account_list; cur != NULL; cur = cur->next) {
315 ap = (PrefsAccount *)cur->data;
317 ap->is_default = FALSE;
320 ac_prefs->is_default = TRUE;
323 PrefsAccount *account_get_default(void)
328 for (cur = account_list; cur != NULL; cur = cur->next) {
329 ap = (PrefsAccount *)cur->data;
337 void account_set_missing_folder(void)
342 for (cur = account_list; cur != NULL; cur = cur->next) {
343 ap = (PrefsAccount *)cur->data;
344 if ((ap->protocol == A_IMAP4 || ap->protocol == A_NNTP) &&
348 if (ap->protocol == A_IMAP4) {
349 folder = folder_new(F_IMAP, ap->account_name,
352 folder = folder_new(F_NEWS, ap->account_name,
356 folder->account = ap;
357 ap->folder = REMOTE_FOLDER(folder);
359 if (ap->protocol == A_IMAP4)
360 folder->create_tree(folder);
365 FolderItem *account_get_special_folder(PrefsAccount *ac_prefs,
366 SpecialFolderItemType type)
368 FolderItem *item = NULL;
370 g_return_val_if_fail(ac_prefs != NULL, NULL);
372 if (type == F_OUTBOX) {
373 if (ac_prefs->set_sent_folder && ac_prefs->sent_folder) {
374 item = folder_find_item_from_identifier
375 (ac_prefs->sent_folder);
378 if (ac_prefs->folder)
379 item = FOLDER(ac_prefs->folder)->outbox;
381 item = folder_get_default_outbox();
383 } else if (type == F_DRAFT) {
384 if (ac_prefs->set_draft_folder && ac_prefs->draft_folder) {
385 item = folder_find_item_from_identifier
386 (ac_prefs->draft_folder);
389 if (ac_prefs->folder)
390 item = FOLDER(ac_prefs->folder)->draft;
392 item = folder_get_default_draft();
394 } else if (type == F_QUEUE) {
395 if (ac_prefs->folder)
396 item = FOLDER(ac_prefs->folder)->queue;
398 item = folder_get_default_queue();
399 } else if (type == F_TRASH) {
400 if (ac_prefs->set_trash_folder && ac_prefs->trash_folder) {
401 item = folder_find_item_from_identifier
402 (ac_prefs->trash_folder);
405 if (ac_prefs->folder)
406 item = FOLDER(ac_prefs->folder)->trash;
408 item = folder_get_default_trash();
415 void account_destroy(PrefsAccount *ac_prefs)
417 g_return_if_fail(ac_prefs != NULL);
419 prefs_account_free(ac_prefs);
420 account_list = g_list_remove(account_list, ac_prefs);
422 if (cur_account == ac_prefs) cur_account = NULL;
423 if (!cur_account && account_list) {
424 cur_account = account_get_default();
426 ac_prefs = (PrefsAccount *)account_list->data;
427 account_set_as_default(ac_prefs);
428 cur_account = ac_prefs;
434 static void account_edit_create(void)
440 GtkWidget *scrolledwin;
442 gchar *titles[N_EDIT_ACCOUNT_COLS];
452 GtkWidget *default_btn;
455 GtkWidget *close_btn;
457 debug_print(_("Creating account edit window...\n"));
459 window = gtk_window_new (GTK_WINDOW_DIALOG);
460 gtk_widget_set_usize (window, 500, 320);
461 gtk_container_set_border_width (GTK_CONTAINER (window), 8);
462 gtk_window_set_title (GTK_WINDOW (window), _("Edit accounts"));
463 gtk_window_set_modal (GTK_WINDOW (window), TRUE);
464 gtk_signal_connect (GTK_OBJECT (window), "delete_event",
465 GTK_SIGNAL_FUNC (account_delete_event), NULL);
466 gtk_signal_connect (GTK_OBJECT (window), "key_press_event",
467 GTK_SIGNAL_FUNC (account_key_pressed), NULL);
468 MANAGE_WINDOW_SIGNALS_CONNECT (window);
469 gtk_widget_realize(window);
471 vbox = gtk_vbox_new (FALSE, 10);
472 gtk_widget_show (vbox);
473 gtk_container_add (GTK_CONTAINER (window), vbox);
475 hbox = gtk_hbox_new (FALSE, 0);
476 gtk_widget_show (hbox);
477 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
479 label = gtk_label_new
480 (_("New messages will be checked in this order. Check the boxes\n"
481 "on the `G' column to enable message retrieval by `Get all'."));
482 gtk_widget_show (label);
483 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
484 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
486 hbox = gtk_hbox_new (FALSE, 8);
487 gtk_widget_show (hbox);
488 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
489 gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
491 scrolledwin = gtk_scrolled_window_new (NULL, NULL);
492 gtk_widget_show (scrolledwin);
493 gtk_box_pack_start (GTK_BOX (hbox), scrolledwin, TRUE, TRUE, 0);
494 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwin),
495 GTK_POLICY_AUTOMATIC,
496 GTK_POLICY_AUTOMATIC);
498 titles[COL_DEFAULT] = "D";
499 titles[COL_GETALL] = "G";
500 titles[COL_NAME] = _("Name");
501 titles[COL_PROTOCOL] = _("Protocol");
502 titles[COL_SERVER] = _("Server");
504 clist = gtk_clist_new_with_titles (N_EDIT_ACCOUNT_COLS, titles);
505 gtk_widget_show (clist);
506 gtk_container_add (GTK_CONTAINER (scrolledwin), clist);
507 gtk_clist_set_column_width (GTK_CLIST(clist), COL_DEFAULT , 10);
508 gtk_clist_set_column_width (GTK_CLIST(clist), COL_GETALL , 11);
509 gtk_clist_set_column_width (GTK_CLIST(clist), COL_NAME , 100);
510 gtk_clist_set_column_width (GTK_CLIST(clist), COL_PROTOCOL, 100);
511 gtk_clist_set_column_width (GTK_CLIST(clist), COL_SERVER , 100);
512 gtk_clist_set_column_justification (GTK_CLIST(clist), COL_DEFAULT,
514 gtk_clist_set_column_justification (GTK_CLIST(clist), COL_GETALL,
516 gtk_clist_set_selection_mode (GTK_CLIST(clist), GTK_SELECTION_BROWSE);
518 for (i = 0; i < N_EDIT_ACCOUNT_COLS; i++)
519 GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(clist)->column[i].button,
522 gtk_signal_connect (GTK_OBJECT (clist), "select_row",
523 GTK_SIGNAL_FUNC (account_selected), NULL);
524 gtk_signal_connect (GTK_OBJECT (clist), "row_move",
525 GTK_SIGNAL_FUNC (account_row_moved), NULL);
527 vbox2 = gtk_vbox_new (FALSE, 0);
528 gtk_widget_show (vbox2);
529 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
531 add_btn = gtk_button_new_with_label (_("Add"));
532 gtk_widget_show (add_btn);
533 gtk_box_pack_start (GTK_BOX (vbox2), add_btn, FALSE, FALSE, 4);
534 gtk_signal_connect (GTK_OBJECT(add_btn), "clicked",
535 GTK_SIGNAL_FUNC (account_add), NULL);
537 edit_btn = gtk_button_new_with_label (_("Edit"));
538 gtk_widget_show (edit_btn);
539 gtk_box_pack_start (GTK_BOX (vbox2), edit_btn, FALSE, FALSE, 4);
540 gtk_signal_connect (GTK_OBJECT(edit_btn), "clicked",
541 GTK_SIGNAL_FUNC (account_edit_prefs), NULL);
543 del_btn = gtk_button_new_with_label (_(" Delete "));
544 gtk_widget_show (del_btn);
545 gtk_box_pack_start (GTK_BOX (vbox2), del_btn, FALSE, FALSE, 4);
546 gtk_signal_connect (GTK_OBJECT(del_btn), "clicked",
547 GTK_SIGNAL_FUNC (account_delete), NULL);
549 down_btn = gtk_button_new_with_label (_("Down"));
550 gtk_widget_show (down_btn);
551 gtk_box_pack_end (GTK_BOX (vbox2), down_btn, FALSE, FALSE, 4);
552 gtk_signal_connect (GTK_OBJECT(down_btn), "clicked",
553 GTK_SIGNAL_FUNC (account_down), NULL);
555 up_btn = gtk_button_new_with_label (_("Up"));
556 gtk_widget_show (up_btn);
557 gtk_box_pack_end (GTK_BOX (vbox2), up_btn, FALSE, FALSE, 4);
558 gtk_signal_connect (GTK_OBJECT(up_btn), "clicked",
559 GTK_SIGNAL_FUNC (account_up), NULL);
561 hbox = gtk_hbox_new (FALSE, 8);
562 gtk_widget_show (hbox);
563 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
565 vbox2 = gtk_vbox_new(FALSE, 0);
566 gtk_widget_show (vbox2);
567 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
569 default_btn = gtk_button_new_with_label (_(" Set as default account "));
570 gtk_widget_show (default_btn);
571 gtk_box_pack_start (GTK_BOX (vbox2), default_btn, TRUE, FALSE, 0);
572 gtk_signal_connect (GTK_OBJECT(default_btn), "clicked",
573 GTK_SIGNAL_FUNC (account_set_default), NULL);
575 gtkut_button_set_create(&hbbox, &close_btn, _("Close"),
576 NULL, NULL, NULL, NULL);
577 gtk_widget_show(hbbox);
578 gtk_box_pack_end (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
579 gtk_widget_grab_default (close_btn);
581 gtk_signal_connect (GTK_OBJECT (close_btn), "clicked",
582 GTK_SIGNAL_FUNC (account_edit_close),
585 stock_pixmap_gdk(clist, STOCK_PIXMAP_MARK, &markxpm, &markxpmmask);
586 stock_pixmap_gdk(clist, STOCK_PIXMAP_CHECKBOX_ON,
587 &checkboxonxpm, &checkboxonxpmmask);
588 stock_pixmap_gdk(clist, STOCK_PIXMAP_CHECKBOX_OFF,
589 &checkboxoffxpm, &checkboxoffxpmmask);
591 edit_account.window = window;
592 edit_account.clist = clist;
593 edit_account.close_btn = close_btn;
596 static void account_edit_prefs(void)
598 GtkCList *clist = GTK_CLIST(edit_account.clist);
599 PrefsAccount *ac_prefs;
601 gboolean prev_default;
604 if (!clist->selection) return;
606 row = GPOINTER_TO_INT(clist->selection->data);
607 ac_prefs = gtk_clist_get_row_data(clist, row);
608 prev_default = ac_prefs->is_default;
609 Xstrdup_a(ac_name, ac_prefs->account_name ? ac_prefs->account_name : "",
612 prefs_account_open(ac_prefs);
614 if (!prev_default && ac_prefs->is_default)
615 account_set_as_default(ac_prefs);
617 if ((ac_prefs->protocol == A_IMAP4 || ac_prefs->protocol == A_NNTP) &&
618 ac_prefs->folder && strcmp2(ac_name, ac_prefs->account_name) != 0) {
619 folder_set_name(FOLDER(ac_prefs->folder),
620 ac_prefs->account_name);
621 folderview_rescan_all();
627 static gboolean account_delete_references_func(GNode *node, gpointer data)
632 g_return_val_if_fail(node->data != NULL, FALSE);
634 item = FOLDER_ITEM(node->data);
635 account = GPOINTER_TO_INT(data);
637 if(!item->prefs) /* && item->prefs->stype == F_NORMAL */
639 if(item->prefs->default_account != account)
642 item->prefs->enable_default_account = FALSE;
643 item->prefs->default_account = 0;
644 prefs_folder_item_save_config(item);
647 static void account_delete(void)
649 GtkCList *clist = GTK_CLIST(edit_account.clist);
650 PrefsAccount *ac_prefs;
655 if (!clist->selection) return;
657 if (alertpanel(_("Delete account"),
658 _("Do you really want to delete this account?"),
659 _("Yes"), _("+No"), NULL) != G_ALERTDEFAULT)
662 row = GPOINTER_TO_INT(clist->selection->data);
663 ac_prefs = gtk_clist_get_row_data(clist, row);
664 if (ac_prefs->folder) {
665 folder_destroy(FOLDER(ac_prefs->folder));
666 folderview_rescan_all();
668 account_destroy(ac_prefs);
671 debug_print(_("Removing deleted account references for all the folders...\n"));
672 list = folder_get_list();
673 for (; list != NULL; list = list->next) {
674 folder = FOLDER(list->data);
675 if (folder->node) /* && folder->type == F_? */
676 g_node_traverse(folder->node, G_PRE_ORDER,
678 account_delete_references_func,
679 GINT_TO_POINTER(ac_prefs->account_id));
683 static void account_up(void)
685 GtkCList *clist = GTK_CLIST(edit_account.clist);
688 if (!clist->selection) return;
690 row = GPOINTER_TO_INT(clist->selection->data);
692 gtk_clist_row_move(clist, row, row - 1);
695 static void account_down(void)
697 GtkCList *clist = GTK_CLIST(edit_account.clist);
700 if (!clist->selection) return;
702 row = GPOINTER_TO_INT(clist->selection->data);
703 if (row < clist->rows - 1)
704 gtk_clist_row_move(clist, row, row + 1);
707 static void account_set_default(void)
709 GtkCList *clist = GTK_CLIST(edit_account.clist);
711 PrefsAccount *ac_prefs;
713 if (!clist->selection) return;
715 row = GPOINTER_TO_INT(clist->selection->data);
716 ac_prefs = gtk_clist_get_row_data(clist, row);
717 account_set_as_default(ac_prefs);
720 cur_account = ac_prefs;
722 main_window_reflect_prefs_all();
725 static void account_edit_close(void)
728 account_save_config_all();
730 if (!cur_account && account_list) {
731 PrefsAccount *ac_prefs = (PrefsAccount *)account_list->data;
732 account_set_as_default(ac_prefs);
733 cur_account = ac_prefs;
737 main_window_reflect_prefs_all();
739 gtk_widget_hide(edit_account.window);
744 static gint account_delete_event(GtkWidget *widget, GdkEventAny *event,
747 account_edit_close();
751 static void account_selected(GtkCList *clist, gint row, gint column,
752 GdkEvent *event, gpointer data)
754 if (event && event->type == GDK_2BUTTON_PRESS)
755 account_edit_prefs();
757 if (column == COL_GETALL) {
760 ac = gtk_clist_get_row_data(clist, row);
761 if (ac->protocol == A_POP3 || ac->protocol == A_APOP ||
762 ac->protocol == A_IMAP4 || ac->protocol == A_NNTP ||
763 ac->protocol == A_LOCAL) {
764 ac->recv_at_getall ^= TRUE;
765 account_clist_set_row(ac, row);
770 static void account_row_moved(GtkCList *clist, gint source_row, gint dest_row)
773 if (gtk_clist_row_is_visible(clist, dest_row) != GTK_VISIBILITY_FULL) {
774 gtk_clist_moveto(clist, dest_row, -1,
775 source_row < dest_row ? 1.0 : 0.0, 0.0);
779 static void account_key_pressed(GtkWidget *widget, GdkEventKey *event,
782 if (event && event->keyval == GDK_Escape)
783 account_edit_close();
786 /* set one CList row or add new row */
787 static gint account_clist_set_row(PrefsAccount *ac_prefs, gint row)
789 GtkCList *clist = GTK_CLIST(edit_account.clist);
790 gchar *text[N_EDIT_ACCOUNT_COLS];
791 gboolean has_getallbox;
794 text[COL_DEFAULT] = "";
795 text[COL_GETALL] = "";
796 text[COL_NAME] = ac_prefs->account_name;
798 text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ?
799 (ac_prefs->ssl_pop ? "POP3 (SSL)" : "POP3") :
800 ac_prefs->protocol == A_APOP ?
802 "POP3 (APOP, SSL)" : "POP3 (APOP)") :
803 ac_prefs->protocol == A_IMAP4 ?
804 (ac_prefs->ssl_imap ? "IMAP4 (SSL)" : "IMAP4") :
805 ac_prefs->protocol == A_LOCAL ? "Local" :
806 ac_prefs->protocol == A_NNTP ?
807 (ac_prefs->ssl_nntp ? "NNTP (SSL)" : "NNTP") : "";
809 text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ? "POP3" :
810 ac_prefs->protocol == A_APOP ? "POP3 (APOP)" :
811 ac_prefs->protocol == A_IMAP4 ? "IMAP4" :
812 ac_prefs->protocol == A_LOCAL ? "Local" :
813 ac_prefs->protocol == A_NNTP ? "NNTP" : "";
815 text[COL_SERVER] = ac_prefs->protocol == A_NNTP
816 ? ac_prefs->nntp_server : ac_prefs->recv_server;
819 row = gtk_clist_append(clist, text);
821 gtk_clist_set_text(clist, row, COL_DEFAULT, text[COL_DEFAULT]);
822 gtk_clist_set_text(clist, row, COL_GETALL, text[COL_GETALL]);
823 gtk_clist_set_text(clist, row, COL_NAME, text[COL_NAME]);
824 gtk_clist_set_text(clist, row, COL_PROTOCOL, text[COL_PROTOCOL]);
825 gtk_clist_set_text(clist, row, COL_SERVER, text[COL_SERVER]);
828 has_getallbox = (ac_prefs->protocol == A_POP3 ||
829 ac_prefs->protocol == A_APOP ||
830 ac_prefs->protocol == A_IMAP4 ||
831 ac_prefs->protocol == A_NNTP ||
832 ac_prefs->protocol == A_LOCAL);
833 getall = has_getallbox && ac_prefs->recv_at_getall;
835 if (ac_prefs->is_default)
836 gtk_clist_set_pixmap(clist, row, COL_DEFAULT,
837 markxpm, markxpmmask);
839 gtk_clist_set_pixmap(clist, row, COL_GETALL,
840 checkboxonxpm, checkboxonxpmmask);
841 else if (has_getallbox)
842 gtk_clist_set_pixmap(clist, row, COL_GETALL,
843 checkboxoffxpm, checkboxoffxpmmask);
845 gtk_clist_set_row_data(clist, row, ac_prefs);
850 /* set CList from account list */
851 static void account_clist_set(void)
853 GtkCList *clist = GTK_CLIST(edit_account.clist);
855 gint row = -1, prev_row = -1;
857 if (clist->selection)
858 prev_row = GPOINTER_TO_INT(clist->selection->data);
860 gtk_clist_freeze(clist);
861 gtk_clist_clear(clist);
863 for (cur = account_list; cur != NULL; cur = cur->next) {
864 row = account_clist_set_row((PrefsAccount *)cur->data, -1);
865 if ((PrefsAccount *)cur->data == cur_account) {
866 gtk_clist_select_row(clist, row, -1);
867 gtkut_clist_set_focus_row(clist, row);
873 gtk_clist_select_row(clist, row, -1);
874 gtkut_clist_set_focus_row(clist, row);
878 gtk_clist_row_is_visible(clist, row) != GTK_VISIBILITY_FULL)
879 gtk_clist_moveto(clist, row, -1, 0.5, 0);
881 gtk_clist_thaw(clist);
884 /* set account list from CList */
885 static void account_list_set(void)
887 GtkCList *clist = GTK_CLIST(edit_account.clist);
889 PrefsAccount *ac_prefs;
892 account_list = g_list_remove(account_list, account_list->data);
894 for (row = 0; (ac_prefs = gtk_clist_get_row_data(clist, row)) != NULL;
896 account_list = g_list_append(account_list, ac_prefs);