Skip to content

Commit

Permalink
Show non-running processes as gray
Browse files Browse the repository at this point in the history
The menu items remain gray when selected, though. Still better than not
giving the user information about whether the process is still running.
  • Loading branch information
Mike McFadden committed May 9, 2015
1 parent 57445b9 commit 2ca6943
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Loading/MenuDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,8 @@ - (void)open:(id)sender {
}
}

- (NSAttributedString *)wrappedText:(NSString *)text width:(float)max_width {
NSMutableParagraphStyle* pathStyle = [[NSMutableParagraphStyle alloc] init];
pathStyle.minimumLineHeight = 13.0;

NSDictionary *pathAttribs= @{ NSFontAttributeName:[NSFont menuFontOfSize:11.0], NSParagraphStyleAttributeName:pathStyle };

NSAttributedString *pathText = [[NSAttributedString alloc] initWithString:text attributes:pathAttribs];
- (NSAttributedString *)wrappedText:(NSString *)text width:(float)max_width attributes:attribs {
NSAttributedString *pathText = [[NSAttributedString alloc] initWithString:text attributes:attribs];

CTFramesetterRef fs = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)pathText);
CGMutablePathRef path2 = CGPathCreateMutable();
Expand All @@ -96,7 +91,7 @@ - (NSAttributedString *)wrappedText:(NSString *)text width:(float)max_width {

NSString *joiner = @"\n";
if ([[AppDelegate sharedDelegate] isRightToLeft]) joiner = @"\n\u200F";
return [[NSAttributedString alloc] initWithString:[final componentsJoinedByString:joiner] attributes:pathAttribs];
return [[NSAttributedString alloc] initWithString:[final componentsJoinedByString:joiner] attributes:attribs];
}

- (void)toggleAnimate:(id)obj {
Expand Down Expand Up @@ -374,6 +369,11 @@ - (void)updateMenu:(NSMenu *)menu {
float max_width = [menu size].width;
if (max_width < 210) max_width = 210;

NSMutableParagraphStyle* pathStyle = [[NSMutableParagraphStyle alloc] init];
pathStyle.minimumLineHeight = 13.0;
NSDictionary *attribs= @{ NSFontAttributeName:[NSFont menuFontOfSize:11.0], NSParagraphStyleAttributeName:pathStyle };
NSDictionary *disabledAttribs= @{ NSFontAttributeName:[NSFont menuFontOfSize:11.0], NSParagraphStyleAttributeName:pathStyle, NSForegroundColorAttributeName:[NSColor tertiaryLabelColor] };

for (long index = 0; index < [advancedProcesses count]; index++) {
ProcessRecord *process = [advancedProcesses objectAtIndex:index];
NSMenuItem *item = [advancedItems objectAtIndex:index];
Expand Down Expand Up @@ -404,7 +404,10 @@ - (void)updateMenu:(NSMenu *)menu {
joiner = @"\u00A0\u202B ";
format = @"\u202B%d\u00A0%@";
}
[item setAttributedTitle:[self wrappedText:[NSString stringWithFormat:format, process.pid, [folders componentsJoinedByString:joiner]] width:max_width]];
NSDictionary *useAttribs = attribs;
if (!process.running) useAttribs = disabledAttribs;

[item setAttributedTitle:[self wrappedText:[NSString stringWithFormat:format, process.pid, [folders componentsJoinedByString:joiner]] width:max_width attributes:useAttribs]];
[item setIndentationLevel:1];
[item setRepresentedObject:process];
[item setTarget:self];
Expand Down

0 comments on commit 2ca6943

Please sign in to comment.