[empathy] individual-store: keep track of the number of events associated with each row
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] individual-store: keep track of the number of events associated with each row
- Date: Wed, 8 Jun 2011 09:24:11 +0000 (UTC)
commit 49f661f321635b6b0350dbf27aec3548fbff8ee2
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Tue Jun 7 14:53:45 2011 +0200
individual-store: keep track of the number of events associated with each row
libempathy-gtk/empathy-individual-store.c | 1 +
libempathy-gtk/empathy-individual-store.h | 1 +
src/empathy-main-window.c | 84 +++++++++++++++++++++++++++++
3 files changed, 86 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-individual-store.c b/libempathy-gtk/empathy-individual-store.c
index ac1a96c..e4e6444 100644
--- a/libempathy-gtk/empathy-individual-store.c
+++ b/libempathy-gtk/empathy-individual-store.c
@@ -1572,6 +1572,7 @@ individual_store_setup (EmpathyIndividualStore *self)
G_TYPE_BOOLEAN, /* Can make video calls */
G_TYPE_BOOLEAN, /* Is a fake group */
G_TYPE_STRV, /* Client types */
+ G_TYPE_UINT, /* Event count */
};
priv = GET_PRIV (self);
diff --git a/libempathy-gtk/empathy-individual-store.h b/libempathy-gtk/empathy-individual-store.h
index ae5f3c5..418761e 100644
--- a/libempathy-gtk/empathy-individual-store.h
+++ b/libempathy-gtk/empathy-individual-store.h
@@ -65,6 +65,7 @@ typedef enum
EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL,
EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP,
EMPATHY_INDIVIDUAL_STORE_COL_CLIENT_TYPES,
+ EMPATHY_INDIVIDUAL_STORE_COL_EVENT_COUNT,
EMPATHY_INDIVIDUAL_STORE_COL_COUNT,
} EmpathyIndividualStoreCol;
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 9cc65ba..a9e76a2 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -432,11 +432,93 @@ main_window_auth_display (EmpathyMainWindow *window,
}
static void
+modify_event_count (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EmpathyEvent *event,
+ gboolean increase)
+{
+ FolksIndividual *individual;
+ EmpathyContact *contact;
+ guint count;
+
+ gtk_tree_model_get (model, iter,
+ EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual,
+ EMPATHY_INDIVIDUAL_STORE_COL_EVENT_COUNT, &count,
+ -1);
+
+ if (individual == NULL)
+ return;
+
+ increase ? count++ : count--;
+
+ contact = empathy_contact_dup_from_folks_individual (individual);
+ if (contact == event->contact) {
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+ EMPATHY_INDIVIDUAL_STORE_COL_EVENT_COUNT, count, -1);
+ }
+
+ tp_clear_object (&contact);
+ g_object_unref (individual);
+}
+
+static gboolean
+increase_event_count_foreach (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ EmpathyEvent *event = user_data;
+
+ modify_event_count (model, iter, event, TRUE);
+
+ return FALSE;
+}
+
+static void
+increase_event_count (EmpathyMainWindow *self,
+ EmpathyEvent *event)
+{
+ EmpathyMainWindowPriv *priv = GET_PRIV (self);
+ GtkTreeModel *model;
+
+ model = GTK_TREE_MODEL (priv->individual_store);
+
+ gtk_tree_model_foreach (model, increase_event_count_foreach, event);
+}
+
+static gboolean
+decrease_event_count_foreach (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ EmpathyEvent *event = user_data;
+
+ modify_event_count (model, iter, event, FALSE);
+
+ return FALSE;
+}
+
+static void
+decrease_event_count (EmpathyMainWindow *self,
+ EmpathyEvent *event)
+{
+ EmpathyMainWindowPriv *priv = GET_PRIV (self);
+ GtkTreeModel *model;
+
+ model = GTK_TREE_MODEL (priv->individual_store);
+
+ gtk_tree_model_foreach (model, decrease_event_count_foreach, event);
+}
+
+static void
main_window_event_added_cb (EmpathyEventManager *manager,
EmpathyEvent *event,
EmpathyMainWindow *window)
{
if (event->contact) {
+ increase_event_count (window, event);
+
main_window_flash_start (window);
} else if (event->type == EMPATHY_EVENT_TYPE_AUTH) {
main_window_auth_display (window, event);
@@ -460,6 +542,8 @@ main_window_event_removed_cb (EmpathyEventManager *manager,
return;
}
+ decrease_event_count (window, event);
+
data.on = FALSE;
data.event = event;
data.window = window;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]