+ NSEnumerator *itemEnum;
+ id anItem;
+ ITDebugLog(@"Setting up table view arrays.");
+ // Set the list of items you can have.
+ availableItems = [[NSMutableArray alloc] initWithObjects:
+ @"separator",
+ @"trackInfo",
+ @"upcomingSongs",
+ @"playlists",
+ @"eqPresets",
+ @"songRating",
+ @"playPause",
+ @"nextTrack",
+ @"prevTrack",
+ @"fastForward",
+ @"rewind",
+ @"showPlayer",
+ @"quit",
+ nil];
+
+ // Get our preferred menu
+ myItems = [[df arrayForKey:@"menu"] mutableCopy];
+
+ // Delete items in the availableItems array that are already part of the menu
+ itemEnum = [myItems objectEnumerator];
+ while ( (anItem = [itemEnum nextObject]) ) {
+ if (![anItem isEqualToString:@"separator"]) {
+ [availableItems removeObject:anItem];
+ }
+ }
+
+ // Items that show should a submenu image
+ submenuItems = [[NSArray alloc] initWithObjects:
+ @"upcomingSongs",
+ @"playlists",
+ @"eqPresets",
+ @"songRating",
+ nil];
+}
+
+- (void)setupUI
+{
+ NSEnumerator *keyArrayEnum;
+ NSString *serverName;
+ NSData *colorData;
+ int selectedBGStyle;
+ id anItem;
+
+ [df setInteger:MT_CURRENT_VERSION forKey:@"appVersion"];
+
+ ITDebugLog(@"Setting up preferences UI.");
+ // Fill in the number of songs in advance to show field
+ [songsInAdvance setIntValue:[df integerForKey:@"SongsInAdvance"]];
+
+ // Fill hot key array
+ keyArrayEnum = [hotKeysArray objectEnumerator];
+
+ while ( (anItem = [keyArrayEnum nextObject]) ) {
+ if ([df objectForKey:anItem]) {
+ ITDebugLog(@"Setting up \"%@\" hot key.", anItem);
+ [hotKeysDictionary setObject:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:anItem]] forKey:anItem];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:anItem];
+ }
+ }
+
+ ITDebugLog(@"Setting up track info checkboxes.");
+ // Check current track info buttons
+ [albumCheckbox setState:[df boolForKey:@"showAlbum"] ? NSOnState : NSOffState];
+ [nameCheckbox setState:NSOnState]; // Song info will ALWAYS show song title.
+ [nameCheckbox setEnabled:NO]; // Song info will ALWAYS show song title.
+ [artistCheckbox setState:[df boolForKey:@"showArtist"] ? NSOnState : NSOffState];
+ [composerCheckbox setState:[df boolForKey:@"showComposer"] ? NSOnState : NSOffState];
+ [trackTimeCheckbox setState:[df boolForKey:@"showTime"] ? NSOnState : NSOffState];
+ [trackNumberCheckbox setState:[df boolForKey:@"showTrackNumber"] ? NSOnState : NSOffState];
+ [ratingCheckbox setState:[df boolForKey:@"showTrackRating"] ? NSOnState : NSOffState];
+ [albumArtworkCheckbox setState:[df boolForKey:@"showAlbumArtwork"] ? NSOnState : NSOffState];
+
+ if ([df boolForKey:@"runScripts"]) {
+ [runScriptsCheckbox setState:NSOnState];
+ [showScriptsButton setEnabled:YES];
+ } else {
+ [showScriptsButton setEnabled:NO];
+ }
+
+ // Set the launch at login checkbox state
+ ITDebugLog(@"Setting launch at login state.");
+ /*if (ITDoesApplicationLaunchOnLogin([[NSBundle mainBundle] bundlePath])) {
+ [launchAtLoginCheckbox setState:NSOnState];
+ }*/
+
+ // Set the launch player checkbox state
+ ITDebugLog(@"Setting launch player with MenuTunes state.");
+ [launchPlayerAtLaunchCheckbox setState:[df boolForKey:@"LaunchPlayerWithMT"] ? NSOnState : NSOffState];
+
+ // Setup the positioning controls
+ [positionMatrix selectCellAtRow:[df integerForKey:@"statusWindowVerticalPosition"]
+ column:[df integerForKey:@"statusWindowHorizontalPosition"]];
+
+ // Setup effects controls
+ // Populate the effects popups
+ [appearanceEffectPopup setAutoenablesItems:NO];
+ [vanishEffectPopup setAutoenablesItems:NO];
+ [self repopulateEffectPopupsForVerticalPosition:[df integerForKey:@"statusWindowVerticalPosition"]
+ horizontalPosition:[df integerForKey:@"statusWindowHorizontalPosition"]];
+
+ // 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]]];
+
+ if ( selectedBGStyle == ITTSWBackgroundColored ) {
+ [backgroundColorWell setEnabled:YES];
+ [backgroundColorPopup setEnabled:YES];
+ } else {
+ [backgroundColorWell setEnabled:NO];
+ [backgroundColorPopup setEnabled:NO];
+ }
+
+ 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"]) {
+ [shareMenuTunesCheckbox setState:NSOnState];
+ [useSharedMenuTunesCheckbox setEnabled:NO];
+ [selectSharedPlayerButton setEnabled:NO];
+ [passwordTextField setEnabled:YES];
+ [nameTextField setEnabled:YES];
+ } else if ([df boolForKey:@"useSharedPlayer"]) {
+ [useSharedMenuTunesCheckbox setState:NSOnState];
+ [shareMenuTunesCheckbox setEnabled:NO];
+ [selectSharedPlayerButton setEnabled:YES];
+ }
+
+ [[NSNotificationCenter defaultCenter] addObserver:sharingTableView selector:@selector(reloadData) name:@"ITMTFoundNetService" object:nil];
+
+ serverName = [df stringForKey:@"sharedPlayerName"];
+ if (!serverName || [serverName length] == 0) {
+ serverName = @"MenuTunes Shared Player";
+ }
+ [nameTextField setStringValue:serverName];
+
+ [selectPlayerBox setContentView:zeroConfView];
+ if ([[df dataForKey:@"sharedPlayerPassword"] length] > 0) {
+ [passwordTextField setStringValue:@"p4s5w0rdMT1.2"];
+ } else {
+ [passwordTextField setStringValue:@""];
+ }
+ if ([df stringForKey:@"sharedPlayerHost"]) {
+ [hostTextField setStringValue:[df stringForKey:@"sharedPlayerHost"]];
+ }
+
+ if ([[NetworkController sharedController] isConnectedToServer]) {
+ [selectedPlayerTextField setStringValue:[[[NetworkController sharedController] networkObject] serverName]];
+ [locationTextField setStringValue:[[NetworkController sharedController] remoteHost]];
+ } else {
+ [selectedPlayerTextField setStringValue:@"No shared player selected."];
+ [locationTextField setStringValue:@"-"];
+ }