code cleanup

This commit is contained in:
Hylke Bons 2010-05-31 17:48:42 +02:00
parent 7a051e3d87
commit 32dd91e4fa

View file

@ -48,10 +48,12 @@ namespace SparkleShare {
Label RemoteUrlLabel = Label RemoteUrlLabel =
new Label (_("Address of remote SparkleShare folder:")); new Label (_("Address of remote SparkleShare folder:"));
RemoteUrlLabel.Xalign = 0;
ListStore Defaults = new ListStore (typeof (string)); ListStore Defaults = new ListStore (typeof (string));
RemoteUrlCombo = new ComboBoxEntry (Defaults, 0); RemoteUrlCombo = new ComboBoxEntry (Defaults, 0);
if (Url.Equals ("")) if (Url.Equals (""))
RemoteUrlCombo.Entry.Text = "ssh://"; RemoteUrlCombo.Entry.Text = "ssh://";
else else
@ -65,26 +67,18 @@ namespace SparkleShare {
RemoteUrlCombo.Entry.Completion.TextColumn = 0; RemoteUrlCombo.Entry.Completion.TextColumn = 0;
RemoteUrlCombo.Entry.Changed += CheckFields; RemoteUrlCombo.Entry.Changed += CheckFields;
// Add some preset addresses
Defaults.AppendValues ("ssh://git@github.com/"); Defaults.AppendValues ("ssh://git@github.com/");
Defaults.AppendValues ("ssh://git@git.gnome.org/"); Defaults.AppendValues ("ssh://git@git.gnome.org/");
Defaults.AppendValues ("ssh://git@fedorahosted.org/"); Defaults.AppendValues ("ssh://git@fedorahosted.org/");
Defaults.AppendValues ("ssh://git@gitorious.org/"); Defaults.AppendValues ("ssh://git@gitorious.org/");
Label RemoteUrlExample =
new Label (_("These usually look something like this:\n ") +
_("git://git@gnome.org/project."));
RemoteUrlExample.UseMarkup = true;
RemoteUrlExample.SetAlignment (0, 0);
RemoteUrlLabel.Xalign = 0;
HButtonBox ButtonBox = new HButtonBox (); HButtonBox ButtonBox = new HButtonBox ();
ButtonBox.Layout = ButtonBoxStyle.End; ButtonBox.Layout = ButtonBoxStyle.End;
ButtonBox.Spacing = 6; ButtonBox.Spacing = 6;
ButtonBox.BorderWidth = 0; ButtonBox.BorderWidth = 0;
AddButton = new Button (_("Add Folder")); AddButton = new Button (_("Add Folder"));
// TODO: This freezes the UI
AddButton.Clicked += CloneRepo; AddButton.Clicked += CloneRepo;
AddButton.Sensitive = false; AddButton.Sensitive = false;
@ -107,14 +101,17 @@ namespace SparkleShare {
} }
// Clones a remote repo
public void CloneRepo (object o, EventArgs args) { public void CloneRepo (object o, EventArgs args) {
HideAll ();
string RepoRemoteUrl = RemoteUrlCombo.Entry.Text; string RepoRemoteUrl = RemoteUrlCombo.Entry.Text;
int SlashPos = RepoRemoteUrl.LastIndexOf ("/"); int SlashPos = RepoRemoteUrl.LastIndexOf ("/");
int ColumnPos = RepoRemoteUrl.LastIndexOf (":"); int ColumnPos = RepoRemoteUrl.LastIndexOf (":");
// Check wheter a "/" or ":" is used to separate the // Check whether a "/" or ":" is used to separate the
// repo name from the domain. // repo name from the domain.
string RepoName; string RepoName;
if (SlashPos > ColumnPos) if (SlashPos > ColumnPos)
@ -124,9 +121,7 @@ namespace SparkleShare {
SparkleBubble SparkleBubble = SparkleBubble SparkleBubble =
new SparkleBubble (_("Syncing folder ") + RepoName + "", new SparkleBubble (_("Syncing folder ") + RepoName + "",
_("SparkleShare will notify you when this is done.")); _("SparkleShare will notify you when this is done."));
HideAll ();
Process Process = new Process(); Process Process = new Process();
Process.EnableRaisingEvents = true; Process.EnableRaisingEvents = true;
@ -148,17 +143,18 @@ namespace SparkleShare {
SparkleBubble = SparkleBubble =
new SparkleBubble ("Something went wrong while syncing " + new SparkleBubble ("Something went wrong while syncing " +
" " + RepoName + "", " " + RepoName + "",
"Please double check your address and\n" + "Please double check the address and\n" +
"network connection."); "network connection.");
SparkleBubble.AddAction ("", _("Try Again…"), SparkleBubble.AddAction ("", _("Try Again…"),
delegate { delegate {
Process.StartInfo.FileName = "xdg-open"; Process.StartInfo.FileName = "xdg-open";
Process.StartInfo.Arguments = Process.StartInfo.Arguments =
SparkleHelpers.CombineMore ( SparkleHelpers.CombineMore
SparklePaths.SparklePath, RepoName); (SparklePaths.SparklePath, RepoName);
Process.Start(); Process.Start();
} ); }
);
SparkleDialog SparkleDialog = new SparkleDialog (RepoRemoteUrl); SparkleDialog SparkleDialog = new SparkleDialog (RepoRemoteUrl);
SparkleDialog.ShowAll (); SparkleDialog.ShowAll ();
@ -170,8 +166,6 @@ namespace SparkleShare {
// Move the folder to the SparkleShare folder when done cloning // Move the folder to the SparkleShare folder when done cloning
Process.Exited += delegate { Process.Exited += delegate {
// Move the repo from the temporary folder
// to the SparkleShare folder
Directory.Move ( Directory.Move (
SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath,
RepoName), RepoName),
@ -179,19 +173,22 @@ namespace SparkleShare {
RepoName) RepoName)
); );
// Show a confirmation notification
SparkleBubble = SparkleBubble =
new SparkleBubble (_("Successfully synced the folder") + new SparkleBubble (_("Successfully synced the folder ") +
" " + RepoName + "", "" + RepoName + "",
_("Now make great stuff happen!")); _("Now make great stuff happen!"));
SparkleBubble.AddAction ("", _("Open Folder"), SparkleBubble.AddAction ("", _("Open Folder"),
delegate { delegate {
Process.StartInfo.FileName = "xdg-open"; Process.StartInfo.FileName = "xdg-open";
Process.StartInfo.Arguments = Process.StartInfo.Arguments =
SparkleHelpers.CombineMore ( SparkleHelpers.CombineMore (
SparklePaths.SparklePath, RepoName); SparklePaths.SparklePath, RepoName);
Process.Start(); Process.Start();
} ); }
);
// Destroy the Add dialog // Destroy the Add dialog
Destroy (); Destroy ();