linux setup: clean up

This commit is contained in:
Hylke Bons 2012-12-02 15:26:20 +00:00
parent c748db8be0
commit b92d3f89e9
2 changed files with 651 additions and 822 deletions

View file

@ -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 {
@ -48,9 +44,16 @@ namespace SparkleShare {
Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
Application.Invoke (delegate {
Reset ();
ShowPage (type, warnings);
ShowAll ();
});
};
}
switch (type) {
case PageType.Setup: {
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.";
@ -79,14 +82,6 @@ namespace SparkleShare {
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 ("<b>" + "Email:" + "</b>") {
UseMarkup = true,
Xalign = 1
@ -101,36 +96,30 @@ namespace SparkleShare {
wrapper.PackStart (table, true, false, 0);
Button cancel_button = new Button ("Cancel");
Button continue_button = new Button ("Continue") { Sensitive = false };
cancel_button.Clicked += delegate {
Controller.SetupPageCancelled ();
Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) {
Application.Invoke (delegate { continue_button.Sensitive = button_enabled; });
};
Button continue_button = new Button ("Continue") {
Sensitive = false
};
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.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: {
if (type == PageType.Add) {
Header = "Where's your project hosted?";
VBox layout_vertical = new VBox (false, 12);
@ -138,9 +127,7 @@ namespace SparkleShare {
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));
ListStore store = new ListStore (typeof (Gdk.Pixbuf), typeof (string), typeof (SparklePlugin));
SparkleTreeView tree = new SparkleTreeView (store) { HeadersVisible = false };
ScrolledWindow scrolled_window = new ScrolledWindow ();
@ -157,13 +144,11 @@ namespace SparkleShare {
service_column.SetCellDataFunc (service_cell, new TreeCellDataFunc (RenderServiceColumn));
foreach (SparklePlugin plugin in Controller.Plugins) {
store.AppendValues (
new Gdk.Pixbuf (plugin.ImagePath),
store.AppendValues (new Gdk.Pixbuf (plugin.ImagePath),
"<span size=\"small\"><b>" + plugin.Name + "</b>\n" +
"<span fgcolor=\"" + SecondaryTextColorSelected + "\">" +
plugin.Description + "</span>" +
"</span>",
plugin);
"</span>", plugin);
}
tree.AppendColumn (service_column);
@ -299,14 +284,9 @@ namespace SparkleShare {
// Cancel button
Button cancel_button = new Button ("Cancel");
Button add_button = new Button ("Add") { Sensitive = false };
cancel_button.Clicked += delegate {
Controller.PageCancelled ();
};
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);
@ -319,40 +299,28 @@ namespace SparkleShare {
};
CheckButton check_button = new CheckButton ("Fetch prior history") {
Active = false
};
CheckButton check_button = new CheckButton ("Fetch prior history") { Active = false };
check_button.Toggled += delegate {
Controller.HistoryItemChanged (check_button.Active);
};
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: {
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_label = new Label ("Address:") { Xalign = 1 };
Label path_label = new Label ("Remote Path:") { Xalign = 1 };
Label address_value = new Label ("<b>" + Controller.PendingInvite.Address + "</b>") {
UseMarkup = true,
@ -373,65 +341,45 @@ namespace SparkleShare {
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 ();
};
cancel_button.Clicked += delegate { Controller.PageCancelled (); };
add_button.Clicked += delegate { Controller.InvitePageCompleted (); };
AddButton (cancel_button);
AddButton (add_button);
Add (wrapper);
break;
}
case PageType.Syncing: {
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?";
this.progress_bar.Fraction = Controller.ProgressBarPercentage / 100;
ProgressBar progress_bar = new ProgressBar ();
progress_bar.Fraction = Controller.ProgressBarPercentage / 100;
Button finish_button = new Button () {
Sensitive = false,
Label = "Finish"
};
Button cancel_button = new Button () { Label = "Cancel" };
Button finish_button = new Button ("Finish") { Sensitive = false };
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;
});
Application.Invoke (delegate { progress_bar.Fraction = percentage / 100; });
};
if (this.progress_bar.Parent != null)
(this.progress_bar.Parent as Container).Remove (this.progress_bar);
cancel_button.Clicked += delegate { Controller.SyncingCancelled (); };
VBox bar_wrapper = new VBox (false, 0);
bar_wrapper.PackStart (this.progress_bar, false, false, 15);
bar_wrapper.PackStart (progress_bar, false, false, 21);
Add (bar_wrapper);
break;
AddButton (cancel_button);
AddButton (finish_button);
}
case PageType.Error: {
if (type == PageType.Error) {
Header = "Oops! Something went wrong" + "…";
VBox points = new VBox (false, 0);
@ -485,30 +433,28 @@ namespace SparkleShare {
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 ();
};
Button try_again_button = new Button ("Try Again…") {
Sensitive = true
};
cancel_button.Clicked += delegate { Controller.PageCancelled (); };
try_again_button.Clicked += delegate { Controller.ErrorPageCompleted (); };
try_again_button.Clicked += delegate {
Controller.ErrorPageCompleted ();
};
AddButton (cancel_button);
AddButton (try_again_button);
Add (points);
break;
}
case PageType.CryptoSetup: {
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 ("<b>" + "Password:" + "</b>") {
UseMarkup = true,
Xalign = 1
@ -525,36 +471,6 @@ namespace SparkleShare {
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
@ -568,10 +484,8 @@ namespace SparkleShare {
VBox wrapper = new VBox (false, 9);
wrapper.PackStart (table, true, false, 0);
Image warning_image = new Image (
SparkleUIHelpers.GetIcon ("dialog-information", 24)
);
SparkleUIHelpers.GetIcon ("dialog-information", 24));
Label warning_label = new Label () {
Xalign = 0,
@ -586,35 +500,19 @@ namespace SparkleShare {
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 };
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 ("<b>" + "Password:" + "</b>") {
UseMarkup = true,
Xalign = 1
Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
Application.Invoke (delegate { continue_button.Sensitive = button_enabled; });
};
Entry password_entry = new Entry () {
Xalign = 0,
Visibility = false,
ActivatesDefault = true
};
CheckButton show_password_check_button = new CheckButton ("Show password") {
Active = false,
Xalign = 0
Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) {
Application.Invoke (delegate { continue_button.Sensitive = button_enabled; });
};
show_password_check_button.Toggled += delegate {
@ -622,74 +520,44 @@ namespace SparkleShare {
};
password_entry.Changed += delegate {
if (type == PageType.CryptoSetup)
Controller.CheckCryptoSetupPage (password_entry.Text);
else
Controller.CheckCryptoPasswordPage (password_entry.Text);
};
Button continue_button = new Button ("Continue") {
Sensitive = false
};
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);
};
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;
if (type == PageType.Finished) {
Header = "Your shared project is ready!";
Description = "You can find it in your SparkleShare folder";
// A button that opens the synced folder
UrgencyHint = true;
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 ();
};
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));
Image warning_image = new Image (SparkleUIHelpers.GetIcon ("dialog-information", 24));
Label warning_label = new Label (warnings [0]) {
Xalign = 0,
@ -709,15 +577,11 @@ namespace SparkleShare {
Add (null);
}
AddButton (show_files_button);
AddButton (finish_button);
break;
}
case PageType.Tutorial: {
if (type == PageType.Tutorial) {
switch (Controller.TutorialPageNumber) {
case 1: {
Header = "What's happening next?";
@ -725,18 +589,10 @@ namespace SparkleShare {
"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);
skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped (); };
continue_button.Clicked += delegate { Controller.TutorialPageCompleted (); };
AddButton (skip_tutorial_button);
AddButton (continue_button);
@ -750,13 +606,7 @@ namespace SparkleShare {
"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);
continue_button.Clicked += delegate { Controller.TutorialPageCompleted (); };
AddButton (continue_button);
break;
@ -768,13 +618,7 @@ namespace SparkleShare {
"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);
continue_button.Clicked += delegate { Controller.TutorialPageCompleted (); };
AddButton (continue_button);
break;
@ -785,13 +629,8 @@ namespace SparkleShare {
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
};
VBox layout_vertical = new VBox (false, 0) { BorderWidth = 48 };
HBox layout_horizontal = new HBox (false, 6);
Entry link_code_entry = new Entry () {
@ -801,23 +640,17 @@ namespace SparkleShare {
Button copy_button = new Button (" Copy ");
CheckButton check_button = new CheckButton ("Add SparkleShare to startup items") {
Active = true
};
CheckButton check_button = new CheckButton ("Add SparkleShare to startup items");
check_button.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 ();
};
check_button.Toggled += delegate { Controller.StartupItemChanged (check_button.Active); };
finish_button.Clicked += delegate { Controller.TutorialPageCompleted (); };
layout_horizontal.PackStart (link_code_entry, true, true, 0);
@ -836,13 +669,11 @@ namespace SparkleShare {
}
}
break;
if (Controller.TutorialPageNumber < 4) {
Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-" + Controller.TutorialPageNumber + ".png");
Add (slide);
}
}
ShowAll ();
});
};
}
@ -864,10 +695,9 @@ namespace SparkleShare {
(cell as CellRendererText).Markup = markup;
}
}
public class SparkleTreeView : TreeView {
private class SparkleTreeView : TreeView {
public int SelectedRow
{
@ -876,7 +706,6 @@ namespace SparkleShare {
TreeModel model;
Selection.GetSelected (out model, out iter);
return int.Parse (model.GetPath (iter).ToString ());
}
}
@ -886,4 +715,5 @@ namespace SparkleShare {
{
}
}
}
}

View file

@ -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 " +