[statusicon] don't create a [log] if one for the same repo is already open. present to the user instead

This commit is contained in:
Hylke Bons 2010-09-08 22:58:30 +01:00
parent 162b0acdaa
commit 9d0b7f4451
2 changed files with 27 additions and 4 deletions

View file

@ -26,7 +26,7 @@ namespace SparkleShare {
public class SparkleLog : Window {
private string LocalPath;
public readonly string LocalPath;
private VBox LayoutVertical;
private ScrolledWindow ScrolledWindow;
@ -83,7 +83,7 @@ namespace SparkleShare {
Button close_button = new Button (Stock.Close);
close_button.Clicked += delegate (object o, EventArgs args) {
close_button.Clicked += delegate {
Close ();
};
@ -105,6 +105,7 @@ namespace SparkleShare {
// Get commits from the repository
if (repo.LocalPath.Equals (LocalPath)) {
// Remove the eventhooks
repo.NewCommit -= UpdateEventLog;
repo.PushingStarted -= UpdateEventLog;
@ -112,7 +113,7 @@ namespace SparkleShare {
}
Destroy ();
HideAll ();
}

View file

@ -18,6 +18,7 @@ using Gtk;
using Mono.Unix;
using SparkleLib;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Timers;
@ -27,6 +28,8 @@ namespace SparkleShare {
public class SparkleStatusIcon : StatusIcon
{
private List <SparkleLog> OpenLogs;
public int SyncingReposCount;
private Menu Menu;
@ -49,6 +52,8 @@ namespace SparkleShare {
public SparkleStatusIcon () : base ()
{
OpenLogs = new List <SparkleLog> ();
FolderSize = GetFolderSize (new DirectoryInfo (SparklePaths.SparklePath));
FrameNumber = 0;
@ -126,7 +131,24 @@ namespace SparkleShare {
return delegate {
SparkleLog log = new SparkleLog (path);
SparkleLog log = OpenLogs.Find (delegate (SparkleLog l) { return l.LocalPath.Equals (path); });
// Check whether the log is already open,
// create a new one if that's not the case or
// present it to the user if it is
if (log == null) {
log = new SparkleLog (path);
log.Hidden += delegate {
OpenLogs.Remove (log);
log = null;
};
OpenLogs.Add (log);
}
log.ShowAll ();
log.Present ();