Fixed more bugs having to do with the updating of the prefs file to 1.2
[MenuTunes.git] / MainController.m
index dafd199..afc0db2 100755 (executable)
@@ -55,6 +55,13 @@ static MainController *sharedController;
         SetITDebugMode(YES);
     }
     
+    if (([df integerForKey:@"appVersion"] < 1200) && ([df integerForKey:@"SongsInAdvance"] > 0)) {
+        [df removePersistentDomainForName:@"com.ithinksw.menutunes"];
+        [df synchronize];
+        [[PreferencesController sharedPrefs] registerDefaults];
+        [[StatusWindowController sharedController] showPreferencesUpdateWindow];
+    }
+    
     currentRemote = [self loadRemote];
     [[self currentRemote] begin];
     
@@ -292,7 +299,7 @@ static MainController *sharedController;
         [statusItem setMenu:[menuController menu]];
     }
     
-    if ( [self songChanged] && (timerUpdating != YES) ) {
+    if ( [self songChanged] && (timerUpdating != YES) && (playerRunningState == ITMTRemotePlayerRunning) ) {
         ITDebugLog(@"The song changed.");
         timerUpdating = YES;
         
@@ -406,6 +413,7 @@ static MainController *sharedController;
 {
     ITDebugLog(@"Selecting playlist %i", index);
     NS_DURING
+        //[[self currentRemote] switchToPlaylistAtIndex:(index % 1000) ofSourceAtIndex:(index / 1000)];
         [[self currentRemote] switchToPlaylistAtIndex:index];
     NS_HANDLER
         [self networkError:localException];
@@ -475,6 +483,15 @@ static MainController *sharedController;
     [[PreferencesController sharedPrefs] showPrefsWindow:self];
 }
 
+- (void)showPreferencesAndClose
+{
+    ITDebugLog(@"Show preferences.");
+    [[PreferencesController sharedPrefs] showPrefsWindow:self];
+    [[StatusWindow sharedWindow] setLocked:NO];
+    [[StatusWindow sharedWindow] vanish:self];
+    [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
+}
+
 - (void)showTestWindow
 {
     [self showCurrentTrackInfo];
@@ -1072,12 +1089,12 @@ static MainController *sharedController;
     NS_DURING
         if (!note || [[[note userInfo] objectForKey:@"NSApplicationName"] isEqualToString:[[self currentRemote] playerFullName]]) {
             ITDebugLog(@"Remote application terminated.");
+            playerRunningState = ITMTRemotePlayerNotRunning;
             [[self currentRemote] halt];
             [refreshTimer invalidate];
             [refreshTimer release];
             refreshTimer = nil;
             [self clearHotKeys];
-            playerRunningState = ITMTRemotePlayerNotRunning;
             
             if ([df objectForKey:@"ShowPlayer"] != nil) {
                 ITHotKey *hotKey;