From 9d0b7f445186721ad165248a9160389b3ac9e483 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 8 Sep 2010 22:58:30 +0100 Subject: [PATCH] [statusicon] don't create a [log] if one for the same repo is already open. present to the user instead --- SparkleShare/SparkleLog.cs | 7 ++++--- SparkleShare/SparkleStatusIcon.cs | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/SparkleShare/SparkleLog.cs b/SparkleShare/SparkleLog.cs index 055feb10..29274860 100644 --- a/SparkleShare/SparkleLog.cs +++ b/SparkleShare/SparkleLog.cs @@ -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 (); } diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 903f30e6..e5f02eea 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -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 OpenLogs; + public int SyncingReposCount; private Menu Menu; @@ -49,6 +52,8 @@ namespace SparkleShare { public SparkleStatusIcon () : base () { + OpenLogs = new List (); + 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 ();