diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-06-07 20:53:45 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-06-08 17:14:20 +0800 |
commit | 49f661f321635b6b0350dbf27aec3548fbff8ee2 (patch) | |
tree | 99b208adf1d6c6f43224953534265e1f27230756 | |
parent | 92ee08109f1af2bd3862b6f1c21a7a52adb0f9a4 (diff) | |
download | gsoc2013-empathy-49f661f321635b6b0350dbf27aec3548fbff8ee2.tar gsoc2013-empathy-49f661f321635b6b0350dbf27aec3548fbff8ee2.tar.gz gsoc2013-empathy-49f661f321635b6b0350dbf27aec3548fbff8ee2.tar.bz2 gsoc2013-empathy-49f661f321635b6b0350dbf27aec3548fbff8ee2.tar.lz gsoc2013-empathy-49f661f321635b6b0350dbf27aec3548fbff8ee2.tar.xz gsoc2013-empathy-49f661f321635b6b0350dbf27aec3548fbff8ee2.tar.zst gsoc2013-empathy-49f661f321635b6b0350dbf27aec3548fbff8ee2.zip |
individual-store: keep track of the number of events associated with each row
-rw-r--r-- | libempathy-gtk/empathy-individual-store.c | 1 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-store.h | 1 | ||||
-rw-r--r-- | 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 ac1a96c02..e4e644424 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 ae5f3c580..418761ead 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 9cc65ba61..a9e76a286 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; |