+ NSMutableDictionary *loginwindow;
+ NSMutableArray *loginarray;
+ NSEnumerator *loginEnum;
+ id anItem;
+ ITDebugLog(@"Setting up preferences UI.");
+ // Fill in the number of songs in advance to show field
+ [songsInAdvance setIntValue:[df integerForKey:@"SongsInAdvance"]];
+
+ // Fill in hot key buttons
+ if ([df objectForKey:@"PlayPause"]) {
+ ITDebugLog(@"Setting up \"PlayPause\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"PlayPause"]];
+ [hotKeysDictionary setObject:anItem forKey:@"PlayPause"];
+ [playPauseButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"PlayPause"];
+ [playPauseButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"NextTrack"]) {
+ ITDebugLog(@"Setting up \"NextTrack\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"NextTrack"]];
+ [hotKeysDictionary setObject:anItem forKey:@"NextTrack"];
+ [nextTrackButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"NextTrack"];
+ [nextTrackButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"PrevTrack"]) {
+ ITDebugLog(@"Setting up \"PrevTrack\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"PrevTrack"]];
+ [hotKeysDictionary setObject:anItem forKey:@"PrevTrack"];
+ [previousTrackButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"PrevTrack"];
+ [previousTrackButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"ShowPlayer"]) {
+ ITDebugLog(@"Setting up \"ShowPlayer\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ShowPlayer"]];
+ [hotKeysDictionary setObject:anItem forKey:@"ShowPlayer"];
+ [showPlayerButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"ShowPlayer"];
+ [showPlayerButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"TrackInfo"]) {
+ ITDebugLog(@"Setting up \"TrackInfo\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"TrackInfo"]];
+ [hotKeysDictionary setObject:anItem forKey:@"TrackInfo"];
+ [trackInfoButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"TrackInfo"];
+ [trackInfoButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"UpcomingSongs"]) {
+ ITDebugLog(@"Setting up \"UpcomingSongs\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"UpcomingSongs"]];
+ [hotKeysDictionary setObject:anItem forKey:@"UpcomingSongs"];
+ [upcomingSongsButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"UpcomingSongs"];
+ [upcomingSongsButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"IncrementVolume"]) {
+ ITDebugLog(@"Setting up \"IncrementVolume\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"IncrementVolume"]];
+ [hotKeysDictionary setObject:anItem forKey:@"IncrementVolume"];
+ [volumeIncrementButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"IncrementVolume"];
+ [volumeIncrementButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"DecrementVolume"]) {
+ ITDebugLog(@"Setting up \"DecrementVolume\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"DecrementVolume"]];
+ [hotKeysDictionary setObject:anItem forKey:@"DecrementVolume"];
+ [volumeDecrementButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"DecrementVolume"];
+ [volumeDecrementButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"IncrementRating"]) {
+ ITDebugLog(@"Setting up \"IncrementRating\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"IncrementRating"]];
+ [hotKeysDictionary setObject:anItem forKey:@"IncrementRating"];
+ [ratingIncrementButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"IncrementRating"];
+ [ratingIncrementButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"DecrementRating"]) {
+ ITDebugLog(@"Setting up \"DecrementRating\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"DecrementRating"]];
+ [hotKeysDictionary setObject:anItem forKey:@"DecrementRating"];
+ [ratingDecrementButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"DecrementRating"];
+ [ratingDecrementButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"ToggleLoop"]) {
+ ITDebugLog(@"Setting up \"ToggleLoop\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ToggleLoop"]];
+ [hotKeysDictionary setObject:anItem forKey:@"ToggleLoop"];
+ [toggleLoopButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"ToggleLoop"];
+ [toggleLoopButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ if ([df objectForKey:@"ToggleShuffle"]) {
+ ITDebugLog(@"Setting up \"ToggleShuffle\" hot key.");
+ anItem = [ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ToggleShuffle"]];
+ [hotKeysDictionary setObject:anItem forKey:@"ToggleShuffle"];
+ [toggleShuffleButton setTitle:[anItem description]];
+ } else {
+ [hotKeysDictionary setObject:[ITKeyCombo clearKeyCombo] forKey:@"ToggleShuffle"];
+ [toggleShuffleButton setTitle:[[ITKeyCombo clearKeyCombo] description]];
+ }
+
+ 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];