[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 { public class SparkleLog : Window {
private string LocalPath; public readonly string LocalPath;
private VBox LayoutVertical; private VBox LayoutVertical;
private ScrolledWindow ScrolledWindow; private ScrolledWindow ScrolledWindow;
@ -83,7 +83,7 @@ namespace SparkleShare {
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 {
Close (); Close ();
}; };
@ -105,6 +105,7 @@ namespace SparkleShare {
// Get commits from the repository // Get commits from the repository
if (repo.LocalPath.Equals (LocalPath)) { if (repo.LocalPath.Equals (LocalPath)) {
// Remove the eventhooks
repo.NewCommit -= UpdateEventLog; repo.NewCommit -= UpdateEventLog;
repo.PushingStarted -= UpdateEventLog; repo.PushingStarted -= UpdateEventLog;
@ -112,7 +113,7 @@ namespace SparkleShare {
} }
Destroy (); HideAll ();
} }

View file

@ -18,6 +18,7 @@ using Gtk;
using Mono.Unix; using Mono.Unix;
using SparkleLib; using SparkleLib;
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Timers; using System.Timers;
@ -27,6 +28,8 @@ namespace SparkleShare {
public class SparkleStatusIcon : StatusIcon public class SparkleStatusIcon : StatusIcon
{ {
private List <SparkleLog> OpenLogs;
public int SyncingReposCount; public int SyncingReposCount;
private Menu Menu; private Menu Menu;
@ -49,6 +52,8 @@ namespace SparkleShare {
public SparkleStatusIcon () : base () public SparkleStatusIcon () : base ()
{ {
OpenLogs = new List <SparkleLog> ();
FolderSize = GetFolderSize (new DirectoryInfo (SparklePaths.SparklePath)); FolderSize = GetFolderSize (new DirectoryInfo (SparklePaths.SparklePath));
FrameNumber = 0; FrameNumber = 0;
@ -126,7 +131,24 @@ namespace SparkleShare {
return delegate { 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.ShowAll ();
log.Present (); log.Present ();