[banshee: 6/27] [lastfm] Try to move RadioSource sorting to LastfmStreaming
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee: 6/27] [lastfm] Try to move RadioSource sorting to LastfmStreaming
- Date: Sat, 22 May 2010 18:52:04 +0000 (UTC)
commit d60f08ecff37ef7e5856489a51f9240a961ae287
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Sun Jan 24 12:47:45 2010 +0100
[lastfm] Try to move RadioSource sorting to LastfmStreaming
.../Banshee.Lastfm.Radio/LastfmSource.cs | 28 +++--------------
.../LastfmStreamingService.cs | 31 ++++++++++++++++++-
.../Banshee.LastfmStreaming.csproj | 3 ++
3 files changed, 37 insertions(+), 25 deletions(-)
---
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
index ab7db5a..be9ea5a 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
@@ -29,13 +29,11 @@
using System;
using System.IO;
using System.Collections;
-using System.Collections.Generic;
using Mono.Unix;
using Lastfm;
using Lastfm.Gui;
using Lastfm.Data;
-using Hyena.Data;
using Banshee.Base;
using Banshee.Collection;
@@ -76,7 +74,7 @@ namespace Banshee.Lastfm.Radio
account = LastfmCore.Account;
// We don't automatically connect to Last.fm, but load the last Last.fm
- // username we used so we can load the user's stations.
+ // account information
if (account.UserName != null) {
account.UserName = LastUserSchema.Get ();
account.SessionKey = LastSessionKeySchema.Get ();
@@ -98,7 +96,6 @@ namespace Banshee.Lastfm.Radio
Properties.SetString ("GtkActionPath", "/LastfmSourcePopup");
Properties.SetString ("Icon.Name", "lastfm-audioscrobbler");
- Properties.SetString ("SortChildrenActionLabel", Catalog.GetString ("Sort Stations by"));
Properties.Set<LastfmColumnController> ("TrackView.ColumnController", new LastfmColumnController ());
// Initialize DataCore's UserAgent and CachePath
@@ -128,26 +125,11 @@ namespace Banshee.Lastfm.Radio
account = null;
}
- // Order by the playCount of a station, then by inverted name
- public class PlayCountComparer : IComparer<Source>
- {
- public int Compare (Source sa, Source sb)
- {
- /*StationSource a = sa as StationSource;
- StationSource b = sb as StationSource;
- return a.PlayCount.CompareTo (b.PlayCount);*/
- return 1;
- }
+ private SourceSortType[] sort_types = new SourceSortType[] {};
+ public void SetChildSortTypes (SourceSortType[] child_sort_types) {
+ sort_types = child_sort_types;
}
-
- private static SourceSortType[] sort_types = new SourceSortType[] {
- SortNameAscending,
- new SourceSortType (
- "LastfmTotalPlayCount",
- Catalog.GetString ("Total Play Count"),
- SortType.Descending, new PlayCountComparer ())
- };
-
+
public override SourceSortType[] ChildSortTypes {
get { return sort_types; }
}
diff --git a/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming.Radio/LastfmStreamingService.cs b/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming.Radio/LastfmStreamingService.cs
index d04ce7e..d5c9939 100644
--- a/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming.Radio/LastfmStreamingService.cs
+++ b/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming.Radio/LastfmStreamingService.cs
@@ -1,5 +1,10 @@
using System;
+using System.Collections.Generic;
+
+using Mono.Unix;
+
+using Hyena.Data;
using Banshee.Lastfm.Radio;
using Banshee.ServiceStack;
@@ -47,6 +52,7 @@ namespace Banshee.LastfmStreaming.Radio
}
lastfm_source.ClearChildSources ();
+ lastfm_source.SetChildSortTypes (station_sort_types);
//lastfm_source.PauseSorting ();
foreach (StationSource child in StationSource.LoadAll (lastfm_source, lastfm_source.Account.UserName)) {
lastfm_source.AddChildSource (child);
@@ -54,8 +60,9 @@ namespace Banshee.LastfmStreaming.Radio
//lastfm_source.ResumeSorting ();
lastfm_source.SortChildSources ();
lastfm_source.Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
- lastfm_source.Properties.Set<bool> ("ActiveSourceUIResourcePropagate", true);
-
+ lastfm_source.Properties.Set<bool> ("ActiveSourceUIResourcePropagate", false);
+ lastfm_source.Properties.SetString ("SortChildrenActionLabel", Catalog.GetString ("Sort Stations by"));
+
return true;
}
@@ -76,6 +83,26 @@ namespace Banshee.LastfmStreaming.Radio
}
}
+ // Order by the playCount of a station, then by inverted name
+ public class PlayCountComparer : IComparer<Source>
+ {
+ public int Compare (Source sa, Source sb)
+ {
+ StationSource a = sa as StationSource;
+ StationSource b = sb as StationSource;
+ return a.PlayCount.CompareTo (b.PlayCount);
+ }
+ }
+
+ private static SourceSortType[] station_sort_types = new SourceSortType[] {
+ Source.SortNameAscending,
+ new SourceSortType (
+ "LastfmTotalPlayCount",
+ Catalog.GetString ("Total Play Count"),
+ SortType.Descending, new PlayCountComparer ())
+ };
+
+
string IService.ServiceName {
get { return "LastfmStreamingService"; }
}
diff --git a/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming.csproj b/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming.csproj
index f187fe4..eb616e0 100644
--- a/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming.csproj
+++ b/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming.csproj
@@ -90,4 +90,7 @@
<Name>Banshee.Core</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Reference Include="Mono.Posix" />
+ </ItemGroup>
</Project>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]