Re: [Banshee-List] [PATCH] Preferences dialog
- From: Alex Hixon <hixon alexander mediati org>
- To: banshee-list gnome org
- Subject: Re: [Banshee-List] [PATCH] Preferences dialog
- Date: Sun, 27 Jan 2008 03:10:30 -0600
Gah, didn't end up getting attached. My bad.
Cheers,
Alex Hixon
Quoting Alex Hixon <hixon alexander mediati org>:
Hi all,
Attached is a patch that ports across the preferences dialog from stable.
Can't really comment, as my internets about to go out, heh. If you
guys could take a look and commit if its OK. :)
Cheers,
Alex Hixon
_______________________________________________
Banshee-list mailing list
Banshee-list gnome org
http://mail.gnome.org/mailman/listinfo/banshee-list
Index: src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
===================================================================
--- src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs (revision 3058)
+++ src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs (working copy)
@@ -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);
Index: src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/PreferencesDialog.cs
===================================================================
--- src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/PreferencesDialog.cs (revision 3029)
+++ src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/PreferencesDialog.cs (working copy)
@@ -1,31 +1,31 @@
-/***************************************************************************
- * PreferencesDialog.cs
- *
- * Copyright (C) 2006 Novell, Inc.
- * Written by Aaron Bockover <aaron abock org>
- ****************************************************************************/
+//
+// 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.
+//
-/* 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.
- */
-
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())));
Index: src/Core/Banshee.ThickClient/Makefile.am
===================================================================
--- src/Core/Banshee.ThickClient/Makefile.am (revision 3058)
+++ src/Core/Banshee.ThickClient/Makefile.am (working copy)
@@ -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 \
Index: src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
===================================================================
--- src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml (revision 3058)
+++ src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml (working copy)
@@ -36,6 +36,7 @@
<menuitem name="SourceProperties" action="SourcePropertiesAction" />
<menuitem name="UnmapSource" action="UnmapSourceAction" />
<separator />
+ <menuitem name="Preferences" action="PreferencesAction" />
<menuitem name="Extensions" action="ExtensionsAction" />
</menu>
Index: src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
===================================================================
--- src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs (revision 3058)
+++ src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs (working copy)
@@ -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
@@ -242,5 +245,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;
+ }
}
}
Index: src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs
===================================================================
--- src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs (revision 3058)
+++ src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs (working copy)
@@ -92,7 +92,7 @@
return;
}
- try {
+ try {
SafeUri uri = new SafeUri (path);
LibraryTrackInfo track = null;
@@ -112,9 +112,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) {
IncrementProcessedCount (String.Format ("{0} - {1}", track.DisplayArtistName, track.DisplayTrackTitle));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]