Fixed some other problems that had to do with the EQ menu
[MenuTunes.git] / MenuTunes.m
index 419a93a..2f3b083 100755 (executable)
@@ -1,12 +1,3 @@
-/*
-Things to do:
-¥ Make preferences window pretty
-¥ Optimize
-¥ Apple Events! Apple Events! Apple Events!
-¥ Manual and webpage
-¥ Finish up registration frontend
-*/
-
 #import "MenuTunes.h"
 #import "PreferencesController.h"
 #import "HotKeyCenter.h"
 #import "MenuTunes.h"
 #import "PreferencesController.h"
 #import "HotKeyCenter.h"
@@ -522,6 +513,7 @@ Things to do:
 - (void)rebuildEQPresetsMenu
 {
     NSArray *eqPresets = [currentRemote eqPresets];
 - (void)rebuildEQPresetsMenu
 {
     NSArray *eqPresets = [currentRemote eqPresets];
+    NSMenuItem *enabledItem;
     int i;
     
     if (eqMenu && ([[currentRemote eqPresets] count] == [eqMenu numberOfItems]))
     int i;
     
     if (eqMenu && ([[currentRemote eqPresets] count] == [eqMenu numberOfItems]))
@@ -530,6 +522,11 @@ Things to do:
     [eqMenu release];
     eqMenu = [[NSMenu alloc] initWithTitle:@""];
     
     [eqMenu release];
     eqMenu = [[NSMenu alloc] initWithTitle:@""];
     
+    enabledItem = [eqMenu addItemWithTitle:@"EQ Enabled"
+                          action:NULL
+                          keyEquivalent:@""];
+    [eqMenu addItem:[NSMenuItem separatorItem]];
+    
     for (i = 0; i < [eqPresets count]; i++) {
         NSString *setName = [eqPresets objectAtIndex:i];
         NSMenuItem *tempItem;
     for (i = 0; i < [eqPresets count]; i++) {
         NSString *setName = [eqPresets objectAtIndex:i];
         NSMenuItem *tempItem;
@@ -543,7 +540,7 @@ Things to do:
     }
     [eqItem setSubmenu:eqMenu];
     
     }
     [eqItem setSubmenu:eqMenu];
     
-    [[eqMenu itemAtIndex:[currentRemote currentEQPresetIndex] - 1] setState:NSOnState];
+    [[eqMenu itemAtIndex:[currentRemote currentEQPresetIndex] + 1] setState:NSOnState];
 }
 
 - (void)clearHotKeys
 }
 
 - (void)clearHotKeys
@@ -661,6 +658,41 @@ Things to do:
                 [playPauseMenuItem setTitle:@"Play"];
             }
         }
                 [playPauseMenuItem setTitle:@"Play"];
             }
         }
+    } else if ((lastPlaylistIndex > 0) && (playlist == 0)) {
+        NSMenuItem *menuItem;
+        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+        //Remote the now playing item and add no song item
+        [menu removeItemAtIndex:trackInfoIndex];
+        
+        if ([defaults boolForKey:@"showName"] == YES) {
+            [menu removeItemAtIndex:trackInfoIndex];
+        }
+        
+        if ([defaults boolForKey:@"showTime"] == YES) {
+            [menu removeItemAtIndex:trackInfoIndex];
+        }
+        
+        if (didHaveArtistName && [defaults boolForKey:@"showArtist"]) {
+            [menu removeItemAtIndex:trackInfoIndex];
+        }
+        
+        if (didHaveAlbumName && [defaults boolForKey:@"showAlbum"]) {
+            [menu removeItemAtIndex:trackInfoIndex];
+        }
+        
+        [playPauseMenuItem setTitle:@"Play"];
+        
+        didHaveArtistName = NO;
+        didHaveAlbumName = NO;
+        lastPlaylistIndex = -1;
+        lastSongIndex = -1;
+        
+        [upcomingSongsItem setSubmenu:nil];
+        [upcomingSongsItem setEnabled:NO];
+        
+        menuItem = [[NSMenuItem alloc] initWithTitle:@"No Song" action:nil keyEquivalent:@""];
+        [menu insertItem:menuItem atIndex:trackInfoIndex];
+        [menuItem release];
     }
 }
 
     }
 }
 
@@ -672,7 +704,12 @@ Things to do:
     refreshTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES]; 
     
     [self rebuildMenu]; //Rebuild the menu since no songs will be playing
     refreshTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES]; 
     
     [self rebuildMenu]; //Rebuild the menu since no songs will be playing
-    [self rebuildPlaylistMenu];
+    if (playlistItem) {
+        [self rebuildPlaylistMenu];
+    }
+    if (eqItem) {
+        [self rebuildEQPresetsMenu];
+    }
     [statusItem setMenu:menu]; //Set the menu back to the main one
 }
 
     [statusItem setMenu:menu]; //Set the menu back to the main one
 }
 
@@ -771,7 +808,8 @@ Things to do:
 
 - (void)setSongRating:(id)sender
 {
 
 - (void)setSongRating:(id)sender
 {
-    //[currentRemote setCurrentSongRating:[sender tag]];
+    NSLog(@"%f", (float)[sender tag] / 100.0);
+    [currentRemote setCurrentSongRating:(float)[sender tag] / 100.0];
 }
 
 //
 }
 
 //