[banshee] [Podcasts] Fix ability to rename podcasts



commit 062039814e99cec7df9e6f03d0e4eba247944212
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Nov 27 18:20:51 2009 -0800

    [Podcasts] Fix ability to rename podcasts
    
    Renaming a podcast via its properties dialog is now supported, and won't
    be overwritten when the feed is next updated.  Also, it updates the
    Podcast column for all the podcast's episodes.

 .../Banshee.Podcasting.Data/PodcastSource.cs       |    2 ++
 .../Banshee.Podcasting.Data/PodcastTrackInfo.cs    |    4 ++++
 .../PodcastTrackListModel.cs                       |    5 +++++
 .../Banshee.Podcasting.Gui/PodcastActions.cs       |    5 ++++-
 .../Dialog/PodcastFeedPropertiesDialog.cs          |   16 ++++++++++++++--
 src/Libraries/Migo/Migo.Syndication/RssParser.cs   |    5 ++++-
 6 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs
index 787c762..6b18450 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs
@@ -128,6 +128,8 @@ namespace Banshee.Podcasting.Gui
                       <column modify-default=""AlbumColumn"">
                         <title>{0}</title>
                         <long-title>{0}</long-title>
+                        <sort-key>PodcastTitle</sort-key>
+                        <renderer property=""ExternalObject.PodcastTitle""/>
                       </column>
                       <column>
                           <visible>true</visible>
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
index 923f472..0f8c509 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
@@ -93,6 +93,10 @@ namespace Banshee.Podcasting.Data
             get { return Item.Feed; }
         }
 
+        public string PodcastTitle {
+            get { return Feed.Title; }
+        }
+
         private FeedItem item;
         public FeedItem Item {
             get {
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs
index 3884a50..73ee484 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs
@@ -92,6 +92,11 @@ namespace Banshee.Podcasting.Gui
                         PodcastItems.PubDate {0}", ascDesc);
                     break;
 
+                case "PodcastTitle":
+                    sort_query = String.Format (@"
+                        HYENA_COLLATION_KEY(PodcastSyndications.Title) {0}, PodcastItems.PubDate DESC", ascDesc);
+                    break;
+
                 case "IsNew":
                     sort_query = String.Format (@"
                         -PodcastItems.IsRead {0}, PodcastItems.PubDate DESC", ascDesc);
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
index 00fd7a3..abf1839 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
@@ -57,9 +57,12 @@ namespace Banshee.Podcasting.Gui
     {
         private uint actions_id;
         private DatabaseSource last_source;
+        private PodcastSource podcast_source;
 
         public PodcastActions (PodcastSource source) : base (ServiceManager.Get<InterfaceActionService> (), "Podcast")
         {
+            this.podcast_source = source;
+
             AddImportant (
                 new ActionEntry (
                     "PodcastUpdateAllAction", Stock.Refresh,
@@ -481,7 +484,7 @@ namespace Banshee.Podcasting.Gui
         {
             Feed feed = ActiveFeedModel.FocusedItem;
             if (feed != null) {
-                new PodcastFeedPropertiesDialog (feed).Run ();
+                new PodcastFeedPropertiesDialog (podcast_source, feed).Run ();
             }
         }
 
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Dialog/PodcastFeedPropertiesDialog.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Dialog/PodcastFeedPropertiesDialog.cs
index 3a30d04..c01e837 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Dialog/PodcastFeedPropertiesDialog.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Dialog/PodcastFeedPropertiesDialog.cs
@@ -40,12 +40,14 @@ namespace Banshee.Podcasting.Gui
 {
     internal class PodcastFeedPropertiesDialog : Dialog
     {
+        private PodcastSource source;
         private Feed feed;
         private SyncPreferenceComboBox new_episode_option_combo;
         private Entry name_entry;
 
-        public PodcastFeedPropertiesDialog (Feed feed)
+        public PodcastFeedPropertiesDialog (PodcastSource source, Feed feed)
         {
+            this.source = source;
             this.feed = feed;
 
             Title = feed.Title;
@@ -216,9 +218,19 @@ namespace Banshee.Podcasting.Gui
             if (args.ResponseId == Gtk.ResponseType.Ok) {
                 FeedAutoDownload new_sync_pref = new_episode_option_combo.ActiveSyncPreference;
 
-                if (feed.AutoDownload != new_sync_pref || feed.Title != name_entry.Text) {
+                bool changed = false;
+                if (feed.AutoDownload != new_sync_pref) {
                     feed.AutoDownload = new_sync_pref;
+                    changed = true;
+                }
+
+                if (feed.Title != name_entry.Text) {
                     feed.Title = name_entry.Text;
+                    source.Reload ();
+                    changed = true;
+                }
+
+                if (changed) {
                     feed.Save ();
                 }
             }
diff --git a/src/Libraries/Migo/Migo.Syndication/RssParser.cs b/src/Libraries/Migo/Migo.Syndication/RssParser.cs
index bd2112f..1877d73 100644
--- a/src/Libraries/Migo/Migo.Syndication/RssParser.cs
+++ b/src/Libraries/Migo/Migo.Syndication/RssParser.cs
@@ -91,7 +91,10 @@ namespace Migo.Syndication
         public Feed UpdateFeed (Feed feed)
         {
             try {
-                feed.Title            = StringUtil.RemoveNewlines (GetXmlNodeText (doc, "/rss/channel/title"));
+                if (feed.Title == null || feed.Title.Trim () == "" || feed.Title == Mono.Unix.Catalog.GetString ("Unknown Podcast")) {
+                    feed.Title = StringUtil.RemoveNewlines (GetXmlNodeText (doc, "/rss/channel/title"));
+                }
+
                 feed.Description      = StringUtil.RemoveNewlines (GetXmlNodeText (doc, "/rss/channel/description"));
                 feed.Copyright        = GetXmlNodeText (doc, "/rss/channel/copyright");
                 feed.ImageUrl         = GetXmlNodeText (doc, "/rss/channel/itunes:image/@href");



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