X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/6f6c21caaebee598943084dd66a15f21a7f65cb5..0605ae7fa0f13acc07644b5e09b3f4187518b3d8:/PreferencesController.m diff --git a/PreferencesController.m b/PreferencesController.m index f5ffe1c..e7421f4 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -16,6 +16,7 @@ #import #import +#import #import #import #import @@ -35,6 +36,7 @@ - (void)setupCustomizationTables; - (void)setupMenuItems; - (void)setupUI; +- (void)setCustomColor:(NSColor *)color updateWell:(BOOL)update; - (IBAction)changeMenus:(id)sender; - (void)setLaunchesAtLogin:(BOOL)flag; @end @@ -100,6 +102,7 @@ static PreferencesController *prefs = nil; controller = nil; [self setupWindow]; // Load in the nib, and perform any initial setup. + [[NSColorPanel sharedColorPanel] setShowsAlpha:YES]; } return self; } @@ -184,6 +187,11 @@ static PreferencesController *prefs = nil; [window performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.0]; } +- (IBAction)showTestWindow:(id)sender +{ + [controller showTestWindow]; +} + - (IBAction)changeGeneralSetting:(id)sender { ITDebugLog(@"Changing general setting of tag %i.", [sender tag]); @@ -364,7 +372,8 @@ static PreferencesController *prefs = nil; if ( [sender tag] == 2010) { [df setInteger:[sender selectedRow] forKey:@"statusWindowVerticalPosition"]; [df setInteger:[sender selectedColumn] forKey:@"statusWindowHorizontalPosition"]; - [[StatusWindowController sharedController] readDefaults]; + [sw setHorizontalPosition:[sender selectedColumn]]; + [sw setVerticalPosition:[sender selectedRow]]; // update the window's position here } else if ( [sender tag] == 2020) { // update screen selection @@ -420,10 +429,61 @@ static PreferencesController *prefs = nil; [sw setExitDelay:[sender floatValue]]; } else if ( [sender tag] == 2080) { [df setBool:SENDER_STATE forKey:@"showSongInfoOnChange"]; + } else if ( [sender tag] == 2090) { + + int setting = [sender indexOfSelectedItem]; + + if ( setting == 0 ) { + [(ITTSWBackgroundView *)[sw contentView] setBackgroundMode:ITTSWBackgroundApple]; + [backgroundColorWell setEnabled:NO]; + [backgroundColorPopup setEnabled:NO]; + } else if ( setting == 1 ) { + [(ITTSWBackgroundView *)[sw contentView] setBackgroundMode:ITTSWBackgroundReadable]; + [backgroundColorWell setEnabled:NO]; + [backgroundColorPopup setEnabled:NO]; + } else if ( setting == 2 ) { + [(ITTSWBackgroundView *)[sw contentView] setBackgroundMode:ITTSWBackgroundColored]; + [backgroundColorWell setEnabled:YES]; + [backgroundColorPopup setEnabled:YES]; + } + + [df setInteger:setting forKey:@"statusWindowBackgroundMode"]; + + } else if ( [sender tag] == 2091) { + [self setCustomColor:[sender color] updateWell:NO]; + } else if ( [sender tag] == 2092) { + + int selectedItem = [sender indexOfSelectedItem]; + + if ( selectedItem == 1 ) { // An NSPopUpButton in PullDown mode uses item 0 as its title. Its first selectable item is 1. + [self setCustomColor:[NSColor colorWithCalibratedRed:0.92549 green:0.686275 blue:0.0 alpha:1.0] updateWell:YES]; + } else if ( selectedItem == 2 ) { + [self setCustomColor:[NSColor colorWithCalibratedRed:0.380392 green:0.670588 blue:0.0 alpha:1.0] updateWell:YES]; + } else if ( selectedItem == 3 ) { + [self setCustomColor:[NSColor colorWithCalibratedRed:0.443137 green:0.231373 blue:0.619608 alpha:1.0] updateWell:YES]; + } else if ( selectedItem == 4 ) { + [self setCustomColor:[NSColor colorWithCalibratedRed:0.831373 green:0.12549 blue:0.509804 alpha:1.0] updateWell:YES]; + } else if ( selectedItem == 5 ) { + [self setCustomColor:[NSColor colorWithCalibratedRed:0.00784314 green:0.611765 blue:0.662745 alpha:1.0] updateWell:YES]; + } else { + [self setCustomColor:[NSColor colorWithCalibratedWhite:0.15 alpha:0.70] updateWell:YES]; + } + } + [df synchronize]; } +- (void)setCustomColor:(NSColor *)color updateWell:(BOOL)update +{ + [(ITTSWBackgroundView *)[[StatusWindow sharedWindow] contentView] setBackgroundColor:color]; + [df setObject:[NSArchiver archivedDataWithRootObject:color] forKey:@"statusWindowBackgroundColor"]; + + if ( update ) { + [backgroundColorWell setColor:color]; + } +} + - (void)registerDefaults { BOOL found = NO; @@ -667,6 +727,7 @@ static PreferencesController *prefs = nil; NSMutableArray *loginarray; NSEnumerator *loginEnum, *keyArrayEnum; NSString *serverName; + int selectedBGStyle; id anItem; ITDebugLog(@"Setting up preferences UI."); @@ -720,8 +781,23 @@ static PreferencesController *prefs = nil; [appearanceSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowAppearanceSpeed"])]; [vanishSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowVanishSpeed"])]; [vanishDelaySlider setFloatValue:[df floatForKey:@"statusWindowVanishDelay"]]; - [showOnChangeCheckbox setState:([df boolForKey:@"showSongInfoOnChange"] ? NSOnState : NSOffState)]; + + // Setup General Controls + selectedBGStyle = [df integerForKey:@"statusWindowBackgroundMode"]; + [backgroundStylePopup selectItem:[backgroundStylePopup itemAtIndex:[backgroundStylePopup indexOfItemWithTag:selectedBGStyle]]]; + + if ( selectedBGStyle == ITTSWBackgroundColored ) { + [backgroundColorWell setEnabled:YES]; + [backgroundColorPopup setEnabled:YES]; + } else { + [backgroundColorWell setEnabled:NO]; + [backgroundColorPopup setEnabled:NO]; + } + + [backgroundColorWell setColor:(NSColor *)[NSUnarchiver unarchiveObjectWithData:[df dataForKey:@"statusWindowBackgroundColor"]]]; + [showOnChangeCheckbox setState:([df boolForKey:@"showSongInfoOnChange"] ? NSOnState : NSOffState)]; + // Setup the sharing controls if ([df boolForKey:@"enableSharing"]) { [shareMenuTunesCheckbox setState:NSOnState]; @@ -850,7 +926,7 @@ static PreferencesController *prefs = nil; NSString *object = [myItems objectAtIndex:rowIndex]; if ([[aTableColumn identifier] isEqualToString:@"name"]) { if ([object isEqualToString:@"showPlayer"]) { - NSString *string; + NSString *string = nil; NS_DURING string = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"show", @"Show"), [[controller currentRemote] playerSimpleName]]; NS_HANDLER @@ -871,7 +947,7 @@ static PreferencesController *prefs = nil; NSString *object = [availableItems objectAtIndex:rowIndex]; if ([[aTableColumn identifier] isEqualToString:@"name"]) { if ([object isEqualToString:@"showPlayer"]) { - NSString *string; + NSString *string = nil; NS_DURING string = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"show", @"Show"), [[controller currentRemote] playerSimpleName]]; NS_HANDLER