Permalink
Browse files

Show the Passenger module warning when it's not installed and hide wh…

…en it is.
  • Loading branch information...
1 parent 7cbaa91 commit f885b8d6aa365092b362c6879f82a989f3b39bea @Manfred Manfred committed Mar 11, 2011
Showing with 27 additions and 13 deletions.
  1. +1 −9 English.lproj/PassengerPref.xib
  2. +26 −4 app/controllers/PassengerPref.m
@@ -919,7 +919,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<object class="NSCustomView" id="992940565">
<reference key="NSNextResponder" ref="453226259"/>
- <int key="NSvFlags">268</int>
+ <int key="NSvFlags">-2147483380</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSImageView" id="556412990">
@@ -2735,14 +2735,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="minorKey">./Classes/PassengerPref.h</string>
</object>
</object>
- <object class="IBPartialClassDescription">
- <string key="className">SFAuthorizationView</string>
- <string key="superclassName">NSView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">./Classes/SFAuthorizationView.h</string>
- </object>
- </object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
@@ -59,15 +59,32 @@ - (void) setupApplicationView {
- (void) setupPassengerModuleWarning {
NSUInteger index;
NSImageView *iconView;
+ NSTextField *warningMessage;
+
+ NSString *url = [NSString stringWithCString:"http://www.modrails.com" encoding:NSUTF8StringEncoding ];
+ NSRange occurence;
+ NSString *messageWithoutLink;
+ NSMutableAttributedString *messageWithLink;
index = [[passengerModuleWarning subviews] indexOfObjectPassingTest:^ BOOL (id object, NSUInteger index, BOOL *stop) {
return [object isKindOfClass:[NSImageView class]];
}];
iconView = [[passengerModuleWarning subviews] objectAtIndex:index];
- if (iconView) {
- NSLog(@"%@", [iconView description]);
- [iconView setImage:[[NSImage alloc] initByReferencingFile:@"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertCautionIcon.icns"]];
- }
+ [iconView setImage:[[NSImage alloc] initByReferencingFile:@"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertCautionIcon.icns"]];
+
+ index = [[passengerModuleWarning subviews] indexOfObjectPassingTest:^ BOOL (id object, NSUInteger index, BOOL *stop) {
+ return [object isKindOfClass:[NSTextField class]];
+ }];
+ warningMessage = [[passengerModuleWarning subviews] objectAtIndex:index];
+
+ messageWithoutLink = [warningMessage stringValue];
+ messageWithLink = [[NSMutableAttributedString alloc] initWithString:messageWithoutLink];
+ occurence = [messageWithoutLink rangeOfString:url];
+ [messageWithLink addAttribute:NSLinkAttributeName value:url range:occurence];
+ [messageWithLink addAttribute:NSForegroundColorAttributeName value:[NSColor blueColor] range:occurence];
+ [messageWithLink addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSSingleUnderlineStyle] range:occurence];
+ [messageWithLink addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11] range:NSMakeRange(0, [messageWithLink length])];
+ [warningMessage setAttributedStringValue:messageWithLink];
}
#pragma SFAuthorizationView delegate methods
@@ -313,6 +330,11 @@ - (void)checkIfPassengerModuleInstalled {
// If we don't know or when it's not yet the case, check.
if (!passengerModuleInstalled) {
[self setPassengerModuleInstalled:[[CLI sharedInstance] isPassengerModuleInstalled]];
+ if (passengerModuleInstalled) {
+ [passengerModuleWarning setHidden:YES];
+ } else {
+ [passengerModuleWarning setHidden:NO];
+ }
}
}

0 comments on commit f885b8d

Please sign in to comment.