[banshee/gio-hardware] [Library] Customize the status message per library



commit d54bfc3adcdf390a35179d09a66ed18bc721f301
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Thu Aug 12 19:30:36 2010 -0700

    [Library] Customize the status message per library
    
    So instead of "N items", say "N songs", or "N videos".  Much nicer.

 .../DatabaseTrackListModel.cs                      |   10 ++++++++--
 .../Banshee.Library/MusicLibrarySource.cs          |    5 +++++
 .../Banshee.Library/VideoLibrarySource.cs          |    5 +++++
 .../Banshee.Sources/DatabaseSource.cs              |    4 ++--
 .../Banshee.Services/Banshee.Sources/Source.cs     |    8 +++++++-
 .../Banshee.Audiobook/AudiobookLibrarySource.cs    |   13 +++++++++++++
 6 files changed, 40 insertions(+), 5 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
index 617c373..cc9284e 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
@@ -58,7 +58,7 @@ namespace Banshee.Collection.Database
         private long count;
 
         private long filtered_count;
-        private TimeSpan filtered_duration;
+        private TimeSpan filtered_duration, duration;
         private long filtered_filesize, filesize;
 
         private ISortableColumn sort_column;
@@ -177,6 +177,7 @@ namespace Banshee.Collection.Database
             cache.Clear ();
             count = 0;
             filesize = 0;
+            duration = TimeSpan.Zero;
             filtered_count = 0;
             OnCleared ();
         }
@@ -230,12 +231,13 @@ namespace Banshee.Collection.Database
         public virtual void UpdateUnfilteredAggregates ()
         {
             HyenaSqliteCommand count_command = new HyenaSqliteCommand (String.Format (
-                "SELECT COUNT(*), SUM(CoreTracks.FileSize) {0}", UnfilteredQuery
+                "SELECT COUNT(*), SUM(CoreTracks.FileSize), SUM(CoreTracks.Duration) {0}", UnfilteredQuery
             ));
 
             using (HyenaDataReader reader = new HyenaDataReader (connection.Query (count_command))) {
                 count = reader.Get<long> (0);
                 filesize = reader.Get<long> (1);
+                duration = reader.Get<TimeSpan> (2);
             }
         }
 
@@ -410,6 +412,10 @@ namespace Banshee.Collection.Database
             get { return filesize; }
         }
 
+        public TimeSpan UnfilteredDuration {
+            get { return duration; }
+        }
+
         public int UnfilteredCount {
             get { return (int) count; }
             set { count = value; }
diff --git a/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs b/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs
index 5ce5bca..221ddfe 100644
--- a/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs
+++ b/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs
@@ -87,6 +87,11 @@ namespace Banshee.Library
             ));
         }
 
+        protected override string GetPluralItemCountString (int count)
+        {
+            return Catalog.GetPluralString ("{0} song", "{0} songs", count);
+        }
+
         public static string GetDefaultBaseDirectory ()
         {
             return Hyena.XdgBaseDirectorySpec.GetXdgDirectoryUnderHome ("XDG_MUSIC_DIR", "Music");
diff --git a/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs b/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs
index daf00f8..4f024d8 100644
--- a/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs
+++ b/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs
@@ -65,6 +65,11 @@ namespace Banshee.Library
             ", Catalog.GetString ("Produced By")));
         }
 
+        protected override string GetPluralItemCountString (int count)
+        {
+            return Catalog.GetPluralString ("{0} video", "{0} videos", count);
+        }
+
         public override bool ShowBrowser {
             get { return false; }
         }
diff --git a/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs b/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
index 08ea6aa..1879453 100644
--- a/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
+++ b/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
@@ -230,11 +230,11 @@ namespace Banshee.Sources
             get { return DatabaseTrackModel.Count; }
         }
 
-        public TimeSpan Duration {
+        public virtual TimeSpan Duration {
             get { return DatabaseTrackModel.Duration; }
         }
 
-        public long FileSize {
+        public virtual long FileSize {
             get { return DatabaseTrackModel.FileSize; }
         }
 
diff --git a/src/Core/Banshee.Services/Banshee.Sources/Source.cs b/src/Core/Banshee.Services/Banshee.Sources/Source.cs
index 8be332f..d1cfb0c 100644
--- a/src/Core/Banshee.Services/Banshee.Sources/Source.cs
+++ b/src/Core/Banshee.Services/Banshee.Sources/Source.cs
@@ -765,7 +765,8 @@ namespace Banshee.Sources
                 return String.Empty;
             }
 
-            builder.AppendFormat (Catalog.GetPluralString ("{0:N0} item", "{0:N0} items", count), count);
+            var count_str = String.Format ("{0:N0}", count);
+            builder.AppendFormat (GetPluralItemCountString (count), count_str);
 
             if (this is IDurationAggregator && StatusFormatsCount > 0) {
                 var duration = ((IDurationAggregator)this).Duration;
@@ -786,6 +787,11 @@ namespace Banshee.Sources
             return builder.ToString ();
         }
 
+        protected virtual string GetPluralItemCountString (int count)
+        {
+            return Catalog.GetPluralString ("{0} item", "{0} items", count);
+        }
+
 #endregion
 
         public override string ToString ()
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
index 1929aac..889d298 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
@@ -139,6 +139,11 @@ namespace Banshee.Audiobook
                 true);
         }
 
+        protected override string GetPluralItemCountString (int count)
+        {
+            return Catalog.GetPluralString ("{0} book", "{0} books", count);
+        }
+
         private void OnPlaybackSourceChanged (object o, EventArgs args)
         {
             if (ServiceManager.PlaybackController.Source == this) {
@@ -372,6 +377,14 @@ namespace Banshee.Audiobook
             get { return books_model.Count; }
         }
 
+        public override TimeSpan Duration {
+            get { return DatabaseTrackModel.UnfilteredDuration; }
+        }
+
+        public override long FileSize {
+            get { return DatabaseTrackModel.UnfilteredFileSize; }
+        }
+
         public override bool ShowBrowser {
             get { return false; }
         }



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