From 2d980d0c53d1b2e3650133e225ae9609b74e0a88 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 3 Jun 2011 01:11:19 +0100 Subject: [PATCH] mac: use NSCaution icon instead of NSFolder in the status menu when the folder is unsynced --- SparkleShare/Mac/SparkleStatusIcon.cs | 33 +++++++++++++++------------ SparkleShare/SparkleController.cs | 14 ++++++++++++ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/SparkleShare/Mac/SparkleStatusIcon.cs b/SparkleShare/Mac/SparkleStatusIcon.cs index 01a4dd64..6cc0072b 100644 --- a/SparkleShare/Mac/SparkleStatusIcon.cs +++ b/SparkleShare/Mac/SparkleStatusIcon.cs @@ -85,7 +85,7 @@ namespace SparkleShare { SparkleShare.Controller.OnIdle += delegate { InvokeOnMainThread (delegate { SetNormalState (); - UpdateMenu (); + CreateMenu (); }); }; @@ -99,7 +99,7 @@ namespace SparkleShare { SparkleShare.Controller.OnError += delegate { InvokeOnMainThread (delegate { SetNormalState (true); - UpdateMenu (); + CreateMenu (); }); }; } @@ -172,19 +172,18 @@ namespace SparkleShare { Tasks = new EventHandler [SparkleShare.Controller.Folders.Count]; int i = 0; - foreach (string path in SparkleShare.Controller.Folders) { - - /* TODO - if (repo.HasUnsyncedChanges) - folder_action.IconName = "dialog-error"; */ - + foreach (string folder_name in SparkleShare.Controller.Folders) { NSMenuItem item = new NSMenuItem (); - - item.Title = System.IO.Path.GetFileName (path); - item.Image = NSImage.ImageNamed ("NSFolder"); - item.Image.Size = new SizeF (16, 16); - Tasks [i] = OpenEventLogDelegate (path); + item.Title = folder_name; + + if (SparkleShare.Controller.UnsyncedFolders.Contains (folder_name)) + item.Image = NSImage.ImageNamed ("NSCaution"); + else + item.Image = NSImage.ImageNamed ("NSFolder"); + + item.Image.Size = new SizeF (16, 16); + Tasks [i] = OpenEventLogDelegate (folder_name); FolderMenuItems [i] = item; FolderMenuItems [i].Activated += Tasks [i]; @@ -192,6 +191,9 @@ namespace SparkleShare { i++; }; + + + } else { FolderMenuItems = new NSMenuItem [1]; @@ -290,7 +292,10 @@ namespace SparkleShare { // The state when there's nothing going on private void SetNormalState () { - SetNormalState (false); + if (SparkleShare.Controller.UnsyncedFolders.Count > 0) + SetNormalState (true); + else + SetNormalState (false); } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index eab255ac..4968723c 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -225,6 +225,20 @@ namespace SparkleShare { return SparkleConfig.DefaultConfig.Folders; } } + + + public List UnsyncedFolders { + get { + List unsynced_folders = new List (); + + foreach (SparkleRepoBase repo in Repositories) { + if (repo.HasUnsyncedChanges) + unsynced_folders.Add (repo.Name); + } + + return unsynced_folders; + } + } public List GetLog (string name)