banshee r4178 - in trunk/banshee: . src/Extensions/Banshee.Lastfm src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations



Author: abock
Date: Fri Jun 20 21:35:41 2008
New Revision: 4178
URL: http://svn.gnome.org/viewvc/banshee?rev=4178&view=rev

Log:
2008-06-20  Aaron Bockover  <abock gnome org>

    * src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationPane.cs:
    Fix remaining layout and style issues, handle height allocation enforcement

    * src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/SimilarArtistTile.cs:
    Created a SimilarArtist tile



Added:
   trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/SimilarArtistTile.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationPane.cs
   trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.mdp
   trunk/banshee/src/Extensions/Banshee.Lastfm/Makefile.am

Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationPane.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationPane.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationPane.cs	Fri Jun 20 21:35:41 2008
@@ -70,7 +70,7 @@
         private TitledList album_box;
         private TitledList track_box;
         
-        private Hyena.Widgets.ScrolledWindow similar_artists_view_sw;
+        private Gtk.ScrolledWindow similar_artists_view_sw;
         
         private TileView similar_artists_view;
         private VBox album_list;
@@ -138,25 +138,25 @@
 
         public RecommendationPane () : base ()
         {
-            //ShadowType = ShadowType.In;
-
             main_box = new HBox ();
             main_box.BorderWidth = 5;
 
             artist_box = new TitledList (String.Format ("Recommended Artists"));
             similar_artists_view = new TileView (2);
-            similar_artists_view_sw = new Hyena.Widgets.ScrolledWindow ();
-            similar_artists_view_sw.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
+            similar_artists_view_sw = new Gtk.ScrolledWindow ();
+            similar_artists_view_sw.SetPolicy (PolicyType.Never, PolicyType.Automatic);
             similar_artists_view_sw.Add (similar_artists_view);
             similar_artists_view_sw.ShowAll ();
-            artist_box.PackEnd (similar_artists_view_sw, true, true, 0);
+            artist_box.PackStart (similar_artists_view_sw, true, true, 0);
 
             album_box  = new TitledList (null);
             album_box.TitleWidthChars = 25;
+            album_box.SizeAllocated += OnSideSizeAllocated;
             album_list = new VBox ();
-            album_box.PackStart (album_list, true, true, 0);
+            album_box.PackStart (album_list, false, false, 0);
 
             track_box  = new TitledList (null);
+            track_box.SizeAllocated += OnSideSizeAllocated;
             track_box.TitleWidthChars = 25;
             track_list = new VBox ();
             track_box.PackStart (track_list, true, true, 0);
@@ -183,21 +183,20 @@
             main_box.PackStart (new VSeparator (), false, false, 0);
             main_box.PackStart (track_box, false, false, 5);
             
-            EventBox event_box = new EventBox ();
-            
-            /*no_artists_pane.StyleSet += delegate {
-                event_box.ModifyBg (StateType.Normal, no_artists_pane.Style.Base (StateType.Normal));
-                similar_artists_view.ModifyBg (StateType.Normal, no_artists_pane.Style.Base (StateType.Normal));
-            };*/
-            
-            /*StyleSet += delegate {
-                ModifyBg (StateType.Normal, Style.Base (StateType.Normal));
-                ModifyFg (StateType.Normal, Style.Text (StateType.Normal));
-            };*/
-
-            event_box.Add (main_box);
             no_artists_pane.Hide ();
-            Add (event_box);
+            
+            Add (main_box);
+        }
+        
+        private void OnSideSizeAllocated (object o, SizeAllocatedArgs args)
+        {
+            SetSizeRequest (-1, args.Allocation.Height + (Allocation.Height - args.Allocation.Height));
+        }
+        
+        protected override void OnStyleSet (Style previous_style)
+        {
+            base.OnStyleSet (previous_style);
+            similar_artists_view.ModifyBg (StateType.Normal, Style.Base (StateType.Normal));
         }
         
         private void UpdateForArtist (string artist_name)
@@ -216,7 +215,8 @@
             }
         }
         
