[banshee] SmartPlaylists: Let child sources decide if the parent can add them
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] SmartPlaylists: Let child sources decide if the parent can add them
- Date: Sun, 4 Sep 2011 09:42:54 +0000 (UTC)
commit 91a596b691473cbf752403898e39a360bcdbd522
Author: AndrÃs G. Aragoneses <knocte gmail com>
Date: Sat Aug 27 13:40:05 2011 +0100
SmartPlaylists: Let child sources decide if the parent can add them
SmartPlaylists, when loaded from the database, are added to their
parent source after they have been initialized, refreshed and
reloaded. The consequence of this is that it was completely up
to their parent if it was OK to add them as children of not.
However SmartPlaylistSources can have an setting enabled called
HiddenWhenEmpty, which is what the default/predefined smart
playlists have activated to prevent polluting the UI (especially
for new users that haven't imported anything yet), so this was
not taken in account and causing BGO#657479.
The alternative fix to this would be to just call Reload() on the
playlist after it has been added to the parent, but that could cause
extra overhead and this is a more elegant solution: returning bool for
SetParentSource so children can veto their addition to the parent.
We also get the side-benefit of having the "virtual" keyword on
this method be actually useful, because before this commit,
SmartPlaylistSource was the only derived class that was overriding
it, but calling just the base method, so indeed not overriding it
but having redundant and unnecessary code.
Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>
.../Banshee.SmartPlaylist/SmartPlaylistSource.cs | 6 +++++-
.../Banshee.Services/Banshee.Sources/Source.cs | 10 ++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs b/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
index 686974a..4200d46 100644
--- a/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
+++ b/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
@@ -512,9 +512,13 @@ namespace Banshee.SmartPlaylist
}
}
- public override void SetParentSource (Source parent)
+ public override bool SetParentSource (Source parent)
{
base.SetParentSource (parent);
+ if (IsHiddenWhenEmpty && Count == 0) {
+ return false;
+ }
+ return true;
}
#endregion
diff --git a/src/Core/Banshee.Services/Banshee.Sources/Source.cs b/src/Core/Banshee.Services/Banshee.Sources/Source.cs
index 867748f..20645b0 100644
--- a/src/Core/Banshee.Services/Banshee.Sources/Source.cs
+++ b/src/Core/Banshee.Services/Banshee.Sources/Source.cs
@@ -190,9 +190,10 @@ namespace Banshee.Sources
get { return SourceMergeType.None; }
}
- public virtual void SetParentSource (Source parent)
+ public virtual bool SetParentSource (Source parent)
{
this.parent = parent;
+ return true;
}
public virtual bool ContainsChildSource (Source child)
@@ -206,9 +207,10 @@ namespace Banshee.Sources
{
lock (Children) {
if (!child_sources.Contains (child)) {
- child.SetParentSource (this);
- child_sources.Add (child);
- OnChildSourceAdded (child);
+ if (child.SetParentSource (this)) {
+ child_sources.Add (child);
+ OnChildSourceAdded (child);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]