Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revisione 3838)
+++ src/Makefile.am	(copia locale)
@@ -14,7 +14,8 @@
 	$(srcdir)/Core/IBrowsableItem.cs	\
 	$(srcdir)/Core/IBrowsableCollection.cs	\
 	$(srcdir)/Core/IPreferenceBackend.cs	\
-	$(srcdir)/Core/Roll.cs
+	$(srcdir)/Core/Roll.cs			\
+	$(srcdir)/Core/XdgBaseDirectorySpec.cs
 
 QUERY_CSDISTFILES =				\
 	$(srcdir)/Query/DateRange.cs		\
Index: src/Core/XdgBaseDirectorySpec.cs
===================================================================
--- src/Core/XdgBaseDirectorySpec.cs	(revisione 0)
+++ src/Core/XdgBaseDirectorySpec.cs	(revisione 0)
@@ -0,0 +1,82 @@
+//
+// XdgBaseDirectorySpec.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;
+
+namespace FSpot
+{
+	public static class XdgBaseDirectorySpec
+	{
+		public static string GetUserDirectory (string key, string fallback)
+		{
+			string home_dir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
+			string config_dir = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
+           
+			string env_path = Environment.GetEnvironmentVariable (key);
+			if (!String.IsNullOrEmpty (env_path)) {
+				return env_path;
+			}
+
+			string user_dirs_path = Path.Combine (config_dir, "user-dirs.dirs");
+
+			if (!File.Exists (user_dirs_path)) {
+				return Path.Combine (home_dir, fallback);
+			}
+
+			try {
+				using (StreamReader reader = new StreamReader (user_dirs_path)) {
+					string line;
+					while ((line = reader.ReadLine ()) != null) {
+						line = line.Trim ();
+						int delim_index = line.IndexOf ('=');
+						if (delim_index > 8 && line.Substring (0, delim_index) == key) {
+							string path = line.Substring (delim_index + 1).Trim ('"');
+							bool relative = false;
+
+							if (path.StartsWith ("$HOME/")) {
+								relative = true;
+								path = path.Substring (6);
+							} else if (path.StartsWith ("~")) {
+								relative = true;
+								path = path.Substring (1);
+							} else if (!path.StartsWith ("/")) {
+								relative = true;
+							}
+
+							return relative ? Path.Combine (home_dir, path) : path;
+						}
+					}
+				}
+			} catch (FileNotFoundException) {
+			}
+            
+			return Path.Combine (home_dir, fallback);
+		}
+	}
+}
Index: src/Core/Global.cs
===================================================================
--- src/Core/Global.cs	(revisione 3838)
+++ src/Core/Global.cs	(copia locale)
@@ -4,16 +4,29 @@
  * This is free software. See COPYING for details
  *
  */
+using System;
+using System.IO;
 
 namespace FSpot {
 	public class Global {
 		public static string HomeDirectory {
 			get {
-				return System.IO.Path.Combine (System.Environment.GetEnvironmentVariable ("HOME"), System.String.Empty);	
+				return Environment.GetFolderPath (Environment.SpecialFolder.Personal);
 			}
 		}
-		
-		private static string base_dir = System.IO.Path.Combine (HomeDirectory,  System.IO.Path.Combine (".gnome2", "f-spot"));
+				
+		private static bool UseOldDir () {
+			return Directory.Exists (legacy_base_dir);
+		}
+
+		private static string legacy_base_dir = Path.Combine (HomeDirectory,  Path.Combine (".gnome2", "f-spot"));
+		public static string LegacyBaseDirectory {
+			get { return legacy_base_dir; }
+			set { legacy_base_dir = value; }
+		}
+
+		private static string base_dir = (UseOldDir () ? legacy_base_dir : 
+					Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData), "f-spot"));
 		public static string BaseDirectory {
 			get { return base_dir; }
 			set { base_dir = value; }
@@ -32,6 +45,18 @@
 			}	
 		}
 
