From 3eb4949fe4554cb4a32e1237571da4a96d26978c Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Tue, 5 Mar 2013 02:08:03 +0100 Subject: [PATCH] Subscribe the output controller to notifications directly. Application delegate has no more need to track the output controller. --- English.lproj/MainMenu.xib | 19 ++----------------- EnjoyableApplicationDelegate.h | 1 - EnjoyableApplicationDelegate.m | 1 - NJOutputController.h | 1 - NJOutputController.m | 21 +++++++++++++++++++-- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 00740ba..cc6ba01 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -329,10 +329,9 @@ Mapping Selector - + 268 {{0, 14}, {140, 25}} - _NS:9 YES @@ -378,10 +377,9 @@ Translation Switch - + 268 {{19, 14}, {67, 25}} - _NS:9 YES @@ -1408,14 +1406,6 @@ 820 - - - outputController - - - - 825 - window @@ -2413,7 +2403,6 @@ NSMenu NJDeviceController NJMappingsController - NJOutputController NSWindow @@ -2429,10 +2418,6 @@ mappingsController NJMappingsController - - outputController - NJOutputController - window NSWindow diff --git a/EnjoyableApplicationDelegate.h b/EnjoyableApplicationDelegate.h index 6488135..4615d12 100644 --- a/EnjoyableApplicationDelegate.h +++ b/EnjoyableApplicationDelegate.h @@ -16,7 +16,6 @@ } @property (nonatomic, strong) IBOutlet NJDeviceController *inputController; -@property (nonatomic, strong) IBOutlet NJOutputController *outputController; @property (nonatomic, strong) IBOutlet NJMappingsController *mappingsController; @end diff --git a/EnjoyableApplicationDelegate.m b/EnjoyableApplicationDelegate.m index 313ba9a..1406115 100644 --- a/EnjoyableApplicationDelegate.m +++ b/EnjoyableApplicationDelegate.m @@ -89,7 +89,6 @@ item.state = mapping == self.mappingsController.currentMapping; [dockMenuBase addItem:item]; } - [_outputController refreshMappings]; } - (void)mappingDidChange:(NSNotification *)note { diff --git a/NJOutputController.h b/NJOutputController.h index 5b9a749..0c6a859 100644 --- a/NJOutputController.h +++ b/NJOutputController.h @@ -28,7 +28,6 @@ @property (assign) BOOL enabled; - (void)loadCurrent; -- (void)refreshMappings; - (IBAction)radioChanged:(id)sender; - (IBAction)mdirChanged:(id)sender; - (IBAction)mbtnChanged:(id)sender; diff --git a/NJOutputController.m b/NJOutputController.m index 5ceccba..0c301ff 100644 --- a/NJOutputController.m +++ b/NJOutputController.m @@ -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" @@ -22,6 +23,21 @@ @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; @@ -216,10 +232,11 @@ [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:@""]; -- 2.30.2