comparison src/gtklog.c @ 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 5655dcd94d0f
children abacf29577b2
comparison
equal deleted inserted replaced
9434:c5cf752acc4a 9435:5635f71aa5db
208 */ 208 */
209 static void populate_log_tree(GaimGtkLogViewer *lv) 209 static void populate_log_tree(GaimGtkLogViewer *lv)
210 /* Logs are made from trees in real life. 210 /* Logs are made from trees in real life.
211 This is a tree made from logs */ 211 This is a tree made from logs */
212 { 212 {
213 char month[30];
213 char title[64]; 214 char title[64];
214 char *title_utf8; /* temporary variable for utf8 conversion */ 215 char prev_top_month[30];
215 GtkTreeIter iter; 216 char *utf8_tmp; /* temporary variable for utf8 conversion */
217 GtkTreeIter toplevel, child;
216 GList *logs = lv->logs; 218 GList *logs = lv->logs;
217 while (logs) { 219 while (logs) {
218 GaimLog *log = logs->data; 220 GaimLog *log = logs->data;
221
222 strftime(month, sizeof(month), "%B %Y", localtime(&log->time));
219 strftime(title, sizeof(title), "%c", localtime(&log->time)); 223 strftime(title, sizeof(title), "%c", localtime(&log->time));
220 title_utf8 = gaim_utf8_try_convert(title); 224
221 strncpy(title, title_utf8, sizeof(title)); 225 /* do utf8 conversions */
222 g_free(title_utf8); 226 utf8_tmp = gaim_utf8_try_convert(month);
223 gtk_tree_store_append (lv->treestore, &iter, NULL); 227 strncpy(month, utf8_tmp, sizeof(month));
224 gtk_tree_store_set(lv->treestore, &iter, 228 utf8_tmp = gaim_utf8_try_convert(title);
225 0, title, 229 strncpy(title, utf8_tmp, sizeof(title));
226 1, log, -1); 230 g_free(utf8_tmp);
231
232 if (strncmp(month, prev_top_month, sizeof(month)) != 0) {
233 /* top level */
234 gtk_tree_store_append(lv->treestore, &toplevel, NULL);
235 gtk_tree_store_set(lv->treestore, &toplevel, 0, month, 1, NULL, -1);
236
237 /* sub */
238 gtk_tree_store_append(lv->treestore, &child, &toplevel);
239 gtk_tree_store_set(lv->treestore, &child, 0, title, 1, log, -1);
240
241 strncpy(prev_top_month, month, sizeof(prev_top_month));
242 } else {
243 gtk_tree_store_append(lv->treestore, &child, &toplevel);
244 gtk_tree_store_set(lv->treestore, &child, 0, title, 1, log, -1);
245 }
246
227 logs = logs->next; 247 logs = logs->next;
228 } 248 }
229 } 249 }
230 250
231 void gaim_gtk_log_show(const char *screenname, GaimAccount *account) { 251 void gaim_gtk_log_show(const char *screenname, GaimAccount *account) {