[banshee] [Shuffler] Build with Mono.Addins 0.3.1 (bgo#610403)
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Shuffler] Build with Mono.Addins 0.3.1 (bgo#610403)
- Date: Mon, 22 Feb 2010 19:29:09 +0000 (UTC)
commit f348d35e4025ad74a5e1e1f2ff1a95b95f59fc3d
Author: Gabriel Burt <gabriel burt gmail com>
Date: Mon Feb 22 11:27:44 2010 -0800
[Shuffler] Build with Mono.Addins 0.3.1 (bgo#610403)
.../Banshee.Collection.Database/RandomBy.cs | 13 ++++++++++---
.../Banshee.Collection.Database/RandomByAlbum.cs | 2 +-
.../Banshee.Collection.Database/RandomByArtist.cs | 2 +-
.../Banshee.Collection.Database/RandomByOff.cs | 2 +-
.../Banshee.Collection.Database/RandomByRating.cs | 2 +-
.../Banshee.Collection.Database/RandomByScore.cs | 2 +-
.../Banshee.Collection.Database/RandomBySlot.cs | 2 +-
.../Banshee.Collection.Database/RandomByTrack.cs | 2 +-
.../Banshee.Collection.Database/Shuffler.cs | 14 +++++++++-----
9 files changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBy.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBy.cs
index 4d1328a..57b0025 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBy.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBy.cs
@@ -61,13 +61,20 @@ namespace Banshee.Collection.Database
protected string Condition { get; set; }
protected string OrderBy { get; set; }
- public RandomBy (string id, Shuffler shuffler)
+ public RandomBy (string id)
{
Id = id;
- Shuffler = shuffler;
insert_shuffle = new HyenaSqliteCommand ("INSERT OR REPLACE INTO CoreShuffles (ShufflerID, TrackID, LastShuffledAt) VALUES (?, ?, ?)");
}
+ public void SetShuffler (Shuffler shuffler)
+ {
+ if (Shuffler != null)
+ throw new InvalidOperationException ("RandomBy already has Shuffler");
+
+ Shuffler = shuffler;
+ }
+
private HyenaSqliteCommand shuffler_query;
protected HyenaSqliteCommand ShufflerQuery {
get {
@@ -145,4 +152,4 @@ namespace Banshee.Collection.Database
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByAlbum.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByAlbum.cs
index 2cd2077..800f40f 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByAlbum.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByAlbum.cs
@@ -45,7 +45,7 @@ namespace Banshee.Collection.Database
private HyenaSqliteCommand album_query;
private int? album_id;
- public RandomByAlbum (Shuffler shuffler) : base ("album", shuffler)
+ public RandomByAlbum () : base ("album")
{
Label = Catalog.GetString ("Shuffle by A_lbum");
Adverb = Catalog.GetString ("by album");
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByArtist.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByArtist.cs
index e2bae5e..b5d60e7 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByArtist.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByArtist.cs
@@ -44,7 +44,7 @@ namespace Banshee.Collection.Database
private HyenaSqliteCommand query;
private int? id;
- public RandomByArtist (Shuffler shuffler) : base ("artist", shuffler)
+ public RandomByArtist () : base ("artist")
{
Label = Catalog.GetString ("Shuffle by A_rtist");
Adverb = Catalog.GetString ("by artist");
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByOff.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByOff.cs
index fffff9d..d0511c1 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByOff.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByOff.cs
@@ -31,7 +31,7 @@ namespace Banshee.Collection.Database
{
public class RandomByOff : RandomBy
{
- public RandomByOff (Shuffler shuffler) : base ("off", shuffler)
+ public RandomByOff () : base ("off")
{
Label = Catalog.GetString ("Shuffle _Off");
Adverb = Catalog.GetString ("manually");
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByRating.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByRating.cs
index 64f51ce..2b95e3c 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByRating.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByRating.cs
@@ -41,7 +41,7 @@ namespace Banshee.Collection.Database
{
private static string track_condition = String.Format ("AND (CoreTracks.Rating = ? OR (? = 3 AND CoreTracks.Rating = 0)) {0} ORDER BY RANDOM()", RANDOM_CONDITION);
- public RandomByRating (Shuffler shuffler) : base ("rating", shuffler)
+ public RandomByRating () : base ("rating")
{
Label = Catalog.GetString ("Shuffle by _Rating");
Adverb = Catalog.GetString ("by rating");
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByScore.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByScore.cs
index 051979f..34204df 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByScore.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByScore.cs
@@ -37,7 +37,7 @@ namespace Banshee.Collection.Database
{
private static string track_condition = String.Format ("AND (CoreTracks.Score BETWEEN ? AND ? OR (? = 50 AND CoreTracks.Score = 0)) {0} ORDER BY RANDOM()", RANDOM_CONDITION);
- public RandomByScore (Shuffler shuffler) : base ("score", shuffler)
+ public RandomByScore () : base ("score")
{
Label = Catalog.GetString ("Shuffle by S_core");
Adverb = Catalog.GetString ("by score");
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBySlot.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBySlot.cs
index 4827151..2adf6c2 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBySlot.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBySlot.cs
@@ -49,7 +49,7 @@ namespace Banshee.Collection.Database
private HyenaSqliteCommand query;
protected int slot;
- public RandomBySlot (string id, Shuffler shuffler) : base (id, shuffler)
+ public RandomBySlot (string id) : base (id)
{
}
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByTrack.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByTrack.cs
index f7b6037..9edc2fb 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByTrack.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByTrack.cs
@@ -42,7 +42,7 @@ namespace Banshee.Collection.Database
{
private static string track_condition = String.Format ("{0} ORDER BY RANDOM()", RANDOM_CONDITION);
- public RandomByTrack (Shuffler shuffler) : base ("song", shuffler)
+ public RandomByTrack () : base ("song")
{
Label = Catalog.GetString ("Shuffle by _Song");
Adverb = Catalog.GetString ("by song");
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
index 0fb4708..754d8c5 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
@@ -48,6 +48,7 @@ namespace Banshee.Collection.Database
private DateTime random_began_at = DateTime.MinValue;
private DateTime last_random = DateTime.MinValue;
private List<RandomBy> random_modes;
+ private Dictionary<TypeExtensionNode, RandomBy> node_map = new Dictionary<TypeExtensionNode, RandomBy> ();
private DatabaseTrackListModel model;
public string Id { get; private set; }
@@ -78,15 +79,17 @@ namespace Banshee.Collection.Database
if (args.Change == ExtensionChange.Add) {
lock (random_modes) {
try {
- random_by = (RandomBy) Activator.CreateInstance (tnode.Type, this);
+ random_by = (RandomBy) tnode.CreateInstance ();
+ random_by.SetShuffler (this);
random_modes.Add (random_by);
+ node_map[tnode] = random_by;
} catch (Exception e) {
Log.Exception (String.Format ("Failed to load RandomBy extension: {0}", args.Path), e);
}
}
if (random_by != null) {
- if (!tnode.Type.AssemblyQualifiedName.Contains ("Banshee.Service")) {
+ if (!random_by.GetType ().AssemblyQualifiedName.Contains ("Banshee.Service")) {
Log.DebugFormat ("Loaded RandomBy: {0}", random_by.Id);
}
var handler = RandomModeAdded;
@@ -96,8 +99,9 @@ namespace Banshee.Collection.Database
}
} else {
lock (random_modes) {
- random_by = random_modes.FirstOrDefault (r => r.GetType () == tnode.Type);
- if (random_by != null) {
+ if (node_map.ContainsKey (tnode)) {
+ random_by = node_map[tnode];
+ node_map.Remove (tnode);
random_modes.Remove (random_by);
}
}
@@ -186,4 +190,4 @@ namespace Banshee.Collection.Database
}
}
}
-}
\ No newline at end of file
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]