banshee r3477 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Database src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.ServiceStack src/Core/Banshee.Services/Banshee.SmartPlaylist src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Core/Banshee.ThickClient/Resources src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue



Author: gburt
Date: Tue Mar 18 21:42:29 2008
New Revision: 3477
URL: http://svn.gnome.org/viewvc/banshee?rev=3477&view=rev

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

	This commit makes it easy/possible to create playlists and smart playlists
	on any PrimarySource.

	* src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs:
	* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
	Add PrimarySourceID column to Core[Smart]Playlists.

	* src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs:
	* src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs:
	Load and save PrimarySourceID.

	* src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs:
	* src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistCore.cs:
	Handle loading smart playlists from various primary sources.

	* src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs:

	* src/Core/Banshee.ThickClient/Resources/banshee-dialogs.glade:
	* src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs: Change Music
	to Media where appropriate.

	* src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs:
	* src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs:
	* src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs:
	* src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs: When creating
	new playlists, create them with the correct primary source.

	* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs:
	* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs:
	This needs to be fixed up - the 'New Playlist' playlist that appears when
	you drag tracks over the SourceView only displays for the Music Library
	atm.

	* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs:
	Update to new PlaylistSource ctor.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistCore.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Resources/banshee-dialogs.glade
   trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	Tue Mar 18 21:42:29 2008
@@ -61,7 +61,7 @@
         // NOTE: Whenever there is a change in ANY of the database schema,
         //       this version MUST be incremented and a migration method
         //       MUST be supplied to match the new version number
-        protected const int CURRENT_VERSION = 2;
+        protected const int CURRENT_VERSION = 3;
         
         protected class DatabaseVersionAttribute : Attribute 
         {
@@ -245,6 +245,17 @@
                 (int)TrackMediaAttributes.Default));
             return true;
         }
+
+        [DatabaseVersion (3)]
+        private bool Migrate_3 ()
+        {
+            Execute ("ALTER TABLE CorePlaylists ADD COLUMN PrimarySourceID INTEGER");
+            Execute ("UPDATE CorePlaylists SET PrimarySourceID = 1");
+
+            Execute ("ALTER TABLE CoreSmartPlaylists ADD COLUMN PrimarySourceID INTEGER");
+            Execute ("UPDATE CoreSmartPlaylists SET PrimarySourceID = 1");
+            return true;
+        }
         
 #pragma warning restore 0169
         

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs	Tue Mar 18 21:42:29 2008
@@ -104,17 +104,28 @@
             }
         }
 
+        protected int primary_source_id;
+        public int PrimarySourceId {
+            get { return primary_source_id; }
+        }
+
+        public PrimarySource PrimarySource {
+            get { return PrimarySource.GetById (primary_source_id); }
+            set { primary_source_id = value.DbId; }
+        }
+
         protected HyenaSqliteCommand count_updated_command;
         protected HyenaSqliteCommand count_removed_command;
 
-        public AbstractPlaylistSource (string generic_name, string name) 
-            : this (generic_name, name, null, -1, 0)
+        public AbstractPlaylistSource (string generic_name, string name, int primarySourceId)
+            : this (generic_name, name, null, -1, 0, primarySourceId)
         {
         }
 
-        public AbstractPlaylistSource (string generic_name, string name, int? dbid, int sortColumn, int sortType) 
+        public AbstractPlaylistSource (string generic_name, string name, int? dbid, int sortColumn, int sortType, int primarySourceId)
             : base (generic_name, name, Convert.ToString (dbid), 500)
         {
+            this.primary_source_id = primarySourceId;
         }
 
         public override void Rename (string newName)

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistFileUtil.cs	Tue Mar 18 21:42:29 2008
@@ -9,6 +9,7 @@
 
 using Banshee.Base;
 using Banshee.Configuration;
+using Banshee.ServiceStack;
 using Banshee.Database;
 using Banshee.Sources;
 using Banshee.Library;
