[banshee] Improve default library locations



commit eb59b4c0dbdf5f45f5f9154f7694dd6288e4d617
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Tue Sep 22 18:09:42 2009 -0700

    Improve default library locations
    
    In some circumstances the default library locations were set to $HOME
    instead of under it.

 src/Core/Banshee.Core/Banshee.Base/Paths.cs        |   12 ++++++++++++
 .../Banshee.Library/MusicLibrarySource.cs          |    2 +-
 .../Banshee.Library/VideoLibrarySource.cs          |    2 +-
 3 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.Base/Paths.cs b/src/Core/Banshee.Core/Banshee.Base/Paths.cs
index c96b5e2..9cf8874 100644
--- a/src/Core/Banshee.Core/Banshee.Base/Paths.cs
+++ b/src/Core/Banshee.Core/Banshee.Base/Paths.cs
@@ -213,5 +213,17 @@ namespace Banshee.Base
         {
             return Path.Combine (InstalledApplicationData, path);
         }
+
+        public static string GetXdgDirectoryUnderHome (string key, string fallback)
+        {
+            string xdg_dir = Banshee.Base.XdgBaseDirectorySpec.GetUserDirectory (key, fallback);
+            string home_dir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
+
+            if (xdg_dir == null || xdg_dir == home_dir || !xdg_dir.StartsWith (home_dir)) {
+                xdg_dir = Combine (home_dir, fallback);
+            }
+
+            return xdg_dir;
+        }
     }
 }
diff --git a/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs b/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs
index 3f54bc1..c596026 100644
--- a/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs
+++ b/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs
@@ -71,7 +71,7 @@ namespace Banshee.Library
         }
         
         public override string DefaultBaseDirectory {
-            get { return Banshee.Base.XdgBaseDirectorySpec.GetUserDirectory ("XDG_MUSIC_DIR", "Music"); }
+            get { return Banshee.Base.Paths.GetXdgDirectoryUnderHome ("XDG_MUSIC_DIR", "Music"); }
         }
 
         public override IEnumerable<SmartPlaylistDefinition> DefaultSmartPlaylists {
diff --git a/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs b/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs
index 8c66382..467b40e 100644
--- a/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs
+++ b/src/Core/Banshee.Services/Banshee.Library/VideoLibrarySource.cs
@@ -73,7 +73,7 @@ namespace Banshee.Library
         }
         
         public override string DefaultBaseDirectory {
-            get { return Banshee.Base.XdgBaseDirectorySpec.GetUserDirectory ("XDG_VIDEOS_DIR", "Videos"); }
+            get { return Banshee.Base.Paths.GetXdgDirectoryUnderHome ("XDG_VIDEOS_DIR", "Videos"); }
         }
 
         public override IEnumerable<SmartPlaylistDefinition> DefaultSmartPlaylists {



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