+		private static string application_cache = Path.Combine (XdgBaseDirectorySpec.GetUserDirectory ("XDG_CACHE_HOME", ".cache"), "f-spot");
+		public static string ApplicationCache {
+			get { return application_cache; }
+			set { application_cache = value; }
+		}
+
+		private static string extension_cache_root = (UseOldDir () ? BaseDirectory : Path.Combine (ApplicationCache, "extensions"));
+		public static string ExtensionCacheRoot {
+			get { return extension_cache_root; }
+			set { extension_cache_root = value; }
+		}
+
 		private static Cms.Profile display_profile;
 		public static Cms.Profile DisplayProfile {
 			set { display_profile = value; }
@@ -49,7 +74,7 @@
 			get {
 				if (icon_theme == null) {
 					icon_theme = Gtk.IconTheme.Default;
-					icon_theme.AppendSearchPath (System.IO.Path.Combine (Defines.APP_DATA_DIR, "icons"));
+					icon_theme.AppendSearchPath (Path.Combine (Defines.APP_DATA_DIR, "icons"));
 				}
 				return icon_theme;
 			}
Index: src/main.cs
===================================================================
--- src/main.cs	(revisione 3838)
+++ src/main.cs	(copia locale)
@@ -48,6 +48,7 @@
 		    	"-? -help -usage     Show this help list" + Environment.NewLine +
 			"-i -import PARAM    import from the given uri" + Environment.NewLine +
 			"-p -photodir PARAM  default import folder" + Environment.NewLine +
+			"-c -cachedir PARAM  cache folder " + Environment.NewLine +
 			"-shutdown           shutdown a running f-spot instance" + Environment.NewLine +
 			"-slideshow          display a slideshow" + Environment.NewLine +
 			"-V -version         Display version and licensing information" + Environment.NewLine +
@@ -104,6 +105,15 @@
 				System.Console.WriteLine ("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory);
 				break;
 
+			case "-c": case "-cachedir": case "--cachedir":
+				if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
+					Console.WriteLine ("f-spot: -cachedir option takes one argument");
+					return 1;
+				}
+				FSpot.Global.ApplicationCache = System.IO.Path.GetFullPath (args [++i]);
+				System.Console.WriteLine ("CacheDirectory is now {0}", FSpot.Global.ApplicationCache);
+				break;
+
 			case "-i": case "-import": case "--import":
 				if (i+1 == args.Length) {
 					Console.WriteLine ("f-spot: -import option takes one argument");
@@ -183,7 +193,7 @@
 					       Modules.UI, args);		
 			
 			Console.WriteLine ("Initializing Mono.Addins");
-			AddinManager.Initialize (FSpot.Global.BaseDirectory);
+			AddinManager.Initialize (FSpot.Global.ExtensionCacheRoot);
 			AddinManager.Registry.Update (null);
 			SetupService setupService = new SetupService (AddinManager.Registry);
 			setupService.Repositories.RegisterRepository (null, "http://addins.f-spot.org/" + Defines.VERSION, false);
Index: src/Preferences.cs
===================================================================
--- src/Preferences.cs	(revisione 3838)
+++ src/Preferences.cs	(copia locale)
@@ -181,7 +181,7 @@
 			case SCREENSAVER_TAG:
 				return 1;
 			case STORAGE_PATH:
-				return System.IO.Path.Combine (FSpot.Global.HomeDirectory, Catalog.GetString("Photos"));
+				return System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyPictures), Catalog.GetString ("Photos"));
 			case EXPORT_EMAIL_SIZE:
 				return 3;	// medium size 640px
 			case EXPORT_EMAIL_ROTATE:
Index: ChangeLog
===================================================================
--- ChangeLog	(revisione 3838)
+++ ChangeLog	(copia locale)
@@ -1,3 +1,11 @@
+2008-04-22  Lorenzo Milesi <maxxer@yetopen.it>
+
+	* src/Makefile.am:
+	* src/main.cs:
+	* src/Preferences.cs:
+	* src/Core/XdgBaseDirectorySpec.cs:
+	* src/Core/Global.cs: XDG-dir support. Bgo#459338.
+
 2008-04-16  Lorenzo Milesi <maxxer@yetopen.it>
 
 	* src/Preferences.cs: revert to nullpreferences backend if Gconf
