X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/b3a6450e2033922abc9e4d85a02f942a527c816a..8d3dd2ae3b78305f66e06d48770ef24222b7a0ef:/PreferencesController.m diff --git a/PreferencesController.m b/PreferencesController.m index 9526d8f..c8ac15b 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -1,10 +1,20 @@ #import "PreferencesController.h" #import "MainController.h" +#import "StatusWindow.h" +#import "MyTableView.h" + #import #import #import #import +#import +#import +#import +#import +#import + + #define SENDER_STATE (([sender state] == NSOnState) ? YES : NO) /*************************************************************************/ @@ -96,7 +106,6 @@ static PreferencesController *prefs = nil; [window setLevel:NSStatusWindowLevel]; [window center]; [window makeKeyAndOrderFront:self]; - [NSApp activateIgnoringOtherApps:YES]; } - (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 @@ -369,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]; + } + } +} /*************************************************************************/ @@ -443,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", @@ -454,7 +523,7 @@ static PreferencesController *prefs = nil; @"fastForward", @"rewind", @"showPlayer", - @"separator", + @"quit", nil]; // Get our preferred menu @@ -603,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]; @@ -625,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]; } @@ -803,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; } }