- int i;
- NSImageCell *imgCell = [[[NSImageCell alloc] init] autorelease];
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-
- mt = [tunes retain];
- [mt registerDefaultsIfNeeded];
-
- //Load the nib
- [NSBundle loadNibNamed:@"Preferences" owner:self];
-
- //Show our window
- [window setLevel:NSStatusWindowLevel];
- [window center];
- [window makeKeyAndOrderFront:nil];
-
- //Set the table view cells up
- [imgCell setImageScaling:NSScaleNone];
- [[menuTableView tableColumnWithIdentifier:@"submenu"] setDataCell:imgCell];
- [[allTableView tableColumnWithIdentifier:@"submenu"] setDataCell:imgCell];
-
- //Register for drag and drop
- [menuTableView registerForDraggedTypes:[NSArray arrayWithObjects:@"MenuTableViewPboardType", @"AllTableViewPboardType", nil]];
- [allTableView registerForDraggedTypes:[NSArray arrayWithObjects:@"MenuTableViewPboardType", @"AllTableViewPboardType", nil]];
-
- //Set the list of items you can have.
- availableItems = [[NSMutableArray alloc] initWithObjects:@"Current Track Info", @"Upcoming Songs", @"Playlists", @"EQ Presets", @"Play/Pause", @"Next Track", @"Previous Track", @"Fast Forward", @"Rewind", @"<separator>", nil];
-
- //Get our preferred menu
- myItems = [[[NSUserDefaults standardUserDefaults] arrayForKey:@"menu"] mutableCopy];
-
- //Delete items in the availableItems array that are already part of the menu
- for (i = 0; i < [myItems count]; i++) {
- NSString *item = [myItems objectAtIndex:i];
- if (![item isEqualToString:@"<separator>"])
- {
- [availableItems removeObject:item];
- }
- }
-
- //Items that show should a submenu image
- submenuItems = [[NSArray alloc] initWithObjects:@"Upcoming Songs", @"Playlists", @"EQ Presets", nil];
-
- //Fill in the number of songs in advance to show field
- [songsInAdvance setIntValue:[defaults integerForKey:@"SongsInAdvance"]];
-
- //Fill in hot key buttons
- if ([defaults objectForKey:@"PlayPause"]){
- playPauseCombo = [defaults keyComboForKey:@"PlayPause"];
- [playPauseButton setTitle:[playPauseCombo userDisplayRep]];
- } else {
- playPauseCombo = [[KeyCombo alloc] init];
- }
-
- if ([defaults objectForKey:@"NextTrack"]) {
- nextTrackCombo = [defaults keyComboForKey:@"NextTrack"];
- [nextTrackButton setTitle:[nextTrackCombo userDisplayRep]];
- } else {
- nextTrackCombo = [[KeyCombo alloc] init];
- }
-
- if ([defaults objectForKey:@"PrevTrack"]) {
- prevTrackCombo = [defaults keyComboForKey:@"PrevTrack"];
- [previousTrackButton setTitle:[prevTrackCombo userDisplayRep]];
- } else {
- prevTrackCombo = [[KeyCombo alloc] init];
- }
-
- if ([defaults objectForKey:@"TrackInfo"]) {
- trackInfoCombo = [defaults keyComboForKey:@"TrackInfo"];
- [trackInfoButton setTitle:[trackInfoCombo userDisplayRep]];
- } else {
- trackInfoCombo = [[KeyCombo alloc] init];
- }
-
- if ([defaults objectForKey:@"UpcomingSongs"]) {
- upcomingSongsCombo = [defaults keyComboForKey:@"UpcomingSongs"];
- [upcomingSongsButton setTitle:[upcomingSongsCombo userDisplayRep]];
- } else {
- upcomingSongsCombo = [[KeyCombo alloc] init];
- }
-
- //Check current track info buttons
- [albumCheckbox setState:[defaults boolForKey:@"showAlbum"] ? NSOnState : NSOffState];
- [nameCheckbox setState:[defaults boolForKey:@"showName"] ? NSOnState : NSOffState];
- [artistCheckbox setState:[defaults boolForKey:@"showArtist"] ? NSOnState : NSOffState];
- [trackTimeCheckbox setState:[defaults boolForKey:@"showTime"] ? NSOnState : NSOffState];
-
- //Set the launch at login checkbox state
- {
- NSMutableDictionary *loginwindow;
- NSMutableArray *loginarray;
- int i;
-
- [defaults synchronize];
- loginwindow = [[defaults persistentDomainForName:@"loginwindow"] mutableCopy];
- loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
-
- for (i = 0; i < [loginarray count]; i++) {
- NSDictionary *tempDict = [loginarray objectAtIndex:i];
- if ([[[tempDict objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]]) {
- [launchAtLoginCheckbox setState:NSOnState];
- }
- }
- }