Added stuff for current song rating. Right now in the submenu there are
[MenuTunes.git] / MenuTunes.m
index 1d8f67e..7c5e543 100755 (executable)
@@ -46,17 +46,17 @@ Things to do:
     currentRemote = [self loadRemote];
     [currentRemote begin];
     
     currentRemote = [self loadRemote];
     [currentRemote begin];
     
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iTunesTerminated:) name:@"ITMTRemoteAppDidTerminateNotification" object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iTunesLaunched:) name:@"ITMTRemoteAppDidLaunchNotification" object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(remotePlayerTerminated:) name:@"ITMTRemoteAppDidTerminateNotification" object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(remotePlayerLaunched:) name:@"ITMTRemoteAppDidLaunchNotification" object:nil];
     
     [self registerDefaultsIfNeeded];
     
     menu = [[NSMenu alloc] initWithTitle:@""];
     
     if ([currentRemote isAppRunning]) {
     
     [self registerDefaultsIfNeeded];
     
     menu = [[NSMenu alloc] initWithTitle:@""];
     
     if ([currentRemote isAppRunning]) {
-        [self iTunesLaunched:nil];
+        [self remotePlayerLaunched:nil];
     } else {
     } else {
-        [self iTunesTerminated:nil];
+        [self remotePlayerTerminated:nil];
     }
     
     statusItem = [[ITStatusItem alloc] initWithStatusBar:[NSStatusBar systemStatusBar]
     }
     
     statusItem = [[ITStatusItem alloc] initWithStatusBar:[NSStatusBar systemStatusBar]
@@ -67,7 +67,6 @@ Things to do:
     [statusItem setMenu:menu];
     // Below line of code is for creating builds for Beta Testers
     // [statusItem setToolTip:@[NSString stringWithFormat:@"This Nontransferable Beta (Built on %s) of iThink Software's MenuTunes is Registered to: Beta Tester (betatester@somedomain.com).",__DATE__]];
     [statusItem setMenu:menu];
     // Below line of code is for creating builds for Beta Testers
     // [statusItem setToolTip:@[NSString stringWithFormat:@"This Nontransferable Beta (Built on %s) of iThink Software's MenuTunes is Registered to: Beta Tester (betatester@somedomain.com).",__DATE__]];
-    [statusWindow orderFront:self]; //DEBUG
 }
 
 - (ITMTRemote *)loadRemote
 }
 
 - (ITMTRemote *)loadRemote
@@ -130,6 +129,7 @@ Things to do:
                 @"<separator>",
                 @"Upcoming Songs",
                 @"Playlists",
                 @"<separator>",
                 @"Upcoming Songs",
                 @"Playlists",
+                @"Song Rating",
                 @"<separator>",
                 @"PreferencesÉ",
                 @"Quit",
                 @"<separator>",
                 @"PreferencesÉ",
                 @"Quit",
@@ -288,6 +288,32 @@ Things to do:
             [menu addItemWithTitle:@"No Song"
                     action:nil
                     keyEquivalent:@""];
             [menu addItemWithTitle:@"No Song"
                     action:nil
                     keyEquivalent:@""];
+        } else if ([item isEqualToString:@"Song Rating"]) {
+            NSMenu *ratingSubmenu = [[NSMenu alloc] initWithTitle:@""];
+            unichar whiteStar = 'o';//2606;
+            unichar blackStar = 'x';//2605;
+            NSString *whiteStarString = [NSString stringWithCharacters:&whiteStar
+                                            length:1];
+            NSString *blackStarString = [NSString stringWithCharacters:&blackStar
+                                            length:1];
+            NSString *string = @"";
+            int i;
+            
+            for (i = 0; i < 5; i++) {
+                string = [string stringByAppendingString:whiteStarString];
+            }
+            for (i = 0; i < 6; i++) {
+                NSMenuItem *ratingItem;
+                ratingItem = [ratingSubmenu addItemWithTitle:string action:@selector(setSongRating:) keyEquivalent:@""];
+                [ratingItem setTarget:self];
+                [ratingItem setTag:i * 20];
+                string = [string substringToIndex:4];
+                string = [blackStarString stringByAppendingString:string];
+            }
+            [[menu addItemWithTitle:@"Song Rating"
+                    action:nil
+                    keyEquivalent:@""] setSubmenu:ratingSubmenu];
+            [ratingSubmenu autorelease];
         } else if ([item isEqualToString:@"<separator>"]) {
             [menu addItem:[NSMenuItem separatorItem]];
         }
         } else if ([item isEqualToString:@"<separator>"]) {
             [menu addItem:[NSMenuItem separatorItem]];
         }
@@ -638,7 +664,7 @@ Things to do:
     }
 }
 
     }
 }
 
-- (void)iTunesLaunched:(NSNotification *)note
+- (void)remotePlayerLaunched:(NSNotification *)note
 {
     isAppRunning = YES;
     
 {
     isAppRunning = YES;
     
@@ -650,7 +676,7 @@ Things to do:
     [statusItem setMenu:menu]; //Set the menu back to the main one
 }
 
     [statusItem setMenu:menu]; //Set the menu back to the main one
 }
 
-- (void)iTunesTerminated:(NSNotification *)note
+- (void)remotePlayerTerminated:(NSNotification *)note
 {
     isAppRunning = NO;
     
 {
     isAppRunning = NO;
     
@@ -741,6 +767,11 @@ Things to do:
     [playPauseMenuItem setTitle:@"Play"];
 }
 
     [playPauseMenuItem setTitle:@"Play"];
 }
 
+- (void)setSongRating:(id)sender
+{
+    //[currentRemote setCurrentSongRating:[sender tag]];
+}
+
 //
 //
 // Plugin independent selectors
 //
 //
 // Plugin independent selectors