pidgin/gtkblist.c

changeset 24234
376c2d213eb1
parent 24232
9815b1c75ff6
child 24238
c7b89f7af693
--- a/pidgin/gtkblist.c	Mon Sep 01 08:31:54 2008 +0000
+++ b/pidgin/gtkblist.c	Mon Sep 01 13:31:43 2008 +0000
@@ -67,6 +67,7 @@
 #include <gdk/gdk.h>
 
 #define HEADLINE_CLOSE_SIZE 12
+#define STEPS 50
 
 typedef struct
 {
@@ -167,11 +168,18 @@
 	PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE    =  1 << 0,  /* Whether there's pending message in a conversation */
 } PidginBlistNodeFlags;
 
+typedef enum {
+	RECENT_STATUS_NONE = 0,
+	RECENT_STATUS_SIGN_ON,
+	RECENT_STATUS_SIGN_OFF
+} RecentStatus;
+
 typedef struct _pidgin_blist_node {
 	GtkTreeRowReference *row;
 	gboolean contact_expanded;
-	gboolean recent_signonoff;
+	RecentStatus recent_signonoff;
 	gint recent_signonoff_timer;
+	gint recent_signonoff_steps;
 	struct {
 		PurpleConversation *conv;
 		time_t last_message;          /* timestamp for last displayed message */
@@ -3738,11 +3746,11 @@
 		p = purple_buddy_get_presence(buddy);
 		trans = purple_presence_is_idle(p);
 
-		if (PURPLE_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff)
+		/*if (PURPLE_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff)
 			icon = PIDGIN_STOCK_STATUS_LOGIN;
 		else if (gtkbuddynode && gtkbuddynode->recent_signonoff)
 			icon = PIDGIN_STOCK_STATUS_LOGOUT;
-		else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE))
+		else */if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE))
 			if (trans)
 				icon = PIDGIN_STOCK_STATUS_BUSY_I;
 			else
@@ -6038,9 +6046,11 @@
 	GdkPixbuf *status, *avatar, *emblem, *prpl_icon;
 	char *mark;
 	char *idle = NULL;
+	struct _pidgin_blist_node *gtknode = ((PurpleBlistNode*)buddy)->ui_data;
 	gboolean expanded = ((struct _pidgin_blist_node *)(node->parent->ui_data))->contact_expanded;
 	gboolean selected = (gtkblist->selected_node == node);
 	gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons");
+	int size;
 	presence = purple_buddy_get_presence(buddy);
 
 	if (editing_blist)
@@ -6049,6 +6059,14 @@
 	status = pidgin_blist_get_status_icon((PurpleBlistNode*)buddy,
 						biglist ? PIDGIN_STATUS_ICON_LARGE : PIDGIN_STATUS_ICON_SMALL);
 
+	size = biglist ? 16 : 11;
+	if (gtknode->recent_signonoff == RECENT_STATUS_SIGN_ON) {
+		size = size / 2 + (size / 2 + (STEPS - gtknode->recent_signonoff_steps)) % (size / 2);
+	} else if (gtknode->recent_signonoff == RECENT_STATUS_SIGN_OFF) {
+		size = size - (STEPS - gtknode->recent_signonoff_steps) % (size / 2);
+	}
+	status = gdk_pixbuf_scale_simple(status, size, size, GDK_INTERP_BILINEAR);
+
 	/* Speed it up if we don't want buddy icons. */
 	if(biglist)
 		avatar = pidgin_blist_get_buddy_icon((PurpleBlistNode *)buddy, TRUE, TRUE);
@@ -6180,7 +6198,7 @@
 					   BUDDY_ICON_COLUMN, NULL,
 					   CONTACT_EXPANDER_COLUMN, TRUE,
 					   CONTACT_EXPANDER_VISIBLE_COLUMN, TRUE,
-				  	   GROUP_EXPANDER_VISIBLE_COLUMN, FALSE,
+					   GROUP_EXPANDER_VISIBLE_COLUMN, FALSE,
 					-1);
 			g_free(mark);
 			if(status)
@@ -7132,13 +7150,17 @@
 static gboolean buddy_signonoff_timeout_cb(PurpleBuddy *buddy)
 {
 	struct _pidgin_blist_node *gtknode = ((PurpleBlistNode*)buddy)->ui_data;
-
-	gtknode->recent_signonoff = FALSE;
-	gtknode->recent_signonoff_timer = 0;
+	gboolean cont = TRUE;
+
+	if (--gtknode->recent_signonoff_steps == 0) {
+		gtknode->recent_signonoff = RECENT_STATUS_NONE;
+		gtknode->recent_signonoff_timer = 0;
+		cont = FALSE;
+	}
 
 	pidgin_blist_update(NULL, (PurpleBlistNode*)buddy);
 
-	return FALSE;
+	return cont;
 }
 
 static void buddy_signonoff_cb(PurpleBuddy *buddy)
@@ -7151,11 +7173,12 @@
 
 	gtknode = ((PurpleBlistNode*)buddy)->ui_data;
 
-	gtknode->recent_signonoff = TRUE;
+	gtknode->recent_signonoff = PURPLE_BUDDY_IS_ONLINE(buddy) ? RECENT_STATUS_SIGN_ON : RECENT_STATUS_SIGN_OFF;
 
 	if(gtknode->recent_signonoff_timer > 0)
 		purple_timeout_remove(gtknode->recent_signonoff_timer);
-	gtknode->recent_signonoff_timer = purple_timeout_add(10000,
+	gtknode->recent_signonoff_steps = STEPS;
+	gtknode->recent_signonoff_timer = purple_timeout_add(100,
 			(GSourceFunc)buddy_signonoff_timeout_cb, buddy);
 }
 
@@ -7632,7 +7655,10 @@
 			gtk_widget_destroy(menuitem);
 	}
 
-	for (accounts = purple_accounts_get_all(); accounts; accounts = accounts->next) {
+	if (!(accounts = purple_accounts_get_all()))
+		return;
+
+	for (; accounts; accounts = accounts->next) {
 		char *buf = NULL;
 		GtkWidget *image = NULL;
 		PurpleAccount *account = NULL;

mercurial