Subscribe the output controller to notifications directly. Application delegate has...
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 5 Mar 2013 01:08:03 +0000 (02:08 +0100)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 5 Mar 2013 01:08:03 +0000 (02:08 +0100)
English.lproj/MainMenu.xib
EnjoyableApplicationDelegate.h
EnjoyableApplicationDelegate.m
NJOutputController.h
NJOutputController.m

index 00740ba8f728e5ca2acffa93767e472e18aa25b9..cc6ba0138b08dd1791e501e08e482c2f776f8e82 100644 (file)
                                                        <string key="NSToolbarItemPaletteLabel">Mapping Selector</string>
                                                        <nil key="NSToolbarItemToolTip"/>
                                                        <object class="NSButton" key="NSToolbarItemView" id="227597319">
-                                                               <reference key="NSNextResponder"/>
+                                                               <nil key="NSNextResponder"/>
                                                                <int key="NSvFlags">268</int>
                                                                <string key="NSFrame">{{0, 14}, {140, 25}}</string>
-                                                               <reference key="NSSuperview"/>
                                                                <string key="NSReuseIdentifierKey">_NS:9</string>
                                                                <bool key="NSEnabled">YES</bool>
                                                                <object class="NSButtonCell" key="NSCell" id="850080795">
                                                        <string key="NSToolbarItemPaletteLabel">Translation Switch</string>
                                                        <nil key="NSToolbarItemToolTip"/>
                                                        <object class="NSSegmentedControl" key="NSToolbarItemView" id="679083346">
-                                                               <reference key="NSNextResponder"/>
+                                                               <nil key="NSNextResponder"/>
                                                                <int key="NSvFlags">268</int>
                                                                <string key="NSFrame">{{19, 14}, {67, 25}}</string>
-                                                               <reference key="NSSuperview"/>
                                                                <string key="NSReuseIdentifierKey">_NS:9</string>
                                                                <bool key="NSEnabled">YES</bool>
                                                                <object class="NSSegmentedCell" key="NSCell" id="594076765">
                                        </object>
                                        <int key="connectionID">820</int>
                                </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">outputController</string>
-                                               <reference key="source" ref="207406104"/>
-                                               <reference key="destination" ref="801536542"/>
-                                       </object>
-                                       <int key="connectionID">825</int>
-                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">window</string>
                                                <string key="dockMenuBase">NSMenu</string>
                                                <string key="inputController">NJDeviceController</string>
                                                <string key="mappingsController">NJMappingsController</string>
-                                               <string key="outputController">NJOutputController</string>
                                                <string key="window">NSWindow</string>
                                        </dictionary>
                                        <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
                                                        <string key="name">mappingsController</string>
                                                        <string key="candidateClassName">NJMappingsController</string>
                                                </object>
-                                               <object class="IBToOneOutletInfo" key="outputController">
-                                                       <string key="name">outputController</string>
-                                                       <string key="candidateClassName">NJOutputController</string>
-                                               </object>
                                                <object class="IBToOneOutletInfo" key="window">
                                                        <string key="name">window</string>
                                                        <string key="candidateClassName">NSWindow</string>
index 648813585e08d38763e1c81489e1a4a4bc4d4d1b..4615d12a5692b19239992dbabd36772d66aef803 100644 (file)
@@ -16,7 +16,6 @@
 }
 
 @property (nonatomic, strong) IBOutlet NJDeviceController *inputController;
-@property (nonatomic, strong) IBOutlet NJOutputController *outputController;
 @property (nonatomic, strong) IBOutlet NJMappingsController *mappingsController;
 
 @end
index 313ba9a2fbf65df4a82e89369a7ceade015b0204..140611539795ffdd3c3be11f2fd89f334f264256 100644 (file)
@@ -89,7 +89,6 @@
         item.state = mapping == self.mappingsController.currentMapping;
         [dockMenuBase addItem:item];
     }
-    [_outputController refreshMappings];
 }
 
 - (void)mappingDidChange:(NSNotification *)note {
index 5b9a749ca41f6b98425fd2edbd6c16dd5b52bc8c..0c6a8594fde054b1e5e70de35608a47b3685577b 100644 (file)
@@ -28,7 +28,6 @@
 @property (assign) BOOL enabled;
 
 - (void)loadCurrent;
-- (void)refreshMappings;
 - (IBAction)radioChanged:(id)sender;
 - (IBAction)mdirChanged:(id)sender;
 - (IBAction)mbtnChanged:(id)sender;
index 5ceccba605dce87c09972270a3523f7f61457ba4..0c301ff6811f9e407101ef89a2296ed6b6973d1a 100644 (file)
@@ -10,6 +10,7 @@
 #import "NJMappingsController.h"
 #import "NJMapping.h"
 #import "NJInput.h"
+#import "NJEvents.h"
 #import "NJDeviceController.h"
 #import "NJKeyInputField.h"
 #import "NJOutputMapping.h"
 
 @implementation NJOutputController
 
+- (id)init {
+    if ((self = [super init])) {
+        [NSNotificationCenter.defaultCenter
+            addObserver:self
+            selector:@selector(mappingListDidChange:)
+            name:NJEventMappingListChanged
+            object:nil];
+    }
+    return self;
+}
+
+- (void)dealloc {
+    [NSNotificationCenter.defaultCenter removeObserver:self];
+}
+
 - (void)cleanUpInterface {
     NSInteger row = radioButtons.selectedRow;
     
         [keyInput resignIfFirstResponder];
 }
 
-- (void)refreshMappings {
+- (void)mappingListDidChange:(NSNotification *)note {
+    NSArray *mappings = note.object;
     NJMapping *current = mappingPopup.selectedItem.representedObject;
     [mappingPopup.menu removeAllItems];
-    for (NJMapping *mapping in mappingsController) {
+    for (NJMapping *mapping in mappings) {
         NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:mapping.name
                                                       action:@selector(mappingChosen:)
                                                keyEquivalent:@""];