X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/6a84de24eb2e905de206250ee5b3a95041930713..e350c02cdc2d016846056966c9595969aebcf559:/PreferencesController.m diff --git a/PreferencesController.m b/PreferencesController.m index 086e2ec..2f1eb9c 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -1,10 +1,19 @@ #import "PreferencesController.h" #import "MainController.h" +#import "StatusWindow.h" + #import #import #import #import +#import +#import +#import +#import +#import + + #define SENDER_STATE (([sender state] == NSOnState) ? YES : NO) /*************************************************************************/ @@ -93,10 +102,10 @@ 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]; - [window makeKeyAndOrderFront:self]; [NSApp activateIgnoringOtherApps:YES]; + [window makeKeyAndOrderFront:self]; } - (IBAction)changeGeneralSetting:(id)sender @@ -122,11 +131,14 @@ static PreferencesController *prefs = nil; } else if ( [sender tag] == 1090) { [df setBool:SENDER_STATE forKey:@"showTrackRating"]; } + [df synchronize]; } - (IBAction)changeStatusWindowSetting:(id)sender { + StatusWindow *sw = [StatusWindow sharedWindow]; + if ( [sender tag] == 2010) { [df setInteger:[sender selectedRow] forKey:@"statusWindowVerticalPosition"]; [df setInteger:[sender selectedColumn] forKey:@"statusWindowHorizontalPosition"]; @@ -134,19 +146,61 @@ static PreferencesController *prefs = nil; } else if ( [sender tag] == 2020) { // update screen selection } else if ( [sender tag] == 2030) { - // Update appearance effect + int effectTag = [[sender selectedItem] tag]; + float time = ([df floatForKey:@"statusWindowAppearanceSpeed"] ? [df floatForKey:@"statusWindowAppearanceSpeed"] : 0.8); + [df setInteger:effectTag forKey:@"statusWindowAppearanceEffect"]; + + if ( effectTag == 2100 ) { + [sw setEntryEffect:[[[ITCutWindowEffect alloc] initWithWindow:sw] autorelease]]; + } else if ( effectTag == 2101 ) { + [sw setEntryEffect:[[[ITDissolveWindowEffect alloc] initWithWindow:sw] autorelease]]; + } else if ( effectTag == 2102 ) { + [sw setEntryEffect:[[[ITSlideVerticallyWindowEffect alloc] initWithWindow:sw] autorelease]]; + } else if ( effectTag == 2103 ) { + [sw setEntryEffect:[[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:sw] autorelease]]; + } else if ( effectTag == 2104 ) { + NSLog(@"dflhgldf"); + [sw setEntryEffect:[[[ITPivotWindowEffect alloc] initWithWindow:sw] autorelease]]; + } + + [[sw entryEffect] setEffectTime:time]; + } else if ( [sender tag] == 2040) { - // Update Vanish Effect + int effectTag = [[sender selectedItem] tag]; + float time = ([df floatForKey:@"statusWindowVanishSpeed"] ? [df floatForKey:@"statusWindowVanishSpeed"] : 0.8); + + [df setInteger:[[sender selectedItem] tag] forKey:@"statusWindowVanishEffect"]; + + if ( effectTag == 2100 ) { + [sw setExitEffect:[[[ITCutWindowEffect alloc] initWithWindow:sw] autorelease]]; + } else if ( effectTag == 2101 ) { + [sw setExitEffect:[[[ITDissolveWindowEffect alloc] initWithWindow:sw] autorelease]]; + } else if ( effectTag == 2102 ) { + [sw setExitEffect:[[[ITSlideVerticallyWindowEffect alloc] initWithWindow:sw] autorelease]]; + } else if ( effectTag == 2103 ) { + [sw setExitEffect:[[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:sw] autorelease]]; + } else if ( effectTag == 2104 ) { + [sw setExitEffect:[[[ITPivotWindowEffect alloc] initWithWindow:sw] autorelease]]; + } + + [[sw exitEffect] setEffectTime:time]; + } else if ( [sender tag] == 2050) { - // Update appearance speed + float newTime = (-([sender floatValue])); + [df setFloat:newTime forKey:@"statusWindowAppearanceSpeed"]; + [[sw entryEffect] setEffectTime:newTime]; } else if ( [sender tag] == 2060) { - // Update vanish speed + float newTime = (-([sender floatValue])); + [df setFloat:newTime forKey:@"statusWindowVanishSpeed"]; + [[sw exitEffect] setEffectTime:newTime]; } else if ( [sender tag] == 2070) { - // Update vanish delay + [df setFloat:[sender floatValue] forKey:@"statusWindowVanishDelay"]; + [sw setExitDelay:[sender floatValue]]; } else if ( [sender tag] == 2080) { - // Update "Song Info window when song changes" setting. [df setBool:SENDER_STATE forKey:@"showSongInfoOnChange"]; } + + [df synchronize]; } - (IBAction)changeHotKey:(id)sender @@ -303,31 +357,32 @@ static PreferencesController *prefs = nil; if ( NSRunAlertPanel(NSLocalizedString(@"duplicateCombo", @"Duplicate Key Combo") , NSLocalizedString(@"duplicateCombo_msg", @"The specified key combo is already in use..."), NSLocalizedString(@"replace", @"Replace"), NSLocalizedString(@"cancel", @"Cancel"), nil) ) { [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:currentHotKey]; if ([enumKey isEqualToString:@"PlayPause"]) { - [playPauseButton setTitle:@""]; + [playPauseButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"NextTrack"]) { - [nextTrackButton setTitle:@""]; + [nextTrackButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"PrevTrack"]) { - [previousTrackButton setTitle:@""]; + [previousTrackButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"ShowPlayer"]) { - [showPlayerButton setTitle:@""]; + [showPlayerButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"TrackInfo"]) { - [trackInfoButton setTitle:@""]; + [trackInfoButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"UpcomingSongs"]) { - [upcomingSongsButton setTitle:@""]; + [upcomingSongsButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"IncrementVolume"]) { - [volumeIncrementButton setTitle:@""]; + [volumeIncrementButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"DecrementVolume"]) { - [volumeDecrementButton setTitle:@""]; + [volumeDecrementButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"IncrementRating"]) { - [ratingIncrementButton setTitle:@""]; + [ratingIncrementButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"DecrementRating"]) { - [ratingDecrementButton setTitle:@""]; + [ratingDecrementButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"ToggleShuffle"]) { - [toggleShuffleButton setTitle:@""]; + [toggleShuffleButton setTitle:@"(None)"]; } else if ([enumKey isEqualToString:@"ToggleLoop"]) { - [toggleLoopButton setTitle:@""]; + [toggleLoopButton setTitle:@"(None)"]; } [df setObject:[[ITKeyCombo clearKeyCombo] plistRepresentation] forKey:enumKey]; + [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:enumKey]; } else { return; } @@ -396,7 +451,7 @@ static PreferencesController *prefs = nil; string = [combo description]; if (string == nil) { - string = @""; + string = @"(None)"; } [keyComboField setStringValue:string]; } @@ -454,6 +509,7 @@ static PreferencesController *prefs = nil; @"rewind", @"showPlayer", @"separator", + @"quit", nil]; // Get our preferred menu @@ -602,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]; @@ -624,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]; } @@ -802,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; } }