From bc1560c609d2f96db3aa14e2926e4d0f85385f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Wed, 24 Dec 2014 15:12:20 -0500 Subject: [PATCH] manager: cleaner way of returning enabled sources --- src/gcal-manager.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gcal-manager.c b/src/gcal-manager.c index f26656ff..7ae8d0b4 100644 --- a/src/gcal-manager.c +++ b/src/gcal-manager.c @@ -645,20 +645,21 @@ GList* gcal_manager_get_sources (GcalManager *manager) { GcalManagerPrivate *priv; - GList *l, *l2, *aux = NULL; - ESource *source; + GHashTableIter iter; + gpointer key, value; + GList *aux = NULL; priv = gcal_manager_get_instance_private (manager); - l = g_hash_table_get_keys (priv->clients); - for (l2 = l; l2 != NULL; l2 = g_list_next (l2)) - { - source = l2->data; - if (g_strv_contains ((const gchar * const *) priv->disabled_sources, e_source_get_uid (source))) - continue; - aux = g_list_append (aux, source); - } - g_list_free (l); + g_hash_table_iter_init (&iter, priv->clients); + while (g_hash_table_iter_next (&iter, &key, &value)) + { + GcalManagerUnit *unit = value; + if (!unit->enabled) + continue; + aux = g_list_append (aux, key); + + } return aux; }