diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2009-01-31 01:33:53 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-01-31 01:33:53 +0800 |
commit | 6a5f844389c641862c68176b7dc633263a2f1d3b (patch) | |
tree | f8732e34b1c9e76518f2713c8f5fcfbbc20bdab2 /libempathy-gtk | |
parent | 131e07a1db3f65a444fcb4da2e44f51ca8e3e4b6 (diff) | |
download | gsoc2013-empathy-6a5f844389c641862c68176b7dc633263a2f1d3b.tar gsoc2013-empathy-6a5f844389c641862c68176b7dc633263a2f1d3b.tar.gz gsoc2013-empathy-6a5f844389c641862c68176b7dc633263a2f1d3b.tar.bz2 gsoc2013-empathy-6a5f844389c641862c68176b7dc633263a2f1d3b.tar.lz gsoc2013-empathy-6a5f844389c641862c68176b7dc633263a2f1d3b.tar.xz gsoc2013-empathy-6a5f844389c641862c68176b7dc633263a2f1d3b.tar.zst gsoc2013-empathy-6a5f844389c641862c68176b7dc633263a2f1d3b.zip |
improve function to find iter for blank contact
svn path=/trunk/; revision=2319
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-contact-selector.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/libempathy-gtk/empathy-contact-selector.c b/libempathy-gtk/empathy-contact-selector.c index f7c42e5ce..c5ed34f33 100644 --- a/libempathy-gtk/empathy-contact-selector.c +++ b/libempathy-gtk/empathy-contact-selector.c @@ -50,8 +50,8 @@ struct _EmpathyContactSelectorPriv }; static void changed_cb (GtkComboBox *widget, gpointer data); -static gboolean get_iter_for_contact (GtkTreeStore *store, - GtkTreeIter *list_iter, EmpathyContact *contact); +static gboolean get_iter_for_blank_contact (GtkTreeStore *store, + GtkTreeIter *blank_iter); EmpathyContact * @@ -102,7 +102,7 @@ notify_popup_shown_cb (GtkComboBox *widget, if (shown) { - if (get_iter_for_contact (GTK_TREE_STORE (priv->store), &blank_iter, NULL)) + if (get_iter_for_blank_contact (GTK_TREE_STORE (priv->store), &blank_iter)) { gtk_tree_store_remove (GTK_TREE_STORE (priv->store), &blank_iter); priv->is_blank_set = FALSE; @@ -144,7 +144,7 @@ changed_cb (GtkComboBox *widget, } else { - if (get_iter_for_contact (GTK_TREE_STORE (priv->store), &blank_iter, NULL)) + if (get_iter_for_blank_contact (GTK_TREE_STORE (priv->store), &blank_iter)) { gtk_tree_store_remove (GTK_TREE_STORE (priv->store), &blank_iter); priv->is_blank_set = FALSE; @@ -154,16 +154,14 @@ changed_cb (GtkComboBox *widget, static gboolean -get_iter_for_contact (GtkTreeStore *store, - GtkTreeIter *list_iter, - EmpathyContact *contact) +get_iter_for_blank_contact (GtkTreeStore *store, + GtkTreeIter *blank_iter) { GtkTreePath *path; GtkTreeIter tmp_iter; EmpathyContact *tmp_contact; - gboolean found = FALSE; + gboolean is_present = FALSE; - /* Do a linear search to find the row with CONTACT_COL set to contact. */ path = gtk_tree_path_new_first (); if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &tmp_iter, path)) { @@ -172,18 +170,18 @@ get_iter_for_contact (GtkTreeStore *store, gtk_tree_model_get (GTK_TREE_MODEL (store), &tmp_iter, EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &tmp_contact, -1); - found = (tmp_contact == contact); - if (found) + if (tmp_contact == NULL) { - *list_iter = tmp_iter; + *blank_iter = tmp_iter; + is_present = TRUE; break; } - } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), - &tmp_iter)); + } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &tmp_iter)); } gtk_tree_path_free (path); - return found; + + return is_present; } |