[banshee] [Podcasting] Show episodes in a grid view



commit 27e86a9723289622de89ce50e2310c4a05dcb685
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Oct 13 15:10:19 2010 -0500

    [Podcasting] Show episodes in a grid view

 .../Banshee.Podcasting.Data/PodcastSource.cs       |   16 +++-
 .../Banshee.Podcasting.Gui/Grid.cs                 |   95 ++++++++++++++++++
 .../Banshee.Podcasting.Gui/GridContent.cs          |  101 ++++++++++++++++++++
 .../Banshee.Podcasting.Gui/HeaderWidget.cs         |   94 ++++++++++++++++++
 .../Banshee.Podcasting.Gui/PodcastActions.cs       |    3 +
 src/Extensions/Banshee.Podcasting/Makefile.am      |    3 +
 .../Resources/ActiveSourceUI.xml                   |    8 ++
 7 files changed, 317 insertions(+), 3 deletions(-)
---
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs
index 6efed71..f6f2729 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs
@@ -59,6 +59,8 @@ namespace Banshee.Podcasting.Gui
     public class PodcastSource : Banshee.Library.LibrarySource
     {
         private PodcastFeedModel feed_model;
+        private PodcastUnheardFilterModel new_filter;
+        private DownloadStatusFilterModel downloaded_filter;
 
         public override string DefaultBaseDirectory {
             get {
@@ -91,6 +93,9 @@ namespace Banshee.Podcasting.Gui
             get { return feed_model; }
         }
 
+        public PodcastUnheardFilterModel NewFilter { get { return new_filter; } }
+        public DownloadStatusFilterModel DownloadedFilter { get { return downloaded_filter; } }
+
         public override string PreferencesPageId {
             get { return UniqueId; }
         }
@@ -222,10 +227,15 @@ namespace Banshee.Podcasting.Gui
 
             Properties.SetString ("GtkActionPath", "/PodcastSourcePopup");
 
-            Properties.Set<ISourceContents> ("Nereid.SourceContents", new LazyLoadSourceContents<PodcastSourceContents> ());
+            //Properties.Set<ISourceContents> ("Nereid.SourceContents", new LazyLoadSourceContents<PodcastSourceContents> ());
+            Properties.Set<ISourceContents> ("Nereid.SourceContents", new LazyLoadSourceContents<GridContent> ());
             Properties.Set<bool> ("Nereid.SourceContentsPropagate", true);
             Properties.Set<bool> ("SourceView.HideCount", false);
 
+            var header_widget = new HeaderWidget (this);
+            header_widget.ShowAll ();
+            Properties.Set<Gtk.Widget> ("Nereid.SourceContents.HeaderWidget", header_widget);
+
             Properties.SetString ("TrackView.ColumnControllerXml", String.Format (@"
                     <column-controller>
                       <add-all-defaults />
@@ -311,8 +321,8 @@ namespace Banshee.Podcasting.Gui
         protected override IEnumerable<IFilterListModel> CreateFiltersFor (DatabaseSource src)
         {
             PodcastFeedModel feed_model;
-            yield return new PodcastUnheardFilterModel (src.DatabaseTrackModel);
-            yield return new DownloadStatusFilterModel (src.DatabaseTrackModel);
+            yield return new_filter = new PodcastUnheardFilterModel (src.DatabaseTrackModel);
+            yield return downloaded_filter = new DownloadStatusFilterModel (src.DatabaseTrackModel);
             yield return feed_model = new PodcastFeedModel (src, src.DatabaseTrackModel, ServiceManager.DbConnection, String.Format ("PodcastFeeds-{0}", src.UniqueId));
 
             if (src == this) {
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Grid.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Grid.cs
new file mode 100644
index 0000000..6718e46
--- /dev/null
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/Grid.cs
@@ -0,0 +1,95 @@
+//
+// Grid.cs
+//
+// Author:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+using Mono.Unix;
+
+using Hyena;
+using Hyena.Data;
+using Hyena.Gui;
+using Hyena.Gui.Canvas;
+using Hyena.Data.Gui;
+
+using Banshee.Collection;
+using Banshee.Collection.Gui;
+
+using Banshee.Podcasting;
+using Banshee.Podcasting.Data;
+
+namespace Banshee.Podcasting.Gui
+{
+    public class Grid : BaseTrackListView
+    {
+        public Grid ()
+        {
+            var layout = new DataViewLayoutGrid () {
+                ChildAllocator = () => {
+                    return new StackPanel () {
+                        Margin = new Thickness (5),
+                        Width = 350,
+                        Height = 150,
+                        Spacing = 10,
+                        Children = {
+                            new DataViewChildImage (),
+                            new TextBlock () {
+                                UseMarkup = true,
+                                TextWrap = TextWrap.WordChar,
+                                TextGenerator = o => {
+                                    var track = o as TrackInfo;
+                                    if (track != null) {
+                                        var episode = PodcastTrackInfo.From (track);
+                                        if (episode != null) {
+                                            return "<b>{0}</b>\n<small>{1}\n{2}</small>".FormatEscaped (
+                                                track.DisplayTrackTitle, episode.PublishedDate.ToShortDateString (), episode.Description
+                                            );
+                                        }
+                                    }
+                                    return "";
+                                }
+                            }
+                        }
+                    };
+                },
+                View = this
+            };
+
+            ViewLayout = layout;
+        }
+
+        public void SetLibrary (PodcastSource library)
+        {
+            SetModel (library.TrackModel);
+        }
+
+        public override bool SelectOnRowFound {
+            get { return true; }
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/GridContent.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/GridContent.cs
new file mode 100644
index 0000000..1159bea
--- /dev/null
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/GridContent.cs
@@ -0,0 +1,101 @@
+//
+// AudiobookContent.cs
+//
+// Author:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2009 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+using Mono.Unix;
+using Gtk;
+
+using Hyena;
+using Hyena.Data;
+using Hyena.Data.Gui;
+
+using Banshee.Widgets;
+using Banshee.Sources;
+using Banshee.ServiceStack;
+using Banshee.Collection;
+using Banshee.Collection.Database;
+using Banshee.Collection.Gui;
+using Banshee.Gui;
+using Banshee.Gui.Widgets;
+using Banshee.Sources.Gui;
+using Banshee.Web;
+
+using Banshee.Podcasting;
+using Banshee.Podcasting.Data;
+
+namespace Banshee.Podcasting.Gui
+{
+    public class GridContent : ISourceContents
+    {
+        private PodcastSource library;
+        private Grid grid;
+        private ScrolledWindow sw;
+
+        public GridContent ()
+        {
+            sw = new ScrolledWindow ();
+            grid = new Grid ();
+            sw.Child = grid;
+            sw.ShowAll ();
+        }
+
+        public bool SetSource (ISource src)
+        {
+            if (src != null && src == library)
+                return true;
+
+            library = src as PodcastSource;
+            if (library == null) {
+                return false;
+            }
+
+            grid.SetLibrary (library);
+
+            // Not sure why this is needed
+            /*library.BooksModel.Reloaded += delegate {
+                grid.QueueDraw ();
+            };*/
+            return true;
+        }
+
+        public ISource Source {
+            get { return library; }
+        }
+
+        public void ResetSource ()
+        {
+            library = null;
+        }
+
+        public Widget Widget {
+            get { return sw; }
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/HeaderWidget.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/HeaderWidget.cs
new file mode 100644
index 0000000..da594a1
--- /dev/null
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/HeaderWidget.cs
@@ -0,0 +1,94 @@
+//
+// HeaderWidget.cs
+//
+// Author:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using Gtk;
+using Mono.Unix;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using Hyena;
+using Banshee.PlaybackController;
+using Banshee.Sources;
+using Banshee.Collection.Database;
+using Banshee.Widgets;
+
+namespace Banshee.Podcasting.Gui
+{
+    public class HeaderWidget : HBox
+    {
+        public HeaderWidget (PodcastSource source)
+        {
+            ThreadAssist.AssertInMainThread ();
+            Spacing = 6;
+
+            var podcast_label = new Label (Catalog.GetString ("_Limit to episodes from"));
+            var podcast_combo = new DictionaryComboBox<string> ();
+            podcast_combo.Add ("All Podcasts", "bar");
+            podcast_combo.Add ("Foo", "bar");
+            podcast_combo.Add ("Baz", "lkjer");
+            podcast_combo.Active = 0;
+
+            podcast_label.MnemonicWidget = podcast_combo;
+            //podcast_combo.Changed += OnModeComboChanged;
+
+            var new_check = new CheckButton ("new") { Active = true };
+            new_check.Toggled += (o, a) => {
+                source.NewFilter.Selection.Clear (false);
+                // HACK; 1 == new, 0 == both
+                source.NewFilter.Selection.Select (new_check.Active ? 1 : 0);
+            };
+
+            var downloaded_check = new CheckButton ("downloaded");
+            downloaded_check.Toggled += (o, a) => {
+                source.DownloadedFilter.Selection.Clear (false);
+                // HACK; 1 == downloaded, 0 == both
+                source.DownloadedFilter.Selection.Select (downloaded_check.Active ? 1 : 0);
+            };
+
+            PackStart (podcast_label, false, false, 0);
+            PackStart (podcast_combo, false, false, 0);
+            PackStart (new Label ("that are"), false, false, 0);
+            PackStart (new_check, false, false, 0);
+            PackStart (downloaded_check, false, false, 0);
+        }
+
+        /*private void OnModeComboChanged (object o, EventArgs args)
+        {
+            var random_by = mode_combo.ActiveValue;
+            foreach (var widget in sensitive_widgets) {
+                widget.Sensitive = random_by.Id != "off";
+            }
+
+            var handler = ModeChanged;
+            if (handler != null) {
+                handler (this, new EventArgs<RandomBy> (random_by));
+            }
+        }*/
+    }
+}
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
index 665cc8d..ab116aa 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
@@ -85,6 +85,9 @@ namespace Banshee.Podcasting.Gui
                 new ActionEntry("PodcastFeedPopupAction", null,
                     String.Empty, null, null, OnFeedPopup),
 
+                new ActionEntry("EpisodePodcastMenu", null,
+                    Catalog.GetString ("Podcast"), null, null, null),
+
                 new ActionEntry (
                     "PodcastDeleteAction", Stock.Delete,
                      Catalog.GetString ("Unsubscribe and Delete"),
diff --git a/src/Extensions/Banshee.Podcasting/Makefile.am b/src/Extensions/Banshee.Podcasting/Makefile.am
index 40d2893..3bb4a77 100644
--- a/src/Extensions/Banshee.Podcasting/Makefile.am
+++ b/src/Extensions/Banshee.Podcasting/Makefile.am
@@ -19,6 +19,9 @@ SOURCES =  \
 	Banshee.Podcasting.Gui/DownloadManager/DownloadManagerInterface.cs \
 	Banshee.Podcasting.Gui/DownloadManager/DownloadUserJob.cs \
 	Banshee.Podcasting.Gui/DownloadStatusFilterView.cs \
+	Banshee.Podcasting.Gui/Grid.cs \
+	Banshee.Podcasting.Gui/GridContent.cs \
+	Banshee.Podcasting.Gui/HeaderWidget.cs \
 	Banshee.Podcasting.Gui/Models/FilterableListModel.cs \
 	Banshee.Podcasting.Gui/Models/ListModel.cs \
 	Banshee.Podcasting.Gui/PodcastActions.cs \
diff --git a/src/Extensions/Banshee.Podcasting/Resources/ActiveSourceUI.xml b/src/Extensions/Banshee.Podcasting/Resources/ActiveSourceUI.xml
index c49ee17..c9ad56d 100644
--- a/src/Extensions/Banshee.Podcasting/Resources/ActiveSourceUI.xml
+++ b/src/Extensions/Banshee.Podcasting/Resources/ActiveSourceUI.xml
@@ -31,6 +31,14 @@
   <popup name="TrackContextMenu" action="TrackContextMenuAction">
     <placeholder name="BelowAddToPlaylist">
         <separator />
+        <menu action="EpisodePodcastMenu">
+            <menuitem name="PodcastUpdateFeed" action="PodcastUpdateFeedAction" />
+            <menuitem name="PodcastDownloadAll" action="PodcastDownloadAllAction"/>
+            <menuitem name="PodcastHomepage" action="PodcastHomepageAction" />
+            <menuitem name="PodcastDelete" action="PodcastDeleteAction" />
+            <separator />
+            <menuitem name="PodcastProperties" action="PodcastPropertiesAction" />
+        </menu>
         <menuitem name="PodcastItemLink" action="PodcastItemLinkAction" />
         <menuitem name="PodcastItemDownload" action="PodcastItemDownloadAction" />
         <menuitem name="PodcastItemDeleteFile" action="PodcastItemDeleteFileAction" />



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]