banshee r3657 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.ServiceStack src/Core/Banshee.Services/Banshee.Sources src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Resources src/Extensions/Banshee.Dap.MassStorage src/Extensions/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage



Author: gburt
Date: Thu Apr  3 21:52:50 2008
New Revision: 3657
URL: http://svn.gnome.org/viewvc/banshee?rev=3657&view=rev

Log:
2008-04-03  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs: Playlists
	and smart playlsits loaded by each PrimarySource now.

	* src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs: When loaded,
	load our playlists and smart playlists.

	* src/Core/Banshee.Services/Banshee.Sources/Source.cs: In AddChildSource
	check that we don't already have this child.

	* src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs: Hide the
	Remove and Delete actions unless CanRemove/Delete true.  Previously just
	set them insensitive.

	* src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml: Add
	RemovableSource context menu.

	* src/Extensions/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/RemovableSource.cs:
	Set the context menu action path property.  On dispose, clear children.
	And don't allow removing tracks (delete only).  Add Merge* foo from
	PlaylistSource, but not really hooked up yet.

	* src/Extensions/Banshee.Dap.MassStorage/Makefile.am: MD sorted.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
   trunk/banshee/src/Extensions/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/RemovableSource.cs
   trunk/banshee/src/Extensions/Banshee.Dap.MassStorage/Makefile.am

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs	Thu Apr  3 21:52:50 2008
@@ -66,23 +66,6 @@
             if (ServiceManager.SourceManager != null) {
                 ServiceManager.SourceManager.AddSource (new MusicLibrarySource (), true);
                 ServiceManager.SourceManager.AddSource (new VideoLibrarySource (), false);
-
-                foreach (PlaylistSource pl in PlaylistSource.LoadAll ()) {
-                    if (pl.PrimarySource != null) {
-                        pl.PrimarySource.AddChildSource (pl);
-                    } else {
-                        Console.WriteLine ("Loading playlist {0} with ps id {1}, ps is null {2}", pl.Name, pl.PrimarySourceId, pl.PrimarySource == null);
-                    }
-                }
-
-                foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll ()) {
-                    if (pl.PrimarySource != null) {
-                        pl.PrimarySource.AddChildSource (pl);
-                    } else {
-                        Console.WriteLine ("Loading playlist {0} with ps id {1}, ps is null {2}", pl.Name, pl.PrimarySourceId, pl.PrimarySource == null);
-                    }
-                }
-
                 ServiceManager.SourceManager.LoadExtensionSources ();
             }
             

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs	Thu Apr  3 21:52:50 2008
@@ -38,6 +38,8 @@
 using Banshee.Base;
 using Banshee.ServiceStack;
 using Banshee.Sources;
+using Banshee.Playlist;
+using Banshee.SmartPlaylist;
 using Banshee.Collection;
 using Banshee.Collection.Database;
 using Banshee.Query;
@@ -119,6 +121,15 @@
             track_model.Condition = String.Format ("CoreTracks.PrimarySourceID = {0}", dbid);
 
             primary_sources[dbid] = this;
+            
+            
+            foreach (PlaylistSource pl in PlaylistSource.LoadAll ())
+                if (pl.PrimarySourceId == dbid)
+                    AddChildSource (pl);
+
+            foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll ())
+                if (pl.PrimarySourceId == dbid)
+                    AddChildSource (pl);
         }
 
         internal void NotifyTracksAdded ()

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs	Thu Apr  3 21:52:50 2008
@@ -143,9 +143,11 @@
         public virtual void AddChildSource (Source child)
         {
             lock (Children) {
-                child.SetParentSource (this);
-                child_sources.Add (child);
-                OnChildSourceAdded (child);
+                if (!child_sources.Contains (child)) {
+                    child.SetParentSource (this);
+                    child_sources.Add (child);
+                    OnChildSourceAdded (child);
+                }
             }
         }
 
@@ -159,7 +161,7 @@
                 child_sources.Remove (child);
                 
                 if (ServiceManager.SourceManager.ActiveSource == child) {
-                    ServiceManager.SourceManager.SetActiveSource (ServiceManager.SourceManager.DefaultSource);
+                    ServiceManager.SourceManager.SetActiveSource (this);
                 }
                 
                 OnChildSourceRemoved (child);

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs	Thu Apr  3 21:52:50 2008
@@ -218,14 +218,8 @@
                        "SearchMenuAction", "SearchForSameArtistAction", "SearchForSameAlbumAction"
                     );
 
-                    UpdateAction ("RemoveTracksAction", is_track_source,
-                        has_selection && is_track_source && track_source.CanRemoveTracks, source
-                    );
-
-                    UpdateAction ("DeleteTracksFromDriveAction", is_track_source,
-                        has_selection && is_track_source && track_source.CanDeleteTracks, source
-                    );
-
+                    UpdateAction ("RemoveTracksAction", is_track_source && track_source.CanRemoveTracks, has_selection, source);
+                    UpdateAction ("DeleteTracksFromDriveAction", is_track_source && track_source.CanDeleteTracks, has_selection && is_track_source , source);
                     UpdateAction ("RemoveTracksFromLibraryAction", source.Parent is LibrarySource, has_selection, null);
                     
                     UpdateAction ("TrackPropertiesAction", in_database, has_selection, null);

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml	Thu Apr  3 21:52:50 2008
@@ -113,6 +113,24 @@
     </menu>
   </popup>
 
