tomboy r2209 - in trunk: . Tomboy Tomboy/Addins/InsertTimestamp winbin



Author: sharm
Date: Sun Oct 12 15:22:50 2008
New Revision: 2209
URL: http://svn.gnome.org/viewvc/tomboy?rev=2209&view=rev

Log:
* tomboy/Tomboy/WindowsFactory.cs: IPlatformFactory implementation for
  Windows.

* tomboy/Tomboy.mdp:
* tomboy/Tomboy/Makefile.am: Add new files.

* tomboy/Tomboy/NativeApplication.cs: Adds INativeApplication interface,
  abstracted from the Application class in Utils.cs.

* tomboy/Tomboy/Utils.cs: Application now wraps INativeApplication, and
  the implementation has moved to GnomeApplication. 
  Gnome.Help.DisplayDesktopOnScreen ->
  Serivces.NativeApplication.DisplayHelp.  #if-out some libtomboy code
  in ForcedPresentWindow for WIN32 (this could be done better, of
  course).

* tomboy/Tomboy/Services.cs: Static class providing easy-access to
  platform-specific services.  Responsible for creating the right
  IPlatformFactory implementation.

* tomboy/Tomboy/GnomeFactory.cs: IPlatformFactory implementation for
  GNOME (maintains same behavior as Tomboy 0.12.0).

* tomboy/Tomboy/PreferencesClient.cs: Add IPreferencesClient,
  IPropertyEditor, and IPropertyEditorBool interfaces, modeled after
  GConf.  Also includes a NullPreferencesClient.

* tomboy/Tomboy/Tomboy.cs: Get note path from
  Services.NativeApplication.ConfDir.  #if-out some GNOME Panel code
  for WIN32.

* tomboy/Tomboy/PlatformFactory.cs: Adds IPlatformFactory interface for
  creating platform-specific instances of new interfaces.

* tomboy/winbin: Binaries for building and running on Windows without
  needing a Mono install.

* tomboy/Tomboy/Watchers.cs: GConf -> IPreferencesClient. 
  Gnome.Url.Show -> Services.NativeApplication.OpenUrl.

* tomboy/Tomboy.sln:
* tomboy/Tomboy.csproj: Visual Studio solution/project for building on
  Windows.  Tested in Visual Studio 2008 and SharpDevelop 3.

* tomboy/Tomboy/WindowsApplication.cs: INativeApplication implementation
  for Windows.

* tomboy/Tomboy/XmlPreferencesClient.cs: An IPreferencesClient
  implementation that uses an XML file backend.

* tomboy/Tomboy/Logger.cs: A few hacks to run in Windows that need to be
  reviewed.

* tomboy/Tomboy/PreferencesDialog.cs: GConf -> IPreferencesClient. 
  Also, only show Hotkeys preferences if a keybinder other than
  NullKeybinder is available.

* tomboy/Tomboy/GConfPreferencesClient.cs: An IPreferencesClient
  implementation that uses a GConf backend.

* tomboy/Tomboy/NoteWindow.cs:
* tomboy/Tomboy/NoteEditor.cs:
* tomboy/Tomboy/Preferences.cs:
* tomboy/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs:
* tomboy/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs:
  GConf -> IPreferencesClient.

* tomboy/Tomboy/Keybinder.cs: Simple IKeybinder interface for binding
  keys to actions, and a NullKeybinder implementation.

* tomboy/Tomboy/GnomeApplication.cs: INativeApplication implementation
  for GNOME.

* tomboy/Tomboy/NoteManager.cs: GConf -> IPreferencesClient.  Get Tomboy
  configuration directory from Services.NativeApplication.

* tomboy/Tomboy/XKeybinder.cs: Implementation of IKeybinder for X11
  environments.

* tomboy/Tomboy/PrefsKeybinder.cs: Lifted from XKeybinder.cs.  GConf ->
  IPreferencesClient, etc.

* tomboy/Tomboy/Tray.cs:
* tomboy/Tomboy/Applet.cs: New ITomboyTray interface, implemented by
  tray and applet.  Accelerator DllImports moved to keybinder code. 
  Use GetPointer instead of GetGeometry on WIN32 to work-around a
  gtk-sharp bug (Doug Johnston).  Rearrange note menu item management
  code to prevent duplication (bug #531774, Boyd Timothy, Samuel
  Vandamme).

Added:
   trunk/Tomboy.csproj
   trunk/Tomboy.sln
   trunk/Tomboy/GConfPreferencesClient.cs   (contents, props changed)
   trunk/Tomboy/GnomeApplication.cs   (contents, props changed)
   trunk/Tomboy/GnomeFactory.cs   (contents, props changed)
   trunk/Tomboy/Keybinder.cs   (contents, props changed)
   trunk/Tomboy/NativeApplication.cs   (contents, props changed)
   trunk/Tomboy/PlatformFactory.cs   (contents, props changed)
   trunk/Tomboy/PreferencesClient.cs   (contents, props changed)
   trunk/Tomboy/PrefsKeybinder.cs   (contents, props changed)
   trunk/Tomboy/Services.cs   (contents, props changed)
   trunk/Tomboy/WindowsApplication.cs   (contents, props changed)
   trunk/Tomboy/WindowsFactory.cs   (contents, props changed)
   trunk/Tomboy/XmlPreferencesClient.cs   (contents, props changed)
   trunk/winbin/
   trunk/winbin/ICSharpCode.SharpZipLib.dll   (contents, props changed)
   trunk/winbin/Mono.Addins.Gui.dll   (contents, props changed)
   trunk/winbin/Mono.Addins.Setup.dll   (contents, props changed)
   trunk/winbin/Mono.Addins.dll   (contents, props changed)
   trunk/winbin/Mono.Addins.dll.config
   trunk/winbin/Mono.Posix.dll   (contents, props changed)
   trunk/winbin/MonoPosixHelper.dll   (contents, props changed)
Modified:
   trunk/ChangeLog
   trunk/Tomboy.mdp
   trunk/Tomboy/AddinManager.cs
   trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs
   trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs
   trunk/Tomboy/Applet.cs
   trunk/Tomboy/Logger.cs
   trunk/Tomboy/Makefile.am
   trunk/Tomboy/NoteEditor.cs
   trunk/Tomboy/NoteManager.cs
   trunk/Tomboy/NoteWindow.cs
   trunk/Tomboy/Preferences.cs
   trunk/Tomboy/PreferencesDialog.cs
   trunk/Tomboy/Tomboy.cs
   trunk/Tomboy/Tray.cs
   trunk/Tomboy/Utils.cs
   trunk/Tomboy/Watchers.cs
   trunk/Tomboy/XKeybinder.cs

Added: trunk/Tomboy.csproj
==============================================================================
--- (empty file)
+++ trunk/Tomboy.csproj	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,226 @@
+ï<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"; ToolsVersion="3.5">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.21022</ProductVersion>
+    <ProjectGuid>{315DBB30-1461-4A41-A23F-A888D84E1EA0}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AssemblyName>Tomboy</AssemblyName>
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+    <FileUpgradeFlags>
+    </FileUpgradeFlags>
+    <OldToolsVersion>2.0</OldToolsVersion>
+    <UpgradeBackupLocation>
+    </UpgradeBackupLocation>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+    <Execution>
+      <Execution xmlns="" />
+    </Execution>
+    <Build>
+      <Build xmlns="" />
+    </Build>
+    <DefineConstants>WIN32</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+    <Execution>
+      <Execution xmlns="" />
+    </Execution>
+    <Build>
+      <Build xmlns="" />
+    </Build>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="atk-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\Program Files\Medsphere\Gtk# SDK\lib\gtk-sharp-2.0\atk\atk-sharp.dll</HintPath>
+    </Reference>
+    <Reference Include="gdk-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <Reference Include="gtk-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>winbin\ICSharpCode.SharpZipLib.dll</HintPath>
+    </Reference>
+    <Reference Include="Mono.Addins, Version=0.3.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>winbin\Mono.Addins.dll</HintPath>
+    </Reference>
+    <Reference Include="Mono.Addins.Gui, Version=0.3.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>winbin\Mono.Addins.Gui.dll</HintPath>
+    </Reference>
+    <Reference Include="Mono.Addins.Setup, Version=0.3.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>winbin\Mono.Addins.Setup.dll</HintPath>
+    </Reference>
+    <Reference Include="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>winbin\Mono.Posix.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Xml" />
+    <Reference Include="glib-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <Reference Include="System" />
+    <Reference Include="pango-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <Reference Include="Mono.Cairo" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Tomboy\ActionManager.cs" />
+    <Compile Include="Tomboy\Contrast.cs" />
+    <Compile Include="Tomboy\Logger.cs" />
+    <Compile Include="Tomboy\Note.cs" />
+    <Compile Include="Tomboy\NoteBuffer.cs" />
+    <Compile Include="Tomboy\NoteManager.cs" />
+    <Compile Include="Tomboy\NoteTag.cs" />
+    <Compile Include="Tomboy\NoteWindow.cs" />
+    <Compile Include="Tomboy\Preferences.cs" />
+    <Compile Include="Tomboy\RecentChanges.cs" />
+    <Compile Include="Tomboy\Tomboy.cs" />
+    <Compile Include="Tomboy\Tray.cs" />
+    <Compile Include="Tomboy\Trie.cs" />
+    <Compile Include="Tomboy\Undo.cs" />
+    <Compile Include="Tomboy\Utils.cs" />
+    <Compile Include="Tomboy\Watchers.cs" />
+    <Compile Include="Tomboy\TagManager.cs" />
+    <Compile Include="Tomboy\Tag.cs" />
+    <Compile Include="Tomboy\TagButton.cs" />
+    <Compile Include="Tomboy\WrapBox.cs" />
+    <Compile Include="Tomboy\Defines.cs" />
+    <Compile Include="Tomboy\PreferencesDialog.cs" />
+    <Compile Include="Tomboy\NoteEditor.cs" />
+    <Compile Include="Tomboy\AbstractAddin.cs" />
+    <Compile Include="Tomboy\ApplicationAddin.cs" />
+    <Compile Include="Tomboy\NoteAddin.cs" />
+    <Compile Include="Tomboy\AddinManager.cs" />
+    <Compile Include="Tomboy\AddinPreferenceFactory.cs" />
+    <Compile Include="Tomboy\Synchronization\SyncDialog.cs" />
+    <Compile Include="Tomboy\Synchronization\SyncManager.cs" />
+    <Compile Include="Tomboy\Synchronization\SyncUtils.cs" />
+    <Compile Include="Tomboy\Synchronization\TomboySyncClient.cs" />
+    <Compile Include="Tomboy\Synchronization\FileSystemSyncServer.cs" />
+    <Compile Include="Tomboy\Synchronization\SyncServiceAddin.cs" />
+    <Compile Include="Tomboy\TagEntry.cs" />
+    <Compile Include="Tomboy\Search.cs" />
+    <Compile Include="Tomboy\Notebooks\Notebook.cs" />
+    <Compile Include="Tomboy\Notebooks\NotebookManager.cs" />
+    <Compile Include="Tomboy\Notebooks\CreateNotebookDialog.cs" />
+    <Compile Include="Tomboy\Notebooks\NotebookNoteAddin.cs" />
+    <Compile Include="Tomboy\Notebooks\NotebookMenuItem.cs" />
+    <Compile Include="Tomboy\Notebooks\NotebookApplicationAddin.cs" />
+    <Compile Include="Tomboy\Notebooks\NotebookNewNoteMenuItem.cs" />
+    <Compile Include="Tomboy\PreferenceTabAddin.cs" />
+    <Compile Include="Tomboy\Notebooks\NotebooksTreeView.cs" />
+    <Compile Include="Tomboy\RecentTreeView.cs" />
+    <Compile Include="Tomboy\Services.cs" />
+    <Compile Include="Tomboy\Keybinder.cs" />
+    <Compile Include="Tomboy\NativeApplication.cs" />
+    <Compile Include="Tomboy\PlatformFactory.cs" />
+    <Compile Include="Tomboy\PreferencesClient.cs" />
+    <Compile Include="Tomboy\PrefsKeybinder.cs" />
+    <Compile Include="Tomboy\WindowsApplication.cs" />
+    <Compile Include="Tomboy\XmlPreferencesClient.cs" />
+    <None Include="ChangeLog" />
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="UIManagerLayout.xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Tomboy.addin.xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="filter-note-all.png" />
+    <EmbeddedResource Include="filter-note-unfiled.png" />
+    <EmbeddedResource Include="note-new.png" />
+    <EmbeddedResource Include="note.png" />
+    <EmbeddedResource Include="notebook-new.png" />
+    <EmbeddedResource Include="notebook.png" />
+    <EmbeddedResource Include="pin-active.png" />
+    <EmbeddedResource Include="pin-down.png" />
+    <EmbeddedResource Include="pin-up.png" />
+    <EmbeddedResource Include="tomboy.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Tomboy\Defines.cs.in" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ProjectExtensions>
+    <MonoDevelop>
+      <Properties xmlns="">
+        <GtkDesignInfo gtkVersion="2.10.3" />
+        <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="./Makefile.am" ExecuteTargetName="run">
+          <BuildFilesVar />
+          <DeployFilesVar />
+          <ResourcesVar />
+          <OthersVar />
+          <GacRefVar />
+          <AsmRefVar />
+          <ProjectRefVar />
+        </MonoDevelop.Autotools.MakefileInfo>
+      </Properties>
+    </MonoDevelop>
+    <VisualStudio />
+  </ProjectExtensions>
+  <PropertyGroup>
+    <PreBuildEvent>copy "$(ProjectDir)data\icons\hicolor_apps_48x48_tomboy.png" "$(ProjectDir)tomboy.png"
+copy "$(ProjectDir)data\icons\hicolor_places_22x22_note.png" "$(ProjectDir)note.png"
+copy "$(ProjectDir)data\icons\hicolor_actions_16x16_note-new.png" "$(ProjectDir)note-new.png"
+copy "$(ProjectDir)data\icons\hicolor_actions_22x22_filter-note-all.png" "$(ProjectDir)filter-note-all.png"
+copy "$(ProjectDir)data\icons\hicolor_actions_22x22_filter-note-unfiled.png" "$(ProjectDir)\filter-note-unfiled.png"
+copy "$(ProjectDir)data\icons\hicolor_places_22x22_notebook.png" "$(ProjectDir)notebook.png"
+copy "$(ProjectDir)data\icons\hicolor_actions_48x48_notebook-new.png" "$(ProjectDir)notebook-new.png"
+copy "$(ProjectDir)data\icons\hicolor_status_16x16_pin-down.png" "$(ProjectDir)pin-down.png"
+copy "$(ProjectDir)data\icons\hicolor_status_16x16_pin-up.png" "$(ProjectDir)pin-up.png"
+copy "$(ProjectDir)data\icons\hicolor_status_16x16_pin-active.png" "$(ProjectDir)pin-active.png"
+copy "$(ProjectDir)Tomboy\Tomboy.addin.xml" "$(ProjectDir)"
+copy "$(ProjectDir)data\UIManagerLayout.xml" "$(ProjectDir)"
+copy "$(ProjectDir)Tomboy\Defines.cs.in" "$(ProjectDir)Tomboy\Defines.cs"</PreBuildEvent>
+    <PostBuildEvent>copy "$(ProjectDir)winbin\MonoPosixHelper.dll" "$(ProjectDir)bin\Debug"
+copy "$(ProjectDir)winbin\Mono.Addins.dll.config" "$(ProjectDir)bin\Debug"</PostBuildEvent>
+  </PropertyGroup>
+</Project>
\ No newline at end of file

