[tomboy/xdg-migration2: 2/16] Bugzilla (minus migration)



commit a4b2870495dfb20b075079aa7a7f5fc9e617c2f3
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date:   Sat Aug 22 12:25:11 2009 -0700

    Bugzilla (minus migration)

 Tomboy/Addins/Bugzilla/BugzillaLink.cs        |    7 ++++---
 Tomboy/Addins/Bugzilla/BugzillaNoteAddin.cs   |   10 ++++++++++
 Tomboy/Addins/Bugzilla/BugzillaPreferences.cs |   21 ++++++---------------
 3 files changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/Tomboy/Addins/Bugzilla/BugzillaLink.cs b/Tomboy/Addins/Bugzilla/BugzillaLink.cs
index a85f510..152c979 100644
--- a/Tomboy/Addins/Bugzilla/BugzillaLink.cs
+++ b/Tomboy/Addins/Bugzilla/BugzillaLink.cs
@@ -1,4 +1,6 @@
 using System;
+using System.IO;
+
 using Tomboy;
 
 namespace Tomboy.Bugzilla
@@ -60,9 +62,8 @@ namespace Tomboy.Bugzilla
 			}
 
 			string host = uri.Host;
-			// TODO: Get this in a safer way
-			string imageDir = "~/.tomboy/BugzillaIcons/";
-			string imagePath = imageDir.Replace ("~", Environment.GetEnvironmentVariable ("HOME")) + host + ".png";
+			string imagePath = Path.Combine (BugzillaNoteAddin.ImageDirectory,
+			                                 host + ".png");
 
 			try {
 				Image = new Gdk.Pixbuf (imagePath);
diff --git a/Tomboy/Addins/Bugzilla/BugzillaNoteAddin.cs b/Tomboy/Addins/Bugzilla/BugzillaNoteAddin.cs
index 4360741..61c0b57 100644
--- a/Tomboy/Addins/Bugzilla/BugzillaNoteAddin.cs
+++ b/Tomboy/Addins/Bugzilla/BugzillaNoteAddin.cs
@@ -1,5 +1,6 @@
 
 using System;
+using System.IO;
 using System.Runtime.InteropServices;
 using System.Text;
 using System.Text.RegularExpressions;
@@ -15,6 +16,15 @@ namespace Tomboy.Bugzilla
 	{
 		public const string BugzillaLinkTagName = "link:bugzilla";
 
+		public static string ImageDirectory { get; private set; }
+
+		static BugzillaNoteAddin ()
+		{
+			// TODO: Migration
+			ImageDirectory = Path.Combine (Services.NativeApplication.ConfigurationDirectory,
+			                               "BugzillaIcons");
+		}
+
 		public override void Initialize ()
 		{
 			if (!Note.TagTable.IsDynamicTagRegistered (BugzillaLinkTagName)) {
diff --git a/Tomboy/Addins/Bugzilla/BugzillaPreferences.cs b/Tomboy/Addins/Bugzilla/BugzillaPreferences.cs
index 09e14e9..d398fb2 100644
--- a/Tomboy/Addins/Bugzilla/BugzillaPreferences.cs
+++ b/Tomboy/Addins/Bugzilla/BugzillaPreferences.cs
@@ -14,15 +14,6 @@ namespace Tomboy.Bugzilla
 
 		string last_opened_dir;
 
-		static string IMAGE_DIR = "~/.tomboy/BugzillaIcons";
-		static string image_dir = null;
-
-		static BugzillaPreferences ()
-		{
-			// TODO: Get this in a safer way
-			image_dir = IMAGE_DIR.Replace ("~", Environment.GetEnvironmentVariable ("HOME"));
-		}
-
 		public BugzillaPreferences ()
 : base (false, 12)
 		{
@@ -116,14 +107,14 @@ namespace Tomboy.Bugzilla
 
 		void UpdateIconStore ()
 		{
-			// Read ~/.tomboy/BugzillaIcons/"
+			// Read ~/.config/tomboy/BugzillaIcons/"
 
-			if (!Directory.Exists (image_dir))
+			if (!Directory.Exists (BugzillaNoteAddin.ImageDirectory))
 				return;
 
 			icon_store.Clear (); // clear out the old entries
 
-			string [] icon_files = Directory.GetFiles (image_dir);
+			string [] icon_files = Directory.GetFiles (BugzillaNoteAddin.ImageDirectory);
 			foreach (string icon_file in icon_files) {
 				FileInfo file_info = new FileInfo (icon_file);
 
@@ -272,10 +263,10 @@ run_add_dialog:
 
 			FileInfo file_info = new FileInfo (file_path);
 			string ext = file_info.Extension;
-			string saved_path = System.IO.Path.Combine (image_dir, host + ext);
+			string saved_path = System.IO.Path.Combine (BugzillaNoteAddin.ImageDirectory, host + ext);
 			try {
-				if (!Directory.Exists (image_dir)) {
-					Directory.CreateDirectory (image_dir);
+				if (!Directory.Exists (BugzillaNoteAddin.ImageDirectory)) {
+					Directory.CreateDirectory (BugzillaNoteAddin.ImageDirectory);
 				}
 
 				File.Copy (file_path, saved_path);



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