[rhythmbox] audioscrobbler: display user's total playcount in profile source
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: display user's total playcount in profile source
- Date: Tue, 21 Sep 2010 10:49:41 +0000 (UTC)
commit 16509352375edeb3d0cc624ba4a4c8ff30f047ce
Author: Jamie Nicol <jamie thenicols net>
Date: Fri Jun 25 16:26:49 2010 +0100
audioscrobbler: display user's total playcount in profile source
plugins/audioscrobbler/audioscrobbler-profile.ui | 22 +++++++++++++++++++-
.../rb-audioscrobbler-profile-source.c | 16 ++++++++++---
plugins/audioscrobbler/rb-audioscrobbler-user.c | 6 ++--
plugins/audioscrobbler/rb-audioscrobbler-user.h | 2 +-
4 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/plugins/audioscrobbler/audioscrobbler-profile.ui b/plugins/audioscrobbler/audioscrobbler-profile.ui
index 2d9411e..2dafe10 100644
--- a/plugins/audioscrobbler/audioscrobbler-profile.ui
+++ b/plugins/audioscrobbler/audioscrobbler-profile.ui
@@ -23,12 +23,14 @@
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
+ <property name="spacing">4</property>
<child>
<object class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="username_label">
<property name="visible">True</property>
+ <property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="2.000000"/>
@@ -68,6 +70,24 @@
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xscale">0</property>
+ <property name="left_padding">4</property>
+ <child>
+ <object class="GtkLabel" id="playcount_label">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xscale">0</property>
<child>
<object class="GtkLinkButton" id="view_profile_link">
<property name="label" translatable="yes">View your profile</property>
@@ -81,7 +101,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
index 6413b67..ea991cb 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
@@ -58,6 +58,7 @@ struct _RBAudioscrobblerProfileSourcePrivate {
GtkWidget *user_info_area;
GtkWidget *profile_image;
GtkWidget *username_label;
+ GtkWidget *playcount_label;
GtkWidget *view_profile_link;
GtkWidget *recent_tracks_area;
@@ -388,6 +389,7 @@ rb_audioscrobbler_profile_source_init_profile_ui (RBAudioscrobblerProfileSource
source->priv->user_info_area = GTK_WIDGET (gtk_builder_get_object (builder, "user_info_area"));
source->priv->profile_image = GTK_WIDGET (gtk_builder_get_object (builder, "profile_image"));
source->priv->username_label = GTK_WIDGET (gtk_builder_get_object (builder, "username_label"));
+ source->priv->playcount_label = GTK_WIDGET (gtk_builder_get_object (builder, "playcount_label"));
source->priv->view_profile_link = GTK_WIDGET (gtk_builder_get_object (builder, "view_profile_link"));
source->priv->recent_tracks_area = GTK_WIDGET (gtk_builder_get_object (builder, "recent_tracks_area"));
@@ -639,18 +641,24 @@ rb_audioscrobbler_profile_source_user_info_updated_cb (RBAudioscrobblerUser *use
{
RBAudioscrobblerProfileSource *source = RB_AUDIOSCROBBLER_PROFILE_SOURCE (user_data);
if (data != NULL) {
+ char *playcount_text;
+
gtk_label_set_label (GTK_LABEL (source->priv->username_label),
data->user_info.username);
+
+ playcount_text = g_strdup_printf (_("%s plays"), data->user_info.playcount);
+ gtk_label_set_label (GTK_LABEL (source->priv->playcount_label),
+ playcount_text);
+
gtk_link_button_set_uri (GTK_LINK_BUTTON (source->priv->view_profile_link),
data->user_info.url);
+
gtk_image_set_from_pixbuf (GTK_IMAGE (source->priv->profile_image), data->user_info.image);
gtk_widget_show_all (source->priv->user_info_area);
- } else {
- gtk_label_set_label (GTK_LABEL (source->priv->username_label),
- "");
- gtk_image_set_from_pixbuf (GTK_IMAGE (source->priv->profile_image), NULL);
+ g_free (playcount_text);
+ } else {
gtk_widget_hide_all (source->priv->user_info_area);
}
}
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-user.c b/plugins/audioscrobbler/rb-audioscrobbler-user.c
index 6bea59d..ad06bb3 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-user.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-user.c
@@ -46,6 +46,7 @@ rb_audioscrobbler_user_data_copy (RBAudioscrobblerUserData *data)
case RB_AUDIOSCROBBLER_USER_DATA_TYPE_USER_INFO:
d->user_info.username = g_strdup (data->user_info.username);
d->user_info.url = g_strdup (data->user_info.url);
+ d->user_info.playcount = g_strdup (data->user_info.playcount);
if (data->user_info.image != NULL) {
d->user_info.image = g_object_ref (data->user_info.image);
}
@@ -77,6 +78,7 @@ rb_audioscrobbler_user_data_free (RBAudioscrobblerUserData *data)
case RB_AUDIOSCROBBLER_USER_DATA_TYPE_USER_INFO:
g_free (data->user_info.username);
g_free (data->user_info.url);
+ g_free (data->user_info.playcount);
if (data->user_info.image != NULL) {
g_object_unref (data->user_info.image);
}
@@ -487,9 +489,6 @@ rb_audioscrobbler_user_set_authentication_details (RBAudioscrobblerUser *user,
/* load new user from cache (or set to NULL) */
rb_audioscrobbler_user_load_from_cache (user);
-
- /* request new info */
- //rb_audioscrobbler_user_update (user);
}
void
@@ -690,6 +689,7 @@ rb_audioscrobbler_user_parse_user_info (RBAudioscrobblerUser *user, const char *
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.url = g_strdup (json_object_get_string_member (user_object, "url"));
+ user_info->user_info.playcount = g_strdup (json_object_get_string_member (user_object, "playcount"));
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) {
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-user.h b/plugins/audioscrobbler/rb-audioscrobbler-user.h
index 6c460fb..7ecccdd 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-user.h
+++ b/plugins/audioscrobbler/rb-audioscrobbler-user.h
@@ -48,8 +48,8 @@ typedef struct {
union {
struct {
char *username;
- char *real_name;
char *url;
+ char *playcount;
GdkPixbuf *image;
} user_info;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]