#include <glib/gi18n-lib.h>
-#include <libempathy-gtk/empathy-roster-contact.h>
-#include <libempathy-gtk/empathy-roster-group.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
+#include "empathy-contact-groups.h"
+
+#include "empathy-roster-contact.h"
+#include "empathy-roster-group.h"
+#include "empathy-ui-utils.h"
G_DEFINE_TYPE (EmpathyRosterView, empathy_roster_view, EGG_TYPE_LIST_BOX)
/* Flashing delay for icons (milliseconds). */
#define FLASH_TIMEOUT 500
+/* Delay in milliseconds between the last stroke on the keyboard and the start
+ * of the live search. */
+#define SEARCH_TIMEOUT 500
+
enum
{
- PROP_MANAGER = 1,
+ PROP_MODEL = 1,
PROP_SHOW_OFFLINE,
PROP_SHOW_GROUPS,
PROP_EMPTY,
SIG_INDIVIDUAL_ACTIVATED,
SIG_POPUP_INDIVIDUAL_MENU,
SIG_EVENT_ACTIVATED,
+ SIG_INDIVIDUAL_TOOLTIP,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
#define NO_GROUP "X-no-group"
-#define UNGROUPED _("Ungrouped")
-#define TOP_GROUP _("Top Contacts")
struct _EmpathyRosterViewPriv
{
- EmpathyIndividualManager *manager;
-
/* FolksIndividual (borrowed) -> GHashTable (
* (gchar * group_name) -> EmpathyRosterContact (borrowed))
*
guint flash_id;
gboolean display_flash_event;
+ guint search_id;
+
gboolean show_offline;
gboolean show_groups;
gboolean empty;
EmpathyLiveSearch *search;
- EmpathyRosterViewIndividualTooltipCb individual_tooltip_cb;
- gpointer individual_tooltip_data;
+ EmpathyRosterModel *model;
};
typedef struct
switch (property_id)
{
- case PROP_MANAGER:
- g_value_set_object (value, self->priv->manager);
+ case PROP_MODEL:
+ g_value_set_object (value, self->priv->model);
break;
case PROP_SHOW_OFFLINE:
g_value_set_boolean (value, self->priv->show_offline);
switch (property_id)
{
- case PROP_MANAGER:
- g_assert (self->priv->manager == NULL); /* construct only */
- self->priv->manager = g_value_dup_object (value);
+ case PROP_MODEL:
+ g_assert (self->priv->model == NULL);
+ self->priv->model = g_value_dup_object (value);
break;
case PROP_SHOW_OFFLINE:
empathy_roster_view_show_offline (self, g_value_get_boolean (value));
}
g_list_free (widgets);
+
+ empathy_contact_group_set_expanded (empathy_roster_group_get_name (group),
+ gtk_expander_get_expanded (GTK_EXPANDER (group)));
}
static EmpathyRosterGroup *
if (roster_group != NULL)
return EMPATHY_ROSTER_GROUP (roster_group);
- if (!tp_strdiff (group, TOP_GROUP))
+ if (!tp_strdiff (group, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP))
roster_group = empathy_roster_group_new (group, "emblem-favorite-symbolic");
+ else if (!tp_strdiff (group, EMPATHY_ROSTER_MODEL_GROUP_PEOPLE_NEARBY))
+ roster_group = empathy_roster_group_new (group, "im-local-xmpp");
else
roster_group = empathy_roster_group_new (group, NULL);
+ gtk_expander_set_expanded (GTK_EXPANDER (roster_group),
+ empathy_contact_group_get_expanded (group));
+
g_signal_connect (roster_group, "notify::expanded",
G_CALLBACK (group_expanded_cb), self);
return EMPATHY_ROSTER_GROUP (roster_group);
}
+static void
+update_empty (EmpathyRosterView *self,
+ gboolean empty)
+{
+ if (self->priv->empty == empty)
+ return;
+
+ self->priv->empty = empty;
+ g_object_notify (G_OBJECT (self), "empty");
+}
+
+static gboolean filter_group (EmpathyRosterView *self,
+ EmpathyRosterGroup *group);
+
+static gboolean
+at_least_one_group_displayed (EmpathyRosterView *self)
+{
+ GHashTableIter iter;
+ gpointer v;
+
+ g_hash_table_iter_init (&iter, self->priv->roster_groups);
+ while (g_hash_table_iter_next (&iter, NULL, &v))
+ {
+ EmpathyRosterGroup *group = EMPATHY_ROSTER_GROUP (v);
+
+ if (filter_group (self, group))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+check_if_empty (EmpathyRosterView *self)
+{
+ /* Roster is considered as empty if there is no contact *and* no group
+ * currently displayed. */
+ if (g_hash_table_size (self->priv->displayed_contacts) != 0 ||
+ at_least_one_group_displayed (self))
+ {
+ update_empty (self, FALSE);
+ return;
+ }
+
+ update_empty (self, TRUE);
+}
+
static void
update_group_widgets (EmpathyRosterView *self,
EmpathyRosterGroup *group,
count = empathy_roster_group_remove_widget (group, GTK_WIDGET (contact));
if (count != old_count)
- egg_list_box_child_changed (EGG_LIST_BOX (self), GTK_WIDGET (group));
+ {
+ egg_list_box_child_changed (EGG_LIST_BOX (self), GTK_WIDGET (group));
+
+ check_if_empty (self);
+ }
}
static void
if (contacts == NULL)
return;
+ if (g_hash_table_lookup (contacts, group) != NULL)
+ return;
+
if (tp_strdiff (group, NO_GROUP))
roster_group = ensure_roster_group (self, group);
}
}
+static void
+individual_favourite_change_cb (FolksIndividual *individual,
+ GParamSpec *spec,
+ EmpathyRosterView *self)
+{
+ /* We may have to refilter the contact as only favorite contacts are always
+ * displayed regardless of their presence. */
+ GHashTable *contacts;
+ GtkWidget *contact;
+
+ contacts = g_hash_table_lookup (self->priv->roster_contacts, individual);
+ if (contacts == NULL)
+ return;
+
+ if (self->priv->show_groups)
+ contact = g_hash_table_lookup (contacts,
+ EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP);
+ else
+ contact = g_hash_table_lookup (contacts, NO_GROUP);
+
+ if (contact == NULL)
+ return;
+
+ egg_list_box_child_changed (EGG_LIST_BOX (self), contact);
+}
+
static void
individual_added (EmpathyRosterView *self,
FolksIndividual *individual)
}
else
{
- GeeSet *groups;
+ GList *groups, *l;
- if (folks_favourite_details_get_is_favourite (
- FOLKS_FAVOURITE_DETAILS (individual)))
- {
- add_to_group (self, individual, TOP_GROUP);
- }
+ groups = empathy_roster_model_dup_groups_for_individual (self->priv->model,
+ individual);
- groups = folks_group_details_get_groups (
- FOLKS_GROUP_DETAILS (individual));
-
- if (gee_collection_get_size (GEE_COLLECTION (groups)) > 0)
+ if (g_list_length (groups) > 0)
{
- GeeIterator *iter = gee_iterable_iterator (GEE_ITERABLE (groups));
-
- while (iter != NULL && gee_iterator_next (iter))
+ for (l = groups; l != NULL; l = g_list_next (l))
{
- gchar *group = gee_iterator_get (iter);
-
- add_to_group (self, individual, group);
-
- g_free (group);
+ add_to_group (self, individual, l->data);
}
-
- g_clear_object (&iter);
}
else
{
/* No group, adds to Ungrouped */
- add_to_group (self, individual, UNGROUPED);
+ add_to_group (self, individual, EMPATHY_ROSTER_MODEL_GROUP_UNGROUPED);
}
+
+ g_list_free_full (groups, g_free);
}
+
+ tp_g_signal_connect_object (individual, "notify::is-favourite",
+ G_CALLBACK (individual_favourite_change_cb), self, 0);
}
static void
}
static void
-members_changed_cb (EmpathyIndividualManager *manager,
- const gchar *message,
- GList *added,
- GList *removed,
- TpChannelGroupChangeReason reason,
+individual_added_cb (EmpathyRosterModel *model,
+ FolksIndividual *individual,
EmpathyRosterView *self)
{
- GList *l;
+ individual_added (self, individual);
+}
- for (l = added; l != NULL; l = g_list_next (l))
+static void
+individual_removed_cb (EmpathyRosterModel *model,
+ FolksIndividual *individual,
+ EmpathyRosterView *self)
+{
+ individual_removed (self, individual);
+}
+
+static gboolean
+contact_in_top (EmpathyRosterView *self,
+ EmpathyRosterContact *contact)
+{
+ if (!self->priv->show_groups)
{
- FolksIndividual *individual = l->data;
+ /* Always display top contacts in non-group mode. */
+ GList *groups;
+ FolksIndividual *individual;
+ gboolean result = FALSE;
- individual_added (self, individual);
- }
+ individual = empathy_roster_contact_get_individual (contact);
- for (l = removed; l != NULL; l = g_list_next (l))
- {
- FolksIndividual *individual = l->data;
+ groups = empathy_roster_model_dup_groups_for_individual (
+ self->priv->model, individual);
+
+ if (g_list_find_custom (groups, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP,
+ (GCompareFunc) g_strcmp0) != NULL)
+ result = TRUE;
+
+ g_list_free_full (groups, g_free);
- individual_removed (self, individual);
+ 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
return g_ascii_strcasecmp (alias_a, alias_b);
}
-static gboolean
-contact_is_favourite (EmpathyRosterContact *contact)
-{
- FolksIndividual *individual;
-
- individual = empathy_roster_contact_get_individual (contact);
-
- return folks_favourite_details_get_is_favourite (
- FOLKS_FAVOURITE_DETAILS (individual));
-}
-
-static gboolean
-contact_in_top (EmpathyRosterView *self,
- EmpathyRosterContact *contact)
-{
- FolksIndividual *individual;
- GList *tops;
-
- if (contact_is_favourite (contact))
- return TRUE;
-
- individual = empathy_roster_contact_get_individual (contact);
-
- tops = empathy_individual_manager_get_top_individuals (self->priv->manager);
-
- if (g_list_index (tops, individual) != -1)
- return TRUE;
-
- return FALSE;
-}
-
static gint
compare_roster_contacts_no_group (EmpathyRosterView *self,
EmpathyRosterContact *a,
compare_group_names (const gchar *group_a,
const gchar *group_b)
{
- if (!tp_strdiff (group_a, TOP_GROUP))
+ if (!tp_strdiff (group_a, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP))
return -1;
- if (!tp_strdiff (group_b, TOP_GROUP))
+ if (!tp_strdiff (group_b, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP))
return 1;
+ if (!tp_strdiff (group_a, EMPATHY_ROSTER_MODEL_GROUP_UNGROUPED))
+ return 1;
+ else if (!tp_strdiff (group_b, EMPATHY_ROSTER_MODEL_GROUP_UNGROUPED))
+ return -1;
+
return g_ascii_strcasecmp (group_a, group_b);
}
return gtk_widget_get_visible (GTK_WIDGET (self->priv->search));
}
-static void
-update_empty (EmpathyRosterView *self,
- gboolean empty)
-{
- if (self->priv->empty == empty)
- return;
-
- self->priv->empty = empty;
- g_object_notify (G_OBJECT (self), "empty");
-}
-
static void
add_to_displayed (EmpathyRosterView *self,
EmpathyRosterContact *contact)
FolksIndividual *individual;
GHashTable *contacts;
GHashTableIter iter;
- gpointer v;
+ gpointer k;
if (g_hash_table_lookup (self->priv->displayed_contacts, contact) != NULL)
return;
/* Groups of this contact may now be displayed if we just displays the first
* child in this group. */
+
+ if (!self->priv->show_groups)
+ return;
+
individual = empathy_roster_contact_get_individual (contact);
contacts = g_hash_table_lookup (self->priv->roster_contacts, individual);
if (contacts == NULL)
return;
g_hash_table_iter_init (&iter, contacts);
- while (g_hash_table_iter_next (&iter, NULL, &v))
+ while (g_hash_table_iter_next (&iter, &k, NULL))
{
- GtkWidget *group = GTK_WIDGET (v);
+ const gchar *group_name = k;
+ GtkWidget *group;
+
+ group = g_hash_table_lookup (self->priv->roster_groups, group_name);
+ if (group == NULL)
+ continue;
egg_list_box_child_changed (EGG_LIST_BOX (self), group);
}
{
g_hash_table_remove (self->priv->displayed_contacts, contact);
- if (g_hash_table_size (self->priv->displayed_contacts) == 0)
- update_empty (self, TRUE);
+ check_if_empty (self);
+}
+
+static gboolean
+contact_is_favorite (EmpathyRosterContact *contact)
+{
+ FolksIndividual *individual;
+
+ individual = empathy_roster_contact_get_individual (contact);
+
+ return folks_favourite_details_get_is_favourite (
+ FOLKS_FAVOURITE_DETAILS (individual));
}
/**
empathy_live_search_get_text (self->priv->search),
empathy_live_search_get_words (self->priv->search));
}
- else
- {
- if (self->priv->show_offline)
- {
- return TRUE;
- }
- else if (!self->priv->show_groups &&
- contact_is_favourite (contact))
- {
- /* Always display favourite contacts in non-group mode. In the group
- * mode we'll display only the one in the 'top' section. */
- return TRUE;
- }
- else
- {
- return empathy_roster_contact_is_online (contact);
- }
- }
+
+ if (self->priv->show_offline)
+ return TRUE;
+
+ if (contact_in_top (self, contact) &&
+ contact_is_favorite (contact))
+ /* Favorite top contacts are always displayed */
+ return TRUE;
+
+ return empathy_roster_contact_is_online (contact);
}
+
static gboolean
filter_contact (EmpathyRosterView *self,
EmpathyRosterContact *contact)
group_name = empathy_roster_contact_get_group (contact);
group = lookup_roster_group (self, group_name);
- if (!tp_strdiff (group_name, TOP_GROUP) &&
- contact_is_favourite (contact))
- displayed = TRUE;
-
if (group != NULL)
{
/* When searching, always display even if the group is closed */
EmpathyRosterGroup *group)
{
GList *widgets, *l;
+ gboolean result = FALSE;
/* Display the group if it contains at least one displayed contact */
widgets = empathy_roster_group_get_widgets (group);
EmpathyRosterContact *contact = l->data;
if (contact_should_be_displayed (self, contact))
- return TRUE;
+ {
+ result = TRUE;
+ break;
+ }
}
- return FALSE;
+ g_list_free (widgets);
+
+ return result;
}
static gboolean
g_return_val_if_reached (FALSE);
}
-/* @list: GList of EmpathyRosterContact
- *
- * Returns: %TRUE if @list contains an EmpathyRosterContact associated with
- * @individual */
-static gboolean
-individual_in_list (FolksIndividual *individual,
- GList *list)
-{
- GList *l;
-
- for (l = list; l != NULL; l = g_list_next (l))
- {
- EmpathyRosterContact *contact = l->data;
-
- if (empathy_roster_contact_get_individual (contact) == individual)
- return TRUE;
- }
-
- return FALSE;
-}
-
static void
populate_view (EmpathyRosterView *self)
{
GList *individuals, *l;
- individuals = empathy_individual_manager_get_members (self->priv->manager);
+ individuals = empathy_roster_model_get_individuals (self->priv->model);
for (l = individuals; l != NULL; l = g_list_next (l))
{
FolksIndividual *individual = l->data;
if (g_hash_table_size (contacts) == 0)
{
- add_to_group (self, individual, UNGROUPED);
+ add_to_group (self, individual, EMPATHY_ROSTER_MODEL_GROUP_UNGROUPED);
}
roster_group = lookup_roster_group (self, group);
}
static void
-update_top_contacts (EmpathyRosterView *self)
+groups_changed_cb (EmpathyRosterModel *model,
+ FolksIndividual *individual,
+ const gchar *group,
+ gboolean is_member,
+ EmpathyRosterView *self)
{
- GList *tops, *l;
- GList *to_add = NULL, *to_remove = NULL;
- EmpathyRosterGroup *group;
-
if (!self->priv->show_groups)
{
egg_list_box_resort (EGG_LIST_BOX (self));
return;
}
- tops = empathy_individual_manager_get_top_individuals (self->priv->manager);
-
- group = g_hash_table_lookup (self->priv->roster_groups, TOP_GROUP);
- if (group == NULL)
- {
- to_add = g_list_copy (tops);
- }
- else
- {
- GList *contacts;
-
- contacts = empathy_roster_group_get_widgets (group);
-
- /* Check which EmpathyRosterContact have to be removed */
- for (l = contacts; l != NULL; l = g_list_next (l))
- {
- EmpathyRosterContact *contact = l->data;
- FolksIndividual *individual;
-
- if (contact_is_favourite (contact))
- continue;
-
- individual = empathy_roster_contact_get_individual (contact);
-
- if (g_list_find (tops, individual) == NULL)
- to_remove = g_list_prepend (to_remove, individual);
- }
-
- /* Check which EmpathyRosterContact have to be added */
- for (l = tops; l != NULL; l = g_list_next (l))
- {
- FolksIndividual *individual = l->data;
-
- if (!individual_in_list (individual, contacts))
- to_add = g_list_prepend (to_add, individual);
- }
- }
-
- for (l = to_add; l != NULL; l = g_list_next (l))
- add_to_group (self, l->data, TOP_GROUP);
-
- for (l = to_remove; l != NULL; l = g_list_next (l))
- remove_from_group (self, l->data, TOP_GROUP);
-
- g_list_free (to_add);
- g_list_free (to_remove);
-}
-
-static void
-groups_changed_cb (EmpathyIndividualManager *manager,
- FolksIndividual *individual,
- gchar *group,
- gboolean is_member,
- EmpathyRosterView *self)
-{
- if (!self->priv->show_groups)
- return;
-
if (is_member)
{
add_to_group (self, individual, group);
}
}
-static void
-top_individuals_changed_cb (EmpathyIndividualManager *manager,
- GParamSpec *spec,
- EmpathyRosterView *self)
-{
- update_top_contacts (self);
-}
-
-static void
-favourites_changed_cb (EmpathyIndividualManager *manager,
- FolksIndividual *individual,
- gboolean favourite,
- EmpathyRosterView *self)
-{
- GHashTable *contacts;
-
- contacts = g_hash_table_lookup (self->priv->roster_contacts, individual);
- if (contacts == NULL)
- return;
-
- if (self->priv->show_groups)
- {
- if (favourite)
- add_to_group (self, individual, TOP_GROUP);
- else
- remove_from_group (self, individual, TOP_GROUP);
- }
- else
- {
- GtkWidget *contact;
-
- contact = g_hash_table_lookup (contacts, NO_GROUP);
- if (contact == NULL)
- return;
-
- egg_list_box_child_changed (EGG_LIST_BOX (self), contact);
- }
-}
-
static void
empathy_roster_view_constructed (GObject *object)
{
if (chain_up != NULL)
chain_up (object);
- g_assert (EMPATHY_IS_INDIVIDUAL_MANAGER (self->priv->manager));
+ g_assert (EMPATHY_IS_ROSTER_MODEL (self->priv->model));
+
+ /* Get saved group states. */
+ empathy_contact_groups_get_all ();
populate_view (self);
- tp_g_signal_connect_object (self->priv->manager, "members-changed",
- G_CALLBACK (members_changed_cb), self, 0);
- tp_g_signal_connect_object (self->priv->manager, "groups-changed",
+ tp_g_signal_connect_object (self->priv->model, "individual-added",
+ G_CALLBACK (individual_added_cb), self, 0);
+ tp_g_signal_connect_object (self->priv->model, "individual-removed",
+ G_CALLBACK (individual_removed_cb), self, 0);
+ tp_g_signal_connect_object (self->priv->model, "groups-changed",
G_CALLBACK (groups_changed_cb), self, 0);
- tp_g_signal_connect_object (self->priv->manager, "notify::top-individuals",
- G_CALLBACK (top_individuals_changed_cb), self, 0);
- tp_g_signal_connect_object (self->priv->manager, "notify::favourites-changed",
- G_CALLBACK (favourites_changed_cb), self, 0);
egg_list_box_set_sort_func (EGG_LIST_BOX (self),
roster_view_sort, self, NULL);
egg_list_box_set_activate_on_single_click (EGG_LIST_BOX (self), FALSE);
}
+static void
+clear_view (EmpathyRosterView *self)
+{
+ g_hash_table_remove_all (self->priv->roster_contacts);
+ g_hash_table_remove_all (self->priv->roster_groups);
+ g_hash_table_remove_all (self->priv->displayed_contacts);
+
+ gtk_container_foreach (GTK_CONTAINER (self),
+ (GtkCallback) gtk_widget_destroy, NULL);
+}
+
static void
empathy_roster_view_dispose (GObject *object)
{
void (*chain_up) (GObject *) =
((GObjectClass *) empathy_roster_view_parent_class)->dispose;
+ /* Start by clearing the view so our internal hash tables are cleared from
+ * objects being destroyed. */
+ clear_view (self);
+
stop_flashing (self);
empathy_roster_view_set_live_search (self, NULL);
- g_clear_object (&self->priv->manager);
+ g_clear_object (&self->priv->model);
+
+ if (self->priv->search_id != 0)
+ {
+ g_source_remove (self->priv->search_id);
+ self->priv->search_id = 0;
+ }
if (chain_up != NULL)
chain_up (object);
return chain_up (widget, event);
}
+/**
+ * @out_child: (out) (allow-none)
+ */
+FolksIndividual *
+empathy_roster_view_get_individual_at_y (EmpathyRosterView *self,
+ gint y,
+ GtkWidget **out_child)
+{
+ GtkWidget *child;
+
+ child = egg_list_box_get_child_at_y (EGG_LIST_BOX (self), y);
+
+ if (out_child != NULL)
+ *out_child = child;
+
+ if (!EMPATHY_IS_ROSTER_CONTACT (child))
+ return NULL;
+
+ return empathy_roster_contact_get_individual (EMPATHY_ROSTER_CONTACT (child));
+}
+
+/**
+ * @out_child: (out) (allow-none)
+ */
+const gchar *
+empathy_roster_view_get_group_at_y (EmpathyRosterView *self,
+ gint y)
+{
+ GtkWidget *child;
+
+ child = egg_list_box_get_child_at_y (EGG_LIST_BOX (self), y);
+
+ if (EMPATHY_IS_ROSTER_CONTACT (child))
+ return empathy_roster_contact_get_group (EMPATHY_ROSTER_CONTACT (child));
+ else if (EMPATHY_IS_ROSTER_GROUP (child))
+ return empathy_roster_group_get_name (EMPATHY_ROSTER_GROUP (child));
+
+ return NULL;
+}
+
static gboolean
empathy_roster_view_query_tooltip (GtkWidget *widget,
gint x,
GtkTooltip *tooltip)
{
EmpathyRosterView *self = EMPATHY_ROSTER_VIEW (widget);
- GtkWidget *child;
- EmpathyRosterContact *contact;
FolksIndividual *individual;
+ gboolean result;
+ GtkWidget *child;
- if (self->priv->individual_tooltip_cb == NULL)
- return FALSE;
-
- child = egg_list_box_get_child_at_y (EGG_LIST_BOX (self), y);
- if (!EMPATHY_IS_ROSTER_CONTACT (child))
+ individual = empathy_roster_view_get_individual_at_y (self, y, &child);
+ if (individual == NULL)
return FALSE;
- contact = EMPATHY_ROSTER_CONTACT (child);
- individual = empathy_roster_contact_get_individual (contact);
+ g_signal_emit (self, signals[SIG_INDIVIDUAL_TOOLTIP], 0,
+ individual, keyboard_mode, tooltip, &result);
- return self->priv->individual_tooltip_cb (self, individual, keyboard_mode,
- tooltip, self->priv->individual_tooltip_data);
-}
+ if (result)
+ {
+ GtkAllocation allocation;
-void
-empathy_roster_view_set_individual_tooltip_cb (EmpathyRosterView *self,
- EmpathyRosterViewIndividualTooltipCb callback,
- gpointer user_data)
-{
- self->priv->individual_tooltip_cb = callback;
- self->priv->individual_tooltip_data = user_data;
+ gtk_widget_get_allocation (child, &allocation);
+ gtk_tooltip_set_tip_area (tooltip, (GdkRectangle *) &allocation);
+ }
- gtk_widget_set_has_tooltip (GTK_WIDGET (self), callback != NULL);
+ return result;
}
static void
box_class->child_activated = empathy_roster_view_child_activated;
- spec = g_param_spec_object ("manager", "Manager",
- "EmpathyIndividualManager",
- EMPATHY_TYPE_INDIVIDUAL_MANAGER,
+ spec = g_param_spec_object ("model", "Model",
+ "EmpathyRosterModel",
+ EMPATHY_TYPE_ROSTER_MODEL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (oclass, PROP_MANAGER, spec);
+ g_object_class_install_property (oclass, PROP_MODEL, spec);
spec = g_param_spec_boolean ("show-offline", "Show Offline",
"Show offline contacts",
G_TYPE_NONE,
2, FOLKS_TYPE_INDIVIDUAL, G_TYPE_POINTER);
+ signals[SIG_INDIVIDUAL_TOOLTIP] = g_signal_new ("individual-tooltip",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, g_signal_accumulator_true_handled, NULL, NULL,
+ G_TYPE_BOOLEAN,
+ 3, FOLKS_TYPE_INDIVIDUAL, G_TYPE_BOOLEAN, GTK_TYPE_TOOLTIP);
+
g_type_class_add_private (klass, sizeof (EmpathyRosterViewPriv));
}
}
GtkWidget *
-empathy_roster_view_new (EmpathyIndividualManager *manager)
+empathy_roster_view_new (EmpathyRosterModel *model)
{
- g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (manager), NULL);
+ g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (model), NULL);
return g_object_new (EMPATHY_TYPE_ROSTER_VIEW,
- "manager", manager,
+ "model", model,
NULL);
}
-EmpathyIndividualManager *
-empathy_roster_view_get_manager (EmpathyRosterView *self)
-{
- return self->priv->manager;
-}
-
void
empathy_roster_view_show_offline (EmpathyRosterView *self,
gboolean show)
g_object_notify (G_OBJECT (self), "show-offline");
}
-static void
-clear_view (EmpathyRosterView *self)
-{
- gtk_container_foreach (GTK_CONTAINER (self),
- (GtkCallback) gtk_widget_destroy, NULL);
-
- g_hash_table_remove_all (self->priv->roster_contacts);
- g_hash_table_remove_all (self->priv->roster_groups);
- g_hash_table_remove_all (self->priv->displayed_contacts);
-}
-
void
empathy_roster_view_show_groups (EmpathyRosterView *self,
gboolean show)
g_list_free (children);
}
+static gboolean
+search_timeout_cb (EmpathyRosterView *self)
+{
+ egg_list_box_refilter (EGG_LIST_BOX (self));
+
+ select_first_contact (self);
+
+ self->priv->search_id = 0;
+ return G_SOURCE_REMOVE;
+}
+
static void
search_text_notify_cb (EmpathyLiveSearch *search,
GParamSpec *pspec,
EmpathyRosterView *self)
{
- egg_list_box_refilter (EGG_LIST_BOX (self));
+ if (self->priv->search_id != 0)
+ g_source_remove (self->priv->search_id);
- select_first_contact (self);
+ self->priv->search_id = g_timeout_add (SEARCH_TIMEOUT,
+ (GSourceFunc) search_timeout_cb, self);
}
static void
}
}
}
+
+FolksIndividual *
+empathy_roster_view_get_selected_individual (EmpathyRosterView *self)
+{
+ GtkWidget *child;
+
+ child = egg_list_box_get_selected_child (EGG_LIST_BOX (self));
+
+ if (!EMPATHY_IS_ROSTER_CONTACT (child))
+ return NULL;
+
+ return empathy_roster_contact_get_individual (EMPATHY_ROSTER_CONTACT (child));
+}