]> git.0d.be Git - empathy.git/commitdiff
empathy-chat: keep count of the number of unread messages
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 25 Nov 2009 17:03:00 +0000 (17:03 +0000)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 27 Nov 2009 15:24:59 +0000 (15:24 +0000)
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-chat.h

index 372e90cf034a8ab9d64762d6e254d7a030f3b7f0..d9a72d3e959ba77c49dfc7f119e6ecbf5698cf4d 100644 (file)
@@ -93,6 +93,8 @@ typedef struct {
        GtkWidget         *label_topic;
        GtkWidget         *contact_list_view;
        GtkWidget         *info_bar_vbox;
+
+       guint              unread_messages;
 } EmpathyChatPriv;
 
 typedef struct {
@@ -1074,6 +1076,7 @@ chat_message_received (EmpathyChat *chat, EmpathyMessage *message)
                               TP_CHANNEL_CHAT_STATE_ACTIVE,
                               chat);
 
+       priv->unread_messages++;
        g_signal_emit (chat, signals[NEW_MESSAGE], 0, message);
 }
 
@@ -2801,3 +2804,23 @@ empathy_chat_is_room (EmpathyChat *chat)
        return (priv->handle_type == TP_HANDLE_TYPE_ROOM);
 }
 
+guint
+empathy_chat_get_nb_unread_messages (EmpathyChat *self)
+{
+       EmpathyChatPriv *priv = GET_PRIV (self);
+
+       g_return_val_if_fail (EMPATHY_IS_CHAT (self), FALSE);
+
+       return priv->unread_messages;
+}
+
+/* called when the messages have been read by user */
+void
+empathy_chat_messages_read (EmpathyChat *self)
+{
+       EmpathyChatPriv *priv = GET_PRIV (self);
+
+       g_return_if_fail (EMPATHY_IS_CHAT (self));
+
+       priv->unread_messages = 0;
+}
index 9123d11ddc9ea62ffc99dafeefc6578384c76c4f..9e0985040b28744fd8ff77e6c13cdf41a3f416f2 100644 (file)
@@ -84,6 +84,9 @@ void               empathy_chat_correct_word         (EmpathyChat   *chat,
 gboolean           empathy_chat_is_room              (EmpathyChat   *chat);
 void               empathy_chat_set_show_contacts    (EmpathyChat *chat,
                                                       gboolean     show);
+guint              empathy_chat_get_nb_unread_messages (EmpathyChat   *chat);
+
+void               empathy_chat_messages_read        (EmpathyChat *self);
 G_END_DECLS
 
 #endif /* __EMPATHY_CHAT_H__ */