private void TrackCellPodcastFeedStatus(TreeViewColumn tree_column,
                                                CellRenderer cell, TreeModel tree_model, TreeIter iter)
        {
            PodcastFeedInfo feed = model.IterPodcastFeedInfo(iter);

            CellRendererText renderer = cell as CellRendererText;

            renderer.Style  = Pango.Style.Normal;
            renderer.Weight = (int)Pango.Weight.Normal;

            if (feed == PodcastFeedInfo.All)
            {
                renderer.Text   = Catalog.GetString("All");
                renderer.Weight = (int)Pango.Weight.Bold;
            }
            else if (feed != null)
            {
                if (feed.IsSubscribed)
                {
                    renderer.Text = String.Format(
                        "({0}/{1})",
                        feed.DownloadedPodcasts, feed.TotalPodcasts
                        );
                }
                else
                {
                    renderer.Text = String.Format(
                        "({0})", feed.DownloadedPodcasts
                        );
                }
            }
        }
        private void TrackCellPodcastFeedTitle(TreeViewColumn tree_column,
                                               CellRenderer cell, TreeModel tree_model, TreeIter iter)
        {
            PodcastFeedInfo  feed     = model.IterPodcastFeedInfo(iter);
            CellRendererText renderer = cell as CellRendererText;

            if (feed == PodcastFeedInfo.All)
            {
                renderer.Text = String.Format(
                    Catalog.GetPluralString(
                        "{0} Feed", "{0} Feeds", PodcastCore.Library.FeedCount
                        ),
                    PodcastCore.Library.FeedCount
                    );

                renderer.Weight = (int)Pango.Weight.Bold;
                renderer.Style  = Pango.Style.Normal;
            }
            else if (feed != null)
            {
                string title = (feed.Title == null || feed.Title == String.Empty)
                               ? feed.Url.ToString() : feed.Title;

                if (feed.NewPodcasts > 0)
                {
                    string episode_str = Catalog.GetPluralString(
                        "Episode", "Episodes", feed.NewPodcasts
                        );

                    renderer.Text = String.Format(
                        "{0} - {1} {2} {3}",
                        title, feed.NewPodcasts, Catalog.GetString("New"), episode_str
                        );
                }
                else
                {
                    renderer.Text = title;
                }

                if (!feed.IsSubscribed)
                {
                    renderer.Style  = Pango.Style.Italic;
                    renderer.Weight = (int)Pango.Weight.Normal;
                }
                else
                {
                    renderer.Style = Pango.Style.Normal;

                    if (feed.IsUpdating || feed.NewPodcasts > 0)
                    {
                        renderer.Weight = (int)Pango.Weight.Bold;
                    }
                    else
                    {
                        renderer.Weight = (int)Pango.Weight.Normal;
                    }
                }
            }
        }
Example #3
0
        private void OnFeedMenuVisitLinkActivated(object sender, EventArgs args)
        {
            PodcastFeedInfo feed = GetSelectedFeed();

            if (feed != null)
            {
                Gnome.Url.Show(feed.Link.ToString());
            }
        }
Example #4
0
        private void OnFeedMenuRemoveActivated(object sender, EventArgs args)
        {
            PodcastFeedInfo feed = GetSelectedFeed();

            if (feed != null)
            {
                PodcastCore.Library.RemovePodcastFeed(feed);
            }
        }
        private void OnModelPodcastFeedAdded(object sender, PodcastFeedEventArgs args)
        {
            PodcastFeedInfo feed = args.Feed;

            if (feed != null)
            {
                SelectFeed(feed);
            }
        }
        public void QueueRemove(PodcastFeedInfo feed)
        {
            lock (remove_queue.SyncRoot)
            {
                remove_queue.Add(feed);
            }

            GLib.Idle.Add(PumpRemoveQueue);
        }
        public void QueueAdd(PodcastFeedInfo feed)
        {
            lock (add_queue.SyncRoot)
            {
                add_queue.Add(feed);
            }

            GLib.Idle.Add(PumpAddQueue);
        }
        public void SelectFeed(PodcastFeedInfo feed)
        {
            if (feed == null)
            {
                throw new ArgumentNullException("feed");
            }

            Selection.SelectIter(feed.TreeIter);
            ScrollToIter(feed.TreeIter);
        }
        public PodcastFeedPropertiesDialog(PodcastFeedInfo feed) :
            base(feed.Title, InterfaceElements.MainWindow, DialogFlags.DestroyWithParent)
        {
            this.feed = feed;

            Title = feed.Title;
            IconThemeUtils.SetWindowIcon(this);

            BuildWindow();
        }
