[xchat-gnome] Bug 657535 - [patch] Scrollback logs are loaded without timestamps (edit)



commit 9188a6f01ef6515b41410dc660b4f7a9c895014a
Author: Marc Deslauriers <marc deslauriers ubuntu com>
Date:   Thu May 24 20:00:21 2012 +0530

    Bug 657535 - [patch] Scrollback logs are loaded without timestamps (edit)

 src/fe-gnome/conversation-panel.c |   26 +++++++++++++++-----------
 src/fe-gnome/conversation-panel.h |    3 ++-
 src/fe-gnome/fe-gnome.c           |    2 +-
 src/fe-gnome/text-entry.c         |    4 ++--
 4 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/src/fe-gnome/conversation-panel.c b/src/fe-gnome/conversation-panel.c
index d39f56a..2374a2e 100644
--- a/src/fe-gnome/conversation-panel.c
+++ b/src/fe-gnome/conversation-panel.c
@@ -91,7 +91,8 @@ static void     conversation_panel_print_line         (ConversationPanel      *p
                                                        xtext_buffer           *buffer,
                                                        char                   *text,
                                                        int                     len,
-                                                       gboolean                indent);
+                                                       gboolean                indent,
+                                                       time_t                  timet);
 static void     conversation_panel_lastlog_foreach    (GtkXText               *xtext,
                                                        char                   *text,
                                                        fe_lastlog_info        *info);
@@ -1089,7 +1090,7 @@ conversation_panel_clear (ConversationPanel *panel, struct session *sess)
 }
 
 static void
