banshee r4789 - in trunk/banshee: . src/Dap/Banshee.Dap src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage src/Dap/Banshee.Dap/Banshee.Dap src/Dap/Banshee.Dap/Banshee.Dap.Gui src/Dap/Banshee.Dap/Resources



Author: abock
Date: Fri Nov  7 10:13:51 2008
New Revision: 4789
URL: http://svn.gnome.org/viewvc/banshee?rev=4789&view=rev

Log:
* banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/PurchasedMusicActions.cs:
  UI actions for IPurchasedMusicSource

* banshee/src/Dap/Banshee.Dap/Resources/PurchasedMusicSourceUI.xml: UI
  for importing purchased music

* banshee/src/Dap/Banshee.Dap/Banshee.Dap/IPurchasedMusicSource.cs:
  Interface for advertising that the purchased music UI should be
  connected

* banshee/src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs: If self
  implements IPurchasedMusicSource, connect that UI

* banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/AndroidDevice.cs:
  Implement IPurchasedMusicSource

Added:
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/PurchasedMusicActions.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/IPurchasedMusicSource.cs
   trunk/banshee/src/Dap/Banshee.Dap/Resources/PurchasedMusicSourceUI.xml
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/AndroidDevice.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.csproj
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs
   trunk/banshee/src/Dap/Banshee.Dap/Makefile.am

Modified: trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/AndroidDevice.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/AndroidDevice.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/AndroidDevice.cs	Fri Nov  7 10:13:51 2008
@@ -30,6 +30,7 @@
 using Mono.Unix;
 
 using Banshee.Hardware;
+using Banshee.Library;
 using Banshee.Collection.Database;
 
 namespace Banshee.Dap.MassStorage
@@ -63,10 +64,10 @@
         
         public override void SourceInitialize ()
         {
-            amazon_source = new AmazonMp3GroupSource (Source);
-            amazon_source.AutoHide = true;
-            
             amazon_base_dir = System.IO.Path.Combine (Source.Volume.MountPoint, audio_folders[1]);
+            
+            amazon_source = new AmazonMp3GroupSource (this, Source);
+            amazon_source.AutoHide = true;
         }
         
         public override bool LoadDeviceConfiguration ()
@@ -136,10 +137,15 @@
             return true;
         }
         
-        private class AmazonMp3GroupSource : MediaGroupSource
+        private class AmazonMp3GroupSource : MediaGroupSource, IPurchasedMusicSource
         {
-            public AmazonMp3GroupSource (DapSource parent) : base (parent, Catalog.GetString ("Purchased Music"))
+            private AndroidDevice android;
+            
+            public AmazonMp3GroupSource (AndroidDevice android, DapSource parent) 
+                : base (parent, Catalog.GetString ("Purchased Music"))
             {
+                this.android = android;
+                
                 Properties.SetString ("Icon.Name", "amazon-mp3-source");
                 ConditionSql = "(CoreTracks.Uri LIKE \"amazonmp3/%\")";
             }
@@ -156,6 +162,12 @@
                 active = false;
             }
             
