[tasque/windows] Use a .config file for path settings (DataDir)



commit afbf0b74a0cc47157efc59dabb7a27f850be2102
Author: Antonius Riha <antoniusriha gmail com>
Date:   Fri Oct 26 19:02:49 2012 +0200

    Use a .config file for path settings (DataDir)
    
    This enables better integration with WiX Windows Installer,
    because the value of DataDir can now be set during install
    time instead of compile time.

 .gitignore                              |    1 +
 src/Gtk.Tasque/Defines.cs.in            |   34 +++++++++++++++++++++----------
 src/Gtk.Tasque/Gtk.Tasque.csproj        |    1 +
 src/Gtk.Tasque/GtkApplication.cs        |    3 --
 src/tasque/Tasque.exe.Defines.config.in |    6 +++++
 src/tasque/tasque.csproj                |    4 +++
 6 files changed, 35 insertions(+), 14 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index abb45f5..66812bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -103,6 +103,7 @@ Makefile.in
 /src/tasque/obj/
 !/src/tasque/Makefile.in
 /src/tasque/locale/
+/src/tasque/Tasque.exe.Defines.config
 
 # /src/Addins/Backends/*/
 /src/Addins/Backends/*/*.dll
diff --git a/src/Gtk.Tasque/Defines.cs.in b/src/Gtk.Tasque/Defines.cs.in
index a112e13..43d120c 100644
--- a/src/Gtk.Tasque/Defines.cs.in
+++ b/src/Gtk.Tasque/Defines.cs.in
@@ -2,7 +2,11 @@
  *  Defines.cs.in
  *
  *  Copyright (C) 2008 Novell, Inc.
- *  Written by Calvin Gaisford <calvinrg gmail com>
+ *  Copyright (C) 2012 Antonius Riha
+ *  
+ *  Written by
+ *  	Calvin Gaisford <calvinrg gmail com>
+ *  	Antonius Riha <antoniusriha gmail com>
  ****************************************************************************/
 
 /*  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
@@ -26,20 +30,28 @@
  *  DEALINGS IN THE SOFTWARE.
  */
 
-using System;
+using System.Configuration;
 using System.IO;
 
 namespace Tasque
 {
-	public class Defines
+	public static class Defines
 	{
-		public const string Version		= @"@version@";
-		public const string DataDir		= @"@datadir@";
-		public static string LocaleDir	= Path.Combine (@"@datadir@", "locale");
-		public static string IconsDir	= Path.Combine (@"@datadir@", "tasque", "icons");
-		public static string SoundDir	= Path.Combine (@"@datadir@", "tasque", "sounds");
-#if WIN
-		public static string GlobalIconsDir = Path.Combine (@"@datadir@", "icons");
-#endif
+		static Defines ()
+		{
+			var definesCfgFileMap = new ExeConfigurationFileMap ();
+			definesCfgFileMap.ExeConfigFilename = "Tasque.exe.Defines.config";
+			var cfg = ConfigurationManager.OpenMappedExeConfiguration (definesCfgFileMap, ConfigurationUserLevel.None);
+
+			var appSettings = cfg.AppSettings;
+			DataDir = appSettings.Settings ["DataDir"].Value;
+		}
+
+		public const string Version = @"@version@";
+		public static readonly string DataDir;
+
+		public static string LocaleDir { get { return Path.Combine (DataDir, "locale"); } }
+		public static string IconsDir { get { return Path.Combine (DataDir, "tasque", "icons"); } }
+		public static string SoundDir { get { return Path.Combine (DataDir, "tasque", "sounds"); } }
 	}
 }
diff --git a/src/Gtk.Tasque/Gtk.Tasque.csproj b/src/Gtk.Tasque/Gtk.Tasque.csproj
index fd246d8..72e9c14 100644
--- a/src/Gtk.Tasque/Gtk.Tasque.csproj
+++ b/src/Gtk.Tasque/Gtk.Tasque.csproj
@@ -47,6 +47,7 @@
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
+    <Reference Include="System.configuration" />
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
     <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
diff --git a/src/Gtk.Tasque/GtkApplication.cs b/src/Gtk.Tasque/GtkApplication.cs
index 141d03c..ba1c16b 100644
--- a/src/Gtk.Tasque/GtkApplication.cs
+++ b/src/Gtk.Tasque/GtkApplication.cs
@@ -53,9 +53,6 @@ namespace Tasque
 
 			// add package icon path to default icon theme search paths
 			Gtk.IconTheme.Default.PrependSearchPath (Defines.IconsDir);
-#if WIN
-			Gtk.IconTheme.Default.PrependSearchPath (Defines.GlobalIconsDir);
-#endif
 		}
 
 		public virtual void InitializeIdle ()
diff --git a/src/tasque/Tasque.exe.Defines.config.in b/src/tasque/Tasque.exe.Defines.config.in
new file mode 100644
index 0000000..52cbe79
--- /dev/null
+++ b/src/tasque/Tasque.exe.Defines.config.in
@@ -0,0 +1,6 @@
+ï<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <appSettings>
+    <add key="DataDir" value="@datadir@" />
+  </appSettings>
+</configuration>
\ No newline at end of file
diff --git a/src/tasque/tasque.csproj b/src/tasque/tasque.csproj
index 38dd266..178e9f4 100644
--- a/src/tasque/tasque.csproj
+++ b/src/tasque/tasque.csproj
@@ -94,6 +94,7 @@
   <ItemGroup>
     <Substitute Include="tasque.in" />
     <Substitute Include="tasque.pc.in" />
+    <Substitute Include="Tasque.exe.Defines.config.in" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Properties\" />
@@ -106,6 +107,9 @@
     <CreateItem Condition="'$(Configuration)' == 'GtkLinuxDebug' Or '$(Configuration)' == 'GtkLinuxRelease' " Include="$(SrcDir)\Tasque.exe.config" AdditionalMetadata="InstallPath=$(PkgLibDir);InstallFileName=Tasque.exe.config;Executable=false">
       <Output TaskParameter="Include" ItemName="InstallFile" />
     </CreateItem>
+    <CreateItem Include="Tasque.exe.Defines.config" AdditionalMetadata="InstallPath=$(PkgLibDir);InstallFileName=Tasque.exe.Defines.config;Executable=false">
+      <Output TaskParameter="Include" ItemName="InstallFile" />
+    </CreateItem>
     <CreateItem Include="tasque.pc" AdditionalMetadata="InstallPath=$(PkgConfigDir);InstallFileName=tasque.pc;Executable=false">
       <Output TaskParameter="Include" ItemName="InstallFile" />
     </CreateItem>



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