Add a method to set the escape identifier on the touch bar
This commit is contained in:
parent
3c1a372157
commit
4d6b0fc01b
10 changed files with 66 additions and 1 deletions
|
@ -31,6 +31,8 @@
|
|||
- (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items;
|
||||
- (NSMutableArray*)identifiersFromSettings:(const std::vector<mate::PersistentDictionary>&)settings;
|
||||
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar id:(const std::string&)item_id;
|
||||
- (void)addNonDefaultTouchBarItems:(std::vector<mate::PersistentDictionary>)items;
|
||||
- (void)setEscapeTouchBarItem:(mate::PersistentDictionary)item forTouchBar:(NSTouchBar*)touchBar;
|
||||
|
||||
|
||||
- (NSString*)idFromIdentifier:(NSString*)identifier withPrefix:(NSString*)prefix;
|
||||
|
|
|
@ -145,7 +145,25 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|||
} else if (item_type == "scrubber") {
|
||||
[self updateScrubber:(NSCustomTouchBarItem*)item withSettings:settings];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addNonDefaultTouchBarItems:(std::vector<mate::PersistentDictionary>)items {
|
||||
[self identifiersFromSettings:items];
|
||||
}
|
||||
|
||||
- (void)setEscapeTouchBarItem:(mate::PersistentDictionary)item forTouchBar:(NSTouchBar*)touchBar {
|
||||
std::string type;
|
||||
std::string item_id;
|
||||
NSTouchBarItemIdentifier identifier = nil;
|
||||
if (item.Get("type", &type) && item.Get("id", &item_id)) {
|
||||
identifier = [self identifierFromID:item_id type:type];
|
||||
}
|
||||
if (identifier) {
|
||||
[self addNonDefaultTouchBarItems:{ item }];
|
||||
touchBar.escapeKeyReplacementItemIdentifier = identifier;
|
||||
} else {
|
||||
touchBar.escapeKeyReplacementItemIdentifier = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)buttonAction:(id)sender {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue