statusicon: Show count of paused projects when there are some
This commit is contained in:
parent
049f4b3444
commit
8da4978741
|
@ -21,58 +21,45 @@ using System.Threading;
|
|||
|
||||
namespace SparkleShare {
|
||||
|
||||
public class SparkleAboutController {
|
||||
public class SparkleNoteController {
|
||||
|
||||
public event Action ShowWindowEvent = delegate { };
|
||||
public event Action HideWindowEvent = delegate { };
|
||||
|
||||
public event UpdateLabelEventDelegate UpdateLabelEvent = delegate { };
|
||||
public delegate void UpdateLabelEventDelegate (string text);
|
||||
public event UpdateTitleEventDelegate UpdateTitleEvent = delegate { };
|
||||
public delegate void UpdateTitleEventDelegate (string title);
|
||||
|
||||
public readonly string WebsiteLinkAddress = "http://www.sparkleshare.org/";
|
||||
public readonly string CreditsLinkAddress = "http://github.com/hbons/SparkleShare/blob/master/legal/Authors.txt";
|
||||
public readonly string ReportProblemLinkAddress = "http://www.github.com/hbons/SparkleShare/issues";
|
||||
public readonly string DebugLogLinkAddress = "file://" + Program.Controller.Config.LogFilePath;
|
||||
|
||||
public string RunningVersion;
|
||||
public string CurrentProject { get; private set; }
|
||||
|
||||
|
||||
public SparkleAboutController ()
|
||||
public SparkleNoteController ()
|
||||
{
|
||||
RunningVersion = SparkleLib.SparkleBackend.Version;
|
||||
|
||||
Program.Controller.ShowAboutWindowEvent += delegate {
|
||||
Program.Controller.ShowNoteWindowEvent += delegate (string project) {
|
||||
CurrentProject = project;
|
||||
ShowWindowEvent ();
|
||||
new Thread (() => CheckForNewVersion ()).Start ();
|
||||
UpdateTitleEvent (CurrentProject);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void CancelClicked ()
|
||||
{
|
||||
HideWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
public void SyncClicked (string note)
|
||||
{
|
||||
HideWindowEvent ();
|
||||
new Thread (() => Program.Controller.GetRepoByName (CurrentProject).Resume (note)).Start ();
|
||||
}
|
||||
|
||||
|
||||
public void WindowClosed ()
|
||||
{
|
||||
HideWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
private void CheckForNewVersion ()
|
||||
{
|
||||
UpdateLabelEvent ("Checking for updates...");
|
||||
Thread.Sleep (500);
|
||||
|
||||
WebClient web_client = new WebClient ();
|
||||
Uri uri = new Uri ("http://www.sparkleshare.org/version");
|
||||
|
||||
try {
|
||||
string latest_version = web_client.DownloadString (uri).Trim ();
|
||||
|
||||
if (new Version (latest_version) > new Version (RunningVersion))
|
||||
UpdateLabelEvent ("A newer version (" + latest_version + ") is available!");
|
||||
else
|
||||
UpdateLabelEvent ("You are running the latest version.");
|
||||
|
||||
} catch {
|
||||
UpdateLabelEvent ("Version check failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,10 +178,7 @@ namespace SparkleShare {
|
|||
if (CurrentState != IconState.Error) {
|
||||
CurrentState = IconState.Idle;
|
||||
|
||||
if (Projects.Length == 0)
|
||||
StateText = "Welcome to SparkleShare!";
|
||||
else
|
||||
StateText = "Projects up to date";
|
||||
UpdateStateText ();
|
||||
}
|
||||
|
||||
UpdateFolders ();
|
||||
|
@ -194,10 +191,7 @@ namespace SparkleShare {
|
|||
if (CurrentState != IconState.Error) {
|
||||
CurrentState = IconState.Idle;
|
||||
|
||||
if (Projects.Length == 0)
|
||||
StateText = "Welcome to SparkleShare!";
|
||||
else
|
||||
StateText = "Projects up to date";
|
||||
UpdateStateText ();
|
||||
}
|
||||
|
||||
UpdateFolders ();
|
||||
|
@ -269,6 +263,30 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
private string UpdateStateText ()
|
||||
{
|
||||
if (Projects.Length == 0)
|
||||
return StateText = "Welcome to SparkleShare!";
|
||||
else
|
||||
return StateText = "Projects up to date " + GetPausedCount ();
|
||||
}
|
||||
|
||||
|
||||
private string GetPausedCount ()
|
||||
{
|
||||
int paused_projects = 0;
|
||||
|
||||
foreach (ProjectInfo project in Projects)
|
||||
if (project.IsPaused)
|
||||
paused_projects++;
|
||||
|
||||
if (paused_projects > 0)
|
||||
return string.Format ("— {0} paused", paused_projects);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// Main menu items
|
||||
public void RecentEventsClicked ()
|
||||
{
|
||||
|
@ -311,6 +329,7 @@ namespace SparkleShare {
|
|||
public void PauseClicked (string project)
|
||||
{
|
||||
Program.Controller.GetRepoByName (project).Pause ();
|
||||
UpdateStateText ();
|
||||
UpdateMenuEvent (CurrentState);
|
||||
}
|
||||
|
||||
|
@ -320,10 +339,14 @@ namespace SparkleShare {
|
|||
Program.Controller.ShowNoteWindow (project);
|
||||
|
||||
} else {
|
||||
new Thread (() => Program.Controller.GetRepoByName (project).Resume ("")).Start ();
|
||||
}
|
||||
new System.Threading.Thread (() => {
|
||||
Program.Controller.GetRepoByName (project).Resume ("");
|
||||
|
||||
UpdateStateText ();
|
||||
UpdateMenuEvent (CurrentState);
|
||||
|
||||
UpdateMenuEvent (CurrentState);
|
||||
}).Start ();
|
||||
}
|
||||
}
|
||||
|
||||
public void TryAgainClicked (string project)
|
||||
|
|
Loading…
Reference in a new issue