X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/ef4f5a3e753596396e93ba33b7e2ab5e8b53c5d8..6b8a2b55809e875bb0aadc3ab9cbab181014d1a9:/PreferencesController.m diff --git a/PreferencesController.m b/PreferencesController.m index 2206fab..217afb4 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -61,10 +61,8 @@ static PreferencesController *prefs = nil; - (void)setController:(id)object { -NSLog(@"foo"); [controller autorelease]; controller = [object retain]; -NSLog(@"bar"); } @@ -73,7 +71,6 @@ NSLog(@"bar"); #pragma mark INSTANCE METHODS /*************************************************************************/ - - (IBAction)showPrefsWindow:(id)sender { if (! window) { // If window does not exist yet, then the nib hasn't been loaded. @@ -180,10 +177,70 @@ NSLog(@"bar"); [controller clearHotKeys]; } -- (IBAction)cancel:(id)sender +- (void)registerDefaults { - [window close]; - [controller closePreferences]; + BOOL found = NO; + NSMutableDictionary *loginWindow; + NSMutableArray *loginArray; + NSEnumerator *loginEnum; + id anItem; + + [df setObject:[NSArray arrayWithObjects: + @"Play/Pause", + @"Next Track", + @"Previous Track", + @"Fast Forward", + @"Rewind", + @"", + @"Upcoming Songs", + @"Playlists", + @"Song Rating", + @"", + @"PreferencesÉ", + @"Quit", + @"", + @"Current Track Info", + nil] forKey:@"menu"]; + + [df setInteger:5 forKey:@"SongsInAdvance"]; + [df setBool:YES forKey:@"showName"]; + [df setBool:YES forKey:@"showArtist"]; + [df setBool:NO forKey:@"showAlbum"]; + [df setBool:NO forKey:@"showTime"]; + + [df synchronize]; + + loginWindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy]; + loginArray = [loginWindow objectForKey:@"AutoLaunchedApplicationDictionary"]; + loginEnum = [loginArray objectEnumerator]; + + while ( (anItem = [loginEnum nextObject]) ) { + if ( [[[anItem objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]] ) { + found = YES; + } + } + + [loginWindow release]; + + // This is teh sux + // We must fix it so it is no longer suxy + if (!found) { + if (NSRunInformationalAlertPanel(@"Auto-launch MenuTunes", @"Would you like MenuTunes to automatically launch at login?", @"Yes", @"No", nil) == NSOKButton) { + 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]]; + ComponentInstance asComponent = OpenDefaultComponent(kOSAComponentType, kAppleScriptSubtype); + + AECreateDesc(typeChar, [script cString], [script cStringLength], + &scriptDesc); + + OSADoScript(asComponent, &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc); + + AEDisposeDesc(&scriptDesc); + AEDisposeDesc(&resultDesc); + + CloseComponent(asComponent); + } + } } - (IBAction)cancelHotKey:(id)sender @@ -203,7 +260,7 @@ NSLog(@"bar"); NSString *string = [combo userDisplayRep]; if (string == nil) { - string = @"None"; + string = @""; } if ([setHotKey isEqualToString:@"PlayPause"]) { if (([combo isEqual:nextTrackCombo] || [combo isEqual:prevTrackCombo] || @@ -269,13 +326,6 @@ NSLog(@"bar"); [self cancelHotKey:sender]; } -- (IBAction)save:(id)sender -{ - [self apply:nil]; - [window close]; - [controller closePreferences]; -} - - (IBAction)setCurrentTrackInfo:(id)sender { [self setKeyCombo:trackInfoCombo]; @@ -306,6 +356,12 @@ NSLog(@"bar"); [self setHotKey:@"UpcomingSongs"]; } + +/*************************************************************************/ +#pragma mark - +#pragma mark HOTKEY SUPPORT METHODS +/*************************************************************************/ + - (void)setHotKey:(NSString *)key { setHotKey = key;