-conversation_panel_print_line (ConversationPanel *panel, xtext_buffer *buffer, char *text, int len, gboolean indent)
+conversation_panel_print_line (ConversationPanel *panel, xtext_buffer *buffer, char *text, int len, gboolean indent, time_t timet)
 {
 	if (len == 0) {
 		return;
@@ -1100,7 +1101,10 @@ conversation_panel_print_line (ConversationPanel *panel, xtext_buffer *buffer, c
 		char   *stamp;
 		guchar *new_text;
 
-		stamp_size = get_stamp_str (prefs.stamp_format, time(NULL), &stamp);
+		if (timet == 0)
+			timet = time (NULL);
+
+		stamp_size = get_stamp_str (prefs.stamp_format, timet, &stamp);
 		new_text = g_malloc (len + stamp_size + 1);
 		memcpy (new_text, stamp, stamp_size);
 		g_free (stamp);
@@ -1117,21 +1121,21 @@ conversation_panel_print_line (ConversationPanel *panel, xtext_buffer *buffer, c
 		if(!panel->priv->redundant_nickstamps && strncmp (buffer->laststamp, text, leftlen) == 0) {
 			text = tab+1;
 			len -= leftlen;
-			gtk_xtext_append_indent (buffer, 0, 0, (unsigned char*) text, len, time(NULL));
+			gtk_xtext_append_indent (buffer, 0, 0, (unsigned char*) text, len, timet);
 		} else {
 			strncpy (buffer->laststamp, text, leftlen);
 			buffer->laststamp[leftlen]=0;
 			gtk_xtext_append_indent (buffer, (unsigned char*) text, leftlen,
 			                         (unsigned char*) tab + 1, strlen (text) - leftlen - 1,
-			                         time(NULL));
+			                         timet);
 		}
 	} else {
-		gtk_xtext_append_indent (buffer, 0, 0, (unsigned char*) text, len, time(NULL));
+		gtk_xtext_append_indent (buffer, 0, 0, (unsigned char*) text, len, timet);
 	}
 }
 
 void
-conversation_panel_print (ConversationPanel *panel, struct session *sess, char *text, gboolean indent)
+conversation_panel_print (ConversationPanel *panel, struct session *sess, char *text, gboolean indent, time_t stamp)
 {
 	xtext_buffer *buffer;
 	char *last_text = text;
@@ -1150,10 +1154,10 @@ conversation_panel_print (ConversationPanel *panel, struct session *sess, char *
 	while (1) {
 		switch (*text) {
 		case '\0':
-			conversation_panel_print_line (panel, buffer, last_text, len, indent);
+			conversation_panel_print_line (panel, buffer, last_text, len, indent, stamp);
 			return;
 		case '\n':
-			conversation_panel_print_line (panel, buffer, last_text, len, indent);
+			conversation_panel_print_line (panel, buffer, last_text, len, indent, stamp);
 			text++;
 			if (*text == '\0')
 				return;
@@ -1189,7 +1193,7 @@ static void
 conversation_panel_lastlog_foreach (GtkXText *xtext, char *text, fe_lastlog_info *info)
 {
 	if (nocasestrstr (text, (char*) info->sstr)) {
-		conversation_panel_print (info->panel, info->sess, text, prefs.indent_nicks);
+		conversation_panel_print (info->panel, info->sess, text, prefs.indent_nicks, time(NULL));
 	}
 }
 
@@ -1202,7 +1206,7 @@ conversation_panel_lastlog (ConversationPanel *panel, struct session *sess, stru
 	lbuffer = g_hash_table_lookup (panel->priv->buffers, lsess);
 
 	if (gtk_xtext_is_empty (buffer)) {
-		conversation_panel_print (panel, lsess, _("Search buffer is empty.\n"), TRUE);
+		conversation_panel_print (panel, lsess, _("Search buffer is empty.\n"), TRUE, time(NULL));
 	} else {
 		fe_lastlog_info info;
 		info.panel = panel;
diff --git a/src/fe-gnome/conversation-panel.h b/src/fe-gnome/conversation-panel.h
index ba25253..eed6c66 100644
--- a/src/fe-gnome/conversation-panel.h
+++ b/src/fe-gnome/conversation-panel.h
@@ -62,7 +62,8 @@ void       conversation_panel_clear                   (ConversationPanel *panel,
 void       conversation_panel_print                   (ConversationPanel *panel,
                                                        struct session    *sess,
                                                        char              *text,
-                                                       gboolean           indent);
+                                                       gboolean           indent,
+                                                       time_t             stamp);
 void       conversation_panel_remove_session          (ConversationPanel *panel,
                                                        struct session    *sess);
 void       conversation_panel_lastlog                 (ConversationPanel *panel,
diff --git a/src/fe-gnome/fe-gnome.c b/src/fe-gnome/fe-gnome.c
index 261b29e..e6d97ae 100644
--- a/src/fe-gnome/fe-gnome.c
+++ b/src/fe-gnome/fe-gnome.c
@@ -474,7 +474,7 @@ fe_print_text (struct session *sess, char *text, time_t stamp)
 	}
 
 	conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel),
-	                          sess, text, prefs.indent_nicks);
+	                          sess, text, prefs.indent_nicks, stamp);
 	sess->new_data = TRUE;
 	navigation_model_set_hilight (gui.tree_model, sess);
 	if (sess->nick_said) {
diff --git a/src/fe-gnome/text-entry.c b/src/fe-gnome/text-entry.c
index b0ae046..d527830 100644
--- a/src/fe-gnome/text-entry.c
+++ b/src/fe-gnome/text-entry.c
@@ -495,7 +495,7 @@ tab_complete_command (GtkEntry *entry)
 			g_free (printtext);
 			printtext = npt;
 		}
-		conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), text_entry->priv->current, printtext, TRUE);
+		conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), text_entry->priv->current, printtext, TRUE, time (NULL));
 		g_free (printtext);
 
 		if (new_prefix && strcasecmp (prefix, new_prefix) != 0) {
@@ -598,7 +598,7 @@ tab_complete_nickname (GtkEntry *entry, gint start)
 			g_free (printtext);
 			printtext = npt;
 		}
-		conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), text_entry->priv->current, printtext, TRUE);
+		conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), text_entry->priv->current, printtext, TRUE, time (NULL));
 		g_free (printtext);
 
 		if (strcasecmp (prefix, new_prefix) != 0) {



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