diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-01-31 01:35:18 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-01-31 01:35:18 +0800 |
commit | 469ecd6b2967e98061bed1b30f77158373c08844 (patch) | |
tree | a8dfaeb24831367d2476189bcd5046f18fe5fc56 | |
parent | 56938e43323f7b967beec149fcb18382bfb2e7df (diff) | |
download | gsoc2013-empathy-469ecd6b2967e98061bed1b30f77158373c08844.tar gsoc2013-empathy-469ecd6b2967e98061bed1b30f77158373c08844.tar.gz gsoc2013-empathy-469ecd6b2967e98061bed1b30f77158373c08844.tar.bz2 gsoc2013-empathy-469ecd6b2967e98061bed1b30f77158373c08844.tar.lz gsoc2013-empathy-469ecd6b2967e98061bed1b30f77158373c08844.tar.xz gsoc2013-empathy-469ecd6b2967e98061bed1b30f77158373c08844.tar.zst gsoc2013-empathy-469ecd6b2967e98061bed1b30f77158373c08844.zip |
Simplified loops in
Simplified loops in contact_selector_get_{number_online_contacts,iter_for_blank_contact}.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=2349
-rw-r--r-- | libempathy-gtk/empathy-contact-selector.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/libempathy-gtk/empathy-contact-selector.c b/libempathy-gtk/empathy-contact-selector.c index f1a1a6873..e4648f241 100644 --- a/libempathy-gtk/empathy-contact-selector.c +++ b/libempathy-gtk/empathy-contact-selector.c @@ -56,17 +56,16 @@ contact_selector_get_number_online_contacts (GtkTreeStore *store) GtkTreeIter tmp_iter; gboolean is_online; guint number_online_contacts = 0; + gboolean ok; - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &tmp_iter)) + for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &tmp_iter); + ok; ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &tmp_iter)) { - do - { - gtk_tree_model_get (GTK_TREE_MODEL (store), - &tmp_iter, EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, - &is_online, -1); - if (is_online) - number_online_contacts++; - } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &tmp_iter)); + gtk_tree_model_get (GTK_TREE_MODEL (store), + &tmp_iter, EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, + &is_online, -1); + if (is_online) + number_online_contacts++; } return number_online_contacts; @@ -79,21 +78,20 @@ contact_selector_get_iter_for_blank_contact (GtkTreeStore *store, GtkTreeIter tmp_iter; EmpathyContact *tmp_contact; gboolean is_present = FALSE; + gboolean ok; - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &tmp_iter)) + for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &tmp_iter); + ok; ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &tmp_iter)) { - do + gtk_tree_model_get (GTK_TREE_MODEL (store), + &tmp_iter, EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, + &tmp_contact, -1); + if (tmp_contact == NULL) { - gtk_tree_model_get (GTK_TREE_MODEL (store), - &tmp_iter, EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, - &tmp_contact, -1); - if (tmp_contact == NULL) - { - *blank_iter = tmp_iter; - is_present = TRUE; - break; - } - } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &tmp_iter)); + *blank_iter = tmp_iter; + is_present = TRUE; + break; + } } return is_present; |