X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/22ec357f346dd68b0340d4a9cea7279a31f38023..6b8a2b55809e875bb0aadc3ab9cbab181014d1a9:/OldMainController.m diff --git a/OldMainController.m b/OldMainController.m index aec922d..7ce374c 100755 --- a/OldMainController.m +++ b/OldMainController.m @@ -48,6 +48,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)note { + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; currentRemote = [self loadRemote]; [currentRemote begin]; @@ -63,8 +64,10 @@ selector:@selector(applicationLaunched:) name:NSWorkspaceDidLaunchApplicationNotification object:nil]; - - [self registerDefaults]; + + if ( ! [defaults objectForKey:@"menu"] ) { // If this is nil, defaults have never been registered. + [[PreferencesController sharedPrefs] registerDefaults]; + } statusItem = [[ITStatusItem alloc] initWithStatusBar:[NSStatusBar systemStatusBar] @@ -166,89 +169,6 @@ #pragma mark INSTANCE METHODS /*************************************************************************/ -- (void)registerDefaults -{ - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if (![defaults objectForKey:@"menu"]) { - BOOL found = NO; - NSMutableDictionary *loginwindow; - NSMutableArray *loginarray; - int i; - - [defaults 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"]; - - [defaults synchronize]; - loginwindow = [[defaults 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]]) { - found = YES; - } - } - - // - //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); - } - } - } - - if (![defaults integerForKey:@"SongsInAdvance"]) - { - [defaults setInteger:5 forKey:@"SongsInAdvance"]; - } - - if (![defaults objectForKey:@"showName"]) { - [defaults setBool:YES forKey:@"showName"]; - } - - if (![defaults objectForKey:@"showArtist"]) { - [defaults setBool:YES forKey:@"showArtist"]; - } - - if (![defaults objectForKey:@"showAlbum"]) { - [defaults setBool:NO forKey:@"showAlbum"]; - } - - if (![defaults objectForKey:@"showTime"]) { - [defaults setBool:NO forKey:@"showTime"]; - } -} - - (void)startTimerInNewThread { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];