[banshee] [Banshee.Moblin] Add rough recent albums view



commit 73639b182540bac4dd079e31871a8402a11dbd6a
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Oct 14 14:56:21 2009 -0700

    [Banshee.Moblin] Add rough recent albums view

 .../Banshee.Moblin/MediaPanelContents.cs           |    6 +-
 .../Banshee.Moblin/RecentAlbumsList.cs             |    4 +-
 .../Banshee.Moblin/RecentAlbumsView.cs             |   88 ++++++++++++++++++++
 src/Extensions/Banshee.Moblin/Makefile.am          |    1 +
 4 files changed, 95 insertions(+), 4 deletions(-)
---
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/MediaPanelContents.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MediaPanelContents.cs
index c1524dc..5e56586 100644
--- a/src/Extensions/Banshee.Moblin/Banshee.Moblin/MediaPanelContents.cs
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MediaPanelContents.cs
@@ -47,8 +47,10 @@ namespace Banshee.Moblin
         
         private void BuildViews ()
         {
-            var left = new VBox ();
+            var left = new VBox () { Spacing = 10 };
             left.PackStart (new SearchHeader (), false, false, 0);
+            left.PackStart (new RecentAlbumsView (), false, false, 0);
+
             PackStart (left, true, true, 0);
             PackStart (new PlayQueueBox (), false, false, 0);
 
@@ -64,4 +66,4 @@ namespace Banshee.Moblin
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/RecentAlbumsList.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/RecentAlbumsList.cs
index 1f1608d..c691029 100644
--- a/src/Extensions/Banshee.Moblin/Banshee.Moblin/RecentAlbumsList.cs
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/RecentAlbumsList.cs
@@ -84,8 +84,8 @@ namespace Banshee.Moblin
         private void Dump ()
         {
             Console.WriteLine ("RecentAlbumsList has {0} albums", list.Count);
-            foreach (var album in list) {
-                Console.WriteLine ("Recent Album: {0} by {1}", album.Title, album.ArtistName);
+            foreach (var album in Albums) {
+                Console.WriteLine ("Recent Album: {0} by {1} (ArtworkId: {2})", album.Title, album.ArtistName, album.ArtworkId);
             }
         }
 
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/RecentAlbumsView.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/RecentAlbumsView.cs
new file mode 100644
index 0000000..a2a70c4
--- /dev/null
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/RecentAlbumsView.cs
@@ -0,0 +1,88 @@
+// 
+// RecentAlbumsView.cs
+//  
+// Author:
+//   Gabriel Burt <gburt novell com>
+// 
+// Copyright 2009 Novell, Inc.
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+
+using Gtk;
+
+using Banshee.Gui;
+using Banshee.Gui.Widgets;
+using Banshee.Collection.Gui;
+using Banshee.ServiceStack;
+
+namespace Banshee.Moblin
+{
+    public class RecentAlbumsView : Table
+    {
+        const int icon_size = 48;
+        const int cols = 3;
+        const int rows = 4;
+
+        private RecentAlbumsList recent;
+        private List<Image> images;
+
+        public RecentAlbumsView () : base (3, 4, true)
+        {
+            RowSpacing = ColumnSpacing = 12;
+            Build ();
+
+            recent = new RecentAlbumsList (cols*rows);
+            recent.Changed += (o, a) => Reload ();
+            Reload ();
+        }
+
+        private void Build ()
+        {
+            images = new List<Image> ();
+
+            for (uint j = 0; j < rows; j++) {
+                for (uint i = 0; i < cols; i++) {
+                    var image = new Image ();
+                    images.Add (image);
+                    Attach (image, i, i+1, j, j+1);
+                }
+            }
+
+            ShowAll ();
+        }
+
+        public void Reload ()
+        {
+            var artwork = ServiceManager.Get<ArtworkManager> ();
+
+            for (int i = 0; i < recent.Albums.Count; i++) {
+                var album = recent.Albums[i];
+                images[i].Pixbuf = artwork.LookupScalePixbuf (album.ArtworkId, icon_size);
+                images[i].Show ();
+            }
+
+            for (int i = recent.Albums.Count; i < cols*rows; i++) {
+                images[i].Hide ();
+            }
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Moblin/Makefile.am b/src/Extensions/Banshee.Moblin/Makefile.am
index 95678de..241d5c8 100644
--- a/src/Extensions/Banshee.Moblin/Makefile.am
+++ b/src/Extensions/Banshee.Moblin/Makefile.am
@@ -10,6 +10,7 @@ SOURCES =  \
 	Banshee.Moblin/PlaybackBox.cs \
 	Banshee.Moblin/PlayQueueBox.cs \
 	Banshee.Moblin/RecentAlbumsList.cs \
+	Banshee.Moblin/RecentAlbumsView.cs \
 	Banshee.Moblin/SearchEntry.cs \
 	Banshee.Moblin/SearchHeader.cs \
 	Mutter/PanelClient.cs \



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