[banshee] [TrackInfo] Allow overriding IsPlaying method



commit 37f5ffcd2614983bffeb507baa936b889477cc86
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Mon May 17 14:50:23 2010 -0700

    [TrackInfo] Allow overriding IsPlaying method
    
    By defining the method on the PrimarySource, like can be done for
    ArtworkId already.

 .../Banshee.Core/Banshee.Collection/TrackInfo.cs   |    2 +-
 .../DatabaseTrackInfo.cs                           |    9 ++++++++
 .../Banshee.Sources/PrimarySource.cs               |   21 +++----------------
 3 files changed, 14 insertions(+), 18 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs b/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
index a9a1340..89f828b 100644
--- a/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
+++ b/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
@@ -138,7 +138,7 @@ namespace Banshee.Collection
             LastPlayed = DateTime.Now;
         }
 
-        public bool IsPlaying {
+        public virtual bool IsPlaying {
             get { return (IsPlayingMethod != null) ? IsPlayingMethod (this) : false; }
         }
 
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
index 2111f56..8f493d9 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
@@ -133,6 +133,15 @@ namespace Banshee.Collection.Database
             }
         }
 
+        public override bool IsPlaying {
+            get {
+                if (PrimarySource != null && PrimarySource.TrackIsPlayingHandler != null) {
+                    return PrimarySource.TrackIsPlayingHandler (this);
+                }
+                return base.IsPlaying;
+            }
+        }
+
         public static bool TrackEqual (DatabaseTrackInfo a, DatabaseTrackInfo b)
         {
             return a != null && b != null && a.TrackId == b.TrackId;
diff --git a/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs b/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
index 604d4e5..eb783d1 100644
--- a/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
+++ b/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
@@ -81,23 +81,10 @@ namespace Banshee.Sources
     {
         #region Functions that let us override some behavior of our DatabaseTrackInfos
 
-        private TrackEqualHandler track_equal_handler;
-        public TrackEqualHandler TrackEqualHandler {
-            get { return track_equal_handler; }
-            protected set { track_equal_handler = value; }
-        }
-
-        private TrackExternalObjectHandler track_external_object_handler;
-        public TrackExternalObjectHandler TrackExternalObjectHandler {
-            get { return track_external_object_handler; }
-            protected set { track_external_object_handler = value; }
-        }
-
-        private TrackArtworkIdHandler track_artwork_id_handler;
-        public TrackArtworkIdHandler TrackArtworkIdHandler {
-            get { return track_artwork_id_handler; }
-            protected set { track_artwork_id_handler = value; }
-        }
+        public TrackEqualHandler TrackEqualHandler { get; protected set; }
+        public TrackInfo.IsPlayingHandler TrackIsPlayingHandler { get; protected set; }
+        public TrackExternalObjectHandler TrackExternalObjectHandler { get; protected set; }
+        public TrackArtworkIdHandler TrackArtworkIdHandler { get; protected set; }
 
         #endregion
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]