[log] remove event handlers for updating the log when window is closed

This commit is contained in:
Hylke Bons 2010-09-04 21:17:41 +01:00
parent 5670148dd5
commit 9ce46e4579

View file

@ -53,6 +53,10 @@ namespace SparkleShare {
Title = String.Format(_("Recent Events in {0}"), name); Title = String.Format(_("Recent Events in {0}"), name);
IconName = "folder-sparkleshare"; IconName = "folder-sparkleshare";
DeleteEvent += delegate {
Close ();
};
LayoutVertical = new VBox (false, 12); LayoutVertical = new VBox (false, 12);
LayoutVertical.PackStart (CreateEventLog (), true, true, 0); LayoutVertical.PackStart (CreateEventLog (), true, true, 0);
@ -73,14 +77,14 @@ namespace SparkleShare {
process.StartInfo.Arguments = LocalPath.Replace (" ", "\\ "); // Escape space-characters process.StartInfo.Arguments = LocalPath.Replace (" ", "\\ "); // Escape space-characters
process.Start (); process.Start ();
Destroy (); Close ();
}; };
Button close_button = new Button (Stock.Close); Button close_button = new Button (Stock.Close);
close_button.Clicked += delegate (object o, EventArgs args) { close_button.Clicked += delegate (object o, EventArgs args) {
Destroy (); Close ();
}; };
dialog_buttons.Add (open_folder_button); dialog_buttons.Add (open_folder_button);
@ -93,15 +97,38 @@ namespace SparkleShare {
} }
public void Close ()
{
foreach (SparkleRepo repo in SparkleUI.Repositories) {
// Get commits from the repository
if (repo.LocalPath.Equals (LocalPath)) {
repo.NewCommit -= UpdateEventLog;
repo.PushingStarted -= UpdateEventLog;
}
}
Destroy ();
}
public void UpdateEventLog (object o, EventArgs args) public void UpdateEventLog (object o, EventArgs args)
{ {
Application.Invoke (delegate {
LayoutVertical.Remove (ScrolledWindow); LayoutVertical.Remove (ScrolledWindow);
ScrolledWindow = CreateEventLog (); ScrolledWindow = CreateEventLog ();
LayoutVertical.PackStart (ScrolledWindow, true, true, 0); LayoutVertical.PackStart (ScrolledWindow, true, true, 0);
LayoutVertical.ReorderChild (ScrolledWindow, 0); LayoutVertical.ReorderChild (ScrolledWindow, 0);
ShowAll (); ShowAll ();
});
} }
@ -118,14 +145,10 @@ namespace SparkleShare {
commits = repo.GetCommits (25); commits = repo.GetCommits (25);
// Update the log when there are new remote changes // Update the log when there are new remote changes
repo.NewCommit += delegate { repo.NewCommit += UpdateEventLog;
Application.Invoke (UpdateEventLog);
};
// Update the log when changes are being sent // Update the log when changes are being sent
repo.PushingStarted += delegate { repo.PushingStarted += UpdateEventLog;
Application.Invoke (UpdateEventLog);
};
break; break;