[tasque/transition: 70/213] Remove last Gtk# dep from model: IBackend.GetPreferencesWidget ()



commit d9b84dd46f719b9f736ebe73cac470590ccfc571
Author: Antonius Riha <antoniusriha gmail com>
Date:   Mon Jul 9 23:55:03 2012 +0200

    Remove last Gtk# dep from model: IBackend.GetPreferencesWidget ()
    
    The method IBackend.GetPreferencesWidget () has been substituted by the read-only property IBackend.Preferences, which is of type IBackendPreferences. This interface has been created to provide an abstract handle for the class PreferencesDialog.cs in the application. A concrete preferences widget is being provided along with the backend implementation: DummyPreferences.cs.
    
    This commit removes the last residuals of Gtk# in the model.

 src/libtasque/IBackend.cs                         |   46 +++++++++++++++-----
 src/libtasque/IBackendPreferences.cs              |   33 +++++++++++++++
 src/libtasque/libtasque.csproj                    |   20 +---------
 src/tasque/Backends/Dummy/DummyBackend.cs         |   11 +++--
 src/tasque/Backends/Dummy/Gtk/DummyPreferences.cs |   40 ++++++++++++++++++
 src/tasque/PreferencesDialog.cs                   |    4 +-
 src/tasque/tasque.csproj                          |    4 +-
 7 files changed, 120 insertions(+), 38 deletions(-)
---
diff --git a/src/libtasque/IBackend.cs b/src/libtasque/IBackend.cs
index 01f18de..c3ea0cf 100644
--- a/src/libtasque/IBackend.cs
+++ b/src/libtasque/IBackend.cs
@@ -1,8 +1,32 @@
 // ITaskBackend.cs created with MonoDevelop
 // User: boyd at 7:02 AMÂ2/11/2008
-
-using System.Collections.ObjectModel;
+// 
+// IBackend.cs
+//  
+// Author:
+//       Antonius Riha <antoniusriha gmail com>
+// 
+// Copyright (c) 2012 Antonius Riha
+// 
+// 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.
 using System.Collections;
+using System.Collections.ObjectModel;
 
 namespace Tasque.Backends
 {
@@ -59,6 +83,14 @@ namespace Tasque.Backends
 		bool Initialized {
 			get;
 		}
+		
+		/// <summary>
+		/// An object that provides a means of managing backend specific preferences.
+		/// </summary>
+		/// <returns>
+		/// A <see cref="Tasque.Backends.BackendPreferences"/>
+		/// </returns>
+		IBackendPreferences Preferences { get; }
 		#endregion // Properties
 		
 		#region Methods
@@ -89,16 +121,6 @@ namespace Tasque.Backends
 		/// Cleanup the backend before quitting
 		/// </summary>
 		void Cleanup ();
-		
-		/// <summary>
-		/// A widget that will be placed into the Preferences Dialog when the
-		/// backend is the one being used.
-		/// </summary>
-		/// <returns>
-		/// A <see cref="Gtk.Widget"/>
-		/// </returns>
-		Gtk.Widget GetPreferencesWidget ();
-
 		#endregion // Methods
 	}
 }
diff --git a/src/libtasque/IBackendPreferences.cs b/src/libtasque/IBackendPreferences.cs
new file mode 100644
index 0000000..8154eb7
--- /dev/null
+++ b/src/libtasque/IBackendPreferences.cs
@@ -0,0 +1,33 @@
+// 
+// IBackendPreferences.cs
+//  
+// Author:
+//       Antonius Riha <antoniusriha gmail com>
+// 
+// Copyright (c) 2012 Antonius Riha
+// 
+// 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.
+
+namespace Tasque.Backends
+{
+	public interface IBackendPreferences
+	{
+	}
+}
+
diff --git a/src/libtasque/libtasque.csproj b/src/libtasque/libtasque.csproj
index 3c10a45..9b27d2a 100644
--- a/src/libtasque/libtasque.csproj
+++ b/src/libtasque/libtasque.csproj
@@ -160,30 +160,12 @@
       <Link>Properties\GlobalDefines.cs</Link>
     </Compile>
     <Compile Include="NativeApplication.cs" />
+    <Compile Include="IBackendPreferences.cs" />
   </ItemGroup>
   <ItemGroup>
