about: move more logic to controller
This commit is contained in:
parent
8bed56d707
commit
1980a81204
|
@ -54,12 +54,17 @@ namespace SparkleShare {
|
|||
|
||||
CreateAbout ();
|
||||
|
||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||
MakeKeyAndOrderFront (this);
|
||||
Controller.HideWindowEvent += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
PerformClose (this);
|
||||
});
|
||||
};
|
||||
|
||||
OrderFrontRegardless ();
|
||||
|
||||
Program.UI.UpdateDockIconVisibility ();
|
||||
Controller.ShowWindowEvent += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
OrderFrontRegardless ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.NewVersionEvent += delegate (string new_version) {
|
||||
InvokeOnMainThread (delegate {
|
||||
|
@ -157,6 +162,29 @@ namespace SparkleShare {
|
|||
ContentView.AddSubview (UpdatesTextField);
|
||||
ContentView.AddSubview (CreditsTextField);
|
||||
}
|
||||
|
||||
|
||||
public override void OrderFrontRegardless ()
|
||||
{
|
||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||
MakeKeyAndOrderFront (this);
|
||||
|
||||
if (Program.UI != null)
|
||||
Program.UI.UpdateDockIconVisibility ();
|
||||
|
||||
base.OrderFrontRegardless ();
|
||||
}
|
||||
|
||||
|
||||
public override void PerformClose (NSObject sender)
|
||||
{
|
||||
base.OrderOut (this);
|
||||
|
||||
if (Program.UI != null)
|
||||
Program.UI.UpdateDockIconVisibility ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,9 +192,7 @@ namespace SparkleShare {
|
|||
|
||||
public override bool WindowShouldClose (NSObject sender)
|
||||
{
|
||||
(sender as SparkleAbout).OrderOut (this);
|
||||
Program.UI.UpdateDockIconVisibility ();
|
||||
|
||||
(sender as SparkleAbout).Controller.HideWindow ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -294,18 +294,8 @@ namespace SparkleShare {
|
|||
Enabled = true
|
||||
};
|
||||
|
||||
// TODO: move this logic
|
||||
AboutMenuItem.Activated += delegate {
|
||||
// Controller.AboutClicked ();
|
||||
InvokeOnMainThread (delegate {
|
||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||
|
||||
if (SparkleUI.About == null)
|
||||
SparkleUI.About = new SparkleAbout ();
|
||||
else
|
||||
SparkleUI.About.OrderFrontRegardless ();
|
||||
|
||||
});
|
||||
Controller.AboutClicked ();
|
||||
};
|
||||
|
||||
Menu.AddItem (AboutMenuItem);
|
||||
|
|
|
@ -64,9 +64,9 @@ namespace SparkleShare {
|
|||
("Lucida Grande", NSFontTraitMask.Bold, 0, 13);
|
||||
|
||||
StatusIcon = new SparkleStatusIcon ();
|
||||
Bubbles = new SparkleBubbles ();
|
||||
Setup = new SparkleSetup ();
|
||||
// About = new SparkleAbout ();
|
||||
Bubbles = new SparkleBubbles ();
|
||||
Setup = new SparkleSetup ();
|
||||
About = new SparkleAbout ();
|
||||
|
||||
if (Program.Controller.FirstRun)
|
||||
Program.Controller.ShowSetupWindow (PageType.Setup);
|
||||
|
|
|
@ -26,6 +26,12 @@ namespace SparkleShare {
|
|||
|
||||
public class SparkleAboutController {
|
||||
|
||||
public event ShowWindowEventHandler ShowWindowEvent;
|
||||
public delegate void ShowWindowEventHandler ();
|
||||
|
||||
public event HideWindowEventHandler HideWindowEvent;
|
||||
public delegate void HideWindowEventHandler ();
|
||||
|
||||
public event NewVersionEventHandler NewVersionEvent;
|
||||
public delegate void NewVersionEventHandler (string new_version);
|
||||
|
||||
|
@ -35,32 +41,34 @@ namespace SparkleShare {
|
|||
public event CheckingForNewVersionEventHandler CheckingForNewVersionEvent;
|
||||
public delegate void CheckingForNewVersionEventHandler ();
|
||||
|
||||
|
||||
public string RunningVersion {
|
||||
get {
|
||||
return SparkleBackend.Version;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for a new version once a day
|
||||
private System.Timers.Timer version_checker = new System.Timers.Timer () {
|
||||
Enabled = true,
|
||||
Interval = 24 * 60 * 60 * 1000
|
||||
};
|
||||
|
||||
|
||||
public SparkleAboutController ()
|
||||
{
|
||||
CheckForNewVersion ();
|
||||
Program.Controller.ShowAboutWindowEvent += delegate {
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
|
||||
this.version_checker.Elapsed += delegate {
|
||||
CheckForNewVersion ();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void HideWindow ()
|
||||
{
|
||||
if (HideWindowEvent != null)
|
||||
HideWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
public void CheckForNewVersion ()
|
||||
{
|
||||
this.version_checker.Stop ();
|
||||
if (CheckingForNewVersionEvent != null)
|
||||
CheckingForNewVersionEvent ();
|
||||
|
||||
|
@ -92,8 +100,6 @@ namespace SparkleShare {
|
|||
if (NewVersionEvent != null)
|
||||
NewVersionEvent (result);
|
||||
}
|
||||
|
||||
this.version_checker.Start ();
|
||||
};
|
||||
|
||||
web_client.DownloadStringAsync (uri);
|
||||
|
|
|
@ -135,5 +135,11 @@ namespace SparkleShare {
|
|||
{
|
||||
Program.Controller.ShowSetupWindow (PageType.Add);
|
||||
}
|
||||
|
||||
|
||||
public void AboutClicked ()
|
||||
{
|
||||
Program.Controller.ShowAboutWindow ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue