Code cleanup
This commit is contained in:
parent
54f40b1390
commit
bf22f3c566
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ namespace SparkleShare {
|
|||
|
||||
public class SparkleEventLog : NSWindow {
|
||||
|
||||
|
||||
|
||||
public SparkleEventLogController Controller = new SparkleEventLogController ();
|
||||
|
||||
private WebView web_view = new WebView (new RectangleF (0, 0, 480, 579), "", "") {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
4
SparkleShare/Mac/SparkleShare.csproj
Normal file → Executable 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" />
|
||||
|
|
|
@ -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,20 +309,16 @@ namespace SparkleShare {
|
|||
Menu.AddItem (NSMenuItem.SeparatorItem);
|
||||
|
||||
|
||||
QuitAppMenuItem = new NSMenuItem () {
|
||||
Title = "Quit SparkleShare",
|
||||
Enabled = true
|
||||
QuitMenuItem = new NSMenuItem () {
|
||||
Title = "Quit",
|
||||
Enabled = true
|
||||
};
|
||||
|
||||
QuitMenuItem.Activated += delegate {
|
||||
Program.Controller.Quit ();
|
||||
};
|
||||
|
||||
QuitAppMenuItem.Activated += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
NSApplication.SharedApplication.Terminate(this);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Menu.AddItem (QuitAppMenuItem);
|
||||
Menu.AddItem (QuitMenuItem);
|
||||
|
||||
StatusItem.Menu = Menu;
|
||||
StatusItem.Menu.Update ();
|
||||
|
|
|
@ -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 ();
|
||||
}
|
||||
|
@ -93,10 +91,28 @@ 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")]
|
||||
|
|
Loading…
Reference in a new issue