示例#1
0
        private void OnMetadataCompleted(Song song)
        {
            string station_id = Driver.connection.StationLocation;
            current_song = song;

            love_button.Sensitive = true;
            hate_button.Sensitive = true;
            tag_button.Sensitive = true;
            journal_button.Sensitive = true;
            info_button.Sensitive = true;
            progress_label.Markup = "";
            progress_label.Visible = true;

            if (station_id != null) {
                if (known_stations.Contains (station_id) == false) {
                    string name;

                    if (station_id.StartsWith ("lastfm://play")) {
                        // This is a 30 second preview
                        // but the station name isn't very
                        // descriptive..Make it better.

                        name = song.Artist + " (" + song.Station + ")";
                    } else {
                        name = song.Station;
                    }

                    add_custom_station (null, name,
                                station_id, true);
                    select_station (station_id);
                } else {
                    // Irritating code to deal with
                    // the payola adverts on last.fm now.
                    set_station_title (station_id, song.Station);
                }
            }

            trayicon.FillPopup (song);

            song.ImageLoaded += new Song.ImageLoadedHandler (OnCoverLoaded);
            if (song.Track != null) {
                song_label.Markup = "<span weight=\"bold\"><a href=\"" + song.TrackUrl + "\">" + StringUtils.EscapeForPango (song.Track) + "</a></span>";
            } else {
                song_label.Markup = "<span weight=\"bold\"> </span>";
            }

            if (song.Album != null && song.Artist != null) {
                artist_label.Markup = String.Format(Catalog.GetString("<span size=\"smaller\">From <a href=\"{0}\">{1}</a> by <a href=\"{2}\">{3}</a></span>"), song.AlbumUrl, StringUtils.EscapeForPango (song.Album), song.ArtistUrl, StringUtils.EscapeForPango (song.Artist));
            } else if (song.Album == null) {
                artist_label.Markup = String.Format(Catalog.GetString("<span size=\"smaller\">By <a href=\"{0}\">{1}</a></span>"), song.ArtistUrl, StringUtils.EscapeForPango (song.Artist));
            } else if (song.Artist == null) {
                artist_label.Markup = String.Format(Catalog.GetString("<span size=\"smaller\">From <a href=\"{0}\">{1}</a></span>"), song.AlbumUrl, StringUtils.EscapeForPango (song.Album));
            } else {
                artist_label.Markup = "<span size=\"smaller\"> </span>";
            }

            song.RequestImage (Driver.CoverSize, Driver.CoverSize);

            this.Title = String.Format(Catalog.GetString("{0} by {1}"), song.Track, song.Artist);

            love_button.Sensitive = true;
            hate_button.Sensitive = true;

            if (i_window != null) {
                i_window.SetSong (song);
            }

            GLib.Timeout.Add (250, new GLib.TimeoutHandler (adjust_progress_label_callback));
        }