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); track_box.Title = String.Format(track_title_format, artist); similar_artists_view.ClearWidgets(); ClearBox(album_list); ClearBox(track_list); // Similar Artists for (int i = 0; i < Math.Min(20, similar_artists.Count); i++) { SimilarArtistTile tile = new SimilarArtistTile(similar_artists[i]); tile.ShowAll(); similar_artists_view.AddWidget(tile); } if (similar_artists.Count > 0) { no_artists_pane.Hide(); similar_artists_view_sw.ShowAll(); } else { similar_artists_view_sw.Hide(); no_artists_pane.ShowAll(); } for (int i = 0; i < Math.Min(5, top_albums.Count); i++) { ArtistTopAlbum album = top_albums[i]; Button album_button = new Button(); album_button.Relief = ReliefStyle.None; Label label = new Label(); label.ModifyFg(StateType.Normal, Style.Text(StateType.Normal)); label.Ellipsize = Pango.EllipsizeMode.End; label.Xalign = 0; label.Markup = String.Format("{0}. {1}", i + 1, GLib.Markup.EscapeText(album.Name)); album_button.Add(label); album_button.Clicked += delegate { Banshee.Web.Browser.Open(album.Url); }; album_list.PackStart(album_button, false, true, 0); } album_box.ShowAll(); for (int i = 0; i < Math.Min(5, top_tracks.Count); i++) { ArtistTopTrack track = top_tracks[i]; Button track_button = new Button(); track_button.Relief = ReliefStyle.None; HBox box = new HBox(); Label label = new Label(); label.ModifyFg(StateType.Normal, Style.Text(StateType.Normal)); label.Ellipsize = Pango.EllipsizeMode.End; label.Xalign = 0; label.Markup = String.Format("{0}. {1}", i + 1, GLib.Markup.EscapeText(track.Name)); /*if(node.SelectSingleNode("track_id") != null) { * box.PackEnd(new Image(now_playing_arrow), false, false, 0); * track_button.Clicked += delegate { * //PlayerEngineCore.OpenPlay(Globals.Library.GetTrack( * //Convert.ToInt32(node.SelectSingleNode("track_id").InnerText))); * }; * } else {*/ track_button.Clicked += delegate { Banshee.Web.Browser.Open(track.Url); }; //} box.PackStart(label, true, true, 0); track_button.Add(box); track_list.PackStart(track_button, false, true, 0); } track_box.ShowAll(); ready = true; refreshing = false; context_page.SetState(Banshee.ContextPane.ContextState.Loaded); }); }
private void RenderRecommendationData(string artist, XmlNodeList artistsXmlList, XmlNodeList tracksXmlList, XmlNodeList albumsXmlList) { // Wipe the old recommendations here, we keep them around in case // where the the artist is the same as the last song. similar_artists_view.ClearWidgets(); foreach (Widget child in tracks_items_box.Children) { tracks_items_box.Remove(child); } foreach (Widget child in albums_items_box.Children) { albums_items_box.Remove(child); } // Display recommendations and artist information current_artist = artist; tracks_header.Markup = "<b>" + String.Format(Catalog.GetString("Top Tracks by {0}"), GLib.Markup.EscapeText(artist)) + "</b>"; albums_header.Markup = "<b>" + String.Format(Catalog.GetString("Top Albums by {0}"), GLib.Markup.EscapeText(artist)) + "</b>"; artists_widgets_list.Clear(); ShowAll(); if (artistsXmlList != null && artistsXmlList.Count > 0) { for (int i = 0; i < artistsXmlList.Count && i < NUM_MAX_ARTISTS; i++) { artists_widgets_list.Add(RenderSimilarArtist(artistsXmlList[i])); } RenderSimilarArtists(); no_artists_pane.Hide(); similar_artists_view_sw.ShowAll(); } else { similar_artists_view_sw.Hide(); no_artists_pane.ShowAll(); } if (tracksXmlList != null) { for (int i = 0; i < tracksXmlList.Count && i < NUM_TRACKS; i++) { tracks_items_box.PackStart(RenderTrack(tracksXmlList[i], i + 1), false, true, 0); } tracks_items_box.ShowAll(); } if (albumsXmlList != null) { for (int i = 0; i < albumsXmlList.Count && i < NUM_ALBUMS; i++) { albums_items_box.PackStart(RenderAlbum(albumsXmlList[i], i + 1), false, true, 0); } albums_items_box.ShowAll(); } }