[intro] implement more of the wizard

This commit is contained in:
Hylke Bons 2011-02-08 22:40:09 +00:00
parent 32296666a1
commit d9c9c38d53
6 changed files with 201 additions and 45 deletions

View file

@ -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,24 +63,26 @@ 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 () {
Title = "Next", Title = "Next",
Enabled = false Enabled = false
}; };
NextButton.Activated += delegate { NextButton.Activated += delegate {
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;
ShowServerForm (); InvokeOnMainThread (delegate {
ShowServerForm ();
});
}; };
@ -101,13 +110,22 @@ namespace SparkleShare {
timer.Start (); timer.Start ();
ContentView.AddSubview (UserInfoForm); ContentView.AddSubview (UserInfoForm);
Buttons.Add (NextButton); Buttons.Add (NextButton);
ShowAll (); ShowAll ();
} }
public void ShowServerForm (bool server_form_only)
{
ServerFormOnly = server_form_only;
ShowServerForm ();
}
public void ShowServerForm () public void ShowServerForm ()
{ {
@ -123,21 +141,131 @@ namespace SparkleShare {
Enabled = false Enabled = false
}; };
Buttons.Add (SyncButton);
if (ServerFormOnly) {
CancelButton = new NSButton () {
Title = "Cancel"
};
CancelButton.Activated += delegate {
PerformClose (this);
};
Buttons.Add (SyncButton); Buttons.Add (CancelButton);
} else {
SkipButton = new NSButton () {
Title = "Skip"
};
SkipButton.Activated += delegate {
ShowCompletedPage ();
};
Buttons.Add (SkipButton);
}
ShowAll (); 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 ();
}
} }
} }
// 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)) {

View file

@ -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)
{ {

View file

@ -226,7 +226,7 @@ namespace SparkleShare {
Menu.AddItem (FolderMenuItems [0]); Menu.AddItem (FolderMenuItems [0]);
} }
Menu.AddItem (NSMenuItem.SeparatorItem); Menu.AddItem (NSMenuItem.SeparatorItem);
@ -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);
@ -300,31 +318,31 @@ namespace SparkleShare {
{ {
return delegate { return delegate {
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); InvokeOnMainThread (delegate {
SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) {
return l.LocalPath.Equals (path);
});
// Check whether the log is already open, create a new one if NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
// that's not the case or present it to the user if it is
if (log == null) {
InvokeOnMainThread (delegate { SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) {
return l.LocalPath.Equals (path);
});
// Check whether the log is already open, create a new one if
// that's not the case or present it to the user if it is
if (log == null) {
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);
});
}
}
});
}; };
} }

View file

@ -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 ()

View file

@ -47,16 +47,16 @@ namespace SparkleShare {
Center (); Center ();
StyleMask = (NSWindowStyle.Closable | StyleMask = (
NSWindowStyle.Miniaturizable |
NSWindowStyle.Titled); NSWindowStyle.Titled);
MaxSize = new SizeF (640, 480); MaxSize = new SizeF (640, 480);
MinSize = new SizeF (640, 480); MinSize = new SizeF (640, 480);
HasShadow = true; HasShadow = true;
BackingType = NSBackingStore.Buffered; BackingType = NSBackingStore.Buffered;
string side_splash_path = Path.Combine (NSBundle.MainBundle.ResourcePath, string side_splash_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "side-splash.png"); "Pixmaps", "side-splash.png");
@ -92,7 +92,7 @@ namespace SparkleShare {
MakeKeyAndOrderFront (this); MakeKeyAndOrderFront (this);
} }
public void Reset () { public void Reset () {
@ -135,6 +135,15 @@ namespace SparkleShare {
} }
}
public override void Close ()
{
OrderOut (this);
return;
}
}
} }

View file

@ -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;