[tasque/viewmodel: 66/78] Improve AboutDialog viewmodel and NativeClass implementation
- From: Antonius Riha <antoniusri src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tasque/viewmodel: 66/78] Improve AboutDialog viewmodel and NativeClass implementation
- Date: Wed, 29 Aug 2012 18:40:12 +0000 (UTC)
commit b1798ad68a128b96f537f1d843d6a12b327b864d
Author: Antonius Riha <antoniusriha gmail com>
Date: Wed Aug 8 18:44:24 2012 +0200
Improve AboutDialog viewmodel and NativeClass implementation
* No further explanation, I'm hungry.
src/libtasqueui/Legacy/AboutDialogModel.cs | 32 ++++++++++-
src/libtasqueui/Legacy/NativeApplication.cs | 79 ++++++++++++++++++++++++++-
2 files changed, 105 insertions(+), 6 deletions(-)
---
diff --git a/src/libtasqueui/Legacy/AboutDialogModel.cs b/src/libtasqueui/Legacy/AboutDialogModel.cs
index 86d5bfc..6b2bfdc 100644
--- a/src/libtasqueui/Legacy/AboutDialogModel.cs
+++ b/src/libtasqueui/Legacy/AboutDialogModel.cs
@@ -24,13 +24,39 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
+using System.Collections.ObjectModel;
+using Mono.Unix;
+
namespace Tasque.UIModel.Legacy
{
- public class AboutDialogModel
+ public class AboutDialogModel : ViewModel
{
- public AboutDialogModel ()
+ internal AboutDialogModel (string iconName, ViewModel parent) : base (parent)
{
+ IconName = iconName;
+ }
+
+ public ReadOnlyCollection<string> Authors { get { return GlobalDefines.Authors; } }
+
+ public string CopyrightInfo { get { return GlobalDefines.CopyrightInfo; } }
+
+ public string Description { get { return "A useful task list."; } }
+
+ public string IconName { get; private set; }
+
+ public string License { get { return GlobalDefines.License; } }
+
+ public string Version { get { return GlobalDefines.Version; } }
+
+ public string WebsiteUrl { get { return GlobalDefines.Website; } }
+
+ public ReadOnlyCollection<string> Translators {
+ get {
+ var translators = Catalog.GetString ("translator-credits");
+ if (translators == "translator-credits")
+ translators = null;
+ return translators ?? string.Empty;
+ }
}
}
}
-
diff --git a/src/libtasqueui/Legacy/NativeApplication.cs b/src/libtasqueui/Legacy/NativeApplication.cs
index 186db4e..d0da541 100644
--- a/src/libtasqueui/Legacy/NativeApplication.cs
+++ b/src/libtasqueui/Legacy/NativeApplication.cs
@@ -30,10 +30,12 @@ using System.Diagnostics;
using System.IO;
using System.Reflection;
using Mono.Options;
+using CrossCommand;
+using System.ComponentModel;
namespace Tasque.UIModel.Legacy
{
- public abstract class NativeApplication : IDisposable
+ public abstract class NativeApplication : INotifyPropertyChanged, IDisposable
{
protected NativeApplication () : this (Path.Combine (Environment.GetFolderPath (
Environment.SpecialFolder.ApplicationData), "tasque")) {}
@@ -46,15 +48,67 @@ namespace Tasque.UIModel.Legacy
ConfDir = confDir;
if (!Directory.Exists (confDir))
Directory.CreateDirectory (confDir);
+
+ viewModelRoot = new ViewModelRoot ();
}
public Backend CurrentBackend { get; private set; }
public ReadOnlyCollection<Backend> AvailableBackends { get; }
- public MainWindowModel MainWindowModel { get; }
-
protected string ConfDir { get; private set; }
+
+ public MainWindowModel MainWindowModel {
+ get { return mainWindowModel; }
+ private set {
+ if (value != mainWindowModel) {
+ mainWindowModel = value;
+ OnPropertyChanged ("MainWindowModel");
+ }
+ }
+ }
+ MainWindowModel mainWindowModel;
+
+ public RelayCommand ShowMainWindow {
+ get { return showMainWindow ?? (showMainWindow = new RelayCommand ()); }
+ }
+
+ public PreferencesDialogModel PreferencesDialogModel {
+ get { return preferencesDialogModel; }
+ private set {
+ if (value != preferencesDialogModel) {
+ preferencesDialogModel = value;
+ OnPropertyChanged ("PreferencesDialogModel");
+ }
+ }
+ }
+ PreferencesDialogModel preferencesDialogModel;
+
+ public RelayCommand ShowPreferencesDialog {
+ get { return showPreferencesDialog ?? (showPreferencesDialog = new RelayCommand ()); }
+ }
+
+ public AboutDialogModel AboutDialogModel { get; private set; }
+
+ public ICommand ShowAboutDialog {
+ get {
+ if (showAboutDialog == null) {
+ showAboutDialog = new RelayCommand () {
+ ExecuteAction = delegate {
+ if (AboutDialogModel == null)
+ AboutDialogModel = new AboutDialogModel ("tasque-24", viewModelRoot);
+ OnPropertyChanged ("AboutDialogModel");
+ }
+ };
+ }
+
+ return showAboutDialog;
+ }
+ }
+
+ RelayCommand showAboutDialog;
+
+ RelayCommand showPreferencesDialog;
public void Exit (int exitcode)
{
@@ -159,6 +213,16 @@ namespace Tasque.UIModel.Legacy
Dispose (false);
}
#endregion
+
+ #region INotifyPropertyChanged implementation
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged (string propertyName)
+ {
+ if (PropertyChanged != null)
+ PropertyChanged (this, new PropertyChangedEventArgs (propertyName));
+ }
+ #endregion
/// <summary>
/// Load all the available backends that Tasque can find. First look in
@@ -335,5 +399,14 @@ namespace Tasque.UIModel.Legacy
Dictionary<string, Backend> availableBackends;
TrayModel tray;
+
+ RelayCommand showMainWindow;
+
+ ViewModelRoot viewModelRoot;
+
+ class ViewModelRoot : ViewModel
+ {
+ internal ViewModelRoot () : base (null) {}
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]