X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/ea3dc416d45e5e72dc83a757a2031a2a763bbe51..a822d608c6739b4c2cd2c39187a78ca461d4d6d4:/PreferencesController.m diff --git a/PreferencesController.m b/PreferencesController.m index b4cba9e..82b7f82 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -1,10 +1,10 @@ #import "PreferencesController.h" -#import "MenuTunes.h" +#import "MainController.h" #import "HotKeyCenter.h" @implementation PreferencesController -- (id)initWithMenuTunes:(MenuTunes *)tunes; +- (id)initWithMenuTunes:(MainController *)tunes; { if ( (self = [super init]) ) { int i; @@ -12,16 +12,11 @@ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; mt = [tunes retain]; - [mt registerDefaultsIfNeeded]; + [mt registerDefaults]; //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]; @@ -32,7 +27,7 @@ [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", @"", nil]; + availableItems = [[NSMutableArray alloc] initWithObjects:@"Current Track Info", @"Upcoming Songs", @"Playlists", @"EQ Presets", @"Song Rating", @"Play/Pause", @"Next Track", @"Previous Track", @"Fast Forward", @"Rewind", @"", nil]; //Get our preferred menu myItems = [[[NSUserDefaults standardUserDefaults] arrayForKey:@"menu"] mutableCopy]; @@ -47,7 +42,7 @@ } //Items that show should a submenu image - submenuItems = [[NSArray alloc] initWithObjects:@"Upcoming Songs", @"Playlists", @"EQ Presets", nil]; + submenuItems = [[NSArray alloc] initWithObjects:@"Upcoming Songs", @"Playlists", @"EQ Presets", @"Song Rating", nil]; //Fill in the number of songs in advance to show field [songsInAdvance setIntValue:[defaults integerForKey:@"SongsInAdvance"]]; @@ -111,6 +106,12 @@ } } } + + //Show our window + [window setLevel:NSStatusWindowLevel]; + [window center]; + [window makeKeyAndOrderFront:nil]; + [window setDelegate:self]; } return self; } @@ -134,7 +135,6 @@ - (IBAction)apply:(id)sender { - ProcessSerialNumber psn; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:myItems forKey:@"menu"]; @@ -210,10 +210,17 @@ [defaults setInteger:5 forKey:@"SongsInAdvance"]; } - psn = [mt iTunesPSN]; - if (!((psn.highLongOfPSN == kNoProcess) && (psn.lowLongOfPSN == 0))) { - [mt rebuildMenu]; - } + /*{ + NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications]; + int i; + + for (i = 0; i < [apps count]; i++) { + if ([[[apps objectAtIndex:i] objectForKey:@"NSApplicationName"] + isEqualToString:@"iTunes"]) { + [mt rebuildMenu]; + } + } + }*/ [mt clearHotKeys]; } @@ -237,15 +244,7 @@ - (IBAction)okHotKey:(id)sender { - NSString *string; - if (([combo modifiers] <= 0) && ([combo keyCode] >= 0)) { - [window setLevel:NSNormalWindowLevel]; - NSRunAlertPanel(@"Bad Key Combo", @"Please enter a valid key combo. A valid combo must have a modifier key in it. (Command, option, shift, control).", @"OK", nil, nil, nil); - [window setLevel:NSStatusWindowLevel]; - return; - } - - string = [combo userDisplayRep]; + NSString *string = [combo userDisplayRep]; if (string == nil) { string = @"None"; @@ -393,6 +392,14 @@ [keyComboField setStringValue:string]; } +// +// + +- (void)windowWillClose:(NSNotification *)note +{ + [mt closePreferences]; +} + // // // Table View Datasource Methods