+  <popup name="RemovableSourceContextMenu" action="RemovableSourceContextMenuAction">
+    <menuitem name="NewPlaylist" action="NewPlaylistAction"/>
+    <menuitem name="NewSmartPlaylist" action="NewSmartPlaylistAction"/>
+    <separator/>
+    <menu name="SortChildren" action="SortChildrenAction">
+      <menuitem name="SortChildrenNameAsc" action="SortChildrenNameAscAction"/>
+      <menuitem name="SortChildrenNameDesc" action="SortChildrenNameDescAction"/>
+      <menuitem name="SortChildrenSizeAsc" action="SortChildrenSizeAscAction"/>
+      <menuitem name="SortChildrenSizeDesc" action="SortChildrenSizeDescAction"/>
+    </menu>
+    <separator/>
+    <menuitem name="ImportSource" action="ImportSourceAction"/>
+    <menuitem name="RenameSource" action="RenameSourceAction"/>
+    <menuitem name="UnmapSource" action="UnmapSourceAction"/>
+    <separator/>
+    <menuitem name="SourceProperties" action="SourcePropertiesAction"/>
+  </popup>
+
   <popup name="ErrorSourceContextMenu" action="ErrorSourceContextMenuAction">
     <menuitem name="UnmapSource" action="UnmapSourceAction"/>
   </popup>
@@ -124,7 +142,6 @@
     <menuitem name="RefreshSmartPlaylist" action="RefreshSmartPlaylistAction"/>
     <menuitem name="ExportPlaylist" action="ExportPlaylistAction"/>
     <menuitem name="UnmapSource" action="UnmapSourceAction"/>
-    <!--<menuitem name="SyncDap" action="SyncDapAction"/>-->
     <separator/>
     <menuitem name="SourceProperties" action="SourcePropertiesAction"/>
   </popup>

Modified: trunk/banshee/src/Extensions/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/RemovableSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/RemovableSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/RemovableSource.cs	Thu Apr  3 21:52:50 2008
@@ -48,6 +48,7 @@
             Name = name;
 
             Properties.SetString ("UnmapSourceActionIconName", "media-eject");
+            Properties.SetString ("GtkActionPath", "/RemovableSourceContextMenu");
             AfterInitialized ();
         }
 
@@ -62,11 +63,12 @@
 
         public void Dispose ()
         {
+            ClearChildSources ();
             ServiceManager.SourceManager.RemoveSource (this);
         }
         
         public override bool CanRemoveTracks {
-            get { return !IsReadOnly; }
+            get { return false; }
         }
 
         public override bool CanDeleteTracks {
@@ -77,6 +79,40 @@
             get { return (double)device.StorageUsed / (double)device.StorageCapacity; }
         }*/
 
+#region Source Overrides
+
+        public override bool AcceptsInputFromSource (Source source)
+        {
+            // TODO: Probably should be more restrictive than this
+            return source is DatabaseSource;
+        }
+        
+        public override void MergeSourceInput (Source from, SourceMergeType mergeType)
+        {
+            DatabaseSource source = from as DatabaseSource;
+            if (source == null || !(source.TrackModel is TrackListDatabaseModel)) {
+                return;
+            }
+            
+            //TrackListDatabaseModel model = (TrackListDatabaseModel)source.TrackModel;
+            
+            switch (mergeType) {
+                case SourceMergeType.ModelSelection:
+                    //AddSelectedTracks (model);
+                    break;
+                case SourceMergeType.Source:
+                    //AddTrackRange (model, new RangeCollection.Range (0, model.Count));
+                    Reload ();
+                    break;
+            }
+        }
+        
+        public override SourceMergeType SupportedMergeTypes {
+            get { return IsReadOnly ? SourceMergeType.None : SourceMergeType.All; }
+        }
+
+#endregion
+
 #region IUnmapableSource Implementation
 
         public bool Unmap ()
@@ -107,8 +143,9 @@
             return true;
         }
 
+        private bool syncing = false;
         public bool CanUnmap {
-            get { return true; }
+            get { return !syncing; }
         }
 
         public bool ConfirmBeforeUnmap {

Modified: trunk/banshee/src/Extensions/Banshee.Dap.MassStorage/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Dap.MassStorage/Makefile.am	(original)
+++ trunk/banshee/src/Extensions/Banshee.Dap.MassStorage/Makefile.am	Thu Apr  3 21:52:50 2008
@@ -3,10 +3,10 @@
 LINK = $(REF_EXTENSION_DAP_MASS_STORAGE)
 INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
 
-SOURCES = \
-	Banshee.Dap.MassStorage/MassStorageSource.cs \
+SOURCES =  \
 	Banshee.Dap.MassStorage/DapService.cs \
 	Banshee.Dap.MassStorage/DapSource.cs \
+	Banshee.Dap.MassStorage/MassStorageSource.cs \
 	Banshee.Dap.MassStorage/RemovableSource.cs
 
 RESOURCES = Banshee.Dap.MassStorage.addin.xml



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