@@ -171,7 +172,7 @@
         
         private void CreatePlaylist ()
         {
-            PlaylistSource playlist = new PlaylistSource (name);
+            PlaylistSource playlist = new PlaylistSource (name, ServiceManager.SourceManager.MusicLibrary.DbId);
             playlist.Save ();
 
             HyenaSqliteCommand command = new HyenaSqliteCommand (

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	Tue Mar 18 21:42:29 2008
@@ -93,16 +93,16 @@
 
 #region Constructors
 
-        public PlaylistSource (string name) : this (name, null)
+        public PlaylistSource (string name, int primarySourceId) : this (name, null, primarySourceId)
         {
         }
 
-        public PlaylistSource (string name, int? dbid) : this (name, dbid, -1, 0)
+        public PlaylistSource (string name, int? dbid, int primarySourceId) : this (name, dbid, -1, 0, primarySourceId)
         {
         }
 
-        public PlaylistSource (string name, int? dbid, int sortColumn, int sortType) 
-            : base (generic_name, name, dbid, sortColumn, sortType)
+        public PlaylistSource (string name, int? dbid, int sortColumn, int sortType, int primarySourceId)
+            : base (generic_name, name, dbid, sortColumn, sortType, primarySourceId)
         {
             Properties.SetString ("Icon.Name", "source-playlist");
             Properties.SetString ("RemoveTracksActionLabel", Catalog.GetString ("Remove From Playlist"));
@@ -165,9 +165,9 @@
         protected override void Create ()
         {
             DbId = ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (
-                @"INSERT INTO CorePlaylists (PlaylistID, Name, SortColumn, SortType)
-                    VALUES (NULL, ?, ?, ?)",
-                Name, -1, 1 //SortColumn, SortType
+                @"INSERT INTO CorePlaylists (PlaylistID, Name, SortColumn, SortType, PrimarySourceID)
+                    VALUES (NULL, ?, ?, ?, ?)",
+                Name, -1, 1, PrimarySourceId //SortColumn, SortType
             ));
         }
 
@@ -288,11 +288,11 @@
         public static IEnumerable<PlaylistSource> LoadAll ()
         {
             using (IDataReader reader = ServiceManager.DbConnection.Query (
-                "SELECT PlaylistID, Name, SortColumn, SortType FROM CorePlaylists WHERE Special = 0")) {
+                "SELECT PlaylistID, Name, SortColumn, SortType, PrimarySourceID FROM CorePlaylists WHERE Special = 0")) {
                 while (reader.Read ()) {
                     yield return new PlaylistSource (
                         reader[1] as string, Convert.ToInt32 (reader[0]),
-                        Convert.ToInt32 (reader[2]), Convert.ToInt32 (reader[3])
+                        Convert.ToInt32 (reader[2]), Convert.ToInt32 (reader[3]), Convert.ToInt32 (reader[4])
                     );
                 }
             }
@@ -309,14 +309,14 @@
             }
         }
         
-        public static int GetPlaylistId (string name)
+        private static int GetPlaylistId (string name)
         {
             return ServiceManager.DbConnection.Query<int> (
                 "SELECT PlaylistID FROM Playlists WHERE Name = ? LIMIT 1", name
             );
         }
         
-        public static bool PlaylistExists (string name)
+        private static bool PlaylistExists (string name)
         {
             return GetPlaylistId (name) > 0;
         }

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	Tue Mar 18 21:42:29 2008
@@ -61,10 +61,12 @@
                 ServiceManager.SourceManager.AddSource (new MusicLibrarySource (), true);
                 ServiceManager.SourceManager.AddSource (new VideoLibrarySource (), false);
 
