aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-individual-store.c106
-rw-r--r--libempathy-gtk/empathy-individual-store.h7
-rw-r--r--libempathy-gtk/empathy-individual-view.c63
-rw-r--r--libempathy-gtk/empathy-individual-view.h7
-rw-r--r--src/empathy-main-window.c2
5 files changed, 70 insertions, 115 deletions
diff --git a/libempathy-gtk/empathy-individual-store.c b/libempathy-gtk/empathy-individual-store.c
index 41d9f5214..574ae2b58 100644
--- a/libempathy-gtk/empathy-individual-store.c
+++ b/libempathy-gtk/empathy-individual-store.c
@@ -61,7 +61,6 @@
typedef struct
{
EmpathyIndividualManager *manager;
- gboolean show_offline;
gboolean show_avatars;
gboolean show_groups;
gboolean is_compact;
@@ -99,7 +98,6 @@ enum
{
PROP_0,
PROP_INDIVIDUAL_MANAGER,
- PROP_SHOW_OFFLINE,
PROP_SHOW_AVATARS,
PROP_SHOW_PROTOCOLS,
PROP_SHOW_GROUPS,
@@ -352,8 +350,7 @@ individual_store_add_individual (EmpathyIndividualStore *self,
priv = GET_PRIV (self);
- if (EMP_STR_EMPTY (folks_individual_get_alias (individual)) ||
- (!priv->show_offline && !folks_individual_is_online (individual)))
+ if (EMP_STR_EMPTY (folks_individual_get_alias (individual)))
return;
if (priv->show_groups)
@@ -515,8 +512,7 @@ individual_store_contact_active_cb (ShowActiveData *data)
priv = GET_PRIV (data->self);
- if (data->remove &&
- !priv->show_offline && !folks_individual_is_online (data->individual))
+ if (data->remove)
{
DEBUG ("Individual'%s' active timeout, removing item",
folks_individual_get_alias (data->individual));
@@ -578,7 +574,6 @@ individual_store_contact_update (EmpathyIndividualStore *self,
EmpathyContact *contact;
GList *iters, *l;
gboolean in_list;
- gboolean should_be_in_list;
gboolean was_online = TRUE;
gboolean now_online = FALSE;
gboolean set_model = FALSE;
@@ -606,46 +601,7 @@ individual_store_contact_update (EmpathyIndividualStore *self,
/* Get online state now. */
now_online = folks_individual_is_online (individual);
- if (priv->show_offline || now_online)
- {
- should_be_in_list = TRUE;
- }
- else
- {
- should_be_in_list = FALSE;
- }
-
- if (!in_list && !should_be_in_list)
- {
- /* Nothing to do. */
- DEBUG ("Individual:'%s' in list:NO, should be:NO",
- folks_individual_get_alias (individual));
-
- g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
- g_list_free (iters);
- return;
- }
- else if (in_list && !should_be_in_list)
- {
- DEBUG ("Individual:'%s' in list:YES, should be:NO",
- folks_individual_get_alias (individual));
-
- if (priv->show_active)
- {
- do_remove = TRUE;
- do_set_active = TRUE;
- do_set_refresh = TRUE;
-
- set_model = TRUE;
- DEBUG ("Remove item (after timeout)");
- }
- else
- {
- DEBUG ("Remove item (now)!");
- individual_store_remove_individual (self, individual);
- }
- }
- else if (!in_list && should_be_in_list)
+ if (!in_list)
{
DEBUG ("Individual'%s' in list:NO, should be:YES",
folks_individual_get_alias (individual));
@@ -999,9 +955,6 @@ individual_store_get_property (GObject *object,
case PROP_INDIVIDUAL_MANAGER:
g_value_set_object (value, priv->manager);
break;
- case PROP_SHOW_OFFLINE:
- g_value_set_boolean (value, priv->show_offline);
- break;
case PROP_SHOW_AVATARS:
g_value_set_boolean (value, priv->show_avatars);
break;
@@ -1039,10 +992,6 @@ individual_store_set_property (GObject *object,
individual_store_set_individual_manager (EMPATHY_INDIVIDUAL_STORE
(object), g_value_get_object (value));
break;
- case PROP_SHOW_OFFLINE:
- empathy_individual_store_set_show_offline (EMPATHY_INDIVIDUAL_STORE
- (object), g_value_get_boolean (value));
- break;
case PROP_SHOW_AVATARS:
empathy_individual_store_set_show_avatars (EMPATHY_INDIVIDUAL_STORE
(object), g_value_get_boolean (value));
@@ -1086,12 +1035,6 @@ empathy_individual_store_class_init (EmpathyIndividualStoreClass *klass)
EMPATHY_TYPE_INDIVIDUAL_MANAGER,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
g_object_class_install_property (object_class,
- PROP_SHOW_OFFLINE,
- g_param_spec_boolean ("show-offline",
- "Show Offline",
- "Whether contact list should display "
- "offline contacts", FALSE, G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
PROP_SHOW_AVATARS,
g_param_spec_boolean ("show-avatars",
"Show Avatars",
@@ -1460,49 +1403,6 @@ empathy_individual_store_get_manager (EmpathyIndividualStore *self)
}
gboolean
-empathy_individual_store_get_show_offline (EmpathyIndividualStore *self)
-{
- EmpathyIndividualStorePriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), FALSE);
-
- priv = GET_PRIV (self);
-
- return priv->show_offline;
-}
-
-void
-empathy_individual_store_set_show_offline (EmpathyIndividualStore *self,
- gboolean show_offline)
-{
- EmpathyIndividualStorePriv *priv;
- GList *contacts, *l;
- gboolean show_active;
-
- g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
-
- priv = GET_PRIV (self);
-
- priv->show_offline = show_offline;
- show_active = priv->show_active;
-
- /* Disable temporarily. */
- priv->show_active = FALSE;
-
- contacts = empathy_individual_manager_get_members (priv->manager);
- for (l = contacts; l; l = l->next)
- {
- individual_store_contact_update (self, l->data);
- }
- g_list_free (contacts);
-
- /* Restore to original setting. */
- priv->show_active = show_active;
-
- g_object_notify (G_OBJECT (self), "show-offline");
-}
-
-gboolean
empathy_individual_store_get_show_avatars (EmpathyIndividualStore *self)
{
EmpathyIndividualStorePriv *priv;
diff --git a/libempathy-gtk/empathy-individual-store.h b/libempathy-gtk/empathy-individual-store.h
index 9c855824e..4c99610d6 100644
--- a/libempathy-gtk/empathy-individual-store.h
+++ b/libempathy-gtk/empathy-individual-store.h
@@ -92,13 +92,6 @@ EmpathyIndividualStore *empathy_individual_store_new (
EmpathyIndividualManager *empathy_individual_store_get_manager (
EmpathyIndividualStore *store);
-gboolean empathy_individual_store_get_show_offline (
- EmpathyIndividualStore *store);
-
-void empathy_individual_store_set_show_offline (
- EmpathyIndividualStore *store,
- gboolean show_offline);
-
gboolean empathy_individual_store_get_show_avatars (
EmpathyIndividualStore *store);
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index 79e6562e1..4ffbed3c5 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -70,6 +70,8 @@ typedef struct
GtkWidget *tooltip_widget;
GtkTargetList *file_targets;
+ gboolean show_offline;
+
GtkTreeModelFilter *filter;
GtkWidget *search_widget;
} EmpathyIndividualViewPriv;
@@ -94,6 +96,7 @@ enum
PROP_STORE,
PROP_VIEW_FEATURES,
PROP_INDIVIDUAL_FEATURES,
+ PROP_SHOW_OFFLINE,
};
/* TODO: re-add DRAG_TYPE_CONTACT_ID, for the case that we're dragging around
@@ -187,15 +190,20 @@ individual_view_filter_visible_func (GtkTreeModel *model,
FolksIndividual *individual = NULL;
gboolean is_group, is_separator, valid;
GtkTreeIter child_iter;
- gboolean visible;
+ gboolean visible, show_offline, is_online;
+ gboolean is_searching = TRUE;
+
+ show_offline = empathy_individual_view_get_show_offline (self);
if (priv->search_widget == NULL ||
!gtk_widget_get_visible (priv->search_widget))
- return TRUE;
+ is_searching = FALSE;
+
gtk_tree_model_get (model, iter,
EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, &is_group,
EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator,
+ EMPATHY_INDIVIDUAL_STORE_COL_IS_ONLINE, &is_online,
EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual,
-1);
@@ -203,7 +211,11 @@ individual_view_filter_visible_func (GtkTreeModel *model,
{
visible = individual_view_is_visible_individual (self, individual);
g_object_unref (individual);
- return visible;
+
+ if (is_searching)
+ return visible;
+ else
+ return (show_offline || is_online);
}
if (is_separator)
@@ -218,6 +230,7 @@ individual_view_filter_visible_func (GtkTreeModel *model,
{
gtk_tree_model_get (model, &child_iter,
EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual,
+ EMPATHY_INDIVIDUAL_STORE_COL_IS_ONLINE, &is_online,
-1);
if (individual == NULL)
@@ -227,7 +240,8 @@ individual_view_filter_visible_func (GtkTreeModel *model,
g_object_unref (individual);
/* show group if it has at least one visible contact in it */
- if (visible)
+ if ((is_searching && visible) ||
+ (!is_searching && (show_offline || is_online)))
return TRUE;
}
@@ -1734,6 +1748,9 @@ individual_view_get_property (GObject *object,
case PROP_INDIVIDUAL_FEATURES:
g_value_set_flags (value, priv->individual_features);
break;
+ case PROP_SHOW_OFFLINE:
+ g_value_set_boolean (value, priv->show_offline);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -1760,6 +1777,10 @@ individual_view_set_property (GObject *object,
case PROP_INDIVIDUAL_FEATURES:
priv->individual_features = g_value_get_flags (value);
break;
+ case PROP_SHOW_OFFLINE:
+ empathy_individual_view_set_show_offline (view,
+ g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -1820,6 +1841,12 @@ empathy_individual_view_class_init (EmpathyIndividualViewClass *klass)
"Flags for all enabled features for the menu",
EMPATHY_TYPE_INDIVIDUAL_FEATURE_FLAGS,
EMPATHY_CONTACT_FEATURE_NONE, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_SHOW_OFFLINE,
+ g_param_spec_boolean ("show-offline",
+ "Show Offline",
+ "Whether contact list should display "
+ "offline contacts", FALSE, G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (EmpathyIndividualViewPriv));
}
@@ -2192,3 +2219,31 @@ empathy_individual_view_set_live_search (EmpathyIndividualView *view,
G_CALLBACK (individual_view_search_show_cb), view);
}
}
+
+gboolean
+empathy_individual_view_get_show_offline (EmpathyIndividualView *self)
+{
+ EmpathyIndividualViewPriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_VIEW (self), FALSE);
+
+ priv = GET_PRIV (self);
+
+ return priv->show_offline;
+}
+
+void
+empathy_individual_view_set_show_offline (EmpathyIndividualView *self,
+ gboolean show_offline)
+{
+ EmpathyIndividualViewPriv *priv;
+
+ g_return_if_fail (EMPATHY_IS_INDIVIDUAL_VIEW (self));
+
+ priv = GET_PRIV (self);
+
+ priv->show_offline = show_offline;
+
+ g_object_notify (G_OBJECT (self), "show-offline");
+ gtk_tree_model_filter_refilter (priv->filter);
+}
diff --git a/libempathy-gtk/empathy-individual-view.h b/libempathy-gtk/empathy-individual-view.h
index 826e490bb..ce3c95ce3 100644
--- a/libempathy-gtk/empathy-individual-view.h
+++ b/libempathy-gtk/empathy-individual-view.h
@@ -95,5 +95,12 @@ GtkWidget *empathy_individual_view_get_group_menu (EmpathyIndividualView *view);
void empathy_individual_view_set_live_search (EmpathyIndividualView *view,
EmpathyLiveSearch *search);
+gboolean empathy_individual_view_get_show_offline (
+ EmpathyIndividualView *view);
+
+void empathy_individual_view_set_show_offline (
+ EmpathyIndividualView *view,
+ gboolean show_offline);
+
G_END_DECLS
#endif /* __EMPATHY_INDIVIDUAL_VIEW_H__ */
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index ae50eaa4e..6588dfd59 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -736,7 +736,7 @@ main_window_view_show_offline_cb (GtkToggleAction *action,
/* Turn off sound just while we alter the contact list. */
// FIXME: empathy_sound_set_enabled (FALSE);
- empathy_individual_store_set_show_offline (priv->individual_store,
+ empathy_individual_view_set_show_offline (priv->individual_view,
current);
//empathy_sound_set_enabled (TRUE);
}