[intro] implement more of the wizard
This commit is contained in:
parent
207cbeef13
commit
74c0b2b6e3
|
@ -30,18 +30,25 @@ namespace SparkleShare {
|
||||||
|
|
||||||
private NSButton NextButton;
|
private NSButton NextButton;
|
||||||
private NSButton SyncButton;
|
private NSButton SyncButton;
|
||||||
|
private NSButton TryAgainButton;
|
||||||
|
private NSButton CancelButton;
|
||||||
|
private NSButton SkipButton;
|
||||||
|
private NSButton OpenFolderButton;
|
||||||
|
private NSButton FinishButton;
|
||||||
private NSForm UserInfoForm;
|
private NSForm UserInfoForm;
|
||||||
|
|
||||||
|
private bool ServerFormOnly;
|
||||||
|
|
||||||
|
|
||||||
public SparkleIntro () : base ()
|
public SparkleIntro () : base ()
|
||||||
{
|
{
|
||||||
|
|
||||||
ShowUserForm ();
|
ServerFormOnly = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ShowUserForm ()
|
public void ShowAccountForm ()
|
||||||
{
|
{
|
||||||
|
|
||||||
Reset ();
|
Reset ();
|
||||||
|
@ -56,9 +63,9 @@ namespace SparkleShare {
|
||||||
UserInfoForm.AddEntry ("Email Address:");
|
UserInfoForm.AddEntry ("Email Address:");
|
||||||
UserInfoForm.CellSize = new SizeF (280, 22);
|
UserInfoForm.CellSize = new SizeF (280, 22);
|
||||||
|
|
||||||
string login_name = UnixUserInfo.GetLoginName ();
|
string full_name = new UnixUserInfo (UnixEnvironment.UserName).RealName;
|
||||||
string full_name = new UnixUserInfo (login_name).RealName;
|
|
||||||
UserInfoForm.Cells [0].StringValue = full_name;
|
UserInfoForm.Cells [0].StringValue = full_name;
|
||||||
|
UserInfoForm.Cells [1].StringValue = SparkleShare.Controller.UserEmail;
|
||||||
|
|
||||||
|
|
||||||
NextButton = new NSButton () {
|
NextButton = new NSButton () {
|
||||||
|
@ -70,10 +77,12 @@ namespace SparkleShare {
|
||||||
|
|
||||||
SparkleShare.Controller.UserName = UserInfoForm.Cells [0].StringValue.Trim ();
|
SparkleShare.Controller.UserName = UserInfoForm.Cells [0].StringValue.Trim ();
|
||||||
SparkleShare.Controller.UserEmail = UserInfoForm.Cells [1].StringValue.Trim ();
|
SparkleShare.Controller.UserEmail = UserInfoForm.Cells [1].StringValue.Trim ();
|
||||||
|
|
||||||
SparkleShare.Controller.GenerateKeyPair ();
|
SparkleShare.Controller.GenerateKeyPair ();
|
||||||
|
SparkleShare.Controller.FirstRun = false;
|
||||||
|
|
||||||
|
InvokeOnMainThread (delegate {
|
||||||
ShowServerForm ();
|
ShowServerForm ();
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -109,6 +118,15 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ShowServerForm (bool server_form_only)
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerFormOnly = server_form_only;
|
||||||
|
ShowServerForm ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ShowServerForm ()
|
public void ShowServerForm ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -123,9 +141,123 @@ namespace SparkleShare {
|
||||||
Enabled = false
|
Enabled = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Buttons.Add (SyncButton);
|
Buttons.Add (SyncButton);
|
||||||
|
|
||||||
|
|
||||||
|
if (ServerFormOnly) {
|
||||||
|
|
||||||
|
CancelButton = new NSButton () {
|
||||||
|
Title = "Cancel"
|
||||||
|
};
|
||||||
|
|
||||||
|
CancelButton.Activated += delegate {
|
||||||
|
PerformClose (this);
|
||||||
|
};
|
||||||
|
|
||||||
|
Buttons.Add (CancelButton);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
SkipButton = new NSButton () {
|
||||||
|
Title = "Skip"
|
||||||
|
};
|
||||||
|
|
||||||
|
SkipButton.Activated += delegate {
|
||||||
|
ShowCompletedPage ();
|
||||||
|
};
|
||||||
|
|
||||||
|
Buttons.Add (SkipButton);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowAll ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ShowErrorPage ()
|
||||||
|
{
|
||||||
|
|
||||||
|
Reset ();
|
||||||
|
|
||||||
|
Header = "Something went wrong…";
|
||||||
|
Description = "";
|
||||||
|
|
||||||
|
|
||||||
|
TryAgainButton = new NSButton () {
|
||||||
|
Title = "Try again…"
|
||||||
|
};
|
||||||
|
|
||||||
|
TryAgainButton.Activated += delegate {
|
||||||
|
ShowServerForm ();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Buttons.Add (TryAgainButton);
|
||||||
|
|
||||||
|
ShowAll ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ShowSuccessPage (string folder_name)
|
||||||
|
{
|
||||||
|
|
||||||
|
Reset ();
|
||||||
|
|
||||||
|
Header = "Folder synced succesfully!";
|
||||||
|
Description = "Now you can access the synced files from ‘" + folder_name + "’ in " +
|
||||||
|
"your SparkleShare folder.";
|
||||||
|
|
||||||
|
|
||||||
|
FinishButton = new NSButton () {
|
||||||
|
Title = "Finish"
|
||||||
|
};
|
||||||
|
|
||||||
|
FinishButton.Activated += delegate {
|
||||||
|
Close ();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
OpenFolderButton = new NSButton () {
|
||||||
|
Title = "Open Folder"
|
||||||
|
};
|
||||||
|
|
||||||
|
OpenFolderButton.Activated += delegate {
|
||||||
|
SparkleShare.Controller.OpenSparkleShareFolder (folder_name);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Buttons.Add (FinishButton);
|
||||||
|
Buttons.Add (OpenFolderButton);
|
||||||
|
|
||||||
|
ShowAll ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ShowCompletedPage ()
|
||||||
|
{
|
||||||
|
|
||||||
|
Reset ();
|
||||||
|
|
||||||
|
Header = "SparkleShare is ready to go!";
|
||||||
|
Description = "Now you can start accepting invitations from others. " +
|
||||||
|
"Just click on invitations you get by email and " +
|
||||||
|
"we will take care of the rest.";
|
||||||
|
|
||||||
|
|
||||||
|
FinishButton = new NSButton () {
|
||||||
|
Title = "Finish"
|
||||||
|
};
|
||||||
|
|
||||||
|
FinishButton.Activated += delegate {
|
||||||
|
Console.WriteLine ("ffffffff");
|
||||||
|
Close ();
|
||||||
|
};
|
||||||
|
|
||||||
|
Buttons.Add (FinishButton);
|
||||||
|
|
||||||
ShowAll ();
|
ShowAll ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -134,10 +266,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// proto.SetButtonType (NSButtonType.Radio) ;
|
// proto.SetButtonType (NSButtonType.Radio) ;
|
||||||
|
|
||||||
// NSButton button = new NSButton (new RectangleF (150, 0, 350, 300)) {
|
// NSButton button = new NSButton (new RectangleF (150, 0, 350, 300)) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
LocalPath = path;
|
LocalPath = path;
|
||||||
|
|
||||||
Delegate = new LogDelegate ();
|
Delegate = new SparkleLogDelegate ();
|
||||||
|
|
||||||
SetFrame (new RectangleF (0, 0, 480, 640), true);
|
SetFrame (new RectangleF (0, 0, 480, 640), true);
|
||||||
Center ();
|
Center ();
|
||||||
|
@ -145,7 +145,7 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class LogDelegate : NSWindowDelegate {
|
public class SparkleLogDelegate : NSWindowDelegate {
|
||||||
|
|
||||||
public override bool WindowShouldClose (NSObject sender)
|
public override bool WindowShouldClose (NSObject sender)
|
||||||
{
|
{
|
||||||
|
|
|
@ -238,7 +238,25 @@ namespace SparkleShare {
|
||||||
SyncMenuItem.Enabled = false;
|
SyncMenuItem.Enabled = false;
|
||||||
|
|
||||||
SyncMenuItem.Activated += delegate {
|
SyncMenuItem.Activated += delegate {
|
||||||
new SparkleIntro ();
|
|
||||||
|
InvokeOnMainThread (delegate {
|
||||||
|
|
||||||
|
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||||
|
|
||||||
|
if (SparkleUI.Intro == null) {
|
||||||
|
|
||||||
|
SparkleUI.Intro = new SparkleIntro ();
|
||||||
|
SparkleUI.Intro.ShowServerForm (true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SparkleUI.Intro.IsVisible)
|
||||||
|
SparkleUI.Intro.ShowServerForm (true);
|
||||||
|
|
||||||
|
SparkleUI.Intro.OrderFrontRegardless ();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Menu.AddItem (SyncMenuItem);
|
Menu.AddItem (SyncMenuItem);
|
||||||
|
@ -301,6 +319,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
return delegate {
|
return delegate {
|
||||||
|
|
||||||
|
InvokeOnMainThread (delegate {
|
||||||
|
|
||||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||||
|
|
||||||
SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) {
|
SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) {
|
||||||
|
@ -311,20 +331,18 @@ namespace SparkleShare {
|
||||||
// that's not the case or present it to the user if it is
|
// that's not the case or present it to the user if it is
|
||||||
if (log == null) {
|
if (log == null) {
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
SparkleUI.OpenLogs.Add (new SparkleLog (path));
|
SparkleUI.OpenLogs.Add (new SparkleLog (path));
|
||||||
SparkleUI.OpenLogs [SparkleUI.OpenLogs.Count - 1].MakeKeyAndOrderFront (this);
|
SparkleUI.OpenLogs [SparkleUI.OpenLogs.Count - 1].MakeKeyAndOrderFront (this);
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
log.OrderFrontRegardless ();
|
log.OrderFrontRegardless ();
|
||||||
log.MakeKeyAndOrderFront (this);
|
log.MakeKeyAndOrderFront (this);
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace SparkleShare {
|
||||||
public static SparkleStatusIcon StatusIcon;
|
public static SparkleStatusIcon StatusIcon;
|
||||||
public static List <SparkleLog> OpenLogs;
|
public static List <SparkleLog> OpenLogs;
|
||||||
public static int NewEvents;
|
public static int NewEvents;
|
||||||
|
public static SparkleIntro Intro;
|
||||||
|
|
||||||
|
|
||||||
public SparkleUI ()
|
public SparkleUI ()
|
||||||
|
|
|
@ -47,8 +47,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Center ();
|
Center ();
|
||||||
|
|
||||||
StyleMask = (NSWindowStyle.Closable |
|
StyleMask = (
|
||||||
NSWindowStyle.Miniaturizable |
|
|
||||||
NSWindowStyle.Titled);
|
NSWindowStyle.Titled);
|
||||||
|
|
||||||
MaxSize = new SizeF (640, 480);
|
MaxSize = new SizeF (640, 480);
|
||||||
|
@ -135,6 +135,15 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void Close ()
|
||||||
|
{
|
||||||
|
|
||||||
|
OrderOut (this);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -865,7 +865,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (File.Exists (key_file_path)) {
|
if (File.Exists (key_file_path)) {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Config", "Key already exists (" + key_file_name + "), " +
|
SparkleHelpers.DebugInfo ("Config", "Key already exists ('" + key_file_name + "'), " +
|
||||||
"leaving it untouched");
|
"leaving it untouched");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue