changeset 14065:8ef994bacf3d

[gaim-migrate @ 16686] Add preference to show idletime in the 'tooltip' for the buddylist. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 10 Aug 2006 15:44:43 +0000
parents fec4fadf30c9
children 29f03c8fba4a
files console/gntblist.c console/gntprefs.c
diffstat 2 files changed, 37 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntblist.c	Wed Aug 09 18:19:12 2006 +0000
+++ b/console/gntblist.c	Thu Aug 10 15:44:43 2006 +0000
@@ -813,6 +813,18 @@
 			g_free(br);
 		}
 
+		if (gaim_prefs_get_bool("/gaim/gnt/blist/idletime"))
+		{
+			GaimPresence *pre = gaim_buddy_get_presence(buddy);
+			if (gaim_presence_is_idle(pre))
+			{
+				time_t idle = gaim_presence_get_idle_time(pre);
+				char *st = gaim_str_seconds_to_string(time(NULL) - idle);
+				g_string_append_printf(str, _("\nIdle: %s"), st);
+				g_free(st);
+			}
+		}
+
 		title = g_strdup(gaim_buddy_get_name(buddy));
 	}
 	else if (GAIM_BLIST_NODE_IS_GROUP(node))
--- a/console/gntprefs.c	Wed Aug 09 18:19:12 2006 +0000
+++ b/console/gntprefs.c	Thu Aug 10 15:44:43 2006 +0000
@@ -14,9 +14,12 @@
 	gaim_prefs_add_none("/gaim/gnt/plugins");
 	gaim_prefs_add_string_list("/gaim/gnt/plugins/loaded", NULL);
 
+	gaim_prefs_add_none("/gaim/gnt/blist");
+	gaim_prefs_add_bool("/gaim/gnt/blist/idletime", TRUE);
+	
 	gaim_prefs_add_none("/gaim/gnt/conversations");
 	gaim_prefs_add_bool("/gaim/gnt/conversations/timestamps", TRUE);
-	gaim_prefs_add_bool("/gaim/gnt/conversations/notify_typing", FALSE);
+	gaim_prefs_add_bool("/gaim/gnt/conversations/notify_typing", FALSE); /* XXX: Not functional yet */
 }
 
 typedef struct
@@ -93,6 +96,12 @@
 	return field;
 }
 
+static Prefs blist[] = 
+{
+	{GAIM_PREF_BOOLEAN, "/gaim/gnt/blist/idletime", _("Show Idle Time"), NULL},
+	{GAIM_PREF_NONE, NULL, NULL, NULL}
+};
+
 static Prefs convs[] = 
 {
 	{GAIM_PREF_BOOLEAN, "/gaim/gnt/conversations/timestamps", _("Show Timestamps"), NULL},
@@ -163,30 +172,31 @@
 	}
 }
 
-void gg_prefs_show_all()
+static void
+add_pref_group(GaimRequestFields *fields, const char *title, Prefs *prefs)
 {
-	GaimRequestFields *fields;
 	GaimRequestField *field;
 	GaimRequestFieldGroup *group;
 	int i;
 
-	fields = gaim_request_fields_new();
-
-	group = gaim_request_field_group_new(_("Conversations"));
+	group = gaim_request_field_group_new(title);
 	gaim_request_fields_add_group(fields, group);
-	for (i = 0; convs[i].pref; i++)
+	for (i = 0; prefs[i].pref; i++)
 	{
-		field = get_pref_field(convs + i);
+		field = get_pref_field(prefs + i);
 		gaim_request_field_group_add_field(group, field);
 	}
+}
 
-	group = gaim_request_field_group_new(_("Logging"));
-	gaim_request_fields_add_group(fields, group);
-	for (i = 0; logging[i].pref; i++)
-	{
-		field = get_pref_field(logging + i);
-		gaim_request_field_group_add_field(group, field);
-	}
+void gg_prefs_show_all()
+{
+	GaimRequestFields *fields;
+
+	fields = gaim_request_fields_new();
+
+	add_pref_group(fields, _("Buddy List"), blist);
+	add_pref_group(fields, _("Conversations"), convs);
+	add_pref_group(fields, _("Logging"), logging);
 
 	gaim_request_fields(NULL, _("Preferences"), NULL, NULL, fields,
 			_("Save"), G_CALLBACK(save_cb), _("Cancel"), NULL, NULL);