aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2010-02-05 06:24:01 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-02-09 03:41:13 +0800
commit6e30bb870bc9748dd39e3a29992c5fd057afb339 (patch)
tree760fac8da44d79ffd01ffd14904a828606373897
parent30d84cace706ad67081df9ac309190ba07aa7bac (diff)
downloadgsoc2013-empathy-6e30bb870bc9748dd39e3a29992c5fd057afb339.tar
gsoc2013-empathy-6e30bb870bc9748dd39e3a29992c5fd057afb339.tar.gz
gsoc2013-empathy-6e30bb870bc9748dd39e3a29992c5fd057afb339.tar.bz2
gsoc2013-empathy-6e30bb870bc9748dd39e3a29992c5fd057afb339.tar.lz
gsoc2013-empathy-6e30bb870bc9748dd39e3a29992c5fd057afb339.tar.xz
gsoc2013-empathy-6e30bb870bc9748dd39e3a29992c5fd057afb339.tar.zst
gsoc2013-empathy-6e30bb870bc9748dd39e3a29992c5fd057afb339.zip
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.
-rw-r--r--libempathy-gtk/empathy-chat.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 222258082..bed7aa78e 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);
+ }
}