X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/0605ae7fa0f13acc07644b5e09b3f4187518b3d8..a06b23045deb51ce036acf7bdcd3ab3c5514bfaf:/PreferencesController.m diff --git a/PreferencesController.m b/PreferencesController.m index e7421f4..96fcfea 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -10,6 +10,8 @@ #import #import +#import + #import #import #import @@ -17,6 +19,7 @@ #import #import +#import #import #import #import @@ -378,42 +381,19 @@ static PreferencesController *prefs = nil; } else if ( [sender tag] == 2020) { // update screen selection } else if ( [sender tag] == 2030) { - int effectTag = [[sender selectedItem] tag]; + Class selectedClass = [[sender selectedItem] representedObject]; 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 ) { - [sw setEntryEffect:[[[ITPivotWindowEffect alloc] initWithWindow:sw] autorelease]]; - } + [df setObject:NSStringFromClass(selectedClass) forKey:@"statusWindowAppearanceEffect"]; + [sw setEntryEffect:[[[selectedClass alloc] initWithWindow:sw] autorelease]]; [[sw entryEffect] setEffectTime:time]; } else if ( [sender tag] == 2040) { - int effectTag = [[sender selectedItem] tag]; + Class selectedClass = [[sender selectedItem] representedObject]; float time = ([df floatForKey:@"statusWindowVanishSpeed"] ? [df floatForKey:@"statusWindowVanishSpeed"] : 0.8); + [df setObject:NSStringFromClass(selectedClass) forKey:@"statusWindowVanishEffect"]; - [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 setExitEffect:[[[selectedClass alloc] initWithWindow:sw] autorelease]]; [[sw exitEffect] setEffectTime:time]; } else if ( [sender tag] == 2050) { @@ -469,6 +449,9 @@ static PreferencesController *prefs = nil; [self setCustomColor:[NSColor colorWithCalibratedWhite:0.15 alpha:0.70] updateWell:YES]; } + } else if ( [sender tag] == 2095) { + [sw vanish:self]; + [df setInteger:[sender indexOfSelectedItem] forKey:@"statusWindowSizing"]; } [df synchronize]; @@ -507,18 +490,22 @@ static PreferencesController *prefs = nil; nil] forKey:@"menu"]; [df setInteger:5 forKey:@"SongsInAdvance"]; - // [df setBool:YES forKey:@"showName"]; // Song info will always show song title. +// [df setBool:YES forKey:@"showName"]; // Song info will always show song title. [df setBool:YES forKey:@"showArtist"]; [df setBool:NO forKey:@"showAlbum"]; [df setBool:NO forKey:@"showTime"]; - [df setInteger:2100 forKey:@"statusWindowAppearanceEffect"]; - [df setInteger:2101 forKey:@"statusWindowVanishEffect"]; + [df setObject:@"ITCutWindowEffect" forKey:@"statusWindowAppearanceEffect"]; + [df setObject:@"ITDissolveWindowEffect" forKey:@"statusWindowVanishEffect"]; [df setFloat:0.8 forKey:@"statusWindowAppearanceSpeed"]; [df setFloat:0.8 forKey:@"statusWindowVanishSpeed"]; [df setFloat:4.0 forKey:@"statusWindowVanishDelay"]; + [df setInteger:(int)ITWindowPositionBottom forKey:@"statusWindowVerticalPosition"]; + [df setInteger:(int)ITWindowPositionLeft forKey:@"statusWindowHorizontalPosition"]; [df setBool:YES forKey:@"showSongInfoOnChange"]; - + + [df setObject:[NSArchiver archivedDataWithRootObject:[NSColor blueColor]] forKey:@"statusWindowBackgroundColor"]; + [df synchronize]; loginWindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy]; @@ -724,9 +711,13 @@ static PreferencesController *prefs = nil; - (void)setupUI { NSMutableDictionary *loginwindow; - NSMutableArray *loginarray; - NSEnumerator *loginEnum, *keyArrayEnum; - NSString *serverName; + NSMutableArray *loginarray; + NSEnumerator *loginEnum; + NSEnumerator *keyArrayEnum; + NSString *serverName; + NSData *colorData; + NSArray *effectClasses = [ITWindowEffect effectClasses]; + NSEnumerator *effectEnum = [effectClasses objectEnumerator]; int selectedBGStyle; id anItem; @@ -776,14 +767,36 @@ static PreferencesController *prefs = nil; // Setup the positioning controls // Setup effects controls - [appearanceEffectPopup selectItem:[appearanceEffectPopup itemAtIndex:[appearanceEffectPopup indexOfItemWithTag:[df integerForKey:@"statusWindowAppearanceEffect"]]]]; - [vanishEffectPopup selectItem:[vanishEffectPopup itemAtIndex:[vanishEffectPopup indexOfItemWithTag:[df integerForKey:@"statusWindowVanishEffect"]]]]; + // Populate the effects popups + [appearanceEffectPopup removeItemAtIndex:0]; + [vanishEffectPopup removeItemAtIndex:0]; + + while ( (anItem = [effectEnum nextObject]) ) { + [appearanceEffectPopup addItemWithTitle:[anItem effectName]]; + [vanishEffectPopup addItemWithTitle:[anItem effectName]]; + [[appearanceEffectPopup lastItem] setRepresentedObject:anItem]; + [[vanishEffectPopup lastItem] setRepresentedObject:anItem]; + } + + // Attempt to find the pref'd effect in the list. + // If it's not there, use cut/dissolve. + if ( [effectClasses containsObject:NSClassFromString([df stringForKey:@"statusWindowAppearanceEffect"])] ) { + [appearanceEffectPopup selectItemAtIndex:[effectClasses indexOfObject:NSClassFromString([df stringForKey:@"statusWindowAppearanceEffect"])]]; + } else { + [appearanceEffectPopup selectItemAtIndex:[effectClasses indexOfObject:NSClassFromString(@"ITCutWindowEffect")]]; + } + + if ( [effectClasses containsObject:NSClassFromString([df stringForKey:@"statusWindowVanishEffect"])] ) { + [vanishEffectPopup selectItemAtIndex:[effectClasses indexOfObject:NSClassFromString([df stringForKey:@"statusWindowVanishEffect"])]]; + } else { + [vanishEffectPopup selectItemAtIndex:[effectClasses indexOfObject:NSClassFromString(@"ITCutWindowEffect")]]; + } + [appearanceSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowAppearanceSpeed"])]; [vanishSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowVanishSpeed"])]; [vanishDelaySlider setFloatValue:[df floatForKey:@"statusWindowVanishDelay"]]; // Setup General Controls - selectedBGStyle = [df integerForKey:@"statusWindowBackgroundMode"]; [backgroundStylePopup selectItem:[backgroundStylePopup itemAtIndex:[backgroundStylePopup indexOfItemWithTag:selectedBGStyle]]]; @@ -795,8 +808,17 @@ static PreferencesController *prefs = nil; [backgroundColorPopup setEnabled:NO]; } - [backgroundColorWell setColor:(NSColor *)[NSUnarchiver unarchiveObjectWithData:[df dataForKey:@"statusWindowBackgroundColor"]]]; + colorData = [df dataForKey:@"statusWindowBackgroundColor"]; + + if ( colorData ) { + [backgroundColorWell setColor:(NSColor *)[NSUnarchiver unarchiveObjectWithData:colorData]]; + } else { + [backgroundColorWell setColor:[NSColor blueColor]]; + } + [showOnChangeCheckbox setState:([df boolForKey:@"showSongInfoOnChange"] ? NSOnState : NSOffState)]; + + [windowSizingPopup selectItem:[windowSizingPopup itemAtIndex:[windowSizingPopup indexOfItemWithTag:[df integerForKey:@"statusWindowSizing"]]]]; // Setup the sharing controls if ([df boolForKey:@"enableSharing"]) {