[banshee] [Audiobook] Make the cover art widget a Gtk.Image



commit 66056ad7a9d523dc5f117e901df8861e400b9fe5
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Sat May 15 18:25:41 2010 -0700

    [Audiobook] Make the cover art widget a Gtk.Image

 .../Banshee.Audiobook/BookCover.cs                 |   29 +++++++++-----------
 .../Banshee.Audiobook/BookView.cs                  |   23 ++++++++++++---
 2 files changed, 31 insertions(+), 21 deletions(-)
---
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookCover.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookCover.cs
index abf8469..1ba77d5 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookCover.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookCover.cs
@@ -28,33 +28,30 @@ using System;
 
 using Gtk;
 
+using Hyena.Gui.Theming;
+
 using Banshee.Gui.Widgets;
 using Banshee.Collection;
-using Hyena.Gui.Theming;
+using Banshee.ServiceStack;
+using Banshee.Collection.Gui;
+using Banshee.Gui;
 
 namespace Banshee.Audiobook
 {
-    public class BookCover : CoverArtDisplay
+    public class BookCover : Gtk.Image
     {
-        Widget parent;
-
         public BookCover (Widget parent)
         {
-            this.parent = parent;
-            MissingVideoIconName = MissingAudioIconName = "audiobook";
-        }
-
-        protected override void OnThemeChanged ()
-        {
-            base.OnThemeChanged ();
-
-            var theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (parent);
-            BackgroundColor = theme.Colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal);
         }
 
         public void LoadImage (TrackMediaAttributes attr, string artwork_id)
         {
-             LoadImage (attr, artwork_id, true);
+            if (Pixbuf != null) {
+                Pixbuf.Dispose ();
+            }
+
+            Pixbuf = ServiceManager.Get<ArtworkManager> ().LookupScalePixbuf (artwork_id, HeightRequest)
+                ?? IconThemeUtils.LoadIcon ("audiobook", HeightRequest);
         }
     }
-}
+}
\ No newline at end of file
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs
index c2d5734..aa2300a 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs
@@ -77,9 +77,12 @@ namespace Banshee.Audiobook
             ShowAll ();
         }
 
+        private DatabaseAlbumInfo Book { get; set; }
+
         public void SetBook (DatabaseAlbumInfo book)
         {
             ThreadAssist.AssertInMainThread ();
+            Book = book;
 
             title_label.Markup = String.Format (
                 "<span size=\"x-large\" weight=\"bold\">{0}</span>\n" +
@@ -88,10 +91,7 @@ namespace Banshee.Audiobook
                 GLib.Markup.EscapeText (book.ArtistName)
             );
 
-            cover.LoadImage (
-                TrackMediaAttributes.AudioStream | TrackMediaAttributes.AudioBook,
-                CoverArtSpec.CreateArtistAlbumId (book.ArtistName, book.Title)
-            );
+            UpdateCover ();
 
             var bookmarks = Bookmark.Provider.FetchAllMatching (
                 "TrackID IN (SELECT TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND AlbumID = ?)",
@@ -108,6 +108,14 @@ namespace Banshee.Audiobook
             ));
         }
 
+        private void UpdateCover ()
+        {
+            cover.LoadImage (
+                TrackMediaAttributes.AudioStream | TrackMediaAttributes.AudioBook,
+                CoverArtSpec.CreateArtistAlbumId (Book.ArtistName, Book.Title)
+            );
+        }
+
         public override void Dispose ()
         {
             if (cover != null) {
@@ -156,7 +164,12 @@ namespace Banshee.Audiobook
                 WidthRequest = 300,
                 HeightRequest = 300
             };
-            var editable_cover = TrackInfoDisplay.GetEditable (cover);
+
+            var editable_cover = CoverArtEditor.For (
+                cover, (x, y) => true,
+                () => library.TrackModel[0],
+                UpdateCover
+            );
 
             // Title
             title_label = new Label () {



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