banshee r3145 - in trunk/banshee: . src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.Sources src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Core/Hyena.Gui/Hyena.Gui.Theatrics



Author: abock
Date: Mon Feb  4 23:17:04 2008
New Revision: 3145
URL: http://svn.gnome.org/viewvc/banshee?rev=3145&view=rev

Log:
2008-02-04  Aaron Bockover  <abock gnome org>

    This commit adds source merge behavior and the ability to drag and drop
    sources in the source view; i.e. drag the play queue to a new playlist
    to save it

    * src/Core/Banshee.Services/Banshee.Sources/Source.cs:
    * src/Core/Banshee.Services/Banshee.Sources/SourceMergeType.cs:
    Added some stuff to advertise how sources can interact with eachother;
    concept of merging sources into sources

    * src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs:
    * src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs:
    Implement merge behaviors

    * src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs:
    Finished the drag and drop support for the source view internally

    * src/Core/Hyena.Gui/Hyena.Gui.Theatrics/SingleActorStage.cs: Override
    OnActorStep so that single actor stages work again

    * src/Core/Hyena.Gui/Hyena.Gui.Theatrics/Stage.cs: Nuke ugly writeline



Added:
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceMergeType.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
   trunk/banshee/src/Core/Banshee.Services/Makefile.am
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs
   trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/SingleActorStage.cs
   trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/Stage.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs	Mon Feb  4 23:17:04 2008
@@ -177,6 +177,20 @@
             }
         }
         
+        public override bool AcceptsInputFromSource (Source source)
+        {
+            return source is IImportSource;
+        }
+
+        public override void MergeSourceInput (Source source, SourceMergeType mergeType)
+        {
+            if (!(source is IImportSource) || mergeType != SourceMergeType.Source) {
+                return;
+            }
+            
+            ((IImportSource)source).Import ();
+        }
+        
         public ErrorSource ErrorSource {
             get { return error_source; }
         }

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	Mon Feb  4 23:17:04 2008
@@ -122,14 +122,28 @@
             return source is DatabaseSource;
         }
         
-        public override void MergeSourceInput (Source from, bool selected)
+        public override void MergeSourceInput (Source from, SourceMergeType mergeType)
         {
             DatabaseSource source = from as DatabaseSource;
             if (source == null || !(source.TrackModel is TrackListDatabaseModel)) {
                 return;
             }
             
-            AddSelectedTracks ((TrackListDatabaseModel)source.TrackModel);
+            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 SourceMergeType.All; }
         }
 
 #endregion

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	Mon Feb  4 23:17:04 2008
@@ -118,8 +118,8 @@
     <File name="Banshee.Sources/IDurationAggregator.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Sources/IFileSizeAggregator.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.ServiceStack/IExtensionService.cs" subtype="Code" buildaction="Compile" />
-    <File name="Banshee.Configuration" subtype="Directory" buildaction="Compile" />
     <File name="Banshee.Configuration/DatabaseConfigurationClient.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Sources/SourceMergeType.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

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	Mon Feb  4 23:17:04 2008
@@ -108,11 +108,15 @@
             return false;
         }
         
-        public virtual void MergeSourceInput (Source source, bool selection)
+        public virtual void MergeSourceInput (Source source, SourceMergeType mergeType)
         {
             throw new NotImplementedException ();
         }
         
+        public virtual SourceMergeType SupportedMergeTypes {
+            get { return SourceMergeType.None; }
+        }
+        
         public void SetParentSource (Source parent)
         {
             this.parent = parent;

Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceMergeType.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceMergeType.cs	Mon Feb  4 23:17:04 2008
@@ -0,0 +1,41 @@
+//
+// SourceMergeType.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.Sources
+{
+    [Flags]
+    public enum SourceMergeType
+    {
+        None = (0 << 0),
+        Source = (1 << 0),
+        ModelSelection = (1 << 1),
+        All = (Source | ModelSelection)
+    }
+}

Modified: trunk/banshee/src/Core/Banshee.Services/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Makefile.am	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Makefile.am	Mon Feb  4 23:17:04 2008
@@ -110,6 +110,7 @@
 	Banshee.Sources/IUnmapableSource.cs \
 	Banshee.Sources/Source.cs \
 	Banshee.Sources/SourceManager.cs \
+	Banshee.Sources/SourceMergeType.cs \
 	Banshee.Streaming/RadioTrackInfo.cs \
 	Banshee.Web/Browser.cs
 

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	Mon Feb  4 23:17:04 2008
@@ -32,6 +32,7 @@
 using Gtk;
 using Gdk;
 
+using Banshee.Sources;
 using Banshee.ServiceStack;
 using Banshee.Collection;
 using Banshee.Playlist;
@@ -47,6 +48,7 @@
         };
             
         private static TargetEntry [] dnd_dest_entries = new TargetEntry [] {
+            Banshee.Gui.DragDrop.DragDropTarget.Source,
             Banshee.Gui.DragDrop.DragDropTarget.ModelSelection
         };
         
@@ -58,16 +60,20 @@
             EnableModelDragSource (Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
                 dnd_source_entries, DragAction.Copy | DragAction.Move);
         
