diff options
author | Laurent Contzen <lcontzen@gmail.com> | 2012-08-07 22:28:21 +0800 |
---|---|---|
committer | Laurent Contzen <lcontzen@gmail.com> | 2012-08-07 22:41:51 +0800 |
commit | 44472802c9c232f7ab6639af2e0a88b090016671 (patch) | |
tree | 445ce217b743f96d602ff20f87e9f58b4f7da42a /libempathy-gtk | |
parent | 5ff0b2f71b6516b399deb732bfe0124e32a8a7bf (diff) | |
download | gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.gz gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.bz2 gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.lz gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.xz gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.zst gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.zip |
Moved _contact_in_top from the model to the view
empathy-roster-model and empathy-roster-model-manager: removed _contact_in_top
empathy-roster-view: added new function contact_in_top and modified functions to use it
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-roster-model-manager.c | 15 | ||||
-rw-r--r-- | libempathy-gtk/empathy-roster-model.c | 25 | ||||
-rw-r--r-- | libempathy-gtk/empathy-roster-model.h | 5 | ||||
-rw-r--r-- | libempathy-gtk/empathy-roster-view.c | 56 |
4 files changed, 38 insertions, 63 deletions
diff --git a/libempathy-gtk/empathy-roster-model-manager.c b/libempathy-gtk/empathy-roster-model-manager.c index 0668db1d8..a7d952af7 100644 --- a/libempathy-gtk/empathy-roster-model-manager.c +++ b/libempathy-gtk/empathy-roster-model-manager.c @@ -407,20 +407,6 @@ empathy_roster_model_manager_get_top_individuals (EmpathyRosterModel *model) return empathy_individual_manager_get_top_individuals (self->priv->manager); } -static gboolean -empathy_roster_model_manager_contact_in_top (EmpathyRosterModel *model, - EmpathyRosterContact *contact) -{ - FolksIndividual *individual; - EmpathyRosterModelManager *self; - - self = EMPATHY_ROSTER_MODEL_MANAGER (model); - - individual = empathy_roster_contact_get_individual (contact); - - return individual_in_top_group_members (self, individual); -} - static void roster_model_iface_init (EmpathyRosterModelInterface *iface) { @@ -428,5 +414,4 @@ roster_model_iface_init (EmpathyRosterModelInterface *iface) iface->get_groups_for_individual = empathy_roster_model_manager_get_groups_for_individual; iface->get_top_individuals = empathy_roster_model_manager_get_top_individuals; - iface->contact_in_top = empathy_roster_model_manager_contact_in_top; } diff --git a/libempathy-gtk/empathy-roster-model.c b/libempathy-gtk/empathy-roster-model.c index f1e596029..31cc4251f 100644 --- a/libempathy-gtk/empathy-roster-model.c +++ b/libempathy-gtk/empathy-roster-model.c @@ -156,28 +156,3 @@ empathy_roster_model_get_top_individuals (EmpathyRosterModel *self) return (* iface->get_top_individuals) (self); } - -/** - * empathy_roster_model_contact_in_top: - * @self: a #EmpathyRosterModel - * @contact: a #EmpathyRosterContact - * - * Checks if the passed #EmpathyRosterContact should be displayed in - * top contacts. - * - * Returns: %TRUE if it should be displayed in top contacts, %FALSE - * if not - */ -gboolean -empathy_roster_model_contact_in_top (EmpathyRosterModel *self, - EmpathyRosterContact *contact) -{ - EmpathyRosterModelInterface *iface; - - g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), FALSE); - - iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self); - g_return_val_if_fail (iface->contact_in_top != NULL, FALSE); - - return (* iface->contact_in_top) (self, contact); -} diff --git a/libempathy-gtk/empathy-roster-model.h b/libempathy-gtk/empathy-roster-model.h index dae23390e..71b204231 100644 --- a/libempathy-gtk/empathy-roster-model.h +++ b/libempathy-gtk/empathy-roster-model.h @@ -45,8 +45,6 @@ struct _EmpathyRosterModelInterface GList * (*get_groups_for_individual) (EmpathyRosterModel *self, FolksIndividual *individual); GList * (*get_top_individuals) (EmpathyRosterModel *self); - gboolean (*contact_in_top) (EmpathyRosterModel *self, - EmpathyRosterContact *contact); }; GType empathy_roster_model_get_type (void); @@ -88,9 +86,6 @@ GList * empathy_roster_model_get_groups_for_individual ( GList * empathy_roster_model_get_top_individuals (EmpathyRosterModel *self); -gboolean empathy_roster_model_contact_in_top (EmpathyRosterModel *self, - EmpathyRosterContact *contact); - G_END_DECLS #endif /* #ifndef __EMPATHY_ROSTER_MODEL_H__*/ diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c index de14b5d97..a820d2b62 100644 --- a/libempathy-gtk/empathy-roster-view.c +++ b/libempathy-gtk/empathy-roster-view.c @@ -484,6 +484,40 @@ individual_removed_cb (EmpathyRosterModel *model, individual_removed (self, individual); } +static gboolean +contact_in_top (EmpathyRosterView *self, + EmpathyRosterContact *contact) +{ + if (!self->priv->show_groups) + { + /* Always display top contacts in non-group mode. */ + GList *groups; + FolksIndividual *individual; + gboolean result = FALSE; + + individual = empathy_roster_contact_get_individual (contact); + + groups = empathy_roster_model_get_groups_for_individual ( + self->priv->model, individual); + + if (g_list_find (groups, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP) != NULL) + result = TRUE; + + g_list_free (groups); + + return result; + } + + if (!tp_strdiff (empathy_roster_contact_get_group (contact), + EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP)) + /* If we are displaying contacts, we only want to *always* display the + * RosterContact which is displayed at the top; not the ones displayed in + * the 'normal' group sections */ + return TRUE; + + return FALSE; +} + static gint compare_roster_contacts_by_alias (EmpathyRosterContact *a, EmpathyRosterContact *b) @@ -507,8 +541,8 @@ compare_roster_contacts_no_group (EmpathyRosterView *self, { gboolean top_a, top_b; - top_a = empathy_roster_model_contact_in_top (self->priv->model, a); - top_b = empathy_roster_model_contact_in_top (self->priv->model, b); + top_a = contact_in_top (self, a); + top_b = contact_in_top (self, b); if (top_a == top_b) /* Both contacts are in the top of the roster (or not). Sort them @@ -731,22 +765,8 @@ contact_should_be_displayed (EmpathyRosterView *self, if (self->priv->show_offline) return TRUE; - if (empathy_roster_model_contact_in_top (self->priv->model, - contact)) - { - const gchar *group_name; - - if (!self->priv->show_groups) - /* Always display favourite contacts in non-group mode. */ - return TRUE; - - group_name = empathy_roster_contact_get_group (contact); - - if (!tp_strdiff (group_name, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP)) - /* Always display favourite contact in group mode only in the - * 'top group'*/ - return TRUE; - } + if (contact_in_top (self, contact)) + return TRUE; return empathy_roster_contact_is_online (contact); } |