From c88a0a5a4beb122a996336b3c495d8a2d8f471c5 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 26 Oct 2012 23:26:15 +0100 Subject: [PATCH] setup mac: change the last tutorial page. present link code with copy button --- SparkleLib/SparkleConfig.cs | 22 ++++------ SparkleShare/Common/Pixmaps/Makefile.am | 1 - SparkleShare/Mac/SparkleSetup.cs | 55 ++++++++++++++++++------- SparkleShare/Mac/SparkleShare.csproj | 3 -- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/SparkleConfig.cs index 5c2f7626..637f4525 100755 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/SparkleConfig.cs @@ -131,19 +131,16 @@ namespace SparkleLib { public SparkleUser User { get { - XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()"); - string name = name_node.Value; - + XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()"); XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()"); - string email = email_node.Value; + string user_name = name_node.Value; + string user_email = email_node.Value; - string pubkey_file_path = Path.Combine ( - Path.GetDirectoryName (FullPath), "sparkleshare." + email + ".key.pub"); + SparkleUser user = new SparkleUser (user_name, user_email); + string [] pubkey_file_paths = Directory.GetFiles (Path.GetDirectoryName (FullPath), "*.pub"); - SparkleUser user = new SparkleUser (name, email); - - if (File.Exists (pubkey_file_path)) - user.PublicKey = File.ReadAllText (pubkey_file_path); + if (pubkey_file_paths.Length > 0) + user.PublicKey = File.ReadAllText (pubkey_file_paths [0]); return user; } @@ -151,10 +148,9 @@ namespace SparkleLib { set { SparkleUser user = (SparkleUser) value; - XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()"); - name_node.InnerText = user.Name; - + XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()"); XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()"); + name_node.InnerText = user.Name; email_node.InnerText = user.Email; Save (); diff --git a/SparkleShare/Common/Pixmaps/Makefile.am b/SparkleShare/Common/Pixmaps/Makefile.am index c4073c15..68f4cad6 100644 --- a/SparkleShare/Common/Pixmaps/Makefile.am +++ b/SparkleShare/Common/Pixmaps/Makefile.am @@ -1,5 +1,4 @@ dist_pixmaps_DATA = \ - tutorial-slide-4.png \ side-splash.png \ user-icon-default.png \ about.png diff --git a/SparkleShare/Mac/SparkleSetup.cs b/SparkleShare/Mac/SparkleSetup.cs index dd80c911..780d7e91 100755 --- a/SparkleShare/Mac/SparkleSetup.cs +++ b/SparkleShare/Mac/SparkleSetup.cs @@ -35,6 +35,7 @@ namespace SparkleShare { private NSButton ContinueButton; private NSButton AddButton; + private NSButton CopyButton; private NSButton TryAgainButton; private NSButton CancelButton; private NSButton SkipTutorialButton; @@ -51,6 +52,7 @@ namespace SparkleShare { private NSTextField EmailHelpLabel; private NSTextField FullNameTextField; private NSTextField FullNameLabel; + private NSTextField LinkCodeTextField; private NSTextField AddressTextField; private NSTextField AddressLabel; private NSTextField AddressHelpLabel; @@ -832,17 +834,18 @@ namespace SparkleShare { string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-" + Controller.TutorialPageNumber + ".png"); - SlideImage = new NSImage (slide_image_path) { - Size = new SizeF (350, 200) - }; + if (File.Exists (slide_image_path)) { + 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); + SlideImageView = new NSImageView () { + Image = SlideImage, + Frame = new RectangleF (215, Frame.Height - 350, 350, 200) + }; + ContentView.AddSubview (SlideImageView); + } switch (Controller.TutorialPageNumber) { @@ -915,11 +918,26 @@ namespace SparkleShare { } case 4: { - Header = "Adding projects to SparkleShare"; - Description = "You can do this through the status icon menu, or by clicking " + - "magic buttons on webpages that look like this:"; + Header = "Here's your unique link code"; + Description = "You'll need it whenever you want to link this computer to a host" + + " (we keep a copy in your SparkleShare folder)."; + LinkCodeTextField = new NSTextField () { + StringValue = Program.Controller.CurrentUser.PublicKey, + Enabled = false, + Selectable = false, + Frame = new RectangleF (230, Frame.Height - 238, 246, 22) + }; + LinkCodeTextField.Cell.UsesSingleLineMode = true; + LinkCodeTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; + + CopyButton = new NSButton () { + Title = "Copy", + BezelStyle = NSBezelStyle.RoundRect, + Frame = new RectangleF (480, Frame.Height - 238, 60, 22) + }; + StartupCheckButton = new NSButton () { Frame = new RectangleF (190, Frame.Height - 400, 300, 18), Title = "Add SparkleShare to startup items", @@ -932,8 +950,11 @@ namespace SparkleShare { Title = "Finish" }; - SlideImage.Size = new SizeF (350, 64); - + CopyButton.Activated += delegate { + NSPasteboard.GeneralPasteboard.ClearContents (); + NSPasteboard.GeneralPasteboard.SetStringForType (LinkCodeTextField.StringValue, + "NSStringPboardType"); + }; StartupCheckButton.Activated += delegate { Controller.StartupItemChanged (StartupCheckButton.State == NSCellStateValue.On); @@ -942,9 +963,11 @@ namespace SparkleShare { FinishButton.Activated += delegate { Controller.TutorialPageCompleted (); }; - - + + ContentView.AddSubview (LinkCodeTextField); + ContentView.AddSubview (CopyButton); ContentView.AddSubview (StartupCheckButton); + Buttons.Add (FinishButton); break; diff --git a/SparkleShare/Mac/SparkleShare.csproj b/SparkleShare/Mac/SparkleShare.csproj index 735c27e3..0f61c356 100644 --- a/SparkleShare/Mac/SparkleShare.csproj +++ b/SparkleShare/Mac/SparkleShare.csproj @@ -157,9 +157,6 @@ Pixmaps\tutorial-slide-3.png - - Pixmaps\tutorial-slide-4.png - Plugins\bitbucket.xml