aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorFelix Kaser <f.kaser@gmx.net>2010-04-07 19:19:08 +0800
committerFelix Kaser <f.kaser@gmx.net>2010-04-08 19:24:40 +0800
commit77fd33616f44a907342651a5a2d7e326ad5ccf55 (patch)
tree3cb092e8b291d166a0044325f409f11f687ed6d6 /libempathy-gtk
parentc92e1b6631677972dbd25b1164d00ea983340fee (diff)
downloadgsoc2013-empathy-77fd33616f44a907342651a5a2d7e326ad5ccf55.tar
gsoc2013-empathy-77fd33616f44a907342651a5a2d7e326ad5ccf55.tar.gz
gsoc2013-empathy-77fd33616f44a907342651a5a2d7e326ad5ccf55.tar.bz2
gsoc2013-empathy-77fd33616f44a907342651a5a2d7e326ad5ccf55.tar.lz
gsoc2013-empathy-77fd33616f44a907342651a5a2d7e326ad5ccf55.tar.xz
gsoc2013-empathy-77fd33616f44a907342651a5a2d7e326ad5ccf55.tar.zst
gsoc2013-empathy-77fd33616f44a907342651a5a2d7e326ad5ccf55.zip
group messages only if the delay is short
messages from the same sender should not be grouped when the delay between two messages is too long (5min). fixes bug #604475
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-chat-text-view.c10
-rw-r--r--libempathy-gtk/empathy-chat-text-view.h25
-rw-r--r--libempathy-gtk/empathy-theme-boxes.c15
3 files changed, 34 insertions, 16 deletions
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c
index 7f16ab9a3..137a77adb 100644
--- a/libempathy-gtk/empathy-chat-text-view.c
+++ b/libempathy-gtk/empathy-chat-text-view.c
@@ -1308,6 +1308,16 @@ empathy_chat_text_view_get_last_contact (EmpathyChatTextView *view)
return priv->last_contact;
}
+time_t
+empathy_chat_text_view_get_last_timestamp (EmpathyChatTextView *view)
+{
+ EmpathyChatTextViewPriv *priv = GET_PRIV (view);
+
+ g_return_val_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view), 0);
+
+ return priv->last_timestamp;
+}
+
void
empathy_chat_text_view_set_only_if_date (EmpathyChatTextView *view,
gboolean only_if_date)
diff --git a/libempathy-gtk/empathy-chat-text-view.h b/libempathy-gtk/empathy-chat-text-view.h
index 0180f21d1..7ee7ba8a2 100644
--- a/libempathy-gtk/empathy-chat-text-view.h
+++ b/libempathy-gtk/empathy-chat-text-view.h
@@ -68,18 +68,19 @@ struct _EmpathyChatTextViewClass {
#define EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT "event"
#define EMPATHY_CHAT_TEXT_VIEW_TAG_LINK "link"
-GType empathy_chat_text_view_get_type (void) G_GNUC_CONST;
-EmpathyContact * empathy_chat_text_view_get_last_contact (EmpathyChatTextView *view);
-void empathy_chat_text_view_set_only_if_date (EmpathyChatTextView *view,
- gboolean only_if_date);
-void empathy_chat_text_view_append_body (EmpathyChatTextView *view,
- const gchar *body,
- const gchar *tag);
-void empathy_chat_text_view_append_spacing (EmpathyChatTextView *view);
-GtkTextTag * empathy_chat_text_view_tag_set (EmpathyChatTextView *view,
- const gchar *tag_name,
- const gchar *first_property_name,
- ...);
+GType empathy_chat_text_view_get_type (void) G_GNUC_CONST;
+EmpathyContact * empathy_chat_text_view_get_last_contact (EmpathyChatTextView *view);
+time_t empathy_chat_text_view_get_last_timestamp (EmpathyChatTextView *view);
+void empathy_chat_text_view_set_only_if_date (EmpathyChatTextView *view,
+ gboolean only_if_date);
+void empathy_chat_text_view_append_body (EmpathyChatTextView *view,
+ const gchar *body,
+ const gchar *tag);
+void empathy_chat_text_view_append_spacing (EmpathyChatTextView *view);
+GtkTextTag * empathy_chat_text_view_tag_set (EmpathyChatTextView *view,
+ const gchar *tag_name,
+ const gchar *first_property_name,
+ ...);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c
index e6a606de1..3a600a81d 100644
--- a/libempathy-gtk/empathy-theme-boxes.c
+++ b/libempathy-gtk/empathy-theme-boxes.c
@@ -41,6 +41,9 @@
#define MARGIN 4
#define HEADER_PADDING 2
+/* "Join" consecutive messages with timestamps within five minutes */
+#define MESSAGE_JOIN_PERIOD 5*60
+
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeBoxes)
typedef struct {
gboolean show_avatars;
@@ -200,18 +203,23 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme,
GtkTextTagTable *table;
GtkTextTag *tag;
GString *str_obj;
+ gboolean consecutive;
contact = empathy_message_get_sender (msg);
name = empathy_contact_get_name (contact);
last_contact = empathy_chat_text_view_get_last_contact (view);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (theme));
+ time_ = empathy_message_get_timestamp (msg);
+ consecutive = (time_ - empathy_chat_text_view_get_last_timestamp (view)
+ < MESSAGE_JOIN_PERIOD);
DEBUG ("Maybe add fancy header");
- /* Only insert a header if the previously inserted block is not the same
- * as this one.
+ /* Only insert a header if
+ * - the previously inserted block is not the same as this one.
+ * - the delay between two messages is lower then MESSAGE_JOIN_PERIOD
*/
- if (empathy_contact_equal (last_contact, contact)) {
+ if (empathy_contact_equal (last_contact, contact) && consecutive) {
return;
}
@@ -259,7 +267,6 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme,
g_free (str);
/* Add the message receive time */
- time_ = empathy_message_get_timestamp (msg);
tmp = empathy_time_to_string_local (time_,
EMPATHY_TIME_FORMAT_DISPLAY_SHORT);
str = g_strdup_printf ("<i>%s</i>", tmp);