aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat.c
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2009-03-06 19:52:38 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-03-06 19:52:38 +0800
commitd5aeb6601d7290b0ef6ab0564132d92e81106247 (patch)
tree39b6c9d8f5ac104e504ead79b05d53ebf28b826c /libempathy-gtk/empathy-chat.c
parent4ba90ecf0b2321cf2b6ca55eace7bada391f91b6 (diff)
downloadgsoc2013-empathy-d5aeb6601d7290b0ef6ab0564132d92e81106247.tar
gsoc2013-empathy-d5aeb6601d7290b0ef6ab0564132d92e81106247.tar.gz
gsoc2013-empathy-d5aeb6601d7290b0ef6ab0564132d92e81106247.tar.bz2
gsoc2013-empathy-d5aeb6601d7290b0ef6ab0564132d92e81106247.tar.lz
gsoc2013-empathy-d5aeb6601d7290b0ef6ab0564132d92e81106247.tar.xz
gsoc2013-empathy-d5aeb6601d7290b0ef6ab0564132d92e81106247.tar.zst
gsoc2013-empathy-d5aeb6601d7290b0ef6ab0564132d92e81106247.zip
EmpathyChat: Simplified adding appropriate messages to the window.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk> svn path=/trunk/; revision=2602
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-rw-r--r--libempathy-gtk/empathy-chat.c46
1 files changed, 15 insertions, 31 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 1e06ab2ba..5fac903a3 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1031,9 +1031,8 @@ chat_add_logs (EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
gboolean is_chatroom;
- GList *messages, *l, *c;
- guint num_messages;
- guint i;
+ GList *messages, *l;
+ guint i = 0;
const GList *pending_messages, *m;
if (!priv->id) {
@@ -1052,39 +1051,24 @@ chat_add_logs (EmpathyChat *chat)
pending_messages = empathy_tp_chat_get_pending_messages (priv->tp_chat);
- /* Remove messages that are pending */
- c = g_list_copy (messages);
- for (l = messages; l; l = l->next) {
- for (m = pending_messages; m; m = m->next) {
- if (empathy_message_equal (l->data, m->data)) {
- EmpathyMessage *message;
+ for (l = g_list_last (messages); l; l = g_list_previous (l)) {
+ if (i < 10) {
+ gboolean found = FALSE;
- message = l->data;
- c = g_list_remove (c, message);
- g_object_unref (message);
- break;
+ for (m = pending_messages; m; m = g_list_next (m)) {
+ if (empathy_message_equal (l->data, m->data)) {
+ found = TRUE;
+ }
}
- }
- }
-
- g_list_free (messages);
- messages = c;
-
- num_messages = g_list_length (messages);
- /* Only keep the 10 last messages */
- for (i = 0; num_messages - i > 10; i++) {
- EmpathyMessage *message;
-
- message = messages->data;
- messages = g_list_remove (messages, message);
- g_object_unref (message);
- }
-
- for (l = messages; l; l = l->next) {
- empathy_chat_view_append_message (chat->view, l->data);
+ if (!found) {
+ empathy_chat_view_append_message (chat->view, l->data);
+ i++;
+ }
+ }
g_object_unref (l->data);
}
+
g_list_free (messages);
/* Turn back on scrolling */