Code cleanup

This commit is contained in:
Hylke Bons 2012-01-03 23:12:44 +00:00
parent 7155c3e816
commit 10fd77a9b8
6 changed files with 46 additions and 29 deletions

View file

@ -57,6 +57,8 @@ namespace SparkleShare {
OrderFrontRegardless ();
MakeKeyAndOrderFront (this);
Program.UI.UpdateDockIconVisibility ();
Controller.NewVersionEvent += delegate (string new_version) {
InvokeOnMainThread (delegate {
UpdatesTextField.StringValue = "A newer version (" + new_version + ") is available!";
@ -161,6 +163,8 @@ namespace SparkleShare {
public override bool WindowShouldClose (NSObject sender)
{
(sender as SparkleAbout).OrderOut (this);
Program.UI.UpdateDockIconVisibility ();
return false;
}
}

View file

@ -28,8 +28,6 @@ using MonoMac.WebKit;
namespace SparkleShare {
public class SparkleEventLog : NSWindow {
public SparkleEventLogController Controller = new SparkleEventLogController ();
@ -53,7 +51,7 @@ namespace SparkleShare {
// TODO: Window needs to be made resizable
public SparkleEventLog () : base ()
{
{
Title = "Recent Events";
Delegate = new SparkleEventsDelegate ();
@ -132,6 +130,7 @@ namespace SparkleShare {
UpdateChooser (null);
OrderFrontRegardless ();
Program.UI.UpdateDockIconVisibility ();
// Hook up the controller events
Controller.UpdateChooserEvent += delegate (string [] folders) {
@ -242,6 +241,8 @@ namespace SparkleShare {
public override bool WindowShouldClose (NSObject sender)
{
(sender as SparkleEventLog).OrderOut (this);
Program.UI.UpdateDockIconVisibility ();
return false;
}
}

View file

@ -87,6 +87,7 @@ namespace SparkleShare {
MakeKeyAndOrderFront (this);
OrderFrontRegardless ();
Program.UI.UpdateDockIconVisibility ();
}
@ -145,6 +146,8 @@ namespace SparkleShare {
{
base.OrderOut (this);
NSApplication.SharedApplication.RemoveWindowsItem (this);
Program.UI.UpdateDockIconVisibility ();
return;
}

4
SparkleShare/Mac/SparkleShare.csproj Normal file → Executable file
View file

@ -6,7 +6,7 @@
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CF5BC8DB-A633-4FCC-8A3E-E3AC9B59FABC}</ProjectGuid>
<ProjectTypeGuids>{948B3504-5B70-4649-8FE4-BDE1FB46EC69};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectTypeGuids>{1C533B1C-72DD-4CB1-9F6B-BF11D93BCFBE};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>SparkleShare</RootNamespace>
<AssemblyName>SparkleShare</AssemblyName>
@ -116,7 +116,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="MainMenu.xib" xmlns="" />
<Page Include="MainMenu.xib" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />

View file

@ -46,7 +46,7 @@ namespace SparkleShare {
private NSMenuItem AboutMenuItem;
private NSMenuItem NotificationsMenuItem;
private NSMenuItem RecentEventsMenuItem;
private NSMenuItem QuitAppMenuItem;
private NSMenuItem QuitMenuItem;
private NSImage [] AnimationFrames;
private NSImage [] AnimationFramesActive;
private NSImage ErrorImage;
@ -252,9 +252,6 @@ namespace SparkleShare {
if (Controller.Folders.Length > 0) {
RecentEventsMenuItem.Activated += delegate {
InvokeOnMainThread (delegate {
//Show the icon in Dock
Program.UI.SetRegularActivationPolicy();
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
if (SparkleUI.EventLog == null)
@ -312,21 +309,17 @@ namespace SparkleShare {
Menu.AddItem (NSMenuItem.SeparatorItem);
QuitAppMenuItem = new NSMenuItem () {
Title = "Quit SparkleShare",
Enabled = true
};
QuitMenuItem = new NSMenuItem () {
Title = "Quit",
Enabled = true
};
QuitAppMenuItem.Activated += delegate {
InvokeOnMainThread (delegate {
NSApplication.SharedApplication.Terminate(this);
QuitMenuItem.Activated += delegate {
Program.Controller.Quit ();
};
Menu.AddItem (QuitMenuItem);
});
};
Menu.AddItem (QuitAppMenuItem);
StatusItem.Menu = Menu;
StatusItem.Menu.Update ();
}

View file

@ -67,8 +67,6 @@ namespace SparkleShare {
Bubbles = new SparkleBubbles ();
if (Program.Controller.FirstRun) {
//Show Icon in Dock
this.SetRegularActivationPolicy();
Setup = new SparkleSetup ();
Setup.Controller.ShowSetupPage ();
}
@ -92,11 +90,29 @@ namespace SparkleShare {
{
NSApplication.Main (new string [0]);
}
public void SetRegularActivationPolicy()
{
NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;
}
public void UpdateDockIconVisibility ()
{
if (true) { // TODO: check for open windows
ShowDockIcon ();
} else {
HideDockIcon ();
}
}
private void HideDockIcon () {
// Currently not supported, here for completeness sake (see Apple's docs)
// NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.None;
}
private void ShowDockIcon () {
NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;
}
[Export("registrationDictionaryForGrowl")]