banshee r4851 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Preferences.Gui
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4851 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Preferences.Gui
- Date: Fri, 21 Nov 2008 06:30:03 +0000 (UTC)
Author: abock
Date: Fri Nov 21 06:30:03 2008
New Revision: 4851
URL: http://svn.gnome.org/viewvc/banshee?rev=4851&view=rev
Log:
2008-11-21 Aaron Bockover <abock gnome org>
* src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs:
Create the muisc directory before setting it on the FileChooserButton
to prevent GTK from wigging out and then setting the directory to
$HOME, causing the preference to save; if the music directory we create
here ends up not being chosen by the user, try to remove it (if it is
empty, which it should be since we created it) (BNC #432754)
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs Fri Nov 21 06:30:03 2008
@@ -35,6 +35,7 @@
using Banshee.Preferences;
using Banshee.Collection;
+using Hyena;
using Hyena.Widgets;
using Banshee.Widgets;
using Banshee.Gui.Widgets;
@@ -76,7 +77,8 @@
private FileChooserButton chooser;
private Button reset;
private LibraryLocationPreference preference;
-
+ private string created_directory;
+
public LibraryLocationButton (PreferenceBase pref)
{
preference = (LibraryLocationPreference)pref;
@@ -84,6 +86,18 @@
Spacing = 5;
+ // FileChooserButton wigs out if the directory does not exist,
+ // so create it if it doesn't and store the fact that we did
+ // in case it ends up not being used, we can remove it
+ try {
+ if (!Banshee.IO.Directory.Exists (preference.Value)) {
+ Banshee.IO.Directory.Create (preference.Value);
+ created_directory = preference.Value;
+ Log.DebugFormat ("Created library directory: {0}", created_directory);
+ }
+ } catch {
+ }
+
chooser = new FileChooserButton (Catalog.GetString ("Select library location"),
FileChooserAction.SelectFolder);
chooser.SetCurrentFolder (preference.Value);
@@ -113,6 +127,24 @@
{
preference.Value = chooser.Filename;
}
+
+ protected override void OnUnrealized ()
+ {
+ // If the directory we had to create to appease FileSystemChooser exists
+ // and ended up not being the one selected by the user we clean it up
+ if (created_directory != null && chooser.Filename != created_directory) {
+ try {
+ Banshee.IO.Directory.Delete (created_directory);
+ if (!Banshee.IO.Directory.Exists (created_directory)) {
+ Log.DebugFormat ("Deleted unusedi and empty previous library directory: {0}", created_directory);
+ created_directory = null;
+ }
+ } catch {
+ }
+ }
+
+ base.OnUnrealized ();
+ }
}
private class PatternComboBox : DictionaryComboBox<string>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]