Show a special message when the HID was closed during deactivation.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Wed, 13 Mar 2013 09:44:55 +0000 (10:44 +0100)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Wed, 13 Mar 2013 09:44:55 +0000 (10:44 +0100)
Classes/NJDeviceController.h
Classes/NJDeviceController.m
Info.plist
Resources/English.lproj/MainMenu.xib

index c0002e8ad88dd380aeda689ed8f78e02239ea48e..71a0ed17da08d58b56d9558a328f6ee80cc4d772 100644 (file)
@@ -17,6 +17,7 @@
     IBOutlet NJMappingsController *mappingsController;
     IBOutlet NSButton *translatingEventsButton;
     IBOutlet NSView *connectDevicePrompt;
+    IBOutlet NSView *hidSleepingPrompt;
 }
 
 @property (nonatomic, readonly) NJInput *selectedInput;
index a1e58682ca497b547a34453f2ef8bfbe477f4b72..2a1546c974c8ce7a64b352fe5eec2ecdc8a35d17 100644 (file)
     }
 }
 
-- (void)expandRecursiveByUID:(NSString *)uid {
+- (id)elementForUID:(NSString *)uid {
     for (NJDevice *dev in _devices) {
         id item = [dev elementForUID:uid];
         if (item)
-            [self expandRecursive:item];
+            return item;
     }
+    return nil;
+}
+
+- (void)expandRecursiveByUID:(NSString *)uid {
+    [self expandRecursive:[self elementForUID:uid]];
 }
 
 - (void)addRunningOutput:(NJOutput *)output {
@@ -158,6 +163,7 @@ static int findAvailableIndex(NSArray *list, NJDevice *dev) {
     [_devices addObject:dev];
     [outlineView reloadData];
     [self reexpandAll];
+    hidSleepingPrompt.hidden = YES;
     connectDevicePrompt.hidden = !!_devices.count;
 }
 
@@ -185,6 +191,7 @@ static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
         [_devices removeObject:match];
         [outlineView reloadData];
         connectDevicePrompt.hidden = !!_devices.count;
+        hidSleepingPrompt.hidden = YES;
     }
     if (_devices.count == 1)
         [outlineView expandItem:_devices[0]];
@@ -236,6 +243,8 @@ static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
     } else {
         IOHIDManagerRegisterDeviceMatchingCallback(_hidManager, add_callback, (__bridge void *)self);
         IOHIDManagerRegisterDeviceRemovalCallback(_hidManager, remove_callback, (__bridge void *)self);
+        hidSleepingPrompt.hidden = YES;
+        connectDevicePrompt.hidden = !!_devices.count;
     }
 }
 
@@ -249,7 +258,8 @@ static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
     }
     [_devices removeAllObjects];
     [outlineView reloadData];
-    connectDevicePrompt.hidden = !!_devices.count;
+    hidSleepingPrompt.hidden = NO;
+    connectDevicePrompt.hidden = YES;
 }
 
 - (NJInput *)selectedInput {
@@ -280,6 +290,10 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
 }
 
 - (void)outlineViewSelectionDidChange:(NSNotification *)notification {
+    id <NJInputPathElement> item = [outlineView itemAtRow:outlineView.selectedRow];
+    if (item)
+        [NSUserDefaults.standardUserDefaults setObject:item.uid
+                                                forKey:@"selected input"];
     [outputController loadCurrent];
 }
 
