Beispiel #1
0
        private void OnViewRowActivated(object o, RowActivatedArgs args)
        {
            RadioTrackInfo radio_track = model.GetRadioTrackInfo(args.Path);

            if (radio_track != null)
            {
                radio_track.Play();
                return;
            }

            Track track = model.GetTrack(args.Path);

            if (track == null)
            {
                return;
            }

            radio_track = new RadioTrackInfo(track);
            radio_track.ParsingPlaylistEvent += OnTrackParsingPlaylistEvent;
            model.SetRadioTrackInfo(args.Path, radio_track);
            radio_track.Play();
        }
Beispiel #2
0
        protected override void Render(Gdk.Drawable drawable,
                                       Widget widget, Gdk.Rectangle background_area,
                                       Gdk.Rectangle cell_area, Gdk.Rectangle expose_area,
                                       CellRendererState flags)
        {
            StateType state = RendererStateToWidgetState(flags);
            int       text_indent = 6;
            int       text_layout_width, text_layout_height;

            Gdk.Pixbuf     render_icon = radio_icon;
            Track          track       = null;
            RadioTrackInfo radio_track = null;
            string         text        = Text;

            if (widget is TreeView)
            {
                TreePath path;
                if ((widget as TreeView).GetPathAtPos(cell_area.X, cell_area.Y, out path))
                {
                    track       = model.GetTrack(path);
                    radio_track = model.GetRadioTrackInfo(path);
                }
            }

            FontDescription font_description = widget.PangoContext.FontDescription.Copy();

            if (playing_icon != null && track != null && PlayerEngineCore.CurrentTrack is RadioTrackInfo &&
                (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Title == track.Title &&
                (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Annotation == track.Annotation)
            {
                render_icon             = playing_icon;
                font_description.Style  = Pango.Style.Normal;
                font_description.Weight = Pango.Weight.Bold;
            }
            else if (radio_track != null && radio_track.ParsingPlaylist)
            {
                render_icon             = loading_icon;
                font_description.Style  = Pango.Style.Italic;
                font_description.Weight = Pango.Weight.Normal;
                text = String.Format("{0}: {1}", Catalog.GetString("Loading"), Text);
            }
            else if (radio_track != null && radio_track.PlaybackError != TrackPlaybackError.None)
            {
                render_icon             = error_icon;
                font_description.Style  = Pango.Style.Italic;
                font_description.Weight = Pango.Weight.Normal;
                string prefix = null;

                switch (radio_track.PlaybackError)
                {
                case TrackPlaybackError.ResourceNotFound:
                    prefix = Catalog.GetString("Missing");
                    break;

                case TrackPlaybackError.CodecNotFound:
                    prefix = Catalog.GetString("No Codec");
                    break;

                case TrackPlaybackError.Unknown:
                    prefix = Catalog.GetString("Unknown Error");
                    break;

                default:
                    break;
                }

                if (prefix != null)
                {
                    text = String.Format("({0}) {1}", prefix, Text);
                }

                if (!(CellRendererState.Selected & flags).Equals(CellRendererState.Selected))
                {
                    state = StateType.Insensitive;
                }

                if (track != null)
                {
                    track.Title = String.Empty;
                }
            }
            else
            {
                font_description.Style  = Pango.Style.Normal;
                font_description.Weight = Pango.Weight.Normal;
            }

            Gdk.GC main_gc = widget.Style.TextGC(state);

            if (track != null)
            {
                drawable.DrawPixbuf(main_gc, render_icon, 0, 0,
                                    cell_area.X - render_icon.Width,
                                    cell_area.Y + ((cell_area.Height - render_icon.Height) / 2),
                                    render_icon.Width, render_icon.Height,
                                    RgbDither.None, 0, 0);
            }
            else
            {
                text_indent = 0;
            }

            Pango.Layout text_layout = new Pango.Layout(widget.PangoContext);
            text_layout.FontDescription = font_description;
            text_layout.SetMarkup(GLib.Markup.EscapeText(text));
            text_layout.GetPixelSize(out text_layout_width, out text_layout_height);

            drawable.DrawLayout(main_gc,
                                cell_area.X + text_indent,
                                cell_area.Y + ((cell_area.Height - text_layout_height) / 2),
                                text_layout);
        }