mac: remove a lot of boilerplate
This commit is contained in:
parent
3be9fb80ba
commit
5f6c00f773
|
@ -44,8 +44,6 @@ namespace SparkleShare {
|
||||||
public SparkleAbout (IntPtr handle) : base (handle) { }
|
public SparkleAbout (IntPtr handle) : base (handle) { }
|
||||||
|
|
||||||
public SparkleAbout () : base ()
|
public SparkleAbout () : base ()
|
||||||
{
|
|
||||||
using (var a = new NSAutoreleasePool ())
|
|
||||||
{
|
{
|
||||||
SetFrame (new RectangleF (0, 0, 640, 281), true);
|
SetFrame (new RectangleF (0, 0, 640, 281), true);
|
||||||
Center ();
|
Center ();
|
||||||
|
@ -95,58 +93,36 @@ namespace SparkleShare {
|
||||||
ContentView.AddSubview (this.credits_link);
|
ContentView.AddSubview (this.credits_link);
|
||||||
ContentView.AddSubview (this.report_problem_link);
|
ContentView.AddSubview (this.report_problem_link);
|
||||||
ContentView.AddSubview (this.debug_log_link);
|
ContentView.AddSubview (this.debug_log_link);
|
||||||
}
|
|
||||||
|
|
||||||
Controller.HideWindowEvent += delegate {
|
Controller.HideWindowEvent += delegate {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => PerformClose (this));
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
PerformClose (this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ShowWindowEvent += delegate {
|
Controller.ShowWindowEvent += delegate {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => OrderFrontRegardless ());
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
OrderFrontRegardless ();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.NewVersionEvent += delegate (string new_version) {
|
Controller.NewVersionEvent += delegate (string new_version) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.updates_text_field.StringValue = "A newer version (" + new_version + ") is available!";
|
this.updates_text_field.StringValue = "A newer version (" + new_version + ") is available!";
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.VersionUpToDateEvent += delegate {
|
Controller.VersionUpToDateEvent += delegate {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.updates_text_field.StringValue = "You are running the latest version.";
|
this.updates_text_field.StringValue = "You are running the latest version.";
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.CheckingForNewVersionEvent += delegate {
|
Controller.CheckingForNewVersionEvent += delegate {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.updates_text_field.StringValue = "Checking for updates...";
|
this.updates_text_field.StringValue = "Checking for updates...";
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void CreateAbout ()
|
private void CreateAbout ()
|
||||||
{
|
|
||||||
using (var a = new NSAutoreleasePool ())
|
|
||||||
{
|
{
|
||||||
string about_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "about.png");
|
string about_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "about.png");
|
||||||
|
|
||||||
|
@ -202,7 +178,6 @@ namespace SparkleShare {
|
||||||
ContentView.AddSubview (this.updates_text_field);
|
ContentView.AddSubview (this.updates_text_field);
|
||||||
ContentView.AddSubview (this.credits_text_field);
|
ContentView.AddSubview (this.credits_text_field);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void OrderFrontRegardless ()
|
public override void OrderFrontRegardless ()
|
||||||
|
|
|
@ -227,5 +227,17 @@ namespace SparkleShare {
|
||||||
return this.event_entry_html;
|
return this.event_entry_html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public delegate void Code ();
|
||||||
|
private NSObject obj = new NSObject ();
|
||||||
|
|
||||||
|
public void Invoke (Code code)
|
||||||
|
{
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
|
{
|
||||||
|
obj.InvokeOnMainThread (() => code ());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
public SparkleEventLog () : base ()
|
public SparkleEventLog () : base ()
|
||||||
{
|
|
||||||
using (var a = new NSAutoreleasePool ())
|
|
||||||
{
|
{
|
||||||
Title = "Recent Changes";
|
Title = "Recent Changes";
|
||||||
Delegate = new SparkleEventsDelegate ();
|
Delegate = new SparkleEventsDelegate ();
|
||||||
|
@ -175,85 +173,57 @@ namespace SparkleShare {
|
||||||
ContentView.AddSubview (this.background);
|
ContentView.AddSubview (this.background);
|
||||||
ContentView.AddSubview (this.hidden_close_button);
|
ContentView.AddSubview (this.hidden_close_button);
|
||||||
|
|
||||||
(Delegate as SparkleEventsDelegate).WindowResized += Relayout;
|
(Delegate as SparkleEventsDelegate).WindowResized += delegate (SizeF new_window_size) {
|
||||||
}
|
Program.Controller.Invoke (() => {
|
||||||
|
Relayout (new_window_size);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Hook up the controller events
|
// Hook up the controller events
|
||||||
Controller.HideWindowEvent += delegate {
|
Controller.HideWindowEvent += delegate {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.progress_indicator.Hidden = true;
|
this.progress_indicator.Hidden = true;
|
||||||
PerformClose (this);
|
PerformClose (this);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ShowWindowEvent += delegate {
|
Controller.ShowWindowEvent += delegate {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => OrderFrontRegardless ());
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
OrderFrontRegardless ();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateChooserEvent += delegate (string [] folders) {
|
Controller.UpdateChooserEvent += delegate (string [] folders) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => UpdateChooser (folders));
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
UpdateChooser (folders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
|
Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => { this.popup_button.Enabled = enabled; });
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.popup_button.Enabled = enabled;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateContentEvent += delegate (string html) {
|
Controller.UpdateContentEvent += delegate (string html) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.progress_indicator.Hidden = true;
|
this.progress_indicator.Hidden = true;
|
||||||
UpdateContent (html);
|
UpdateContent (html);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ContentLoadingEvent += delegate {
|
Controller.ContentLoadingEvent += delegate {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.web_view.RemoveFromSuperview ();
|
this.web_view.RemoveFromSuperview ();
|
||||||
this.progress_indicator.Hidden = false;
|
this.progress_indicator.Hidden = false;
|
||||||
|
|
||||||
this.progress_indicator.StartAnimation (this);
|
this.progress_indicator.StartAnimation (this);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
|
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.size_label_value.StringValue = size;
|
this.size_label_value.StringValue = size;
|
||||||
this.history_label_value.StringValue = history_size;
|
this.history_label_value.StringValue = history_size;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) {
|
Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (() => {
|
|
||||||
// TODO: Make this a sheet
|
|
||||||
NSSavePanel panel = new NSSavePanel () {
|
NSSavePanel panel = new NSSavePanel () {
|
||||||
DirectoryUrl = new NSUrl (target_folder_path, true),
|
DirectoryUrl = new NSUrl (target_folder_path, true),
|
||||||
NameFieldStringValue = file_name,
|
NameFieldStringValue = file_name,
|
||||||
|
@ -263,23 +233,19 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((NSPanelButtonType) panel.RunModal () == NSPanelButtonType.Ok) {
|
if ((NSPanelButtonType) panel.RunModal () == NSPanelButtonType.Ok) {
|
||||||
string target_file_path = Path.Combine (panel.DirectoryUrl.RelativePath,
|
string target_file_path = Path.Combine (panel.DirectoryUrl.RelativePath, panel.NameFieldStringValue);
|
||||||
panel.NameFieldStringValue);
|
|
||||||
|
|
||||||
Controller.SaveDialogCompleted (target_file_path);
|
Controller.SaveDialogCompleted (target_file_path);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Controller.SaveDialogCancelled ();
|
Controller.SaveDialogCancelled ();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Relayout (SizeF new_window_size)
|
public void Relayout (SizeF new_window_size)
|
||||||
{
|
{
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.web_view.Frame = new RectangleF (this.web_view.Frame.Location,
|
this.web_view.Frame = new RectangleF (this.web_view.Frame.Location,
|
||||||
new SizeF (new_window_size.Width, new_window_size.Height - TitlebarHeight - 39));
|
new SizeF (new_window_size.Width, new_window_size.Height - TitlebarHeight - 39));
|
||||||
|
|
||||||
|
@ -319,13 +285,10 @@ namespace SparkleShare {
|
||||||
new PointF (new_window_size.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
|
new PointF (new_window_size.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
|
||||||
this.progress_indicator.Frame.Size
|
this.progress_indicator.Frame.Size
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void UpdateChooser (string [] folders)
|
public void UpdateChooser (string [] folders)
|
||||||
{
|
|
||||||
using (var a = new NSAutoreleasePool ())
|
|
||||||
{
|
{
|
||||||
if (folders == null)
|
if (folders == null)
|
||||||
folders = Controller.Folders;
|
folders = Controller.Folders;
|
||||||
|
@ -352,23 +315,17 @@ namespace SparkleShare {
|
||||||
this.popup_button.AddItems (folders);
|
this.popup_button.AddItems (folders);
|
||||||
|
|
||||||
this.popup_button.Activated += delegate {
|
this.popup_button.Activated += delegate {
|
||||||
using (var b = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
if (this.popup_button.IndexOfSelectedItem == 0)
|
if (this.popup_button.IndexOfSelectedItem == 0)
|
||||||
Controller.SelectedFolder = null;
|
Controller.SelectedFolder = null;
|
||||||
else
|
else
|
||||||
Controller.SelectedFolder = this.popup_button.SelectedItem.Title;
|
Controller.SelectedFolder = this.popup_button.SelectedItem.Title;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void UpdateContent (string html)
|
public void UpdateContent (string html)
|
||||||
{
|
|
||||||
using (var a = new NSAutoreleasePool ())
|
|
||||||
{
|
{
|
||||||
string pixmaps_path = "file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps");
|
string pixmaps_path = "file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps");
|
||||||
|
|
||||||
|
@ -388,8 +345,7 @@ namespace SparkleShare {
|
||||||
html = html.Replace ("<!-- $document-moved-background-image -->", pixmaps_path + "/document-moved-12.png");
|
html = html.Replace ("<!-- $document-moved-background-image -->", pixmaps_path + "/document-moved-12.png");
|
||||||
|
|
||||||
this.web_view = new WebView (new RectangleF (0, 0, 481, 579), "", "") {
|
this.web_view = new WebView (new RectangleF (0, 0, 481, 579), "", "") {
|
||||||
Frame = new RectangleF (new PointF (0, 0),
|
Frame = new RectangleF (new PointF (0, 0), new SizeF (ContentView.Frame.Width, ContentView.Frame.Height - 39))
|
||||||
new SizeF (ContentView.Frame.Width, ContentView.Frame.Height - 39))
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.web_view.MainFrame.LoadHtmlString (html, new NSUrl (""));
|
this.web_view.MainFrame.LoadHtmlString (html, new NSUrl (""));
|
||||||
|
@ -397,8 +353,7 @@ namespace SparkleShare {
|
||||||
this.web_view.PolicyDelegate = new SparkleWebPolicyDelegate ();
|
this.web_view.PolicyDelegate = new SparkleWebPolicyDelegate ();
|
||||||
ContentView.AddSubview (this.web_view);
|
ContentView.AddSubview (this.web_view);
|
||||||
|
|
||||||
(this.web_view.PolicyDelegate as SparkleWebPolicyDelegate).LinkClicked +=
|
(this.web_view.PolicyDelegate as SparkleWebPolicyDelegate).LinkClicked += delegate (string href) {
|
||||||
delegate (string href) {
|
|
||||||
if (href.StartsWith ("file:///"))
|
if (href.StartsWith ("file:///"))
|
||||||
href = href.Substring (7);
|
href = href.Substring (7);
|
||||||
|
|
||||||
|
@ -407,7 +362,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
this.progress_indicator.Hidden = true;
|
this.progress_indicator.Hidden = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void OrderFrontRegardless ()
|
public override void OrderFrontRegardless ()
|
||||||
|
|
|
@ -33,68 +33,43 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public SparkleSetupController Controller = new SparkleSetupController ();
|
public SparkleSetupController Controller = new SparkleSetupController ();
|
||||||
|
|
||||||
private NSButton ContinueButton;
|
private NSButton ContinueButton, AddButton, CopyButton, TryAgainButton, CancelButton,
|
||||||
private NSButton AddButton;
|
SkipTutorialButton, FinishButton, ShowFilesButton;
|
||||||
private NSButton CopyButton;
|
|
||||||
private NSButton TryAgainButton;
|
private NSTextField FullNameTextField, FullNameLabel, EmailLabel, EmailTextField, EmailHelpLabel,
|
||||||
private NSButton CancelButton;
|
LinkCodeTextField, AddressTextField, AddressLabel, AddressHelpLabel, PathTextField, PathLabel,
|
||||||
private NSButton SkipTutorialButton;
|
PathHelpLabel, PasswordTextField, VisiblePasswordTextField, PasswordLabel, WarningTextField;
|
||||||
private NSButton StartupCheckButton;
|
|
||||||
private NSButton HistoryCheckButton;
|
private NSButton StartupCheckButton, HistoryCheckButton, ShowPasswordCheckButton;
|
||||||
private NSButton ShowPasswordCheckButton;
|
|
||||||
private NSButton ShowFilesButton;
|
|
||||||
private NSButton FinishButton;
|
|
||||||
private NSImage SlideImage;
|
|
||||||
private NSImageView SlideImageView;
|
|
||||||
private NSProgressIndicator ProgressIndicator;
|
private NSProgressIndicator ProgressIndicator;
|
||||||
private NSTextField EmailLabel;
|
private NSImage WarningImage, SlideImage;
|
||||||
private NSTextField EmailTextField;
|
private NSImageView WarningImageView, SlideImageView;
|
||||||
private NSTextField EmailHelpLabel;
|
private NSTableColumn IconColumn, DescriptionColumn;
|
||||||
private NSTextField FullNameTextField;
|
|
||||||
private NSTextField FullNameLabel;
|
|
||||||
private NSTextField LinkCodeTextField;
|
|
||||||
private NSTextField AddressTextField;
|
|
||||||
private NSTextField AddressLabel;
|
|
||||||
private NSTextField AddressHelpLabel;
|
|
||||||
private NSTextField PathTextField;
|
|
||||||
private NSTextField PathLabel;
|
|
||||||
private NSTextField PathHelpLabel;
|
|
||||||
private NSTextField PasswordTextField;
|
|
||||||
private NSTextField VisiblePasswordTextField;
|
|
||||||
private NSTextField PasswordLabel;
|
|
||||||
private NSTextField WarningTextField;
|
|
||||||
private NSImage WarningImage;
|
|
||||||
private NSImageView WarningImageView;
|
|
||||||
private NSTableView TableView;
|
private NSTableView TableView;
|
||||||
private NSScrollView ScrollView;
|
private NSScrollView ScrollView;
|
||||||
private NSTableColumn IconColumn;
|
|
||||||
private NSTableColumn DescriptionColumn;
|
|
||||||
private SparkleDataSource DataSource;
|
private SparkleDataSource DataSource;
|
||||||
|
|
||||||
|
|
||||||
public SparkleSetup () : base ()
|
public SparkleSetup () : base ()
|
||||||
{
|
{
|
||||||
Controller.HideWindowEvent += delegate {
|
Controller.HideWindowEvent += delegate {
|
||||||
InvokeOnMainThread (delegate {
|
Program.Controller.Invoke (() => {
|
||||||
PerformClose (this);
|
PerformClose (this);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ShowWindowEvent += delegate {
|
Controller.ShowWindowEvent += delegate {
|
||||||
InvokeOnMainThread (delegate {
|
Program.Controller.Invoke (() => {
|
||||||
OrderFrontRegardless ();
|
OrderFrontRegardless ();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
|
Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
Reset ();
|
Reset ();
|
||||||
ShowPage (type, warnings);
|
ShowPage (type, warnings);
|
||||||
ShowAll ();
|
ShowAll ();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +155,7 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) {
|
Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) {
|
||||||
InvokeOnMainThread (delegate {
|
Program.Controller.Invoke (() => {
|
||||||
ContinueButton.Enabled = button_enabled;
|
ContinueButton.Enabled = button_enabled;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -399,7 +374,7 @@ namespace SparkleShare {
|
||||||
Controller.ChangeAddressFieldEvent += delegate (string text,
|
Controller.ChangeAddressFieldEvent += delegate (string text,
|
||||||
string example_text, FieldState state) {
|
string example_text, FieldState state) {
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
Program.Controller.Invoke (() => {
|
||||||
AddressTextField.StringValue = text;
|
AddressTextField.StringValue = text;
|
||||||
AddressTextField.Enabled = (state == FieldState.Enabled);
|
AddressTextField.Enabled = (state == FieldState.Enabled);
|
||||||
AddressHelpLabel.StringValue = example_text;
|
AddressHelpLabel.StringValue = example_text;
|
||||||
|
@ -409,7 +384,7 @@ namespace SparkleShare {
|
||||||
Controller.ChangePathFieldEvent += delegate (string text,
|
Controller.ChangePathFieldEvent += delegate (string text,
|
||||||
string example_text, FieldState state) {
|
string example_text, FieldState state) {
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
Program.Controller.Invoke (() => {
|
||||||
PathTextField.StringValue = text;
|
PathTextField.StringValue = text;
|
||||||
PathTextField.Enabled = (state == FieldState.Enabled);
|
PathTextField.Enabled = (state == FieldState.Enabled);
|
||||||
PathHelpLabel.StringValue = example_text;
|
PathHelpLabel.StringValue = example_text;
|
||||||
|
@ -445,7 +420,7 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) {
|
Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) {
|
||||||
InvokeOnMainThread (delegate {
|
Program.Controller.Invoke (() => {
|
||||||
AddButton.Enabled = button_enabled;
|
AddButton.Enabled = button_enabled;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -493,7 +468,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
Controller.UpdateProgressBarEvent += delegate (double percentage) {
|
Controller.UpdateProgressBarEvent += delegate (double percentage) {
|
||||||
InvokeOnMainThread (() => {
|
Program.Controller.Invoke (() => {
|
||||||
ProgressIndicator.DoubleValue = percentage;
|
ProgressIndicator.DoubleValue = percentage;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -664,7 +639,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
|
Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
|
||||||
InvokeOnMainThread (() => {
|
Program.Controller.Invoke (() => {
|
||||||
ContinueButton.Enabled = button_enabled;
|
ContinueButton.Enabled = button_enabled;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -733,7 +708,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) {
|
Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) {
|
||||||
InvokeOnMainThread (() => {
|
Program.Controller.Invoke (() => {
|
||||||
ContinueButton.Enabled = button_enabled;
|
ContinueButton.Enabled = button_enabled;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,17 +29,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public SparkleStatusIconController Controller = new SparkleStatusIconController ();
|
public SparkleStatusIconController Controller = new SparkleStatusIconController ();
|
||||||
|
|
||||||
|
private NSStatusItem status_item = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
|
||||||
|
|
||||||
private NSMenu menu;
|
private NSMenu menu;
|
||||||
private NSMenu submenu;
|
private NSMenu submenu;
|
||||||
|
|
||||||
private NSStatusItem status_item = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
|
|
||||||
private NSMenuItem state_item;
|
private NSMenuItem state_item;
|
||||||
private NSMenuItem folder_item;
|
private NSMenuItem folder_item;
|
||||||
|
|
||||||
private NSMenuItem [] folder_menu_items;
|
|
||||||
private NSMenuItem [] error_menu_items;
|
|
||||||
private NSMenuItem [] try_again_menu_items;
|
|
||||||
|
|
||||||
private NSMenuItem add_item;
|
private NSMenuItem add_item;
|
||||||
private NSMenuItem about_item;
|
private NSMenuItem about_item;
|
||||||
private NSMenuItem recent_events_item;
|
private NSMenuItem recent_events_item;
|
||||||
|
@ -61,10 +57,12 @@ namespace SparkleShare {
|
||||||
private NSImage caution_image = NSImage.ImageNamed ("NSCaution");
|
private NSImage caution_image = NSImage.ImageNamed ("NSCaution");
|
||||||
private NSImage sparkleshare_image = NSImage.ImageNamed ("sparkleshare-folder");
|
private NSImage sparkleshare_image = NSImage.ImageNamed ("sparkleshare-folder");
|
||||||
|
|
||||||
|
private NSMenuItem [] folder_menu_items;
|
||||||
|
private NSMenuItem [] error_menu_items;
|
||||||
|
private NSMenuItem [] try_again_menu_items;
|
||||||
|
|
||||||
|
|
||||||
public SparkleStatusIcon () : base ()
|
public SparkleStatusIcon () : base ()
|
||||||
{
|
|
||||||
using (var a = new NSAutoreleasePool ())
|
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -73,13 +71,9 @@ namespace SparkleShare {
|
||||||
this.status_item.AlternateImage.Size = new SizeF (16, 16);
|
this.status_item.AlternateImage.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
CreateMenu ();
|
CreateMenu ();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Controller.UpdateIconEvent += delegate (IconState state) {
|
Controller.UpdateIconEvent += delegate (IconState state) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case IconState.Idle: {
|
case IconState.Idle: {
|
||||||
this.status_item.Image = this.syncing_idle_image;
|
this.status_item.Image = this.syncing_idle_image;
|
||||||
|
@ -111,39 +105,23 @@ namespace SparkleShare {
|
||||||
this.status_item.Image.Size = new SizeF (16, 16);
|
this.status_item.Image.Size = new SizeF (16, 16);
|
||||||
this.status_item.AlternateImage.Size = new SizeF (16, 16);
|
this.status_item.AlternateImage.Size = new SizeF (16, 16);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateStatusItemEvent += delegate (string state_text) {
|
Controller.UpdateStatusItemEvent += delegate (string state_text) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => { this.state_item.Title = state_text; });
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.state_item.Title = state_text;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateMenuEvent += delegate {
|
Controller.UpdateMenuEvent += delegate {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => CreateMenu ());
|
||||||
{
|
|
||||||
InvokeOnMainThread (() => CreateMenu ());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateQuitItemEvent += delegate (bool quit_item_enabled) {
|
Controller.UpdateQuitItemEvent += delegate (bool quit_item_enabled) {
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => { this.quit_item.Enabled = quit_item_enabled; });
|
||||||
{
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
this.quit_item.Enabled = quit_item_enabled;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void CreateMenu ()
|
public void CreateMenu ()
|
||||||
{
|
|
||||||
using (NSAutoreleasePool a = new NSAutoreleasePool ())
|
|
||||||
{
|
{
|
||||||
this.menu = new NSMenu ();
|
this.menu = new NSMenu ();
|
||||||
this.menu.AutoEnablesItems = false;
|
this.menu.AutoEnablesItems = false;
|
||||||
|
@ -262,7 +240,6 @@ namespace SparkleShare {
|
||||||
this.status_item.Menu = this.menu;
|
this.status_item.Menu = this.menu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class SparkleStatusIconMenuDelegate : NSMenuDelegate {
|
public class SparkleStatusIconMenuDelegate : NSMenuDelegate {
|
||||||
|
|
|
@ -42,22 +42,21 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public SparkleUI ()
|
public SparkleUI ()
|
||||||
{
|
{
|
||||||
using (var a = new NSAutoreleasePool ())
|
Program.Controller.Invoke (() => {
|
||||||
{
|
|
||||||
NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed ("sparkleshare-app.icns");
|
|
||||||
|
|
||||||
NSWorkspace.SharedWorkspace.SetIconforFile (NSImage.ImageNamed ("sparkleshare-folder.icns"),
|
NSWorkspace.SharedWorkspace.SetIconforFile (NSImage.ImageNamed ("sparkleshare-folder.icns"),
|
||||||
Program.Controller.FoldersPath, 0);
|
Program.Controller.FoldersPath, 0);
|
||||||
|
|
||||||
|
NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed ("sparkleshare-app.icns");
|
||||||
|
|
||||||
Setup = new SparkleSetup ();
|
Setup = new SparkleSetup ();
|
||||||
EventLog = new SparkleEventLog ();
|
EventLog = new SparkleEventLog ();
|
||||||
About = new SparkleAbout ();
|
About = new SparkleAbout ();
|
||||||
Bubbles = new SparkleBubbles ();
|
Bubbles = new SparkleBubbles ();
|
||||||
StatusIcon = new SparkleStatusIcon ();
|
StatusIcon = new SparkleStatusIcon ();
|
||||||
|
});
|
||||||
|
|
||||||
Program.Controller.UIHasLoaded ();
|
Program.Controller.UIHasLoaded ();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Run ()
|
public void Run ()
|
||||||
|
|
Loading…
Reference in a new issue