+ NSMutableDictionary *loginwindow;
+ NSMutableArray *loginarray;
+ NSEnumerator *loginEnum, *keyArrayEnum;
+ NSString *serverName;
+ id anItem;
+
+ 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];
+ [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
+ ITDebugLog(@"Setting launch at login state.");
+ [df synchronize];
+ loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy];
+ loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
+
+ loginEnum = [loginarray objectEnumerator];
+ while ( (anItem = [loginEnum nextObject]) ) {
+ if ([[[anItem objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]]) {
+ [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
+
+ // Setup effects controls
+ [appearanceEffectPopup selectItem:[appearanceEffectPopup itemAtIndex:[appearanceEffectPopup indexOfItemWithTag:[df integerForKey:@"statusWindowAppearanceEffect"]]]];
+ [vanishEffectPopup selectItem:[vanishEffectPopup itemAtIndex:[vanishEffectPopup indexOfItemWithTag:[df integerForKey:@"statusWindowVanishEffect"]]]];
+ [appearanceSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowAppearanceSpeed"])];
+ [vanishSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowVanishSpeed"])];
+ [vanishDelaySlider setFloatValue:[df floatForKey:@"statusWindowVanishDelay"]];
+ [showOnChangeCheckbox setState:([df boolForKey:@"showSongInfoOnChange"] ? NSOnState : NSOffState)];
+
+ // Setup the sharing controls
+ if ([df boolForKey:@"enableSharing"]) {
+ [shareMenuTunesCheckbox setState:NSOnState];
+ [useSharedMenuTunesCheckbox setEnabled:NO];
+ [selectSharedPlayerButton setEnabled:NO];
+ [passwordTextField setEnabled:YES];
+ [usePasswordCheckbox 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];
+ [usePasswordCheckbox setState:([df boolForKey:@"enableSharingPassword"] ? NSOnState : NSOffState)];
+ if ([df dataForKey:@"sharedPlayerPassword"]) {
+ [passwordTextField setStringValue:@"password"];
+ }
+ 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:@"-"];
+ }