empathy r791 - trunk/libempathy-gtk



Author: xclaesse
Date: Fri Mar 14 13:05:41 2008
New Revision: 791
URL: http://svn.gnome.org/viewvc/empathy?rev=791&view=rev

Log:
Remove EmpathyChatViewBlock and empaty_chat_view_set_last_contact


Modified:
   trunk/libempathy-gtk/empathy-chat-view.c
   trunk/libempathy-gtk/empathy-chat-view.h
   trunk/libempathy-gtk/empathy-theme-boxes.c

Modified: trunk/libempathy-gtk/empathy-chat-view.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat-view.c	(original)
+++ trunk/libempathy-gtk/empathy-chat-view.c	Fri Mar 14 13:05:41 2008
@@ -69,7 +69,6 @@
 	EmpathyTheme   *theme;
 
 	time_t         last_timestamp;
-	EmpathyChatViewBlock last_block_type;
 
 	gboolean       allow_scrolling;
 	guint          scroll_timeout;
@@ -156,12 +155,8 @@
 	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 @@
 
 	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 @@
 				  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 @@
 	}
 
 	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 @@
 	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_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_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 @@
 	 */
 	priv = GET_PRIV (view);
 
-	priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_NONE;
 	priv->last_timestamp = 0;
 }
 
@@ -1498,31 +1497,6 @@
 	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 @@
 	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);
-	}
-}
-

Modified: trunk/libempathy-gtk/empathy-chat-view.h
==============================================================================
--- trunk/libempathy-gtk/empathy-chat-view.h	(original)
+++ trunk/libempathy-gtk/empathy-chat-view.h	Fri Mar 14 13:05:41 2008
@@ -53,15 +53,6 @@
 	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 @@
 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

Modified: trunk/libempathy-gtk/empathy-theme-boxes.c
==============================================================================
--- trunk/libempathy-gtk/empathy-theme-boxes.c	(original)
+++ trunk/libempathy-gtk/empathy-theme-boxes.c	Fri Mar 14 13:05:41 2008
@@ -527,10 +527,10 @@
 {
 	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 @@
 	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 @@
 					   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 @@
 						  "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 @@
 							  "fancy-time",
 							  NULL);
 
-		empathy_chat_view_set_last_block_type (view, EMPATHY_CHAT_VIEW_BLOCK_TIME);
 		empathy_chat_view_set_last_timestamp (view, timestamp);
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]