-                // FIXME add each playlist as a childsource of the PrimarySource it belongs to,
-                // not just to the MusicLibrary.
                 foreach (PlaylistSource pl in PlaylistSource.LoadAll ()) {
-                    ServiceManager.SourceManager.MusicLibrary.AddChildSource (pl);
+                    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.SmartPlaylist/SmartPlaylistCore.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistCore.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistCore.cs	Tue Mar 18 21:42:29 2008
@@ -67,13 +67,17 @@
 
         private void HandleSourceAdded (SourceEventArgs args)
         {
-            if (args.Source == ServiceManager.SourceManager.DefaultSource) {
+            PrimarySource primary = args.Source as PrimarySource;
+            if (primary != null) {
                 foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll ()) {
-                    playlists.Add (pl);
-                    if (migrated_this_run) {
-                        pl.RefreshAndReload ();
+                    if (pl.PrimarySourceId == primary.DbId) {
+                        playlists.Add (pl);
+
+                        if (migrated_this_run) {
+                            pl.RefreshAndReload ();
+                        }
+                        primary.AddChildSource (pl);
                     }
-                    ServiceManager.SourceManager.DefaultSource.AddChildSource (pl);
                 }
                 return;
             }
@@ -94,14 +98,9 @@
                     false
             );*/
 
-            Timer t = new Timer ("HandleSourceAdded", playlist.Name);
-
             StartTimer (playlist);
-            
             playlists.Add(playlist);
             SortPlaylists();
-
-            t.Stop();
         }
 
         private void HandleSourceRemoved (SourceEventArgs args)

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs	Tue Mar 18 21:42:29 2008
@@ -160,12 +160,12 @@
 
 #region Constructors
 
-        public SmartPlaylistSource (string name) : this (null, name, String.Empty, String.Empty, String.Empty, String.Empty)
+        public SmartPlaylistSource (string name, int primarySourceId) : this (null, name, String.Empty, String.Empty, String.Empty, String.Empty, primarySourceId)
         {
         }
 
-        public SmartPlaylistSource (string name, QueryNode condition, QueryOrder order, QueryLimit limit, IntegerQueryValue limit_value)
-            : base (generic_name, name, null, -1, 0)
+        public SmartPlaylistSource (string name, QueryNode condition, QueryOrder order, QueryLimit limit, IntegerQueryValue limit_value, int primarySourceId)
+            : base (generic_name, name, null, -1, 0, primarySourceId)
         {
             ConditionTree = condition;
             QueryOrder = order;
@@ -177,8 +177,8 @@
         }
 
         // For existing smart playlists that we're loading from the database
-        public SmartPlaylistSource (int? dbid, string name, string condition_xml, string order_by, string limit_number, string limit_criterion) :
-            base (generic_name, name, dbid, -1, 0)
+        public SmartPlaylistSource (int? dbid, string name, string condition_xml, string order_by, string limit_number, string limit_criterion, int primarySourceId) :
+            base (generic_name, name, dbid, -1, 0, primarySourceId)
         {
             ConditionXml = condition_xml;
             QueryOrder = BansheeQuery.FindOrder (order_by);
@@ -258,12 +258,13 @@
         {
             DbId = ServiceManager.DbConnection.Execute (new HyenaSqliteCommand (@"
                 INSERT INTO CoreSmartPlaylists
-                    (Name, Condition, OrderBy, LimitNumber, LimitCriterion)
-                    VALUES (?, ?, ?, ?, ?)",
+                    (Name, Condition, OrderBy, LimitNumber, LimitCriterion, PrimarySourceID)
+                    VALUES (?, ?, ?, ?, ?, ?)",
                 Name, ConditionXml,
                 IsLimited ? QueryOrder.Name : null,
                 IsLimited ? LimitValue.ToSql () : null,
-                IsLimited ? Limit.Name : null
+                IsLimited ? Limit.Name : null,
+                PrimarySourceId
             ));
             UpdateDependencies ();
         }
@@ -305,9 +306,9 @@
                   INSERT INTO CoreSmartPlaylistEntries 
                     SELECT NULL, {0} as SmartPlaylistID, TrackId
                         FROM CoreTracks, CoreArtists, CoreAlbums
-                        WHERE CoreTracks.ArtistID = CoreArtists.ArtistID AND CoreTracks.AlbumID = CoreAlbums.AlbumID
+                        WHERE CoreTracks.ArtistID = CoreArtists.ArtistID AND CoreTracks.AlbumID = CoreAlbums.AlbumID AND CoreTracks.PrimarySourceID = {3}
                         {1} {2}",
-                DbId, PrependCondition("AND"), OrderAndLimit
+                DbId, PrependCondition("AND"), OrderAndLimit, PrimarySourceId
             ));
         }
 