+            public void Import ()
+            {
+                LibraryImportManager importer = new LibraryImportManager (true);
+                importer.Enqueue (android.amazon_base_dir);
+            }
+            
             private bool active;
             public bool Active {
                 get { return active; }

Added: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/PurchasedMusicActions.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/PurchasedMusicActions.cs	Fri Nov  7 10:13:51 2008
@@ -0,0 +1,69 @@
+//
+// PurchasedMusicActions.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 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 Mono.Unix;
+using Gtk;
+
+using Banshee.Dap;
+using Banshee.Gui;
+using Banshee.ServiceStack;
+
+namespace Banshee.Dap.Gui
+{
+    public class PurchasedMusicActions : BansheeActionGroup
+    {
+        private IPurchasedMusicSource source;
+        
+        public PurchasedMusicActions (IPurchasedMusicSource source) : base ("dap-purchased-music")
+        {
+            this.source = source;
+            
+            AddImportant (
+                new ActionEntry ("PurchasedMusicImportAction", null,
+                    Catalog.GetString ("Import Purchased Music"), null,
+                    null, OnImportPurchasedMusic)
+            );
+            
+            this["PurchasedMusicImportAction"].IconName = Stock.Save;
+            
+            Actions.AddActionGroup (this);
+        }
+        
+        public override void Dispose ()
+        {
+            Actions.RemoveActionGroup (this);
+            base.Dispose ();
+        }
+
+        private void OnImportPurchasedMusic (object o, EventArgs args)
+        {
+            source.Import ();
+        }
+    }
+}

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.csproj
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.csproj	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.csproj	Fri Nov  7 10:13:51 2008
@@ -73,6 +73,8 @@
     <Compile Include="Banshee.Dap.Gui\DapContent.cs" />
     <Compile Include="Banshee.Dap.Gui\DapActions.cs" />
     <Compile Include="Banshee.Dap\PodcastGroupSource.cs" />
+    <Compile Include="Banshee.Dap\IPurchasedMusicSource.cs" />
+    <Compile Include="Banshee.Dap.Gui\PurchasedMusicActions.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Banshee.Dap.addin.xml" />
@@ -82,6 +84,9 @@
     <EmbeddedResource Include="Resources\GlobalUI.xml">
       <LogicalName>GlobalUI.xml</LogicalName>
     </EmbeddedResource>
+    <EmbeddedResource Include="Resources\PurchasedMusicSourceUI.xml">
+      <LogicalName>PurchasedMusicSourceUI.xml</LogicalName>
+    </EmbeddedResource>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ProjectExtensions>

Added: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/IPurchasedMusicSource.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/IPurchasedMusicSource.cs	Fri Nov  7 10:13:51 2008
@@ -0,0 +1,37 @@
+//
+// IPurchasedMusicSource.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 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;
+
+namespace Banshee.Dap
+{
+    public interface IPurchasedMusicSource
+    {
+        void Import ();
+    }
+}

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/MediaGroupSource.cs	Fri Nov  7 10:13:51 2008
@@ -27,6 +27,7 @@
 //
 
 using System;
+using System.Reflection;
 
 using Mono.Unix;
 
@@ -36,11 +37,14 @@
 using Banshee.Collection;
 using Banshee.SmartPlaylist;
 
+using Banshee.Dap.Gui;
+
 namespace Banshee.Dap
 {
-    public abstract class MediaGroupSource : SmartPlaylistSource
+    public abstract class MediaGroupSource : SmartPlaylistSource, IDisposable
     {
         private DapSource parent;
+        private PurchasedMusicActions actions;
         
         public MediaGroupSource (DapSource parent, string name) : base (name, parent)
         {
@@ -51,6 +55,21 @@
             
             Properties.Set<string> ("DeleteTracksFromDriveActionLabel", 
                 String.Format (Catalog.GetString ("Delete From {0}"), parent.Name));
+                
+            if (this is IPurchasedMusicSource) {
+                actions = new PurchasedMusicActions ((IPurchasedMusicSource)this);
+                
+                Properties.Set<Assembly> ("ActiveSourceUIResource.Assembly", Assembly.GetExecutingAssembly ());
+                Properties.SetString ("ActiveSourceUIResource", "PurchasedMusicSourceUI.xml");
+            }
+        }
+        
+        public void Dispose ()
+        {
+            if (actions != null) {
+                actions.Dispose ();
+                actions = null;
+            }
         }
 
         protected override void AfterInitialized ()

Modified: trunk/banshee/src/Dap/Banshee.Dap/Makefile.am
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Makefile.am	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Makefile.am	Fri Nov  7 10:13:51 2008
@@ -9,11 +9,13 @@
 	Banshee.Dap.Gui/DapInfoBar.cs \
 	Banshee.Dap.Gui/DapPropertiesDialog.cs \
 	Banshee.Dap.Gui/DapPropertiesDisplay.cs \
+	Banshee.Dap.Gui/PurchasedMusicActions.cs \
 	Banshee.Dap/DapLibrarySync.cs \
 	Banshee.Dap/DapService.cs \
 	Banshee.Dap/DapSource.cs \
 	Banshee.Dap/DapSync.cs \
 	Banshee.Dap/InvalidDeviceException.cs \
+	Banshee.Dap/IPurchasedMusicSource.cs \
 	Banshee.Dap/MediaGroupSource.cs \
 	Banshee.Dap/MusicGroupSource.cs \
 	Banshee.Dap/PodcastGroupSource.cs \
@@ -23,7 +25,8 @@
 RESOURCES =  \
 	Banshee.Dap.addin.xml \
 	Resources/ActiveSourceUI.xml \
-	Resources/GlobalUI.xml
+	Resources/GlobalUI.xml \
+	Resources/PurchasedMusicSourceUI.xml
 
 include $(top_srcdir)/build/build.mk
 

Added: trunk/banshee/src/Dap/Banshee.Dap/Resources/PurchasedMusicSourceUI.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap/Resources/PurchasedMusicSourceUI.xml	Fri Nov  7 10:13:51 2008
@@ -0,0 +1,7 @@
+<ui>
+  <toolbar name="HeaderToolbar">
+    <placeholder name="SourceActions">
+      <toolitem name="PurchasedMusicImport" action="PurchasedMusicImportAction"/>
+    </placeholder>
+  </toolbar>
+</ui>



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