From 0894d20e47cca3e36c62a009693839b3831bddb2 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Mon, 21 May 2012 00:57:17 +0100 Subject: [PATCH] linux setup: implement UI for encryption --- SparkleShare/Linux/SparkleSetup.cs | 173 ++++++++++++++++++++++- SparkleShare/Linux/SparkleSetupWindow.cs | 5 +- SparkleShare/Mac/SparkleSetup.cs | 2 +- 3 files changed, 173 insertions(+), 7 deletions(-) diff --git a/SparkleShare/Linux/SparkleSetup.cs b/SparkleShare/Linux/SparkleSetup.cs index 7dcd84a4..82b2dcff 100755 --- a/SparkleShare/Linux/SparkleSetup.cs +++ b/SparkleShare/Linux/SparkleSetup.cs @@ -433,7 +433,7 @@ namespace SparkleShare { (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, 0); + bar_wrapper.PackStart (this.progress_bar, false, false, 15); Add (bar_wrapper); @@ -509,7 +509,172 @@ namespace SparkleShare { break; } + + case PageType.CryptoSetup: { + Header = "Set up file encryption"; + Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below."; + + Label password_label = new Label ("" + _("Password:") + "") { + UseMarkup = true, + Xalign = 1 + }; + + Entry password_entry = new Entry () { + Xalign = 0, + Visibility = false + }; + + 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 + }; + + 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; @@ -540,7 +705,7 @@ namespace SparkleShare { if (warnings.Length > 0) { Image warning_image = new Image ( - SparkleUIHelpers.GetIcon ("dialog-info", 24) + SparkleUIHelpers.GetIcon ("dialog-information", 24) ); Label warning_label = new Label (warnings [0]) { @@ -549,8 +714,8 @@ namespace SparkleShare { }; HBox warning_layout = new HBox (false, 0); - warning_layout.PackStart (warning_image, false, false, 0); - warning_layout.PackStart (warning_label, true, true, 15); + 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); diff --git a/SparkleShare/Linux/SparkleSetupWindow.cs b/SparkleShare/Linux/SparkleSetupWindow.cs index 0ad8b06f..88a7eadc 100755 --- a/SparkleShare/Linux/SparkleSetupWindow.cs +++ b/SparkleShare/Linux/SparkleSetupWindow.cs @@ -146,9 +146,10 @@ namespace SparkleShare { if (!string.IsNullOrEmpty (Description)) { Label description = new Label (Description) { Xalign = 0, - Wrap = true + LineWrap = true, + LineWrapMode = Pango.WrapMode.WordChar }; - + layout_vertical.PackStart (description, false, false, 21); } diff --git a/SparkleShare/Mac/SparkleSetup.cs b/SparkleShare/Mac/SparkleSetup.cs index 77a6ea5e..518d0eb0 100755 --- a/SparkleShare/Mac/SparkleSetup.cs +++ b/SparkleShare/Mac/SparkleSetup.cs @@ -610,7 +610,7 @@ namespace SparkleShare { case PageType.CryptoSetup: { Header = "Set up file encryption"; - Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide a password below:"; + Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below:"; PasswordLabel = new NSTextField () {