@@ -332,6 +346,13 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
 - (void)reexpandAll {
     for (NSString *uid in [_expanded copy])
         [self expandRecursiveByUID:uid];
+    if (outlineView.selectedRow == -1) {
+        NSString *selectedUid = [NSUserDefaults.standardUserDefaults objectForKey:@"selected input"];
+        id item = [self elementForUID:selectedUid];
+        NSInteger row = [outlineView rowForItem:item];
+        if (row >= 0)
+            [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
+    }
 }
 
 - (void)closeHidIfDisabled:(NSNotification *)application {
index 49083b1ffe53624f8ef86e8ff358239775341097..2add15970f208dafbab64429ae2578ee68517a33 100644 (file)
@@ -46,7 +46,7 @@
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>213</string>
+       <string>222</string>
        <key>LSApplicationCategoryType</key>
        <string>public.app-category.utilities</string>
        <key>NSHumanReadableCopyright</key>
index 47b41c1c079cc11027f361c21af8a5f4f32830bb..c63659b64b0d7133f40a4f3a028837ae144fd0cc 100644 (file)
                                                        <reference key="NSNextResponder" ref="177223957"/>
                                                        <int key="NSvFlags">275</int>
                                                        <array class="NSMutableArray" key="NSSubviews">
-                                                               <object class="NSButton" id="12898323">
+                                                               <object class="NSButton" id="918286878">
                                                                        <reference key="NSNextResponder" ref="734312853"/>
-                                                                       <int key="NSvFlags">274</int>
+                                                                       <int key="NSvFlags">-2147483374</int>
                                                                        <string key="NSFrame">{{20, 20}, {194, 283}}</string>
                                                                        <reference key="NSSuperview" ref="734312853"/>
                                                                        <reference key="NSWindow"/>
                                                                        <reference key="NSNextKeyView" ref="471332453"/>
                                                                        <string key="NSReuseIdentifierKey">_NS:22</string>
                                                                        <bool key="NSEnabled">YES</bool>
-                                                                       <object class="NSButtonCell" key="NSCell" id="468117320">
+                                                                       <object class="NSButtonCell" key="NSCell" id="543930440">
                                                                                <int key="NSCellFlags">603979776</int>
                                                                                <int key="NSCellFlags2">134217728</int>
-                                                                               <string type="base64-UTF8" key="NSContents">Tm8gaW5wdXQgZGV2aWNlcyB3ZXJlIGZvdW5kLgoKQ29ubmVjdCBhIGRldmljZSB0byBiZWdpbiBtYXBw
-aW5nLg</string>
-                                                                               <object class="NSFont" key="NSSupport">
+                                                                               <string type="base64-UTF8" key="NSContents">SW5wdXQgaXMgY3VycmVudGx5IGRpc2FibGVkLgoKU3dpdGNoIGJhY2sgdG8gcmUtZW5hYmxlIGlucHV0
+Lg</string>
+                                                                               <object class="NSFont" key="NSSupport" id="644067327">
                                                                                        <string key="NSName">LucidaGrande-Bold</string>
                                                                                        <double key="NSSize">14</double>
                                                                                        <int key="NSfFlags">16</int>
                                                                                </object>
                                                                                <string key="NSCellIdentifier">_NS:22</string>
+                                                                               <reference key="NSControlView" ref="918286878"/>
+                                                                               <int key="NSButtonFlags">-2041823232</int>
+                                                                               <int key="NSButtonFlags2">134</int>
+                                                                               <string key="NSAlternateContents"/>
+                                                                               <string key="NSKeyEquivalent"/>
+                                                                               <int key="NSPeriodicDelay">400</int>
+                                                                               <int key="NSPeriodicInterval">75</int>
+                                                                       </object>
+                                                                       <bool key="NSAllowsLogicalLayoutDirection">NO</bool>
+                                                               </object>
+                                                               <object class="NSButton" id="12898323">
+                                                                       <reference key="NSNextResponder" ref="734312853"/>
+                                                                       <int key="NSvFlags">274</int>
+                                                                       <string key="NSFrame">{{20, 20}, {194, 283}}</string>
+                                                                       <reference key="NSSuperview" ref="734312853"/>
+                                                                       <reference key="NSWindow"/>
+                                                                       <reference key="NSNextKeyView" ref="918286878"/>
+                                                                       <string key="NSReuseIdentifierKey">_NS:22</string>
+                                                                       <bool key="NSEnabled">YES</bool>
+                                                                       <object class="NSButtonCell" key="NSCell" id="468117320">
+                                                                               <int key="NSCellFlags">603979776</int>
+                                                                               <int key="NSCellFlags2">134217728</int>
+                                                                               <string type="base64-UTF8" key="NSContents">Tm8gaW5wdXQgZGV2aWNlcyB3ZXJlIGZvdW5kLgoKQ29ubmVjdCBhIGRldmljZSB0byBiZWdpbiBtYXBw
+aW5nLg</string>
+                                                                               <reference key="NSSupport" ref="644067327"/>
+                                                                               <string key="NSCellIdentifier">_NS:22</string>
                                                                                <reference key="NSControlView" ref="12898323"/>
                                                                                <int key="NSButtonFlags">-2041823232</int>
                                                                                <int key="NSButtonFlags2">134</int>
@@ -741,7 +767,6 @@ aW5nLg</string>
                                                                        <string key="NSFrame">{{343, 31}, {70, 18}}</string>
                                                                        <reference key="NSSuperview" ref="471332453"/>
                                                                        <reference key="NSWindow"/>
-                                                                       <reference key="NSNextKeyView"/>
                                                                        <string key="NSReuseIdentifierKey">_NS:9</string>
                                                                        <bool key="NSEnabled">YES</bool>
                                                                        <object class="NSButtonCell" key="NSCell" id="868379451">
@@ -1668,6 +1693,14 @@ aW5nLg</string>
                                        </object>
                                        <int key="connectionID">915</int>
                                </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">hidSleepingPrompt</string>
+                                               <reference key="source" ref="1007832501"/>
+                                               <reference key="destination" ref="918286878"/>
+                                       </object>
+                                       <int key="connectionID">976</int>
+                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">mappingsController</string>
@@ -2599,6 +2632,7 @@ aW5nLg</string>
                                                <array class="NSMutableArray" key="children">
                                                        <reference ref="364857164"/>
                                                        <reference ref="12898323"/>
+                                                       <reference ref="918286878"/>
                                                </array>
                                                <reference key="parent" ref="177223957"/>
                                        </object>
@@ -2956,6 +2990,19 @@ aW5nLg</string>
                                                <reference key="object" ref="331930027"/>
                                                <reference key="parent" ref="720053764"/>
                                        </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">974</int>
+                                               <reference key="object" ref="918286878"/>
+                                               <array class="NSMutableArray" key="children">
+                                                       <reference ref="543930440"/>
+                                               </array>
+                                               <reference key="parent" ref="734312853"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">975</int>
+                                               <reference key="object" ref="543930440"/>
+                                               <reference key="parent" ref="918286878"/>
+                                       </object>
                                </array>
                        </object>
                        <dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -3205,12 +3252,14 @@ aW5nLg</string>
                                <string key="967.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                                <string key="968.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                                <string key="970.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+                               <string key="974.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+                               <string key="975.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                        </dictionary>
                        <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
                        <nil key="activeLocalization"/>
                        <dictionary class="NSMutableDictionary" key="localizations"/>
                        <nil key="sourceID"/>
-                       <int key="maxID">971</int>
+                       <int key="maxID">976</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3273,6 +3322,7 @@ aW5nLg</string>
                                        </object>
                                        <dictionary class="NSMutableDictionary" key="outlets">
                                                <string key="connectDevicePrompt">NSView</string>
+                                               <string key="hidSleepingPrompt">NSView</string>
                                                <string key="mappingsController">NJMappingsController</string>
                                                <string key="outlineView">NSOutlineView</string>
                                                <string key="outputController">NJOutputController</string>
@@ -3283,6 +3333,10 @@ aW5nLg</string>
                                                        <string key="name">connectDevicePrompt</string>
                                                        <string key="candidateClassName">NSView</string>
                                                </object>
+                                               <object class="IBToOneOutletInfo" key="hidSleepingPrompt">
+                                                       <string key="name">hidSleepingPrompt</string>
+                                                       <string key="candidateClassName">NSView</string>
+                                               </object>
                                                <object class="IBToOneOutletInfo" key="mappingsController">
                                                        <string key="name">mappingsController</string>
                                                        <string key="candidateClassName">NJMappingsController</string>