Skip to content

Commit 2ca6943

Browse files
author
Mike McFadden
committed
Show non-running processes as gray
The menu items remain gray when selected, though. Still better than not giving the user information about whether the process is still running.
1 parent 57445b9 commit 2ca6943

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Loading/MenuDelegate.m

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,8 @@ - (void)open:(id)sender {
6969
}
7070
}
7171

72-
- (NSAttributedString *)wrappedText:(NSString *)text width:(float)max_width {
73-
NSMutableParagraphStyle* pathStyle = [[NSMutableParagraphStyle alloc] init];
74-
pathStyle.minimumLineHeight = 13.0;
75-
76-
NSDictionary *pathAttribs= @{ NSFontAttributeName:[NSFont menuFontOfSize:11.0], NSParagraphStyleAttributeName:pathStyle };
77-
78-
NSAttributedString *pathText = [[NSAttributedString alloc] initWithString:text attributes:pathAttribs];
72+
- (NSAttributedString *)wrappedText:(NSString *)text width:(float)max_width attributes:attribs {
73+
NSAttributedString *pathText = [[NSAttributedString alloc] initWithString:text attributes:attribs];
7974

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

9792
NSString *joiner = @"\n";
9893
if ([[AppDelegate sharedDelegate] isRightToLeft]) joiner = @"\n\u200F";
99-
return [[NSAttributedString alloc] initWithString:[final componentsJoinedByString:joiner] attributes:pathAttribs];
94+
return [[NSAttributedString alloc] initWithString:[final componentsJoinedByString:joiner] attributes:attribs];
10095
}
10196

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

372+
NSMutableParagraphStyle* pathStyle = [[NSMutableParagraphStyle alloc] init];
373+
pathStyle.minimumLineHeight = 13.0;
374+
NSDictionary *attribs= @{ NSFontAttributeName:[NSFont menuFontOfSize:11.0], NSParagraphStyleAttributeName:pathStyle };
375+
NSDictionary *disabledAttribs= @{ NSFontAttributeName:[NSFont menuFontOfSize:11.0], NSParagraphStyleAttributeName:pathStyle, NSForegroundColorAttributeName:[NSColor tertiaryLabelColor] };
376+
377377
for (long index = 0; index < [advancedProcesses count]; index++) {
378378
ProcessRecord *process = [advancedProcesses objectAtIndex:index];
379379
NSMenuItem *item = [advancedItems objectAtIndex:index];
@@ -404,7 +404,10 @@ - (void)updateMenu:(NSMenu *)menu {
404404
joiner = @"\u00A0\u202B ";
405405
format = @"\u202B%d\u00A0%@";
406406
}
407-
[item setAttributedTitle:[self wrappedText:[NSString stringWithFormat:format, process.pid, [folders componentsJoinedByString:joiner]] width:max_width]];
407+
NSDictionary *useAttribs = attribs;
408+
if (!process.running) useAttribs = disabledAttribs;
409+
410+
[item setAttributedTitle:[self wrappedText:[NSString stringWithFormat:format, process.pid, [folders componentsJoinedByString:joiner]] width:max_width attributes:useAttribs]];
408411
[item setIndentationLevel:1];
409412
[item setRepresentedObject:process];
410413
[item setTarget:self];

0 commit comments

Comments
 (0)