aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-chat-view.c71
-rw-r--r--libempathy-gtk/empathy-chat-view.h14
-rw-r--r--libempathy-gtk/empathy-theme-boxes.c41
3 files changed, 17 insertions, 109 deletions
diff --git a/libempathy-gtk/empathy-chat-view.c b/libempathy-gtk/empathy-chat-view.c
index 7682bf3a1..d67f9c4dd 100644
--- a/libempathy-gtk/empathy-chat-view.c
+++ b/libempathy-gtk/empathy-chat-view.c
@@ -69,7 +69,6 @@ struct _EmpathyChatViewPriv {
EmpathyTheme *theme;
time_t last_timestamp;
- EmpathyChatViewBlock last_block_type;
gboolean allow_scrolling;
guint scroll_timeout;
@@ -156,12 +155,8 @@ empathy_chat_view_init (EmpathyChatView *view)
priv = GET_PRIV (view);
priv->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
- priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_NONE;
priv->last_timestamp = 0;
-
priv->allow_scrolling = TRUE;
-
priv->is_group_chat = FALSE;
g_object_set (view,
@@ -637,8 +632,6 @@ chat_view_theme_changed_cb (EmpathyThemeManager *manager,
priv = GET_PRIV (view);
- priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_NONE;
-
empathy_conf_get_bool (empathy_conf_get (),
EMPATHY_PREFS_CHAT_THEME_CHAT_ROOM,
&theme_rooms);
@@ -761,9 +754,7 @@ empathy_chat_view_append_message (EmpathyChatView *view,
EmpathyMessage *msg)
{
EmpathyChatViewPriv *priv = GET_PRIV (view);
- EmpathyContact *sender;
gboolean bottom;
- gboolean from_self;
g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
g_return_if_fail (EMPATHY_IS_MESSAGE (msg));
@@ -773,8 +764,6 @@ empathy_chat_view_append_message (EmpathyChatView *view,
}
bottom = chat_view_is_scrolled_down (view);
- sender = empathy_message_get_sender (msg);
- from_self = empathy_contact_is_user (sender);
chat_view_maybe_trim_buffer (view);
@@ -783,6 +772,11 @@ empathy_chat_view_append_message (EmpathyChatView *view,
if (bottom) {
empathy_chat_view_scroll_down (view);
}
+
+ if (priv->last_contact) {
+ g_object_unref (priv->last_contact);
+ }
+ priv->last_contact = g_object_ref (empathy_message_get_sender (msg));
}
void
@@ -807,7 +801,10 @@ empathy_chat_view_append_event (EmpathyChatView *view,
empathy_chat_view_scroll_down (view);
}
- priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_EVENT;
+ if (priv->last_contact) {
+ g_object_unref (priv->last_contact);
+ priv->last_contact = NULL;
+ }
}
void
@@ -877,7 +874,10 @@ empathy_chat_view_append_button (EmpathyChatView *view,
empathy_chat_view_scroll_down (view);
}
- priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_INVITE;
+ if (priv->last_contact) {
+ g_object_unref (priv->last_contact);
+ priv->last_contact = NULL;
+ }
}
void
@@ -982,7 +982,6 @@ empathy_chat_view_clear (EmpathyChatView *view)
*/
priv = GET_PRIV (view);
- priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_NONE;
priv->last_timestamp = 0;
}
@@ -1498,31 +1497,6 @@ empathy_chat_view_set_last_timestamp (EmpathyChatView *view,
priv->last_timestamp = timestamp;
}
-EmpathyChatViewBlock
-empathy_chat_view_get_last_block_type (EmpathyChatView *view)
-{
- EmpathyChatViewPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), 0);
-
- priv = GET_PRIV (view);
-
- return priv->last_block_type;
-}
-
-void
-empathy_chat_view_set_last_block_type (EmpathyChatView *view,
- EmpathyChatViewBlock block_type)
-{
- EmpathyChatViewPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
-
- priv = GET_PRIV (view);
-
- priv->last_block_type = block_type;
-}
-
EmpathyContact *
empathy_chat_view_get_last_contact (EmpathyChatView *view)
{
@@ -1535,22 +1509,3 @@ empathy_chat_view_get_last_contact (EmpathyChatView *view)
return priv->last_contact;
}
-void
-empathy_chat_view_set_last_contact (EmpathyChatView *view, EmpathyContact *contact)
-{
- EmpathyChatViewPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
-
- priv = GET_PRIV (view);
-
- if (priv->last_contact) {
- g_object_unref (priv->last_contact);
- priv->last_contact = NULL;
- }
-
- if (contact) {
- priv->last_contact = g_object_ref (contact);
- }
-}
-
diff --git a/libempathy-gtk/empathy-chat-view.h b/libempathy-gtk/empathy-chat-view.h
index 58219ca04..5eac2e6cc 100644
--- a/libempathy-gtk/empathy-chat-view.h
+++ b/libempathy-gtk/empathy-chat-view.h
@@ -53,15 +53,6 @@ struct _EmpathyChatViewClass {
GtkTextViewClass parent_class;
};
-typedef enum {
- EMPATHY_CHAT_VIEW_BLOCK_NONE,
- EMPATHY_CHAT_VIEW_BLOCK_SELF,
- EMPATHY_CHAT_VIEW_BLOCK_OTHER,
- EMPATHY_CHAT_VIEW_BLOCK_EVENT,
- EMPATHY_CHAT_VIEW_BLOCK_TIME,
- EMPATHY_CHAT_VIEW_BLOCK_INVITE
-} EmpathyChatViewBlock;
-
GType empathy_chat_view_get_type (void) G_GNUC_CONST;
EmpathyChatView *empathy_chat_view_new (void);
void empathy_chat_view_append_message (EmpathyChatView *view,
@@ -106,12 +97,7 @@ void empathy_chat_view_set_is_group_chat (EmpathyChatView *view,
time_t empathy_chat_view_get_last_timestamp (EmpathyChatView *view);
void empathy_chat_view_set_last_timestamp (EmpathyChatView *view,
time_t timestamp);
-EmpathyChatViewBlock empathy_chat_view_get_last_block_type (EmpathyChatView *view);
-void empathy_chat_view_set_last_block_type (EmpathyChatView *view,
- EmpathyChatViewBlock block_type);
EmpathyContact * empathy_chat_view_get_last_contact (EmpathyChatView *view);
-void empathy_chat_view_set_last_contact (EmpathyChatView *view,
- EmpathyContact *contact);
GdkPixbuf * empathy_chat_view_get_avatar_pixbuf_with_cache (EmpathyContact *contact);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c
index 797cb4324..06c35cae8 100644
--- a/libempathy-gtk/empathy-theme-boxes.c
+++ b/libempathy-gtk/empathy-theme-boxes.c
@@ -527,10 +527,10 @@ theme_boxes_maybe_append_header (EmpathyTheme *theme,
{
EmpathyThemeBoxesPriv *priv;
EmpathyContact *contact;
+ EmpathyContact *last_contact;
GdkPixbuf *avatar = NULL;
GtkTextBuffer *buffer;
const gchar *name;
- gboolean header;
GtkTextIter iter;
GtkWidget *label1, *label2;
GtkTextChildAnchor *anchor;
@@ -541,42 +541,20 @@ theme_boxes_maybe_append_header (EmpathyTheme *theme,
GtkTextIter start;
GdkColor color;
gboolean parse_success;
- gboolean from_self;
priv = GET_PRIV (theme);
contact = empathy_message_get_sender (msg);
- from_self = empathy_contact_is_user (contact);
+ name = empathy_contact_get_name (contact);
+ last_contact = empathy_chat_view_get_last_contact (view);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
empathy_debug (DEBUG_DOMAIN, "Maybe add fancy header");
- name = empathy_contact_get_name (contact);
-
- header = FALSE;
-
/* Only insert a header if the previously inserted block is not the same
* as this one. This catches all the different cases:
*/
- if (empathy_chat_view_get_last_block_type (view) != EMPATHY_CHAT_VIEW_BLOCK_SELF &&
- empathy_chat_view_get_last_block_type (view) != EMPATHY_CHAT_VIEW_BLOCK_OTHER) {
- header = TRUE;
- }
- else if (from_self &&
- empathy_chat_view_get_last_block_type (view) == EMPATHY_CHAT_VIEW_BLOCK_OTHER) {
- header = TRUE;
- }
- else if (!from_self &&
- empathy_chat_view_get_last_block_type (view) == EMPATHY_CHAT_VIEW_BLOCK_SELF) {
- header = TRUE;
- }
- else if (!from_self &&
- (!empathy_chat_view_get_last_contact (view) ||
- contact != empathy_chat_view_get_last_contact (view))) {
- header = TRUE;
- }
-
- if (!header) {
+ if (last_contact && empathy_contact_equal (last_contact, contact)) {
return;
}
@@ -708,14 +686,6 @@ theme_boxes_append_message (EmpathyTheme *theme,
empathy_message_get_body (message),
"fancy-body", "fancy-link");
}
-
- if (empathy_contact_is_user (sender)) {
- empathy_chat_view_set_last_block_type (view, EMPATHY_CHAT_VIEW_BLOCK_SELF);
- empathy_chat_view_set_last_contact (view, NULL);
- } else {
- empathy_chat_view_set_last_block_type (view, EMPATHY_CHAT_VIEW_BLOCK_OTHER);
- empathy_chat_view_set_last_contact (view, sender);
- }
}
static void
@@ -740,8 +710,6 @@ theme_boxes_append_event (EmpathyTheme *theme,
"fancy-event",
NULL);
g_free (msg);
-
- empathy_chat_view_set_last_block_type (view, EMPATHY_CHAT_VIEW_BLOCK_EVENT);
}
static void
@@ -804,7 +772,6 @@ theme_boxes_append_timestamp (EmpathyTheme *theme,
"fancy-time",
NULL);
- empathy_chat_view_set_last_block_type (view, EMPATHY_CHAT_VIEW_BLOCK_TIME);
empathy_chat_view_set_last_timestamp (view, timestamp);
}