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 UpdateForArtist(string artist_name, LastfmData<SimilarArtist> similar_artists, LastfmData<ArtistTopAlbum> top_albums, LastfmData<ArtistTopTrack> top_tracks) { 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 var artists = similar_artists.Take (20); if (artists.Count () > 0) { int artist_name_max_len = 2 * (int) artists.Select (a => a.Name.Length).Average (); foreach (var similar_artist in artists) { SimilarArtistTile tile = new SimilarArtistTile (similar_artist); tile.PrimaryLabel.WidthChars = artist_name_max_len; tile.PrimaryLabel.Ellipsize = Pango.EllipsizeMode.End; tile.ShowAll (); similar_artists_view.AddWidget (tile); } 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.OverrideColor (StateFlags.Normal, StyleContext.GetColor (StateFlags.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.OverrideColor (StateFlags.Normal, StyleContext.GetColor (StateFlags.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); }); }