]> granicus.if.org Git - handbrake/commitdiff
MacGui: add a touch bar button to open a new source when all the windows are closed.
authorDamiano Galassi <damiog@gmail.com>
Thu, 13 Dec 2018 12:23:34 +0000 (13:23 +0100)
committerDamiano Galassi <damiog@gmail.com>
Thu, 13 Dec 2018 12:23:34 +0000 (13:23 +0100)
macosx/HBAppDelegate.m

index e4d78e6fb4d72507a76a1030253344d2463b6cd7..630fcb7500fc020322596c5e21493edd7aa5028a 100644 (file)
 }
 
 @end
+
+@interface NSApplication (TouchBar) <NSTouchBarDelegate>
+@end
+
+@implementation NSApplication (TouchBar)
+
+static NSTouchBarItemIdentifier HBTouchBarMain = @"fr.handbrake.appDelegateTouchBar";
+static NSTouchBarItemIdentifier HBTouchBarOpen = @"fr.handbrake.openSource";
+
+- (NSTouchBar *)makeTouchBar
+{
+    NSTouchBar *bar = [[NSTouchBar alloc] init];
+    bar.delegate = self;
+
+    bar.defaultItemIdentifiers = @[HBTouchBarOpen];
+
+    return bar;
+}
+
+- (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
+{
+    if ([identifier isEqualTo:HBTouchBarOpen])
+    {
+        NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
+        item.customizationLabel = NSLocalizedString(@"Open Source", @"Touch bar");
+
+        NSButton *button = [NSButton buttonWithTitle:NSLocalizedString(@"Open Source", @"Touch bar") target:nil action:@selector(browseSources:)];
+
+        item.view = button;
+        return item;
+    }
+
+    return nil;
+}
+
+@end