setup: code cleanup
This commit is contained in:
parent
4c6ffeac87
commit
f4c59a6426
|
@ -25,6 +25,8 @@ using MonoMac.AppKit;
|
|||
using MonoMac.ObjCRuntime;
|
||||
using MonoMac.WebKit;
|
||||
|
||||
using Mono.Unix;
|
||||
|
||||
namespace SparkleShare {
|
||||
|
||||
public class SparkleSetup : SparkleSetupWindow {
|
||||
|
@ -86,12 +88,20 @@ namespace SparkleShare {
|
|||
{
|
||||
InvokeOnMainThread (delegate {
|
||||
Reset ();
|
||||
ShowPage (type, warnings);
|
||||
ShowAll ();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case PageType.Setup: {
|
||||
|
||||
public void ShowPage (PageType type, string [] warnings)
|
||||
{
|
||||
if (type == PageType.Setup) {
|
||||
Header = "Welcome to SparkleShare!";
|
||||
Description = "First off, what's your name and email?\nThis information is only visible to team members.";
|
||||
Description = "First off, what's your name and email?\n(visible only to team members)";
|
||||
|
||||
|
||||
FullNameLabel = new NSTextField () {
|
||||
Alignment = NSTextAlignment.Right,
|
||||
|
@ -105,7 +115,7 @@ namespace SparkleShare {
|
|||
|
||||
FullNameTextField = new NSTextField () {
|
||||
Frame = new RectangleF (330, Frame.Height - 238, 196, 22),
|
||||
StringValue = Controller.GuessedUserName,
|
||||
StringValue = UnixUserInfo.GetRealUser ().RealName,
|
||||
Delegate = new SparkleTextFieldDelegate ()
|
||||
};
|
||||
|
||||
|
@ -121,31 +131,27 @@ namespace SparkleShare {
|
|||
|
||||
EmailTextField = new NSTextField () {
|
||||
Frame = new RectangleF (330, Frame.Height - 268, 196, 22),
|
||||
StringValue = Controller.GuessedUserEmail,
|
||||
Delegate = new SparkleTextFieldDelegate ()
|
||||
};
|
||||
|
||||
|
||||
(FullNameTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
Controller.CheckSetupPage (
|
||||
FullNameTextField.StringValue,
|
||||
EmailTextField.StringValue
|
||||
);
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
(EmailTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
Controller.CheckSetupPage (
|
||||
FullNameTextField.StringValue,
|
||||
EmailTextField.StringValue
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
ContinueButton = new NSButton () {
|
||||
Title = "Continue",
|
||||
Enabled = false
|
||||
};
|
||||
|
||||
|
||||
(FullNameTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
Controller.CheckSetupPage (FullNameTextField.StringValue, EmailTextField.StringValue);
|
||||
};
|
||||
|
||||
(EmailTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
Controller.CheckSetupPage (FullNameTextField.StringValue, EmailTextField.StringValue);
|
||||
};
|
||||
|
||||
ContinueButton.Activated += delegate {
|
||||
string full_name = FullNameTextField.StringValue.Trim ();
|
||||
string email = EmailTextField.StringValue.Trim ();
|
||||
|
@ -153,15 +159,10 @@ namespace SparkleShare {
|
|||
Controller.SetupPageCompleted (full_name, email);
|
||||
};
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.SetupPageCancelled ();
|
||||
};
|
||||
|
||||
|
||||
Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) {
|
||||
InvokeOnMainThread (delegate {
|
||||
ContinueButton.Enabled = button_enabled;
|
||||
|
@ -177,16 +178,10 @@ namespace SparkleShare {
|
|||
Buttons.Add (ContinueButton);
|
||||
Buttons.Add (CancelButton);
|
||||
|
||||
Controller.CheckSetupPage (
|
||||
FullNameTextField.StringValue,
|
||||
EmailTextField.StringValue
|
||||
);
|
||||
|
||||
break;
|
||||
Controller.CheckSetupPage (FullNameTextField.StringValue, EmailTextField.StringValue);
|
||||
}
|
||||
|
||||
case PageType.Invite: {
|
||||
|
||||
if (type == PageType.Invite) {
|
||||
Header = "You've received an invite!";
|
||||
Description = "Do you want to add this project to SparkleShare?";
|
||||
|
||||
|
@ -231,40 +226,38 @@ namespace SparkleShare {
|
|||
Font = SparkleUI.BoldFont
|
||||
};
|
||||
|
||||
|
||||
ContentView.AddSubview (AddressLabel);
|
||||
ContentView.AddSubview (PathLabel);
|
||||
ContentView.AddSubview (AddressTextField);
|
||||
ContentView.AddSubview (PathTextField);
|
||||
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.PageCancelled ();
|
||||
};
|
||||
|
||||
AddButton = new NSButton () {
|
||||
Title = "Add"
|
||||
};
|
||||
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.PageCancelled ();
|
||||
};
|
||||
|
||||
AddButton.Activated += delegate {
|
||||
Controller.InvitePageCompleted ();
|
||||
};
|
||||
|
||||
|
||||
ContentView.AddSubview (AddressLabel);
|
||||
ContentView.AddSubview (PathLabel);
|
||||
ContentView.AddSubview (AddressTextField);
|
||||
ContentView.AddSubview (PathTextField);
|
||||
|
||||
Buttons.Add (AddButton);
|
||||
Buttons.Add (CancelButton);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PageType.Add: {
|
||||
|
||||
if (type == PageType.Add) {
|
||||
Header = "Where's your project hosted?";
|
||||
Description = "";
|
||||
|
||||
|
||||
AddressLabel = new NSTextField () {
|
||||
Alignment = NSTextAlignment.Left,
|
||||
BackgroundColor = NSColor.WindowBackground,
|
||||
|
@ -279,11 +272,11 @@ namespace SparkleShare {
|
|||
Frame = new RectangleF (190, Frame.Height - 336, 196, 22),
|
||||
Font = SparkleUI.Font,
|
||||
Enabled = (Controller.SelectedPlugin.Address == null),
|
||||
Delegate = new SparkleTextFieldDelegate ()
|
||||
Delegate = new SparkleTextFieldDelegate (),
|
||||
StringValue = "" + Controller.PreviousAddress
|
||||
};
|
||||
|
||||
if (Controller.PreviousAddress != null)
|
||||
AddressTextField.StringValue = Controller.PreviousAddress;
|
||||
AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
|
||||
|
||||
PathLabel = new NSTextField () {
|
||||
Alignment = NSTextAlignment.Left,
|
||||
|
@ -298,43 +291,34 @@ namespace SparkleShare {
|
|||
PathTextField = new NSTextField () {
|
||||
Frame = new RectangleF (190 + 196 + 16, Frame.Height - 336, 196, 22),
|
||||
Enabled = (Controller.SelectedPlugin.Path == null),
|
||||
Delegate = new SparkleTextFieldDelegate ()
|
||||
Delegate = new SparkleTextFieldDelegate (),
|
||||
StringValue = "" + Controller.PreviousPath
|
||||
};
|
||||
|
||||
if (Controller.PreviousPath != null)
|
||||
PathTextField.StringValue = Controller.PreviousPath;
|
||||
|
||||
AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
|
||||
PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
|
||||
|
||||
|
||||
PathHelpLabel = new NSTextField () {
|
||||
BackgroundColor = NSColor.WindowBackground,
|
||||
Bordered = false,
|
||||
TextColor = NSColor.DisabledControlText,
|
||||
Editable = false,
|
||||
Frame = new RectangleF (190 + 196 + 16, Frame.Height - 355, 204, 17),
|
||||
Font = NSFontManager.SharedFontManager.FontWithFamily
|
||||
("Lucida Grande", NSFontTraitMask.Condensed, 0, 11)
|
||||
Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande",
|
||||
NSFontTraitMask.Condensed, 0, 11),
|
||||
StringValue = "" + Controller.SelectedPlugin.PathExample
|
||||
};
|
||||
|
||||
if (Controller.SelectedPlugin.PathExample != null)
|
||||
PathHelpLabel.StringValue = Controller.SelectedPlugin.PathExample;
|
||||
|
||||
AddressHelpLabel = new NSTextField () {
|
||||
BackgroundColor = NSColor.WindowBackground,
|
||||
Bordered = false,
|
||||
TextColor = NSColor.DisabledControlText,
|
||||
Editable = false,
|
||||
Frame = new RectangleF (190, Frame.Height - 355, 204, 17),
|
||||
Font = NSFontManager.SharedFontManager.FontWithFamily
|
||||
("Lucida Grande", NSFontTraitMask.Condensed, 0, 11)
|
||||
Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande",
|
||||
NSFontTraitMask.Condensed, 0, 11),
|
||||
StringValue = "" + Controller.SelectedPlugin.AddressExample
|
||||
};
|
||||
|
||||
if (Controller.SelectedPlugin.AddressExample != null)
|
||||
AddressHelpLabel.StringValue = Controller.SelectedPlugin.AddressExample;
|
||||
|
||||
|
||||
TableView = new NSTableView () {
|
||||
Frame = new RectangleF (0, 0, 0, 0),
|
||||
RowHeight = 34,
|
||||
|
@ -364,9 +348,8 @@ namespace SparkleShare {
|
|||
Editable = false
|
||||
};
|
||||
|
||||
DescriptionColumn.DataCell.Font =
|
||||
NSFontManager.SharedFontManager.FontWithFamily (
|
||||
"Lucida Grande", NSFontTraitMask.Condensed, 0, 11);
|
||||
DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande",
|
||||
NSFontTraitMask.Condensed, 0, 11);
|
||||
|
||||
TableView.AddColumn (IconColumn);
|
||||
TableView.AddColumn (DescriptionColumn);
|
||||
|
@ -376,8 +359,6 @@ namespace SparkleShare {
|
|||
TableView.DataSource = DataSource;
|
||||
TableView.ReloadData ();
|
||||
|
||||
|
||||
|
||||
HistoryCheckButton = new NSButton () {
|
||||
Frame = new RectangleF (190, Frame.Height - 400, 300, 18),
|
||||
Title = "Fetch prior revisions"
|
||||
|
@ -388,13 +369,14 @@ namespace SparkleShare {
|
|||
|
||||
HistoryCheckButton.SetButtonType (NSButtonType.Switch);
|
||||
|
||||
HistoryCheckButton.Activated += delegate {
|
||||
Controller.HistoryItemChanged (HistoryCheckButton.State == NSCellStateValue.On);
|
||||
AddButton = new NSButton () {
|
||||
Title = "Add",
|
||||
Enabled = false
|
||||
};
|
||||
|
||||
|
||||
|
||||
ContentView.AddSubview (HistoryCheckButton);
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
|
||||
Controller.ChangeAddressFieldEvent += delegate (string text,
|
||||
|
@ -407,7 +389,6 @@ namespace SparkleShare {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
Controller.ChangePathFieldEvent += delegate (string text,
|
||||
string example_text, FieldState state) {
|
||||
|
||||
|
@ -418,36 +399,33 @@ namespace SparkleShare {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
TableView.SelectRow (Controller.SelectedPluginIndex, false);
|
||||
TableView.ScrollRowToVisible (Controller.SelectedPluginIndex);
|
||||
|
||||
(AddressTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
Controller.CheckAddPage (
|
||||
AddressTextField.StringValue,
|
||||
PathTextField.StringValue,
|
||||
TableView.SelectedRow
|
||||
);
|
||||
Controller.CheckAddPage (AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
|
||||
};
|
||||
|
||||
(PathTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
Controller.CheckAddPage (
|
||||
AddressTextField.StringValue,
|
||||
PathTextField.StringValue,
|
||||
TableView.SelectedRow
|
||||
);
|
||||
Controller.CheckAddPage (AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
|
||||
};
|
||||
|
||||
(TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate {
|
||||
Controller.SelectedPluginChanged (TableView.SelectedRow);
|
||||
|
||||
Controller.CheckAddPage (
|
||||
AddressTextField.StringValue,
|
||||
PathTextField.StringValue,
|
||||
TableView.SelectedRow
|
||||
);
|
||||
Controller.CheckAddPage (AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
|
||||
};
|
||||
|
||||
HistoryCheckButton.Activated += delegate {
|
||||
Controller.HistoryItemChanged (HistoryCheckButton.State == NSCellStateValue.On);
|
||||
};
|
||||
|
||||
AddButton.Activated += delegate {
|
||||
Controller.AddPageCompleted (AddressTextField.StringValue, PathTextField.StringValue);
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.PageCancelled ();
|
||||
};
|
||||
|
||||
Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) {
|
||||
InvokeOnMainThread (delegate {
|
||||
|
@ -463,44 +441,18 @@ namespace SparkleShare {
|
|||
ContentView.AddSubview (PathLabel);
|
||||
ContentView.AddSubview (PathTextField);
|
||||
ContentView.AddSubview (PathHelpLabel);
|
||||
|
||||
AddButton = new NSButton () {
|
||||
Title = "Add",
|
||||
Enabled = false
|
||||
};
|
||||
|
||||
AddButton.Activated += delegate {
|
||||
Controller.AddPageCompleted (
|
||||
AddressTextField.StringValue,
|
||||
PathTextField.StringValue
|
||||
);
|
||||
};
|
||||
ContentView.AddSubview (HistoryCheckButton);
|
||||
|
||||
Buttons.Add (AddButton);
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.PageCancelled ();
|
||||
};
|
||||
|
||||
Buttons.Add (CancelButton);
|
||||
|
||||
Controller.CheckAddPage (
|
||||
AddressTextField.StringValue,
|
||||
PathTextField.StringValue,
|
||||
TableView.SelectedRow
|
||||
);
|
||||
|
||||
|
||||
break;
|
||||
Controller.CheckAddPage (AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
|
||||
}
|
||||
|
||||
case PageType.Syncing: {
|
||||
if (type == PageType.Syncing) {
|
||||
Header = "Adding project ‘" + Controller.SyncingFolder + "’…";
|
||||
Description = "This may either take a short or a long time depending on the project's size.";
|
||||
Description = "This may take a while on big projects. Isn't it coffee-o'clock?";
|
||||
|
||||
|
||||
ProgressIndicator = new NSProgressIndicator () {
|
||||
Frame = new RectangleF (190, Frame.Height - 200, 640 - 150 - 80, 20),
|
||||
|
@ -513,38 +465,38 @@ namespace SparkleShare {
|
|||
|
||||
ProgressIndicator.StartAnimation (this);
|
||||
|
||||
Controller.UpdateProgressBarEvent += delegate (double percentage) {
|
||||
InvokeOnMainThread (delegate {
|
||||
ProgressIndicator.DoubleValue = percentage;
|
||||
});
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
ContentView.AddSubview (ProgressIndicator);
|
||||
|
||||
FinishButton = new NSButton () {
|
||||
Title = "Finish",
|
||||
Enabled = false
|
||||
};
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
|
||||
Controller.UpdateProgressBarEvent += delegate (double percentage) {
|
||||
InvokeOnMainThread (() => {
|
||||
ProgressIndicator.DoubleValue = percentage;
|
||||
});
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.SyncingCancelled ();
|
||||
};
|
||||
|
||||
|
||||
ContentView.AddSubview (ProgressIndicator);
|
||||
|
||||
Buttons.Add (FinishButton);
|
||||
Buttons.Add (CancelButton);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PageType.Error: {
|
||||
|
||||
if (type == PageType.Error) {
|
||||
Header = "Oops! Something went wrong…";
|
||||
Description = "Please check the following:";
|
||||
|
||||
|
||||
// Displaying marked up text with Cocoa is
|
||||
// a pain, so we just use a webview instead
|
||||
WebView web_view = new WebView ();
|
||||
|
@ -587,33 +539,31 @@ namespace SparkleShare {
|
|||
web_view.MainFrame.LoadHtmlString (html, new NSUrl (""));
|
||||
web_view.DrawsBackground = false;
|
||||
|
||||
ContentView.AddSubview (web_view);
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
TryAgainButton = new NSButton () {
|
||||
Title = "Try again…"
|
||||
};
|
||||
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.PageCancelled ();
|
||||
};
|
||||
|
||||
TryAgainButton.Activated += delegate {
|
||||
Controller.ErrorPageCompleted ();
|
||||
};
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.PageCancelled ();
|
||||
};
|
||||
ContentView.AddSubview (web_view);
|
||||
|
||||
Buttons.Add (TryAgainButton);
|
||||
Buttons.Add (CancelButton);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case PageType.CryptoSetup: {
|
||||
|
||||
if (type == PageType.CryptoSetup) {
|
||||
Header = "Set up file encryption";
|
||||
Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below:";
|
||||
|
||||
|
@ -638,7 +588,6 @@ namespace SparkleShare {
|
|||
Delegate = new SparkleTextFieldDelegate ()
|
||||
};
|
||||
|
||||
|
||||
ShowPasswordCheckButton = new NSButton () {
|
||||
Frame = new RectangleF (318, Frame.Height - 235, 300, 18),
|
||||
Title = "Show password",
|
||||
|
@ -647,54 +596,6 @@ namespace SparkleShare {
|
|||
|
||||
ShowPasswordCheckButton.SetButtonType (NSButtonType.Switch);
|
||||
|
||||
ShowPasswordCheckButton.Activated += delegate {
|
||||
if (PasswordTextField.Superview == ContentView) {
|
||||
PasswordTextField.RemoveFromSuperview ();
|
||||
ContentView.AddSubview (VisiblePasswordTextField);
|
||||
|
||||
} else {
|
||||
VisiblePasswordTextField.RemoveFromSuperview ();
|
||||
ContentView.AddSubview (PasswordTextField);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
(PasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
VisiblePasswordTextField.StringValue = PasswordTextField.StringValue;
|
||||
Controller.CheckCryptoSetupPage (PasswordTextField.StringValue);
|
||||
};
|
||||
|
||||
(VisiblePasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
PasswordTextField.StringValue = VisiblePasswordTextField.StringValue;
|
||||
Controller.CheckCryptoSetupPage (PasswordTextField.StringValue);
|
||||
};
|
||||
|
||||
|
||||
ContinueButton = new NSButton () {
|
||||
Title = "Continue",
|
||||
Enabled = false
|
||||
};
|
||||
|
||||
ContinueButton.Activated += delegate {
|
||||
Controller.CryptoSetupPageCompleted (PasswordTextField.StringValue);
|
||||
};
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.CryptoPageCancelled ();
|
||||
};
|
||||
|
||||
|
||||
Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
|
||||
InvokeOnMainThread (delegate {
|
||||
ContinueButton.Enabled = button_enabled;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
WarningImage = NSImage.ImageNamed ("NSInfo");
|
||||
WarningImage.Size = new SizeF (24, 24);
|
||||
|
||||
|
@ -712,6 +613,52 @@ namespace SparkleShare {
|
|||
Font = SparkleUI.Font
|
||||
};
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
ContinueButton = new NSButton () {
|
||||
Title = "Continue",
|
||||
Enabled = false
|
||||
};
|
||||
|
||||
|
||||
ShowPasswordCheckButton.Activated += delegate {
|
||||
if (PasswordTextField.Superview == ContentView) {
|
||||
PasswordTextField.RemoveFromSuperview ();
|
||||
ContentView.AddSubview (VisiblePasswordTextField);
|
||||
|
||||
} else {
|
||||
VisiblePasswordTextField.RemoveFromSuperview ();
|
||||
ContentView.AddSubview (PasswordTextField);
|
||||
}
|
||||
};
|
||||
|
||||
(PasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
VisiblePasswordTextField.StringValue = PasswordTextField.StringValue;
|
||||
Controller.CheckCryptoSetupPage (PasswordTextField.StringValue);
|
||||
};
|
||||
|
||||
(VisiblePasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
PasswordTextField.StringValue = VisiblePasswordTextField.StringValue;
|
||||
Controller.CheckCryptoSetupPage (PasswordTextField.StringValue);
|
||||
};
|
||||
|
||||
|
||||
Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
|
||||
InvokeOnMainThread (() => {
|
||||
ContinueButton.Enabled = button_enabled;
|
||||
});
|
||||
};
|
||||
|
||||
ContinueButton.Activated += delegate {
|
||||
Controller.CryptoSetupPageCompleted (PasswordTextField.StringValue);
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.CryptoPageCancelled ();
|
||||
};
|
||||
|
||||
|
||||
ContentView.AddSubview (PasswordLabel);
|
||||
ContentView.AddSubview (PasswordTextField);
|
||||
|
@ -722,19 +669,13 @@ namespace SparkleShare {
|
|||
Buttons.Add (ContinueButton);
|
||||
Buttons.Add (CancelButton);
|
||||
|
||||
NSApplication.SharedApplication.RequestUserAttention
|
||||
(NSRequestUserAttentionType.CriticalRequest);
|
||||
|
||||
break;
|
||||
NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest);
|
||||
}
|
||||
|
||||
|
||||
case PageType.CryptoPassword: {
|
||||
|
||||
if (type == PageType.CryptoPassword) {
|
||||
Header = "This project contains encrypted files";
|
||||
Description = "Please enter the password to see their contents.";
|
||||
|
||||
|
||||
PasswordLabel = new NSTextField () {
|
||||
Alignment = NSTextAlignment.Right,
|
||||
BackgroundColor = NSColor.WindowBackground,
|
||||
|
@ -755,7 +696,6 @@ namespace SparkleShare {
|
|||
Delegate = new SparkleTextFieldDelegate ()
|
||||
};
|
||||
|
||||
|
||||
ShowPasswordCheckButton = new NSButton () {
|
||||
Frame = new RectangleF (318, Frame.Height - 255, 300, 18),
|
||||
Title = "Show password",
|
||||
|
@ -764,6 +704,22 @@ namespace SparkleShare {
|
|||
|
||||
ShowPasswordCheckButton.SetButtonType (NSButtonType.Switch);
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
ContinueButton = new NSButton () {
|
||||
Title = "Continue",
|
||||
Enabled = false
|
||||
};
|
||||
|
||||
|
||||
Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) {
|
||||
InvokeOnMainThread (() => {
|
||||
ContinueButton.Enabled = button_enabled;
|
||||
});
|
||||
};
|
||||
|
||||
ShowPasswordCheckButton.Activated += delegate {
|
||||
if (PasswordTextField.Superview == ContentView) {
|
||||
PasswordTextField.RemoveFromSuperview ();
|
||||
|
@ -775,7 +731,6 @@ namespace SparkleShare {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
(PasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
|
||||
VisiblePasswordTextField.StringValue = PasswordTextField.StringValue;
|
||||
Controller.CheckCryptoPasswordPage (PasswordTextField.StringValue);
|
||||
|
@ -786,32 +741,15 @@ namespace SparkleShare {
|
|||
Controller.CheckCryptoPasswordPage (PasswordTextField.StringValue);
|
||||
};
|
||||
|
||||
|
||||
ContinueButton = new NSButton () {
|
||||
Title = "Continue",
|
||||
Enabled = false
|
||||
};
|
||||
|
||||
ContinueButton.Activated += delegate {
|
||||
Controller.CryptoPasswordPageCompleted (PasswordTextField.StringValue);
|
||||
};
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
Controller.CryptoPageCancelled ();
|
||||
};
|
||||
|
||||
|
||||
Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) {
|
||||
InvokeOnMainThread (delegate {
|
||||
ContinueButton.Enabled = button_enabled;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
ContentView.AddSubview (PasswordLabel);
|
||||
ContentView.AddSubview (PasswordTextField);
|
||||
ContentView.AddSubview (ShowPasswordCheckButton);
|
||||
|
@ -819,18 +757,15 @@ namespace SparkleShare {
|
|||
Buttons.Add (ContinueButton);
|
||||
Buttons.Add (CancelButton);
|
||||
|
||||
NSApplication.SharedApplication.RequestUserAttention
|
||||
(NSRequestUserAttentionType.CriticalRequest);
|
||||
|
||||
break;
|
||||
NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest);
|
||||
}
|
||||
|
||||
|
||||
case PageType.Finished: {
|
||||
|
||||
if (type == PageType.Finished) {
|
||||
Header = "Your shared project is ready!";
|
||||
Description = "You can find the files in your SparkleShare folder.";
|
||||
|
||||
|
||||
if (warnings.Length > 0) {
|
||||
WarningImage = NSImage.ImageNamed ("NSInfo");
|
||||
WarningImage.Size = new SizeF (24, 24);
|
||||
|
@ -853,57 +788,34 @@ namespace SparkleShare {
|
|||
ContentView.AddSubview (WarningTextField);
|
||||
}
|
||||
|
||||
|
||||
OpenFolderButton = new NSButton () {
|
||||
Title = string.Format ("Open {0}", Path.GetFileName (Controller.PreviousPath))
|
||||
};
|
||||
|
||||
FinishButton = new NSButton () {
|
||||
Title = "Finish"
|
||||
};
|
||||
|
||||
|
||||
OpenFolderButton.Activated += delegate {
|
||||
Controller.OpenFolderClicked ();
|
||||
};
|
||||
|
||||
FinishButton.Activated += delegate {
|
||||
Controller.FinishPageCompleted ();
|
||||
};
|
||||
|
||||
OpenFolderButton = new NSButton () {
|
||||
Title = string.Format ("Open {0}", Path.GetFileName (Controller.PreviousPath))
|
||||
};
|
||||
|
||||
OpenFolderButton.Activated += delegate {
|
||||
Controller.OpenFolderClicked ();
|
||||
};
|
||||
|
||||
Buttons.Add (FinishButton);
|
||||
Buttons.Add (OpenFolderButton);
|
||||
|
||||
NSApplication.SharedApplication.RequestUserAttention
|
||||
(NSRequestUserAttentionType.CriticalRequest);
|
||||
|
||||
break;
|
||||
NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest);
|
||||
}
|
||||
|
||||
case PageType.Tutorial: {
|
||||
|
||||
switch (Controller.TutorialPageNumber) {
|
||||
case 1: {
|
||||
Header = "What's happening next?";
|
||||
Description = "SparkleShare creates a special folder on your computer " +
|
||||
"that will keep track of your projects.";
|
||||
|
||||
SkipTutorialButton = new NSButton () {
|
||||
Title = "Skip Tutorial"
|
||||
};
|
||||
|
||||
SkipTutorialButton.Activated += delegate {
|
||||
Controller.TutorialSkipped ();
|
||||
};
|
||||
|
||||
ContinueButton = new NSButton () {
|
||||
Title = "Continue"
|
||||
};
|
||||
|
||||
ContinueButton.Activated += delegate {
|
||||
Controller.TutorialPageCompleted ();
|
||||
};
|
||||
|
||||
if (type == PageType.Tutorial) {
|
||||
string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||
"Pixmaps", "tutorial-slide-1.png");
|
||||
"Pixmaps", "tutorial-slide-" + Controller.TutorialPageNumber + ".png");
|
||||
|
||||
SlideImage = new NSImage (slide_image_path) {
|
||||
Size = new SizeF (350, 200)
|
||||
|
@ -915,6 +827,36 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
ContentView.AddSubview (SlideImageView);
|
||||
|
||||
|
||||
switch (Controller.TutorialPageNumber) {
|
||||
|
||||
case 1: {
|
||||
Header = "What's happening next?";
|
||||
Description = "SparkleShare creates a special folder on your computer " +
|
||||
"that will keep track of your projects.";
|
||||
|
||||
|
||||
SkipTutorialButton = new NSButton () {
|
||||
Title = "Skip Tutorial"
|
||||
};
|
||||
|
||||
ContinueButton = new NSButton () {
|
||||
Title = "Continue"
|
||||
};
|
||||
|
||||
|
||||
SkipTutorialButton.Activated += delegate {
|
||||
Controller.TutorialSkipped ();
|
||||
};
|
||||
|
||||
ContinueButton.Activated += delegate {
|
||||
Controller.TutorialPageCompleted ();
|
||||
};
|
||||
|
||||
|
||||
ContentView.AddSubview (SlideImageView);
|
||||
|
||||
Buttons.Add (ContinueButton);
|
||||
Buttons.Add (SkipTutorialButton);
|
||||
|
||||
|
@ -934,19 +876,6 @@ namespace SparkleShare {
|
|||
Controller.TutorialPageCompleted ();
|
||||
};
|
||||
|
||||
string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||
"Pixmaps", "tutorial-slide-2.png");
|
||||
|
||||
SlideImage = new NSImage (slide_image_path) {
|
||||
Size = new SizeF (350, 200)
|
||||
};
|
||||
|
||||
SlideImageView = new NSImageView () {
|
||||
Image = SlideImage,
|
||||
Frame = new RectangleF (215, Frame.Height - 350, 350, 200)
|
||||
};
|
||||
|
||||
ContentView.AddSubview (SlideImageView);
|
||||
Buttons.Add (ContinueButton);
|
||||
|
||||
break;
|
||||
|
@ -965,19 +894,6 @@ namespace SparkleShare {
|
|||
Controller.TutorialPageCompleted ();
|
||||
};
|
||||
|
||||
string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||
"Pixmaps", "tutorial-slide-3.png");
|
||||
|
||||
SlideImage = new NSImage (slide_image_path) {
|
||||
Size = new SizeF (350, 200)
|
||||
};
|
||||
|
||||
SlideImageView = new NSImageView () {
|
||||
Image = SlideImage,
|
||||
Frame = new RectangleF (215, Frame.Height - 350, 350, 200)
|
||||
};
|
||||
|
||||
ContentView.AddSubview (SlideImageView);
|
||||
Buttons.Add (ContinueButton);
|
||||
|
||||
break;
|
||||
|
@ -997,49 +913,30 @@ namespace SparkleShare {
|
|||
|
||||
StartupCheckButton.SetButtonType (NSButtonType.Switch);
|
||||
|
||||
StartupCheckButton.Activated += delegate {
|
||||
Controller.StartupItemChanged (StartupCheckButton.State == NSCellStateValue.On);
|
||||
};
|
||||
|
||||
FinishButton = new NSButton () {
|
||||
Title = "Finish"
|
||||
};
|
||||
|
||||
SlideImage.Size = new SizeF (350, 64);
|
||||
|
||||
|
||||
StartupCheckButton.Activated += delegate {
|
||||
Controller.StartupItemChanged (StartupCheckButton.State == NSCellStateValue.On);
|
||||
};
|
||||
|
||||
FinishButton.Activated += delegate {
|
||||
Controller.TutorialPageCompleted ();
|
||||
};
|
||||
|
||||
|
||||
string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||
"Pixmaps", "tutorial-slide-4.png");
|
||||
|
||||
SlideImage = new NSImage (slide_image_path) {
|
||||
Size = new SizeF (350, 64)
|
||||
};
|
||||
|
||||
SlideImageView = new NSImageView () {
|
||||
Image = SlideImage,
|
||||
Frame = new RectangleF (215, Frame.Height - 215, 350, 64)
|
||||
};
|
||||
|
||||
|
||||
ContentView.AddSubview (SlideImageView);
|
||||
ContentView.AddSubview (StartupCheckButton);
|
||||
Buttons.Add (FinishButton);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ShowAll ();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1061,11 +958,9 @@ namespace SparkleShare {
|
|||
foreach (SparklePlugin plugin in plugins) {
|
||||
Items.Add (plugin);
|
||||
|
||||
|
||||
NSTextFieldCell cell = new NSTextFieldCell ();
|
||||
|
||||
NSData name_data = NSData.FromString (
|
||||
"<font face='Lucida Grande'><b>" + plugin.Name + "</b></font>");
|
||||
NSData name_data = NSData.FromString ("<font face='Lucida Grande'><b>" + plugin.Name + "</b></font>");
|
||||
|
||||
NSDictionary name_dictionary = new NSDictionary();
|
||||
NSAttributedString name_attributes = new NSAttributedString (
|
||||
|
@ -1085,7 +980,6 @@ namespace SparkleShare {
|
|||
cell.AttributedStringValue = mutable_attributes;
|
||||
Cells [i] = (NSAttributedString) cell.ObjectValue;
|
||||
|
||||
|
||||
NSTextFieldCell selected_cell = new NSTextFieldCell ();
|
||||
|
||||
NSData selected_name_data = NSData.FromString (
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="MonoMac" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="Mono.Posix" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppDelegate.cs">
|
||||
|
|
Loading…
Reference in a new issue