A couple more modifications, as well as some comments to ease others'
[MenuTunes.git] / MenuController.m
index 7c0f307..6560821 100755 (executable)
@@ -9,6 +9,7 @@
 #import "MenuController.h"
 #import "MainController.h"
 #import <ITKit/ITHotKeyCenter.h>
 #import "MenuController.h"
 #import "MainController.h"
 #import <ITKit/ITHotKeyCenter.h>
+#import <ITKit/ITHotKey.h>
 #import <ITKit/ITKeyCombo.h>
 
 @interface MenuController (SubmenuMethods)
 #import <ITKit/ITKeyCombo.h>
 
 @interface MenuController (SubmenuMethods)
@@ -39,7 +40,8 @@
     NSString *nextObject;
     NSMenuItem *tempItem;
     NSEnumerator *itemEnum;
     NSString *nextObject;
     NSMenuItem *tempItem;
     NSEnumerator *itemEnum;
-    ITKeyCombo *keyCombo;
+    ITHotKey *hotKey;
+    NSArray *hotKeys = [[ITHotKeyCenter sharedCenter] allHotKeys];
     
     //Get the information
     _currentPlaylist = [currentRemote currentPlaylistIndex];
     
     //Get the information
     _currentPlaylist = [currentRemote currentPlaylistIndex];
             [tempItem setTag:MTMenuPlayPauseItem];
             [tempItem setTarget:self];
             
             [tempItem setTag:MTMenuPlayPauseItem];
             [tempItem setTarget:self];
             
-            /*if ( (keyCombo = [[ITHotKeyCenter sharedCenter] keyComboForName:@"PlayPause"]) ) {
-                [self setKeyEquivalentForCode:[keyCombo keyCode]
-                        andModifiers:[keyCombo modifiers]
-                        onItem:tempItem];
-            }*/ // FIX ME!
+            itemEnum = [hotKeys objectEnumerator];
+            while ( (hotKey = [itemEnum nextObject]) ) {
+                if ([[hotKey name] isEqualToString:@"PlayPause"]) {
+                    ITKeyCombo *combo = [hotKey keyCombo];
+                    [self setKeyEquivalentForCode:[combo keyCode]
+                          andModifiers:[combo modifiers]
+                          onItem:tempItem];
+                }
+            }
             
             switch ([currentRemote playerPlayingState]) {
                 case ITMTRemotePlayerPlaying:
             
             switch ([currentRemote playerPlayingState]) {
                 case ITMTRemotePlayerPlaying:
                     action:@selector(performMainMenuAction:)
                     keyEquivalent:@""];
             
                     action:@selector(performMainMenuAction:)
                     keyEquivalent:@""];
             
-            /*if ( (keyCombo = [[ITHotKeyCenter sharedCenter] keyComboForName:@"NextTrack"]) ) {
-                [self setKeyEquivalentForCode:[keyCombo keyCode]
-                        andModifiers:[keyCombo modifiers]
-                        onItem:tempItem];
-            }*/ // FIX ME!
+            itemEnum = [hotKeys objectEnumerator];
+            while ( (hotKey = [itemEnum nextObject]) ) {
+                if ([[hotKey name] isEqualToString:@"NextTrack"]) {
+                    ITKeyCombo *combo = [hotKey keyCombo];
+                    [self setKeyEquivalentForCode:[combo keyCode]
+                          andModifiers:[combo modifiers]
+                          onItem:tempItem];
+                }
+            }
             
             if (_currentPlaylist) {
                 [tempItem setTag:MTMenuNextTrackItem];
             
             if (_currentPlaylist) {
                 [tempItem setTag:MTMenuNextTrackItem];
                     action:@selector(performMainMenuAction:)
                     keyEquivalent:@""];
             
                     action:@selector(performMainMenuAction:)
                     keyEquivalent:@""];
             
-            /*if ( (keyCombo = [[ITHotKeyCenter sharedCenter] keyComboForName:@"PrevTrack"]) ) {
-                [self setKeyEquivalentForCode:[keyCombo keyCode]
-                        andModifiers:[keyCombo modifiers]
-                        onItem:tempItem];
-            }*/ // FIX ME!
+            itemEnum = [hotKeys objectEnumerator];
+            while ( (hotKey = [itemEnum nextObject]) ) {
+                if ([[hotKey name] isEqualToString:@"PrevTrack"]) {
+                    ITKeyCombo *combo = [hotKey keyCombo];
+                    [self setKeyEquivalentForCode:[combo keyCode]
+                          andModifiers:[combo modifiers]
+                          onItem:tempItem];
+                }
+            }
             
             if (_currentPlaylist) {
                 [tempItem setTag:MTMenuPreviousTrackItem];
             
             if (_currentPlaylist) {
                 [tempItem setTag:MTMenuPreviousTrackItem];
                     action:@selector(performMainMenuAction:)
                     keyEquivalent:@""];
             
                     action:@selector(performMainMenuAction:)
                     keyEquivalent:@""];
             
-            /*if ( (keyCombo = [[ITHotKeyCenter sharedCenter] keyComboForName:@"ShowPlayer"]) ) {
-                [self setKeyEquivalentForCode:[keyCombo keyCode]
-                        andModifiers:[keyCombo modifiers]
-                        onItem:tempItem];
-            }*/ // FIX ME!
+            itemEnum = [hotKeys objectEnumerator];
+            while ( (hotKey = [itemEnum nextObject]) ) {
+                if ([[hotKey name] isEqualToString:@"ShowPlayer"]) {
+                    ITKeyCombo *combo = [hotKey keyCombo];
+                    [self setKeyEquivalentForCode:[combo keyCode]
+                          andModifiers:[combo modifiers]
+                          onItem:tempItem];
+                }
+            }
             
             [tempItem setTarget:self];
             [tempItem setTag:MTMenuShowPlayerItem];
             
             [tempItem setTarget:self];
             [tempItem setTag:MTMenuShowPlayerItem];