projects
/
enjoyable.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
93c9d4b
)
Push notifications out with more idiomatic semantics - controller as object, paramete...
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Mon, 11 Mar 2013 01:01:08 +0000
(
02:01
+0100)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Mon, 11 Mar 2013 01:01:08 +0000
(
02:01
+0100)
Classes/EnjoyableApplicationDelegate.m
patch
|
blob
|
history
Classes/NJMappingsController.m
patch
|
blob
|
history
Classes/NJOutputController.m
patch
|
blob
|
history
Info.plist
patch
|
blob
|
history
diff --git
a/Classes/EnjoyableApplicationDelegate.m
b/Classes/EnjoyableApplicationDelegate.m
index
634f362
..
c66cf6b
100644
(file)
--- a/
Classes/EnjoyableApplicationDelegate.m
+++ b/
Classes/EnjoyableApplicationDelegate.m
@@
-124,10
+124,13
@@
[self.mappingsController mappingPressed:sender];
}
[self.mappingsController mappingPressed:sender];
}
-- (void)addMappingsToMenu:(NSMenu *)menu withKeys:(BOOL)withKeys atIndex:(NSInteger)index {
+- (void)addMappings:(NSArray *)mappings
+ toMenu:(NSMenu *)menu
+ withKeys:(BOOL)withKeys
+ atIndex:(NSInteger)index {
static const NSUInteger MAXIMUM_ITEMS = 15;
int added = 0;
static const NSUInteger MAXIMUM_ITEMS = 15;
int added = 0;
- for (NJMapping *mapping in
self.mappingsController
) {
+ for (NJMapping *mapping in
mappings
) {
NSString *keyEquiv = (++added < 10 && withKeys) ? @(added).stringValue : @"";
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:mapping.name
action:@selector(chooseMapping:)
NSString *keyEquiv = (++added < 10 && withKeys) ? @(added).stringValue : @"";
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:mapping.name
action:@selector(chooseMapping:)
@@
-143,7
+146,7
@@
keyEquivalent:@""];
// There must be a represented object here so the item gets
// removed correctly when the menus are regenerated.
keyEquivalent:@""];
// There must be a represented object here so the item gets
// removed correctly when the menus are regenerated.
- end.representedObject =
self.mappingsController.
mappings;
+ end.representedObject = mappings;
end.target = self;
[menu insertItem:end atIndex:index++];
break;
end.target = self;
[menu insertItem:end atIndex:index++];
break;
@@
-152,16
+155,20
@@
}
- (void)mappingListDidChange:(NSNotification *)note {
}
- (void)mappingListDidChange:(NSNotification *)note {
+ NSArray *mappings = note.userInfo[@"mappings"];
while (mappingsMenu.lastItem.representedObject)
[mappingsMenu removeLastItem];
while (mappingsMenu.lastItem.representedObject)
[mappingsMenu removeLastItem];
- [self addMappingsToMenu:mappingsMenu withKeys:YES atIndex:mappingsMenu.numberOfItems];
+ [self addMappings:mappings
+ toMenu:mappingsMenu
+ withKeys:YES
+ atIndex:mappingsMenu.numberOfItems];
while ([statusItemMenu itemAtIndex:2].representedObject)
[statusItemMenu removeItemAtIndex:2];
while ([statusItemMenu itemAtIndex:2].representedObject)
[statusItemMenu removeItemAtIndex:2];
- [self addMappings
T
oMenu:statusItemMenu withKeys:NO atIndex:2];
+ [self addMappings
:mappings t
oMenu:statusItemMenu withKeys:NO atIndex:2];
}
- (void)mappingDidChange:(NSNotification *)note {
}
- (void)mappingDidChange:(NSNotification *)note {
- NJMapping *current = note.
object
;
+ NJMapping *current = note.
userInfo[@"mapping"]
;
for (NSMenuItem *item in mappingsMenu.itemArray)
if (item.representedObject)
item.state = item.representedObject == current;
for (NSMenuItem *item in mappingsMenu.itemArray)
if (item.representedObject)
item.state = item.representedObject == current;
@@
-184,7
+191,10
@@
- (NSMenu *)applicationDockMenu:(NSApplication *)sender {
while (dockMenu.lastItem.representedObject)
[dockMenu removeLastItem];
- (NSMenu *)applicationDockMenu:(NSApplication *)sender {
while (dockMenu.lastItem.representedObject)
[dockMenu removeLastItem];
- [self addMappingsToMenu:dockMenu withKeys:NO atIndex:dockMenu.numberOfItems];
+ [self addMappings:self.mappingsController.mappings
+ toMenu:dockMenu
+ withKeys:NO
+ atIndex:dockMenu.numberOfItems];
return dockMenu;
}
return dockMenu;
}
diff --git
a/Classes/NJMappingsController.m
b/Classes/NJMappingsController.m
index
5d86186
..
ad88d73
100644
(file)
--- a/
Classes/NJMappingsController.m
+++ b/
Classes/NJMappingsController.m
@@
-51,7
+51,8
@@
[self updateInterfaceForCurrentMapping];
[NSNotificationCenter.defaultCenter
postNotificationName:NJEventMappingListChanged
[self updateInterfaceForCurrentMapping];
[NSNotificationCenter.defaultCenter
postNotificationName:NJEventMappingListChanged
- object:_mappings];
+ object:self
+ userInfo:@{ @"mappings": _mappings }];
}
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
}
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
@@
-104,8
+105,10
@@
_manualMapping = mapping;
_currentMapping = mapping;
[self updateInterfaceForCurrentMapping];
_manualMapping = mapping;
_currentMapping = mapping;
[self updateInterfaceForCurrentMapping];
- [NSNotificationCenter.defaultCenter postNotificationName:NJEventMappingChanged
- object:_currentMapping];
+ [NSNotificationCenter.defaultCenter
+ postNotificationName:NJEventMappingChanged
+ object:self
+ userInfo:@{ @"mapping": _currentMapping }];
}
- (IBAction)addPressed:(id)sender {
}
- (IBAction)addPressed:(id)sender {
diff --git
a/Classes/NJOutputController.m
b/Classes/NJOutputController.m
index
5d90bee
..
cf758e6
100644
(file)
--- a/
Classes/NJOutputController.m
+++ b/
Classes/NJOutputController.m
@@
-280,7
+280,7
@@
}
- (void)mappingListDidChange:(NSNotification *)note {
}
- (void)mappingListDidChange:(NSNotification *)note {
- NSArray *mappings = note.
object
;
+ NSArray *mappings = note.
userInfo[@"mappings"]
;
NJMapping *current = mappingPopup.selectedItem.representedObject;
[mappingPopup.menu removeAllItems];
for (NJMapping *mapping in mappings) {
NJMapping *current = mappingPopup.selectedItem.representedObject;
[mappingPopup.menu removeAllItems];
for (NJMapping *mapping in mappings) {
diff --git
a/Info.plist
b/Info.plist
index
9d3612e
..
ebc0a1d
100644
(file)
--- a/
Info.plist
+++ b/
Info.plist
@@
-46,7
+46,7
@@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>10
8
</string>
+ <string>10
9
</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>NSHumanReadableCopyright</key>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>NSHumanReadableCopyright</key>