Removed the ability to remove the Quit (and therefore, Register if you
[MenuTunes.git] / MainController.m
index 523936c..36212c4 100755 (executable)
@@ -39,6 +39,7 @@ static MainController *sharedController;
         statusWindowController = [StatusWindowController sharedController];
         menuController = [[MenuController alloc] init];
         df = [[NSUserDefaults standardUserDefaults] retain];
+        timerUpdating = NO;
     }
     return self;
 }
@@ -202,15 +203,19 @@ static MainController *sharedController;
 
 - (void)timerUpdate
 {
-    if ( [self songChanged] ) {
+    if ( [self songChanged] && (timerUpdating != YES) ) {
         ITDebugLog(@"The song changed.");
-        [self setLatestSongIdentifier:[currentRemote playerStateUniqueIdentifier]];
+        timerUpdating = YES;
         latestPlaylistClass = [currentRemote currentPlaylistClass];
         [menuController rebuildSubmenus];
 
         if ( [df boolForKey:@"showSongInfoOnChange"] ) {
             [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
         }
+        
+        [self setLatestSongIdentifier:[currentRemote playerStateUniqueIdentifier]];
+        
+        timerUpdating = NO;
     }
 }
 
@@ -366,6 +371,11 @@ static MainController *sharedController;
 {
     ITHotKey *hotKey;
     ITDebugLog(@"Setting up hot keys.");
+    
+    if (playerRunningState == ITMTRemotePlayerNotRunning) {
+        return;
+    }
+    
     if ([df objectForKey:@"PlayPause"] != nil) {
         ITDebugLog(@"Setting up play pause hot key.");
         hotKey = [[ITHotKey alloc] init];
@@ -528,7 +538,10 @@ static MainController *sharedController;
         }
 
         if ( [df boolForKey:@"showTrackRating"] ) {
-            rating = ( [currentRemote currentSongRating] * 5 );
+            float currentRating = [currentRemote currentSongRating];
+            if (currentRating >= 0.0) {
+                rating = ( currentRating * 5 );
+            }
         }
         
     } else {
@@ -612,6 +625,12 @@ static MainController *sharedController;
 {
     float rating = [currentRemote currentSongRating];
     ITDebugLog(@"Incrementing rating.");
+    
+    if ([currentRemote currentPlaylistIndex] == 0) {
+        ITDebugLog(@"No song playing, rating change aborted.");
+        return;
+    }
+    
     rating += 0.2;
     if (rating > 1.0) {
         rating = 1.0;
@@ -627,6 +646,12 @@ static MainController *sharedController;
 {
     float rating = [currentRemote currentSongRating];
     ITDebugLog(@"Decrementing rating.");
+    
+    if ([currentRemote currentPlaylistIndex] == 0) {
+        ITDebugLog(@"No song playing, rating change aborted.");
+        return;
+    }
+    
     rating -= 0.2;
     if (rating < 0.0) {
         rating = 0.0;