changeset 9435:5635f71aa5db

[gaim-migrate @ 10256] this patch had some little discussion, so the original comments about it don't make too much sense now. it makes the log viewwer further collapse things into months for things older than the current month. for relatively short logs this might not be wonderful, but it should help with very long logs. see patch #963827 oh and thanks to Cole Kowalski for this committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 01 Jul 2004 15:57:38 +0000
parents c5cf752acc4a
children 1ddcc9caa538
files src/gtklog.c
diffstat 1 files changed, 29 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtklog.c	Wed Jun 30 20:38:41 2004 +0000
+++ b/src/gtklog.c	Thu Jul 01 15:57:38 2004 +0000
@@ -210,20 +210,40 @@
      /* Logs are made from trees in real life. 
         This is a tree made from logs */
 {
+	char month[30];
 	char title[64];
-	char *title_utf8; /* temporary variable for utf8 conversion */
-	GtkTreeIter iter;
+	char prev_top_month[30];
+	char *utf8_tmp; /* temporary variable for utf8 conversion */
+	GtkTreeIter toplevel, child;
 	GList *logs = lv->logs;
 	while (logs) {
 		GaimLog *log = logs->data;
+		
+		strftime(month, sizeof(month), "%B %Y", localtime(&log->time));
 		strftime(title, sizeof(title), "%c", localtime(&log->time));
-		title_utf8 = gaim_utf8_try_convert(title);
-		strncpy(title, title_utf8, sizeof(title));
-		g_free(title_utf8);
-		gtk_tree_store_append (lv->treestore, &iter, NULL);
-		gtk_tree_store_set(lv->treestore, &iter,
-				   0, title,
-				   1, log, -1);
+		
+		/* do utf8 conversions */
+		utf8_tmp = gaim_utf8_try_convert(month);
+		strncpy(month, utf8_tmp, sizeof(month));
+		utf8_tmp = gaim_utf8_try_convert(title);
+		strncpy(title, utf8_tmp, sizeof(title));
+		g_free(utf8_tmp);
+		
+		if (strncmp(month, prev_top_month, sizeof(month)) != 0) {
+			/* top level */
+			gtk_tree_store_append(lv->treestore, &toplevel, NULL);
+			gtk_tree_store_set(lv->treestore, &toplevel, 0, month, 1, NULL, -1);
+			
+			/* sub */
+			gtk_tree_store_append(lv->treestore, &child, &toplevel);
+			gtk_tree_store_set(lv->treestore, &child, 0, title, 1, log, -1);
+			
+			strncpy(prev_top_month, month, sizeof(prev_top_month));
+		} else {
+			gtk_tree_store_append(lv->treestore, &child, &toplevel);
+			gtk_tree_store_set(lv->treestore, &child, 0, title, 1, log, -1);
+		}
+		   
 		logs = logs->next;
 	}
 }