-    <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
-      <Package>gtk-sharp-2.0</Package>
-    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="Mono.Posix" />
-    <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
-      <Private>False</Private>
-      <Package>gtk-sharp-2.0</Package>
-    </Reference>
-    <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
-      <Private>False</Private>
-      <Package>gtk-sharp-2.0</Package>
-    </Reference>
-    <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
-      <Private>False</Private>
-      <Package>gtk-sharp-2.0</Package>
-    </Reference>
-    <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
-      <Private>False</Private>
-      <Package>glib-sharp-2.0</Package>
-    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="DateFormatters\" />
diff --git a/src/tasque/Backends/Dummy/DummyBackend.cs b/src/tasque/Backends/Dummy/DummyBackend.cs
index 2a394fc..70be94b 100644
--- a/src/tasque/Backends/Dummy/DummyBackend.cs
+++ b/src/tasque/Backends/Dummy/DummyBackend.cs
@@ -32,6 +32,7 @@ using System.Collections.ObjectModel;
 using System.ComponentModel;
 using CollectionTransforms;
 using Tasque.Backends;
+using Tasque.Backends.Dummy.Gtk;
 
 namespace Tasque.Backends.Dummy
 {
@@ -246,11 +247,13 @@ namespace Tasque.Backends.Dummy
 		{
 		}
 		
-		public Gtk.Widget GetPreferencesWidget ()
+		public IBackendPreferences Preferences
 		{
-			// TODO: Replace this with returning null once things are going
-			// so that the Preferences Dialog doesn't waste space.
-			return new Gtk.Label ("Debugging System (this message is a test)");
+			get {
+				// TODO: Replace this with returning null once things are going
+				// so that the Preferences Dialog doesn't waste space.
+				return new DummyPreferences ();
+			}
 		}
 		#endregion // Public Methods
 		
diff --git a/src/tasque/Backends/Dummy/Gtk/DummyPreferences.cs b/src/tasque/Backends/Dummy/Gtk/DummyPreferences.cs
new file mode 100644
index 0000000..1a33a58
--- /dev/null
+++ b/src/tasque/Backends/Dummy/Gtk/DummyPreferences.cs
@@ -0,0 +1,40 @@
+// 
+// DummyPreferences.cs
+//  
+// Author:
+//       Antonius Riha <antoniusriha gmail com>
+// 
+// Copyright (c) 2012 Antonius Riha
+// 
+// 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.
+using Gtk;
+
+namespace Tasque.Backends.Dummy.Gtk
+{
+	public class DummyPreferences : Box, IBackendPreferences
+	{
+		public DummyPreferences () : base ()
+		{
+			var lbl = new Label ("Debugging System (this message is a test)");
+			PackStart (lbl, true, true, 0);
+			ShowAll ();
+		}
+	}
+}
+
diff --git a/src/tasque/PreferencesDialog.cs b/src/tasque/PreferencesDialog.cs
index 5e586f5..3bc101e 100644
--- a/src/tasque/PreferencesDialog.cs
+++ b/src/tasque/PreferencesDialog.cs
@@ -131,7 +131,7 @@ namespace Tasque
 			backendPageId = -1;
 			
 			if (Application.Backend != null) {
-				backendPage = Application.Backend.GetPreferencesWidget ();
+				backendPage = (Widget)Application.Backend.Preferences;
 				if (backendPage != null) {
 					backendPage.Show ();
 					Label l =
@@ -462,7 +462,7 @@ namespace Tasque
 			selectedBackend = backendComboBox.Active;
 			
 			// Add a backend prefs page if one exists
-			backendPage = newBackend.GetPreferencesWidget ();
+			backendPage = (Widget)newBackend.Preferences;
 			if (backendPage != null) {
 				backendPage.Show ();
 				Label l = new Label (GLib.Markup.EscapeText (newBackend.Name));
diff --git a/src/tasque/tasque.csproj b/src/tasque/tasque.csproj
index 6f3a875..aee5e15 100644
--- a/src/tasque/tasque.csproj
+++ b/src/tasque/tasque.csproj
@@ -11,7 +11,7 @@
     <AssemblyName>tasque</AssemblyName>
     <FileAlignment>512</FileAlignment>
     <NoWin32Manifest>True</NoWin32Manifest>
-    <RootNamespace>tasque</RootNamespace>
+    <RootNamespace>Tasque</RootNamespace>
     <ReleaseVersion>0.1.10</ReleaseVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'GnomeDebug|AnyCPU' ">
@@ -230,6 +230,7 @@
     <Compile Include="TaskTreeView.cs" />
     <Compile Include="TaskWindow.cs" />
     <Compile Include="Utilities.cs" />
+    <Compile Include="Backends\Dummy\Gtk\DummyPreferences.cs" />
   </ItemGroup>
   <ItemGroup Condition=" '$(Configuration)' == 'GnomeDebug' or '$(Configuration)' == 'GnomeRelease' ">
     <Compile Include="GnomeApplication.cs" />
@@ -253,6 +254,7 @@
     <Folder Include="data\osx\Contents\" />
     <Folder Include="data\osx\Contents\MacOS\" />
     <Folder Include="data\osx\Contents\Resources\" />
+    <Folder Include="Backends\Dummy\Gtk\" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\libtasque\libtasque.csproj">



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