diff --git a/SparkleShare/Linux/SparkleSetup.cs b/SparkleShare/Linux/SparkleSetup.cs
index e5b650a7..16c82b5c 100755
--- a/SparkleShare/Linux/SparkleSetup.cs
+++ b/SparkleShare/Linux/SparkleSetup.cs
@@ -27,15 +27,11 @@ namespace SparkleShare {
public SparkleSetupController Controller = new SparkleSetupController ();
- private ProgressBar progress_bar = new ProgressBar ();
-
public SparkleSetup () : base ()
{
Controller.HideWindowEvent += delegate {
- Application.Invoke (delegate {
- HideAll ();
- });
+ Application.Invoke (delegate { HideAll (); });
};
Controller.ShowWindowEvent += delegate {
@@ -44,806 +40,641 @@ namespace SparkleShare {
Present ();
});
};
-
+
Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
Application.Invoke (delegate {
Reset ();
-
- switch (type) {
- case PageType.Setup: {
- Header = "Welcome to SparkleShare!";
- Description = "First off, what's your name and email?\nThis information is only visible to team members.";
-
- Table table = new Table (2, 3, true) {
- RowSpacing = 6,
- ColumnSpacing = 6
- };
-
- Label name_label = new Label ("" + "Full Name:" + "") {
- UseMarkup = true,
- Xalign = 1
- };
-
- Entry name_entry = new Entry () {
- Xalign = 0,
- ActivatesDefault = true
- };
-
- UnixUserInfo user_info = UnixUserInfo.GetRealUser ();
-
- if (user_info != null && user_info.RealName != null)
- name_entry.Text = user_info.RealName.TrimEnd (",".ToCharArray ());
-
- Entry email_entry = new Entry () {
- Xalign = 0,
- ActivatesDefault = true
- };
-
- name_entry.Changed += delegate {
- Controller.CheckSetupPage (name_entry.Text, email_entry.Text);
- };
-
- email_entry.Changed += delegate {
- Controller.CheckSetupPage (name_entry.Text, email_entry.Text);
- };
-
- Label email_label = new Label ("" + "Email:" + "") {
- UseMarkup = true,
- Xalign = 1
- };
-
- table.Attach (name_label, 0, 1, 0, 1);
- table.Attach (name_entry, 1, 2, 0, 1);
- table.Attach (email_label, 0, 1, 1, 2);
- table.Attach (email_entry, 1, 2, 1, 2);
-
- VBox wrapper = new VBox (false, 9);
- wrapper.PackStart (table, true, false, 0);
-
- Button cancel_button = new Button ("Cancel");
-
- cancel_button.Clicked += delegate {
- Controller.SetupPageCancelled ();
- };
-
- Button continue_button = new Button ("Continue") {
- Sensitive = false
- };
-
- continue_button.Clicked += delegate {
- Controller.SetupPageCompleted (name_entry.Text, email_entry.Text);
- };
-
- AddButton (cancel_button);
- AddButton (continue_button);
- Add (wrapper);
-
-
- Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) {
- Application.Invoke (delegate {
- continue_button.Sensitive = button_enabled;
- });
- };
-
- Controller.CheckSetupPage (name_entry.Text, email_entry.Text);
-
- break;
- }
-
- case PageType.Add: {
- Header = "Where's your project hosted?";
-
- VBox layout_vertical = new VBox (false, 12);
- HBox layout_fields = new HBox (true, 12);
- VBox layout_address = new VBox (true, 0);
- VBox layout_path = new VBox (true, 0);
-
-
- ListStore store = new ListStore (typeof (Gdk.Pixbuf),
- typeof (string), typeof (SparklePlugin));
-
- SparkleTreeView tree = new SparkleTreeView (store) { HeadersVisible = false };
- ScrolledWindow scrolled_window = new ScrolledWindow ();
- scrolled_window.AddWithViewport (tree);
-
- // Icon column
- tree.AppendColumn ("Icon", new Gtk.CellRendererPixbuf (), "pixbuf", 0);
- tree.Columns [0].Cells [0].Xpad = 6;
-
- // Service column
- TreeViewColumn service_column = new TreeViewColumn () { Title = "Service" };
- CellRendererText service_cell = new CellRendererText () { Ypad = 4 };
- service_column.PackStart (service_cell, true);
- service_column.SetCellDataFunc (service_cell, new TreeCellDataFunc (RenderServiceColumn));
-
- foreach (SparklePlugin plugin in Controller.Plugins) {
- store.AppendValues (
- new Gdk.Pixbuf (plugin.ImagePath),
- "" + plugin.Name + "\n" +
- "" +
- plugin.Description + "" +
- "",
- plugin);
- }
-
- tree.AppendColumn (service_column);
-
- Entry address_entry = new Entry () {
- Text = Controller.PreviousAddress,
- Sensitive = (Controller.SelectedPlugin.Address == null),
- ActivatesDefault = true
- };
-
- Entry path_entry = new Entry () {
- Text = Controller.PreviousPath,
- Sensitive = (Controller.SelectedPlugin.Path == null),
- ActivatesDefault = true
- };
-
- Label address_example = new Label () {
- Xalign = 0,
- UseMarkup = true,
- Markup = "" + Controller.SelectedPlugin.AddressExample + ""
- };
-
- Label path_example = new Label () {
- Xalign = 0,
- UseMarkup = true,
- Markup = "" + Controller.SelectedPlugin.PathExample + ""
- };
-
-
- // Select the first plugin by default
- TreeSelection default_selection = tree.Selection;
- TreePath default_path = new TreePath ("0");
- default_selection.SelectPath (default_path);
- Controller.SelectedPluginChanged (0);
-
- Controller.ChangeAddressFieldEvent += delegate (string text,
- string example_text, FieldState state) {
-
- Application.Invoke (delegate {
- address_entry.Text = text;
- address_entry.Sensitive = (state == FieldState.Enabled);
- address_example.Markup = "" + example_text + "";
- });
- };
-
- Controller.ChangePathFieldEvent += delegate (string text,
- string example_text, FieldState state) {
-
- Application.Invoke (delegate {
- path_entry.Text = text;
- path_entry.Sensitive = (state == FieldState.Enabled);
- path_example.Markup = "" + example_text + "";
- });
- };
-
- Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1);
-
- // Update the address field text when the selection changes
- tree.CursorChanged += delegate (object sender, EventArgs e) {
- Controller.SelectedPluginChanged (tree.SelectedRow);
- // TODO: Scroll to selected row when using arrow keys
- };
-
- tree.Model.Foreach (new TreeModelForeachFunc (delegate (TreeModel model,
- TreePath path, TreeIter iter) {
-
- string address;
-
- try {
- address = (model.GetValue (iter, 2) as SparklePlugin).Address;
-
- } catch (NullReferenceException) {
- address = "";
- }
-
- if (!string.IsNullOrEmpty (address) &&
- address.Equals (Controller.PreviousAddress)) {
-
- tree.SetCursor (path, service_column, false);
- SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2);
-
- if (plugin.Address != null) {
- address_entry.Sensitive = false;}
-
- if (plugin.Path != null)
- path_entry.Sensitive = false;
-
- // TODO: Scroll to the selection
-
- return true;
- } else {
- return false;
- }
- }));
-
-
- address_entry.Changed += delegate {
- Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow);
- };
-
- layout_address.PackStart (new Label () {
- Markup = "" + "Address:" + "",
- Xalign = 0
- }, true, true, 0);
-
- layout_address.PackStart (address_entry, false, false, 0);
- layout_address.PackStart (address_example, false, false, 0);
-
- path_entry.Changed += delegate {
- Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow);
- };
-
- layout_path.PackStart (new Label () {
- Markup = "" + "Remote Path:" + "",
- Xalign = 0
- }, true, true, 0);
-
- layout_path.PackStart (path_entry, false, false, 0);
- layout_path.PackStart (path_example, false, false, 0);
-
- layout_fields.PackStart (layout_address);
- layout_fields.PackStart (layout_path);
-
- layout_vertical.PackStart (new Label (""), false, false, 0);
- layout_vertical.PackStart (scrolled_window, true, true, 0);
- layout_vertical.PackStart (layout_fields, false, false, 0);
-
- Add (layout_vertical);
-
- // Cancel button
- Button cancel_button = new Button ("Cancel");
-
- cancel_button.Clicked += delegate {
- Controller.PageCancelled ();
- };
-
- Button add_button = new Button ("Add") {
- Sensitive = false
- };
-
- add_button.Clicked += delegate {
- Controller.AddPageCompleted (address_entry.Text, path_entry.Text);
- };
-
- Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) {
- Application.Invoke (delegate {
- add_button.Sensitive = button_enabled;
- });
- };
-
-
- CheckButton check_button = new CheckButton ("Fetch prior history") {
- Active = false
- };
-
- check_button.Toggled += delegate {
- Controller.HistoryItemChanged (check_button.Active);
- };
-
- AddOption (check_button);
- AddButton (cancel_button);
- AddButton (add_button);
-
- Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1);
-
- break;
- }
-
- case PageType.Invite: {
- Header = "You've received an invite!";
- Description = "Do you want to add this project to SparkleShare?";
-
-
- Table table = new Table (2, 3, true) {
- RowSpacing = 6,
- ColumnSpacing = 6
- };
-
- Label address_label = new Label ("Address:") {
- Xalign = 1
- };
-
- Label path_label = new Label ("Remote Path:") {
- Xalign = 1
- };
-
- Label address_value = new Label ("" + Controller.PendingInvite.Address + "") {
- UseMarkup = true,
- Xalign = 0
- };
-
- Label path_value = new Label ("" + Controller.PendingInvite.RemotePath + "") {
- UseMarkup = true,
- Xalign = 0
- };
-
- table.Attach (address_label, 0, 1, 0, 1);
- table.Attach (address_value, 1, 2, 0, 1);
- table.Attach (path_label, 0, 1, 1, 2);
- table.Attach (path_value, 1, 2, 1, 2);
-
- VBox wrapper = new VBox (false, 9);
- wrapper.PackStart (table, true, false, 0);
-
- Button cancel_button = new Button ("Cancel");
-
- cancel_button.Clicked += delegate {
- Controller.PageCancelled ();
- };
-
- Button add_button = new Button ("Add");
-
- add_button.Clicked += delegate {
- Controller.InvitePageCompleted ();
- };
-
- AddButton (cancel_button);
- AddButton (add_button);
- Add (wrapper);
-
- break;
- }
-
- case PageType.Syncing: {
-
- Header = String.Format ("Adding project ‘{0}’…", Controller.SyncingFolder);
- Description = "This may take a while for large projects.\nIsn't it coffee-o'clock?";
-
- this.progress_bar.Fraction = Controller.ProgressBarPercentage / 100;
-
- Button finish_button = new Button () {
- Sensitive = false,
- Label = "Finish"
- };
-
- Button cancel_button = new Button () {
- Label = "Cancel"
- };
-
- cancel_button.Clicked += delegate {
- Controller.SyncingCancelled ();
- };
-
- AddButton (cancel_button);
- AddButton (finish_button);
-
- Controller.UpdateProgressBarEvent += delegate (double percentage) {
- Application.Invoke (delegate {
- this.progress_bar.Fraction = percentage / 100;
- });
- };
-
- if (this.progress_bar.Parent != null)
- (this.progress_bar.Parent as Container).Remove (this.progress_bar);
-
- VBox bar_wrapper = new VBox (false, 0);
- bar_wrapper.PackStart (this.progress_bar, false, false, 15);
-
- Add (bar_wrapper);
-
- break;
- }
-
- case PageType.Error: {
- Header = "Oops! Something went wrong" + "…";
-
- VBox points = new VBox (false, 0);
- Image list_point_one = new Image (SparkleUIHelpers.GetIcon ("list-point", 16));
- Image list_point_two = new Image (SparkleUIHelpers.GetIcon ("list-point", 16));
- Image list_point_three = new Image (SparkleUIHelpers.GetIcon ("list-point", 16));
-
- Label label_one = new Label () {
- Markup = "" + Controller.PreviousUrl + " is the address we've compiled. " +
- "Does this look alright?",
- Wrap = true,
- Xalign = 0
- };
-
- Label label_two = new Label () {
- Text = "Do you have access rights to this remote project?",
- Wrap = true,
- Xalign = 0
- };
-
- points.PackStart (new Label ("Please check the following:") { Xalign = 0 }, false, false, 6);
-
- HBox point_one = new HBox (false, 0);
- point_one.PackStart (list_point_one, false, false, 0);
- point_one.PackStart (label_one, true, true, 12);
- points.PackStart (point_one, false, false, 12);
-
- HBox point_two = new HBox (false, 0);
- point_two.PackStart (list_point_two, false, false, 0);
- point_two.PackStart (label_two, true, true, 12);
- points.PackStart (point_two, false, false, 12);
-
- if (warnings.Length > 0) {
- string warnings_markup = "";
-
- foreach (string warning in warnings)
- warnings_markup += "\n" + warning + "";
-
- Label label_three = new Label () {
- Markup = "Here's the raw error message:" + warnings_markup,
- Wrap = true,
- Xalign = 0
- };
-
- HBox point_three = new HBox (false, 0);
- point_three.PackStart (list_point_three, false, false, 0);
- point_three.PackStart (label_three, true, true, 12);
- points.PackStart (point_three, false, false, 12);
- }
-
- points.PackStart (new Label (""), true, true, 0);
-
- Button cancel_button = new Button ("Cancel");
-
- cancel_button.Clicked += delegate {
- Controller.PageCancelled ();
- };
-
- Button try_again_button = new Button ("Try Again…") {
- Sensitive = true
- };
-
- try_again_button.Clicked += delegate {
- Controller.ErrorPageCompleted ();
- };
-
- AddButton (cancel_button);
- AddButton (try_again_button);
- Add (points);
-
- break;
- }
-
- case PageType.CryptoSetup: {
- Header = "Set up file encryption";
- Description = "Please a provide a strong password that you don't use elsewhere below:";
-
- Label password_label = new Label ("" + "Password:" + "") {
- UseMarkup = true,
- Xalign = 1
- };
-
- Entry password_entry = new Entry () {
- Xalign = 0,
- Visibility = false,
- ActivatesDefault = true
- };
-
- CheckButton show_password_check_button = new CheckButton ("Show password") {
- Active = false,
- Xalign = 0,
- };
-
- show_password_check_button.Toggled += delegate {
- password_entry.Visibility = !password_entry.Visibility;
- };
-
- password_entry.Changed += delegate {
- Controller.CheckCryptoSetupPage (password_entry.Text);
- };
-
-
- Button continue_button = new Button ("Continue") {
- Sensitive = false
- };
-
- continue_button.Clicked += delegate {
- Controller.CryptoSetupPageCompleted (password_entry.Text);
- };
-
- Button cancel_button = new Button ("Cancel");
-
- cancel_button.Clicked += delegate {
- Controller.CryptoPageCancelled ();
- };
-
- Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
- Application.Invoke (delegate {
- continue_button.Sensitive = button_enabled;
- });
- };
-
-
- Table table = new Table (2, 3, true) {
- RowSpacing = 6,
- ColumnSpacing = 6
- };
-
- table.Attach (password_label, 0, 1, 0, 1);
- table.Attach (password_entry, 1, 2, 0, 1);
-
- table.Attach (show_password_check_button, 1, 2, 1, 2);
-
- VBox wrapper = new VBox (false, 9);
- wrapper.PackStart (table, true, false, 0);
-
-
- Image warning_image = new Image (
- SparkleUIHelpers.GetIcon ("dialog-information", 24)
- );
-
- Label warning_label = new Label () {
- Xalign = 0,
- Wrap = true,
- Text = "This password can't be changed later, and your files can't be recovered if it's forgotten."
- };
-
- HBox warning_layout = new HBox (false, 0);
- warning_layout.PackStart (warning_image, false, false, 15);
- warning_layout.PackStart (warning_label, true, true, 0);
-
- VBox warning_wrapper = new VBox (false, 0);
- warning_wrapper.PackStart (warning_layout, false, false, 15);
-
- wrapper.PackStart (warning_wrapper, false, false, 0);
-
-
- Add (wrapper);
-
- AddButton (cancel_button);
- AddButton (continue_button);
-
- break;
- }
-
- case PageType.CryptoPassword: {
- Header = "This project contains encrypted files";
- Description = "Please enter the password to see their contents.";
-
- Label password_label = new Label ("" + "Password:" + "") {
- UseMarkup = true,
- Xalign = 1
- };
-
- Entry password_entry = new Entry () {
- Xalign = 0,
- Visibility = false,
- ActivatesDefault = true
- };
-
- CheckButton show_password_check_button = new CheckButton ("Show password") {
- Active = false,
- Xalign = 0
- };
-
- show_password_check_button.Toggled += delegate {
- password_entry.Visibility = !password_entry.Visibility;
- };
-
- password_entry.Changed += delegate {
- Controller.CheckCryptoPasswordPage (password_entry.Text);
- };
-
-
- Button continue_button = new Button ("Continue") {
- Sensitive = false
- };
-
- continue_button.Clicked += delegate {
- Controller.CryptoPasswordPageCompleted (password_entry.Text);
- };
-
- Button cancel_button = new Button ("Cancel");
-
- cancel_button.Clicked += delegate {
- Controller.CryptoPageCancelled ();
- };
-
- Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) {
- Application.Invoke (delegate {
- continue_button.Sensitive = button_enabled;
- });
- };
-
- Table table = new Table (2, 3, true) {
- RowSpacing = 6,
- ColumnSpacing = 6
- };
-
- table.Attach (password_label, 0, 1, 0, 1);
- table.Attach (password_entry, 1, 2, 0, 1);
-
- table.Attach (show_password_check_button, 1, 2, 1, 2);
-
- VBox wrapper = new VBox (false, 9);
- wrapper.PackStart (table, true, false, 0);
-
- Add (wrapper);
-
- AddButton (cancel_button);
- AddButton (continue_button);
-
- break;
- }
-
- case PageType.Finished: {
- UrgencyHint = true;
-
- Header = "Your shared project is ready!";
- Description = "You can find it in your SparkleShare folder";
-
- // A button that opens the synced folder
- Button show_files_button = new Button ("Show Files…");
-
- show_files_button.Clicked += delegate {
- Controller.ShowFilesClicked ();
- };
-
- Button finish_button = new Button ("Finish");
-
- finish_button.Clicked += delegate {
- Controller.FinishPageCompleted ();
- };
-
-
- if (warnings.Length > 0) {
- Image warning_image = new Image (
- SparkleUIHelpers.GetIcon ("dialog-information", 24));
-
- Label warning_label = new Label (warnings [0]) {
- Xalign = 0,
- Wrap = true
- };
-
- HBox warning_layout = new HBox (false, 0);
- warning_layout.PackStart (warning_image, false, false, 15);
- warning_layout.PackStart (warning_label, true, true, 0);
-
- VBox warning_wrapper = new VBox (false, 0);
- warning_wrapper.PackStart (warning_layout, false, false, 0);
-
- Add (warning_wrapper);
-
- } else {
- Add (null);
- }
-
-
- AddButton (show_files_button);
- AddButton (finish_button);
-
- break;
- }
-
-
- case PageType.Tutorial: {
- switch (Controller.TutorialPageNumber) {
- case 1: {
- Header = "What's happening next?";
- 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 {
- Controller.TutorialSkipped ();
- };
-
- Button continue_button = new Button ("Continue");
- continue_button.Clicked += delegate {
- Controller.TutorialPageCompleted ();
- };
-
- Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-1.png");
-
- Add (slide);
-
- AddButton (skip_tutorial_button);
- AddButton (continue_button);
-
- break;
- }
-
- case 2: {
- Header = "Sharing files with others";
- 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 {
- Controller.TutorialPageCompleted ();
- };
-
- Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-2.png");
-
- Add (slide);
- AddButton (continue_button);
-
- break;
- }
-
- case 3: {
- Header = "The status icon helps you";
- 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 {
- Controller.TutorialPageCompleted ();
- };
-
- Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-3.png");
-
- Add (slide);
- AddButton (continue_button);
-
- break;
- }
-
- case 4: {
- 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).";
-
-
- Button finish_button = new Button ("Finish");
-
- VBox layout_vertical = new VBox (false, 0) {
- BorderWidth = 48
- };
-
- HBox layout_horizontal = new HBox (false, 6);
-
- Entry link_code_entry = new Entry () {
- Text = Program.Controller.CurrentUser.PublicKey,
- Sensitive = false
- };
-
- Button copy_button = new Button (" Copy ");
-
- CheckButton check_button = new CheckButton ("Add SparkleShare to startup items") {
- Active = true
- };
-
-
- check_button.Toggled += delegate {
- Controller.StartupItemChanged (check_button.Active);
- };
-
- copy_button.Clicked += delegate {
- Clipboard clip_board = Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
- clip_board.Text = link_code_entry.Text;
- };
-
- finish_button.Clicked += delegate {
- Controller.TutorialPageCompleted ();
- };
-
-
- layout_horizontal.PackStart (link_code_entry, true, true, 0);
- layout_horizontal.PackStart (copy_button, false, false, 0);
-
- layout_vertical.PackStart (new Label (""), true, true, 0);
- layout_vertical.PackStart (layout_horizontal, false, false, 0);
- layout_vertical.PackStart (new Label (""), true, true, 18);
-
- Add (layout_vertical);
-
- AddOption (check_button);
- AddButton (finish_button);
-
- break;
- }
- }
-
- break;
- }
- }
-
+ ShowPage (type, warnings);
ShowAll ();
});
};
}
+
+
+ public void ShowPage (PageType type, string [] warnings)
+ {
+ if (type == PageType.Setup) {
+ Header = "Welcome to SparkleShare!";
+ Description = "First off, what's your name and email?\nThis information is only visible to team members.";
+
+ Table table = new Table (2, 3, true) {
+ RowSpacing = 6,
+ ColumnSpacing = 6
+ };
+
+ Label name_label = new Label ("" + "Full Name:" + "") {
+ UseMarkup = true,
+ Xalign = 1
+ };
+
+ Entry name_entry = new Entry () {
+ Xalign = 0,
+ ActivatesDefault = true
+ };
+
+ UnixUserInfo user_info = UnixUserInfo.GetRealUser ();
+
+ if (user_info != null && user_info.RealName != null)
+ name_entry.Text = user_info.RealName.TrimEnd (",".ToCharArray ());
+
+ Entry email_entry = new Entry () {
+ Xalign = 0,
+ ActivatesDefault = true
+ };
+
+ Label email_label = new Label ("" + "Email:" + "") {
+ UseMarkup = true,
+ Xalign = 1
+ };
+
+ table.Attach (name_label, 0, 1, 0, 1);
+ table.Attach (name_entry, 1, 2, 0, 1);
+ table.Attach (email_label, 0, 1, 1, 2);
+ table.Attach (email_entry, 1, 2, 1, 2);
+
+ VBox wrapper = new VBox (false, 9);
+ wrapper.PackStart (table, true, false, 0);
+
+ Button cancel_button = new Button ("Cancel");
+ Button continue_button = new Button ("Continue") { Sensitive = false };
+
+
+ Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) {
+ Application.Invoke (delegate { continue_button.Sensitive = button_enabled; });
+ };
+
+ name_entry.Changed += delegate { Controller.CheckSetupPage (name_entry.Text, email_entry.Text); };
+ email_entry.Changed += delegate { Controller.CheckSetupPage (name_entry.Text, email_entry.Text); };
+ cancel_button.Clicked += delegate { Controller.SetupPageCancelled (); };
+
+ continue_button.Clicked += delegate {
+ Controller.SetupPageCompleted (name_entry.Text, email_entry.Text);
+ };
+
+
+ AddButton (cancel_button);
+ AddButton (continue_button);
+ Add (wrapper);
+
+ Controller.CheckSetupPage (name_entry.Text, email_entry.Text);
+ }
+
+ if (type == PageType.Add) {
+ Header = "Where's your project hosted?";
+
+ VBox layout_vertical = new VBox (false, 12);
+ HBox layout_fields = new HBox (true, 12);
+ VBox layout_address = new VBox (true, 0);
+ VBox layout_path = new VBox (true, 0);
+
+ ListStore store = new ListStore (typeof (Gdk.Pixbuf), typeof (string), typeof (SparklePlugin));
+
+ SparkleTreeView tree = new SparkleTreeView (store) { HeadersVisible = false };
+ ScrolledWindow scrolled_window = new ScrolledWindow ();
+ scrolled_window.AddWithViewport (tree);
+
+ // Icon column
+ tree.AppendColumn ("Icon", new Gtk.CellRendererPixbuf (), "pixbuf", 0);
+ tree.Columns [0].Cells [0].Xpad = 6;
+
+ // Service column
+ TreeViewColumn service_column = new TreeViewColumn () { Title = "Service" };
+ CellRendererText service_cell = new CellRendererText () { Ypad = 4 };
+ service_column.PackStart (service_cell, true);
+ service_column.SetCellDataFunc (service_cell, new TreeCellDataFunc (RenderServiceColumn));
+
+ foreach (SparklePlugin plugin in Controller.Plugins) {
+ store.AppendValues (new Gdk.Pixbuf (plugin.ImagePath),
+ "" + plugin.Name + "\n" +
+ "" +
+ plugin.Description + "" +
+ "", plugin);
+ }
+
+ tree.AppendColumn (service_column);
+
+ Entry address_entry = new Entry () {
+ Text = Controller.PreviousAddress,
+ Sensitive = (Controller.SelectedPlugin.Address == null),
+ ActivatesDefault = true
+ };
+
+ Entry path_entry = new Entry () {
+ Text = Controller.PreviousPath,
+ Sensitive = (Controller.SelectedPlugin.Path == null),
+ ActivatesDefault = true
+ };
+
+ Label address_example = new Label () {
+ Xalign = 0,
+ UseMarkup = true,
+ Markup = "" + Controller.SelectedPlugin.AddressExample + ""
+ };
+
+ Label path_example = new Label () {
+ Xalign = 0,
+ UseMarkup = true,
+ Markup = "" + Controller.SelectedPlugin.PathExample + ""
+ };
+
+
+ // Select the first plugin by default
+ TreeSelection default_selection = tree.Selection;
+ TreePath default_path = new TreePath ("0");
+ default_selection.SelectPath (default_path);
+ Controller.SelectedPluginChanged (0);
+
+ Controller.ChangeAddressFieldEvent += delegate (string text,
+ string example_text, FieldState state) {
+
+ Application.Invoke (delegate {
+ address_entry.Text = text;
+ address_entry.Sensitive = (state == FieldState.Enabled);
+ address_example.Markup = "" + example_text + "";
+ });
+ };
+
+ Controller.ChangePathFieldEvent += delegate (string text,
+ string example_text, FieldState state) {
+
+ Application.Invoke (delegate {
+ path_entry.Text = text;
+ path_entry.Sensitive = (state == FieldState.Enabled);
+ path_example.Markup = "" + example_text + "";
+ });
+ };
+
+ Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1);
+
+ // Update the address field text when the selection changes
+ tree.CursorChanged += delegate (object sender, EventArgs e) {
+ Controller.SelectedPluginChanged (tree.SelectedRow);
+ // TODO: Scroll to selected row when using arrow keys
+ };
+
+ tree.Model.Foreach (new TreeModelForeachFunc (delegate (TreeModel model,
+ TreePath path, TreeIter iter) {
+
+ string address;
+
+ try {
+ address = (model.GetValue (iter, 2) as SparklePlugin).Address;
+
+ } catch (NullReferenceException) {
+ address = "";
+ }
+
+ if (!string.IsNullOrEmpty (address) &&
+ address.Equals (Controller.PreviousAddress)) {
+
+ tree.SetCursor (path, service_column, false);
+ SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2);
+
+ if (plugin.Address != null) {
+ address_entry.Sensitive = false;}
+
+ if (plugin.Path != null)
+ path_entry.Sensitive = false;
+
+ // TODO: Scroll to the selection
+
+ return true;
+ } else {
+ return false;
+ }
+ }));
+
+
+ address_entry.Changed += delegate {
+ Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow);
+ };
+
+ layout_address.PackStart (new Label () {
+ Markup = "" + "Address:" + "",
+ Xalign = 0
+ }, true, true, 0);
+
+ layout_address.PackStart (address_entry, false, false, 0);
+ layout_address.PackStart (address_example, false, false, 0);
+
+ path_entry.Changed += delegate {
+ Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow);
+ };
+
+ layout_path.PackStart (new Label () {
+ Markup = "" + "Remote Path:" + "",
+ Xalign = 0
+ }, true, true, 0);
+
+ layout_path.PackStart (path_entry, false, false, 0);
+ layout_path.PackStart (path_example, false, false, 0);
+
+ layout_fields.PackStart (layout_address);
+ layout_fields.PackStart (layout_path);
+
+ layout_vertical.PackStart (new Label (""), false, false, 0);
+ layout_vertical.PackStart (scrolled_window, true, true, 0);
+ layout_vertical.PackStart (layout_fields, false, false, 0);
+
+ Add (layout_vertical);
+
+ // Cancel button
+ Button cancel_button = new Button ("Cancel");
+ Button add_button = new Button ("Add") { Sensitive = false };
+
+ cancel_button.Clicked += delegate { Controller.PageCancelled (); };
+
+ add_button.Clicked += delegate {
+ Controller.AddPageCompleted (address_entry.Text, path_entry.Text);
+ };
+
+ Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) {
+ Application.Invoke (delegate {
+ add_button.Sensitive = button_enabled;
+ });
+ };
+
+
+ CheckButton check_button = new CheckButton ("Fetch prior history") { Active = false };
+
+ check_button.Toggled += delegate { Controller.HistoryItemChanged (check_button.Active); };
+
+ AddOption (check_button);
+ AddButton (cancel_button);
+ AddButton (add_button);
+
+ Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1);
+ }
+
+ if (type == PageType.Invite) {
+ Header = "You've received an invite!";
+ Description = "Do you want to add this project to SparkleShare?";
+
+ Table table = new Table (2, 3, true) {
+ RowSpacing = 6,
+ ColumnSpacing = 6
+ };
+
+ Label address_label = new Label ("Address:") { Xalign = 1 };
+ Label path_label = new Label ("Remote Path:") { Xalign = 1 };
+
+ Label address_value = new Label ("" + Controller.PendingInvite.Address + "") {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ Label path_value = new Label ("" + Controller.PendingInvite.RemotePath + "") {
+ UseMarkup = true,
+ Xalign = 0
+ };
+
+ table.Attach (address_label, 0, 1, 0, 1);
+ table.Attach (address_value, 1, 2, 0, 1);
+ table.Attach (path_label, 0, 1, 1, 2);
+ table.Attach (path_value, 1, 2, 1, 2);
+
+ VBox wrapper = new VBox (false, 9);
+ wrapper.PackStart (table, true, false, 0);
+
+ Button cancel_button = new Button ("Cancel");
+ Button add_button = new Button ("Add");
+
+
+ cancel_button.Clicked += delegate { Controller.PageCancelled (); };
+ add_button.Clicked += delegate { Controller.InvitePageCompleted (); };
+
+
+ AddButton (cancel_button);
+ AddButton (add_button);
+ Add (wrapper);
+ }
+
+ if (type == PageType.Syncing) {
+ Header = String.Format ("Adding project ‘{0}’…", Controller.SyncingFolder);
+ Description = "This may take a while for large projects.\nIsn't it coffee-o'clock?";
+
+ ProgressBar progress_bar = new ProgressBar ();
+ progress_bar.Fraction = Controller.ProgressBarPercentage / 100;
+
+ Button cancel_button = new Button () { Label = "Cancel" };
+ Button finish_button = new Button ("Finish") { Sensitive = false };
+
+
+ Controller.UpdateProgressBarEvent += delegate (double percentage) {
+ Application.Invoke (delegate { progress_bar.Fraction = percentage / 100; });
+ };
+
+ cancel_button.Clicked += delegate { Controller.SyncingCancelled (); };
+
+
+ VBox bar_wrapper = new VBox (false, 0);
+ bar_wrapper.PackStart (progress_bar, false, false, 21);
+
+ Add (bar_wrapper);
+ AddButton (cancel_button);
+ AddButton (finish_button);
+ }
+
+ if (type == PageType.Error) {
+ Header = "Oops! Something went wrong" + "…";
+
+ VBox points = new VBox (false, 0);
+ Image list_point_one = new Image (SparkleUIHelpers.GetIcon ("list-point", 16));
+ Image list_point_two = new Image (SparkleUIHelpers.GetIcon ("list-point", 16));
+ Image list_point_three = new Image (SparkleUIHelpers.GetIcon ("list-point", 16));
+
+ Label label_one = new Label () {
+ Markup = "" + Controller.PreviousUrl + " is the address we've compiled. " +
+ "Does this look alright?",
+ Wrap = true,
+ Xalign = 0
+ };
+
+ Label label_two = new Label () {
+ Text = "Do you have access rights to this remote project?",
+ Wrap = true,
+ Xalign = 0
+ };
+
+ points.PackStart (new Label ("Please check the following:") { Xalign = 0 }, false, false, 6);
+
+ HBox point_one = new HBox (false, 0);
+ point_one.PackStart (list_point_one, false, false, 0);
+ point_one.PackStart (label_one, true, true, 12);
+ points.PackStart (point_one, false, false, 12);
+
+ HBox point_two = new HBox (false, 0);
+ point_two.PackStart (list_point_two, false, false, 0);
+ point_two.PackStart (label_two, true, true, 12);
+ points.PackStart (point_two, false, false, 12);
+
+ if (warnings.Length > 0) {
+ string warnings_markup = "";
+
+ foreach (string warning in warnings)
+ warnings_markup += "\n" + warning + "";
+
+ Label label_three = new Label () {
+ Markup = "Here's the raw error message:" + warnings_markup,
+ Wrap = true,
+ Xalign = 0
+ };
+
+ HBox point_three = new HBox (false, 0);
+ point_three.PackStart (list_point_three, false, false, 0);
+ point_three.PackStart (label_three, true, true, 12);
+ points.PackStart (point_three, false, false, 12);
+ }
+
+ points.PackStart (new Label (""), true, true, 0);
+
+ Button cancel_button = new Button ("Cancel");
+ Button try_again_button = new Button ("Try Again…") { Sensitive = true };
+
+
+ cancel_button.Clicked += delegate { Controller.PageCancelled (); };
+ try_again_button.Clicked += delegate { Controller.ErrorPageCompleted (); };
+
+
+ AddButton (cancel_button);
+ AddButton (try_again_button);
+ Add (points);
+ }
+
+ if (type == PageType.CryptoSetup || type == PageType.CryptoPassword) {
+ if (type == PageType.CryptoSetup) {
+ Header = "Set up file encryption";
+ Description = "Please a provide a strong password that you don't use elsewhere below:";
+
+ } else {
+ Header = "This project contains encrypted files";
+ Description = "Please enter the password to see their contents.";
+ }
+
+ Label password_label = new Label ("" + "Password:" + "") {
+ UseMarkup = true,
+ Xalign = 1
+ };
+
+ Entry password_entry = new Entry () {
+ Xalign = 0,
+ Visibility = false,
+ ActivatesDefault = true
+ };
+
+ CheckButton show_password_check_button = new CheckButton ("Show password") {
+ Active = false,
+ Xalign = 0,
+ };
+
+ Table table = new Table (2, 3, true) {
+ RowSpacing = 6,
+ ColumnSpacing = 6
+ };
+
+ table.Attach (password_label, 0, 1, 0, 1);
+ table.Attach (password_entry, 1, 2, 0, 1);
+
+ table.Attach (show_password_check_button, 1, 2, 1, 2);
+
+ VBox wrapper = new VBox (false, 9);
+ wrapper.PackStart (table, true, false, 0);
+
+ Image warning_image = new Image (
+ SparkleUIHelpers.GetIcon ("dialog-information", 24));
+
+ Label warning_label = new Label () {
+ Xalign = 0,
+ Wrap = true,
+ Text = "This password can't be changed later, and your files can't be recovered if it's forgotten."
+ };
+
+ HBox warning_layout = new HBox (false, 0);
+ warning_layout.PackStart (warning_image, false, false, 15);
+ warning_layout.PackStart (warning_label, true, true, 0);
+
+ VBox warning_wrapper = new VBox (false, 0);
+ warning_wrapper.PackStart (warning_layout, false, false, 15);
+
+ if (type == PageType.CryptoSetup)
+ wrapper.PackStart (warning_wrapper, false, false, 0);
+
+ Button cancel_button = new Button ("Cancel");
+ Button continue_button = new Button ("Continue") { Sensitive = false };
+
+
+ Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
+ Application.Invoke (delegate { continue_button.Sensitive = button_enabled; });
+ };
+
+ Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) {
+ Application.Invoke (delegate { continue_button.Sensitive = button_enabled; });
+ };
+
+ show_password_check_button.Toggled += delegate {
+ password_entry.Visibility = !password_entry.Visibility;
+ };
+
+ password_entry.Changed += delegate {
+ if (type == PageType.CryptoSetup)
+ Controller.CheckCryptoSetupPage (password_entry.Text);
+ else
+ Controller.CheckCryptoPasswordPage (password_entry.Text);
+ };
+
+ cancel_button.Clicked += delegate { Controller.CryptoPageCancelled (); };
+
+ continue_button.Clicked += delegate {
+ if (type == PageType.CryptoSetup)
+ Controller.CryptoSetupPageCompleted (password_entry.Text);
+ else
+ Controller.CryptoPasswordPageCompleted (password_entry.Text);
+ };
+
+
+ Add (wrapper);
+
+ AddButton (cancel_button);
+ AddButton (continue_button);
+ }
+
+ if (type == PageType.Finished) {
+ Header = "Your shared project is ready!";
+ Description = "You can find it in your SparkleShare folder";
+
+ UrgencyHint = true;
+
+ Button show_files_button = new Button ("Show Files…");
+ Button finish_button = new Button ("Finish");
+
+
+ show_files_button.Clicked += delegate { Controller.ShowFilesClicked (); };
+ finish_button.Clicked += delegate { Controller.FinishPageCompleted (); };
+
+
+ if (warnings.Length > 0) {
+ Image warning_image = new Image (SparkleUIHelpers.GetIcon ("dialog-information", 24));
+
+ Label warning_label = new Label (warnings [0]) {
+ Xalign = 0,
+ Wrap = true
+ };
+
+ HBox warning_layout = new HBox (false, 0);
+ warning_layout.PackStart (warning_image, false, false, 15);
+ warning_layout.PackStart (warning_label, true, true, 0);
+
+ VBox warning_wrapper = new VBox (false, 0);
+ warning_wrapper.PackStart (warning_layout, false, false, 0);
+
+ Add (warning_wrapper);
+
+ } else {
+ Add (null);
+ }
+
+ AddButton (show_files_button);
+ AddButton (finish_button);
+ }
+
+ if (type == PageType.Tutorial) {
+ switch (Controller.TutorialPageNumber) {
+ case 1: {
+ Header = "What's happening next?";
+ Description = "SparkleShare creates a special folder on your computer " +
+ "that will keep track of your projects.";
+
+ Button skip_tutorial_button = new Button ("Skip Tutorial");
+ Button continue_button = new Button ("Continue");
+
+ skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped (); };
+ continue_button.Clicked += delegate { Controller.TutorialPageCompleted (); };
+
+ AddButton (skip_tutorial_button);
+ AddButton (continue_button);
+
+ break;
+ }
+
+ case 2: {
+ Header = "Sharing files with others";
+ 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 { Controller.TutorialPageCompleted (); };
+ AddButton (continue_button);
+
+ break;
+ }
+
+ case 3: {
+ Header = "The status icon helps you";
+ 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 { Controller.TutorialPageCompleted (); };
+ AddButton (continue_button);
+
+ break;
+ }
+
+ case 4: {
+ 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).";
+
+ Button finish_button = new Button ("Finish");
+ VBox layout_vertical = new VBox (false, 0) { BorderWidth = 48 };
+ HBox layout_horizontal = new HBox (false, 6);
+
+ Entry link_code_entry = new Entry () {
+ Text = Program.Controller.CurrentUser.PublicKey,
+ Sensitive = false
+ };
+
+ Button copy_button = new Button (" Copy ");
+
+ CheckButton check_button = new CheckButton ("Add SparkleShare to startup items");
+ check_button.Active = true;
+
+
+ copy_button.Clicked += delegate {
+ Clipboard clip_board = Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
+ clip_board.Text = link_code_entry.Text;
+ };
+
+ check_button.Toggled += delegate { Controller.StartupItemChanged (check_button.Active); };
+ finish_button.Clicked += delegate { Controller.TutorialPageCompleted (); };
+
+
+ layout_horizontal.PackStart (link_code_entry, true, true, 0);
+ layout_horizontal.PackStart (copy_button, false, false, 0);
+
+ layout_vertical.PackStart (new Label (""), true, true, 0);
+ layout_vertical.PackStart (layout_horizontal, false, false, 0);
+ layout_vertical.PackStart (new Label (""), true, true, 18);
+
+ Add (layout_vertical);
+
+ AddOption (check_button);
+ AddButton (finish_button);
+
+ break;
+ }
+ }
+
+ if (Controller.TutorialPageNumber < 4) {
+ Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-" + Controller.TutorialPageNumber + ".png");
+ Add (slide);
+ }
+ }
+ }
private void RenderServiceColumn (TreeViewColumn column, CellRenderer cell,
@@ -864,26 +695,25 @@ namespace SparkleShare {
(cell as CellRendererText).Markup = markup;
}
- }
+
+
+ private class SparkleTreeView : TreeView {
+ public int SelectedRow
+ {
+ get {
+ TreeIter iter;
+ TreeModel model;
- public class SparkleTreeView : TreeView {
-
- public int SelectedRow
- {
- get {
- TreeIter iter;
- TreeModel model;
-
- Selection.GetSelected (out model, out iter);
-
- return int.Parse (model.GetPath (iter).ToString ());
+ Selection.GetSelected (out model, out iter);
+ return int.Parse (model.GetPath (iter).ToString ());
+ }
}
- }
- public SparkleTreeView (ListStore store) : base (store)
- {
+ public SparkleTreeView (ListStore store) : base (store)
+ {
+ }
}
}
}
diff --git a/SparkleShare/Mac/SparkleSetup.cs b/SparkleShare/Mac/SparkleSetup.cs
index 42cc167a..2d753d0f 100755
--- a/SparkleShare/Mac/SparkleSetup.cs
+++ b/SparkleShare/Mac/SparkleSetup.cs
@@ -496,6 +496,14 @@ namespace SparkleShare {
};
+ Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) {
+ Program.Controller.Invoke (() => { ContinueButton.Enabled = button_enabled; });
+ };
+
+ Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
+ Program.Controller.Invoke (() => { ContinueButton.Enabled = button_enabled; });
+ };
+
ShowPasswordCheckButton.Activated += delegate {
if (PasswordTextField.Superview == ContentView) {
PasswordTextField.RemoveFromSuperview ();
@@ -525,14 +533,6 @@ namespace SparkleShare {
Controller.CheckCryptoPasswordPage (PasswordTextField.StringValue);
};
- Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) {
- Program.Controller.Invoke (() => { ContinueButton.Enabled = button_enabled; });
- };
-
- Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
- Program.Controller.Invoke (() => { ContinueButton.Enabled = button_enabled; });
- };
-
ContinueButton.Activated += delegate {
if (type == PageType.CryptoSetup)
Controller.CryptoSetupPageCompleted (PasswordTextField.StringValue);
@@ -611,7 +611,6 @@ namespace SparkleShare {
}
switch (Controller.TutorialPageNumber) {
-
case 1: {
Header = "What's happening next?";
Description = "SparkleShare creates a special folder on your computer " +