statusicon: Limit paused unsynced items list to 10

This commit is contained in:
Hylke Bons 2014-11-05 13:21:18 +00:00
parent bfa3dd2bec
commit 320c74c9f4
5 changed files with 27 additions and 4 deletions

View file

@ -1136,10 +1136,6 @@ namespace SparkleLib.Git {
}
changes.Add (change);
count++;
if (count == 10)
break;
}
git_status.StandardOutput.ReadToEnd ();

View file

@ -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…");

View file

@ -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…");

View file

@ -79,11 +79,19 @@ namespace SparkleShare {
}
public string MoreUnsyncedChanges = "";
public Dictionary<string, string> UnsyncedChangesInfo {
get {
Dictionary<string, string> changes_info = new Dictionary<string, string> ();
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;
}
}

View file

@ -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…" };