diff --git a/SparkleShare/Mac/SparkleShare/SparkleIntro.cs b/SparkleShare/Mac/SparkleShare/SparkleIntro.cs index baf970c8..3a42588a 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleIntro.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleIntro.cs @@ -30,18 +30,25 @@ namespace SparkleShare { private NSButton NextButton; private NSButton SyncButton; + private NSButton TryAgainButton; + private NSButton CancelButton; + private NSButton SkipButton; + private NSButton OpenFolderButton; + private NSButton FinishButton; private NSForm UserInfoForm; + private bool ServerFormOnly; + public SparkleIntro () : base () { - ShowUserForm (); + ServerFormOnly = false; } - public void ShowUserForm () + public void ShowAccountForm () { Reset (); @@ -56,24 +63,26 @@ namespace SparkleShare { UserInfoForm.AddEntry ("Email Address:"); UserInfoForm.CellSize = new SizeF (280, 22); - string login_name = UnixUserInfo.GetLoginName (); - string full_name = new UnixUserInfo (login_name).RealName; + string full_name = new UnixUserInfo (UnixEnvironment.UserName).RealName; UserInfoForm.Cells [0].StringValue = full_name; + UserInfoForm.Cells [1].StringValue = SparkleShare.Controller.UserEmail; NextButton = new NSButton () { Title = "Next", Enabled = false }; - + NextButton.Activated += delegate { SparkleShare.Controller.UserName = UserInfoForm.Cells [0].StringValue.Trim (); SparkleShare.Controller.UserEmail = UserInfoForm.Cells [1].StringValue.Trim (); - - SparkleShare.Controller.GenerateKeyPair (); - - ShowServerForm (); + SparkleShare.Controller.GenerateKeyPair (); + SparkleShare.Controller.FirstRun = false; + + InvokeOnMainThread (delegate { + ShowServerForm (); + }); }; @@ -101,13 +110,22 @@ namespace SparkleShare { timer.Start (); - ContentView.AddSubview (UserInfoForm); - Buttons.Add (NextButton); + ContentView.AddSubview (UserInfoForm); + Buttons.Add (NextButton); ShowAll (); } + + public void ShowServerForm (bool server_form_only) + { + + ServerFormOnly = server_form_only; + ShowServerForm (); + + } + public void ShowServerForm () { @@ -123,21 +141,131 @@ namespace SparkleShare { 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 (); } + + 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) ; // NSButton button = new NSButton (new RectangleF (150, 0, 350, 300)) { diff --git a/SparkleShare/Mac/SparkleShare/SparkleLog.cs b/SparkleShare/Mac/SparkleShare/SparkleLog.cs index da178ce8..441fc535 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleLog.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleLog.cs @@ -42,7 +42,7 @@ namespace SparkleShare { LocalPath = path; - Delegate = new LogDelegate (); + Delegate = new SparkleLogDelegate (); SetFrame (new RectangleF (0, 0, 480, 640), true); Center (); @@ -145,7 +145,7 @@ namespace SparkleShare { } - public class LogDelegate : NSWindowDelegate { + public class SparkleLogDelegate : NSWindowDelegate { public override bool WindowShouldClose (NSObject sender) { diff --git a/SparkleShare/Mac/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/Mac/SparkleShare/SparkleStatusIcon.cs index 2d9c7ec7..82ab7fd3 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleStatusIcon.cs @@ -226,7 +226,7 @@ namespace SparkleShare { Menu.AddItem (FolderMenuItems [0]); } - + Menu.AddItem (NSMenuItem.SeparatorItem); @@ -238,7 +238,25 @@ namespace SparkleShare { SyncMenuItem.Enabled = false; 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); @@ -300,31 +318,31 @@ namespace SparkleShare { { return delegate { - - NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); - - SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) { - return l.LocalPath.Equals (path); - }); + + InvokeOnMainThread (delegate { - // 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) { + 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 + // 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 [SparkleUI.OpenLogs.Count - 1].MakeKeyAndOrderFront (this); - }); - - } else { - - InvokeOnMainThread (delegate { + + } else { + log.OrderFrontRegardless (); log.MakeKeyAndOrderFront (this); - }); - - } - + + } + + }); + }; } diff --git a/SparkleShare/Mac/SparkleShare/SparkleUI.cs b/SparkleShare/Mac/SparkleShare/SparkleUI.cs index 5efaf3a2..4ea01a11 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleUI.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleUI.cs @@ -46,6 +46,7 @@ namespace SparkleShare { public static SparkleStatusIcon StatusIcon; public static List OpenLogs; public static int NewEvents; + public static SparkleIntro Intro; public SparkleUI () diff --git a/SparkleShare/Mac/SparkleShare/SparkleWindow.cs b/SparkleShare/Mac/SparkleShare/SparkleWindow.cs index 7a326fc7..686957c7 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleWindow.cs @@ -47,16 +47,16 @@ namespace SparkleShare { Center (); - StyleMask = (NSWindowStyle.Closable | - NSWindowStyle.Miniaturizable | + StyleMask = ( + NSWindowStyle.Titled); MaxSize = new SizeF (640, 480); MinSize = new SizeF (640, 480); HasShadow = true; BackingType = NSBackingStore.Buffered; - + string side_splash_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "side-splash.png"); @@ -92,7 +92,7 @@ namespace SparkleShare { MakeKeyAndOrderFront (this); } - + public void Reset () { @@ -135,6 +135,15 @@ namespace SparkleShare { } - } + public override void Close () + { + + OrderOut (this); + return; + + } + + } + } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 49edf96c..6b69202f 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -865,7 +865,7 @@ namespace SparkleShare { 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"); return;