pidgin: 0f15c5a7: New API to get the stock-id for a presen...

sadrul at pidgin.im sadrul at pidgin.im
Tue Apr 28 23:31:16 EDT 2009


-----------------------------------------------------------------
Revision: 0f15c5a7278f404af37e6e4ba706a2e7cfc1d9e3
Ancestor: 8ca847c9c44387f3a02ab4d5c82fc696db14e28c
Author: sadrul at pidgin.im
Date: 2009-04-29T03:19:43
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0f15c5a7278f404af37e6e4ba706a2e7cfc1d9e3

Modified files:
        ChangeLog.API pidgin/gtkutils.c pidgin/gtkutils.h

ChangeLog: 

New API to get the stock-id for a presence.

-------------- next part --------------
============================================================
--- ChangeLog.API	3314ceaba0004f34ae95317a7d71a14950034ef6
+++ ChangeLog.API	99b9a8724eeeacae75763222086da67e8a09d270
@@ -83,6 +83,7 @@ version 2.6.0 (??/??/2009):
 		* PidginIconTheme, PidginStatusIconTheme, PidginIconThemeLoader
 		  API
 		* pidgin_stock_id_from_status_primitive
+		* pidgin_stock_id_from_presence
 
 	libgnt:
 		Added:
============================================================
--- pidgin/gtkutils.c	045c5737f708594fe428e7862430b9cb0f5b22b8
+++ pidgin/gtkutils.c	17f8decb6d1cf73f09dc584079c05b94d54a7aeb
@@ -1722,8 +1722,8 @@ GdkPixbuf * pidgin_create_status_icon(Pu
 	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 @@ pidgin_stock_id_from_status_primitive(Pu
 			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)
 {
============================================================
--- pidgin/gtkutils.h	7570d2b3a4018b0dfd313d8fd5dbc3357c391f49
+++ pidgin/gtkutils.h	8b5e41d7d2bc62a47bc90bd9b8cb6b0b5d30c9a0
@@ -581,6 +581,17 @@ const char *pidgin_stock_id_from_status_
 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.


More information about the Commits mailing list