Have device controller setup itself rather than relying on the application delegate...
[enjoyable.git] / Classes / EnjoyableApplicationDelegate.m
index aaa9f00..634f362 100644 (file)
@@ -55,7 +55,6 @@
 }
 
 - (void)applicationDidFinishLaunching:(NSNotification *)notification {
-    [self.inputController setup];
     [window makeKeyAndOrderFront:nil];
 }
 
 }
 
 - (void)addMappingsToMenu:(NSMenu *)menu withKeys:(BOOL)withKeys atIndex:(NSInteger)index {
-    static const NSUInteger MAXIMUM_ITEMS = 5;
+    static const NSUInteger MAXIMUM_ITEMS = 15;
     int added = 0;
     for (NJMapping *mapping in self.mappingsController) {
         NSString *keyEquiv = (++added < 10 && withKeys) ? @(added).stringValue : @"";
         item.state = mapping == self.mappingsController.currentMapping;
         [menu insertItem:item atIndex:index++];
         if (added == MAXIMUM_ITEMS && self.mappingsController.mappings.count > MAXIMUM_ITEMS + 1) {
-            NSMenuItem *end = [[NSMenuItem alloc] initWithTitle:@"…"
+            NSString *msg = [NSString stringWithFormat:@"(and %lu more…)",
+                             self.mappingsController.mappings.count - MAXIMUM_ITEMS];
+            NSMenuItem *end = [[NSMenuItem alloc] initWithTitle:msg
                                                          action:@selector(restoreWindowAndShowMappings:)
                                                   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.target = self;
             [menu insertItem:end atIndex:index++];
             break;