banshee r3114 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs src/Core/Banshee.ThickClient/Resources



Author: abock
Date: Thu Jan 31 05:38:19 2008
New Revision: 3114
URL: http://svn.gnome.org/viewvc/banshee?rev=3114&view=rev

Log:
2008-01-31  Aaron Bockover  <abock gnome org>

    Patch to enable the preferences dialog by Alex Hixon

    * src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs:
    * src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs:
    Copy track to library directory if it's not already there and the user
    has opted to copy files

    * src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/PreferencesDialog.cs:
    Port the preferences dialog from stable

    * src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs:
    * src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml:
    Added preferences actions



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/PreferencesDialog.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
   trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs	Thu Jan 31 05:38:19 2008
@@ -28,12 +28,15 @@
 
 using System;
 using System.Data;
+using System.IO;
 
 using Hyena;
 using Hyena.Data.Sqlite;
 
 using Banshee.Base;
+using Banshee.Configuration.Schema;
 using Banshee.Database;
+using Banshee.IO;
 using Banshee.ServiceStack;
 
 namespace Banshee.Collection.Database
@@ -243,5 +246,47 @@
             return Convert.ToInt32 (ServiceManager.DbConnection.ExecuteScalar (
                 check_command.ApplyValues (relative_path, uri.AbsoluteUri))) > 0;
         }
+        
+        /// <summary>
+        /// Copies the file references in the current LibraryTrackInfo instance to a location
+        /// inside of the user's current library path.
+        /// </summary>
+        /// <returns>New SafeUri pointing to the newly copied file.</returns>
+        public SafeUri CopyToLibrary ()
+        {
+            SafeUri old_uri = this.Uri;
+            if (old_uri == null) {
+                // Get out quick, no URI set yet.
+                return null;
+            }
+            
+            SafeUri library_check = new SafeUri (Paths.LibraryLocation + Path.DirectorySeparatorChar);
+        
+            bool in_library = old_uri.ToString ().StartsWith (library_check.ToString ());
+            //Console.WriteLine ("{0} is{1}in library.", old_uri.ToString (), in_library ? " " : " not ");
+
+            if (!in_library && LibrarySchema.CopyOnImport.Get ()) {
+                string new_filename = FileNamePattern.BuildFull (this,
+                    Path.GetExtension (old_uri.ToString ()).Substring (1));
+                SafeUri new_uri = new SafeUri (new_filename);
+
+                try {
+                    if (IOProxy.File.Exists (new_uri)) {
+                        return null;
+                    }
+                    
+                    // TODO: Once GnomeVfs and Unix have proper Copy providers, use IOProxy.File.Copy instead.
+                    File.Copy (old_uri.LocalPath, new_uri.LocalPath);
+                    
+                    // Return new SafeUri after copy
+                    return new_uri;
+                } catch (Exception ex) {
+                    Log.Error (String.Format("Exception copying into library: {0}", ex), false);
+                    return null;
+                }
+            }
+            
+            return null;
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs	Thu Jan 31 05:38:19 2008
@@ -92,7 +92,7 @@
                 return;
             }
             
-            try {
+            try {            
                 SafeUri uri = new SafeUri (path);
 
                 LibraryTrackInfo track = null;
@@ -113,9 +113,14 @@
                     track.AlbumId = new LibraryAlbumInfo (artist, track.AlbumTitle).DbId;
 
                     artist.Save ();
+
+                    SafeUri newpath = track.CopyToLibrary ();
+                    if (newpath != null) {
+                        track.Uri = newpath;
+                    }
+
                     track.Save ();
                     (ServiceManager.SourceManager.DefaultSource as LibrarySource).Reload ();
-
                 });
                 
                 if (track != null && track.DbId > 0) {

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/PreferencesDialog.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/PreferencesDialog.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/PreferencesDialog.cs	Thu Jan 31 05:38:19 2008
@@ -1,30 +1,30 @@
-/***************************************************************************
- *  PreferencesDialog.cs
- *
- *  Copyright (C) 2006 Novell, Inc.
- *  Written by Aaron Bockover <aaron abock org>
- ****************************************************************************/
-
-/*  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
- *
- *  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.
- */
+//
+// PreferencesDialog.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2006-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 System.IO;
@@ -34,6 +34,7 @@
 using Mono.Unix;
 
 using Banshee.Base;
+using Banshee.ServiceStack;
 using Banshee.Collection;
 using Banshee.Widgets;
 using Banshee.AudioProfiles;
@@ -71,7 +72,7 @@
             (Glade["library_location_label"] as Label).MnemonicWidget = library_location_chooser;
             library_location_chooser.Show();
             
-            cd_importing_profile_box = new ProfileComboBoxConfigurable(Globals.AudioProfileManager, "cd-importing", 
+            cd_importing_profile_box = new ProfileComboBoxConfigurable(ServiceManager.ProfileManager, "cd-importing", 
                 Glade["cd_importing_profile_description"] as Box);
             (Glade["cd_importing_profile_container"] as Box).PackStart(cd_importing_profile_box, false, false, 0);  
             (Glade["cd_importing_profile_label"] as Label).MnemonicWidget = cd_importing_profile_box.Combo;        
@@ -125,6 +126,8 @@
                 "Error correction tries to work around problem areas on a disc, such " +
                 "as surface scratches, but will slow down importing substantially."),
                 "error-correction");
