aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2009-01-31 01:34:07 +0800
committerxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2009-01-31 01:34:07 +0800
commit53baa6f67f5309688c07a16f6bc52384d21a7261 (patch)
tree97c399c23c070c43d5b919d484a176e5b55cebd7
parent796ea20a113583f639a1a6e86536d0bfc78d87e3 (diff)
downloadgsoc2013-empathy-53baa6f67f5309688c07a16f6bc52384d21a7261.tar
gsoc2013-empathy-53baa6f67f5309688c07a16f6bc52384d21a7261.tar.gz
gsoc2013-empathy-53baa6f67f5309688c07a16f6bc52384d21a7261.tar.bz2
gsoc2013-empathy-53baa6f67f5309688c07a16f6bc52384d21a7261.tar.lz
gsoc2013-empathy-53baa6f67f5309688c07a16f6bc52384d21a7261.tar.xz
gsoc2013-empathy-53baa6f67f5309688c07a16f6bc52384d21a7261.tar.zst
gsoc2013-empathy-53baa6f67f5309688c07a16f6bc52384d21a7261.zip
add function to find number of online contacts; fix sensitivity management
git-svn-id: svn+ssh://svn.gnome.org/svn/empathy/trunk@2324 4ee84921-47dd-4033-b63a-18d7a039a3e4
-rw-r--r--libempathy-gtk/empathy-contact-selector.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/libempathy-gtk/empathy-contact-selector.c b/libempathy-gtk/empathy-contact-selector.c
index 6b3d5790e..8fc07d626 100644
--- a/libempathy-gtk/empathy-contact-selector.c
+++ b/libempathy-gtk/empathy-contact-selector.c
@@ -69,6 +69,34 @@ empathy_contact_selector_get_selected (EmpathyContactSelector *selector)
}
+static guint
+get_number_online_contacts (GtkTreeStore *store)
+{
+ GtkTreePath *path;
+ GtkTreeIter tmp_iter;
+ gboolean is_online;
+ guint number_online_contacts = 0;
+
+ path = gtk_tree_path_new_first ();
+
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &tmp_iter, path))
+ {
+ 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_path_free (path);
+
+ return number_online_contacts;
+}
+
+
static gboolean
get_iter_for_blank_contact (GtkTreeStore *store,
GtkTreeIter *blank_iter)
@@ -79,6 +107,7 @@ get_iter_for_blank_contact (GtkTreeStore *store,
gboolean is_present = FALSE;
path = gtk_tree_path_new_first ();
+
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &tmp_iter, path))
{
do
@@ -110,7 +139,8 @@ set_blank_contact (EmpathyContactSelector *selector)
gtk_tree_store_insert (GTK_TREE_STORE (priv->store), &blank_iter, NULL, 0);
gtk_tree_store_set (GTK_TREE_STORE (priv->store), &blank_iter,
EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, NULL,
- EMPATHY_CONTACT_LIST_STORE_COL_NAME, ("Select a contact"), -1);
+ EMPATHY_CONTACT_LIST_STORE_COL_NAME, ("Select a contact"),
+ EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, FALSE, -1);
g_signal_handlers_block_by_func(selector, changed_cb, NULL);
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (selector), &blank_iter);
g_signal_handlers_unblock_by_func(selector, changed_cb, NULL);
@@ -136,14 +166,12 @@ static void
manage_sensitivity (EmpathyContactSelector *selector)
{
EmpathyContactSelectorPriv *priv = GET_PRIV (selector);
- gint children;
-
- children = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->store), NULL);
- g_print ("Number of children %d\n", children);
+ guint number_online_contacts =
+ get_number_online_contacts (GTK_TREE_STORE (priv->store));
- if (children == 1 && priv->is_blank_set)
+ if (number_online_contacts == 0 && priv->is_blank_set)
gtk_widget_set_sensitive (GTK_WIDGET (selector), FALSE);
- else if (children)
+ else if (number_online_contacts)
gtk_widget_set_sensitive (GTK_WIDGET (selector), TRUE);
else
gtk_widget_set_sensitive (GTK_WIDGET (selector), FALSE);