From: Kent Sutherland Date: Thu, 18 Sep 2003 01:59:31 +0000 (+0000) Subject: Added rating checkbox outlet in Prefs nib and controller. Rating shows up X-Git-Tag: v1.0~61 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/e350c02cdc2d016846056966c9595969aebcf559 Added rating checkbox outlet in Prefs nib and controller. Rating shows up in menu. Quit menu item shows up in prefs tables now. --- diff --git a/English.lproj/Preferences.nib/classes.nib b/English.lproj/Preferences.nib/classes.nib index f2bcacf..2c165fa 100755 --- a/English.lproj/Preferences.nib/classes.nib +++ b/English.lproj/Preferences.nib/classes.nib @@ -27,6 +27,7 @@ nextTrackButton = NSButton; playPauseButton = NSButton; previousTrackButton = NSButton; + ratingCheckbox = NSButton; ratingDecrementButton = NSButton; ratingIncrementButton = NSButton; showPlayerButton = NSButton; diff --git a/English.lproj/Preferences.nib/info.nib b/English.lproj/Preferences.nib/info.nib index 7718757..d9513a1 100755 --- a/English.lproj/Preferences.nib/info.nib +++ b/English.lproj/Preferences.nib/info.nib @@ -3,9 +3,9 @@ IBDocumentLocation - 1 3 356 240 0 0 1056 770 + 6 66 356 240 0 0 1152 746 IBFramework Version - 286.0 + 291.0 IBGroupedObjects 0 diff --git a/English.lproj/Preferences.nib/keyedobjects.nib b/English.lproj/Preferences.nib/keyedobjects.nib index f99cf5d..59710a3 100755 Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ diff --git a/MenuController.m b/MenuController.m index b862318..cfd2909 100755 --- a/MenuController.m +++ b/MenuController.m @@ -228,6 +228,34 @@ action:nil keyEquivalent:@""]; } + + if ([defaults boolForKey:@"showTrackRating"]) { + NSString *string; + switch ((int)([currentRemote currentSongRating] * 5)) { + case 0: + string = [NSString stringWithUTF8String:"☆☆☆☆☆"]; + break; + case 1: + string = [NSString stringWithUTF8String:"★☆☆☆☆"]; + break; + case 2: + string = [NSString stringWithUTF8String:"★★☆☆☆"]; + break; + case 3: + string = [NSString stringWithUTF8String:"★★★☆☆"]; + break; + case 4: + string = [NSString stringWithUTF8String:"★★★★☆"]; + break; + case 5: + string = [NSString stringWithUTF8String:"★★★★★"]; + break; + } + [menu addItemWithTitle: + [@" " stringByAppendingString:string] + action:nil + keyEquivalent:@""]; + } } else { [menu addItemWithTitle:NSLocalizedString(@"noSong", @"No Song") action:NULL keyEquivalent:@""]; } diff --git a/PreferencesController.h b/PreferencesController.h index 761a518..1f0094d 100755 --- a/PreferencesController.h +++ b/PreferencesController.h @@ -30,6 +30,7 @@ IBOutlet NSButton *nextTrackButton; IBOutlet NSButton *playPauseButton; IBOutlet NSButton *previousTrackButton; + IBOutlet NSButton *ratingCheckbox; IBOutlet NSButton *ratingDecrementButton; IBOutlet NSButton *ratingIncrementButton; IBOutlet NSTextField *songsInAdvance; diff --git a/PreferencesController.m b/PreferencesController.m index 1cc9355..2f1eb9c 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -509,6 +509,7 @@ static PreferencesController *prefs = nil; @"rewind", @"showPlayer", @"separator", + @"quit", nil]; // Get our preferred menu @@ -657,6 +658,7 @@ static PreferencesController *prefs = nil; [artistCheckbox setState:[df boolForKey:@"showArtist"] ? NSOnState : NSOffState]; [trackTimeCheckbox setState:[df boolForKey:@"showTime"] ? NSOnState : NSOffState]; [trackNumberCheckbox setState:[df boolForKey:@"showTrackNumber"] ? NSOnState : NSOffState]; + [ratingCheckbox setState:[df boolForKey:@"showTrackRating"] ? NSOnState : NSOffState]; // Set the launch at login checkbox state [df synchronize]; @@ -679,57 +681,31 @@ static PreferencesController *prefs = nil; - (void)setLaunchesAtLogin:(BOOL)flag { - if ( flag ) { - NSMutableDictionary *loginwindow; - NSMutableArray *loginarray; - ComponentInstance temp = OpenDefaultComponent(kOSAComponentType, kAppleScriptSubtype); - int i; - BOOL skip = NO; - - [df synchronize]; - loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy]; - loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"]; - - for (i = 0; i < [loginarray count]; i++) { - NSDictionary *tempDict = [loginarray objectAtIndex:i]; - if ([[[tempDict objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]]) { - skip = YES; - } - } - - if (!skip) { - AEDesc scriptDesc, resultDesc; - NSString *script = [NSString stringWithFormat:@"tell application \"System Events\"\nmake new login item at end of login items with properties {path:\"%@\", kind:\"APPLICATION\"}\nend tell", [[NSBundle mainBundle] bundlePath]]; - - AECreateDesc(typeChar, [script cString], [script cStringLength], - &scriptDesc); - - OSADoScript(temp, &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc); - - AEDisposeDesc(&scriptDesc); - AEDisposeDesc(&resultDesc); - CloseComponent(temp); - } - + NSMutableDictionary *loginwindow; + NSMutableArray *loginarray; + + [df synchronize]; + loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy]; + loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"]; + + if (flag) { + NSDictionary *itemDict = [NSDictionary dictionaryWithObjectsAndKeys: + [[NSBundle mainBundle] bundlePath], @"Path", + [NSNumber numberWithInt:0], @"Hide", nil]; + [loginarray addObject:itemDict]; } else { - NSMutableDictionary *loginwindow; - NSMutableArray *loginarray; int i; - - [df synchronize]; - loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy]; - loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"]; - for (i = 0; i < [loginarray count]; i++) { NSDictionary *tempDict = [loginarray objectAtIndex:i]; if ([[[tempDict objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]]) { [loginarray removeObjectAtIndex:i]; - [df setPersistentDomain:loginwindow forName:@"loginwindow"]; - [df synchronize]; break; } } } + [df setPersistentDomain:loginwindow forName:@"loginwindow"]; + [df synchronize]; + [loginwindow release]; } @@ -857,7 +833,7 @@ static PreferencesController *prefs = nil; if ([[[info draggingPasteboard] types] containsObject:@"MenuTableViewPboardType"]) { NSString *item = [myItems objectAtIndex:[[[info draggingPasteboard] stringForType:@"MenuTableViewPboardType"] intValue]]; - if ([item isEqualToString:@"Preferences"] || [item isEqualToString:@"Quit"]) { + if ([item isEqualToString:@"preferences"]) { return NSDragOperationNone; } }