[tasque/transition: 197/213] [libtasque] Add initial support for thread dispatching



commit 1815a81d44917a7ee084896407331715fe46058c
Author: Antonius Riha <antoniusriha gmail com>
Date:   Sun Aug 19 17:47:25 2012 +0200

    [libtasque] Add initial support for thread dispatching

 src/Tasque.Gtk/GtkApplication.cs |    5 +++++
 src/Tasque.Gtk/GtkDispatcher.cs  |   37 +++++++++++++++++++++++++++++++++++++
 src/Tasque.Gtk/Tasque.Gtk.csproj |    1 +
 src/libtasque/Application.cs     |    2 ++
 src/libtasque/Dispatcher.cs      |   34 ++++++++++++++++++++++++++++++++++
 src/libtasque/libtasque.csproj   |    1 +
 6 files changed, 80 insertions(+), 0 deletions(-)
---
diff --git a/src/Tasque.Gtk/GtkApplication.cs b/src/Tasque.Gtk/GtkApplication.cs
index 1c4194b..60783ae 100644
--- a/src/Tasque.Gtk/GtkApplication.cs
+++ b/src/Tasque.Gtk/GtkApplication.cs
@@ -51,6 +51,10 @@ namespace Tasque
 			instance = this;
 		}
 		
+		public override Dispatcher Dispatcher {
+			get { return dispatcher ?? (dispatcher = new GtkDispatcher ()); }
+		}
+		
 		protected override void OnInitialize ()
 		{
 			Catalog.Init ("tasque", GlobalDefines.LocaleDir);
@@ -227,5 +231,6 @@ namespace Tasque
 		bool backendWasNullBeforeChange;
 		PreferencesDialog preferencesDialog;
 		GtkTray trayIcon;
+		GtkDispatcher dispatcher;
 	}
 }
diff --git a/src/Tasque.Gtk/GtkDispatcher.cs b/src/Tasque.Gtk/GtkDispatcher.cs
new file mode 100644
index 0000000..7b23d0a
--- /dev/null
+++ b/src/Tasque.Gtk/GtkDispatcher.cs
@@ -0,0 +1,37 @@
+// 
+// GtkDispatcher.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;
+
+namespace Tasque
+{
+	public class GtkDispatcher : Dispatcher
+	{
+		public override void Invoke (EventHandler handler)
+		{
+			Gtk.Application.Invoke (handler);
+		}
+	}
+}
diff --git a/src/Tasque.Gtk/Tasque.Gtk.csproj b/src/Tasque.Gtk/Tasque.Gtk.csproj
index 18e1b24..5b80f00 100644
--- a/src/Tasque.Gtk/Tasque.Gtk.csproj
+++ b/src/Tasque.Gtk/Tasque.Gtk.csproj
@@ -114,6 +114,7 @@
     <Compile Include="StatusIconTray.cs" />
     <Compile Include="GtkTray.cs" />
     <Compile Include="GtkApplication.cs" />
+    <Compile Include="GtkDispatcher.cs" />
   </ItemGroup>
   <ItemGroup Condition=" '$(Configuration)' == 'WinDebug' or '$(Configuration)' == 'WinRelease' ">
     <Compile Include="GtkWinApplication.cs" />
diff --git a/src/libtasque/Application.cs b/src/libtasque/Application.cs
index 50675a6..f737be8 100644
--- a/src/libtasque/Application.cs
+++ b/src/libtasque/Application.cs
@@ -53,6 +53,8 @@ namespace Tasque
 			Application.Instance = this;
 		}
 		
+		public abstract Dispatcher Dispatcher { get; }
+		
 		public List<Backend> AvailableBackends {
 			get { return new List<Backend> (availableBackends.Values); }
 //			get { return Application.Instance.availableBackends; }
diff --git a/src/libtasque/Dispatcher.cs b/src/libtasque/Dispatcher.cs
new file mode 100644
index 0000000..58068a9
--- /dev/null
+++ b/src/libtasque/Dispatcher.cs
@@ -0,0 +1,34 @@
+// 
+// Dispatcher.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;
+
+namespace Tasque
+{
+	public abstract class Dispatcher
+	{
+		public abstract void Invoke (EventHandler handler);
+	}
+}
diff --git a/src/libtasque/libtasque.csproj b/src/libtasque/libtasque.csproj
index f45fed8..3cdb2c3 100644
--- a/src/libtasque/libtasque.csproj
+++ b/src/libtasque/libtasque.csproj
@@ -71,6 +71,7 @@
     <Compile Include="TaskGroupModel.cs" />
     <Compile Include="CompletedTaskGroupModel.cs" />
     <Compile Include="Application.cs" />
+    <Compile Include="Dispatcher.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />



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