-        private void UpdateForArtist (string artist_name, LastfmData<SimilarArtist> similar_artists, LastfmData<ArtistTopAlbum> top_albums, LastfmData<ArtistTopTrack> top_tracks)
+        private void UpdateForArtist (string artist_name, LastfmData<SimilarArtist> similar_artists, 
+            LastfmData<ArtistTopAlbum> top_albums, LastfmData<ArtistTopTrack> top_tracks)
         {
             Banshee.Base.ThreadAssist.ProxyToMain (delegate {
                 album_box.Title = String.Format (album_title_format, artist);
@@ -228,21 +228,8 @@
                 
                 // Similar Artists                
                 for (int i = 0; i < Math.Min (20, similar_artists.Count); i++) {
-                    SimilarArtist similar_artist = similar_artists[i];
-                    Tile tile = new Tile (similar_artist.Name);
-                    try {
-                        tile.Pixbuf = new Gdk.Pixbuf (DataCore.GetCachedPathFromUrl (similar_artist.SmallImageUrl));
-                    } catch {
-                        tile.Pixbuf = IconThemeUtils.LoadIcon ("generic-artist", 48);
-                    }
-                    
-                    try {
-                        tile.SecondaryText = String.Format (Catalog.GetString ("{0}% Similarity"), similar_artist.MatchAsInt);
-                    } catch {
-                        tile.SecondaryText = Catalog.GetString ("Unknown Similarity");
-                    }
-                    
-                    tile.Clicked += delegate { Banshee.Web.Browser.Open (similar_artist.Url); };
+                    SimilarArtistTile tile = new SimilarArtistTile (similar_artists[i]);
+                    tile.ShowAll ();
                     similar_artists_view.AddWidget (tile);
                 }
                 

Added: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/SimilarArtistTile.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/SimilarArtistTile.cs	Fri Jun 20 21:35:41 2008
@@ -0,0 +1,73 @@
+//
+// SimilarArtistTile.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 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 Mono.Unix;
+
+using Lastfm.Data;
+using Banshee.Widgets;
+
+namespace Banshee.Lastfm.Recommendations
+{
+    public class SimilarArtistTile : Tile
+    {
+        private SimilarArtist artist;
+        
+        public SimilarArtistTile (SimilarArtist artist)
+        {
+            Artist = artist;
+        }
+        
+        protected override void OnClicked ()
+        {
+            if (artist != null) {
+                Banshee.Web.Browser.Open (artist.Url);
+            }
+        }
+        
+        public SimilarArtist Artist {
+            set {
+                artist = value;
+                
+                PrimaryText = value.Name;
+                
+                try {
+                    SecondaryText = String.Format (Catalog.GetString ("{0}% Similarity"), value.MatchAsInt);
+                } catch {
+                    SecondaryText = Catalog.GetString ("Unknown Similarity");
+                }
+                
+                try {
+                    Pixbuf = new Gdk.Pixbuf (DataCore.GetCachedPathFromUrl (value.SmallImageUrl));
+                } catch {
+                    Pixbuf = Banshee.Gui.IconThemeUtils.LoadIcon ("generic-artist", 48);
+                }
+            }
+        }
+    }
+}

Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.mdp
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.mdp	(original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.mdp	Fri Jun 20 21:35:41 2008
@@ -28,6 +28,8 @@
     <File name="Banshee.Lastfm.Recommendations/RecommendationPane.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Lastfm.Recommendations/RecommendationService.cs" subtype="Code" buildaction="Compile" />
     <File name="Resources/RecommendationMenu.xml" subtype="Code" buildaction="EmbedAsResource" />
+    <File name="Resources/no-results.png" subtype="Code" buildaction="EmbedAsResource" />
+    <File name="Banshee.Lastfm.Recommendations/SimilarArtistTile.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />

Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Makefile.am	(original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Makefile.am	Fri Jun 20 21:35:41 2008
@@ -16,7 +16,8 @@
 	Banshee.Lastfm.Radio/StationType.cs \
 	Banshee.Lastfm.Recommendations/RecommendationActions.cs \
 	Banshee.Lastfm.Recommendations/RecommendationPane.cs \
-	Banshee.Lastfm.Recommendations/RecommendationService.cs
+	Banshee.Lastfm.Recommendations/RecommendationService.cs \
+	Banshee.Lastfm.Recommendations/SimilarArtistTile.cs
 
 
 RESOURCES =  \



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