[rhythmbox] audioscrobbler: add UI for creating custom radio stations
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: add UI for creating custom radio stations
- Date: Tue, 21 Sep 2010 10:50:51 +0000 (UTC)
commit 32934a27b4bf1fe943fd059dc76a44b711cff370
Author: Jamie Nicol <jamie thenicols net>
Date: Tue Jul 13 13:56:12 2010 +0100
audioscrobbler: add UI for creating custom radio stations
plugins/audioscrobbler/audioscrobbler-profile.ui | 123 +++++++++++++++++++-
.../rb-audioscrobbler-profile-source.c | 92 +++++++++++++++
.../rb-audioscrobbler-radio-source.c | 42 +++++--
.../rb-audioscrobbler-radio-source.h | 3 +-
4 files changed, 242 insertions(+), 18 deletions(-)
---
diff --git a/plugins/audioscrobbler/audioscrobbler-profile.ui b/plugins/audioscrobbler/audioscrobbler-profile.ui
index 1701b0d..3056a79 100644
--- a/plugins/audioscrobbler/audioscrobbler-profile.ui
+++ b/plugins/audioscrobbler/audioscrobbler-profile.ui
@@ -294,6 +294,119 @@
</packing>
</child>
<child>
+ <object class="GtkVBox" id="station_creator_area">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHSeparator" id="hseparator6">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="radio_creator_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">10</property>
+ <property name="ypad">10</property>
+ <property name="label" translatable="yes">Create a Radio Station</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="station_creator_type_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Type:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">4</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="station_creator_combo_container">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="station_creator_arg_label">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">4</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="station_creator_arg_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="activates_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="station_creator_button">
+ <property name="label" translatable="yes">Create Station</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="rb_audioscrobbler_profile_source_station_creator_button_clicked_cb"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkVBox" id="recent_tracks_area">
<property name="visible">True</property>
<property name="orientation">vertical</property>
@@ -371,7 +484,7 @@
</child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -452,7 +565,7 @@
</child>
</object>
<packing>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -533,7 +646,7 @@
</child>
</object>
<packing>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -614,7 +727,7 @@
</child>
</object>
<packing>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
<child>
@@ -695,7 +808,7 @@
</child>
</object>
<packing>
- <property name="position">5</property>
+ <property name="position">6</property>
</packing>
</child>
</object>
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
index a0baf13..d0cd059 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
@@ -90,6 +90,10 @@ struct _RBAudioscrobblerProfileSourcePrivate {
GtkWidget *recommended_artists_area;
GtkWidget *recommended_artists_table;
+ GtkWidget *station_creator_type_combo;
+ GtkWidget *station_creator_arg_label;
+ GtkWidget *station_creator_arg_entry;
+
GHashTable *button_to_popup_menu_map;
GHashTable *popup_menu_to_data_map;
@@ -144,6 +148,10 @@ static void rb_audioscrobbler_profile_source_playing_song_changed_cb (RBShellPla
RhythmDBEntry *entry,
RBAudioscrobblerProfileSource *source);
+static void rb_audioscrobbler_profile_source_station_creator_type_combo_changed_cb (GtkComboBox *combo_box,
+ RBAudioscrobblerProfileSource *source);
+void rb_audioscrobbler_profile_source_station_creator_button_clicked_cb (GtkButton *button,
+ RBAudioscrobblerProfileSource *source);
static void rb_audioscrobbler_profile_source_load_radio_stations (RBAudioscrobblerProfileSource *source);
static RBSource *rb_audioscrobbler_profile_source_add_radio_station (RBAudioscrobblerProfileSource *source,
const char *url,
@@ -483,6 +491,8 @@ rb_audioscrobbler_profile_source_init_profile_ui (RBAudioscrobblerProfileSource
RBPlugin *plugin;
char *builder_file;
GtkBuilder *builder;
+ GtkWidget *combo_container;
+ int i;
GtkWidget *viewport;
GtkWidget *scrolled_win;
@@ -507,6 +517,21 @@ rb_audioscrobbler_profile_source_init_profile_ui (RBAudioscrobblerProfileSource
source->priv->scrobbler_submit_count_label = GTK_WIDGET (gtk_builder_get_object (builder, "scrobbler_submit_count_label"));
source->priv->scrobbler_submit_time_label = GTK_WIDGET (gtk_builder_get_object (builder, "scrobbler_submit_time_label"));
+ /* station creator */
+ source->priv->station_creator_arg_label = GTK_WIDGET (gtk_builder_get_object (builder, "station_creator_arg_label"));
+ source->priv->station_creator_arg_entry = GTK_WIDGET (gtk_builder_get_object (builder, "station_creator_arg_entry"));
+ combo_container = GTK_WIDGET (gtk_builder_get_object (builder, "station_creator_combo_container"));
+ source->priv->station_creator_type_combo = gtk_combo_box_new_text ();
+ gtk_container_add (GTK_CONTAINER (combo_container), source->priv->station_creator_type_combo);
+ for (i = 0; i < RB_AUDIOSCROBBLER_RADIO_TYPE_LAST; i++) {
+ gtk_combo_box_append_text (GTK_COMBO_BOX (source->priv->station_creator_type_combo),
+ rb_audioscrobbler_radio_type_get_text (i));
+ }
+ g_signal_connect_object (source->priv->station_creator_type_combo, "changed",
+ G_CALLBACK (rb_audioscrobbler_profile_source_station_creator_type_combo_changed_cb),
+ source, 0);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (source->priv->station_creator_type_combo), 0);
+
/* lists of data */
source->priv->recent_tracks_area = GTK_WIDGET (gtk_builder_get_object (builder, "recent_tracks_area"));
source->priv->recent_tracks_table = GTK_WIDGET (gtk_builder_get_object (builder, "recent_tracks_table"));
@@ -812,6 +837,73 @@ rb_audioscrobbler_profile_source_playing_song_changed_cb (RBShellPlayer *player,
g_free (action_name);
}
+static void
+rb_audioscrobbler_profile_source_station_creator_type_combo_changed_cb (GtkComboBox *combo_box,
+ RBAudioscrobblerProfileSource *source)
+{
+ const char *text;
+
+ switch (gtk_combo_box_get_active (combo_box)) {
+ case RB_AUDIOSCROBBLER_RADIO_TYPE_SIMILAR_ARTISTS:
+ text = _("to Artist:");
+ break;
+ case RB_AUDIOSCROBBLER_RADIO_TYPE_TOP_FANS:
+ text = _("of Artist:");
+ break;
+ case RB_AUDIOSCROBBLER_RADIO_TYPE_LIBRARY:
+ text = _("of User:");
+ break;
+ case RB_AUDIOSCROBBLER_RADIO_TYPE_NEIGHBOURS:
+ text = _("of User:");
+ break;
+ case RB_AUDIOSCROBBLER_RADIO_TYPE_LOVED_TRACKS:
+ text = _("by User:");
+ break;
+ case RB_AUDIOSCROBBLER_RADIO_TYPE_RECOMMENDATION:
+ text = _("for User:");
+ break;
+ case RB_AUDIOSCROBBLER_RADIO_TYPE_GLOBAL_TAG:
+ text = _("Tag name:");
+ break;
+ default:
+ text = "";
+ break;
+ }
+
+ gtk_label_set_label (GTK_LABEL (source->priv->station_creator_arg_label), text);
+}
+
+void
+rb_audioscrobbler_profile_source_station_creator_button_clicked_cb (GtkButton *button,
+ RBAudioscrobblerProfileSource *source)
+{
+ const char *arg;
+
+ arg = gtk_entry_get_text (GTK_ENTRY (source->priv->station_creator_arg_entry));
+
+ if (arg[0] != '\0') {
+ RBAudioscrobblerRadioType type;
+ char *url;
+ char *name;
+
+ type = gtk_combo_box_get_active (GTK_COMBO_BOX (source->priv->station_creator_type_combo));
+
+ url = g_strdup_printf (rb_audioscrobbler_radio_type_get_url (type),
+ arg);
+ name = g_strdup_printf (rb_audioscrobbler_radio_type_get_default_name (type),
+ arg);
+
+ rb_audioscrobbler_profile_source_add_radio_station (source,
+ url,
+ name);
+
+ gtk_entry_set_text (GTK_ENTRY (source->priv->station_creator_arg_entry), "");
+
+ g_free (url);
+ g_free (name);
+ }
+}
+
/* delete old user's radio sources and load ones for new user */
static void
rb_audioscrobbler_profile_source_load_radio_stations (RBAudioscrobblerProfileSource *source)
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
index 2d4479b..c8f8184 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
@@ -41,18 +41,25 @@
#include "rb-debug.h"
#include "rb-util.h"
+
/* radio type stuff */
-static const char* radio_names[] = {
- N_("%s Radio"),
- N_("%s Fan Radio"),
- N_("%s's Library"),
- N_("%s's Neighbourhood"),
- N_("%s's Loved Tracks"),
- N_("%s's Recommended Radio"),
- N_("%s's Tag Radio"),
+static const char* radio_types[] = {
+ N_("Similar Artists"),
+ N_("Top Fans"),
+ N_("Library"),
+ N_("Neighbourhood"),
+ N_("Loved Tracks"),
+ N_("Recommendations"),
+ N_("Tag Radio"),
NULL
};
+const char *
+rb_audioscrobbler_radio_type_get_text (RBAudioscrobblerRadioType type)
+{
+ return radio_types[type];
+}
+
static const char* radio_urls[] = {
"lastfm://artist/%s/similarartists",
"lastfm://artist/%s/fans",
@@ -65,15 +72,26 @@ static const char* radio_urls[] = {
};
const char *
-rb_audioscrobbler_radio_type_get_default_name (RBAudioscrobblerRadioType type)
+rb_audioscrobbler_radio_type_get_url (RBAudioscrobblerRadioType type)
{
- return radio_names[type];
+ return radio_urls[type];
}
+static const char* radio_names[] = {
+ N_("%s Radio"),
+ N_("%s Fan Radio"),
+ N_("%s's Library"),
+ N_("%s's Neighbourhood"),
+ N_("%s's Loved Tracks"),
+ N_("%s's Recommended Radio"),
+ N_("%s Tag Radio"),
+ NULL
+};
+
const char *
-rb_audioscrobbler_radio_type_get_url (RBAudioscrobblerRadioType type)
+rb_audioscrobbler_radio_type_get_default_name (RBAudioscrobblerRadioType type)
{
- return radio_urls[type];
+ return radio_names[type];
}
/* entry data stuff */
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.h b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.h
index fa005cc..8c205da 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.h
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.h
@@ -49,8 +49,9 @@ typedef enum
RB_AUDIOSCROBBLER_RADIO_TYPE_LAST
} RBAudioscrobblerRadioType;
-const char *rb_audioscrobbler_radio_type_get_default_name (RBAudioscrobblerRadioType type);
+const char *rb_audioscrobbler_radio_type_get_text (RBAudioscrobblerRadioType type);
const char *rb_audioscrobbler_radio_type_get_url (RBAudioscrobblerRadioType type);
+const char *rb_audioscrobbler_radio_type_get_default_name (RBAudioscrobblerRadioType type);
#define RB_TYPE_AUDIOSCROBBLER_RADIO_SOURCE (rb_audioscrobbler_radio_source_get_type ())
#define RB_AUDIOSCROBBLER_RADIO_SOURCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), RB_TYPE_AUDIOSCROBBLER_RADIO_SOURCE, RBAudioscrobblerRadioSource))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]