GHashTable *folks_individual_cache;
/* Hash: char *groupname -> GtkTreeIter * */
GHashTable *empathy_group_cache;
+ gboolean show_active;
};
typedef struct
empathy_individual_store_add_individual (EmpathyIndividualStore *self,
FolksIndividual *individual)
{
- GtkTreeIter iter;
- GeeIterator *group_iter = NULL;
+ GtkTreeIter iter, iter_group;
+ GeeSet *group_set = NULL;
+ gboolean grouped = FALSE;
if (EMP_STR_EMPTY (folks_alias_details_get_alias (
FOLKS_ALIAS_DETAILS (individual))))
return;
- if (self->priv->show_groups)
+ if (!self->priv->show_groups)
{
- GeeSet *group_set = NULL;
-
- group_set = folks_group_details_get_groups (
- FOLKS_GROUP_DETAILS (individual));
+ /* add our individual to the toplevel of the store */
+ add_individual_to_store (GTK_TREE_STORE (self), &iter, NULL,
+ individual);
- if (gee_collection_get_size (GEE_COLLECTION (group_set)) > 0)
- group_iter = gee_iterable_iterator (GEE_ITERABLE (group_set));
+ goto finally;
}
- /* fall-back groups, in case there are no named groups */
- if (group_iter == NULL)
+ group_set = folks_group_details_get_groups (
+ FOLKS_GROUP_DETAILS (individual));
+
+ if (gee_collection_get_size (GEE_COLLECTION (group_set)) > 0)
+ {
+ /* add the contact to its groups */
+ GeeIterator *group_iter =
+ gee_iterable_iterator (GEE_ITERABLE (group_set));
+
+ while (group_iter != NULL && gee_iterator_next (group_iter))
+ {
+ gchar *group_name = gee_iterator_get (group_iter);
+
+ individual_store_get_group (self, group_name, &iter_group,
+ NULL, NULL, FALSE);
+
+ add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
+ individual);
+ grouped = TRUE;
+
+ g_free (group_name);
+ }
+
+ g_clear_object (&group_iter);
+ }
+ else
{
- GtkTreeIter iter_group, *parent;
+ /* fall-back groups, in case there are no named groups */
EmpathyContact *contact;
TpConnection *connection;
- gchar *protocol_name = NULL;
-
- parent = &iter_group;
+ const gchar *protocol_name = NULL;
contact = empathy_contact_dup_from_folks_individual (individual);
if (contact != NULL)
{
connection = empathy_contact_get_connection (contact);
- tp_connection_parse_object_path (connection, &protocol_name, NULL);
+ protocol_name = tp_connection_get_protocol_name (connection);
}
- if (!self->priv->show_groups)
- parent = NULL;
- else if (!tp_strdiff (protocol_name, "local-xmpp"))
+ if (!tp_strdiff (protocol_name, "local-xmpp"))
{
/* these are People Nearby */
individual_store_get_group (self,
EMPATHY_INDIVIDUAL_STORE_PEOPLE_NEARBY, &iter_group, NULL, NULL,
TRUE);
+ add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
+ individual);
+ grouped = TRUE;
}
- else
- {
- individual_store_get_group (self,
- EMPATHY_INDIVIDUAL_STORE_UNGROUPED,
- &iter_group, NULL, NULL, TRUE);
- }
-
- add_individual_to_store (GTK_TREE_STORE (self), &iter, parent,
- individual);
- g_free (protocol_name);
g_clear_object (&contact);
}
- /* Else add to each group. */
- while (group_iter != NULL && gee_iterator_next (group_iter))
+ if (folks_favourite_details_get_is_favourite (
+ FOLKS_FAVOURITE_DETAILS (individual)))
{
- gchar *group_name = gee_iterator_get (group_iter);
- GtkTreeIter iter_group;
-
- individual_store_get_group (self, group_name, &iter_group, NULL, NULL,
- FALSE);
+ /* Add contact to the fake 'Favorites' group */
+ individual_store_get_group (self, EMPATHY_INDIVIDUAL_STORE_FAVORITE,
+ &iter_group, NULL, NULL, TRUE);
add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
individual);
-
- g_free (group_name);
+ grouped = TRUE;
}
- g_clear_object (&group_iter);
- if (self->priv->show_groups &&
- folks_favourite_details_get_is_favourite (
- FOLKS_FAVOURITE_DETAILS (individual)))
+ if (!grouped)
{
- /* Add contact to the fake 'Favorites' group */
- GtkTreeIter iter_group;
-
- individual_store_get_group (self, EMPATHY_INDIVIDUAL_STORE_FAVORITE,
+ /* Else add the contact to 'Ungrouped' */
+ individual_store_get_group (self,
+ EMPATHY_INDIVIDUAL_STORE_UNGROUPED,
&iter_group, NULL, NULL, TRUE);
-
add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
individual);
}
+
+finally:
individual_store_contact_update (self, individual);
}
empathy_individual_store_add_individual (self, individual);
- if (self->show_active)
+ if (self->priv->show_active)
{
do_set_active = TRUE;
}
/* Is this really an update or an online/offline. */
- if (self->show_active)
+ if (self->priv->show_active)
{
if (was_online != now_online)
{
-1);
}
- if (self->show_active && do_set_active)
+ if (self->priv->show_active && do_set_active)
{
individual_store_contact_set_active (self, individual, do_set_active,
do_set_refresh);
g_source_remove (self->priv->inhibit_active);
}
- if (self->setup_idle_id != 0)
- {
- g_source_remove (self->setup_idle_id);
- }
-
g_hash_table_unref (self->priv->status_icons);
g_hash_table_unref (self->priv->folks_individual_cache);
g_hash_table_unref (self->priv->empathy_group_cache);
static gboolean
individual_store_inhibit_active_cb (EmpathyIndividualStore *self)
{
- self->show_active = TRUE;
+ self->priv->show_active = TRUE;
self->priv->inhibit_active = 0;
return FALSE;
empathy_individual_store_set_show_groups (EmpathyIndividualStore *self,
gboolean show_groups)
{
+ EmpathyIndividualStoreClass *klass;
+
g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
+ klass = EMPATHY_INDIVIDUAL_STORE_GET_CLASS ( self);
+
if (self->priv->show_groups == show_groups)
{
return;
self->priv->show_groups = show_groups;
- if (self->setup_idle_id == 0)
+ if (!klass->initial_loading (self))
{
/* Remove all contacts and add them back, not optimized but
* that's the easy way :)
* This is only done if there's not a pending setup idle
* callback, otherwise it will race and the contacts will get
* added twice */
- EmpathyIndividualStoreClass *klass = EMPATHY_INDIVIDUAL_STORE_GET_CLASS (
- self);
gtk_tree_store_clear (GTK_TREE_STORE (self));
/* Also clear the cache */
return pixbuf_status;
}
+
+void
+empathy_individual_store_refresh_individual (EmpathyIndividualStore *self,
+ FolksIndividual *individual)
+{
+ gboolean show_active;
+
+ show_active = self->priv->show_active;
+ self->priv->show_active = FALSE;
+ empathy_individual_store_remove_individual (self, individual);
+ empathy_individual_store_add_individual (self, individual);
+ self->priv->show_active = show_active;
+}