diff plugins/timestamp.c @ 8864:8ab568b92480

[gaim-migrate @ 9632] " I like the iChat style timestamp, but it's annoying that it constantly adds the timestamp, scrolling old msgs off the screen. This patch will make it only add a timestamp if there have been messages since the last timestamp. Adding a preference checkbox for this is left as an exercise for the reader." --Robert Story as this behavior seems to me more intuitive, i'm going ahead with this patch committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Mon, 03 May 2004 18:00:46 +0000
parents d7b8eb1f0a18
children c2dff943e240
line wrap: on
line diff
--- a/plugins/timestamp.c	Mon May 03 17:55:46 2004 +0000
+++ b/plugins/timestamp.c	Mon May 03 18:00:46 2004 +0000
@@ -46,14 +46,34 @@
 	char *buf;
 	char mdate[6];
 	time_t tim = time(NULL);
+        gsize len = 0;
 
 	if (!g_list_find(gaim_get_conversations(), c))
 		return FALSE;
 
-	strftime(mdate, sizeof(mdate), "%H:%M", localtime(&tim));
-	buf = g_strdup_printf("            %s", mdate);
-	gaim_conversation_write(c, NULL, buf, GAIM_MESSAGE_NO_LOG, tim);
-	g_free(buf);
+        len = GPOINTER_TO_INT(
+            gaim_conversation_get_data(c, "timestamp-last-size"));
+        if((NULL != c->history) && (len != c->history->len)) {
+
+            strftime(mdate, sizeof(mdate), "%02H:%02M", localtime(&tim));
+            buf = g_strdup_printf("%s", mdate);
+        }
+#ifndef DEBUG_TIMESTAMP
+        else {
+            return TRUE;
+        }
+#else
+        else {
+            buf = g_strdup_printf("NC");
+        }
+#endif
+
+        gaim_conversation_write(c, NULL, buf, GAIM_MESSAGE_NO_LOG, tim);
+        g_free(buf);
+
+        gaim_conversation_set_data(c, "timestamp-last-size",
+                                   GINT_TO_POINTER(c->history->len));
+
 	return TRUE;
 }