@@ -399,14 +400,14 @@
         public static IEnumerable<SmartPlaylistSource> LoadAll ()
         {
             using (IDataReader reader = ServiceManager.DbConnection.Query (
-                "SELECT SmartPlaylistID, Name, Condition, OrderBy, LimitNumber, LimitCriterion FROM CoreSmartPlaylists")) {
+                "SELECT SmartPlaylistID, Name, Condition, OrderBy, LimitNumber, LimitCriterion, PrimarySourceID FROM CoreSmartPlaylists")) {
                 while (reader.Read ()) {
                     SmartPlaylistSource playlist = null;
                     try {
                         playlist = new SmartPlaylistSource (
                             Convert.ToInt32 (reader[0]), reader[1] as string,
                             reader[2] as string, reader[3] as string,
-                            reader[4] as string, reader[5] as string
+                            reader[4] as string, reader[5] as string, Convert.ToInt32 (reader[6])
                         );
                     } catch (Exception e) {
                         Log.Warning ("Ignoring Smart Playlist", String.Format ("Caught error: {0}", e), false);

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs	Tue Mar 18 21:42:29 2008
@@ -92,6 +92,10 @@
             get { return ServiceManager.SourceManager.ActiveSource; }
         }
 
+        public virtual PrimarySource ActivePrimarySource {
+            get { return (ActiveSource as PrimarySource) ?? (ActiveSource.Parent as PrimarySource) ?? ServiceManager.SourceManager.MusicLibrary; }
+        }
+
         public Gtk.Window PrimaryWindow {
             get { return ServiceManager.Get<GtkElementsService> ("GtkElementsService").PrimaryWindow; }
         }

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs	Tue Mar 18 21:42:29 2008
@@ -50,8 +50,8 @@
                     Catalog.GetString ("_Music"), null, null, null),
 
                 new ActionEntry ("ImportAction", Stock.Open,
-                    Catalog.GetString ("Import _Music..."), "<control>I",
-                    Catalog.GetString ("Import music from a variety of sources"), OnImport),
+                    Catalog.GetString ("Import _Media..."), "<control>I",
+                    Catalog.GetString ("Import media from a variety of sources"), OnImport),
 
                 new ActionEntry ("ImportPlaylistAction", null,
                     Catalog.GetString ("Import Playlist..."), null,

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs	Tue Mar 18 21:42:29 2008
@@ -61,7 +61,11 @@
         public Source ActionSource {
             get { return SourceView.HighlightedSource ?? ActiveSource; }
         }
-        
+
+        public override PrimarySource ActivePrimarySource {
+            get { return (SourceView.HighlightedSource as PrimarySource) ?? base.ActivePrimarySource; }
+        }
+
         public SourceActions (InterfaceActionService actionService) : base ("Source")
         {
             action_service = actionService;
@@ -153,16 +157,17 @@
 
         private void OnNewPlaylist (object o, EventArgs args)
         {
-            PlaylistSource playlist = new PlaylistSource ("New Playlist");
+            PlaylistSource playlist = new PlaylistSource ("New Playlist", ActivePrimarySource.DbId);
             playlist.Save ();
-            ServiceManager.SourceManager.DefaultSource.AddChildSource (playlist);
+            playlist.PrimarySource.AddChildSource (playlist);
             playlist.NotifyUpdated ();
             //SourceView.BeginRenameSource (playlist);
         }
 
+
         private void OnNewSmartPlaylist (object o, EventArgs args)
         {
-            Editor ed = new Editor ();
+            Editor ed = new Editor (ActivePrimarySource);
             ed.RunDialog ();
         }
 
@@ -281,9 +286,9 @@
 
         private void OnSourceProperties (object o, EventArgs args)
         {
-            Source source = ActionSource;
-            if (source is SmartPlaylistSource) {
-                Editor ed = new Editor (source as SmartPlaylistSource);
+            SmartPlaylistSource source = ActionSource as SmartPlaylistSource;
+            if (source != null) {
+                Editor ed = new Editor (source);
                 ed.RunDialog ();
             }
         }

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	Tue Mar 18 21:42:29 2008
@@ -294,7 +294,7 @@
                 submenu.Append (this ["AddToNewPlaylistAction"].CreateMenuItem ());
                 bool separator_added = false;
                 
-                foreach (Source child in ServiceManager.SourceManager.DefaultSource.Children) {
+                foreach (Source child in ActivePrimarySource.Children) {
                     PlaylistSource playlist = child as PlaylistSource;
                     if (playlist != null) {
                         if (!separator_added) {
@@ -317,9 +317,9 @@
         private void OnAddToNewPlaylist (object o, EventArgs args)
         {
             // TODO generate name based on the track selection, or begin editing it
-            PlaylistSource playlist = new PlaylistSource ("New Playlist");
+            PlaylistSource playlist = new PlaylistSource ("New Playlist", ActivePrimarySource.DbId);
             playlist.Save ();
-            ServiceManager.SourceManager.DefaultSource.AddChildSource (playlist);
+            playlist.PrimarySource.AddChildSource (playlist);
             ThreadAssist.SpawnFromMain (delegate {
                 playlist.AddSelectedTracks (TrackSelector.TrackModel);
             });

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs	Tue Mar 18 21:42:29 2008
@@ -23,6 +23,7 @@
     {
         private BansheeQueryBox builder;
         private SmartPlaylistSource playlist = null;
+        private PrimarySource primary_source;
 
         private static SmartPlaylistSource currently_editing;
         public static SmartPlaylistSource CurrentlyEditing {
@@ -40,6 +41,7 @@
         {
             currently_editing = playlist;
             this.playlist = playlist;
+            this.primary_source = playlist.PrimarySource;
             /*Console.WriteLine ("Loading smart playlist into editor: {0}",
                 playlist.ConditionTree == null ? "" : playlist.ConditionTree.ToXml (BansheeQuery.FieldSet, true));*/
 
@@ -56,8 +58,9 @@
             LimitEnabled = playlist.IsLimited;
         }
     
-        public Editor () : base ("SmartPlaylistEditorDialog")
+        public Editor (PrimarySource primary_source) : base ("SmartPlaylistEditorDialog")
         {
+            this.primary_source = primary_source;
             Initialize ();
         }
 
@@ -226,7 +229,7 @@
                 ThreadAssist.Spawn (delegate {
                     //Console.WriteLine ("Name = {0}, Cond = {1}, OrderAndLimit = {2}", name, condition, order_by, limit_number);
                     if (playlist == null) {
-                        playlist = new SmartPlaylistSource (name);
+                        playlist = new SmartPlaylistSource (name, primary_source.DbId);
 
                         playlist.ConditionTree = condition_tree;
                         playlist.QueryOrder = order;
@@ -234,7 +237,7 @@
                         playlist.LimitValue = limit_value;
 
                         playlist.Save ();
-                        ServiceManager.SourceManager.DefaultSource.AddChildSource (playlist);
+                        playlist.PrimarySource.AddChildSource (playlist);
                         playlist.RefreshAndReload ();
                         //SmartPlaylistCore.Instance.StartTimer (playlist);
                     } else {
@@ -289,10 +292,9 @@
                     val.ParseUserQuery (adv_tree_view.Model.GetValue (iter, 3) as string);
                     QueryLimit limit       = BansheeQuery.FindLimit (adv_tree_view.Model.GetValue (iter, 4) as string);
 
-                    SmartPlaylistSource pl = new SmartPlaylistSource (name, condition, order, limit, val);
+                    SmartPlaylistSource pl = new SmartPlaylistSource (name, condition, order, limit, val, primary_source.DbId);
                     pl.Save ();
-                    //Banshee.Sources.LibrarySource.Instance.AddChildSource (pl);
-                    ServiceManager.SourceManager.DefaultSource.AddChildSource (pl);
+                    pl.PrimarySource.AddChildSource (pl);
                     pl.RefreshAndReload ();
                     //SmartPlaylistCore.Instance.StartTimer (pl);
                 }

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs	Tue Mar 18 21:42:29 2008
@@ -31,6 +31,7 @@
 
 using Gtk;
 using Cairo;
+using Mono.Unix;
 
 using Hyena.Gui.Theming;
 using Hyena.Gui.Theatrics;
@@ -560,7 +561,10 @@
         }
         
         internal Source NewPlaylistSource {
-            get { return new_playlist_source; }
+            get {
+                return new_playlist_source ??
+                    new_playlist_source = new PlaylistSource (Catalog.GetString ("New Playlist"), ServiceManager.SourceManager.MusicLibrary.DbId);
+            }
         }
 
 #endregion        

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	Tue Mar 18 21:42:29 2008
@@ -54,7 +54,7 @@
             Hyena.Data.Gui.ListViewDragDropTarget.ModelSelection
         };
         
-        private Source new_playlist_source = new PlaylistSource (Catalog.GetString ("New Playlist"));
+        private Source new_playlist_source = null;
         private TreeIter new_playlist_iter = TreeIter.Zero;
         private bool new_playlist_visible = false;
         
@@ -90,7 +90,7 @@
             TreeIter library = FindSource (ServiceManager.SourceManager.DefaultSource);
             new_playlist_iter = store.AppendNode (library);
             
-            store.SetValue (new_playlist_iter, 0, new_playlist_source);
+            store.SetValue (new_playlist_iter, 0, NewPlaylistSource);
             store.SetValue (new_playlist_iter, 1, 999);
             new_playlist_visible = true;
 
@@ -107,7 +107,7 @@
             bool self_drag = Gtk.Drag.GetSourceWidget (context) == this;
             
             if (!new_playlist_visible && active_source != null && 
-                new_playlist_source.AcceptsInputFromSource (active_source) &&
+                NewPlaylistSource.AcceptsInputFromSource (active_source) &&
                 ((self_drag && active_source.SupportedMergeTypes != SourceMergeType.None) || !self_drag)) {
                 ShowNewPlaylistRow ();
             }
@@ -166,8 +166,8 @@
                 
                 Source drop_source = final_drag_source;    
                 
-                if (final_drag_source == new_playlist_source) {
-                    PlaylistSource playlist = new PlaylistSource ("New Playlist");
+                if (final_drag_source == NewPlaylistSource) {
+                    PlaylistSource playlist = new PlaylistSource ("New Playlist", ServiceManager.SourceManager.MusicLibrary.DbId);
                     playlist.Save ();
                     ServiceManager.SourceManager.DefaultSource.AddChildSource (playlist);
                     drop_source = playlist;

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Resources/banshee-dialogs.glade
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Resources/banshee-dialogs.glade	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Resources/banshee-dialogs.glade	Tue Mar 18 21:42:29 2008
@@ -1342,7 +1342,7 @@
   </widget>
   <widget class="GtkDialog" id="ImportDialog">
     <property name="border_width">12</property>
-    <property name="title" translatable="yes">Import Music to Library</property>
+    <property name="title" translatable="yes">Import Media to Library</property>
     <property name="resizable">False</property>
     <property name="modal">True</property>
     <property name="window_position">GTK_WIN_POS_CENTER</property>
@@ -1418,7 +1418,7 @@
               <widget class="GtkLabel" id="label64">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
-                <property name="label" translatable="yes">&lt;big&gt;&lt;b&gt;Import Music to Library&lt;/b&gt;&lt;/big&gt;</property>
+                <property name="label" translatable="yes">&lt;big&gt;&lt;b&gt;Import Media to Library&lt;/b&gt;&lt;/big&gt;</property>
                 <property name="use_markup">True</property>
               </widget>
               <packing>
@@ -1431,7 +1431,7 @@
               <widget class="GtkLabel" id="MessageLabel">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
-                <property name="label" translatable="yes">Your music library is empty. You may import new music into your library now, or choose to do so later.</property>
+                <property name="label" translatable="yes">Your media library is empty. You may import new music and videos into your library now, or choose to do so later.</property>
                 <property name="wrap">True</property>
               </widget>
               <packing>
@@ -1468,7 +1468,7 @@
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
-                <property name="label" translatable="yes">Import Music Source</property>
+                <property name="label" translatable="yes">Import Media Source</property>
                 <property name="use_underline">True</property>
                 <property name="response_id">-5</property>
               </widget>

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	Tue Mar 18 21:42:29 2008
@@ -54,7 +54,7 @@
         private DatabaseTrackInfo playing_track;
         private bool actions_loaded = false;
         
-        public PlayQueueSource () : base (Catalog.GetString ("Play Queue"), null)
+        public PlayQueueSource () : base (Catalog.GetString ("Play Queue"), null, 0)
         {
             BindToDatabase ();
             



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