[tomboy/xdg-migration2: 16/16] Implement new directories for Windows/Mac (untested).
- From: Sanford Armstrong <sharm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tomboy/xdg-migration2: 16/16] Implement new directories for Windows/Mac (untested).
- Date: Mon, 24 Aug 2009 02:02:01 +0000 (UTC)
commit 5f9c2db94a91aef9494ac85b96be3a5cee9fb836
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date: Sun Aug 23 18:55:38 2009 -0700
Implement new directories for Windows/Mac (untested).
Tomboy/MacApplication.cs | 101 +++++++++++++++++++++++++++++++++++++-----
Tomboy/WindowsApplication.cs | 52 +++++++++++++++++-----
2 files changed, 131 insertions(+), 22 deletions(-)
---
diff --git a/Tomboy/MacApplication.cs b/Tomboy/MacApplication.cs
index 0eae103..7ea3c00 100644
--- a/Tomboy/MacApplication.cs
+++ b/Tomboy/MacApplication.cs
@@ -134,7 +134,7 @@ namespace Tomboy
}
- public class MacApplication : WindowsApplication
+ public class MacApplication : INativeApplication
{
private const string osxMenuXml =@"
<ui>
@@ -148,7 +148,60 @@ namespace Tomboy
</menubar>
</ui>
";
- public override void StartMainLoop ()
+
+ private static string confDir;
+ private static string dataDir;
+ private static string cacheDir;
+ private static string logDir;
+ private const string tomboyDirName = "Tomboy";
+
+ static MacApplication ()
+ {
+ string homeDir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
+ string libraryDir = Path.Combine (homeDir, "Library");
+
+ dataDir = Path.Combine (Path.Combine (libraryDir, "Application Support"),
+ tomboyDirName);
+ confDir = Path.Combine (Path.Combine (libraryDir, "Preferences"),
+ tomboyDirName);
+ cacheDir = Path.Combine (Path.Combine (libraryDir, "Caches"),
+ tomboyDirName);
+ logDir = Path.Combine (Path.Combine (libraryDir, "Logs"),
+ tomboyDirName);
+
+ // NOTE: Other directories created on demand
+ // (non-existence is an indicator that migration is needed)
+ if (!Directory.Exists (cacheDir))
+ Directory.CreateDirectory (cacheDir);
+ }
+
+ #region INativeApplication implementation
+
+ public event EventHandler ExitingEvent;
+
+ public virtual void Initialize (string locale_dir, string display_name, string process_name, string[] args)
+ {
+ Gtk.Application.Init ();
+ }
+
+ public virtual void RegisterSessionManagerRestart (string executable_path, string[] args, string[] environment)
+ {
+ // Do nothing
+ }
+
+ public virtual void RegisterSignalHandlers ()
+ {
+ // Nothing yet, but need to register for native exit signals?
+ }
+
+ public virtual void Exit (int exitcode)
+ {
+ if (ExitingEvent != null)
+ ExitingEvent (null, new EventArgs ());
+ System.Environment.Exit (exitcode);
+ }
+
+ public virtual void StartMainLoop ()
{
Gtk.UIManager uiManager = Tomboy.ActionManager.UI;
@@ -194,17 +247,43 @@ namespace Tomboy
Tomboy.ActionManager ["CloseWindowAction"].Visible = false;
- base.StartMainLoop ();
+ Gtk.Application.Run ();
+ }
+
+ public string DataDirectory {
+ get { return dataDir; }
+ }
+
+ public string ConfigurationDirectory {
+ get { return confDir; }
+ }
+
+ public string CacheDirectory {
+ get { return cacheDir; }
}
-
- [DllImport ("libc", EntryPoint="system")]
- public static extern int system (string command);
-
- public override void OpenUrl (string url, Gdk.Screen screen)
- {
- system ("open \"" + url + "\"");
- }
+ public string LogDirectory {
+ get { return logDir; }
+ }
+
+ public string PreOneDotZeroNoteDirectory {
+ get {
+ return Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
+ "tomboy");
+ }
+ }
+
+ [DllImport ("libc", EntryPoint="system")]
+ public static extern int system (string command);
+
+ public virtual void OpenUrl (string url, Gdk.Screen screen)
+ {
+ system ("open \"" + url + "\"");
+ }
+ public virtual void DisplayHelp (string help_uri, Gdk.Screen screen)
+ {
+ OpenUrl ("http://library.gnome.org/users/tomboy/0.12/", screen);
+ }
}
}
diff --git a/Tomboy/WindowsApplication.cs b/Tomboy/WindowsApplication.cs
index 7b6c9cb..4bbb27b 100644
--- a/Tomboy/WindowsApplication.cs
+++ b/Tomboy/WindowsApplication.cs
@@ -29,19 +29,31 @@ using System.IO;
namespace Tomboy
{
- // TODO: Rename to GtkApplication
public class WindowsApplication : INativeApplication
{
- private string confDir;
-
- public WindowsApplication ()
+ private static string confDir;
+ private static string dataDir;
+ private static string cacheDir;
+ private static string logDir;
+ private const string tomboyDirName = "Tomboy";
+
+ static WindowsApplication ()
{
- confDir = Path.Combine (
- Environment.GetFolderPath (
- Environment.SpecialFolder.ApplicationData),
- "tomboy");
+ string appDataPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
+ tomboyDirName);
+ string localAppDataPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData),
+ tomboyDirName);
+ dataDir = Path.Combine (appDataPath, "notes");
+ confDir = Path.Combine (appDataPath, "config");
+ cacheDir = Path.Combine (localAppDataPath, "cache");
+ logDir = localAppDataPath;
+
+ // NOTE: Other directories created on demand
+ // (non-existence is an indicator that migration is needed)
+ if (!Directory.Exists (cacheDir))
+ Directory.CreateDirectory (cacheDir);
}
-
+
#region INativeApplication implementation
public event EventHandler ExitingEvent;
@@ -73,11 +85,29 @@ namespace Tomboy
Gtk.Application.Run ();
}
- public virtual string ConfDir
- {
+ public string DataDirectory {
+ get { return dataDir; }
+ }
+
+ public string ConfigurationDirectory {
get { return confDir; }
}
+ public string CacheDirectory {
+ get { return cacheDir; }
+ }
+
+ public string LogDirectory {
+ get { return logDir; }
+ }
+
+ public string PreOneDotZeroNoteDirectory {
+ get {
+ return Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
+ "tomboy");
+ }
+ }
+
public virtual void OpenUrl (string url, Gdk.Screen screen)
{
try {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]