Ejemplo n.º 1
0
        private void PodcastFeedAddedOrRemoved(PodcastFeedEventArgs args, bool added)
        {
            if (args.Feed != null)
            {
                PodcastFeedInfo feed = args.Feed;

                if (added)
                {
                    podcast_feed_model.QueueAdd(feed);
                }
                else
                {
                    // Only single select is handled at the moment.
                    // This will need to be updated if multiple feed selection becomes available.
                    TreeIter iter = feed.TreeIter;

                    podcast_feed_model.QueueRemove(feed);
                    podcast_feed_model.IterNext(ref iter);

                    if (podcast_feed_model.GetPath(iter) != null)
                    {
                        podcast_feed_view.Selection.SelectIter(iter);
                        podcast_feed_view.ScrollToIter(iter);
                        return;
                    }

                    // Should not select first, should select previous.  Why
                    // is there no 'TreeModel.IterPrev' method?
                    podcast_feed_model.GetIterFirst(out iter);

                    if (podcast_feed_model.GetPath(iter) != null)
                    {
                        podcast_feed_view.Selection.SelectIter(iter);
                        podcast_feed_view.ScrollToIter(iter);
                    }
                }
            }
            else if (args.Feeds != null)
            {
                ICollection feeds = args.Feeds;

                if (added)
                {
                    podcast_feed_model.QueueAdd(feeds);
                }
                else
                {
                    podcast_feed_model.QueueRemove(feeds);
                }
            }

            Update();
        }
        public void ScrollToIter(TreeIter iter)
        {
            if (iter.Equals(TreeIter.Zero) ||
                !model.IterIsValid(iter))
            {
                return;
            }

            TreePath path;

            path = model.GetPath(iter);

            if (path != null)
            {
                ScrollToCell(path, null, false, 0, 0);
            }
        }