[empathy] empathy-chat: acknowledge pending messages on empathy_chat_messages_read() (#608979)
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [empathy] empathy-chat: acknowledge pending messages on empathy_chat_messages_read() (#608979)
- Date: Mon, 8 Feb 2010 20:05:16 +0000 (UTC)
commit 6e30bb870bc9748dd39e3a29992c5fd057afb339
Author: Danielle Madeley <danielle madeley collabora co uk>
Date: Fri Feb 5 09:24:01 2010 +1100
empathy-chat: acknowledge pending messages on empathy_chat_messages_read() (#608979)
Empathy displays this handy number of unread messages in the title bar, but
you can't replicate this behaviour using an Observer because Empathy
acknowledges the messages immediately. This patch makes it so that Empathy
only acknowledges the messages when it decrements the unread messages count.
N.B. EmpathyTpChat currently seems to assume that no other client is going to
acknowledge messages for channels, it is handling. This seems valid enough,
just pointing it out.
libempathy-gtk/empathy-chat.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 2222580..bed7aa7 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -96,7 +96,7 @@ typedef struct {
GtkWidget *info_bar_vbox;
GtkWidget *search_bar;
- guint unread_messages;
+ GList *pending_messages;
/* TRUE if the pending messages can be displayed. This is to avoid to show
* pending messages *before* messages from logs. (#603980) */
gboolean can_show_pending;
@@ -1116,7 +1116,9 @@ chat_message_received (EmpathyChat *chat, EmpathyMessage *message)
TP_CHANNEL_CHAT_STATE_ACTIVE,
chat);
- priv->unread_messages++;
+ priv->pending_messages = g_list_prepend (priv->pending_messages,
+ g_object_ref (message));
+
g_signal_emit (chat, signals[NEW_MESSAGE], 0, message);
}
@@ -1126,7 +1128,6 @@ chat_message_received_cb (EmpathyTpChat *tp_chat,
EmpathyChat *chat)
{
chat_message_received (chat, message);
- empathy_tp_chat_acknowledge_message (tp_chat, message);
}
static void
@@ -2065,7 +2066,6 @@ show_pending_messages (EmpathyChat *chat) {
EmpathyMessage *message = EMPATHY_MESSAGE (l->data);
chat_message_received (chat, message);
}
- empathy_tp_chat_acknowledge_messages (priv->tp_chat, messages);
}
static void
@@ -2936,7 +2936,7 @@ empathy_chat_get_nb_unread_messages (EmpathyChat *self)
g_return_val_if_fail (EMPATHY_IS_CHAT (self), FALSE);
- return priv->unread_messages;
+ return g_list_length (priv->pending_messages);
}
/* called when the messages have been read by user */
@@ -2947,5 +2947,12 @@ empathy_chat_messages_read (EmpathyChat *self)
g_return_if_fail (EMPATHY_IS_CHAT (self));
- priv->unread_messages = 0;
+ empathy_tp_chat_acknowledge_messages (priv->tp_chat,
+ priv->pending_messages);
+
+ while (priv->pending_messages != NULL) {
+ g_object_unref (priv->pending_messages->data);
+ priv->pending_messages = g_list_delete_link (
+ priv->pending_messages, priv->pending_messages);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]