diff --git a/SparkleShare/Mac/SparkleController.cs b/SparkleShare/Mac/SparkleController.cs index 24d9637e..e3be75cf 100755 --- a/SparkleShare/Mac/SparkleController.cs +++ b/SparkleShare/Mac/SparkleController.cs @@ -102,9 +102,33 @@ namespace SparkleShare { } - public override void EnableSystemAutostart () + public override void CreateStartupItem () { - // N/A + // There aren't any bindings in MonoMac to support this yet, so + // we call out to an applescript to do the job + Process process = new Process (); + process.EnableRaisingEvents = true; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.UseShellExecute = false; + process.StartInfo.FileName = "osascript"; + process.StartInfo.CreateNoWindow = true; + + string app_path = Path.GetDirectoryName (NSBundle.MainBundle.ResourcePath); + app_path = Path.GetDirectoryName (app_path); + + process.StartInfo.Arguments = "-e 'tell application \"System Events\" to " + + "make login item at end with properties {path:\"" + app_path + "\", hidden:false}'"; + + process.Exited += delegate { + SparkleHelpers.DebugInfo ("Controller", "Added " + app_path + " to login items"); + }; + + try { + process.Start (); + + } catch (Exception e) { + SparkleHelpers.DebugInfo ("Controller", "Failed adding " + app_path + " to login items: " + e.Message); + } } diff --git a/SparkleShare/Mac/SparkleSetup.cs b/SparkleShare/Mac/SparkleSetup.cs index ca15b5ce..a90856c7 100755 --- a/SparkleShare/Mac/SparkleSetup.cs +++ b/SparkleShare/Mac/SparkleSetup.cs @@ -37,6 +37,7 @@ namespace SparkleShare { private NSButton TryAgainButton; private NSButton CancelButton; private NSButton SkipTutorialButton; + private NSButton StartupCheckButton; private NSButton OpenFolderButton; private NSButton FinishButton; private NSImage SlideImage; @@ -52,7 +53,6 @@ namespace SparkleShare { private NSTextField PathTextField; private NSTextField PathLabel; private NSTextField PathHelpLabel; - private NSTextField AddProjectTextField; private NSTextField WarningTextField; private NSImage WarningImage; private NSImageView WarningImageView; @@ -84,10 +84,9 @@ namespace SparkleShare { switch (type) { case PageType.Setup: { - // TODO: Improve text Header = "Welcome to SparkleShare!"; - Description = "We'll need some info to mark your changes in the event log. " + - "Don't worry, this stays between you and your peers."; + Description = "Before we get started, what's your name and email? " + + "Don't worry, this information is only visible to your team members."; FullNameLabel = new NSTextField () { @@ -618,7 +617,7 @@ namespace SparkleShare { switch (Controller.TutorialPageNumber) { case 1: { Header = "What's happening next?"; - Description = "SparkleShare creates a special folder in your personal folder " + + Description = "SparkleShare creates a special folder on your computer " + "that will keep track of your projects."; SkipTutorialButton = new NSButton () { @@ -658,8 +657,8 @@ namespace SparkleShare { case 2: { Header = "Sharing files with others"; - Description = "All files added to your project folders are synced with the host " + - "automatically, as well as with your collaborators."; + Description = "All files added to your project folders are synced automatically with " + + "the host and your team members."; ContinueButton = new NSButton () { Title = "Continue" @@ -689,8 +688,8 @@ namespace SparkleShare { case 3: { Header = "The status icon is here to help"; - Description = "It shows the syncing process status, " + - "and contains links to your projects and the event log."; + Description = "It shows the syncing progress, provides easy access to " + + "your projects and let's you view recent changes."; ContinueButton = new NSButton () { Title = "Continue" @@ -720,17 +719,20 @@ namespace SparkleShare { case 4: { Header = "Adding projects to SparkleShare"; - Description = "Just click this button when you see it on the web, and " + - "the project will be automatically added:"; + Description = "You can do this through the status icon menu, or by clicking " + + "magic buttons on webpages that look like this:"; - AddProjectTextField = new NSTextField () { - Frame = new RectangleF (190, Frame.Height - 290, 640 - 240, 44), - BackgroundColor = NSColor.WindowBackground, - Bordered = false, - Editable = false, - Font = SparkleUI.Font, - StringValue = "…or select ‘Add Hosted Project…’ from the status icon menu " + - "to add one by hand." + + StartupCheckButton = new NSButton () { + Frame = new RectangleF (190, Frame.Height - 400, 300, 18), + Title = "Add SparkleShare to startup items", + State = NSCellStateValue.On + }; + + StartupCheckButton.SetButtonType (NSButtonType.Switch); + + StartupCheckButton.Activated += delegate { + Controller.StartupItemChanged (StartupCheckButton.State == NSCellStateValue.On); }; FinishButton = new NSButton () { @@ -741,6 +743,7 @@ namespace SparkleShare { Controller.TutorialPageCompleted (); }; + string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-4.png"); @@ -754,7 +757,7 @@ namespace SparkleShare { }; ContentView.AddSubview (SlideImageView); - ContentView.AddSubview (AddProjectTextField); + ContentView.AddSubview (StartupCheckButton); Buttons.Add (FinishButton); break; diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 07a17520..db8c93b8 100755 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -45,8 +45,10 @@ namespace SparkleShare { // Creates a .desktop entry in autostart folder to // start SparkleShare automatically at login - public override void EnableSystemAutostart () + public override void CreateStartupItem () { + // TODO: check whether this still works + string autostart_path = Path.Combine (Environment.GetFolderPath ( Environment.SpecialFolder.ApplicationData), "autostart"); diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 3e5bfbb4..eccd7034 100755 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -92,7 +92,7 @@ namespace SparkleShare { public abstract string PluginsPath { get; } // Enables SparkleShare to start automatically at login - public abstract void EnableSystemAutostart (); + public abstract void CreateStartupItem (); // Installs the sparkleshare:// protocol handler public abstract void InstallProtocolHandler (); @@ -132,7 +132,6 @@ namespace SparkleShare { public virtual void Initialize () { - EnableSystemAutostart (); InstallProtocolHandler (); // Create the SparkleShare folder and add it to the bookmarks diff --git a/SparkleShare/SparkleSetup.cs b/SparkleShare/SparkleSetup.cs index 6a42eee9..3af57d68 100755 --- a/SparkleShare/SparkleSetup.cs +++ b/SparkleShare/SparkleSetup.cs @@ -64,8 +64,9 @@ namespace SparkleShare { case PageType.Setup: { Header = _("Welcome to SparkleShare!"); - Description = "We'll need some info to mark your changes in the event log. " + - "Don't worry, this stays between you and your peers."; + Description = "Before we get started, what's your name and email? " + + "Don't worry, this information is only visible to your team members."; + Table table = new Table (2, 3, true) { @@ -496,8 +497,8 @@ namespace SparkleShare { switch (Controller.TutorialPageNumber) { case 1: { Header = _("What's happening next?"); - Description = _("SparkleShare creates a special folder in your personal folder " + - "that will keep track of your projects."); + Description = "SparkleShare creates a special folder on your computer " + + "that will keep track of your projects."; Button skip_tutorial_button = new Button (_("Skip Tutorial")); skip_tutorial_button.Clicked += delegate { @@ -521,8 +522,8 @@ namespace SparkleShare { case 2: { Header = _("Sharing files with others"); - Description = _("All files added to your project folders are synced with the host " + - "automatically, as well as with your collaborators."); + Description = _("All files added to your project folders are synced automatically with " + + "the host and your team members."); Button continue_button = new Button (_("Continue")); continue_button.Clicked += delegate { @@ -539,8 +540,8 @@ namespace SparkleShare { case 3: { Header = _("The status icon is here to help"); - Description = _("It shows the syncing process status, " + - "and contains links to your projects and the event log."); + Description = _("It shows the syncing progress, provides easy access to " + + "your projects and let's you view recent changes."); Button continue_button = new Button (_("Continue")); continue_button.Clicked += delegate { @@ -557,15 +558,8 @@ namespace SparkleShare { case 4: { Header = _("Adding projects to SparkleShare"); - Description = _("Just click this button when you see it on the web, and " + - "the project will be automatically added:"); - - Label label = new Label (_("…or select ‘Add Hosted Project…’ from the status icon menu " + - "to add one by hand.")) { - Wrap = true, - Xalign = 0, - UseMarkup = true - }; + Description = _("You can do this through the status icon menu, or by clicking " + + "magic buttons on webpages that look like this:"); Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-4.png"); @@ -574,12 +568,9 @@ namespace SparkleShare { Controller.FinishPageCompleted (); }; + // TODO: Add startup item checkbox here - VBox box = new VBox (false, 0); - box.Add (slide); - box.Add (label); - - Add (box); + Add (slide); AddButton (finish_button); break; diff --git a/SparkleShare/SparkleSetupController.cs b/SparkleShare/SparkleSetupController.cs index 240efaf3..08bcd946 100755 --- a/SparkleShare/SparkleSetupController.cs +++ b/SparkleShare/SparkleSetupController.cs @@ -103,6 +103,7 @@ namespace SparkleShare { private string saved_address = ""; private string saved_remote_path = ""; + private bool create_startup_item = true; public SparkleSetupController () @@ -209,14 +210,23 @@ namespace SparkleShare { } + public void StartupItemChanged (bool create_startup_item) + { + this.create_startup_item = create_startup_item; + } + + public void TutorialPageCompleted () { TutorialPageNumber++; - if (TutorialPageNumber == 4) { + if (TutorialPageNumber == 5) { if (HideWindowEvent != null) HideWindowEvent (); + if (this.create_startup_item) + Program.Controller.CreateStartupItem (); + } else { if (ChangePageEvent != null) ChangePageEvent (PageType.Tutorial, null); @@ -264,7 +274,7 @@ namespace SparkleShare { remote_path = remote_path.Trim (); if (selected_plugin == 0) - this.saved_address = address; + this.saved_address = address; this.saved_remote_path = remote_path; diff --git a/SparkleShare/SparkleStatusIconController.cs b/SparkleShare/SparkleStatusIconController.cs index 05671aec..c0212c1b 100755 --- a/SparkleShare/SparkleStatusIconController.cs +++ b/SparkleShare/SparkleStatusIconController.cs @@ -145,7 +145,7 @@ namespace SparkleShare { public void AddHostedProjectClicked () { - Program.Controller.ShowSetupWindow (PageType.Add); + Program.Controller.ShowSetupWindow (PageType.Tutorial); } diff --git a/data/tutorial-slide-4.png b/data/tutorial-slide-4.png index ae642773..315179b6 100755 Binary files a/data/tutorial-slide-4.png and b/data/tutorial-slide-4.png differ