Example #10
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();
        }
        private void EmitPodcastFeedAdded(PodcastFeedInfo feed)
        {
            if (feed != null)
            {
                PodcastFeedEventHandler handler = FeedAdded;

                if (handler != null)
                {
                    handler(this, new PodcastFeedEventArgs(feed));
                }
            }
        }
Example #12
0
        private void OnFeedMenuPropertiesActivated(object sender, EventArgs args)
        {
            PodcastFeedInfo feed = GetSelectedFeed();

            if (feed != null)
            {
                PodcastFeedPropertiesDialog prop_dialog = new PodcastFeedPropertiesDialog(feed);

                ThreadAssist.ProxyToMain(delegate {
                    prop_dialog.Show();
                });
            }
        }
        private bool PumpQueue(ArrayList queue,
                               SingleFeedAction sfa, MultipleFeedAction mfa)
        {
            PodcastFeedInfo feed  = null;
            ICollection     feeds = null;

            int range_upper = -1;

            lock (queue.SyncRoot)
            {
                if (queue.Count == 0)
                {
                    return(false);
                }

                int queue_count = queue.Count;
                range_upper = (queue_count >= 32) ? 31 : queue_count;

                if (queue_count == 1)
                {
                    feed = queue [0] as PodcastFeedInfo;
                }
                else if (queue_count > 1)
                {
                    feeds = queue.GetRange(0, range_upper);
                }
            }

            if (feed != null)
            {
                sfa(feed);
            }
            else if (feeds != null)
            {
                mfa(feeds);
            }

            lock (queue.SyncRoot)
            {
                queue.RemoveRange(0, range_upper);

                if (queue.Count == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
        private void RemovePodcastFeed(PodcastFeedInfo feed)
        {
            if (feed != null)
            {
                TreeIter iter = feed.TreeIter;

                feed.TitleUpdated -= OnFeedTitleUpdated;

                if (IterIsValid(iter))
                {
                    Remove(ref iter);
                }
            }
        }
Example #15
0
        private void OnPodcastFeedViewButtonPressEvent(object o,
                                                       ButtonPressEventArgs args)
        {
            if (args.Event.Window != podcast_feed_view.BinWindow)
            {
                return;
            }

            TreePath path;

            podcast_feed_view.GetPathAtPos((int)args.Event.X,
                                           (int)args.Event.Y, out path);

            if (path == null)
            {
                if (args.Event.Button == 3)
                {
                    DefaultMenuPopup(args.Event.Time);
                }
                return;
            }

            podcast_feed_view.Selection.SelectPath(path);
            PodcastFeedInfo clicked_feed = podcast_feed_model.PathPodcastFeedInfo(path);

            switch (args.Event.Type)
            {
            case EventType.ButtonPress:
                if (args.Event.Button == 3)
                {
                    if (clicked_feed == null ||
                        clicked_feed == PodcastFeedInfo.All)
                    {
                        DefaultMenuPopup(args.Event.Time);
                    }
                    else
                    {
                        FeedViewMenuPopup(args.Event.Time, clicked_feed);
                    }
                }

                args.RetVal = false;
                return;

            default:
                args.RetVal = false;
                return;
            }
        }
        public int PodcastFeedTitleTreeIterCompareFunc(TreeModel tree_model,
                                                       TreeIter a,
                                                       TreeIter b)
        {
            PodcastFeedInfo feed_a = tree_model.GetValue(a, 0) as PodcastFeedInfo;
            PodcastFeedInfo feed_b = tree_model.GetValue(b, 0) as PodcastFeedInfo;

            if (feed_a == PodcastFeedInfo.All ||
                feed_b == PodcastFeedInfo.All)
            {
                return(1);
            }

            return(feed_a.CompareTo(feed_b));
        }
        private void AddPodcastFeed(PodcastFeedInfo feed, bool emitFeedAdded)
        {
            if (feed == null)
            {
                return;
            }

            feed.TitleUpdated += OnFeedTitleUpdated;
            feed.TreeIter      = AppendValues(feed);

            if (emitFeedAdded)
            {
                EmitPodcastFeedAdded(feed);
            }
        }
Example #18
0
        // menu callbacks -----------------------------------------------//

        private void OnFeedMenuSubscribeToggled(object sender, EventArgs args)
        {
            PodcastFeedInfo feed = GetSelectedFeed();

            if (feed != null)
            {
                if (feed.IsUpdating)
                {
                    return;
                }

                feed.IsSubscribed = !feed.IsSubscribed;
                feed.Commit();
                podcast_view.Refilter();
            }
        }
Example #19
0
        private void OnFeedMenuUpdateCurrentActivated(object sender, EventArgs args)
        {
            PodcastFeedInfo feed = GetSelectedFeed();

            if (feed != null)
            {
                if (!feed.IsSubscribed)
                {
                    feed.IsSubscribed = true;
                    feed.Commit();

                    podcast_view.Refilter();
                    podcast_view.QueueDraw();
                }

                PodcastCore.FeedFetcher.Update(feed, true);
            }
        }
Example #20
0
        private void OnFeedViewSelectionChanged(object sender, EventArgs args)
        {
            PodcastFeedInfo selected_feed = GetSelectedFeed();

            if (selected_feed == null ||
                previously_selected == selected_feed)
            {
                return;
            }

            if (previously_selected != PodcastFeedInfo.All)
            {
                if (previously_selected.NewPodcasts > 0)
                {
                    previously_selected.Select();
                }
            }

            podcast_view.FilterOnFeed(selected_feed);

            previously_selected = selected_feed;
        }
        private void TrackCellPodcastFeedActivity(TreeViewColumn tree_column,
                                                  CellRenderer cell, TreeModel tree_model, TreeIter iter)
        {
            PodcastFeedInfo    feed     = model.IterPodcastFeedInfo(iter);
            CellRendererPixbuf renderer = cell as CellRendererPixbuf;

            renderer.Pixbuf    = null;
            renderer.StockId   = null;
            renderer.Sensitive = true;

            if (feed.IsUpdating)
            {
                renderer.StockId = Stock.Refresh;
            }
            else if (feed.ActiveDownloads > 0)
            {
                renderer.StockId = Stock.GoForward;
            }
            else if (feed.QueuedDownloads > 0)
            {
                renderer.Sensitive = false;
                renderer.StockId   = Stock.GoForward;
            }
        }
        private void RemovePodcastFeed(PodcastFeedInfo feed)
        {
            if (feed != null)
            {
                TreeIter iter = feed.TreeIter;

                feed.TitleUpdated -= OnFeedTitleUpdated;

                if (IterIsValid (iter))
                {
                    Remove (ref iter);
                }
            }
        }
        private void EmitPodcastFeedAdded(PodcastFeedInfo feed)
        {
            if (feed != null)
            {
                PodcastFeedEventHandler handler = FeedAdded;

                if (handler != null)
                {
                    handler (this, new PodcastFeedEventArgs (feed));
                }
            }
        }
        private void AddPodcastFeed(PodcastFeedInfo feed, bool emitFeedAdded)
        {
            if (feed == null)
            {
                return;
            }

            feed.TitleUpdated += OnFeedTitleUpdated;
            feed.TreeIter = AppendValues (feed);

            if (emitFeedAdded)
            {
                EmitPodcastFeedAdded (feed);
            }
        }
 private void AddPodcastFeed(PodcastFeedInfo feed)
 {
     AddPodcastFeed(feed, true);
 }
Example #26
0
 public void FilterOnFeed(PodcastFeedInfo feed)
 {
     selected_feed = feed;
     Refilter();
 }
        public void QueueAdd(PodcastFeedInfo feed)
        {
            lock (add_queue.SyncRoot)
            {
                add_queue.Add (feed);
            }

            GLib.Idle.Add (PumpAddQueue);
        }
        public void QueueRemove(PodcastFeedInfo feed)
        {
            lock (remove_queue.SyncRoot)
            {
                remove_queue.Add (feed);
            }

            GLib.Idle.Add (PumpRemoveQueue);
        }
 private void AddPodcastFeed(PodcastFeedInfo feed)
 {
     AddPodcastFeed (feed, true);
 }
        public void SelectFeed(PodcastFeedInfo feed)
        {
            if (feed == null)
            {
                throw new ArgumentNullException ("feed");
            }

            Selection.SelectIter (feed.TreeIter);
            ScrollToIter (feed.TreeIter);
        }
Example #31
0
        // Should use ActionManager at some point
        private void FeedViewMenuPopup(uint time, PodcastFeedInfo feed)
        {
            if (feed_view_popup_menu == null)
            {
                feed_view_popup_menu = new Menu();

                feed_subscription_menu_item          = new CheckMenuItem(Catalog.GetString("Subscribed"));
                feed_subscription_menu_item.Toggled += OnFeedMenuSubscribeToggled;

                feed_update_menu_item            = new ImageMenuItem(Catalog.GetString("Update Feed"));
                feed_update_menu_item.Image      = new Gtk.Image(Gtk.Stock.Refresh, IconSize.Menu);
                feed_update_menu_item.Activated += OnFeedMenuUpdateCurrentActivated;

                feed_remove_menu_item            = new ImageMenuItem(Catalog.GetString("Delete Feed"));
                feed_remove_menu_item.Image      = new Gtk.Image(Gtk.Stock.Delete, IconSize.Menu);
                feed_remove_menu_item.Activated += OnFeedMenuRemoveActivated;

                feed_new_menu_item            = new ImageMenuItem(Catalog.GetString("Subscribe to New Feed"));
                feed_new_menu_item.Image      = new Gtk.Image(Gtk.Stock.New, IconSize.Menu);
                feed_new_menu_item.Activated += OnFeedMenuNewActivated;

                feed_visit_link_menu_item            = new ImageMenuItem(Catalog.GetString("Homepage"));
                feed_visit_link_menu_item.Image      = new Gtk.Image(Gtk.Stock.JumpTo, IconSize.Menu);
                feed_visit_link_menu_item.Activated += OnFeedMenuVisitLinkActivated;

                feed_properties_menu_item            = new ImageMenuItem(Catalog.GetString("Properties"));
                feed_properties_menu_item.Image      = new Gtk.Image(Gtk.Stock.Properties, IconSize.Menu);
                feed_properties_menu_item.Activated += OnFeedMenuPropertiesActivated;

                feed_view_popup_menu.Append(feed_subscription_menu_item);
                feed_view_popup_menu.Append(new SeparatorMenuItem());
                feed_view_popup_menu.Append(feed_remove_menu_item);
                feed_view_popup_menu.Append(feed_new_menu_item);
                feed_view_popup_menu.Append(new SeparatorMenuItem());
                feed_view_popup_menu.Append(feed_visit_link_menu_item);
                feed_view_popup_menu.Append(feed_update_menu_item);
                feed_view_popup_menu.Append(new SeparatorMenuItem());
                feed_view_popup_menu.Append(feed_properties_menu_item);

                feed_view_popup_menu.ShowAll();
            }

            feed_subscription_menu_item.Toggled -= OnFeedMenuSubscribeToggled;
            feed_subscription_menu_item.Active   = feed.IsSubscribed;
            feed_subscription_menu_item.Toggled += OnFeedMenuSubscribeToggled;

            if (feed.IsBusy)
            {
                // TODO Allow users to delete / unsubscribe from a busy feed.
                // This will be trivial once the download code is moved into PodcastFeedInfo.

                feed_subscription_menu_item.Sensitive = false;
                feed_remove_menu_item.Sensitive       = false;
            }
            else
            {
                feed_remove_menu_item.Sensitive       = true;
                feed_subscription_menu_item.Sensitive = true;
            }

            feed_view_popup_menu.Popup(null, null, null, 0, time);
            return;
        }