[tomboy/xdg-migration: 4/4] Use XDG specification instead of ~/.tomboy. Incomplete, no migration.
- From: Sanford Armstrong <sharm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tomboy/xdg-migration: 4/4] Use XDG specification instead of ~/.tomboy. Incomplete, no migration.
- Date: Mon, 24 Aug 2009 01:59:59 +0000 (UTC)
commit 5caf95384a5165c43dcb05ce126377563255602f
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date: Sun May 3 07:08:43 2009 -0700
Use XDG specification instead of ~/.tomboy. Incomplete, no migration.
Still need migration, some instances of directory creation, a good way to notify users of the change, and a decision about what to do for Windows/Mac.
Tomboy/GnomeApplication.cs | 43 +++++++++++++++++++++---
Tomboy/NativeApplication.cs | 6 +++-
Tomboy/NoteManager.cs | 2 +-
Tomboy/PreferencesDialog.cs | 2 +-
Tomboy/Synchronization/FileSystemSyncServer.cs | 6 ++--
Tomboy/Synchronization/FuseSyncServiceAddin.cs | 2 +-
Tomboy/Synchronization/TomboySyncClient.cs | 4 +-
Tomboy/Tomboy.cs | 6 ++--
8 files changed, 54 insertions(+), 17 deletions(-)
---
diff --git a/Tomboy/GnomeApplication.cs b/Tomboy/GnomeApplication.cs
index 0040f50..87b2a1f 100644
--- a/Tomboy/GnomeApplication.cs
+++ b/Tomboy/GnomeApplication.cs
@@ -12,12 +12,33 @@ namespace Tomboy
public class GnomeApplication : INativeApplication
{
private Gnome.Program program;
- private string confDir;
+ private static string confDir;
+ private static string dataDir;
+ private static string cacheDir;
+ private const string tomboyDirName = "tomboy";
- public GnomeApplication ()
+ static GnomeApplication ()
{
- confDir = Path.Combine (Environment.GetEnvironmentVariable ("HOME"),
- ".tomboy");
+ string homeDir = Environment.GetEnvironmentVariable ("HOME");
+
+ string dataBaseDir = Environment.GetEnvironmentVariable ("XDG_DATA_HOME");
+ if (string.IsNullOrEmpty (dataBaseDir))
+ dataBaseDir = Path.Combine (Path.Combine (homeDir, ".local"), "share");
+
+ string confBaseDir = Environment.GetEnvironmentVariable ("XDG_CONFIG_HOME");
+ if (string.IsNullOrEmpty (confBaseDir))
+ confBaseDir = Path.Combine (homeDir, ".config");
+
+ string cacheBaseDir = Environment.GetEnvironmentVariable ("XDG_CACHE_HOME");
+ if (string.IsNullOrEmpty (cacheBaseDir))
+ cacheBaseDir = Path.Combine (homeDir, ".cache");
+
+ dataDir = Path.Combine (dataBaseDir, tomboyDirName);
+ confDir = Path.Combine (confBaseDir, tomboyDirName);
+ cacheDir = Path.Combine (cacheBaseDir, tomboyDirName);
+
+ // TODO: Create with 0700 perms if they don't exist
+ // (probably best to do this in NoteManager, AddinManager, etc, or Tomboy.cs?)
}
public void Initialize (string locale_dir,
@@ -157,10 +178,22 @@ namespace Tomboy
screen);
}
- public string ConfDir {
+ public string DataDirectory {
+ get {
+ return dataDir;
+ }
+ }
+
+ public string ConfigurationDirectory {
get {
return confDir;
}
}
+
+ public string CacheDirectory {
+ get {
+ return cacheDir;
+ }
+ }
}
}
diff --git a/Tomboy/NativeApplication.cs b/Tomboy/NativeApplication.cs
index 645c5dd..273ce00 100644
--- a/Tomboy/NativeApplication.cs
+++ b/Tomboy/NativeApplication.cs
@@ -18,7 +18,11 @@ namespace Tomboy
void Exit (int exitcode);
void StartMainLoop ();
- string ConfDir { get; }
+ string ConfigurationDirectory { get; }
+
+ string DataDirectory { get; }
+
+ string CacheDirectory { get; }
void OpenUrl (string url);
diff --git a/Tomboy/NoteManager.cs b/Tomboy/NoteManager.cs
index fa56966..c7af200 100644
--- a/Tomboy/NoteManager.cs
+++ b/Tomboy/NoteManager.cs
@@ -77,7 +77,7 @@ public NoteManager (string directory) :
protected virtual AddinManager CreateAddinManager ()
{
- string tomboy_conf_dir = Services.NativeApplication.ConfDir;
+ string tomboy_conf_dir = Services.NativeApplication.ConfigurationDirectory;
return new AddinManager (tomboy_conf_dir);
}
diff --git a/Tomboy/PreferencesDialog.cs b/Tomboy/PreferencesDialog.cs
index 8a56c83..fcb9835 100644
--- a/Tomboy/PreferencesDialog.cs
+++ b/Tomboy/PreferencesDialog.cs
@@ -1109,7 +1109,7 @@ namespace Tomboy
{
// Nuke ~/.tomboy/manifest.xml
string clientManifestPath = System.IO.Path.Combine (
- Tomboy.DefaultNoteManager.NoteDirectoryPath,
+ Services.NativeApplication.ConfigurationDirectory,
"manifest.xml");
if (System.IO.File.Exists (clientManifestPath) == true) {
try {
diff --git a/Tomboy/Synchronization/FileSystemSyncServer.cs b/Tomboy/Synchronization/FileSystemSyncServer.cs
index ed143e6..cf3d7ff 100644
--- a/Tomboy/Synchronization/FileSystemSyncServer.cs
+++ b/Tomboy/Synchronization/FileSystemSyncServer.cs
@@ -13,7 +13,7 @@ namespace Tomboy.Sync
private string serverId;
private string serverPath;
- private string notePath;
+ private string cachePath;
private string lockPath;
private string manifestPath;
@@ -32,7 +32,7 @@ namespace Tomboy.Sync
if (!Directory.Exists (serverPath))
throw new DirectoryNotFoundException (serverPath);
- notePath = Tomboy.DefaultNoteManager.NoteDirectoryPath;
+ cachePath = Services.NativeApplication.CacheDirectory;
lockPath = Path.Combine (serverPath, "lock");
manifestPath = Path.Combine (serverPath, "manifest.xml");
@@ -100,7 +100,7 @@ namespace Tomboy.Sync
{
Dictionary<string, NoteUpdate> noteUpdates = new Dictionary<string, NoteUpdate> ();
- string tempPath = Path.Combine (notePath, "sync_temp");
+ string tempPath = Path.Combine (cachePath, "sync_temp");
if (!Directory.Exists (tempPath)) {
Directory.CreateDirectory (tempPath);
} else {
diff --git a/Tomboy/Synchronization/FuseSyncServiceAddin.cs b/Tomboy/Synchronization/FuseSyncServiceAddin.cs
index da09b0f..e285808 100644
--- a/Tomboy/Synchronization/FuseSyncServiceAddin.cs
+++ b/Tomboy/Synchronization/FuseSyncServiceAddin.cs
@@ -265,7 +265,7 @@ namespace Tomboy.Sync
private void SetUpMountPath ()
{
- string notesPath = Tomboy.DefaultNoteManager.NoteDirectoryPath;
+ string notesPath = Services.NativeApplication.CacheDirectory;
mountPath = Path.Combine (notesPath, "sync-" + Id); // TODO: Best mount path name?
}
diff --git a/Tomboy/Synchronization/TomboySyncClient.cs b/Tomboy/Synchronization/TomboySyncClient.cs
index f880c39..51f44f5 100644
--- a/Tomboy/Synchronization/TomboySyncClient.cs
+++ b/Tomboy/Synchronization/TomboySyncClient.cs
@@ -20,12 +20,12 @@ namespace Tomboy.Sync
{
// TODO: Why doesn't OnChanged ever get fired?!
FileSystemWatcher w = new FileSystemWatcher ();
- w.Path = Tomboy.DefaultNoteManager.NoteDirectoryPath;
+ w.Path = Services.NativeApplication.ConfigurationDirectory;
w.Filter = localManifestFileName;
w.Changed += OnChanged;
localManifestFilePath =
- Path.Combine (Tomboy.DefaultNoteManager.NoteDirectoryPath,
+ Path.Combine (Services.NativeApplication.ConfigurationDirectory,
localManifestFileName);
Parse (localManifestFilePath);
diff --git a/Tomboy/Tomboy.cs b/Tomboy/Tomboy.cs
index 42a1d8f..8fe1cf8 100644
--- a/Tomboy/Tomboy.cs
+++ b/Tomboy/Tomboy.cs
@@ -92,7 +92,7 @@ namespace Tomboy
RegisterSessionManagerRestart (
Environment.GetEnvironmentVariable ("TOMBOY_WRAPPER_PATH"),
args,
- new string [] { "TOMBOY_PATH=" + note_path });
+ new string [] { "TOMBOY_PATH=" + note_path }); // TODO: Pass along XDG_*?
StartTrayIcon ();
}
@@ -106,10 +106,10 @@ namespace Tomboy
override_path :
Environment.GetEnvironmentVariable ("TOMBOY_PATH");
if (note_path == null)
- note_path = Services.NativeApplication.ConfDir;
+ note_path = Services.NativeApplication.DataDirectory;
// Tilde expand
- return note_path.Replace ("~", Environment.GetEnvironmentVariable ("HOME"));
+ return note_path.Replace ("~", Environment.GetEnvironmentVariable ("HOME")); // TODO: Wasted work
}
static void RegisterPanelAppletFactory ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]