summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2018-12-13 13:23:34 +0100
committerDamiano Galassi <[email protected]>2018-12-13 13:23:34 +0100
commit4475ff63b6dcf61cc90d8667d070022b18654b6e (patch)
treeb9e11f47e35703e8ab7c39c451ce7dff6a86e9cc /macosx
parent8b2d50c0bf64db797c29e03f96bfffabcc2ba19b (diff)
MacGui: add a touch bar button to open a new source when all the windows are closed.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/HBAppDelegate.m36
1 files changed, 36 insertions, 0 deletions
diff --git a/macosx/HBAppDelegate.m b/macosx/HBAppDelegate.m
index e4d78e6fb..630fcb750 100644
--- a/macosx/HBAppDelegate.m
+++ b/macosx/HBAppDelegate.m
@@ -367,3 +367,39 @@
}
@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