[banshee] Show cover art in album browser as soon as downloaded
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Show cover art in album browser as soon as downloaded
- Date: Mon, 19 Jul 2010 21:18:41 +0000 (UTC)
commit ac5fd5ac272f19c60ddf3ccf0688358b6d94e200
Author: Gabriel Burt <gabriel burt gmail com>
Date: Mon Jul 19 12:41:30 2010 -0700
Show cover art in album browser as soon as downloaded
Previously you had to trigger a redraw of the grid some other way before
you'd see it (bgo#624667)
.../Banshee.Metadata/BaseMetadataProvider.cs | 9 +++++++
.../Banshee.Collection.Gui/AlbumListView.cs | 12 +++++++++
.../Banshee.Collection.Gui/ArtworkManager.cs | 25 ++++++++++++++++++++
.../Banshee.Collection.Gui/CoverArtEditor.cs | 8 ++++++
.../Banshee.Collection.Gui/DataViewChildAlbum.cs | 8 ++++++
5 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Metadata/BaseMetadataProvider.cs b/src/Core/Banshee.Services/Banshee.Metadata/BaseMetadataProvider.cs
index 747ba72..d910d29 100644
--- a/src/Core/Banshee.Services/Banshee.Metadata/BaseMetadataProvider.cs
+++ b/src/Core/Banshee.Services/Banshee.Metadata/BaseMetadataProvider.cs
@@ -27,6 +27,7 @@
//
using System;
+using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -39,6 +40,7 @@ namespace Banshee.Metadata
public abstract class BaseMetadataProvider : IMetadataProvider
{
public event MetadataLookupResultHandler HaveResult;
+ public event Action<IBasicTrackInfo> ArtworkUpdated;
protected BaseMetadataProvider()
{
@@ -66,6 +68,13 @@ namespace Banshee.Metadata
return;
}
+ if (tags.Any (t => t.Name == CommonTags.AlbumCoverId)) {
+ var artwork_handler = ArtworkUpdated;
+ if (artwork_handler != null) {
+ artwork_handler (track);
+ }
+ }
+
MetadataLookupResultHandler handler = HaveResult;
if(handler != null) {
handler(this, new MetadataLookupResultArgs(track,
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs
index 3ad6e84..c826110 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs
@@ -78,6 +78,13 @@ namespace Banshee.Collection.Gui
ToggleAlbumGrid);
ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent, PlayerEvent.TrackInfoUpdated);
+ Banshee.Metadata.MetadataService.Instance.ArtworkUpdated += OnArtworkUpdated;
+ }
+
+ public override void Dispose ()
+ {
+ ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
+ Banshee.Metadata.MetadataService.Instance.ArtworkUpdated -= OnArtworkUpdated;
}
private void ToggleAlbumGrid ()
@@ -172,5 +179,10 @@ namespace Banshee.Collection.Gui
// b) xfade the artwork if it is, that'd be slick
QueueDraw ();
}
+
+ private void OnArtworkUpdated (IBasicTrackInfo track)
+ {
+ QueueDraw ();
+ }
}
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
index 094dc8f..2414ca1 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
@@ -79,6 +79,18 @@ namespace Banshee.Collection.Gui
} catch (Exception e) {
Log.Exception ("Could not migrate album artwork cache directory", e);
}
+
+ Banshee.Metadata.MetadataService.Instance.ArtworkUpdated += OnArtworkUpdated;
+ }
+
+ public void Dispose ()
+ {
+ Banshee.Metadata.MetadataService.Instance.ArtworkUpdated -= OnArtworkUpdated;
+ }
+
+ private void OnArtworkUpdated (IBasicTrackInfo track)
+ {
+ ClearCacheFor (track.ArtworkId, true);
}
public Cairo.ImageSurface LookupSurface (string id)
@@ -212,11 +224,24 @@ namespace Banshee.Collection.Gui
public void ClearCacheFor (string id)
{
+ ClearCacheFor (id, false);
+ }
+
+ public void ClearCacheFor (string id, bool inMemoryCacheOnly)
+ {
+ if (String.IsNullOrEmpty (id)) {
+ return;
+ }
+
// Clear from the in-memory cache
foreach (int size in scale_caches.Keys) {
scale_caches[size].Remove (id);
}
+ if (inMemoryCacheOnly) {
+ return;
+ }
+
// And delete from disk
foreach (int size in CachedSizes ()) {
var uri = new SafeUri (CoverArtSpec.GetPathForSize (id, size));
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/CoverArtEditor.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/CoverArtEditor.cs
index 95655eb..538e66b 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/CoverArtEditor.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/CoverArtEditor.cs
@@ -197,6 +197,14 @@ namespace Banshee.Collection.Gui
if (artwork_id != null) {
ServiceManager.Get<ArtworkManager> ().ClearCacheFor (track.ArtworkId);
}
+
+ // Deleting it from this table means the cover art downloader extension will
+ // attempt to redownload it on its next run.
+ var db = ServiceManager.DbConnection;
+ var db_track = track as DatabaseTrackInfo;
+ if (db_track != null && db.TableExists ("CoverArtDownloads")) {
+ db.Execute ("DELETE FROM CoverArtDownloads WHERE AlbumID = ?", db_track.AlbumId);
+ }
}
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DataViewChildAlbum.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DataViewChildAlbum.cs
index cff7cc5..ada4cca 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DataViewChildAlbum.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DataViewChildAlbum.cs
@@ -143,6 +143,14 @@ namespace Banshee.Collection.Gui
return;
}
+ // Need to call this again here to make sure we have the latest artwork
+ var album = BoundObject as AlbumInfo;
+ if (album != null) {
+ image_surface = artwork_manager != null
+ ? artwork_manager.LookupScaleSurface (album.ArtworkId, (int)ImageSize, true)
+ : null;
+ }
+
context.Context.Translate (inner_allocation.X, inner_allocation.Y);
RenderImageSurface (context, image_allocation, image_surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]