diff pidgin/gtkblist.c @ 29849:93cb9f54df45

Now that the "Set Mood" UI is in Pidgin, it can do whatever it likes to find the right icons. Thus, with a small function and a couple other small changes, I can shuffle all the icons around to eliminate the magic Makefile rules and all the duplicated icons at install-time.
author Richard Laager <rlaager@wiktel.com>
date Wed, 26 Nov 2008 22:44:08 +0000
parents 7cc66981f029
children 89b95d143116
line wrap: on
line diff
--- a/pidgin/gtkblist.c	Wed Nov 26 22:18:16 2008 +0000
+++ b/pidgin/gtkblist.c	Wed Nov 26 22:44:08 2008 +0000
@@ -3519,7 +3519,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"));
 		}
@@ -3614,6 +3615,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)
@@ -3637,8 +3656,10 @@
 		gtkbuddynode = node->ui_data;
 		presence = purple_buddy_get_presence(buddy);
 		if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOBILE)) {
-			path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems",
-						"16", "mobile.png", NULL);
+			/* 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);
 		}
 
@@ -3664,12 +3685,14 @@
 		presence = purple_buddy_get_presence(buddy);
 
 	if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOBILE)) {
-		path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", "mobile.png", NULL);
+		/* 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 (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
-		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);
 	}
 
@@ -3692,12 +3715,13 @@
 		
 		if (!(name && *name))
 			return NULL;
-	}
-
-	filename = g_strdup_printf("%s.png", name);
-
-	path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", filename, NULL);
-	g_free(filename);
+
+		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);
@@ -7699,23 +7723,16 @@
 
 	/* TODO: rlaager wants this sorted. */
 	for (mood = prpl_info->get_moods(account);
-	     mood->mood != NULL ; mood++)
-	{
-		char *icon_path;
-		char *filename;
+	     mood->mood != NULL ; mood++) {
+		char *path;
 
 		if (mood->mood == NULL || mood->description == NULL)
 			continue;
 
-		icon_path = g_strdup_printf("%s.png", mood->mood);
-		filename = g_build_filename("pixmaps", "pidgin",
-		                            "emblems", "16",
-		                             icon_path, NULL);
-		g_free(icon_path);
-
+		path = get_mood_icon_path(mood->mood);
 		purple_request_field_list_add_icon(f, _(mood->description),
-				filename, mood->mood);
-		g_free(filename);
+				path, (gpointer)mood->mood);
+		g_free(path);
 
 		if (current_mood && !strcmp(current_mood, mood->mood))
 			purple_request_field_list_add_selected(f, _(mood->description));