diff pidgin/gtkblist.c @ 29851:5391094529c6

propagate from branch 'im.pidgin.pidgin' (head a59a573e3b9b2eb42ff728ba9ff56095f5c9e0d0) to branch 'im.pidgin.cpw.rekkanoryo.icqxstatus' (head b2dd657b5f76abb4285d229516102653fd4616eb)
author Richard Laager <rlaager@wiktel.com>
date Mon, 06 Apr 2009 05:19:40 +0000
parents f5f08111da52 89b95d143116
children a538cb73f897
line wrap: on
line diff
--- a/pidgin/gtkblist.c	Sun Apr 05 20:06:11 2009 +0000
+++ b/pidgin/gtkblist.c	Mon Apr 06 05:19:40 2009 +0000
@@ -3612,7 +3612,8 @@
 
 
 		/* Offline? */
-		/* FIXME: Why is this status special-cased by the core? -- rlaager */
+		/* FIXME: Why is this status special-cased by the core? --rlaager
+		 * FIXME: Alternatively, why not have the core do all of them? --rlaager */
 		if (!PURPLE_BUDDY_IS_ONLINE(b)) {
 			purple_notify_user_info_add_pair(user_info, _("Status"), _("Offline"));
 		}
@@ -3707,6 +3708,24 @@
 	return pb;
 }
 
+static char *get_mood_icon_path(const char *mood)
+{
+	char *path;
+
+	if (!strcmp(mood, "busy")) {
+		path = g_build_filename(DATADIR, "pixmaps", "pidgin",
+		                        "status", "16", "busy.png", NULL);
+	} else if (!strcmp(mood, "hiptop")) {
+		path = g_build_filename(DATADIR, "pixmaps", "pidgin",
+		                        "emblems", "16", "hiptop.png", NULL);
+	} else {
+		char *filename = g_strdup_printf("%s.png", mood);
+		path = g_build_filename(DATADIR, "pixmaps", "pidgin",
+		                        "emotes", "small", filename, NULL);
+		g_free(filename);
+	}
+	return path;
+}
 
 GdkPixbuf *
 pidgin_blist_get_emblem(PurpleBlistNode *node)
@@ -3718,7 +3737,7 @@
 	PurplePluginProtocolInfo *prpl_info;
 	const char *name = NULL;
 	char *filename, *path;
-	PurplePresence *p;
+	PurplePresence *presence = NULL;
 	PurpleStatus *tune;
 
 	if(PURPLE_BLIST_NODE_IS_CONTACT(node)) {
@@ -3729,16 +3748,19 @@
 	} else if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
 		buddy = (PurpleBuddy*)node;
 		gtkbuddynode = node->ui_data;
-		p = purple_buddy_get_presence(buddy);
-		if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
-			path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems",
-						"16", "mobile.png", NULL);
+		presence = purple_buddy_get_presence(buddy);
+		if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOBILE)) {
+			/* This emblem comes from the small emoticon set now,
+			 * to reduce duplication. */
+			path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emotes",
+						"small", "mobile.png", NULL);
 			return _pidgin_blist_get_cached_emblem(path);
 		}
 
 		if (((struct _pidgin_blist_node*)(node->parent->ui_data))->contact_expanded) {
-			if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons"))
-				return pidgin_create_prpl_icon(((PurpleBuddy*)node)->account, PIDGIN_PRPL_ICON_SMALL);
+			if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons"))
+				return NULL;
+			return pidgin_create_prpl_icon(((PurpleBuddy*)node)->account, PIDGIN_PRPL_ICON_SMALL);
 		}
 	} else {
 		return NULL;
@@ -3751,9 +3773,14 @@
 		return _pidgin_blist_get_cached_emblem(path);
 	}
 
-	p = purple_buddy_get_presence(buddy);
-	if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
-		path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", "mobile.png", NULL);
+	/* If we came through the contact code flow above, we didn't need
+	 * to get the presence until now. */
+	if (presence == NULL)
+		presence = purple_buddy_get_presence(buddy);
+
+	if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOBILE)) {
+		/* This emblem comes from the small emoticon set now, to reduce duplication. */
+		path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emotes", "small", "mobile.png", NULL);
 		return _pidgin_blist_get_cached_emblem(path);
 	}
 
@@ -3772,7 +3799,8 @@
 			return _pidgin_blist_get_cached_emblem(path);
 		}
 		/* Regular old "tune" is the only one in all protocols. */
-		path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", "music.png", NULL);
+		/* This emblem comes from the small emoticon set now, to reduce duplication. */
+		path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emotes", "small", "music.png", NULL);
 		return _pidgin_blist_get_cached_emblem(path);
 	}
 
@@ -3784,13 +3812,24 @@
 	if (prpl_info && prpl_info->list_emblem)
 		name = prpl_info->list_emblem(buddy);
 
-	if (name == NULL)
-		return NULL;
-
-	filename = g_strdup_printf("%s.png", name);
-
-	path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", filename, NULL);
-	g_free(filename);
+	if (name == NULL) {
+		PurpleStatus *status;
+
+		if (!purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOOD))
+			return NULL;
+
+		status = purple_presence_get_status(presence, "mood");
+		name = purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
+		
+		if (!(name && *name))
+			return NULL;
+
+		path = get_mood_icon_path(name);
+	} else {
+		filename = g_strdup_printf("%s.png", name);
+		path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", filename, NULL);
+		g_free(filename);
+	}
 
 	/* _pidgin_blist_get_cached_emblem() assumes ownership of path */
 	return _pidgin_blist_get_cached_emblem(path);
@@ -8022,6 +8061,7 @@
 		PurpleAccount *account = NULL;
 		GdkPixbuf *pixbuf = NULL;
 		PurplePlugin *plugin = NULL;
+		PurplePluginProtocolInfo *prpl_info
 
 		account = accounts->data;
 
@@ -8061,12 +8101,38 @@
 
 		gc = purple_account_get_connection(account);
 		plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? gc->prpl : NULL;
-		if (plugin && PURPLE_PLUGIN_HAS_ACTIONS(plugin)) {
-			build_plugin_actions(submenu, plugin, gc);
-		} else {
-			menuitem = gtk_menu_item_new_with_label(_("No actions available"));
-			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
-			gtk_widget_set_sensitive(menuitem, FALSE);
+
+		if (plugin &&
+		    (prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin)) &&
+		    PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods))
+		{
+			GList *types;
+			for (types = purple_account_get_status_types(account);
+			     types != NULL ; types = types->next)
+			{
+				PurpleStatusType *type = types->data;
+
+				if (strcmp(purple_status_type_get_id(type), "mood") != 0)
+					continue;
+
+				menuitem = gtk_menu_item_new_with_mnemonic(_("Set _Mood..."));
+				g_signal_connect(G_OBJECT(menuitem), "activate",
+					         G_CALLBACK(set_mood_cb), account);
+				gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
+
+				/* Be safe.  It shouldn't match more than once anyway */
+				break;
+			}
+		}
+		else
+		{
+			if (plugin && PURPLE_PLUGIN_HAS_ACTIONS(plugin)) {
+				build_plugin_actions(submenu, plugin, gc);
+			} else {
+				menuitem = gtk_menu_item_new_with_label(_("No actions available"));
+				gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
+				gtk_widget_set_sensitive(menuitem, FALSE);
+			}
 		}
 
 		pidgin_separator(submenu);
@@ -8183,4 +8249,3 @@
 	if (activeitem)
 		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE);
 }
-