-            EnableModelDragDest (dnd_dest_entries, DragAction.Copy | DragAction.Move);
+            EnableModelDragDest (dnd_dest_entries, DragAction.Copy | DragAction.Copy);
         }
         
         protected override bool OnDragMotion (Gdk.DragContext context, int x, int y, uint time)
         {
-            base.OnDragMotion (context, x, y, time);
-            SetDragDestRow (null, TreeViewDropPosition.IntoOrAfter);
-            Gdk.Drag.Status (context, Gdk.DragAction.Copy, time);
-        
-            if (!new_playlist_visible && Gtk.Drag.GetSourceWidget (context) != this) {
+            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 && 
+                new_playlist_source.AcceptsInputFromSource (active_source) &&
+                ((self_drag && active_source.SupportedMergeTypes != SourceMergeType.None) || !self_drag)) {
                 TreeIter library = FindSource (ServiceManager.SourceManager.DefaultSource);
                 new_playlist_iter = store.AppendNode (library);
                 store.SetValue (new_playlist_iter, 0, new_playlist_source);
@@ -77,24 +83,24 @@
                 UpdateView ();
                 Expand (library);
             }
-        
-            TreePath path;
-            TreeViewDropPosition pos;
             
             if (!GetDestRowAtPos (x, y, out path, out pos)) {
                 Gdk.Drag.Status (context, 0, time);
-                return true;
+                return false;
             }
             
             Source drop_source = GetSource (path);
-            Source active_source = ServiceManager.SourceManager.ActiveSource;
-
-            if (drop_source == null || drop_source == active_source 
-                || !drop_source.AcceptsInputFromSource (active_source)) {
+         
+            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;
             }
 
             SetDragDestRow (path, TreeViewDropPosition.IntoOrAfter);
+            Gdk.Drag.Status (context, Gdk.DragAction.Copy, time);
+            
             return true;
         }
         
@@ -121,8 +127,13 @@
         protected override void OnDragDataReceived (Gdk.DragContext context, int x, int y,
             Gtk.SelectionData selectionData, uint info, uint time)
         {
-            if (final_drag_start_time == context.StartTime && final_drag_source != null) {
-                Source drop_source = final_drag_source;
+            try {
+                if (final_drag_start_time != context.StartTime || final_drag_source == null) {
+                    Gtk.Drag.Finish (context, false, false, time);
+                    return;
+                }
+                
+                Source drop_source = final_drag_source;    
                 
                 if (final_drag_source == new_playlist_source) {
                     PlaylistSource playlist = new PlaylistSource ("New Playlist");
@@ -131,43 +142,29 @@
                     drop_source = playlist;
                 }
                 
-                drop_source.MergeSourceInput (ServiceManager.SourceManager.ActiveSource, true);
-            }
-            
-            if (new_playlist_visible) {
-                store.Remove (ref new_playlist_iter);
-                new_playlist_visible = false;
-                UpdateView ();
-            }
-        
-            Gtk.Drag.Finish (context, true, false, time);
-            
-            /*if(Gtk.Drag.GetSourceWidget(context) == this) {
-                DragDropList<Source> sources = selectionData;
-                if(sources.Count <= 0) { 
-                    return;
+                if (Gtk.Drag.GetSourceWidget (context) == this) {
+                    DragDropList<Source> sources = selectionData;
+                    if(sources.Count > 0) {
+                        drop_source.MergeSourceInput (sources[0], SourceMergeType.Source);
+                    }
+                } else {   
+                    drop_source.MergeSourceInput (ServiceManager.SourceManager.ActiveSource, 
+                        SourceMergeType.ModelSelection);
                 }
                 
-                Source source = sources[0];
-                
-                if(source is IImportSource && final_drag_source is LibrarySource) {
-                    (source as IImportSource).Import();
-                    Gtk.Drag.Finish(context, true, false, time);
-                } else if(final_drag_source != null && source.IsDragSource && 
-                    final_drag_source.AcceptsSourceDrop) {
-                    final_drag_source.SourceDrop(source);
-                    Gtk.Drag.Finish(context, true, false, time);
-                } else {
-                    Gtk.Drag.Finish(context, false, false, time);
+                Gtk.Drag.Finish (context, true, false, time);
+            } finally {
+                 if (new_playlist_visible) {
+                    store.Remove (ref new_playlist_iter);
+                    new_playlist_visible = false;
+                    UpdateView ();
                 }
-                
-                return;
-            }*/
+            }
         }
                 
-        /*protected override void OnDragBegin (Gdk.DragContext context)
+        protected override void OnDragBegin (Gdk.DragContext context)
         {
-            if (HighlightedSource.IsDragSource || HighlightedSource is IImportSource) {
+            if (ServiceManager.SourceManager.ActiveSource.SupportedMergeTypes != SourceMergeType.None) {
                 base.OnDragBegin (context);
             }
         }
@@ -177,13 +174,14 @@
         {
             switch ((DragDropTargetType)info) {
                 case DragDropTargetType.Source:
-                    new DragDropList<Source> (HighlightedSource, selectionData, context.Targets[0]);
+                    new DragDropList<Source> (ServiceManager.SourceManager.ActiveSource, 
+                        selectionData, context.Targets[0]);
                     break;
                 default:
                     return;
             }
             
             base.OnDragDataGet (context, selectionData, info, time);
-        }*/
+        }
     }
 }

Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/SingleActorStage.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/SingleActorStage.cs	(original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/SingleActorStage.cs	Mon Feb  4 23:17:04 2008
@@ -42,6 +42,11 @@
         {
         }
         
+        protected override bool OnActorStep (Actor<object> actor)
+        {
+            return true;
+        }
+        
         public void Reset ()
         {
             AddOrReset (target);

Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/Stage.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/Stage.cs	(original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/Stage.cs	Mon Feb  4 23:17:04 2008
@@ -146,7 +146,6 @@
                 entry.Value.Step ();
                 
                 if (!OnActorStep (entry.Value) || entry.Value.Expired) {
-                    Console.WriteLine ("EXPIRED");
                     expired_actors.Enqueue (entry.Value);
                 }
             }



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