aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-04-29 21:47:50 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-02 15:23:56 +0800
commit85058e4e3f88412683771172f7dace66366ad069 (patch)
treeaa69a1634762847b49250cdb5d21bd2e8f636b7d /libempathy-gtk
parent5ead12fb5b53cea0c8a97e8f101e2d729ca47282 (diff)
downloadgsoc2013-empathy-85058e4e3f88412683771172f7dace66366ad069.tar
gsoc2013-empathy-85058e4e3f88412683771172f7dace66366ad069.tar.gz
gsoc2013-empathy-85058e4e3f88412683771172f7dace66366ad069.tar.bz2
gsoc2013-empathy-85058e4e3f88412683771172f7dace66366ad069.tar.lz
gsoc2013-empathy-85058e4e3f88412683771172f7dace66366ad069.tar.xz
gsoc2013-empathy-85058e4e3f88412683771172f7dace66366ad069.tar.zst
gsoc2013-empathy-85058e4e3f88412683771172f7dace66366ad069.zip
Display favorite offline contacts only in the Favorite group (#648914)
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-individual-view.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index cc9d49e86..fcbc93fa4 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -1689,7 +1689,9 @@ static gboolean
individual_view_is_visible_individual (EmpathyIndividualView *self,
FolksIndividual *individual,
gboolean is_online,
- gboolean is_searching)
+ gboolean is_searching,
+ const gchar *group,
+ gboolean is_fake_group)
{
EmpathyIndividualViewPriv *priv = GET_PRIV (self);
EmpathyLiveSearch *live = EMPATHY_LIVE_SEARCH (priv->search_widget);
@@ -1721,8 +1723,14 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
is_favorite = folks_favourite_details_get_is_favourite (
FOLKS_FAVOURITE_DETAILS (individual));
- if (is_searching == FALSE)
- return (priv->show_offline || is_online || is_favorite);
+ if (is_searching == FALSE) {
+ if (is_favorite && is_fake_group &&
+ !tp_strdiff (group, EMPATHY_INDIVIDUAL_STORE_FAVORITE))
+ /* Always display favorite contacts in the favorite group */
+ return TRUE;
+
+ return (priv->show_offline || is_online);
+ }
/* check alias name */
str = folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual));
@@ -1757,6 +1765,28 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
return FALSE;
}
+static gchar *
+get_group (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gboolean *is_fake)
+{
+ GtkTreeIter parent_iter;
+ gchar *name = NULL;
+
+ *is_fake = FALSE;
+
+ if (!gtk_tree_model_iter_parent (model, &parent_iter, iter))
+ return NULL;
+
+ gtk_tree_model_get (model, &parent_iter,
+ EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name,
+ EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, is_fake,
+ -1);
+
+ return name;
+}
+
+
static gboolean
individual_view_filter_visible_func (GtkTreeModel *model,
GtkTreeIter *iter,
@@ -1783,10 +1813,16 @@ individual_view_filter_visible_func (GtkTreeModel *model,
if (individual != NULL)
{
+ gchar *group;
+ gboolean is_fake_group;
+
+ group = get_group (model, iter, &is_fake_group);
+
visible = individual_view_is_visible_individual (self, individual,
- is_online, is_searching);
+ is_online, is_searching, group, is_fake_group);
g_object_unref (individual);
+ g_free (group);
/* FIXME: Work around bgo#626552/bgo#621076 */
if (visible == TRUE)
@@ -1809,6 +1845,9 @@ individual_view_filter_visible_func (GtkTreeModel *model,
for (valid = gtk_tree_model_iter_children (model, &child_iter, iter);
valid; valid = gtk_tree_model_iter_next (model, &child_iter))
{
+ gchar *group;
+ gboolean is_fake_group;
+
gtk_tree_model_get (model, &child_iter,
EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual,
EMPATHY_INDIVIDUAL_STORE_COL_IS_ONLINE, &is_online,
@@ -1817,9 +1856,13 @@ individual_view_filter_visible_func (GtkTreeModel *model,
if (individual == NULL)
continue;
+ group = get_group (model, &child_iter, &is_fake_group);
+
visible = individual_view_is_visible_individual (self, individual,
- is_online, is_searching);
+ is_online, is_searching, group, is_fake_group);
+
g_object_unref (individual);
+ g_free (group);
/* show group if it has at least one visible contact in it */
if (visible == TRUE)