From 11745752a5c9bd47a8e17acfc601d98904d93f8d Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 25 Dec 2011 19:01:33 +0100 Subject: [PATCH] setup: prettier form and code cleanup --- SparkleShare/SparkleSetup.cs | 148 ++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 71 deletions(-) diff --git a/SparkleShare/SparkleSetup.cs b/SparkleShare/SparkleSetup.cs index 68f37a8c..26a9b903 100755 --- a/SparkleShare/SparkleSetup.cs +++ b/SparkleShare/SparkleSetup.cs @@ -34,15 +34,6 @@ namespace SparkleShare { private string SecondaryTextColor; private string SecondaryTextColorSelected; - private Entry NameEntry; - private Entry EmailEntry; - private SparkleEntry AddressEntry; - private SparkleEntry PathEntry; - - private Button NextButton; - private Button SyncButton; - - private Table Table; private ProgressBar progress_bar = new ProgressBar (); @@ -76,56 +67,68 @@ namespace 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."; - Table = new Table (4, 2, true) { - RowSpacing = 6 + + Table table = new Table (2, 3, true) { + RowSpacing = 6, + ColumnSpacing = 6 }; Label name_label = new Label ("" + _("Full Name:") + "") { UseMarkup = true, - Xalign = 0 + Xalign = 1 }; - NameEntry = new Entry (Controller.GuessedUserName); - NameEntry.Changed += delegate { - Controller.CheckSetupPage (NameEntry.Text, EmailEntry.Text); + Entry name_entry = new Entry (Controller.GuessedUserName) { + Xalign = 0 }; - EmailEntry = new Entry (Controller.GuessedUserEmail); - EmailEntry.Changed += delegate { - Controller.CheckSetupPage (NameEntry.Text, EmailEntry.Text); + Entry email_entry = new Entry (Controller.GuessedUserEmail) { + Xalign = 0 + }; + + 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 = 0 + Xalign = 1 }; - Table.Attach (name_label, 0, 1, 0, 1); - Table.Attach (NameEntry, 1, 2, 0, 1); - Table.Attach (email_label, 0, 1, 1, 2); - Table.Attach (EmailEntry, 1, 2, 1, 2); + 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); - NextButton = new Button (_("Continue")) { + Button continue_button = new Button (_("Continue")) { Sensitive = false }; - NextButton.Clicked += delegate (object o, EventArgs args) { - string full_name = NameEntry.Text; - string email = EmailEntry.Text; + continue_button.Clicked += delegate (object o, EventArgs args) { + string full_name = name_entry.Text; + string email = email_entry.Text; Controller.SetupPageCompleted (full_name, email); }; - AddButton (NextButton); - Add (Table); - + AddButton (continue_button); + Add (wrapper); + + Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { - NextButton.Sensitive = button_enabled; + continue_button.Sensitive = button_enabled; }); }; - Controller.CheckSetupPage (NameEntry.Text, EmailEntry.Text); + Controller.CheckSetupPage (name_entry.Text, email_entry.Text); break; } @@ -169,8 +172,8 @@ namespace SparkleShare { tree.AppendColumn (service_column); - PathEntry = new SparkleEntry (); - AddressEntry = new SparkleEntry (); + SparkleEntry path_entry = new SparkleEntry (); + SparkleEntry address_entry = new SparkleEntry (); // Select the first plugin by default @@ -183,18 +186,18 @@ namespace SparkleShare { string example_text, FieldState state) { Application.Invoke (delegate { - AddressEntry.Text = text; - AddressEntry.Sensitive = (state == FieldState.Enabled); + address_entry.Text = text; + address_entry.Sensitive = (state == FieldState.Enabled); if (string.IsNullOrEmpty (example_text)) - AddressEntry.ExampleText = null; + address_entry.ExampleText = null; else - AddressEntry.ExampleText = example_text; + address_entry.ExampleText = example_text; if (string.IsNullOrEmpty (text)) - AddressEntry.ExampleTextActive = true; + address_entry.ExampleTextActive = true; else - AddressEntry.ExampleTextActive = false; + address_entry.ExampleTextActive = false; }); }; @@ -202,18 +205,18 @@ namespace SparkleShare { string example_text, FieldState state) { Application.Invoke (delegate { - PathEntry.Text = text; - PathEntry.Sensitive = (state == FieldState.Enabled); + path_entry.Text = text; + path_entry.Sensitive = (state == FieldState.Enabled); if (string.IsNullOrEmpty (example_text)) - PathEntry.ExampleText = null; + path_entry.ExampleText = null; else - PathEntry.ExampleText = example_text; + path_entry.ExampleText = example_text; if (string.IsNullOrEmpty (text)) - PathEntry.ExampleTextActive = true; + path_entry.ExampleTextActive = true; else - PathEntry.ExampleTextActive = false; + path_entry.ExampleTextActive = false; }); }; @@ -242,10 +245,10 @@ namespace SparkleShare { SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2); if (plugin.Address != null) { - AddressEntry.Sensitive = false;} + address_entry.Sensitive = false;} if (plugin.Path != null) - PathEntry.Sensitive = false; + path_entry.Sensitive = false; // TODO: Scroll to the selection @@ -255,43 +258,46 @@ namespace SparkleShare { } })); - AddressEntry.Completion = new EntryCompletion(); + address_entry.Completion = new EntryCompletion(); ListStore server_store = new ListStore (typeof (string)); foreach (string host in Program.Controller.PreviousHosts) server_store.AppendValues (host); - AddressEntry.Completion.Model = server_store; - AddressEntry.Completion.TextColumn = 0; + address_entry.Completion.Model = server_store; + address_entry.Completion.TextColumn = 0; - AddressEntry.Changed += delegate { - Controller.CheckAddPage (AddressEntry.Text, PathEntry.Text, tree.SelectedRow); + 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); + Markup = "" + _("Address") + "", + Xalign = 0 + }, true, true, 0); - layout_address.PackStart (AddressEntry, true, true, 0); + layout_address.PackStart (address_entry, true, true, 0); - PathEntry.Completion = new EntryCompletion(); + path_entry.Completion = new EntryCompletion(); ListStore folder_store = new ListStore (typeof (string)); //foreach (string host in Program.Controller.FolderPaths) // folder_store.AppendValues (host); - PathEntry.Completion.Model = folder_store; - PathEntry.Completion.TextColumn = 0; + path_entry.Completion.Model = folder_store; + path_entry.Completion.TextColumn = 0; - PathEntry.Changed += delegate { - Controller.CheckAddPage (AddressEntry.Text, PathEntry.Text, tree.SelectedRow); + 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 (PathEntry, true, true, 0); + layout_path.PackStart (new Label () { + Markup = "" + _("Remote Path") + "", + Xalign = 0 + }, true, true, 0); + + layout_path.PackStart (path_entry, true, true, 0); layout_fields.PackStart (layout_address); layout_fields.PackStart (layout_path); @@ -310,19 +316,19 @@ namespace SparkleShare { }; // Sync button - SyncButton = new Button (_("Add")); + Button add_button = new Button (_("Add")); - SyncButton.Clicked += delegate { - string server = AddressEntry.Text; - string folder_name = PathEntry.Text; + add_button.Clicked += delegate { + string server = address_entry.Text; + string folder_name = path_entry.Text; Controller.AddPageCompleted (server, folder_name); }; AddButton (cancel_button); - AddButton (SyncButton); + AddButton (add_button); - Controller.CheckAddPage (AddressEntry.Text, PathEntry.Text, tree.SelectedRow); + Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow); break; }