summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/macos.m26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/macos.m b/src/macos.m
index 6f833e12..b000fed9 100644
--- a/src/macos.m
+++ b/src/macos.m
@@ -28,10 +28,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28 28
29#import <AppKit/AppKit.h> 29#import <AppKit/AppKit.h>
30 30
31static NSTouchBarItemIdentifier goBack_TouchId_ = @"fi.skyjake.Lagrange.back"; 31static NSTouchBarItemIdentifier goBack_TouchId_ = @"fi.skyjake.Lagrange.back";
32static NSTouchBarItemIdentifier goForward_TouchId_ = @"fi.skyjake.Lagrange.forward"; 32static NSTouchBarItemIdentifier goForward_TouchId_ = @"fi.skyjake.Lagrange.forward";
33static NSTouchBarItemIdentifier find_TouchId_ = @"fi.skyjake.Lagrange.find"; 33static NSTouchBarItemIdentifier find_TouchId_ = @"fi.skyjake.Lagrange.find";
34static NSTouchBarItemIdentifier newTab_TouchId_ = @"fi.skyjake.Lagrange.tabs.new"; 34static NSTouchBarItemIdentifier newTab_TouchId_ = @"fi.skyjake.Lagrange.tabs.new";
35static NSTouchBarItemIdentifier sidebarMode_TouchId_ = @"fi.skyjake.Lagrange.sidebar.mode";
35 36
36enum iTouchBarVariant { 37enum iTouchBarVariant {
37 default_TouchBarVariant, 38 default_TouchBarVariant,
@@ -205,6 +206,8 @@ static void appearanceChanged_MacOS_(NSString *name) {
205 NSTouchBarItemIdentifierFixedSpaceSmall, 206 NSTouchBarItemIdentifierFixedSpaceSmall,
206 find_TouchId_, 207 find_TouchId_,
207 NSTouchBarItemIdentifierFlexibleSpace, 208 NSTouchBarItemIdentifierFlexibleSpace,
209 sidebarMode_TouchId_,
210 NSTouchBarItemIdentifierFlexibleSpace,
208 newTab_TouchId_, 211 newTab_TouchId_,
209 NSTouchBarItemIdentifierOtherItemsProxy ]; 212 NSTouchBarItemIdentifierOtherItemsProxy ];
210 break; 213 break;
@@ -228,6 +231,11 @@ static void appearanceChanged_MacOS_(NSString *name) {
228 } 231 }
229} 232}
230 233
234- (void)sidebarModePressed:(id)sender {
235 NSSegmentedControl *seg = sender;
236 postCommandf_App("sidebar.mode arg:%d toggle:1", (int) [seg selectedSegment]);
237}
238
231- (nullable NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar 239- (nullable NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar
232 makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier { 240 makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier {
233 iUnused(touchBar); 241 iUnused(touchBar);
@@ -249,6 +257,16 @@ static void appearanceChanged_MacOS_(NSString *name) {
249 widget:nil 257 widget:nil
250 command:@"focus.set id:find.input"]; 258 command:@"focus.set id:find.input"];
251 } 259 }
260 else if ([identifier isEqualToString:sidebarMode_TouchId_]) {
261 NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:sidebarMode_TouchId_];
262 NSSegmentedControl *seg =
263 [NSSegmentedControl segmentedControlWithLabels:@[ @"Bookmarks", @"History", @"Identities", @"Outline"]
264 trackingMode:NSSegmentSwitchTrackingMomentary
265 target:[[NSApplication sharedApplication] delegate]
266 action:@selector(sidebarModePressed:)];
267 item.view = seg;
268 return item;
269 }
252 else if ([identifier isEqualToString:newTab_TouchId_]) { 270 else if ([identifier isEqualToString:newTab_TouchId_]) {
253 return [[CommandButton alloc] initWithIdentifier:identifier 271 return [[CommandButton alloc] initWithIdentifier:identifier
254 image:[NSImage imageNamed:NSImageNameTouchBarAddTemplate] 272 image:[NSImage imageNamed:NSImageNameTouchBarAddTemplate]