Mercurial > pidgin
annotate plugins/gevolution/eds-utils.c @ 10728:b5259f3dfc29
[gaim-migrate @ 12328]
[15:55] <marv> grim: what does it do?
[15:55] <grim> marv: corrects the logic in my patch that luke commited earlier
[15:55] <grim> it's to make the groups hide when all accounts are offline
committer: Tailor Script <tailor@pidgin.im>
| author | Tim Ringenbach <marv@pidgin.im> |
|---|---|
| date | Fri, 25 Mar 2005 21:56:29 +0000 |
| parents | 455c0830d108 |
| children | 5a8bc4b1f5b6 |
| rev | line source |
|---|---|
| 10083 | 1 /* |
| 2 * Evolution integration plugin for Gaim | |
| 3 * | |
| 4 * Copyright (C) 2004 Henry Jen. | |
| 5 * | |
| 6 * This program is free software; you can redistribute it and/or | |
| 7 * modify it under the terms of the GNU General Public License as | |
| 8 * published by the Free Software Foundation; either version 2 of the | |
| 9 * License, or (at your option) any later version. | |
| 10 * | |
| 11 * This program is distributed in the hope that it will be useful, but | |
| 12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 * General Public License for more details. | |
| 15 * | |
| 16 * You should have received a copy of the GNU General Public License | |
| 17 * along with this program; if not, write to the Free Software | |
| 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
| 19 * 02111-1307, USA. | |
| 20 */ | |
| 21 | |
| 22 #include "internal.h" | |
| 23 #include "gtkblist.h" | |
| 24 #include "gtkgaim.h" | |
| 25 #include "gtkutils.h" | |
| 26 #include "gtkimhtml.h" | |
|
10313
455c0830d108
[gaim-migrate @ 11511]
Luke Schierer <lschiere@pidgin.im>
parents:
10083
diff
changeset
|
27 #include "gtkgaim-disclosure.h" |
| 10083 | 28 |
| 29 #include "debug.h" | |
| 30 #include "gevolution.h" | |
| 31 | |
| 32 GtkTreeModel * | |
| 33 gevo_addrbooks_model_new() | |
| 34 { | |
| 35 return GTK_TREE_MODEL(gtk_list_store_new(NUM_ADDRBOOK_COLUMNS, | |
| 36 G_TYPE_STRING, G_TYPE_STRING)); | |
| 37 } | |
| 38 | |
| 39 void | |
| 40 gevo_addrbooks_model_unref(GtkTreeModel *model) | |
| 41 { | |
| 42 GtkTreeIter iter; | |
| 43 | |
| 44 g_return_if_fail(model != NULL); | |
| 45 g_return_if_fail(GTK_IS_LIST_STORE(model)); | |
| 46 | |
| 47 if (!gtk_tree_model_get_iter_first(model, &iter)) | |
| 48 return; | |
| 49 | |
| 50 g_object_unref(model); | |
| 51 } | |
| 52 | |
| 53 void | |
| 54 gevo_addrbooks_model_populate(GtkTreeModel *model) | |
| 55 { | |
| 56 ESourceList *addressbooks; | |
| 57 GError *err; | |
| 58 GSList *groups, *g; | |
| 59 GtkTreeIter iter; | |
| 60 GtkListStore *list; | |
| 61 | |
| 62 g_return_if_fail(model != NULL); | |
| 63 g_return_if_fail(GTK_IS_LIST_STORE(model)); | |
| 64 | |
| 65 list = GTK_LIST_STORE(model); | |
| 66 | |
| 67 if (!e_book_get_addressbooks(&addressbooks, &err)) | |
| 68 { | |
| 69 gaim_debug_error("evolution", | |
| 70 "Unable to fetch list of address books.\n"); | |
| 71 | |
| 72 gtk_list_store_append(list, &iter); | |
| 73 gtk_list_store_set(list, &iter, | |
| 74 ADDRBOOK_COLUMN_NAME, _("None"), | |
| 75 ADDRBOOK_COLUMN_URI, NULL, | |
| 76 -1); | |
| 77 | |
| 78 return; | |
| 79 } | |
| 80 | |
| 81 groups = e_source_list_peek_groups(addressbooks); | |
| 82 | |
| 83 if (groups == NULL) | |
| 84 { | |
| 85 gtk_list_store_append(list, &iter); | |
| 86 gtk_list_store_set(list, &iter, | |
| 87 ADDRBOOK_COLUMN_NAME, _("None"), | |
| 88 ADDRBOOK_COLUMN_URI, NULL, | |
| 89 -1); | |
| 90 | |
| 91 return; | |
| 92 } | |
| 93 | |
| 94 for (g = groups; g != NULL; g = g->next) | |
| 95 { | |
| 96 GSList *sources, *s; | |
| 97 | |
| 98 sources = e_source_group_peek_sources(g->data); | |
| 99 | |
| 100 for (s = sources; s != NULL; s = s->next) | |
| 101 { | |
| 102 ESource *source = E_SOURCE(s->data); | |
| 103 | |
| 104 g_object_ref(source); | |
| 105 | |
| 106 gtk_list_store_append(list, &iter); | |
| 107 gtk_list_store_set(list, &iter, | |
| 108 ADDRBOOK_COLUMN_NAME, e_source_peek_name(source), | |
| 109 ADDRBOOK_COLUMN_URI, e_source_get_uri(source), | |
| 110 -1); | |
| 111 } | |
| 112 } | |
| 113 | |
| 114 g_object_unref(addressbooks); | |
| 115 } |
