changeset 26832:2c08e3e34e02

merge of '26ac092613aaf9cdf75dc965213469a30135ab56' and 'a18b8f63efe643713d40b3c0b2ef93c6775d79be'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 29 Apr 2009 03:30:01 +0000
parents 5aabe95773dd (current diff) 82367f0e6ec3 (diff)
children c33f21f0a73e
files
diffstat 4 files changed, 65 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Wed Apr 29 02:12:19 2009 +0000
+++ b/ChangeLog.API	Wed Apr 29 03:30:01 2009 +0000
@@ -83,6 +83,7 @@
 		* PidginIconTheme, PidginStatusIconTheme, PidginIconThemeLoader
 		  API
 		* pidgin_stock_id_from_status_primitive
+		* pidgin_stock_id_from_presence
 
 	libgnt:
 		Added:
--- a/pidgin/gtkutils.c	Wed Apr 29 02:12:19 2009 +0000
+++ b/pidgin/gtkutils.c	Wed Apr 29 03:30:01 2009 +0000
@@ -1722,8 +1722,8 @@
 	return pixbuf;
 }
 
-const char *
-pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim)
+static const char *
+stock_id_from_status_primitive_idle(PurpleStatusPrimitive prim, gboolean idle)
 {
 	const char *stock = NULL;
 	switch (prim) {
@@ -1731,27 +1731,52 @@
 			stock = NULL;
 			break;
 		case PURPLE_STATUS_UNAVAILABLE:
-			stock = PIDGIN_STOCK_STATUS_BUSY;
+			stock = idle ? PIDGIN_STOCK_STATUS_BUSY_I : PIDGIN_STOCK_STATUS_BUSY;
 			break;
 		case PURPLE_STATUS_AWAY:
-			stock = PIDGIN_STOCK_STATUS_AWAY;
+			stock = idle ? PIDGIN_STOCK_STATUS_AWAY_I : PIDGIN_STOCK_STATUS_AWAY;
 			break;
 		case PURPLE_STATUS_EXTENDED_AWAY:
-			stock = PIDGIN_STOCK_STATUS_XA;
+			stock = idle ? PIDGIN_STOCK_STATUS_XA_I : PIDGIN_STOCK_STATUS_XA;
 			break;
 		case PURPLE_STATUS_INVISIBLE:
 			stock = PIDGIN_STOCK_STATUS_INVISIBLE;
 			break;
 		case PURPLE_STATUS_OFFLINE:
-			stock = PIDGIN_STOCK_STATUS_OFFLINE;
+			stock = idle ? PIDGIN_STOCK_STATUS_OFFLINE_I : PIDGIN_STOCK_STATUS_OFFLINE;
 			break;
 		default:
-			stock = PIDGIN_STOCK_STATUS_AVAILABLE;
+			stock = idle ? PIDGIN_STOCK_STATUS_AVAILABLE_I : PIDGIN_STOCK_STATUS_AVAILABLE;
 			break;
 	}
 	return stock;
 }
 
+const char *
+pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim)
+{
+	return stock_id_from_status_primitive_idle(prim, FALSE);
+}
+
+const char *
+pidgin_stock_id_from_presence(PurplePresence *presence)
+{
+	PurpleStatus *status;
+	PurpleStatusType *type;
+	PurpleStatusPrimitive prim;
+	gboolean idle;
+
+	g_return_val_if_fail(presence, NULL);
+
+	status = purple_presence_get_active_status(presence);
+	type = purple_status_get_type(status);
+	prim = purple_status_type_get_primitive(type);
+
+	idle = purple_presence_is_idle(presence);
+
+	return stock_id_from_status_primitive_idle(prim, idle);
+}
+
 GdkPixbuf *
 pidgin_create_prpl_icon(PurpleAccount *account, PidginPrplIconSize size)
 {
--- a/pidgin/gtkutils.h	Wed Apr 29 02:12:19 2009 +0000
+++ b/pidgin/gtkutils.h	Wed Apr 29 03:30:01 2009 +0000
@@ -581,6 +581,17 @@
 const char *pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim);
 
 /**
+ * Returns an appropriate stock-id for a PurplePresence.
+ *
+ * @param presence   The presence.
+ *
+ * @return The stock-id
+ *
+ * @since 2.6.0
+ */
+const char *pidgin_stock_id_from_presence(PurplePresence *presence);
+
+/**
  * Append a PurpleMenuAction to a menu.
  *
  * @param menu    The menu to append to.
--- a/pidgin/plugins/ticker/ticker.c	Wed Apr 29 02:12:19 2009 +0000
+++ b/pidgin/plugins/ticker/ticker.c	Wed Apr 29 03:30:01 2009 +0000
@@ -37,6 +37,7 @@
 #include "gtkblist.h"
 #include "gtkplugin.h"
 #include "gtkutils.h"
+#include "pidginstock.h"
 
 #include "gtkticker.h"
 
@@ -53,7 +54,7 @@
 	guint timeout;
 } TickerData;
 
-GList *tickerbuds = NULL;
+static GList *tickerbuds = NULL;
 
 static void buddy_ticker_update_contact(PurpleContact *contact);
 
@@ -91,9 +92,10 @@
 	PurpleContact *contact = user_data;
 	PurpleBuddy *b = purple_contact_get_priority_buddy(contact);
 
-	purple_conversation_new(PURPLE_CONV_TYPE_IM,
-	                        purple_buddy_get_account(b),
-							purple_buddy_get_name(b));
+	PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
+	                                purple_buddy_get_account(b),
+	                                purple_buddy_get_name(b));
+	purple_conversation_present(conv);
 	return TRUE;
 }
 
@@ -107,20 +109,27 @@
 	return NULL;
 }
 
-static void buddy_ticker_set_pixmap(PurpleContact *c) {
+static void buddy_ticker_set_pixmap(PurpleContact *c)
+{
 	TickerData *td = buddy_ticker_find_contact(c);
-	GdkPixbuf *pixbuf;
+	PurpleBuddy *buddy;
+	PurplePresence *presence;
+	const char *stock;
 
 	if(!td)
 		return;
 
-	if(!td->icon)
+	buddy = purple_contact_get_priority_buddy(c);
+	presence = purple_buddy_get_presence(buddy);
+	stock = pidgin_stock_id_from_presence(presence);
+	if(!td->icon) {
 		td->icon = gtk_image_new();
-
-	pixbuf = pidgin_blist_get_status_icon((PurpleBlistNode*)c,
-			PIDGIN_STATUS_ICON_SMALL);
-	gtk_image_set_from_pixbuf(GTK_IMAGE(td->icon), pixbuf);
-	g_object_unref(G_OBJECT(pixbuf));
+		g_object_set(G_OBJECT(td->icon), "stock", stock,
+				"icon-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC),
+				NULL);
+	} else {
+		g_object_set(G_OBJECT(td->icon), "stock", stock, NULL);
+	}
 }
 
 static gboolean buddy_ticker_set_pixmap_cb(gpointer data) {