[rhythmbox] audioscrobbler: allow radio station source to be renamed
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: allow radio station source to be renamed
- Date: Tue, 21 Sep 2010 10:51:26 +0000 (UTC)
commit 2d333e5c62779918d415b8e6fbda4322d1e5b6a6
Author: Jamie Nicol <jamie thenicols net>
Date: Fri Jul 16 14:13:15 2010 +0100
audioscrobbler: allow radio station source to be renamed
plugins/audioscrobbler/audioscrobbler-ui.xml | 1 +
.../rb-audioscrobbler-profile-source.c | 19 ++++++++++++++
.../rb-audioscrobbler-radio-source.c | 26 ++++++++++++++++++-
3 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/plugins/audioscrobbler/audioscrobbler-ui.xml b/plugins/audioscrobbler/audioscrobbler-ui.xml
index 89191b9..34604e5 100644
--- a/plugins/audioscrobbler/audioscrobbler-ui.xml
+++ b/plugins/audioscrobbler/audioscrobbler-ui.xml
@@ -1,5 +1,6 @@
<ui>
<popup name="AudioscrobblerRadioSourcePopup">
+ <menuitem name="RenameStation" action="AudioscrobblerRadioRenameStation"/>
<menuitem name="DeleteStation" action="AudioscrobblerRadioDeleteStation"/>
</popup>
</ui>
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
index 1fc9ca8..7e71652 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
@@ -157,6 +157,9 @@ static void rb_audioscrobbler_profile_source_save_radio_stations (RBAudioscrobbl
static RBSource *rb_audioscrobbler_profile_source_add_radio_station (RBAudioscrobblerProfileSource *source,
const char *url,
const char *name);
+static void rb_audioscrobbler_profile_source_radio_station_name_changed_cb (RBAudioscrobblerRadioSource *radio,
+ GParamSpec *spec,
+ RBAudioscrobblerProfileSource *source);
static void rb_audioscrobbler_profile_source_user_info_updated_cb (RBAudioscrobblerUser *user,
RBAudioscrobblerUserData *info,
@@ -959,6 +962,9 @@ rb_audioscrobbler_profile_source_load_radio_stations (RBAudioscrobblerProfileSou
name,
url);
source->priv->radio_sources = g_list_append (source->priv->radio_sources, radio);
+ g_signal_connect (radio, "notify::name",
+ G_CALLBACK (rb_audioscrobbler_profile_source_radio_station_name_changed_cb),
+ source);
}
}
@@ -1057,6 +1063,9 @@ rb_audioscrobbler_profile_source_add_radio_station (RBAudioscrobblerProfileSourc
name,
url);
source->priv->radio_sources = g_list_append (source->priv->radio_sources, radio);
+ g_signal_connect (radio, "notify::name",
+ G_CALLBACK (rb_audioscrobbler_profile_source_radio_station_name_changed_cb),
+ source);
rb_audioscrobbler_profile_source_save_radio_stations (source);
g_object_unref (shell);
@@ -1065,6 +1074,16 @@ rb_audioscrobbler_profile_source_add_radio_station (RBAudioscrobblerProfileSourc
return radio;
}
+/* callback from notify::name for each radio station owned by this profile source */
+static void
+rb_audioscrobbler_profile_source_radio_station_name_changed_cb (RBAudioscrobblerRadioSource *radio,
+ GParamSpec *spec,
+ RBAudioscrobblerProfileSource *source)
+{
+ /* save list of stations with new name */
+ rb_audioscrobbler_profile_source_save_radio_stations (source);
+}
+
/* removes a station from user's list of radio stations, deletes the source */
void
rb_audioscrobbler_profile_source_remove_radio_station (RBAudioscrobblerProfileSource *source,
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
index 29f9420..bc86cdd 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
@@ -39,6 +39,7 @@
#include "rb-audioscrobbler-radio-source.h"
#include "rb-lastfm-play-order.h"
#include "rb-debug.h"
+#include "rb-sourcelist.h"
#include "rb-util.h"
@@ -177,6 +178,8 @@ static void rb_audioscrobbler_radio_source_playing_song_changed_cb (RBShellPlaye
RhythmDBEntry *entry,
RBAudioscrobblerRadioSource *source);
+static void rb_audioscrobbler_radio_source_rename_station_action_cb (GtkAction *action,
+ RBAudioscrobblerRadioSource *source);
static void rb_audioscrobbler_radio_source_delete_station_action_cb (GtkAction *action,
RBAudioscrobblerRadioSource *source);
@@ -213,8 +216,11 @@ enum {
static GtkActionEntry rb_audioscrobbler_radio_source_actions [] =
{
- { "AudioscrobblerRadioDeleteStation", GTK_STOCK_DELETE, N_("Delete Station"), NULL,
- N_("Delete the selected station"),
+ { "AudioscrobblerRadioRenameStation", NULL, N_("_Rename Station"), NULL,
+ N_("Rename station"),
+ G_CALLBACK (rb_audioscrobbler_radio_source_rename_station_action_cb) },
+ { "AudioscrobblerRadioDeleteStation", GTK_STOCK_DELETE, N_("_Delete Station"), NULL,
+ N_("Delete station"),
G_CALLBACK (rb_audioscrobbler_radio_source_delete_station_action_cb) }
};
@@ -932,6 +938,22 @@ rb_audioscrobbler_radio_source_playing_song_changed_cb (RBShellPlayer *player,
}
static void
+rb_audioscrobbler_radio_source_rename_station_action_cb (GtkAction *action,
+ RBAudioscrobblerRadioSource *source)
+{
+ RBShell *shell;
+ RBSourceList *sourcelist;
+
+ g_object_get (source, "shell", &shell, NULL);
+ g_object_get (shell, "sourcelist", &sourcelist, NULL);
+
+ rb_sourcelist_edit_source_name (sourcelist, RB_SOURCE (source));
+
+ g_object_unref (shell);
+ g_object_unref (sourcelist);
+}
+
+static void
rb_audioscrobbler_radio_source_delete_station_action_cb (GtkAction *action,
RBAudioscrobblerRadioSource *source)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]