[rhythmbox] audioscrobbler: display images in profile source
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: display images in profile source
- Date: Tue, 21 Sep 2010 10:49:15 +0000 (UTC)
commit 6f0cd3decd554dcb50cfa91e0f8bc3e6e86c1cbd
Author: Jamie Nicol <jamie thenicols net>
Date: Thu Jun 24 21:03:17 2010 +0100
audioscrobbler: display images in profile source
Display medium sized user profile image at top, then small thumbnails
next to artists and tracks. Images are saved to the user's cache dir.
.../rb-audioscrobbler-profile-source.c | 55 +++-
plugins/audioscrobbler/rb-audioscrobbler-user.c | 387 ++++++++++++++++----
2 files changed, 352 insertions(+), 90 deletions(-)
---
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
index 815a43a..16ffba5 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
@@ -572,11 +572,8 @@ rb_audioscrobbler_profile_source_set_user_list (RBAudioscrobblerProfileSource *s
for (i = 0; i < list_data->len; i++) {
GtkWidget *button;
RBAudioscrobblerUserData *data;
- char *button_text = NULL;
- char *escaped_title_text = NULL;
- char *escaped_artist_text = NULL;
- button = gtk_button_new_with_label ("");
+ button = gtk_button_new ();
gtk_button_set_alignment (GTK_BUTTON (button),
0, 0.5);
gtk_button_set_focus_on_click (GTK_BUTTON (button),
@@ -589,25 +586,59 @@ rb_audioscrobbler_profile_source_set_user_list (RBAudioscrobblerProfileSource *s
data = g_ptr_array_index (list_data, i);
if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_TRACK) {
+ char *button_text;
+ char *escaped_title_text;
+ char *escaped_artist_text;
+ GtkWidget *contents;
+ GtkWidget *label;
+
escaped_title_text = g_markup_escape_text (data->track.title, -1);
escaped_artist_text = g_markup_escape_text (data->track.artist, -1);
button_text = g_strdup_printf ("%i. %s\n<small>%s</small>",
i + 1,
escaped_title_text,
escaped_artist_text);
- gtk_label_set_markup (GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))),
- button_text);
+
+ contents = gtk_hbox_new (FALSE, 4);
+ if (data->track.image != NULL) {
+ gtk_box_pack_start (GTK_BOX(contents),
+ gtk_image_new_from_pixbuf (data->track.image),
+ FALSE, FALSE, 0);
+ }
+ label = gtk_label_new ("");
+ gtk_label_set_markup (GTK_LABEL (label), button_text);
+ gtk_box_pack_start (GTK_BOX(contents),
+ label,
+ FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (button), contents);
+
+ g_free (escaped_title_text);
+ g_free (escaped_artist_text);
+ g_free (button_text);
} else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_ARTIST) {
+ char *button_text;
+ GtkWidget *contents;
+ GtkWidget *label;
+
button_text = g_strdup_printf ("%i. %s",
i + 1,
data->artist.name);
- gtk_button_set_label (GTK_BUTTON (button), button_text);
- }
- g_free (escaped_title_text);
- g_free (escaped_artist_text);
- g_free (button_text);
+ contents = gtk_hbox_new (FALSE, 4);
+ if (data->artist.image != NULL) {
+ gtk_box_pack_start (GTK_BOX(contents),
+ gtk_image_new_from_pixbuf (data->artist.image),
+ FALSE, FALSE, 0);
+ }
+ label = gtk_label_new (button_text);
+ gtk_box_pack_start (GTK_BOX(contents),
+ label,
+ FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (button), contents);
+
+ g_free (button_text);
+ }
}
}
@@ -766,7 +797,7 @@ rb_audioscrobbler_profile_source_list_layout_size_allocate_cb (GtkWidget *layout
}
/* resize the table */
- rb_debug ("resizing table from %i to %i columns", current_num_columns, new_num_columns);
+ rb_debug ("resizing table from %i to %ix%i", current_num_columns, new_num_columns, new_num_rows);
gtk_table_resize (GTK_TABLE (table), new_num_columns, new_num_rows);
/* don't know why, but g_table_resize doesn't always update these properties properly */
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-user.c b/plugins/audioscrobbler/rb-audioscrobbler-user.c
index 497d2d1..35207c9 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-user.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-user.c
@@ -35,6 +35,8 @@
#include "rb-debug.h"
#include "rb-file-helpers.h"
+#define SMALL_IMAGE_SIZE 34
+
static RBAudioscrobblerUserData *
rb_audioscrobbler_user_data_copy (RBAudioscrobblerUserData *data)
{
@@ -128,6 +130,10 @@ struct _RBAudioscrobblerUserPrivate {
GPtrArray *loved_tracks;
GPtrArray *top_artists;
GPtrArray *recommended_artists;
+
+ /* for image downloads */
+ GHashTable *file_to_data_map;
+ GHashTable *file_to_cancellable_map;
};
#define RB_AUDIOSCROBBLER_USER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_AUDIOSCROBBLER_USER, RBAudioscrobblerUserPrivate))
@@ -148,7 +154,8 @@ static void rb_audioscrobbler_user_set_property (GObject *object,
static void rb_audioscrobbler_user_load_from_cache (RBAudioscrobblerUser *user);
-
+static char * rb_audioscrobbler_user_calculate_cached_response_path (RBAudioscrobblerUser *user,
+ const char *request_name);
static void rb_audioscrobbler_user_save_response_to_cache (RBAudioscrobblerUser *user,
const char *request_name,
const char *data);
@@ -200,6 +207,15 @@ static void rb_audioscrobbler_user_recommended_artists_response_cb (SoupSession
gpointer user_data);
static GPtrArray * rb_audioscrobbler_user_parse_recommended_artists (RBAudioscrobblerUser *user,
const char *data);
+
+static char * rb_audioscrobbler_user_calculate_cached_image_path (RBAudioscrobblerUser *user,
+ RBAudioscrobblerUserData *data);
+static void rb_audioscrobbler_user_download_image (RBAudioscrobblerUser *user,
+ const char *image_url,
+ RBAudioscrobblerUserData *data);
+static void rb_audioscrobbler_user_image_download_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data);
enum {
PROP_0,
PROP_SERVICE
@@ -325,6 +341,9 @@ rb_audioscrobbler_user_init (RBAudioscrobblerUser *user)
soup_session_async_new_with_options (SOUP_SESSION_ADD_FEATURE_BY_TYPE,
SOUP_TYPE_GNOME_FEATURES_2_26,
NULL);
+
+ user->priv->file_to_data_map = g_hash_table_new (g_direct_hash, g_direct_equal);
+ user->priv->file_to_cancellable_map = g_hash_table_new (g_direct_hash, g_direct_equal);
}
static void
@@ -377,6 +396,27 @@ rb_audioscrobbler_user_dispose (GObject* object)
g_ptr_array_unref (user->priv->recommended_artists);
user->priv->recommended_artists = NULL;
}
+
+ if (user->priv->file_to_data_map != NULL) {
+ g_hash_table_unref (user->priv->file_to_data_map);
+ user->priv->file_to_data_map = NULL;
+ }
+
+ if (user->priv->file_to_cancellable_map != NULL) {
+ GList *key;
+
+ for (key = g_hash_table_get_keys (user->priv->file_to_cancellable_map);
+ key != NULL;
+ key = g_list_next (key)) {
+ GCancellable *cancellable = g_hash_table_lookup (user->priv->file_to_cancellable_map, key->data);
+ g_cancellable_cancel (cancellable);
+ g_object_unref (cancellable);
+ }
+ g_list_free (key);
+
+ g_hash_table_unref (user->priv->file_to_cancellable_map);
+ user->priv->file_to_cancellable_map = NULL;
+ }
}
static void
@@ -433,82 +473,6 @@ mkmd5 (char *string)
return md5_result;
}
-static char *
-rb_audioscrobbler_user_calculate_cached_response_path (RBAudioscrobblerUser *user, const char *request_name)
-{
- const char *rb_cache_dir;
- rb_cache_dir = rb_user_cache_dir ();
-
- return g_build_filename (rb_cache_dir,
- "audioscrobbler",
- rb_audioscrobbler_service_get_name (user->priv->service),
- "ws-responses",
- user->priv->username,
- request_name,
- NULL);
-}
-
-static void
-rb_audioscrobbler_user_save_response_to_cache (RBAudioscrobblerUser *user, const char *request_name, const char *data)
-{
- char *filename;
- char *file_dir;
-
- filename = rb_audioscrobbler_user_calculate_cached_response_path (user, request_name);
- file_dir = g_path_get_dirname (filename);
-
- g_mkdir_with_parents (file_dir, 0700);
- if (g_file_set_contents (filename, data, -1, NULL)) {
- rb_debug ("saved %s to cache", request_name);
- } else {
- rb_debug ("error saving %s to cache", request_name);
- }
-
- g_free (filename);
- g_free (file_dir);
-}
-
-/*static char *
-rb_audioscrobbler_user_calculate_cached_image_path (RBAudioscrobblerUser *user, RBAudioscrobblerUserData *data)
-{
- const char *rb_cache_dir;
- char *cache_dir;
- char *image_path = NULL;
-
- rb_cache_dir = rb_user_cache_dir ();
- cache_dir = g_build_filename (rb_cache_dir,
- "audioscrobbler",
- rb_audioscrobbler_service_get_name (user->priv->service),
- "images",
- NULL);
-
- if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_USER_INFO) {
- image_path = g_build_filename (cache_dir,
- "users",
- data->user_info.username,
- NULL);
-
- } else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_TRACK) {
- char *filename = g_strdup_printf ("%s - %s",
- data->track.artist,
- data->track.title);
- image_path = g_build_filename (cache_dir,
- "tracks",
- filename,
- NULL);
- g_free (filename);
-
- } else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_ARTIST) {
- image_path = g_build_filename (cache_dir,
- "artists",
- data->artist.name,
- NULL);
- }
-
- g_free (cache_dir);
- return image_path;
-}*/
-
void
rb_audioscrobbler_user_set_authentication_details (RBAudioscrobblerUser *user,
const char *username,
@@ -588,6 +552,41 @@ rb_audioscrobbler_user_load_from_cache (RBAudioscrobblerUser *user)
}
}
+static char *
+rb_audioscrobbler_user_calculate_cached_response_path (RBAudioscrobblerUser *user, const char *request_name)
+{
+ const char *rb_cache_dir;
+ rb_cache_dir = rb_user_cache_dir ();
+
+ return g_build_filename (rb_cache_dir,
+ "audioscrobbler",
+ rb_audioscrobbler_service_get_name (user->priv->service),
+ "ws-responses",
+ user->priv->username,
+ request_name,
+ NULL);
+}
+
+static void
+rb_audioscrobbler_user_save_response_to_cache (RBAudioscrobblerUser *user, const char *request_name, const char *data)
+{
+ char *filename;
+ char *file_dir;
+
+ filename = rb_audioscrobbler_user_calculate_cached_response_path (user, request_name);
+ file_dir = g_path_get_dirname (filename);
+
+ g_mkdir_with_parents (file_dir, 0700);
+ if (g_file_set_contents (filename, data, -1, NULL)) {
+ rb_debug ("saved %s to cache", request_name);
+ } else {
+ rb_debug ("error saving %s to cache", request_name);
+ }
+
+ g_free (filename);
+ g_free (file_dir);
+}
+
/* user info */
static void
rb_audioscrobbler_user_load_cached_user_info (RBAudioscrobblerUser *user)
@@ -687,12 +686,23 @@ rb_audioscrobbler_user_parse_user_info (RBAudioscrobblerUser *user, const char *
if (json_object_has_member (root_object, "user")) {
JsonObject *user_object;
- user_info = g_slice_new0 (RBAudioscrobblerUserData);
user_object = json_object_get_object_member (root_object, "user");
+ user_info = g_slice_new0 (RBAudioscrobblerUserData);
+ user_info->type = RB_AUDIOSCROBBLER_USER_DATA_TYPE_USER_INFO;
user_info->user_info.username = g_strdup (json_object_get_string_member (user_object, "name"));
user_info->user_info.real_name = g_strdup (json_object_get_string_member (user_object, "realname"));
user_info->user_info.url = g_strdup (json_object_get_string_member (user_object, "url"));
+
+ user_info->user_info.image = gdk_pixbuf_new_from_file (rb_audioscrobbler_user_calculate_cached_image_path (user, user_info), NULL);
+ if (user_info->user_info.image == NULL && json_object_has_member (user_object, "image") == TRUE) {
+ JsonArray *image_array;
+ JsonObject *image_object;
+
+ image_array = json_object_get_array_member (user_object, "image");
+ image_object = json_array_get_object_element (image_array, 2);
+ rb_audioscrobbler_user_download_image (user, json_object_get_string_member (image_object, "#text"), user_info);
+ }
}
g_object_unref (parser);
@@ -820,6 +830,17 @@ rb_audioscrobbler_user_parse_recent_tracks (RBAudioscrobblerUser *user, const ch
track->track.url = g_strdup (json_object_get_string_member (track_object, "url"));
g_ptr_array_add (recent_tracks, track);
+
+ track->track.image = gdk_pixbuf_new_from_file_at_size (rb_audioscrobbler_user_calculate_cached_image_path (user, track),
+ SMALL_IMAGE_SIZE, SMALL_IMAGE_SIZE, NULL);
+ if (track->track.image == NULL && json_object_has_member (track_object, "image") == TRUE) {
+ JsonArray *image_array;
+ JsonObject *image_object;
+
+ image_array = json_object_get_array_member (track_object, "image");
+ image_object = json_array_get_object_element (image_array, 0);
+ rb_audioscrobbler_user_download_image (user, json_object_get_string_member (image_object, "#text"), track);
+ }
}
}
@@ -948,6 +969,17 @@ rb_audioscrobbler_user_parse_top_tracks (RBAudioscrobblerUser *user, const char
track->track.url = g_strdup (json_object_get_string_member (track_object, "url"));
g_ptr_array_add (top_tracks, track);
+
+ track->track.image = gdk_pixbuf_new_from_file_at_size (rb_audioscrobbler_user_calculate_cached_image_path (user, track),
+ SMALL_IMAGE_SIZE, SMALL_IMAGE_SIZE, NULL);
+ if (track->track.image == NULL && json_object_has_member (track_object, "image") == TRUE) {
+ JsonArray *image_array;
+ JsonObject *image_object;
+
+ image_array = json_object_get_array_member (track_object, "image");
+ image_object = json_array_get_object_element (image_array, 0);
+ rb_audioscrobbler_user_download_image (user, json_object_get_string_member (image_object, "#text"), track);
+ }
}
}
@@ -1076,6 +1108,17 @@ rb_audioscrobbler_user_parse_loved_tracks (RBAudioscrobblerUser *user, const cha
track->track.url = g_strdup (json_object_get_string_member (track_object, "url"));
g_ptr_array_add (loved_tracks, track);
+
+ track->track.image = gdk_pixbuf_new_from_file_at_size (rb_audioscrobbler_user_calculate_cached_image_path (user, track),
+ SMALL_IMAGE_SIZE, SMALL_IMAGE_SIZE, NULL);
+ if (track->track.image == NULL && json_object_has_member (track_object, "image") == TRUE) {
+ JsonArray *image_array;
+ JsonObject *image_object;
+
+ image_array = json_object_get_array_member (track_object, "image");
+ image_object = json_array_get_object_element (image_array, 0);
+ rb_audioscrobbler_user_download_image (user, json_object_get_string_member (image_object, "#text"), track);
+ }
}
}
@@ -1201,6 +1244,17 @@ rb_audioscrobbler_user_parse_top_artists (RBAudioscrobblerUser *user, const char
artist->artist.url = g_strdup (json_object_get_string_member (artist_object, "url"));
g_ptr_array_add (top_artists, artist);
+
+ artist->artist.image = gdk_pixbuf_new_from_file_at_size (rb_audioscrobbler_user_calculate_cached_image_path (user, artist),
+ SMALL_IMAGE_SIZE, SMALL_IMAGE_SIZE, NULL);
+ if (artist->artist.image == NULL && json_object_has_member (artist_object, "image") == TRUE) {
+ JsonArray *image_array;
+ JsonObject *image_object;
+
+ image_array = json_object_get_array_member (artist_object, "image");
+ image_object = json_array_get_object_element (image_array, 0);
+ rb_audioscrobbler_user_download_image (user, json_object_get_string_member (image_object, "#text"), artist);
+ }
}
}
@@ -1343,6 +1397,17 @@ rb_audioscrobbler_user_parse_recommended_artists (RBAudioscrobblerUser *user, co
artist->artist.url = g_strdup (json_object_get_string_member (artist_object, "url"));
g_ptr_array_add (recommended_artists, artist);
+
+ artist->artist.image = gdk_pixbuf_new_from_file_at_size (rb_audioscrobbler_user_calculate_cached_image_path (user, artist),
+ SMALL_IMAGE_SIZE, SMALL_IMAGE_SIZE, NULL);
+ if (artist->artist.image == NULL && json_object_has_member (artist_object, "image") == TRUE) {
+ JsonArray *image_array;
+ JsonObject *image_object;
+
+ image_array = json_object_get_array_member (artist_object, "image");
+ image_object = json_array_get_object_element (image_array, 0);
+ rb_audioscrobbler_user_download_image (user, json_object_get_string_member (image_object, "#text"), artist);
+ }
}
}
}
@@ -1351,3 +1416,169 @@ rb_audioscrobbler_user_parse_recommended_artists (RBAudioscrobblerUser *user, co
return recommended_artists;
}
+
+static char *
+rb_audioscrobbler_user_calculate_cached_image_path (RBAudioscrobblerUser *user, RBAudioscrobblerUserData *data)
+{
+ const char *rb_cache_dir;
+ char *cache_dir;
+ char *image_path = NULL;
+
+ rb_cache_dir = rb_user_cache_dir ();
+ cache_dir = g_build_filename (rb_cache_dir,
+ "audioscrobbler",
+ rb_audioscrobbler_service_get_name (user->priv->service),
+ "images",
+ NULL);
+
+ if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_USER_INFO) {
+ image_path = g_build_filename (cache_dir,
+ "users",
+ data->user_info.username,
+ NULL);
+
+ } else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_TRACK) {
+ char *filename = g_strdup_printf ("%s - %s",
+ data->track.artist,
+ data->track.title);
+ image_path = g_build_filename (cache_dir,
+ "tracks",
+ filename,
+ NULL);
+ g_free (filename);
+
+ } else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_ARTIST) {
+ image_path = g_build_filename (cache_dir,
+ "artists",
+ data->artist.name,
+ NULL);
+ }
+
+ g_free (cache_dir);
+ return image_path;
+}
+
+static void
+rb_audioscrobbler_user_download_image (RBAudioscrobblerUser *user, const char *image_url, RBAudioscrobblerUserData *data)
+{
+ GFile *src_file;
+
+ /* check image_url is not null or empty */
+ if (image_url == NULL || image_url[0] == '\0') {
+ return;
+ }
+
+ src_file = g_file_new_for_uri (image_url);
+
+ /* only start a download if the file is not already being downloaded */
+ if (g_hash_table_lookup (user->priv->file_to_data_map, src_file) == NULL) {
+ GCancellable *cancellable;
+ char *dest_filename;
+ char *dest_file_dir;
+ GFile *dest_file;
+
+ /* add data to map */
+ g_hash_table_insert (user->priv->file_to_data_map, src_file, data);
+
+ /* create a cancellable for this download */
+ cancellable = g_cancellable_new ();
+ g_hash_table_insert (user->priv->file_to_cancellable_map, src_file, cancellable);
+
+ /* ensure the dest dir exists */
+ dest_filename = rb_audioscrobbler_user_calculate_cached_image_path (user, data);
+ dest_file_dir = g_path_get_dirname (dest_filename);
+ g_mkdir_with_parents (dest_file_dir, 0700);
+
+ /* download the file */
+ rb_debug ("downloading image %s to %s", image_url, dest_filename);
+ dest_file = g_file_new_for_path (dest_filename);
+ g_file_copy_async (src_file,
+ dest_file,
+ G_FILE_COPY_OVERWRITE,
+ G_PRIORITY_DEFAULT,
+ cancellable,
+ NULL,
+ NULL,
+ rb_audioscrobbler_user_image_download_cb,
+ user);
+
+ g_free (dest_filename);
+ g_free (dest_file_dir);
+ g_object_unref (dest_file);
+ }
+}
+
+static void
+rb_audioscrobbler_user_image_download_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ GFile *src_file = G_FILE (source_object);
+
+ if (g_file_copy_finish (src_file, res, NULL)) {
+ RBAudioscrobblerUser *user;
+ GCancellable *cancellable;
+ RBAudioscrobblerUserData *data;
+ char *dest_file_path;
+
+ user = RB_AUDIOSCROBBLER_USER (user_data);
+
+ /* free the cancellable */
+ cancellable = g_hash_table_lookup (user->priv->file_to_cancellable_map, src_file);
+ g_hash_table_remove (user->priv->file_to_cancellable_map, src_file);
+ g_object_unref (cancellable);
+
+ /* update the data */
+ data = g_hash_table_lookup (user->priv->file_to_data_map, src_file);
+ g_hash_table_remove (user->priv->file_to_data_map, src_file);
+
+ dest_file_path = rb_audioscrobbler_user_calculate_cached_image_path (user, data);
+ if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_USER_INFO) {
+ data->user_info.image = gdk_pixbuf_new_from_file (dest_file_path, NULL);
+ } else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_TRACK) {
+ data->track.image = gdk_pixbuf_new_from_file_at_size (dest_file_path, SMALL_IMAGE_SIZE, SMALL_IMAGE_SIZE, NULL);
+ } else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_ARTIST) {
+ data->artist.image = gdk_pixbuf_new_from_file_at_size (dest_file_path, SMALL_IMAGE_SIZE, SMALL_IMAGE_SIZE, NULL);
+ }
+
+ /* emit appropriate signal - quite ugly, surely this could be done in a nicer way */
+ if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_USER_INFO) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[USER_INFO_UPDATED],
+ 0, data);
+ } else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_TRACK) {
+ int i;
+ for (i = 0; i < user->priv->recent_tracks->len; i++) {
+ if (g_ptr_array_index (user->priv->recent_tracks, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[RECENT_TRACKS_UPDATED],
+ 0, user->priv->recent_tracks);
+ }
+ }
+ for (i = 0; i < user->priv->top_tracks->len; i++) {
+ if (g_ptr_array_index (user->priv->top_tracks, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[TOP_TRACKS_UPDATED],
+ 0, user->priv->top_tracks);
+ }
+ }
+ for (i = 0; i < user->priv->loved_tracks->len; i++) {
+ if (g_ptr_array_index (user->priv->loved_tracks, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[LOVED_TRACKS_UPDATED],
+ 0, user->priv->loved_tracks);
+ }
+ }
+ } else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_ARTIST) {
+ int i;
+ for (i = 0; i < user->priv->top_artists->len; i++) {
+ if (g_ptr_array_index (user->priv->top_artists, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[TOP_ARTISTS_UPDATED],
+ 0, user->priv->top_artists);
+ }
+ }
+ for (i = 0; i < user->priv->recommended_artists->len; i++) {
+ if (g_ptr_array_index (user->priv->recommended_artists, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[RECOMMENDED_ARTISTS_UPDATED],
+ 0, user->priv->recommended_artists);
+ }
+ }
+ }
+ } else {
+ rb_debug ("error downloading image. possibly due to cancellation");
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]