Skip to content

Commit

Permalink
Visual Menu improvements
Browse files Browse the repository at this point in the history
No longer auto-disable all items. This makes them easier to read but
also makes the non-action entries act as if they were enabled. Not sure
if this is better.
  • Loading branch information
cbreak-black committed Mar 12, 2018
1 parent d549b78 commit 86247af
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ZetaWatch/ZetaMenuDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ - (void)menuNeedsUpdate:(NSMenu*)menu
NSMenu * createVdevMenu(zfs::ZPool const & pool)
{
NSMenu * vdevMenu = [[NSMenu alloc] init];
[vdevMenu setAutoenablesItems:NO];
try
{
auto vdevs = pool.vdevs();
Expand All @@ -138,22 +139,24 @@ - (void)menuNeedsUpdate:(NSMenu*)menu
auto scrub = zfs::scanStat(vdev);
if (scrub.state == zfs::ScanStat::scanning)
{
NSString * scanLine = [NSString stringWithFormat:@" Scrub in Progress: %0.2f %% (%s out of %s)",
NSString * scanLine = [NSString stringWithFormat:@"Scrub in Progress: %0.2f %% (%s out of %s)",
100.0*scrub.examined/scrub.toExamine,
formatBytes(scrub.examined).c_str(),
formatBytes(scrub.toExamine).c_str()];
[vdevMenu addItemWithTitle:scanLine
action:nullptr keyEquivalent:@""];
NSMenuItem * item = [vdevMenu addItemWithTitle:scanLine
action:nullptr keyEquivalent:@""];
[item setIndentationLevel:1];
}
// Children
auto devices = zfs::vdevChildren(vdev);
for (auto && device: devices)
{
auto stat = zfs::vdevStat(device);
NSString * devLine = [NSString stringWithFormat:@" %s (%@)",
NSString * devLine = [NSString stringWithFormat:@"%s (%@)",
genName(device).c_str(), formatErrorStat(stat)];
[vdevMenu addItemWithTitle:devLine
action:nullptr keyEquivalent:@""];
NSMenuItem * item = [vdevMenu addItemWithTitle:devLine
action:nullptr keyEquivalent:@""];
[item setIndentationLevel:1];
}
}
// Filesystems
Expand Down

0 comments on commit 86247af

Please sign in to comment.