changeset 26729:89f613b16e2b

New API to get the stock-id for a presence.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 29 Apr 2009 03:19:43 +0000
parents f28cb84e1632
children 82367f0e6ec3
files ChangeLog.API pidgin/gtkutils.c pidgin/gtkutils.h
diffstat 3 files changed, 44 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Wed Apr 29 02:27:55 2009 +0000
+++ b/ChangeLog.API	Wed Apr 29 03:19:43 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:27:55 2009 +0000
+++ b/pidgin/gtkutils.c	Wed Apr 29 03:19:43 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:27:55 2009 +0000
+++ b/pidgin/gtkutils.h	Wed Apr 29 03:19:43 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.