changeset 14427:1e00e8245720

[gaim-migrate @ 17137] Patch from wabz (Richard Nelson) to show 'Last Seen' for offline buddies. I have also added a fix to show offline buddies in the tooltip for a contact if 'show offline buddies' is turned on. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 03 Sep 2006 08:01:12 +0000
parents b6047532826b
children f3645fe3da47
files console/gntblist.c
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntblist.c	Sun Sep 03 07:40:11 2006 +0000
+++ b/console/gntblist.c	Sun Sep 03 08:01:12 2006 +0000
@@ -1045,6 +1045,7 @@
 	GntTree *tree;
 	GntWidget *widget, *box;
 	char *title = NULL;
+	int lastseen = 0;
 
 	widget = ggblist->tree;
 	tree = GNT_TREE(widget);
@@ -1070,10 +1071,20 @@
 
 	if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
 		GaimBuddy *pr = gaim_contact_get_priority_buddy((GaimContact*)node);
+		gboolean offline = !GAIM_BUDDY_IS_ONLINE(pr);
+		gboolean showoffline = gaim_prefs_get_bool(PREF_ROOT "/showoffline");
+
 		title = g_strdup(gaim_contact_get_alias((GaimContact*)node));
 		tooltip_for_buddy(pr, str);
 		for (node = node->child; node; node = node->next) {
-			if (node == (GaimBlistNode*)pr || !GAIM_BUDDY_IS_ONLINE((GaimBuddy*)node))
+			if (offline) {
+				int value = gaim_blist_node_get_int(node, "last_seen");
+				if (value > lastseen)
+					lastseen = value;
+			}
+			if (node == (GaimBlistNode*)pr)
+				continue;
+			if (!showoffline && !GAIM_BUDDY_IS_ONLINE((GaimBuddy*)node))
 				continue;
 			str = g_string_append(str, "\n----------\n");
 			g_string_append_printf(str, _("Nickname: %s\n"), gaim_buddy_get_name((GaimBuddy*)node));
@@ -1083,6 +1094,8 @@
 		GaimBuddy *buddy = (GaimBuddy *)node;
 		tooltip_for_buddy(buddy, str);
 		title = g_strdup(gaim_buddy_get_name(buddy));
+		if (!GAIM_BUDDY_IS_ONLINE((GaimBuddy*)node))
+			lastseen = gaim_blist_node_get_int(node, "last_seen");
 	} else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
 		GaimGroup *group = (GaimGroup *)node;
 
@@ -1105,6 +1118,12 @@
 		return;
 	}
 
+	if (lastseen > 0) {
+		char *tmp = gaim_str_seconds_to_string(time(NULL) - lastseen);
+		g_string_append_printf(str, _("\nLast Seen: %s ago"), tmp);
+		g_free(tmp);
+	}
+
 	gnt_widget_get_position(widget, &x, &y);
 	gnt_widget_get_size(widget, &width, NULL);
 	top = gnt_tree_get_selection_visible_line(tree);