From 320c74c9f49f6218593cd5724038673e630458ba Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 5 Nov 2014 13:21:18 +0000 Subject: [PATCH] statusicon: Limit paused unsynced items list to 10 --- SparkleLib/Git/SparkleRepoGit.cs | 4 ---- SparkleShare/Linux/SparkleStatusIcon.cs | 6 ++++++ SparkleShare/Mac/SparkleStatusIcon.cs | 3 +++ SparkleShare/SparkleStatusIconController.cs | 11 +++++++++++ SparkleShare/Windows/SparkleStatusIcon.cs | 7 +++++++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index e0ffc801..2dcb7cf0 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -1136,10 +1136,6 @@ namespace SparkleLib.Git { } changes.Add (change); - - count++; - if (count == 10) - break; } git_status.StandardOutput.ReadToEnd (); diff --git a/SparkleShare/Linux/SparkleStatusIcon.cs b/SparkleShare/Linux/SparkleStatusIcon.cs index 9e7e6854..7f075dd9 100644 --- a/SparkleShare/Linux/SparkleStatusIcon.cs +++ b/SparkleShare/Linux/SparkleStatusIcon.cs @@ -156,6 +156,12 @@ namespace SparkleShare { File = new string [] {icons_path, pair.Value.Replace ("-12", "")}.Combine () }, Sensitive = false }); + + if (!string.IsNullOrEmpty (project.MoreUnsyncedChanges)) { + (item.Submenu as Menu).Add (new MenuItem (MoreUnsyncedChanges) { + Sensitive = false + }); + } (item.Submenu as Menu).Add (new SeparatorMenuItem ()); resume_item = new MenuItem ("Sync and Resume…"); diff --git a/SparkleShare/Mac/SparkleStatusIcon.cs b/SparkleShare/Mac/SparkleStatusIcon.cs index f635f577..dcc4909c 100755 --- a/SparkleShare/Mac/SparkleStatusIcon.cs +++ b/SparkleShare/Mac/SparkleStatusIcon.cs @@ -204,6 +204,9 @@ namespace SparkleShare { Image = NSImage.ImageNamed (pair.Value) }); + if (!string.IsNullOrEmpty (project.MoreUnsyncedChanges)) + item.Submenu.AddItem (new NSMenuItem (project.MoreUnsyncedChanges)); + item.Submenu.AddItem (NSMenuItem.SeparatorItem); this.resume_menu_items [i] = new NSMenuItem ("Sync and Resume…"); diff --git a/SparkleShare/SparkleStatusIconController.cs b/SparkleShare/SparkleStatusIconController.cs index 2a64ca9b..c28b76fc 100755 --- a/SparkleShare/SparkleStatusIconController.cs +++ b/SparkleShare/SparkleStatusIconController.cs @@ -79,11 +79,19 @@ namespace SparkleShare { } + public string MoreUnsyncedChanges = ""; + public Dictionary UnsyncedChangesInfo { get { Dictionary changes_info = new Dictionary (); + int changes_count = 0; foreach (SparkleChange change in repo.UnsyncedChanges) { + changes_count++; + + if (changes_count > 10) + continue; + switch (change.Type) { case SparkleChangeType.Added: changes_info [change.Path] = "document-added-12.png"; break; case SparkleChangeType.Edited: changes_info [change.Path] = "document-edited-12.png"; break; @@ -92,6 +100,9 @@ namespace SparkleShare { } } + if (changes_count > 10) + MoreUnsyncedChanges = string.Format ("and {0} more", changes_count - 10); + return changes_info; } } diff --git a/SparkleShare/Windows/SparkleStatusIcon.cs b/SparkleShare/Windows/SparkleStatusIcon.cs index be719127..a098d71f 100644 --- a/SparkleShare/Windows/SparkleStatusIcon.cs +++ b/SparkleShare/Windows/SparkleStatusIcon.cs @@ -224,6 +224,13 @@ namespace SparkleShare { // TODO image IsEnabled = false }); + + if (!string.IsNullOrEmpty (project.MoreUnsyncedChanges)) { + item.Items.Add (new SparkleMenuItem () { + Header = project.MoreUnsyncedChanges, + IsEnabled = false + }); + } item.Items.Add (new Separator ()); resume_item = new SparkleMenuItem () { Header = "Sync and Resume…" };