Merge pull request #9028 from electron/fix-popover-items-not-updating
Fix popover items not updating
This commit is contained in:
commit
7574c33ef1
2 changed files with 38 additions and 12 deletions
|
@ -113,19 +113,10 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
||||||
id:(const std::string&)item_id {
|
id:(NSTouchBarItemIdentifier)identifier
|
||||||
if (![self hasItemWithID:item_id]) return;
|
withType:(const std::string&)item_type
|
||||||
|
withSettings:(const mate::PersistentDictionary&)settings {
|
||||||
mate::PersistentDictionary settings = settings_[item_id];
|
|
||||||
std::string item_type;
|
|
||||||
settings.Get("type", &item_type);
|
|
||||||
|
|
||||||
NSTouchBarItemIdentifier identifier = [self identifierFromID:item_id
|
|
||||||
type:item_type];
|
|
||||||
if (!identifier) return;
|
|
||||||
|
|
||||||
NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
|
NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
|
@ -166,6 +157,37 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
||||||
|
id:(const std::string&)item_id {
|
||||||
|
if (![self hasItemWithID:item_id]) return;
|
||||||
|
|
||||||
|
mate::PersistentDictionary settings = settings_[item_id];
|
||||||
|
std::string item_type;
|
||||||
|
settings.Get("type", &item_type);
|
||||||
|
|
||||||
|
auto identifier = [self identifierFromID:item_id type:item_type];
|
||||||
|
if (!identifier) return;
|
||||||
|
|
||||||
|
std::vector<std::string> popover_ids;
|
||||||
|
settings.Get("_popover", &popover_ids);
|
||||||
|
for (auto& popover_id : popover_ids) {
|
||||||
|
auto popoverIdentifier = [self identifierFromID:popover_id type:"popover"];
|
||||||
|
if (!popoverIdentifier) continue;
|
||||||
|
|
||||||
|
NSPopoverTouchBarItem* popoverItem =
|
||||||
|
[touchBar itemForIdentifier:popoverIdentifier];
|
||||||
|
[self refreshTouchBarItem:popoverItem.popoverTouchBar
|
||||||
|
id:identifier
|
||||||
|
withType:item_type
|
||||||
|
withSettings:settings];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self refreshTouchBarItem:touchBar
|
||||||
|
id:identifier
|
||||||
|
withType:item_type
|
||||||
|
withSettings:settings];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)buttonAction:(id)sender {
|
- (void)buttonAction:(id)sender {
|
||||||
NSString* item_id = [NSString stringWithFormat:@"%ld", ((NSButton*)sender).tag];
|
NSString* item_id = [NSString stringWithFormat:@"%ld", ((NSButton*)sender).tag];
|
||||||
window_->NotifyTouchBarItemInteraction([item_id UTF8String],
|
window_->NotifyTouchBarItemInteraction([item_id UTF8String],
|
||||||
|
|
|
@ -223,6 +223,10 @@ TouchBar.TouchBarPopover = class TouchBarPopover extends TouchBarItem {
|
||||||
if (!(this.child instanceof TouchBar)) {
|
if (!(this.child instanceof TouchBar)) {
|
||||||
this.child = new TouchBar(this.child)
|
this.child = new TouchBar(this.child)
|
||||||
}
|
}
|
||||||
|
this.child.ordereredItems.forEach((item) => {
|
||||||
|
item._popover = item._popover || []
|
||||||
|
if (!item._popover.includes(this.id)) item._popover.push(this.id)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue