mac: clean up
This commit is contained in:
parent
b57bc767cb
commit
d8e4d5cabc
|
@ -56,8 +56,6 @@ namespace SparkleShare {
|
||||||
this.status_item.HighlightMode = true;
|
this.status_item.HighlightMode = true;
|
||||||
this.status_item.Image = this.syncing_idle_image;
|
this.status_item.Image = this.syncing_idle_image;
|
||||||
this.status_item.AlternateImage = this.syncing_idle_image_active;
|
this.status_item.AlternateImage = this.syncing_idle_image_active;
|
||||||
this.status_item.Image.Size = new SizeF (16, 16);
|
|
||||||
this.status_item.AlternateImage.Size = new SizeF (16, 16);
|
|
||||||
|
|
||||||
CreateMenu ();
|
CreateMenu ();
|
||||||
|
|
||||||
|
@ -90,9 +88,6 @@ namespace SparkleShare {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.status_item.Image.Size = new SizeF (16, 16);
|
|
||||||
this.status_item.AlternateImage.Size = new SizeF (16, 16);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,13 +109,11 @@ namespace SparkleShare {
|
||||||
{
|
{
|
||||||
this.menu = new NSMenu () { AutoEnablesItems = false };
|
this.menu = new NSMenu () { AutoEnablesItems = false };
|
||||||
|
|
||||||
|
|
||||||
this.state_item = new NSMenuItem () {
|
this.state_item = new NSMenuItem () {
|
||||||
Title = Controller.StateText,
|
Title = Controller.StateText,
|
||||||
Enabled = false
|
Enabled = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.folder_item = new NSMenuItem () {
|
this.folder_item = new NSMenuItem () {
|
||||||
Title = "SparkleShare",
|
Title = "SparkleShare",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
|
@ -129,40 +122,26 @@ namespace SparkleShare {
|
||||||
this.folder_item.Image = this.sparkleshare_image;
|
this.folder_item.Image = this.sparkleshare_image;
|
||||||
this.folder_item.Image.Size = new SizeF (16, 16);
|
this.folder_item.Image.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
|
|
||||||
this.add_item = new NSMenuItem () {
|
this.add_item = new NSMenuItem () {
|
||||||
Title = "Add Hosted Project…",
|
Title = "Add Hosted Project…",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.add_item.Activated += Controller.AddHostedProjectClicked;
|
|
||||||
|
|
||||||
|
|
||||||
this.recent_events_item = new NSMenuItem () {
|
this.recent_events_item = new NSMenuItem () {
|
||||||
Title = "Recent Changes…",
|
Title = "Recent Changes…",
|
||||||
Enabled = Controller.RecentEventsItemEnabled
|
Enabled = Controller.RecentEventsItemEnabled
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Controller.RecentEventsItemEnabled)
|
|
||||||
this.recent_events_item.Activated += Controller.RecentEventsClicked;
|
|
||||||
|
|
||||||
|
|
||||||
this.about_item = new NSMenuItem () {
|
this.about_item = new NSMenuItem () {
|
||||||
Title = "About SparkleShare",
|
Title = "About SparkleShare",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.about_item.Activated += Controller.AboutClicked;
|
|
||||||
|
|
||||||
|
|
||||||
this.quit_item = new NSMenuItem () {
|
this.quit_item = new NSMenuItem () {
|
||||||
Title = "Quit",
|
Title = "Quit",
|
||||||
Enabled = Controller.QuitItemEnabled
|
Enabled = Controller.QuitItemEnabled
|
||||||
};
|
};
|
||||||
|
|
||||||
this.quit_item.Activated += Controller.QuitClicked;
|
|
||||||
|
|
||||||
|
|
||||||
this.folder_menu_items = new NSMenuItem [Controller.Folders.Length];
|
this.folder_menu_items = new NSMenuItem [Controller.Folders.Length];
|
||||||
this.error_menu_items = new NSMenuItem [Controller.Folders.Length];
|
this.error_menu_items = new NSMenuItem [Controller.Folders.Length];
|
||||||
this.try_again_menu_items = new NSMenuItem [Controller.Folders.Length];
|
this.try_again_menu_items = new NSMenuItem [Controller.Folders.Length];
|
||||||
|
@ -199,6 +178,14 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Controller.RecentEventsItemEnabled)
|
||||||
|
this.recent_events_item.Activated += Controller.RecentEventsClicked;
|
||||||
|
|
||||||
|
this.add_item.Activated += Controller.AddHostedProjectClicked;
|
||||||
|
this.about_item.Activated += Controller.AboutClicked;
|
||||||
|
this.quit_item.Activated += Controller.QuitClicked;
|
||||||
|
|
||||||
|
|
||||||
this.menu.AddItem (this.state_item);
|
this.menu.AddItem (this.state_item);
|
||||||
this.menu.AddItem (NSMenuItem.SeparatorItem);
|
this.menu.AddItem (NSMenuItem.SeparatorItem);
|
||||||
this.menu.AddItem (this.folder_item);
|
this.menu.AddItem (this.folder_item);
|
||||||
|
|
|
@ -16,12 +16,9 @@
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
using MonoMac.Foundation;
|
using MonoMac.Foundation;
|
||||||
using MonoMac.AppKit;
|
using MonoMac.AppKit;
|
||||||
using MonoMac.ObjCRuntime;
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
@ -43,8 +40,8 @@ namespace SparkleShare {
|
||||||
public SparkleUI ()
|
public SparkleUI ()
|
||||||
{
|
{
|
||||||
Program.Controller.Invoke (() => {
|
Program.Controller.Invoke (() => {
|
||||||
NSWorkspace.SharedWorkspace.SetIconforFile (NSImage.ImageNamed ("sparkleshare-folder.icns"),
|
NSWorkspace.SharedWorkspace.SetIconforFile (
|
||||||
Program.Controller.FoldersPath, 0);
|
NSImage.ImageNamed ("sparkleshare-folder.icns"), Program.Controller.FoldersPath, 0);
|
||||||
|
|
||||||
NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed ("sparkleshare-app.icns");
|
NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed ("sparkleshare-app.icns");
|
||||||
|
|
||||||
|
@ -68,21 +65,6 @@ namespace SparkleShare {
|
||||||
public void UpdateDockIconVisibility ()
|
public void UpdateDockIconVisibility ()
|
||||||
{
|
{
|
||||||
if (Setup.IsVisible || EventLog.IsVisible || About.IsVisible)
|
if (Setup.IsVisible || EventLog.IsVisible || About.IsVisible)
|
||||||
ShowDockIcon ();
|
|
||||||
else
|
|
||||||
HideDockIcon ();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void HideDockIcon ()
|
|
||||||
{
|
|
||||||
// Currently not supported by Apple's API
|
|
||||||
// NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void ShowDockIcon ()
|
|
||||||
{
|
|
||||||
NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;
|
NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,4 +78,3 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,18 +68,9 @@ namespace SparkleShare {
|
||||||
UpdateSizeInfoEvent ("…", "…");
|
UpdateSizeInfoEvent ("…", "…");
|
||||||
|
|
||||||
new Thread (() => {
|
new Thread (() => {
|
||||||
Stopwatch watch = new Stopwatch ();
|
SparkleDelay delay = new SparkleDelay ();
|
||||||
watch.Start ();
|
|
||||||
|
|
||||||
string html = HTML;
|
string html = HTML;
|
||||||
watch.Stop ();
|
delay.Stop ();
|
||||||
|
|
||||||
// A short delay is less annoying than
|
|
||||||
// a flashing window
|
|
||||||
int delay = 500;
|
|
||||||
|
|
||||||
if (watch.ElapsedMilliseconds < delay)
|
|
||||||
Thread.Sleep (delay - (int) watch.ElapsedMilliseconds);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty (html))
|
if (!string.IsNullOrEmpty (html))
|
||||||
UpdateContentEvent (html);
|
UpdateContentEvent (html);
|
||||||
|
@ -161,16 +152,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (this.selected_folder == null) {
|
if (this.selected_folder == null) {
|
||||||
new Thread (() => {
|
new Thread (() => {
|
||||||
Stopwatch watch = new Stopwatch ();
|
SparkleDelay delay = new SparkleDelay ();
|
||||||
|
|
||||||
watch.Start ();
|
|
||||||
string html = HTML;
|
string html = HTML;
|
||||||
watch.Stop ();
|
delay.Stop ();
|
||||||
|
|
||||||
int delay = 500;
|
|
||||||
|
|
||||||
if (watch.ElapsedMilliseconds < delay)
|
|
||||||
Thread.Sleep (delay - (int) watch.ElapsedMilliseconds);
|
|
||||||
|
|
||||||
UpdateChooserEvent (Folders);
|
UpdateChooserEvent (Folders);
|
||||||
UpdateChooserEnablementEvent (true);
|
UpdateChooserEnablementEvent (true);
|
||||||
|
@ -195,16 +179,9 @@ namespace SparkleShare {
|
||||||
ContentLoadingEvent ();
|
ContentLoadingEvent ();
|
||||||
UpdateSizeInfoEvent ("…", "…");
|
UpdateSizeInfoEvent ("…", "…");
|
||||||
|
|
||||||
Stopwatch watch = new Stopwatch ();
|
SparkleDelay delay = new SparkleDelay ();
|
||||||
|
|
||||||
watch.Start ();
|
|
||||||
string html = HTML;
|
string html = HTML;
|
||||||
watch.Stop ();
|
delay.Stop ();
|
||||||
|
|
||||||
int delay = 500;
|
|
||||||
|
|
||||||
if (watch.ElapsedMilliseconds < delay)
|
|
||||||
Thread.Sleep (delay - (int) watch.ElapsedMilliseconds);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty (html))
|
if (!string.IsNullOrEmpty (html))
|
||||||
UpdateContentEvent (html);
|
UpdateContentEvent (html);
|
||||||
|
@ -287,17 +264,10 @@ namespace SparkleShare {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
new Thread (() => {
|
new Thread (() => {
|
||||||
Stopwatch watch = new Stopwatch ();
|
SparkleDelay delay = new SparkleDelay ();
|
||||||
watch.Start ();
|
|
||||||
|
|
||||||
List<SparkleChangeSet> change_sets = repo.GetChangeSets (file_path);
|
List<SparkleChangeSet> change_sets = repo.GetChangeSets (file_path);
|
||||||
string html = GetHistoryHTMLLog (change_sets, file_path);
|
string html = GetHistoryHTMLLog (change_sets, file_path);
|
||||||
|
delay.Stop ();
|
||||||
watch.Stop ();
|
|
||||||
int delay = 500;
|
|
||||||
|
|
||||||
if (watch.ElapsedMilliseconds < delay)
|
|
||||||
Thread.Sleep (delay - (int) watch.ElapsedMilliseconds);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty (html))
|
if (!string.IsNullOrEmpty (html))
|
||||||
UpdateContentEvent (html);
|
UpdateContentEvent (html);
|
||||||
|
@ -627,5 +597,23 @@ namespace SparkleShare {
|
||||||
public string FilePath;
|
public string FilePath;
|
||||||
public string Revision;
|
public string Revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class SparkleDelay : Stopwatch {
|
||||||
|
|
||||||
|
public SparkleDelay () : base ()
|
||||||
|
{
|
||||||
|
Start ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
new public void Stop ()
|
||||||
|
{
|
||||||
|
base.Stop ();
|
||||||
|
|
||||||
|
if (ElapsedMilliseconds < 500)
|
||||||
|
Thread.Sleep (500 - (int) ElapsedMilliseconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue