banshee r3728 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.Sources src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue



Author: gburt
Date: Wed Apr  9 20:50:34 2008
New Revision: 3728
URL: http://svn.gnome.org/viewvc/banshee?rev=3728&view=rev

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

	* src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs:
	* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs: Fix issue
	with reloading way too many things when adding tracks to a source.

	* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs:
	Fix issues with the 'New Playlist' that appears when you drag over the
	source list.  It now will appear under any LibrarySource when you hover
	over it or its children.  And it will only expand the LibrarySource when
	within it, and collapse it when out of it (if it was collapsed to start
	with).

	* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs:
	When items are added to the play queue and the PlayerEngine is not already
	playing, set us as the playback source.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs
   trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs	Wed Apr  9 20:50:34 2008
@@ -237,7 +237,6 @@
         {
             if (Parent == null || source == Parent || source.Parent == Parent) {
                 base.AddSelectedTracks (source);
-                Reload ();
             /*} else {
                 // Adding from a different primary source, so add to our primary source first
                 PrimarySource primary = Parent as PrimarySource;

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	Wed Apr  9 20:50:34 2008
@@ -250,10 +250,7 @@
 
         protected virtual void OnTracksAdded ()
         {
-            HandleTracksAdded (this, new TrackEventArgs ());
-            foreach (PrimarySource psource in PrimarySources) {
-                psource.NotifyTracksAdded ();
-            }
+            Reload ();
         }
 
         protected void OnTracksChanged ()

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs	Wed Apr  9 20:50:34 2008
@@ -35,6 +35,7 @@
 using Gdk;
 
 using Banshee.Sources;
+using Banshee.Library;
 using Banshee.ServiceStack;
 using Banshee.Collection;
 using Banshee.Playlist;
@@ -69,67 +70,88 @@
             EnableModelDragDest (dnd_dest_entries, DragAction.Copy | DragAction.Copy);
         }
         
-        private void HideNewPlaylistRow ()
+        protected override bool OnDragMotion (Gdk.DragContext context, int x, int y, uint time)
         {
-            if (!new_playlist_visible) {
-                return;
+            TreePath path;
+            TreeViewDropPosition pos;
+            Source active_source = ServiceManager.SourceManager.ActiveSource;
+            
+            if (!GetDestRowAtPos (x, y, out path, out pos)) {
+                Gdk.Drag.Status (context, 0, time);
+                return false;
             }
             
-            store.Remove (ref new_playlist_iter);
-            new_playlist_visible = false;
+            Source drop_source = GetSource (path);
+            Source parent_source = drop_source as LibrarySource ?? drop_source.Parent as LibrarySource;
+
+            // Scroll if within 20 pixels of the top or bottom
+            if (y < 20)
+                Vadjustment.Value -= 30;
+            else if ((Allocation.Height - y) < 20)
+                Vadjustment.Value += 30;
+
+            if (parent_source != null) {
+                ShowNewPlaylistUnder (parent_source);
+            } else if (drop_source != NewPlaylistSource) {
+                HideNewPlaylistRow ();
+            }
+
+            if (!drop_source.AcceptsInputFromSource (active_source)) {
+                Gdk.Drag.Status (context, 0, time);
+                return true;
+            }
+
+            SetDragDestRow (path, TreeViewDropPosition.IntoOrAfter);
+
+            bool move = (active_source is LibrarySource) && (drop_source is LibrarySource);
+            Gdk.Drag.Status (context, move ? Gdk.DragAction.Move : Gdk.DragAction.Copy, time);
             
-            UpdateView ();
+            return true;
         }
-        
-        private void ShowNewPlaylistRow ()
+
+        Source new_playlist_parent = null;
+        bool parent_was_expanded;
+        private void ShowNewPlaylistUnder (Source parent)
         {
             if (new_playlist_visible) {
-                return;
+                if (parent == new_playlist_parent)
+                    return;
+                else
+                    HideNewPlaylistRow ();
             }
-            
-            TreeIter library = FindSource (ServiceManager.SourceManager.DefaultSource);
-            new_playlist_iter = store.AppendNode (library);
+
+            TreeIter parent_iter = FindSource (parent);
+            new_playlist_iter = store.AppendNode (parent_iter);
             
             store.SetValue (new_playlist_iter, 0, NewPlaylistSource);
             store.SetValue (new_playlist_iter, 1, 999);
             new_playlist_visible = true;
 
             UpdateView ();
-            Expand (library);
+
+            TreePath parent_path = store.GetPath (parent_iter);
+            parent_was_expanded = GetRowExpanded (parent_path);
+            Expand (parent_iter);
+
+            new_playlist_parent = parent;
         }
-        
-        protected override bool OnDragMotion (Gdk.DragContext context, int x, int y, uint time)
+
+        private void HideNewPlaylistRow ()
         {
-            TreePath path;
-            TreeViewDropPosition pos;
-            Source active_source = ServiceManager.SourceManager.ActiveSource;
-            
-            bool self_drag = Gtk.Drag.GetSourceWidget (context) == this;
-            
-            if (!new_playlist_visible && active_source != null && 
-                NewPlaylistSource.AcceptsInputFromSource (active_source) &&
-                ((self_drag && active_source.SupportedMergeTypes != SourceMergeType.None) || !self_drag)) {
-                ShowNewPlaylistRow ();
-            }
-            
-            if (!GetDestRowAtPos (x, y, out path, out pos)) {
-                Gdk.Drag.Status (context, 0, time);
-                return false;
+            if (!new_playlist_visible) {
+                return;
             }
             
-            Source drop_source = GetSource (path);
-         
-            if (drop_source == null || drop_source == active_source || active_source == null ||
-                (self_drag && active_source.SupportedMergeTypes == SourceMergeType.None) ||
-                !drop_source.AcceptsInputFromSource (active_source)) {
-                Gdk.Drag.Status (context, 0, time);
-                return false;
+            if (!parent_was_expanded) {
+                TreeIter iter = FindSource (new_playlist_parent);
+                TreePath path = store.GetPath (iter);
+                CollapseRow (path);
             }
 
-            SetDragDestRow (path, TreeViewDropPosition.IntoOrAfter);
-            Gdk.Drag.Status (context, Gdk.DragAction.Copy, time);
+            store.Remove (ref new_playlist_iter);
+            new_playlist_visible = false;
             
-            return true;
+            UpdateView ();
         }
         
         protected override void OnDragLeave (Gdk.DragContext context, uint time)
@@ -167,9 +189,9 @@
                 Source drop_source = final_drag_source;    
                 
                 if (final_drag_source == NewPlaylistSource) {
-                    PlaylistSource playlist = new PlaylistSource ("New Playlist", ServiceManager.SourceManager.MusicLibrary.DbId);
+                    PlaylistSource playlist = new PlaylistSource ("New Playlist", (new_playlist_parent as PrimarySource).DbId);
                     playlist.Save ();
-                    ServiceManager.SourceManager.DefaultSource.AddChildSource (playlist);
+                    playlist.PrimarySource.AddChildSource (playlist);
                     drop_source = playlist;
                 }
                 

Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	Wed Apr  9 20:50:34 2008
@@ -107,11 +107,16 @@
             ServiceManager.SourceManager.VideoLibrary.TracksChanged += HandleTracksChanged;
             ServiceManager.SourceManager.VideoLibrary.TracksDeleted += HandleTracksDeleted;
 
+            SetAsPlayingSource ();
+        }
+        
+        private void SetAsPlayingSource ()
+        {
             if (Count > 0 && ServiceManager.PlayerEngine.CurrentState != PlayerEngineState.Playing) {
                 ServiceManager.PlaybackController.Source = this;
             }
         }
-        
+
         public void Dispose ()
         {
             if (ClearOnQuitSchema.Get ()) {
@@ -134,6 +139,12 @@
                 ", special_playlist_name));
             }
         }
+
+        protected override void OnTracksAdded ()
+        {
+            base.OnTracksAdded ();
+            SetAsPlayingSource ();
+        }
         
         protected override void OnUpdated ()
         {
@@ -163,6 +174,7 @@
         private void OnAddToPlayQueue (object o, EventArgs args)
         {
             AddSelectedTracks (ServiceManager.SourceManager.ActiveSource);
+            OnUserNotifyUpdated ();
         }
         
         private void OnClearPlayQueue (object o, EventArgs args)



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