setup: prettier form and code cleanup
This commit is contained in:
parent
87d6a476e1
commit
fca7752689
|
@ -34,15 +34,6 @@ namespace SparkleShare {
|
||||||
private string SecondaryTextColor;
|
private string SecondaryTextColor;
|
||||||
private string SecondaryTextColorSelected;
|
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 ();
|
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. " +
|
Description = "We'll need some info to mark your changes in the event log. " +
|
||||||
"Don't worry, this stays between you and your peers.";
|
"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 ("<b>" + _("Full Name:") + "</b>") {
|
Label name_label = new Label ("<b>" + _("Full Name:") + "</b>") {
|
||||||
UseMarkup = true,
|
UseMarkup = true,
|
||||||
Xalign = 0
|
Xalign = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
NameEntry = new Entry (Controller.GuessedUserName);
|
Entry name_entry = new Entry (Controller.GuessedUserName) {
|
||||||
NameEntry.Changed += delegate {
|
Xalign = 0
|
||||||
Controller.CheckSetupPage (NameEntry.Text, EmailEntry.Text);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EmailEntry = new Entry (Controller.GuessedUserEmail);
|
Entry email_entry = new Entry (Controller.GuessedUserEmail) {
|
||||||
EmailEntry.Changed += delegate {
|
Xalign = 0
|
||||||
Controller.CheckSetupPage (NameEntry.Text, EmailEntry.Text);
|
};
|
||||||
|
|
||||||
|
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>") {
|
Label email_label = new Label ("<b>" + _("Email:") + "</b>") {
|
||||||
UseMarkup = true,
|
UseMarkup = true,
|
||||||
Xalign = 0
|
Xalign = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
Table.Attach (name_label, 0, 1, 0, 1);
|
table.Attach (name_label, 0, 1, 0, 1);
|
||||||
Table.Attach (NameEntry, 1, 2, 0, 1);
|
table.Attach (name_entry, 1, 2, 0, 1);
|
||||||
Table.Attach (email_label, 0, 1, 1, 2);
|
table.Attach (email_label, 0, 1, 1, 2);
|
||||||
Table.Attach (EmailEntry, 1, 2, 1, 2);
|
table.Attach (email_entry, 1, 2, 1, 2);
|
||||||
|
|
||||||
NextButton = new Button (_("Continue")) {
|
VBox wrapper = new VBox (false, 9);
|
||||||
|
wrapper.PackStart (table, true, false, 0);
|
||||||
|
|
||||||
|
Button continue_button = new Button (_("Continue")) {
|
||||||
Sensitive = false
|
Sensitive = false
|
||||||
};
|
};
|
||||||
|
|
||||||
NextButton.Clicked += delegate (object o, EventArgs args) {
|
continue_button.Clicked += delegate (object o, EventArgs args) {
|
||||||
string full_name = NameEntry.Text;
|
string full_name = name_entry.Text;
|
||||||
string email = EmailEntry.Text;
|
string email = email_entry.Text;
|
||||||
|
|
||||||
Controller.SetupPageCompleted (full_name, email);
|
Controller.SetupPageCompleted (full_name, email);
|
||||||
};
|
};
|
||||||
|
|
||||||
AddButton (NextButton);
|
AddButton (continue_button);
|
||||||
Add (Table);
|
Add (wrapper);
|
||||||
|
|
||||||
|
|
||||||
Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) {
|
Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) {
|
||||||
Application.Invoke (delegate {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -169,8 +172,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
tree.AppendColumn (service_column);
|
tree.AppendColumn (service_column);
|
||||||
|
|
||||||
PathEntry = new SparkleEntry ();
|
SparkleEntry path_entry = new SparkleEntry ();
|
||||||
AddressEntry = new SparkleEntry ();
|
SparkleEntry address_entry = new SparkleEntry ();
|
||||||
|
|
||||||
|
|
||||||
// Select the first plugin by default
|
// Select the first plugin by default
|
||||||
|
@ -183,18 +186,18 @@ namespace SparkleShare {
|
||||||
string example_text, FieldState state) {
|
string example_text, FieldState state) {
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
AddressEntry.Text = text;
|
address_entry.Text = text;
|
||||||
AddressEntry.Sensitive = (state == FieldState.Enabled);
|
address_entry.Sensitive = (state == FieldState.Enabled);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty (example_text))
|
if (string.IsNullOrEmpty (example_text))
|
||||||
AddressEntry.ExampleText = null;
|
address_entry.ExampleText = null;
|
||||||
else
|
else
|
||||||
AddressEntry.ExampleText = example_text;
|
address_entry.ExampleText = example_text;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty (text))
|
if (string.IsNullOrEmpty (text))
|
||||||
AddressEntry.ExampleTextActive = true;
|
address_entry.ExampleTextActive = true;
|
||||||
else
|
else
|
||||||
AddressEntry.ExampleTextActive = false;
|
address_entry.ExampleTextActive = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -202,18 +205,18 @@ namespace SparkleShare {
|
||||||
string example_text, FieldState state) {
|
string example_text, FieldState state) {
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
PathEntry.Text = text;
|
path_entry.Text = text;
|
||||||
PathEntry.Sensitive = (state == FieldState.Enabled);
|
path_entry.Sensitive = (state == FieldState.Enabled);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty (example_text))
|
if (string.IsNullOrEmpty (example_text))
|
||||||
PathEntry.ExampleText = null;
|
path_entry.ExampleText = null;
|
||||||
else
|
else
|
||||||
PathEntry.ExampleText = example_text;
|
path_entry.ExampleText = example_text;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty (text))
|
if (string.IsNullOrEmpty (text))
|
||||||
PathEntry.ExampleTextActive = true;
|
path_entry.ExampleTextActive = true;
|
||||||
else
|
else
|
||||||
PathEntry.ExampleTextActive = false;
|
path_entry.ExampleTextActive = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -242,10 +245,10 @@ namespace SparkleShare {
|
||||||
SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2);
|
SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2);
|
||||||
|
|
||||||
if (plugin.Address != null) {
|
if (plugin.Address != null) {
|
||||||
AddressEntry.Sensitive = false;}
|
address_entry.Sensitive = false;}
|
||||||
|
|
||||||
if (plugin.Path != null)
|
if (plugin.Path != null)
|
||||||
PathEntry.Sensitive = false;
|
path_entry.Sensitive = false;
|
||||||
|
|
||||||
// TODO: Scroll to the selection
|
// 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));
|
ListStore server_store = new ListStore (typeof (string));
|
||||||
|
|
||||||
foreach (string host in Program.Controller.PreviousHosts)
|
foreach (string host in Program.Controller.PreviousHosts)
|
||||||
server_store.AppendValues (host);
|
server_store.AppendValues (host);
|
||||||
|
|
||||||
AddressEntry.Completion.Model = server_store;
|
address_entry.Completion.Model = server_store;
|
||||||
AddressEntry.Completion.TextColumn = 0;
|
address_entry.Completion.TextColumn = 0;
|
||||||
|
|
||||||
AddressEntry.Changed += delegate {
|
address_entry.Changed += delegate {
|
||||||
Controller.CheckAddPage (AddressEntry.Text, PathEntry.Text, tree.SelectedRow);
|
Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow);
|
||||||
};
|
};
|
||||||
|
|
||||||
layout_address.PackStart (new Label () {
|
layout_address.PackStart (new Label () {
|
||||||
Markup = "<b>" + _("Address") + "</b>",
|
Markup = "<b>" + _("Address") + "</b>",
|
||||||
Xalign = 0
|
Xalign = 0
|
||||||
}, true, true, 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));
|
ListStore folder_store = new ListStore (typeof (string));
|
||||||
|
|
||||||
//foreach (string host in Program.Controller.FolderPaths)
|
//foreach (string host in Program.Controller.FolderPaths)
|
||||||
// folder_store.AppendValues (host);
|
// folder_store.AppendValues (host);
|
||||||
|
|
||||||
PathEntry.Completion.Model = folder_store;
|
path_entry.Completion.Model = folder_store;
|
||||||
PathEntry.Completion.TextColumn = 0;
|
path_entry.Completion.TextColumn = 0;
|
||||||
|
|
||||||
PathEntry.Changed += delegate {
|
path_entry.Changed += delegate {
|
||||||
Controller.CheckAddPage (AddressEntry.Text, PathEntry.Text, tree.SelectedRow);
|
Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow);
|
||||||
};
|
};
|
||||||
|
|
||||||
layout_path.PackStart (new Label () { Markup = "<b>" + _("Remote Path") + "</b>", Xalign = 0 },
|
layout_path.PackStart (new Label () {
|
||||||
true, true, 0);
|
Markup = "<b>" + _("Remote Path") + "</b>",
|
||||||
layout_path.PackStart (PathEntry, true, true, 0);
|
Xalign = 0
|
||||||
|
}, true, true, 0);
|
||||||
|
|
||||||
|
layout_path.PackStart (path_entry, true, true, 0);
|
||||||
|
|
||||||
layout_fields.PackStart (layout_address);
|
layout_fields.PackStart (layout_address);
|
||||||
layout_fields.PackStart (layout_path);
|
layout_fields.PackStart (layout_path);
|
||||||
|
@ -310,19 +316,19 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sync button
|
// Sync button
|
||||||
SyncButton = new Button (_("Add"));
|
Button add_button = new Button (_("Add"));
|
||||||
|
|
||||||
SyncButton.Clicked += delegate {
|
add_button.Clicked += delegate {
|
||||||
string server = AddressEntry.Text;
|
string server = address_entry.Text;
|
||||||
string folder_name = PathEntry.Text;
|
string folder_name = path_entry.Text;
|
||||||
|
|
||||||
Controller.AddPageCompleted (server, folder_name);
|
Controller.AddPageCompleted (server, folder_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
AddButton (cancel_button);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue