37
37
namespace Banshee.ClutterFlow
40
40
/// A ClutterFlowAlbum is a subclass of the ClutterFlowActor class, containing
41
41
/// banshee related Album art fetching code.
43
public class ClutterFlowAlbum : ClutterFlowActor, IEquatable<ClutterFlowAlbum>
46
protected static ArtworkLookup lookup;
47
public static ArtworkLookup Lookup {
48
get { return lookup; }
49
set { lookup = value; }
52
protected AlbumInfo album;
53
public virtual AlbumInfo Album {
58
Lookup.Enqueue (this);
63
public virtual string PbId {
64
get { return Album!=null ? Album.ArtworkId : "NOT FOUND"; }
67
public override string CacheKey {
68
get { return CreateCacheKey(album); }
70
throw new System.NotImplementedException ("CacheKey cannot be set directly in a ClutterFlowAlbum," +
71
"derived from the Album property."); //TODO should use reflection here
74
public static string CreateCacheKey(AlbumInfo album) {
75
return album!=null ? album.ArtistName + "\n" + album.Title : "";
78
public override string Label {
79
get { return album!=null ? album.ArtistName + "\n" + album.Title : ""; }
81
throw new System.NotImplementedException ("Label cannot be set directly in a ClutterFlowAlbum, derived from the Album property.");
43
public class ClutterFlowAlbum : ClutterFlowActor, IEquatable<ClutterFlowAlbum>
46
private static ArtworkLookup artwork_lookup;
48
private AlbumInfo album;
49
public AlbumInfo Album {
54
artwork_lookup.Enqueue (this);
59
public virtual string PbId {
60
get { return Album != null ? Album.ArtworkId : "NOT FOUND"; }
63
public override string CacheKey {
64
get { return CreateCacheKey (album); }
66
public static string CreateCacheKey (AlbumInfo album)
68
return album != null ? album.ArtistName + "\n" + album.Title : "";
71
public override string Label {
72
get { return album != null ? album.ArtistName + "\n" + album.Title : ""; }
85
75
object sync = new object();
86
76
bool enqueued = false;
88
78
get { lock (sync) { return enqueued; } }
89
79
internal set { lock (sync) { enqueued = value; } }
93
#region Initialization
94
public ClutterFlowAlbum (AlbumInfo album, CoverManager coverManager) : base (coverManager, null)
99
protected override bool SetupStatics ()
101
if (lookup==null) lookup = new ArtworkLookup (CoverManager);
102
return base.SetupStatics ();
104
protected override void DisposeStatics ()
106
if (lookup!=null) lookup.Dispose ();
108
base.DisposeStatics ();
112
#region Texture Handling
113
protected override Cairo.ImageSurface GetDefaultSurface ()
115
Cairo.ImageSurface surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, CoverManager.TextureSize, CoverManager.TextureSize);
116
Cairo.Context context = new Cairo.Context(surface);
117
Gdk.CairoHelper.SetSourcePixbuf(context, IconThemeUtils.LoadIcon (CoverManager.TextureSize, "media-optical", "browser-album-cover"), 0, 0);
119
//((IDisposable) context.Target).Dispose();
120
((IDisposable) context).Dispose();
124
protected override void HandleTextureSizeChanged (object sender, System.EventArgs e)
126
Lookup.Enqueue(this);
130
public virtual bool Equals (ClutterFlowAlbum other)
132
return other.CacheKey==this.CacheKey;
83
#region Initialization
84
public ClutterFlowAlbum (AlbumInfo album, CoverManager coverManager) : base (coverManager)
87
if (artwork_lookup == null) {
88
artwork_lookup = new ArtworkLookup (CoverManager);
90
artwork_lookup.Enqueue(this);
93
public override void Dispose ()
95
if (artwork_lookup != null) {
96
artwork_lookup.Dispose ();
98
artwork_lookup = null;
103
public virtual bool Equals (ClutterFlowAlbum other)
105
return other.CacheKey == this.CacheKey;