[tasque] Refactor NativeApplication model
- From: Antonius Riha <antoniusri src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tasque] Refactor NativeApplication model
- Date: Fri, 30 Nov 2012 16:13:44 +0000 (UTC)
commit f81bf458fa41345e947ef8160a7611644b911ec5
Author: Antonius Riha <antoniusriha gmail com>
Date: Fri Nov 30 15:39:50 2012 +0100
Refactor NativeApplication model
* Implemented common abstract class NativeApplication.
* Dropped GnomeApplication
src/Gtk.Tasque/Application.cs | 8 +--
src/Gtk.Tasque/GnomeApplication.cs | 110 -----------------------------------
src/Gtk.Tasque/Gtk.Tasque.csproj | 1 -
src/Gtk.Tasque/GtkApplication.cs | 35 +++--------
src/libtasque/INativeApplication.cs | 20 +++---
src/libtasque/NativeApplication.cs | 64 ++++++++++++++++++++
src/libtasque/libtasque.csproj | 1 +
src/tasque/Program.cs | 4 +-
8 files changed, 87 insertions(+), 156 deletions(-)
---
diff --git a/src/Gtk.Tasque/Application.cs b/src/Gtk.Tasque/Application.cs
index f5ae1b4..5f00b91 100644
--- a/src/Gtk.Tasque/Application.cs
+++ b/src/Gtk.Tasque/Application.cs
@@ -141,12 +141,8 @@ namespace Tasque
initialized = true;
}
- nativeApp.Initialize (
- Defines.LocaleDir,
- "Tasque",
- "Tasque",
- args);
-
+ nativeApp.Initialize (args);
+
preferences = new Preferences (nativeApp.ConfDir);
#if !WIN && !OSX
diff --git a/src/Gtk.Tasque/Gtk.Tasque.csproj b/src/Gtk.Tasque/Gtk.Tasque.csproj
index 9d5e9ec..ea3135c 100644
--- a/src/Gtk.Tasque/Gtk.Tasque.csproj
+++ b/src/Gtk.Tasque/Gtk.Tasque.csproj
@@ -91,7 +91,6 @@
<Compile Include="CompletedTaskGroup.cs" />
<Compile Include="CompletedTaskGroupModel.cs" />
<Compile Include="DateButton.cs" />
- <Compile Include="GnomeApplication.cs" />
<Compile Include="GtkApplication.cs" />
<Compile Include="Logger.cs" />
<Compile Include="NoteDialog.cs" />
diff --git a/src/Gtk.Tasque/GtkApplication.cs b/src/Gtk.Tasque/GtkApplication.cs
index 08beb3c..7c9cd16 100644
--- a/src/Gtk.Tasque/GtkApplication.cs
+++ b/src/Gtk.Tasque/GtkApplication.cs
@@ -18,25 +18,21 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2008 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2012 Antonius Riha
//
// Authors:
// Sandy Armstrong <sanfordarmstrong gmail com>
+// Antonius Riha <antoniusriha gmail com>
//
-
-
using System;
using System.IO;
namespace Tasque
{
- public class GtkApplication : INativeApplication
+ public class GtkApplication : NativeApplication
{
- #region INativeApplication implementation
-
private string confDir;
- public virtual event EventHandler ExitingEvent;
-
public GtkApplication ()
{
confDir = Path.Combine (
@@ -46,8 +42,8 @@ namespace Tasque
if (!Directory.Exists (confDir))
Directory.CreateDirectory (confDir);
}
-
- public virtual void Initialize (string locale_dir, string display_name, string process_name, string[] args)
+
+ public override void Initialize (string[] args)
{
Mono.Unix.Catalog.Init ("tasque", Defines.LocaleDir);
@@ -59,29 +55,18 @@ namespace Tasque
Gtk.IconTheme.Default.PrependSearchPath (Defines.DataDir + "\\icons");
#endif
}
-
- public virtual void InitializeIdle ()
- {
- }
-
- public virtual void Exit (int exitcode)
- {
- if (ExitingEvent != null)
- ExitingEvent (null, new EventArgs ());
- System.Environment.Exit (exitcode);
- }
- public virtual void StartMainLoop ()
+ public override void StartMainLoop ()
{
Gtk.Application.Run ();
}
- public virtual void QuitMainLoop ()
+ public override void QuitMainLoop ()
{
Gtk.Application.Quit ();
}
- public virtual string ConfDir
+ public override string ConfDir
{
get
{
@@ -89,7 +74,7 @@ namespace Tasque
}
}
- public virtual void OpenUrl (string url)
+ public override void OpenUrl (string url)
{
try {
System.Diagnostics.Process.Start (url);
@@ -97,7 +82,5 @@ namespace Tasque
Logger.Error ("Error opening url [{0}]:\n{1}", url, e.ToString ());
}
}
-
- #endregion
}
}
diff --git a/src/libtasque/INativeApplication.cs b/src/libtasque/INativeApplication.cs
index d333357..11a8f06 100644
--- a/src/libtasque/INativeApplication.cs
+++ b/src/libtasque/INativeApplication.cs
@@ -4,20 +4,20 @@ namespace Tasque
{
public interface INativeApplication
{
- void Initialize (string locale_dir,
- string display_name,
- string process_name,
- string [] args);
-
- event EventHandler ExitingEvent;
+ string ConfDir { get; }
void Exit (int exitcode);
- void StartMainLoop ();
- void QuitMainLoop ();
- void InitializeIdle ();
- string ConfDir { get; }
+ void Initialize (string [] args);
+
+ void InitializeIdle ();
void OpenUrl (string url);
+
+ void QuitMainLoop ();
+
+ void StartMainLoop ();
+
+ event EventHandler Exiting;
}
}
diff --git a/src/libtasque/NativeApplication.cs b/src/libtasque/NativeApplication.cs
new file mode 100644
index 0000000..92565f2
--- /dev/null
+++ b/src/libtasque/NativeApplication.cs
@@ -0,0 +1,64 @@
+//
+// NativeApplication.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;
+using System.Diagnostics;
+
+namespace Tasque
+{
+ public abstract class NativeApplication : INativeApplication
+ {
+ public abstract string ConfDir { get; }
+
+ public void Exit (int exitcode)
+ {
+ OnExit (exitcode);
+
+ if (Exiting != null)
+ Exiting (this, EventArgs.Empty);
+
+ Environment.Exit (exitcode);
+ }
+
+ public abstract void Initialize (string[] args);
+
+ public virtual void InitializeIdle () {}
+
+ protected virtual void OnExit (int exitCode) {}
+
+ public virtual void OpenUrl (string url)
+ {
+ Process.Start (url);
+ }
+
+ public abstract void QuitMainLoop ();
+
+ public abstract void StartMainLoop ();
+
+ public event EventHandler Exiting;
+ }
+}
+
diff --git a/src/libtasque/libtasque.csproj b/src/libtasque/libtasque.csproj
index 1dc2c11..f3503bf 100644
--- a/src/libtasque/libtasque.csproj
+++ b/src/libtasque/libtasque.csproj
@@ -71,6 +71,7 @@
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="IBackendPreferences.cs" />
+ <Compile Include="NativeApplication.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="DateFormatters\" />
diff --git a/src/tasque/Program.cs b/src/tasque/Program.cs
index c5680e5..0728a6c 100644
--- a/src/tasque/Program.cs
+++ b/src/tasque/Program.cs
@@ -34,10 +34,8 @@ namespace Tasque
INativeApplication nativeApp;
#if OSX
nativeApp = new OSXApplication ();
-#elif WIN
- nativeApp = new GtkApplication ();
#else
- nativeApp = new GnomeApplication ();
+ nativeApp = new GtkApplication ();
#endif
return nativeApp;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]