[banshee] [Metadata] Fix prev commit add40560eca0c57c0dd4be16b76fa5ae84e23d89
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Metadata] Fix prev commit add40560eca0c57c0dd4be16b76fa5ae84e23d89
- Date: Sat, 29 May 2010 18:35:54 +0000 (UTC)
commit 6f0ae227bdfbe9ad143fa171ab95c8896eb681fb
Author: Andrés G. Aragoneses <knocte gmail com>
Date: Sat May 29 20:32:51 2010 +0200
[Metadata] Fix prev commit add40560eca0c57c0dd4be16b76fa5ae84e23d89
Ooops, in last commit I forgot to commit one file, and introduced
weird characters instead of spaces in DatabaseTrackInfo.cs.
.../DatabaseTrackInfo.cs | 12 +++---
.../Banshee.Metadata/SaveTrackMetadataService.cs | 44 ++++++++++++++++++-
2 files changed, 47 insertions(+), 9 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
index 1a7b40b..35702ed 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
@@ -189,14 +189,14 @@ namespace Banshee.Collection.Database
}
// If PlayCountField is not transient we still want to update the file only if it's from the music library
- Â Â Â Â Â Â var transient = transient_fields;
- Â Â Â Â Â Â if (!transient.Contains (BansheeQuery.PlayCountField) &&
- Â Â Â Â Â Â Â Â !ServiceManager.SourceManager.MusicLibrary.Equals (PrimarySource)) {
- Â Â Â Â Â Â Â Â transient = new HashSet<QueryField> (transient_fields);
- Â Â Â Â Â Â Â Â transient.Add (BansheeQuery.PlayCountField);
+ var transient = transient_fields;
+ if (!transient.Contains (BansheeQuery.PlayCountField) &&
+ !ServiceManager.SourceManager.MusicLibrary.Equals (PrimarySource)) {
+ transient = new HashSet<QueryField> (transient_fields);
+ transient.Add (BansheeQuery.PlayCountField);
      }
- Â Â Â Â Â Â if (fields_changed.Length == 0 || !transient.IsSupersetOf (fields_changed)) {
+ if (fields_changed.Length == 0 || !transient.IsSupersetOf (fields_changed)) {
DateUpdated = DateTime.Now;
}
diff --git a/src/Core/Banshee.Services/Banshee.Metadata/SaveTrackMetadataService.cs b/src/Core/Banshee.Services/Banshee.Metadata/SaveTrackMetadataService.cs
index c3aea2d..605d996 100644
--- a/src/Core/Banshee.Services/Banshee.Metadata/SaveTrackMetadataService.cs
+++ b/src/Core/Banshee.Services/Banshee.Metadata/SaveTrackMetadataService.cs
@@ -27,6 +27,7 @@
//
using System;
+using System.Collections.Generic;
using Mono.Unix;
using Hyena.Jobs;
@@ -63,6 +64,10 @@ namespace Banshee.Metadata
private SaveTrackMetadataJob job;
private object sync = new object ();
private bool inited = false;
+ private List<PrimarySource> sources = new List<PrimarySource> ();
+ public IEnumerable<PrimarySource> Sources {
+ get { return sources.AsReadOnly (); }
+ }
public SaveTrackMetadataService ()
{
@@ -70,17 +75,50 @@ namespace Banshee.Metadata
WriteMetadataEnabled.ValueChanged += OnEnabledChanged;
WriteRatingsAndPlayCountsEnabled.ValueChanged += OnEnabledChanged;
RenameEnabled.ValueChanged += OnEnabledChanged;
- ServiceManager.SourceManager.MusicLibrary.TracksChanged += OnTracksChanged;
+ foreach (var source in ServiceManager.SourceManager.Sources) {
+ AddPrimarySource (source);
+ }
+ ServiceManager.SourceManager.SourceAdded += (args) => {
+ AddPrimarySource (args.Source);
+ };
+ ServiceManager.SourceManager.SourceRemoved += (args) => {
+ RemovePrimarySource(args.Source);
+ };
Save ();
inited = true;
return false;
});
}
+ private void AddPrimarySource (Source s)
+ {
+ PrimarySource p = s as PrimarySource;
+ if (p != null && p.HasEditableTrackProperties) {
+ sources.Add (p);
+ p.TracksChanged += OnTracksChanged;
+ }
+ }
+
+ private void RemovePrimarySource (Source s)
+ {
+ PrimarySource p = s as PrimarySource;
+ if (p != null && sources.Remove (p)) {
+ p.TracksChanged -= OnTracksChanged;
+ }
+ }
+
+ private void RemovePrimarySources ()
+ {
+ foreach (var source in sources) {
+ source.TracksChanged -= OnTracksChanged;
+ }
+ sources.Clear ();
+ }
+
public void Dispose ()
{
if (inited) {
- ServiceManager.SourceManager.MusicLibrary.TracksChanged -= OnTracksChanged;
+ RemovePrimarySources ();
if (job != null) {
ServiceManager.JobScheduler.Cancel (job);
@@ -127,7 +165,7 @@ namespace Banshee.Metadata
}
string IService.ServiceName {
- get { return "SaveMetadataService"; }
+ get { return "SaveTrackMetadataService"; }
}
// Reserve strings in preparation for the forthcoming string freeze.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]