+                
+            //(Glade["error_correction"] as CheckButton).Sensitive = (Glade["cd_importing_profile_label"] as Label).Sensitive;
         }
         
         private void LoadPreferences()
@@ -154,7 +157,7 @@
             
             library_location_chooser.SelectionChanged += delegate {
                 Paths.LibraryLocation = library_location_chooser.Filename;
-                InterfaceElements.PlaylistView.QueueDraw();
+                //InterfaceElements.PlaylistView.QueueDraw();
             };
             
             copy_on_import.Toggled += delegate {
@@ -176,7 +179,7 @@
         private void OnFolderFileChanged(object o, EventArgs args)
         {
             (Glade["example_path"] as Label).Markup = String.Format("<small><i>{0}.ogg</i></small>",
-                GLib.Markup.EscapeText(FileNamePattern.CreateFromITrackInfo(
+                GLib.Markup.EscapeText(FileNamePattern.CreateFromTrackInfo(
                     FileNamePattern.CreateFolderFilePattern(folder_box.ActiveValue, file_box.ActiveValue),
                     new SampleTrackInfo())));
                         

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	Thu Jan 31 05:38:19 2008
@@ -61,9 +61,13 @@
                     Catalog.GetString ("Quit Banshee"), OnQuit),
 
                 // Edit Menu
-                new ActionEntry("EditMenuAction", null, 
+                new ActionEntry ("EditMenuAction", null, 
                     Catalog.GetString("_Edit"), null, null, null),
 
+                new ActionEntry ("PreferencesAction", null,
+                    Catalog.GetString ("_Preferences"), null,
+                    Catalog.GetString ("Modify your personal preferences"), OnPreferences),
+
                 new ActionEntry ("ExtensionsAction", null, 
                     Catalog.GetString ("Manage _Extensions"), null,
                     Catalog.GetString ("Manage extensions to add new features to Banshee"), OnExtensions),
@@ -216,6 +220,13 @@
 
 #region Edit Menu Actions
 
+        private void OnPreferences (object o, EventArgs args)
+        {
+            Dialogs.PreferencesDialog dialog = new Dialogs.PreferencesDialog ();
+            dialog.Run ();
+            dialog.Destroy ();
+        }
+
         private void OnExtensions (object o, EventArgs args)
         {
             Mono.Addins.Gui.AddinManagerWindow.Run (PrimaryWindow);

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am	Thu Jan 31 05:38:19 2008
@@ -32,6 +32,7 @@
 	Banshee.Gui.Dialogs/GladeWindow.cs \
 	Banshee.Gui.Dialogs/ImageFileChooserDialog.cs \
 	Banshee.Gui.Dialogs/OpenLocationDialog.cs \
+	Banshee.Gui.Dialogs/PreferencesDialog.cs \
 	Banshee.Gui.Dialogs/SeekDialog.cs \
 	Banshee.Gui.Dialogs/TrackEditor.cs \
 	Banshee.Gui.DragDrop/DragDropList.cs \

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 Jan 31 05:38:19 2008
@@ -38,6 +38,7 @@
             <menuitem name="SourceProperties" action="SourcePropertiesAction" />
             <menuitem name="UnmapSource" action="UnmapSourceAction" />
             <separator />
+            <menuitem name="Preferences" action="PreferencesAction" />
             <menuitem name="Extensions" action="ExtensionsAction" />
         </menu>
 



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