Modified: trunk/Tomboy.mdp
==============================================================================
--- trunk/Tomboy.mdp	(original)
+++ trunk/Tomboy.mdp	Sun Oct 12 15:22:50 2008
@@ -206,6 +206,18 @@
     <File name="Tomboy/Addins/GalagoPresence/GalagoPresenceNoteAddin.cs" subtype="Code" buildaction="Compile" />
     <File name="Tomboy/RecentTreeView.cs" subtype="Code" buildaction="Compile" />
     <File name="Mono.Addins/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/Services.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/GConfPreferencesClient.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/GnomeApplication.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/Keybinder.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/NativeApplication.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/PlatformFactory.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/PreferencesClient.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/PrefsKeybinder.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/XmlPreferencesClient.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/WindowsApplication.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/GnomeFactory.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/WindowsFactory.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
@@ -218,6 +230,7 @@
     <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
   </References>
+  <GtkDesignInfo />
   <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" ExecuteTargetName="run">
     <BuildFilesVar />
     <DeployFilesVar />

Added: trunk/Tomboy.sln
==============================================================================
--- (empty file)
+++ trunk/Tomboy.sln	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,26 @@
+ï
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tomboy", "Tomboy.csproj", "{315DBB30-1461-4A41-A23F-A888D84E1EA0}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{315DBB30-1461-4A41-A23F-A888D84E1EA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{315DBB30-1461-4A41-A23F-A888D84E1EA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{315DBB30-1461-4A41-A23F-A888D84E1EA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{315DBB30-1461-4A41-A23F-A888D84E1EA0}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(MonoDevelopProperties) = preSolution
+		name = Tomboy
+		StartupItem = Tomboy.csproj
+		MakePkgConfig = False
+		MakeLibPC = True
+	EndGlobalSection
+EndGlobal

Modified: trunk/Tomboy/AddinManager.cs
==============================================================================
--- trunk/Tomboy/AddinManager.cs	(original)
+++ trunk/Tomboy/AddinManager.cs	Sun Oct 12 15:22:50 2008
@@ -6,7 +6,6 @@
 using System.IO;
 
 using Mono.Unix;
-using Mono.Unix.Native;
 
 using Tomboy.Sync;
 

Modified: trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs	(original)
+++ trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs	Sun Oct 12 15:22:50 2008
@@ -47,7 +47,7 @@
 			Buffer.InsertWithTagsByName (ref cursor, text, "datetime");
 		}
 
-		void OnFormatSettingChanged (object sender, GConf.NotifyEventArgs args)
+		void OnFormatSettingChanged (object sender, NotifyEventArgs args)
 		{
 			if (args.Key == Preferences.INSERT_TIMESTAMP_FORMAT)
 				date_format = (string) args.Value;

Modified: trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs
==============================================================================
--- trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs	(original)
+++ trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs	Sun Oct 12 15:22:50 2008
@@ -6,7 +6,6 @@
 using System;
 using System.Collections.Generic;
 
-using GConf.PropertyEditors;
 using Mono.Unix;
 
 using Tomboy;
@@ -91,7 +90,7 @@
 			custom_entry = new Gtk.Entry ();
 			customBox.PackStart (custom_entry);
 
-			PropertyEditorEntry entryEditor = new PropertyEditorEntry (
+			IPropertyEditor entryEditor = Services.Factory.CreatePropertyEditorEntry (
 				Preferences.INSERT_TIMESTAMP_FORMAT, custom_entry);
 			entryEditor.Setup ();
 

Modified: trunk/Tomboy/Applet.cs
==============================================================================
--- trunk/Tomboy/Applet.cs	(original)
+++ trunk/Tomboy/Applet.cs	Sun Oct 12 15:22:50 2008
@@ -18,7 +18,7 @@
 	{
 		NoteManager manager;
 		TomboyAppletEventBox applet_event_box;
-		TomboyGConfXKeybinder keybinder;
+		TomboyPrefsKeybinder keybinder;
 
 		// Keep referenced so our callbacks don't get reaped.
 		static BonoboUIVerb [] menu_verbs;
@@ -48,7 +48,7 @@
 
 			manager = Tomboy.DefaultNoteManager;
 			applet_event_box = new TomboyAppletEventBox (manager);
-			keybinder = new TomboyGConfXKeybinder (manager, applet_event_box.Tray);
+			keybinder = new TomboyPrefsKeybinder (manager, applet_event_box);
 
 			Flags |= PanelAppletFlags.ExpandMinor;
 
@@ -139,7 +139,7 @@
 	
 	public enum PanelOrientation { Horizontal, Vertical };
 	
-	public class TomboyAppletEventBox : Gtk.EventBox
+	public class TomboyAppletEventBox : Gtk.EventBox, ITomboyTray
 	{
 		NoteManager manager;
 		TomboyTray tray;
@@ -399,6 +399,24 @@
 
 			InitPixbuf ();
 		}
+
+		public bool MenuOpensUpward ()
+		{
+			bool open_upwards = false;
+			int val = 0;
+			Gdk.Screen screen = null;
+
+			int x, y;
+			GdkWindow.GetOrigin (out x, out y);
+			val = y;
+			screen = Screen;
+
+			Gtk.Requisition menu_req = tray.TomboyTrayMenu.SizeRequest ();
+			if (val + menu_req.Height >= screen.Height)
+				open_upwards = true;
+
+			return open_upwards;
+		}
 	}
 }
 

Added: trunk/Tomboy/GConfPreferencesClient.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/GConfPreferencesClient.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,110 @@
+using System;
+using System.Collections.Generic;
+
+namespace Tomboy
+{
+	public class GConfPreferencesClient : IPreferencesClient
+	{
+		private GConf.Client client;
+		private List<NotifyWrapper> wrapper_list;
+
+		public GConfPreferencesClient ()
+		{
+			client = new GConf.Client ();
+			wrapper_list = new List<NotifyWrapper> ();
+		}
+
+		public void Set (string key, object val)
+		{
+			try {
+				client.Set (key, val);
+			} catch {	// TODO: what kind?
+			        throw new Exception ("Error setting key: " + key);	// TODO: can do better than this
+			}
+		}
+
+		public object Get (string key)
+		{
+			try {
+				return client.Get (key);
+			} catch (GConf.NoSuchKeyException) {
+				throw new NoSuchKeyException (key);
+			}
+		}
+
+		public void AddNotify (string dir, NotifyEventHandler notify)
+		{
+			if (dir == null)
+				throw new NullReferenceException("dir");
+			if (notify == null)
+				throw new NullReferenceException("notify");
+
+			NotifyWrapper wrapper = new NotifyWrapper (notify, dir);
+			client.AddNotify (dir, wrapper.HandleNotify);
+			wrapper_list.Add (wrapper);
+		}
+
+		public void RemoveNotify (string dir, NotifyEventHandler notify)
+		{
+			if (dir == null)
+				throw new NullReferenceException("dir");
+			if (notify == null)
+				throw new NullReferenceException("notify");
+
+			NotifyWrapper wrapper_to_remove = null;
+			foreach (NotifyWrapper wrapper in wrapper_list)
+				if (wrapper.dir.Equals (dir) && wrapper.notify.Equals (notify)) {
+					wrapper_to_remove = wrapper;
+					break;
+				}
+
+			// NOTE: For some unknown reason, the RemoveNotify call does not
+			//		 work here.  That is why we explicitly disable the wrapper,
+			//		 since it will unfortunately continue to exist and get
+			//		 inappropriately notified.
+			if (wrapper_to_remove != null) {
+				client.RemoveNotify (dir, wrapper_to_remove.HandleNotify);
+				wrapper_to_remove.enabled = false;
+				wrapper_list.Remove (wrapper_to_remove);
+			}
+		}
+
+		public void SuggestSync ()
+		{
+			client.SuggestSync ();
+		}
+
+		class NotifyWrapper
+		{
+			public NotifyEventHandler notify;
+			public string dir;
+			public bool enabled = true;
+
+			public NotifyWrapper (NotifyEventHandler notify, string dir)
+			{
+				this.notify = notify;
+				this.dir = dir;
+			}
+
+			public void HandleNotify (object sender, GConf.NotifyEventArgs args)
+			{
+				if (!enabled)
+					return;
+				
+				NotifyEventArgs newArgs = new NotifyEventArgs (args.Key, args.Value);
+				notify (sender, newArgs);
+			}
+		}
+	}
+
+
+	public class GConfPropertyEditorToggleButton : GConf.PropertyEditors.PropertyEditorToggleButton, IPropertyEditorBool
+	{
+		public GConfPropertyEditorToggleButton (string key, Gtk.CheckButton sourceButton) : base (key, sourceButton) {}
+	}
+
+	public class GConfPropertyEditorEntry : GConf.PropertyEditors.PropertyEditorEntry, IPropertyEditor
+	{
+		public GConfPropertyEditorEntry (string key, Gtk.Entry sourceEntry) : base (key, sourceEntry) { }
+	}
+}

Added: trunk/Tomboy/GnomeApplication.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/GnomeApplication.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,172 @@
+using System;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.IO;
+using System.Xml;
+
+using Mono.Unix;
+using Mono.Unix.Native;
+
+namespace Tomboy
+{
+	public class GnomeApplication : INativeApplication
+	{
+		private Gnome.Program program;
+		private string confDir;
+
+		public GnomeApplication ()
+		{
+			confDir = Path.Combine (Environment.GetEnvironmentVariable ("HOME"),
+			                        ".tomboy");
+		}
+
+		public void Initialize (string locale_dir,
+		                        string display_name,
+		                        string process_name,
+		                        string [] args)
+		{
+			try {
+				SetProcessName (process_name);
+			} catch {} // Ignore exception if fail (not needed to run)
+
+			Gtk.Application.Init ();
+			program = new Gnome.Program (display_name,
+			                             Defines.VERSION,
+			                             Gnome.Modules.UI,
+			                             args);
+
+			// Register handler for saving session when logging out of Gnome
+			Gnome.Client client = Gnome.Global.MasterClient ();
+			client.SaveYourself += OnSaveYourself;
+		}
+
+		public void RegisterSessionManagerRestart (string executable_path,
+		                string[] args,
+		                string[] environment)
+		{
+			if (executable_path == null)
+				return;
+
+			// Restart if we are running when the session ends or at crash...
+			Gnome.Client client = Gnome.Global.MasterClient ();
+			client.RestartStyle =
+			        Gnome.RestartStyle.IfRunning | Gnome.RestartStyle.Immediately;
+			client.Die += OnSessionManagerDie;
+
+			foreach (string env in environment) {
+				string [] split = env.Split (new char [] { '=' }, 2);
+				if (split.Length == 2) {
+					client.SetEnvironment (split[0], split[1]);
+				}
+			}
+
+			// Get the args for session restart...
+			string [] restart_args = new string [args.Length + 1];
+			restart_args [0] = executable_path;
+			args.CopyTo (restart_args, 1);
+			client.SetRestartCommand (restart_args.Length, restart_args);
+		}
+
+		public void RegisterSignalHandlers ()
+		{
+			// Connect to SIGTERM and SIGINT, so we don't lose
+			// unsaved notes on exit...
+			Stdlib.signal (Signum.SIGTERM, OnExitSignal);
+			Stdlib.signal (Signum.SIGINT, OnExitSignal);
+		}
+
+		public event EventHandler ExitingEvent;
+
+		public void Exit (int exitcode)
+		{
+			OnExitSignal (-1);
+			System.Environment.Exit (exitcode);
+		}
+
+		public void StartMainLoop ()
+		{
+			program.Run ();
+		}
+
+		public void QuitMainLoop ()
+		{
+			Gtk.Main.Quit ();
+		}
+
+		[DllImport("libc")]
+		private static extern int prctl (int option,
+			                                 byte [] arg2,
+			                                 IntPtr arg3,
+			                                 IntPtr arg4,
+			                                 IntPtr arg5);
+
+		// From Banshee: Banshee.Base/Utilities.cs
+		private void SetProcessName (string name)
+		{
+			if (prctl (15 /* PR_SET_NAME */,
+			                Encoding.ASCII.GetBytes (name + "\0"),
+			                IntPtr.Zero,
+			                IntPtr.Zero,
+			                IntPtr.Zero) != 0)
+				throw new ApplicationException (
+				        "Error setting process name: " +
+				        Mono.Unix.Native.Stdlib.GetLastError ());
+		}
+
+		private void OnSessionManagerDie (object sender, EventArgs args)
+		{
+			// Don't let the exit signal run, which would cancel
+			// session management.
+			QuitMainLoop ();
+		}
+
+		private void CancelSessionManagerRestart ()
+		{
+			Gnome.Client client = Gnome.Global.MasterClient ();
+			client.RestartStyle = Gnome.RestartStyle.IfRunning;
+			client.Flush ();
+		}
+
+		private void OnExitSignal (int signal)
+		{
+			// Don't auto-restart after exit/kill.
+			CancelSessionManagerRestart ();
+
+			if (ExitingEvent != null)
+				ExitingEvent (null, new EventArgs ());
+
+			if (signal >= 0)
+				System.Environment.Exit (0);
+		}
+
+		private void OnSaveYourself (object sender, Gnome.SaveYourselfArgs args)
+		{
+			Logger.Log ("Received request for saving session");
+
+			if (ExitingEvent != null)
+				ExitingEvent (null, new EventArgs ());
+		}
+		
+		public void OpenUrl (string url)
+		{
+			Gnome.Url.Show (url);
+		}
+		
+		public void DisplayHelp (string filename, string link_id, Gdk.Screen screen)
+		{
+			Gnome.Help.DisplayDesktopOnScreen (
+			        Gnome.Program.Get (),
+			        Defines.GNOME_HELP_DIR,
+			        filename,
+			        link_id,
+			        screen);
+		}
+		
+		public string ConfDir {
+			get {
+				return confDir;
+			}
+		}
+	}
+}

Added: trunk/Tomboy/GnomeFactory.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/GnomeFactory.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,31 @@
+namespace Tomboy
+{
+	public class GnomeFactory : IPlatformFactory
+	{
+		public IPropertyEditor CreatePropertyEditorEntry (string key, Gtk.Entry sourceEntry)
+		{
+			return new GConfPropertyEditorEntry (key, sourceEntry);
+		}
+
+		public IPropertyEditorBool CreatePropertyEditorToggleButton (
+		        string key, Gtk.CheckButton sourceButton)
+		{
+			return new GConfPropertyEditorToggleButton (key, sourceButton);
+		}
+
+		public IPreferencesClient CreatePreferencesClient ()
+		{
+			return new GConfPreferencesClient ();
+		}
+
+		public INativeApplication CreateNativeApplication ()
+		{
+			return new GnomeApplication ();
+		}
+
+		public IKeybinder CreateKeybinder ()
+		{
+			return new XKeybinder ();
+		}
+	}
+}
\ No newline at end of file

Added: trunk/Tomboy/Keybinder.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Keybinder.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,41 @@
+using System;
+
+namespace Tomboy
+{
+	public interface IKeybinder
+	{
+		void Bind (string keystring, EventHandler handler);
+		void Unbind (string keystring);
+		void UnbindAll ();
+		bool GetAccelKeys (string prefs_path, out uint keyval, out Gdk.ModifierType mods);
+	}
+
+	public class NullKeybinder : IKeybinder
+	{
+		#region IKeybinder implementation 
+		
+		public void Bind (string keystring, EventHandler handler)
+		{
+			// Do nothing
+		}
+		
+		public void Unbind (string keystring)
+		{
+			// Do nothing
+		}
+		
+		public void UnbindAll ()
+		{
+			// Do nothing
+		}
+		
+		public bool GetAccelKeys (string prefs_path, out uint keyval, out Gdk.ModifierType mods)
+		{
+			keyval = 0;
+			mods = Gdk.ModifierType.None;
+			return false;
+		}
+		
+		#endregion
+	}
+}

Modified: trunk/Tomboy/Logger.cs
==============================================================================
--- trunk/Tomboy/Logger.cs	(original)
+++ trunk/Tomboy/Logger.cs	Sun Oct 12 15:22:50 2008
@@ -35,7 +35,11 @@
 		{
 			try {
 				log = File.CreateText (Path.Combine (
+#if WIN32
+				                               Services.NativeApplication.ConfDir,
+#else
 				                               Environment.GetEnvironmentVariable ("HOME"),
+#endif
 				                               ".tomboy.log"));
 				log.Flush ();
 			} catch (IOException) {
@@ -48,7 +52,9 @@
 		~FileLogger ()
 		{
 			if (log != null)
-				log.Flush ();
+				try {
+					log.Flush ();
+				} catch { }
 		}
 
 		public void Log (Level lvl, string msg, params object[] args)

Modified: trunk/Tomboy/Makefile.am
==============================================================================
--- trunk/Tomboy/Makefile.am	(original)
+++ trunk/Tomboy/Makefile.am	Sun Oct 12 15:22:50 2008
@@ -44,7 +44,12 @@
 	$(srcdir)/Applet.cs 			\
 	$(srcdir)/ApplicationAddin.cs		\
 	$(srcdir)/Contrast.cs		\
+	$(srcdir)/GConfPreferencesClient.cs	\
+	$(srcdir)/GnomeApplication.cs		\
+	$(srcdir)/GnomeFactory.cs		\
+	$(srcdir)/Keybinder.cs			\
 	$(srcdir)/Logger.cs			\
+	$(srcdir)/NativeApplication.cs		\
 	$(srcdir)/Note.cs 			\
 	$(srcdir)/NoteAddin.cs			\
 	$(srcdir)/NoteEditor.cs			\
@@ -52,11 +57,15 @@
 	$(srcdir)/NoteWindow.cs 		\
 	$(srcdir)/NoteBuffer.cs 		\
 	$(srcdir)/NoteTag.cs 			\
+	$(srcdir)/PlatformFactory.cs		\
 	$(srcdir)/Preferences.cs		\
+	$(srcdir)/PreferencesClient.cs		\
 	$(srcdir)/PreferencesDialog.cs		\
 	$(srcdir)/PreferenceTabAddin.cs		\
+	$(srcdir)/PrefsKeybinder.cs		\
 	$(srcdir)/RecentChanges.cs		\
 	$(srcdir)/RecentTreeView.cs		\
+	$(srcdir)/Services.cs			\
 	$(srcdir)/Tag.cs			\
 	$(srcdir)/TagButton.cs			\
 	$(srcdir)/TagManager.cs			\

Added: trunk/Tomboy/NativeApplication.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/NativeApplication.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,30 @@
+using System;
+
+namespace Tomboy
+{
+	public interface INativeApplication
+	{
+		void Initialize (string locale_dir,
+		                 string display_name,
+		                 string process_name,
+		                 string [] args);
+
+		void RegisterSessionManagerRestart (string executable_path,
+		                                    string[] args,
+		                                    string[] environment);
+		void RegisterSignalHandlers ();
+		event EventHandler ExitingEvent;
+
+		void Exit (int exitcode);
+		void StartMainLoop ();
+		void QuitMainLoop ();
+
+		string ConfDir { get; }
+
+		void OpenUrl (string url);
+
+		void DisplayHelp (string filename,
+			string link_id,
+			Gdk.Screen screen);
+	}
+}

Modified: trunk/Tomboy/NoteEditor.cs
==============================================================================
--- trunk/Tomboy/NoteEditor.cs	(original)
+++ trunk/Tomboy/NoteEditor.cs	Sun Oct 12 15:22:50 2008
@@ -61,7 +61,7 @@
 				string doc_font_string = (string)
 				                         Preferences.Client.Get (GNOME_DOCUMENT_FONT_KEY);
 				return Pango.FontDescription.FromString (doc_font_string);
-			} catch (GConf.NoSuchKeyException) {
+			} catch (NoSuchKeyException) {
 			} catch (System.InvalidCastException) {
 			}
 
@@ -72,7 +72,7 @@
 		// Update the font based on the changed Preference dialog setting.
 		// Also update the font based on the changed GConf GNOME document font setting.
 		//
-		void OnFontSettingChanged (object sender, GConf.NotifyEventArgs args)
+		void OnFontSettingChanged (object sender, NotifyEventArgs args)
 		{
 			switch (args.Key) {
 			case Preferences.ENABLE_CUSTOM_FONT:

Modified: trunk/Tomboy/NoteManager.cs
==============================================================================
--- trunk/Tomboy/NoteManager.cs	(original)
+++ trunk/Tomboy/NoteManager.cs	Sun Oct 12 15:22:50 2008
@@ -31,7 +31,7 @@
 			Preferences.SettingChanged += OnSettingChanged;
 		}
 
-		static void OnSettingChanged (object sender, GConf.NotifyEventArgs args)
+		static void OnSettingChanged (object sender, NotifyEventArgs args)
 		{
 			switch (args.Key) {
 			case Preferences.START_NOTE_URI:
@@ -78,9 +78,7 @@
 
 		protected virtual AddinManager CreateAddinManager ()
 		{
-			string tomboy_conf_dir =
-			        Path.Combine (Environment.GetEnvironmentVariable ("HOME"),
-			                      ".tomboy");
+			string tomboy_conf_dir = Services.NativeApplication.ConfDir;
 
 			return new AddinManager (tomboy_conf_dir);
 		}

Modified: trunk/Tomboy/NoteWindow.cs
==============================================================================
--- trunk/Tomboy/NoteWindow.cs	(original)
+++ trunk/Tomboy/NoteWindow.cs	Sun Oct 12 15:22:50 2008
@@ -200,7 +200,7 @@
 			Move (x, y);
 		}
 
-		void OnEscapeSettingChanged (object sender, GConf.NotifyEventArgs args)
+		void OnEscapeSettingChanged (object sender, NotifyEventArgs args)
 		{
 			// enable escape key
 			if ((bool) args.Value)

Added: trunk/Tomboy/PlatformFactory.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/PlatformFactory.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,16 @@
+namespace Tomboy
+{
+	public interface IPlatformFactory
+	{
+		IPropertyEditor CreatePropertyEditorEntry (string key, Gtk.Entry sourceEntry);
+
+		IPropertyEditorBool CreatePropertyEditorToggleButton (
+		        string key, Gtk.CheckButton sourceButton);
+
+		IPreferencesClient CreatePreferencesClient ();
+
+		INativeApplication CreateNativeApplication ();
+
+		IKeybinder CreateKeybinder ();
+	}
+}
\ No newline at end of file

Modified: trunk/Tomboy/Preferences.cs
==============================================================================
--- trunk/Tomboy/Preferences.cs	(original)
+++ trunk/Tomboy/Preferences.cs	Sun Oct 12 15:22:50 2008
@@ -46,17 +46,14 @@
 		public const string SEARCH_WINDOW_WIDTH = "/apps/tomboy/search_window_width";
 		public const string SEARCH_WINDOW_HEIGHT = "/apps/tomboy/search_window_height";
 
-		static GConf.Client client;
-		static GConf.NotifyEventHandler changed_handler;
+		static IPreferencesClient client;
 
-		public static GConf.Client Client
+		public static IPreferencesClient Client
 		{
 			get {
 				if (client == null) {
-					client = new GConf.Client ();
-
-					changed_handler = new GConf.NotifyEventHandler (OnSettingChanged);
-					client.AddNotify ("/apps/tomboy", changed_handler);
+					client = Services.Preferences;
+					client.AddNotify ("/apps/tomboy", OnSettingChanged);
 				}
 				return client;
 			}
@@ -144,7 +141,7 @@
 		{
 			try {
 				return Client.Get (key);
-			} catch (GConf.NoSuchKeyException) {
+			} catch (NoSuchKeyException) {
 				object default_val = GetDefault (key);
 
 				if (default_val != null)
@@ -159,9 +156,9 @@
 			Client.Set (key, value);
 		}
 
-		public static event GConf.NotifyEventHandler SettingChanged;
+		public static event NotifyEventHandler SettingChanged;
 
-		static void OnSettingChanged (object sender, GConf.NotifyEventArgs args)
+		static void OnSettingChanged (object sender, NotifyEventArgs args)
 		{
 			if (SettingChanged != null) {
 				SettingChanged (sender, args);

Added: trunk/Tomboy/PreferencesClient.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/PreferencesClient.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,84 @@
+
+namespace Tomboy
+{
+	public interface IPreferencesClient
+	{
+		void Set (string key, object val);
+		object Get (string key);
+		void AddNotify (string dir, NotifyEventHandler notify);
+		void RemoveNotify (string dir, NotifyEventHandler notify);
+		void SuggestSync ();
+	}
+
+	public interface IPropertyEditor
+	{
+		void Setup ();
+		string Key { get; }
+	}
+
+	public interface IPropertyEditorBool : IPropertyEditor
+	{
+		void AddGuard (Gtk.Widget widget);
+	}
+
+	public class NullPreferencesClient : IPreferencesClient
+	{
+		#region IPreferencesClient implementation 
+		
+		public void Set (string key, object val)
+		{
+			// Do nothing
+		}
+		
+		public object Get (string key)
+		{
+			throw new NoSuchKeyException (key);
+		}
+		
+		public void AddNotify (string dir, NotifyEventHandler notify)
+		{
+			// Do nothing
+		}
+		
+		public void RemoveNotify (string dir, NotifyEventHandler notify)
+		{
+			// Do nothing
+		}
+		
+		public void SuggestSync ()
+		{
+			// Do nothing
+		}
+		
+		#endregion
+	}
+
+	public delegate void NotifyEventHandler(object sender, NotifyEventArgs args);
+
+	public class NoSuchKeyException : System.Exception
+	{
+		public NoSuchKeyException(string key) :
+			base(string.Format("No such key: {0}", key))
+		{}
+	}
+
+	public class NotifyEventArgs : System.EventArgs
+	{
+		private string key;
+		private object val;
+
+		public NotifyEventArgs (string key, object val)
+		{
+			this.key = key;
+			this.val = val;
+		}
+
+		public string Key { 
+			get { return key; }
+		}
+
+		public  object Value { 
+			get { return val; }
+		}
+	}
+}

Modified: trunk/Tomboy/PreferencesDialog.cs
==============================================================================
--- trunk/Tomboy/PreferencesDialog.cs	(original)
+++ trunk/Tomboy/PreferencesDialog.cs	Sun Oct 12 15:22:50 2008
@@ -2,7 +2,6 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
-using GConf.PropertyEditors;
 using Mono.Unix;
 
 using Tomboy.Sync;
@@ -79,8 +78,9 @@
 
 			notebook.AppendPage (MakeEditingPane (),
 			                     new Gtk.Label (Catalog.GetString ("Editing")));
-			notebook.AppendPage (MakeHotkeysPane (),
-			                     new Gtk.Label (Catalog.GetString ("Hotkeys")));
+			if (! (Services.Keybinder is NullKeybinder))
+				notebook.AppendPage (MakeHotkeysPane (),
+				                     new Gtk.Label (Catalog.GetString ("Hotkeys")));
 			notebook.AppendPage (MakeSyncPane (),
 			                     new Gtk.Label (Catalog.GetString ("Synchronization")));
 			notebook.AppendPage (MakeAddinsPane (),
@@ -131,7 +131,7 @@
 			Gtk.Label label;
 			Gtk.CheckButton check;
 			Gtk.Alignment align;
-			PropertyEditorBool peditor, font_peditor, bullet_peditor;
+			IPropertyEditorBool peditor, font_peditor, bullet_peditor;
 
 			Gtk.VBox options_list = new Gtk.VBox (false, 12);
 			options_list.BorderWidth = 12;
@@ -146,7 +146,7 @@
 				                Catalog.GetString ("_Spell check while typing"));
 				options_list.PackStart (check, false, false, 0);
 
-				peditor = new PropertyEditorToggleButton (
+				peditor = Services.Factory.CreatePropertyEditorToggleButton (
 				        Preferences.ENABLE_SPELLCHECKING,
 				        check);
 				SetupPropertyEditor (peditor);
@@ -166,7 +166,7 @@
 			check = MakeCheckButton (Catalog.GetString ("Highlight _WikiWords"));
 			options_list.PackStart (check, false, false, 0);
 
-			peditor = new PropertyEditorToggleButton (Preferences.ENABLE_WIKIWORDS,
+			peditor = Services.Factory.CreatePropertyEditorToggleButton (Preferences.ENABLE_WIKIWORDS,
 			                check);
 			SetupPropertyEditor (peditor);
 
@@ -181,7 +181,7 @@
 			check = MakeCheckButton (Catalog.GetString ("Enable auto-_bulleted lists"));
 			options_list.PackStart (check, false, false, 0);
 			bullet_peditor =
-			        new PropertyEditorToggleButton (Preferences.ENABLE_AUTO_BULLETED_LISTS,
+			        Services.Factory.CreatePropertyEditorToggleButton (Preferences.ENABLE_AUTO_BULLETED_LISTS,
 			                                        check);
 			SetupPropertyEditor (bullet_peditor);
 
@@ -191,7 +191,7 @@
 			options_list.PackStart (check, false, false, 0);
 
 			font_peditor =
-			        new PropertyEditorToggleButton (Preferences.ENABLE_CUSTOM_FONT,
+			        Services.Factory.CreatePropertyEditorToggleButton (Preferences.ENABLE_CUSTOM_FONT,
 			                                        check);
 			SetupPropertyEditor (font_peditor);
 
@@ -268,8 +268,8 @@
 			Gtk.CheckButton check;
 			Gtk.Alignment align;
 			Gtk.Entry entry;
-			PropertyEditorBool keybind_peditor;
-			PropertyEditor peditor;
+			IPropertyEditorBool keybind_peditor;
+			IPropertyEditor peditor;
 
 			Gtk.VBox hotkeys_list = new Gtk.VBox (false, 12);
 			hotkeys_list.BorderWidth = 12;
@@ -282,7 +282,7 @@
 			hotkeys_list.PackStart (check, false, false, 0);
 
 			keybind_peditor =
-			        new PropertyEditorToggleButton (Preferences.ENABLE_KEYBINDINGS,
+			        Services.Factory.CreatePropertyEditorToggleButton (Preferences.ENABLE_KEYBINDINGS,
 			                                        check);
 			SetupPropertyEditor (keybind_peditor);
 
@@ -315,7 +315,7 @@
 			entry.Show ();
 			table.Attach (entry, 1, 2, 0, 1);
 
-			peditor = new PropertyEditorEntry (Preferences.KEYBINDING_SHOW_NOTE_MENU,
+			peditor = Services.Factory.CreatePropertyEditorEntry (Preferences.KEYBINDING_SHOW_NOTE_MENU,
 			                                   entry);
 			SetupPropertyEditor (peditor);
 
@@ -332,7 +332,7 @@
 			entry.Show ();
 			table.Attach (entry, 1, 2, 1, 2);
 
-			peditor = new PropertyEditorEntry (Preferences.KEYBINDING_OPEN_START_HERE,
+			peditor = Services.Factory.CreatePropertyEditorEntry (Preferences.KEYBINDING_OPEN_START_HERE,
 			                                   entry);
 			SetupPropertyEditor (peditor);
 
@@ -349,7 +349,7 @@
 			entry.Show ();
 			table.Attach (entry, 1, 2, 2, 3);
 
-			peditor = new PropertyEditorEntry (Preferences.KEYBINDING_CREATE_NEW_NOTE,
+			peditor = Services.Factory.CreatePropertyEditorEntry (Preferences.KEYBINDING_CREATE_NEW_NOTE,
 			                                   entry);
 			SetupPropertyEditor (peditor);
 
@@ -366,7 +366,7 @@
 			entry.Show ();
 			table.Attach (entry, 1, 2, 3, 4);
 
-			peditor = new PropertyEditorEntry (
+			peditor = Services.Factory.CreatePropertyEditorEntry (
 			        Preferences.KEYBINDING_OPEN_RECENT_CHANGES,
 			        entry);
 			SetupPropertyEditor (peditor);
@@ -791,7 +791,7 @@
 			AddinInfoDialogDeleted (sender, null);
 		}
 
-		void SetupPropertyEditor (PropertyEditor peditor)
+		void SetupPropertyEditor (IPropertyEditor peditor)
 		{
 			// Ensure the key exists
 			Preferences.Get (peditor.Key);

Added: trunk/Tomboy/PrefsKeybinder.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/PrefsKeybinder.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,221 @@
+using System;
+using System.Collections;
+
+namespace Tomboy
+{
+	public class PrefsKeybinder
+	{
+		ArrayList bindings;
+		IKeybinder native_keybinder;
+
+		public PrefsKeybinder ()
+		{
+			bindings = new ArrayList ();
+			native_keybinder = Services.Keybinder;
+		}
+
+		public void Bind (string       pref_path,
+		                  string       default_binding,
+		                  EventHandler handler)
+		{
+			try {
+				Binding binding = new Binding (pref_path,
+				                               default_binding,
+				                               handler,
+				                               native_keybinder);
+				bindings.Add (binding);
+			} catch (Exception e) {
+				Logger.Log ("Error Adding global keybinding:");
+				Logger.Log (e.ToString ());
+			}
+		}
+
+		public void UnbindAll ()
+		{
+			try {
+				foreach (Binding binding in bindings)
+					binding.RemoveNotify ();
+				bindings.Clear ();
+				native_keybinder.UnbindAll ();
+			} catch (Exception e) {
+				Logger.Log ("Error Removing global keybinding:");
+				Logger.Log (e.ToString ());
+			}
+		}
+
+		class Binding
+		{
+			public string   pref_path;
+			public string   key_sequence;
+			EventHandler    handler;
+			IKeybinder native_keybinder;
+
+			public Binding (string          pref_path,
+			                string          default_binding,
+			                EventHandler    handler,
+			                IKeybinder native_keybinder)
+			{
+				this.pref_path = pref_path;
+				this.key_sequence = default_binding;
+				this.handler = handler;
+				this.native_keybinder = native_keybinder;
+
+				try {
+					key_sequence = (string) Preferences.Client.Get (pref_path);
+				} catch {
+				        Logger.Log ("Preference key '{0}' does not exist, using default.",
+				                    pref_path);
+				}
+
+				SetBinding ();
+
+				Preferences.Client.AddNotify (
+				        pref_path,
+				        BindingChanged);
+			}
+
+			public void RemoveNotify ()
+			{
+				Preferences.Client.RemoveNotify (
+				        pref_path,
+				        BindingChanged);
+			}
+
+			void BindingChanged (object sender, NotifyEventArgs args)
+			{
+				if (args.Key == pref_path) {
+					Logger.Log ("Binding for '{0}' changed to '{1}'!",
+					            pref_path,
+					            args.Value);
+
+					UnsetBinding ();
+
+					key_sequence = (string) args.Value;
+					SetBinding ();
+				}
+			}
+
+			public void SetBinding ()
+			{
+				if (key_sequence == null ||
+				                key_sequence == String.Empty ||
+				                key_sequence == "disabled")
+					return;
+
+				Logger.Log ("Binding key '{0}' for '{1}'",
+				            key_sequence,
+				            pref_path);
+
+				native_keybinder.Bind (key_sequence, handler);
+			}
+
+			public void UnsetBinding ()
+			{
+				if (key_sequence == null)
+					return;
+
+				Logger.Log ("Unbinding key '{0}' for '{1}'",
+				            key_sequence,
+				            pref_path);
+
+				native_keybinder.Unbind (key_sequence);
+			}
+		}
+	}
+
+	public class TomboyPrefsKeybinder : PrefsKeybinder
+	{
+		NoteManager manager;
+		ITomboyTray  tray;
+
+		public TomboyPrefsKeybinder (NoteManager manager, ITomboyTray tray)
+				: base ()
+		{
+			this.manager = manager;
+			this.tray = tray;
+
+			EnableDisable ((bool) Preferences.Get (Preferences.ENABLE_KEYBINDINGS));
+
+			Preferences.SettingChanged += EnableKeybindingsChanged;
+		}
+
+		void EnableKeybindingsChanged (object sender, NotifyEventArgs args)
+		{
+			if (args.Key == Preferences.ENABLE_KEYBINDINGS) {
+				bool enabled = (bool) args.Value;
+				EnableDisable (enabled);
+			}
+		}
+
+		void EnableDisable (bool enable)
+		{
+			Logger.Log ("EnableDisable Called: enabling... {0}", enable);
+			if (enable) {
+				BindPreference (Preferences.KEYBINDING_SHOW_NOTE_MENU,
+				                new EventHandler (KeyShowMenu));
+
+				BindPreference (Preferences.KEYBINDING_OPEN_START_HERE,
+				                new EventHandler (KeyOpenStartHere));
+
+				BindPreference (Preferences.KEYBINDING_CREATE_NEW_NOTE,
+				                new EventHandler (KeyCreateNewNote));
+
+				BindPreference (Preferences.KEYBINDING_OPEN_SEARCH,
+				                new EventHandler (KeyOpenSearch));
+
+				BindPreference (Preferences.KEYBINDING_OPEN_RECENT_CHANGES,
+				                new EventHandler (KeyOpenRecentChanges));
+			} else {
+				UnbindAll ();
+			}
+		}
+
+		void BindPreference (string pref_path, EventHandler handler)
+		{
+			Bind (pref_path,
+			      (string) Preferences.GetDefault (pref_path),
+			      handler);
+		}
+
+		void KeyShowMenu (object sender, EventArgs args)
+		{
+			// Show the notes menu, highlighting the first item.
+			// This matches the behavior of GTK for
+			// accelerator-shown menus.
+			tray.ShowMenu (true);
+		}
+
+		void KeyOpenStartHere (object sender, EventArgs args)
+		{
+			Note note = manager.FindByUri (NoteManager.StartNoteUri);
+			if (note != null)
+				note.Window.Present ();
+		}
+
+		void KeyCreateNewNote (object sender, EventArgs args)
+		{
+			try {
+				Note new_note = manager.Create ();
+				new_note.Window.Show ();
+			} catch {
+				// Fail silently.
+			}
+		}
+
+		void KeyOpenSearch (object sender, EventArgs args)
+		{
+			/* Find dialog is deprecated in favor of searcable ToC */
+			/*
+			NoteFindDialog find_dialog = NoteFindDialog.GetInstance (manager);
+			find_dialog.Present ();
+			*/
+			KeyOpenRecentChanges (sender, args);
+		}
+
+		void KeyOpenRecentChanges (object sender, EventArgs args)
+		{
+			NoteRecentChanges recent = NoteRecentChanges.GetInstance (manager);
+			recent.Present ();
+		}
+	}
+}

Added: trunk/Tomboy/Services.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Services.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,78 @@
+// 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. 
+// 
+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) 
+// 
+// Authors: 
+//      Sandy Armstrong <sanfordarmstrong gmail com>
+// 
+
+
+using System;
+
+namespace Tomboy
+{
+	public class Services
+	{
+		private static IPreferencesClient prefs;
+		private static INativeApplication nativeApp;
+		private static IKeybinder keybinder;
+		private static IPlatformFactory factory;
+		
+		static Services ()
+		{
+#if WIN32
+			factory = new WindowsFactory ();
+#else
+			factory = new GnomeFactory ();
+#endif
+			
+			nativeApp = factory.CreateNativeApplication ();
+			prefs = factory.CreatePreferencesClient ();
+		}
+
+		public static IPlatformFactory Factory {
+			get {
+				return factory;
+			}
+		}
+
+		public static IPreferencesClient Preferences {
+			get {
+				return prefs;
+			}
+		}
+
+		public static INativeApplication NativeApplication {
+			get {
+				return nativeApp;
+			}
+		}
+
+		public static IKeybinder Keybinder {
+			get {
+				// Initialize on-demand. XKeybinder must not be
+				// created too early.
+				if (keybinder == null)
+					keybinder = factory.CreateKeybinder ();
+				return keybinder;
+			}
+		}
+	}
+}
\ No newline at end of file

Modified: trunk/Tomboy/Tomboy.cs
==============================================================================
--- trunk/Tomboy/Tomboy.cs	(original)
+++ trunk/Tomboy/Tomboy.cs	Sun Oct 12 15:22:50 2008
@@ -6,7 +6,7 @@
 
 #if FIXED_PANELAPPLET
 using Gnome;
-#else
+#elif !WIN32
 using _Gnome;
 #endif
 
@@ -102,7 +102,7 @@
 			        override_path :
 			        Environment.GetEnvironmentVariable ("TOMBOY_PATH");
 			if (note_path == null)
-				note_path = "~/.tomboy";
+				note_path = Services.NativeApplication.ConfDir;
 
 			// Tilde expand
 			return note_path.Replace ("~", Environment.GetEnvironmentVariable ("HOME"));
@@ -111,7 +111,9 @@
 		static void RegisterPanelAppletFactory ()
 		{
 			// This will block if there is no existing instance running
+#if !WIN32
 			PanelAppletFactory.Register (typeof (TomboyApplet));
+#endif
 		}
 
 		static void StartTrayIcon ()

Modified: trunk/Tomboy/Tray.cs
==============================================================================
--- trunk/Tomboy/Tray.cs	(original)
+++ trunk/Tomboy/Tray.cs	Sun Oct 12 15:22:50 2008
@@ -133,15 +133,15 @@
 	}
 	
 	
-	public class TomboyTrayIcon : Gtk.StatusIcon
+	public class TomboyTrayIcon : Gtk.StatusIcon, ITomboyTray
 	{
 		TomboyTray tray;
-		TomboyGConfXKeybinder keybinder;
+		TomboyPrefsKeybinder keybinder;
 
 		public TomboyTrayIcon (NoteManager manager)
 		{
 			tray = new TomboyTray (manager, this);
-			keybinder = new TomboyGConfXKeybinder (manager, tray);
+			keybinder = new TomboyPrefsKeybinder (manager, this);
 			int panel_size = 22;
 			Pixbuf = GuiUtils.GetIcon ("tomboy", panel_size);
 
@@ -194,16 +194,25 @@
 			Gdk.Screen screen;
 			Gdk.Rectangle area;
 			Gtk.Orientation orientation;
-			GetGeometry (out screen, out area, out orientation);
-			
-			x = area.X;
-			y = area.Y;
-			
-			Gtk.Requisition menu_req = menu.SizeRequest ();
-			if (y + menu_req.Height >= screen.Height)
-				y -= menu_req.Height;
-			else
-				y += area.Height;
+			try {
+#if WIN32
+				menu.Screen.Display.GetPointer (out x, out y);
+				screen = menu.Screen;
+				area.Height = 0;
+#else
+				GetGeometry (out screen, out area, out orientation);
+				x = area.X;
+				y = area.Y;
+#endif
+
+				Gtk.Requisition menu_req = menu.SizeRequest ();
+				if (y + menu_req.Height >= screen.Height)
+					y -= menu_req.Height;
+				else
+					y += area.Height;
+			} catch (Exception e) {
+				Logger.Error ("Exception in GetTrayMenuPosition: " + e.ToString ());
+			}
 		}
 		
 		Gtk.Menu MakeRightClickMenu ()
@@ -261,13 +270,42 @@
 			Tomboy.ActionManager ["QuitTomboyAction"].Activate ();
 		}
 
+		public bool MenuOpensUpward ()
+		{
+			bool open_upwards = false;
+			int val = 0;
+			Gdk.Screen screen = null;
+
+			Gdk.Rectangle area;
+			Gtk.Orientation orientation;
+#if WIN32
+			int x;
+			tray.TomboyTrayMenu.Screen.Display.GetPointer (out x, out val);
+			screen = tray.TomboyTrayMenu.Screen;
+#else
+			GetGeometry (out screen, out area, out orientation);
+			val = area.Y;
+#endif
+
+			Gtk.Requisition menu_req = tray.TomboyTrayMenu.SizeRequest ();
+			if (val + menu_req.Height >= screen.Height)
+				open_upwards = true;
+
+			return open_upwards;
+		}
+	}
+
+	// TODO: Some naming love would be nice
+	public interface ITomboyTray
+	{
+		void ShowMenu (bool select_first_item);
+		bool MenuOpensUpward ();
 	}
 	
 	public class TomboyTray
 	{
 		NoteManager manager;
-		TomboyTrayIcon tray_icon = null;
-		TomboyAppletEventBox applet_event_box = null;
+		ITomboyTray tray;
 		bool menu_added = false;
 		List<Gtk.MenuItem> recent_notes = new List<Gtk.MenuItem> ();
 		Gtk.Menu tray_menu;
@@ -277,27 +315,12 @@
 			this.manager = manager;
 			
 			tray_menu = MakeTrayNotesMenu ();
-			tray_menu.Hidden += MenuHidden;
 		}
 		
-		public TomboyTray (NoteManager manager, TomboyTrayIcon tray_icon)
+		public TomboyTray (NoteManager manager, ITomboyTray tray)
 			: this (manager)
 		{
-			this.tray_icon = tray_icon;
-		}
-		
-		public TomboyTray (NoteManager manager, TomboyAppletEventBox applet_event_box)
-			: this (manager)
-		{
-			this.applet_event_box = applet_event_box;
-		}
-		
-		public void ShowMenu (bool select_first_item)
-		{
-			if (applet_event_box != null)
-				applet_event_box.ShowMenu (select_first_item);
-			else if (tray_icon != null)
-				tray_icon.ShowMenu (select_first_item);
+			this.tray = tray;
 		}
 		
 		Gtk.Menu MakeTrayNotesMenu ()
@@ -339,12 +362,6 @@
 			return menu;
 		}
 		
-		void MenuHidden (object sender, EventArgs args)
-		{
-			// Remove the old dynamic items
-			RemoveRecentlyChangedNotes ();
-		}
-		
 		void RemoveRecentlyChangedNotes ()
 		{
 			foreach (Gtk.Widget item in recent_notes) {
@@ -359,9 +376,12 @@
 			int min_size = (int) Preferences.Get (Preferences.MENU_NOTE_COUNT);
 			int max_size = 18;
 			int list_size = 0;
-			bool menuOpensUpward = MenuOpensUpward ();
+			bool menuOpensUpward = tray.MenuOpensUpward ();
 			NoteMenuItem item;
 
+			// Remove the old dynamic items
+			RemoveRecentlyChangedNotes ();
+
 			// Assume menu opens downward, move common items to top of menu
 			Gtk.MenuItem newNoteItem = Tomboy.ActionManager.GetWidget (
 			                                   "/TrayIconMenu/TrayNewNotePlaceholder/TrayNewNote") as Gtk.MenuItem;
@@ -463,31 +483,6 @@
 			tray_menu.Insert (separator, insertion_point);
 			recent_notes.Add (separator);
 		}
-		
-		public bool MenuOpensUpward ()
-		{
-			bool open_upwards = false;
-			int val = 0;
-			Gdk.Screen screen = null;
-			
-			if (applet_event_box != null) {
-				int x, y;
-				applet_event_box.GdkWindow.GetOrigin (out x, out y);
-				val = y;
-				screen = applet_event_box.Screen;
-			} else if (tray_icon != null) {
-				Gdk.Rectangle area;
-				Gtk.Orientation orientation;
-				tray_icon.GetGeometry(out screen, out area, out orientation);
-				val = area.Y;
-			}
-			
-			Gtk.Requisition menu_req = tray_menu.SizeRequest ();
-			if (val + menu_req.Height >= screen.Height)
-				open_upwards = true;
-
-			return open_upwards;
-		}
 
 		public bool IsMenuAdded
 		{
@@ -575,54 +570,12 @@
 		}
 	}
 
-	[DllImport("libtomboy")]
-		static extern bool egg_accelerator_parse_virtual (string keystring,
-			                out uint keysym,
-			                out uint virtual_mods);
-
-		[DllImport("libtomboy")]
-		static extern void egg_keymap_resolve_virtual_modifiers (
-			        IntPtr keymap,
-			        uint virtual_mods,
-			        out Gdk.ModifierType real_mods);
-
-		public static bool GetAccelKeys (string               gconf_path,
-		                                 out uint             keyval,
-		                                 out Gdk.ModifierType mods)
-		{
-			keyval = 0;
-			mods = 0;
-
-			try {
-				string binding = (string) Preferences.Get (gconf_path);
-				if (binding == null ||
-				                binding == String.Empty ||
-				                binding == "disabled")
-					return false;
-
-				uint virtual_mods = 0;
-				if (!egg_accelerator_parse_virtual (binding,
-				                                    out keyval,
-				                                    out virtual_mods))
-					return false;
-
-				Gdk.Keymap keymap = Gdk.Keymap.Default;
-				egg_keymap_resolve_virtual_modifiers (keymap.Handle,
-				                                      virtual_mods,
-				                                      out mods);
-
-				return true;
-			} catch {
-			return false;
-		}
-	}
-
 	public static void AddAccelerator (Gtk.MenuItem item, string gconf_path)
 		{
 			uint keyval;
 			Gdk.ModifierType mods;
 
-			if (GetAccelKeys (gconf_path, out keyval, out mods))
+			if (Services.Keybinder.GetAccelKeys (gconf_path, out keyval, out mods))
 				item.AddAccelerator ("activate",
 				                     accel_group,
 				                     keyval,

Modified: trunk/Tomboy/Utils.cs
==============================================================================
--- trunk/Tomboy/Utils.cs	(original)
+++ trunk/Tomboy/Utils.cs	Sun Oct 12 15:22:50 2008
@@ -7,7 +7,6 @@
 using System.Xml;
 
 using Mono.Unix;
-using Mono.Unix.Native;
 
 namespace Tomboy
 {
@@ -137,12 +136,10 @@
 		                             Gtk.Window parent)
 		{
 			try {
-				Gnome.Help.DisplayDesktopOnScreen (
-				        Gnome.Program.Get (),
-				        Defines.GNOME_HELP_DIR,
-				        filename,
-				        link_id,
-				        screen);
+				Services.NativeApplication.DisplayHelp (
+					filename,
+					link_id,
+					screen);
 			} catch {
 			string message =
 			Catalog.GetString ("The \"Tomboy Notes Manual\" could " +
@@ -789,7 +786,7 @@
 : base (name)
 		{
 		}
-
+#if !WIN32
 		[DllImport("libtomboy")]
 		static extern void tomboy_window_present_hardcore (IntPtr win);
 
@@ -797,6 +794,7 @@
 		{
 			tomboy_window_present_hardcore (this.Handle);
 		}
+#endif
 	}
 
 	class ToolMenuButton : Gtk.ToggleToolButton
@@ -868,7 +866,7 @@
 
 	public class Application
 	{
-		static Gnome.Program program;
+		static INativeApplication native_app;
 		static ActionManager action_manager;
 
 		public static void Initialize (string locale_dir,
@@ -876,131 +874,41 @@
 		                               string process_name,
 		                               string [] args)
 		{
-			try {
-				SetProcessName (process_name);
-			} catch {} // Ignore exception if fail (not needed to run)
-
-			Gtk.Application.Init ();
-			program = new Gnome.Program ("Tomboy",
-			                             Defines.VERSION,
-			                             Gnome.Modules.UI,
-			                             args);
+			native_app = Services.NativeApplication;
+			native_app.Initialize (locale_dir, display_name, process_name, args);
 
 			action_manager = new ActionManager ();
 			action_manager.LoadInterface ();
 
-			RegisterSignalHandlers ();
-
-			// Register handler for saving session when logging out of Gnome
-			Gnome.Client client = Gnome.Global.MasterClient ();
-			client.SaveYourself += OnSaveYourself;
-		}
-
-		[DllImport("libc")]
-		private static extern int prctl (int option,
-			                                 byte [] arg2,
-			                                 IntPtr arg3,
-			                                 IntPtr arg4,
-			                                 IntPtr arg5);
-
-		// From Banshee: Banshee.Base/Utilities.cs
-		public static void SetProcessName (string name)
-		{
-			if (prctl (15 /* PR_SET_NAME */,
-			                Encoding.ASCII.GetBytes (name + "\0"),
-			                IntPtr.Zero,
-			                IntPtr.Zero,
-			                IntPtr.Zero) != 0)
-				throw new ApplicationException (
-				        "Error setting process name: " +
-				        Mono.Unix.Native.Stdlib.GetLastError ());
-		}
-
-		static void RegisterSignalHandlers ()
-		{
-			// Connect to SIGTERM and SIGINT, so we don't lose
-			// unsaved notes on exit...
-			Stdlib.signal (Signum.SIGTERM, OnExitSignal);
-			Stdlib.signal (Signum.SIGINT, OnExitSignal);
-		}
-
-		static void OnSaveYourself (object sender, Gnome.SaveYourselfArgs args)
-		{
-			Logger.Log ("Received request for saving session");
-
-			if (ExitingEvent != null)
-				ExitingEvent (null, new EventArgs ());
+			native_app.RegisterSignalHandlers ();
 		}
 
 		public static void RegisterSessionManagerRestart (string executable_path,
 		                string[] args,
 		                string[] environment)
 		{
-			if (executable_path == null)
-				return;
-
-			// Restart if we are running when the session ends or at crash...
-			Gnome.Client client = Gnome.Global.MasterClient ();
-			client.RestartStyle =
-			        Gnome.RestartStyle.IfRunning | Gnome.RestartStyle.Immediately;
-			client.Die += OnSessionManagerDie;
-
-			foreach (string env in environment) {
-				string [] split = env.Split (new char [] { '=' }, 2);
-				if (split.Length == 2) {
-					client.SetEnvironment (split[0], split[1]);
-				}
-			}
-
-			// Get the args for session restart...
-			string [] restart_args = new string [args.Length + 1];
-			restart_args [0] = executable_path;
-			args.CopyTo (restart_args, 1);
-			client.SetRestartCommand (restart_args.Length, restart_args);
-		}
-
-		static void OnSessionManagerDie (object sender, EventArgs args)
-		{
-			// Don't let the exit signal run, which would cancel
-			// session management.
-			QuitMainLoop ();
+			native_app.RegisterSessionManagerRestart (executable_path, args, environment);
 		}
 
-		static void CancelSessionManagerRestart ()
+		public static event EventHandler ExitingEvent
 		{
-			Gnome.Client client = Gnome.Global.MasterClient ();
-			client.RestartStyle = Gnome.RestartStyle.IfRunning;
-			client.Flush ();
+		        add { native_app.ExitingEvent += value; }
+		        remove { native_app.ExitingEvent -= value; }
 		}
 
-		static void OnExitSignal (int signal)
-		{
-			// Don't auto-restart after exit/kill.
-			CancelSessionManagerRestart ();
-
-			if (ExitingEvent != null)
-				ExitingEvent (null, new EventArgs ());
-
-			if (signal >= 0)
-				System.Environment.Exit (0);
-		}
-
-		public static event EventHandler ExitingEvent;
-
 		public static void Exit (int exitcode)
 		{
-			OnExitSignal (-1);
-			System.Environment.Exit (exitcode);
+			native_app.Exit (exitcode);
 		}
 
 		public static void StartMainLoop ()
 		{
-			program.Run ();
+			native_app.StartMainLoop ();
 		}
 
 		public static void QuitMainLoop ()
 		{
-			Gtk.Main.Quit ();
+			native_app.QuitMainLoop ();
 		}
 
 		public static ActionManager ActionManager

Modified: trunk/Tomboy/Watchers.cs
==============================================================================
--- trunk/Tomboy/Watchers.cs	(original)
+++ trunk/Tomboy/Watchers.cs	Sun Oct 12 15:22:50 2008
@@ -313,7 +313,7 @@
 			}
 		}
 
-		void OnEnableSpellcheckChanged (object sender, GConf.NotifyEventArgs args)
+		void OnEnableSpellcheckChanged (object sender, NotifyEventArgs args)
 		{
 			if (args.Key != Preferences.ENABLE_SPELLCHECKING)
 				return;
@@ -456,7 +456,7 @@
 		{
 			if (url != string.Empty) {
 				Logger.Log ("Opening url '{0}'...", url);
-				Gnome.Url.Show (url);
+				Services.NativeApplication.OpenUrl (url);
 			}
 		}
 
@@ -895,7 +895,7 @@
 			Preferences.SettingChanged += OnEnableWikiwordsChanged;
 		}
 
-		void OnEnableWikiwordsChanged (object sender, GConf.NotifyEventArgs args)
+		void OnEnableWikiwordsChanged (object sender, NotifyEventArgs args)
 		{
 			if (args.Key != Preferences.ENABLE_WIKIWORDS)
 				return;

Added: trunk/Tomboy/WindowsApplication.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/WindowsApplication.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,103 @@
+// 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. 
+// 
+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) 
+// 
+// Authors: 
+//      Sandy Armstrong <sanfordarmstrong gmail com>
+// 
+
+
+using System;
+using System.IO;
+
+namespace Tomboy
+{
+	public class WindowsApplication : INativeApplication
+	{
+		private string confDir;
+		
+		public WindowsApplication ()
+		{
+			confDir = Path.Combine (
+				Environment.GetFolderPath (
+			        	Environment.SpecialFolder.ApplicationData),
+					"tomboy");
+			if (!Directory.Exists (confDir))
+				Directory.CreateDirectory (confDir);
+		}
+		
+		#region INativeApplication implementation 
+		
+		public event EventHandler ExitingEvent;
+		
+		public void Initialize (string locale_dir, string display_name, string process_name, string[] args)
+		{
+			Gtk.Application.Init ();
+		}
+		
+		public void RegisterSessionManagerRestart (string executable_path, string[] args, string[] environment)
+		{
+			// Do nothing
+		}
+		
+		public void RegisterSignalHandlers ()
+		{
+			// Nothing yet, but need to register for native exit signals?
+		}
+		
+		public void Exit (int exitcode)
+		{
+			if (ExitingEvent != null)
+				ExitingEvent (null, new EventArgs ());
+			System.Environment.Exit (exitcode);
+		}
+		
+		public void StartMainLoop ()
+		{
+			Gtk.Application.Run ();
+		}
+		
+		public void QuitMainLoop ()
+		{
+			Gtk.Application.Quit ();
+		}
+
+		public string ConfDir
+		{
+			get { return confDir; }
+		}
+
+		public void OpenUrl (string url)
+		{
+			try {
+				System.Diagnostics.Process.Start (url);
+			} catch (Exception e) {
+				Logger.Error ("Error opening url [{0}]:\n{1}", url, e.ToString ());
+			}
+		}
+
+		public void DisplayHelp (string filename, string link_id, Gdk.Screen screen)
+		{
+			throw new NotImplementedException ();
+		}
+
+		#endregion
+	}
+}

Added: trunk/Tomboy/WindowsFactory.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/WindowsFactory.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,31 @@
+namespace Tomboy
+{
+	public class WindowsFactory : IPlatformFactory
+	{
+		public IPropertyEditor CreatePropertyEditorEntry (string key, Gtk.Entry sourceEntry)
+		{
+			return new PropertyEditorEntry (key, sourceEntry);
+		}
+
+		public IPropertyEditorBool CreatePropertyEditorToggleButton (
+		        string key, Gtk.CheckButton sourceButton)
+		{
+			return new PropertyEditorToggleButton (key, sourceButton);
+		}
+
+		public IPreferencesClient CreatePreferencesClient ()
+		{
+			return new XmlPreferencesClient ();
+		}
+
+		public INativeApplication CreateNativeApplication ()
+		{
+			return new WindowsApplication ();
+		}
+
+		public IKeybinder CreateKeybinder ()
+		{
+			return new NullKeybinder ();
+		}
+	}
+}
\ No newline at end of file

Modified: trunk/Tomboy/XKeybinder.cs
==============================================================================
--- trunk/Tomboy/XKeybinder.cs	(original)
+++ trunk/Tomboy/XKeybinder.cs	Sun Oct 12 15:22:50 2008
@@ -1,12 +1,10 @@
-
 using System;
 using System.Collections;
 using System.Runtime.InteropServices;
-using Mono.Unix;
 
 namespace Tomboy
 {
-	public class XKeybinder
+	public class XKeybinder : IKeybinder
 	{
 		[DllImport("libtomboy")]
 		static extern void tomboy_keybinder_init ();
@@ -21,6 +19,7 @@
 
 		public delegate void BindkeyHandler (string key, IntPtr user_data);
 
+		// TODO: Change to IList<T>
 		ArrayList      bindings;
 		BindkeyHandler key_handler;
 
@@ -30,7 +29,6 @@
 		}
 
 		public XKeybinder ()
-: base ()
 		{
 			bindings = new ArrayList ();
 			key_handler = new BindkeyHandler (KeybindingPressed);
@@ -79,212 +77,47 @@
 
 			bindings.Clear ();
 		}
-	}
 
-	public class GConfXKeybinder : XKeybinder
-	{
-		GConf.Client client;
-		ArrayList bindings;
+	[DllImport("libtomboy")]
+		static extern bool egg_accelerator_parse_virtual (string keystring,
+			                out uint keysym,
+			                out uint virtual_mods);
 
-		public GConfXKeybinder ()
+		[DllImport("libtomboy")]
+		static extern void egg_keymap_resolve_virtual_modifiers (
+			        IntPtr keymap,
+			        uint virtual_mods,
+			        out Gdk.ModifierType real_mods);
+
+		public bool GetAccelKeys (string               gconf_path,
+		                                 out uint             keyval,
+		                                 out Gdk.ModifierType mods)
 		{
-			client = new GConf.Client ();
-			bindings = new ArrayList ();
-		}
+			keyval = 0;
+			mods = 0;
 
-		public void Bind (string       gconf_path,
-		                  string       default_binding,
-		                  EventHandler handler)
-		{
 			try {
-				Binding binding = new Binding (gconf_path,
-				                               default_binding,
-				                               handler,
-				                               this);
-				bindings.Add (binding);
-			} catch (Exception e) {
-				Logger.Log ("Error Adding global keybinding:");
-				Logger.Log (e.ToString ());
-			}
-		}
-
-		public override void UnbindAll ()
-		{
-			try {
-				bindings.Clear ();
-				base.UnbindAll ();
-			} catch (Exception e) {
-				Logger.Log ("Error Removing global keybinding:");
-				Logger.Log (e.ToString ());
-			}
-		}
-
-		class Binding
-		{
-			public string   gconf_path;
-			public string   key_sequence;
-			EventHandler    handler;
-			GConfXKeybinder parent;
-
-			public Binding (string          gconf_path,
-			                string          default_binding,
-			                EventHandler    handler,
-			                GConfXKeybinder parent)
-			{
-				this.gconf_path = gconf_path;
-				this.key_sequence = default_binding;
-				this.handler = handler;
-				this.parent = parent;
-
-				try {
-					key_sequence = (string) parent.client.Get (gconf_path);
-				} catch {
-				Logger.Log ("GConf key '{0}' does not exist, using default.",
-				gconf_path);
-				}
-
-				SetBinding ();
-
-				parent.client.AddNotify (
-				        gconf_path,
-				        new GConf.NotifyEventHandler (BindingChanged));
-			}
-
-			void BindingChanged (object sender, GConf.NotifyEventArgs args)
-			{
-				if (args.Key == gconf_path) {
-					Logger.Log ("Binding for '{0}' changed to '{1}'!",
-					            gconf_path,
-					            args.Value);
-
-					UnsetBinding ();
-
-					key_sequence = (string) args.Value;
-					SetBinding ();
-				}
-			}
-
-			public void SetBinding ()
-			{
-				if (key_sequence == null ||
-				                key_sequence == String.Empty ||
-				                key_sequence == "disabled")
-					return;
-
-				Logger.Log ("Binding key '{0}' for '{1}'",
-				            key_sequence,
-				            gconf_path);
-
-				parent.Bind (key_sequence, handler);
-			}
-
-			public void UnsetBinding ()
-			{
-				if (key_sequence == null)
-					return;
-
-				Logger.Log ("Unbinding key '{0}' for '{1}'",
-				            key_sequence,
-				            gconf_path);
-
-				parent.Unbind (key_sequence);
-			}
-		}
-	}
-
-	public class TomboyGConfXKeybinder : GConfXKeybinder
-	{
-		NoteManager manager;
-		TomboyTray  tray;
-
-		public TomboyGConfXKeybinder (NoteManager manager, TomboyTray tray)
-: base ()
-		{
-			this.manager = manager;
-			this.tray = tray;
+				string binding = (string) Preferences.Get (gconf_path);
+				if (binding == null ||
+				                binding == String.Empty ||
+				                binding == "disabled")
+					return false;
+
+				uint virtual_mods = 0;
+				if (!egg_accelerator_parse_virtual (binding,
+				                                    out keyval,
+				                                    out virtual_mods))
+					return false;
+
+				Gdk.Keymap keymap = Gdk.Keymap.Default;
+				egg_keymap_resolve_virtual_modifiers (keymap.Handle,
+				                                      virtual_mods,
+				                                      out mods);
 
-			EnableDisable ((bool) Preferences.Get (Preferences.ENABLE_KEYBINDINGS));
-
-			Preferences.SettingChanged += EnableKeybindingsChanged;
-		}
-
-		void EnableKeybindingsChanged (object sender, GConf.NotifyEventArgs args)
-		{
-			if (args.Key == Preferences.ENABLE_KEYBINDINGS) {
-				bool enabled = (bool) args.Value;
-				EnableDisable (enabled);
-			}
-		}
-
-		void EnableDisable (bool enable)
-		{
-			Logger.Log ("EnableDisable Called: enabling... {0}", enable);
-			if (enable) {
-				BindPreference (Preferences.KEYBINDING_SHOW_NOTE_MENU,
-				                new EventHandler (KeyShowMenu));
-
-				BindPreference (Preferences.KEYBINDING_OPEN_START_HERE,
-				                new EventHandler (KeyOpenStartHere));
-
-				BindPreference (Preferences.KEYBINDING_CREATE_NEW_NOTE,
-				                new EventHandler (KeyCreateNewNote));
-
-				BindPreference (Preferences.KEYBINDING_OPEN_SEARCH,
-				                new EventHandler (KeyOpenSearch));
-
-				BindPreference (Preferences.KEYBINDING_OPEN_RECENT_CHANGES,
-				                new EventHandler (KeyOpenRecentChanges));
-			} else {
-				UnbindAll ();
-			}
-		}
-
-		void BindPreference (string gconf_path, EventHandler handler)
-		{
-			Bind (gconf_path,
-			      (string) Preferences.GetDefault (gconf_path),
-			      handler);
-		}
-
-		void KeyShowMenu (object sender, EventArgs args)
-		{
-			// Show the notes menu, highlighting the first item.
-			// This matches the behavior of GTK for
-			// accelerator-shown menus.
-			tray.ShowMenu (true);
-		}
-
-		void KeyOpenStartHere (object sender, EventArgs args)
-		{
-			Note note = manager.FindByUri (NoteManager.StartNoteUri);
-			if (note != null)
-				note.Window.Present ();
-		}
-
-		void KeyCreateNewNote (object sender, EventArgs args)
-		{
-			try {
-				Note new_note = manager.Create ();
-				new_note.Window.Show ();
+				return true;
 			} catch {
-			// Fail silently.
+			return false;
 		}
 	}
-
-	void KeyOpenSearch (object sender, EventArgs args)
-		{
-			/* Find dialog is deprecated in favor of searcable ToC */
-			/*
-			NoteFindDialog find_dialog = NoteFindDialog.GetInstance (manager);
-			find_dialog.Present ();
-			*/
-			KeyOpenRecentChanges (sender, args);
-		}
-
-		void KeyOpenRecentChanges (object sender, EventArgs args)
-		{
-			NoteRecentChanges recent = NoteRecentChanges.GetInstance (manager);
-			recent.Present ();
-		}
 	}
 }

Added: trunk/Tomboy/XmlPreferencesClient.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/XmlPreferencesClient.cs	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,249 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Xml;
+
+namespace Tomboy
+{
+	public class XmlPreferencesClient : IPreferencesClient
+	{
+		#region Private Members
+		
+		private string fileName;
+		private XmlDocument prefsDoc;
+		private Dictionary<string, NotifyEventHandler> events;
+
+		#endregion
+
+		#region Constructor
+
+		public XmlPreferencesClient ()
+		{
+			fileName = Path.Combine (
+				Services.NativeApplication.ConfDir,
+				"prefs.xml");
+			prefsDoc = new XmlDocument ();
+			events = new Dictionary<string, NotifyEventHandler> ();
+		}
+		
+		#endregion
+		
+		#region IPreferencesClient implementation
+		
+		public void Set (string key, object value)
+		{
+			try {
+				CreatePath (key);
+				prefsDoc.SelectSingleNode (key).InnerText = System.Convert.ToString(value);
+				prefsDoc.Save(fileName);
+				foreach (string nkey in events.Keys) {
+					NotifyEventHandler handler = events [nkey] as NotifyEventHandler;
+					if (handler != null && key.StartsWith (nkey))
+					{
+						NotifyEventArgs args = new NotifyEventArgs (key, value);
+						handler (this, args);
+					}
+				}
+			}
+			catch {}
+		}
+		
+		public object Get (string key)
+		{
+			try {
+				XmlElement element = prefsDoc.SelectSingleNode(key) as XmlElement;
+				if (element != null) {
+					int intVal;
+					double doubleVal;
+					bool boolVal;
+
+					string innerText = element.InnerText;
+
+					if (bool.TryParse (innerText, out boolVal))
+						return boolVal;
+					else if (int.TryParse (innerText, out intVal))
+						return intVal;
+					else if (double.TryParse (innerText, out doubleVal))
+						return doubleVal;
+					else
+						return innerText;
+				}
+				
+				// TODO: Ugly, fix
+				throw new System.Exception();
+			} catch {
+				throw new NoSuchKeyException (key);
+			}
+
+		}
+		
+		public void AddNotify (string dir, NotifyEventHandler notify)
+		{
+			lock (events) {
+				if (!events.ContainsKey (dir))
+					events [dir] = notify;
+				else
+					events [dir] += notify;
+			}
+		}
+		
+		public void RemoveNotify (string dir, NotifyEventHandler notify)
+		{
+			lock (events) {
+				if (events.ContainsKey (dir))
+					events [dir] -= notify;
+			}
+		}
+		
+		public void SuggestSync ()
+		{
+			// TODO: Sync with file?
+		}
+		
+		#endregion
+
+		#region Private Methods
+
+		private void CreatePath(string path)
+		{
+			if (path.Length == 0)
+				return;
+			if (path [0] == '/') 
+				path = path.Substring (1);
+			if (path.Length == 0)
+				return;
+
+			string [] parts = path.Split ('/');
+			XmlNode node = prefsDoc;
+			for (int i = 0; i < parts.Length; ++i)
+			{
+				if (node [parts [i]] == null)
+				{
+					node.AppendChild (prefsDoc.CreateElement (parts [i]));
+				}
+				node = node [parts [i]];
+			}
+		}
+
+		#endregion
+	}
+
+	public class PropertyEditor : IPropertyEditor
+	{
+		private string key;
+
+		public string Key
+		{
+			get { return key; }
+		}
+
+		public PropertyEditor (string key)
+		{
+			this.key = key;
+		}
+
+		public virtual void Setup ()
+		{
+		}
+
+		protected object Get ()
+		{
+			return Services.Preferences.Get (Key);
+		}
+
+		protected void Set (object value)
+		{
+			Services.Preferences.Set (Key, value);
+		}
+	}
+
+	public class PropertyEditorBool : PropertyEditor, IPropertyEditorBool
+	{
+		protected List<Gtk.Widget> guards = new List<Gtk.Widget> ();
+
+		public PropertyEditorBool (string key) : base (key) { }
+
+		public virtual void AddGuard (Gtk.Widget widget)
+		{
+			guards.Add (widget);
+		}
+
+		protected void Set (bool value)
+		{
+			base.Set (value);
+			UpdateGuards (value);
+		}
+
+		protected void UpdateGuards ()
+		{
+			bool val = false;
+			try {
+				val = Get ();
+			} catch (NoSuchKeyException) { }
+			UpdateGuards (val);
+		}
+
+		private void UpdateGuards (bool value)
+		{
+			foreach (Gtk.Widget widget in guards)
+				widget.Sensitive = value;
+		}
+
+		protected new bool Get ()
+		{
+			return (bool) base.Get ();
+		}
+	}
+
+	public class PropertyEditorToggleButton : PropertyEditorBool
+	{
+		Gtk.CheckButton button;
+
+		public PropertyEditorToggleButton (string key, Gtk.CheckButton sourceButton) :
+			base (key)
+		{
+			button = sourceButton;
+		}
+
+		public override void Setup ()
+		{
+			bool active = false;
+			try {
+				active = Get ();
+			} catch (NoSuchKeyException) { }
+			button.Active = active;
+			button.Clicked += new System.EventHandler (OnChanged);
+			UpdateGuards ();
+		}
+
+		private void OnChanged (object sender, System.EventArgs args)
+		{
+			Set (button.Active);
+		}
+	}
+
+	public class PropertyEditorEntry : PropertyEditor
+	{
+		Gtk.Entry entry;
+		public PropertyEditorEntry (string key, Gtk.Entry sourceEntry) :
+			base (key)
+		{
+			entry = sourceEntry;
+		}
+
+		public override void Setup ()
+		{
+			string val = string.Empty;
+			try {
+				val = System.Convert.ToString (base.Get ());
+			} catch (NoSuchKeyException) { }
+			entry.Text = val;
+			entry.Changed += OnChanged;
+		}
+
+		private void OnChanged (object sender, System.EventArgs args)
+		{
+			Set (entry.Text);
+		}
+	}
+}
\ No newline at end of file

Added: trunk/winbin/ICSharpCode.SharpZipLib.dll
==============================================================================
Binary file. No diff available.

Added: trunk/winbin/Mono.Addins.Gui.dll
==============================================================================
Binary file. No diff available.

Added: trunk/winbin/Mono.Addins.Setup.dll
==============================================================================
Binary file. No diff available.

Added: trunk/winbin/Mono.Addins.dll
==============================================================================
Binary file. No diff available.

Added: trunk/winbin/Mono.Addins.dll.config
==============================================================================
--- (empty file)
+++ trunk/winbin/Mono.Addins.dll.config	Sun Oct 12 15:22:50 2008
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <startup>
+    <supportedRuntime version="v2.0.50727" /> 
+  </startup>
+</configuration>

Added: trunk/winbin/Mono.Posix.dll
==============================================================================
Binary file. No diff available.

Added: trunk/winbin/MonoPosixHelper.dll
==============================================================================
Binary file. No diff available.



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