[banshee] [MiroGuide] Some misc cleanup



commit 30cc64d0e56f5c2101c8d1efbc2180a0f3c419a1
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Sat Jul 17 13:41:27 2010 -0700

    [MiroGuide] Some misc cleanup

 .../Banshee.MiroGuide/Banshee.MiroGuide.addin.xml  |    1 -
 .../Banshee.MiroGuide/Banshee.MiroGuide.csproj     |    2 +-
 .../Banshee.MiroGuide/MiroGuideSource.cs           |    2 +-
 .../{MiroGuideView.cs => View.cs}                  |   82 ++++++++++---------
 src/Extensions/Banshee.MiroGuide/Makefile.am       |    2 +-
 5 files changed, 46 insertions(+), 43 deletions(-)
---
diff --git a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide.addin.xml b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide.addin.xml
index 434ea21..2b90d37 100644
--- a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide.addin.xml
+++ b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide.addin.xml
@@ -19,5 +19,4 @@
   <Extension path="/Banshee/SourceManager/Source">
     <Source class="Banshee.MiroGuide.MiroGuideSource"/>
   </Extension>
-
 </Addin>
diff --git a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide.csproj b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide.csproj
index ac3337c..5de93bc 100644
--- a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide.csproj
+++ b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide.csproj
@@ -75,7 +75,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Banshee.MiroGuide\MiroGuideSource.cs" />
-    <Compile Include="Banshee.MiroGuide\MiroGuideView.cs" />
+    <Compile Include="Banshee.MiroGuide\View.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ProjectExtensions>
diff --git a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/MiroGuideSource.cs b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/MiroGuideSource.cs
index 1932fbe..f368b86 100644
--- a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/MiroGuideSource.cs
+++ b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/MiroGuideSource.cs
@@ -51,7 +51,7 @@ namespace Banshee.MiroGuide
 
         protected override Banshee.WebSource.WebBrowserShell GetWidget ()
         {
-            var view = new MiroGuideView ();
+            var view = new View ();
             var shell = new Banshee.WebSource.WebBrowserShell (Name, view);
             view.Shell = shell;
             view.UpdateSearchText ();
diff --git a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/MiroGuideView.cs b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/View.cs
similarity index 89%
rename from src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/MiroGuideView.cs
rename to src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/View.cs
index df647b8..6301c01 100644
--- a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/MiroGuideView.cs
+++ b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/View.cs
@@ -1,5 +1,5 @@
 //
-// MiroGuideView.cs
+// View.cs
 //
 // Authors:
 //   Aaron Bockover <abockover novell com>
@@ -41,20 +41,18 @@ using Banshee.WebBrowser;
 
 namespace Banshee.MiroGuide
 {
-    public class MiroGuideView : Banshee.WebSource.WebView
+    public class View : Banshee.WebSource.WebView
     {
-        public MiroGuideView ()
+        public View ()
         {
             CanSearch = true;
             FixupJavascriptUrl = "http://integrated-services.banshee.fm/miro/guide-fixups.js";;
             FullReload ();
         }
 
-        internal Banshee.WebSource.WebBrowserShell Shell { get; set; }
-
         public void UpdateSearchText ()
         {
-            Shell.SearchEntry.EmptyMessage = last_was_audio.Get ()
+            Shell.SearchEntry.EmptyMessage = LastPageWasAudio
                 ? Catalog.GetString ("Search for Podcasts")
                 : Catalog.GetString ("Search for Video Podcasts");
         }
@@ -62,7 +60,7 @@ namespace Banshee.MiroGuide
         protected override void OnLoadStatusChanged (OssiferLoadStatus status)
         {
             if (status == OssiferLoadStatus.Finished && Uri != null && Uri.StartsWith ("http://miroguide.com";)) {
-                last_was_audio.Set (Uri.Contains ("miroguide.com/audio/"));
+                LastPageWasAudio = Uri.Contains ("miroguide.com/audio/");
                 UpdateSearchText ();
             }
 
@@ -71,8 +69,6 @@ namespace Banshee.MiroGuide
 
         protected override OssiferNavigationResponse OnMimeTypePolicyDecisionRequested (string mimetype)
         {
-            // We only explicitly accept (render) text/html types, and only
-            // download audio/x-amzxml - everything else is ignored.
             switch (mimetype) {
                 case "application/x-miro": return OssiferNavigationResponse.Download;
                 default:                   return base.OnMimeTypePolicyDecisionRequested (mimetype);
@@ -106,6 +102,40 @@ namespace Banshee.MiroGuide
             return OssiferNavigationResponse.Unhandled;
         }
 
+
+        protected override void OnDownloadStatusChanged (OssiferDownloadStatus status, string mimetype, string destinationUri)
+        {
+            // FIXME: handle the error case
+            if (status != OssiferDownloadStatus.Finished) {
+                return;
+            }
+
+            switch (mimetype) {
+                case "application/x-miro":
+                    Log.Debug ("MiroGuide: downloaded Miro subscription file", destinationUri);
+                    ServiceManager.Get<DBusCommandService> ().PushFile (destinationUri);
+                    break;
+            }
+        }
+
+        public override void GoHome ()
+        {
+            var uri = LastPageWasAudio
+                ? "http://integrated-services.banshee.fm/miro/audio/home/";
+                : "http://integrated-services.banshee.fm/miro/video/home/";;
+
+            LoadUri (uri);
+        }
+
+        public override void GoSearch (string query)
+        {
+            var uri = LastPageWasAudio
+                ? "http://integrated-services.banshee.fm/miro/audio/search/";
+                : "http://integrated-services.banshee.fm/miro/video/search/";;
+
+            LoadUri (new Uri (uri + query).AbsoluteUri);
+        }
+
         // The download and add-to-sidebar buttons take the user to a page that then redirects to the
         // actual media URL or .miro OPML file.  But the URL to that redirection page contains all the
         // info we need to start downloading or subscribe immediately.
@@ -176,37 +206,11 @@ namespace Banshee.MiroGuide
             return ret;
         }
 
-        protected override void OnDownloadStatusChanged (OssiferDownloadStatus status, string mimetype, string destinationUri)
-        {
-            // FIXME: handle the error case
-            if (status != OssiferDownloadStatus.Finished) {
-                return;
-            }
-
-            switch (mimetype) {
-                case "application/x-miro":
-                    Log.Debug ("MiroGuide: downloaded Miro subscription file", destinationUri);
-                    ServiceManager.Get<DBusCommandService> ().PushFile (destinationUri);
-                    break;
-            }
-        }
-
-        public override void GoHome ()
-        {
-            if (last_was_audio.Get ()) {
-                LoadUri ("http://integrated-services.banshee.fm/miro/audio/home/";);
-            } else {
-                LoadUri ("http://integrated-services.banshee.fm/miro/video/home/";);
-            }
-        }
+        internal Banshee.WebSource.WebBrowserShell Shell { get; set; }
 
-        public override void GoSearch (string query)
-        {
-            if (last_was_audio.Get ()) {
-                LoadUri (new Uri ("http://integrated-services.banshee.fm/miro/audio/search/"; + query).AbsoluteUri);
-            } else {
-                LoadUri (new Uri ("http://integrated-services.banshee.fm/miro/video/search/"; + query).AbsoluteUri);
-            }
+        private bool LastPageWasAudio {
+            get { return last_was_audio.Get (); }
+            set { last_was_audio.Set (value); }
         }
 
         private static Banshee.Configuration.SchemaEntry<bool> last_was_audio = new Banshee.Configuration.SchemaEntry<bool> (
diff --git a/src/Extensions/Banshee.MiroGuide/Makefile.am b/src/Extensions/Banshee.MiroGuide/Makefile.am
index 263216b..e779749 100644
--- a/src/Extensions/Banshee.MiroGuide/Makefile.am
+++ b/src/Extensions/Banshee.MiroGuide/Makefile.am
@@ -5,7 +5,7 @@ LINK = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_BANSHEE_WEBBROWSER_DEPS)
 
 SOURCES = \
 	Banshee.MiroGuide/MiroGuideSource.cs \
-	Banshee.MiroGuide/MiroGuideView.cs
+	Banshee.MiroGuide/View.cs
 
 RESOURCES = \
 	Banshee.MiroGuide.addin.xml \



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