X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/97a58d16b59657d99b396a9d7e3ef2eadb357fa8..3b16f08f4e3b0f3b3105f79b12d2f0e0c7564a6e:/PreferencesController.m diff --git a/PreferencesController.m b/PreferencesController.m index 1cc9355..c8ac15b 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -1,6 +1,7 @@ #import "PreferencesController.h" #import "MainController.h" #import "StatusWindow.h" +#import "MyTableView.h" #import #import @@ -102,9 +103,8 @@ static PreferencesController *prefs = nil; [launchPlayerAtLaunchCheckbox setTitle:[NSString stringWithFormat:@"Launch %@ when MenuTunes launches", [[controller currentRemote] playerSimpleName]]]; //This isn't localized... } -// [window setLevel:NSStatusWindowLevel]; + [window setLevel:NSStatusWindowLevel]; [window center]; - [NSApp activateIgnoringOtherApps:YES]; [window makeKeyAndOrderFront:self]; } @@ -423,6 +423,20 @@ static PreferencesController *prefs = nil; [self cancelHotKey:sender]; } +- (void)deletePressedInTableView:(NSTableView *)tableView +{ + if (tableView == menuTableView) { + int selRow = [tableView selectedRow]; + if (selRow != - 1) { + NSString *object = [myItems objectAtIndex:selRow]; + if (![object isEqualToString:@"separator"]) + [availableItems addObject:object]; + [myItems removeObjectAtIndex:selRow]; + [menuTableView reloadData]; + [allTableView reloadData]; + } + } +} /*************************************************************************/ @@ -497,6 +511,7 @@ static PreferencesController *prefs = nil; id anItem; // Set the list of items you can have. availableItems = [[NSMutableArray alloc] initWithObjects: + @"separator", @"trackInfo", @"upcomingSongs", @"playlists", @@ -508,7 +523,7 @@ static PreferencesController *prefs = nil; @"fastForward", @"rewind", @"showPlayer", - @"separator", + @"quit", nil]; // Get our preferred menu @@ -657,6 +672,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 +695,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 +847,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; } }