diff options
author | Damiano Galassi <[email protected]> | 2019-08-11 09:07:20 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2019-08-11 09:07:20 +0200 |
commit | bed55e05880f0286f504142a48089bce60c96cc7 (patch) | |
tree | 795647e216e70981acc9ba0769eb03c53da44023 /macosx/HBController.m | |
parent | 6437b9d6653352011dc8af541b373369c45c8d44 (diff) |
MacGui: move the queue libhb instance to an xpc service.
Diffstat (limited to 'macosx/HBController.m')
-rw-r--r-- | macosx/HBController.m | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m index c2a4716f0..8f45ca51f 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -41,7 +41,6 @@ #import "HBPreferencesKeys.h" static void *HBControllerScanCoreContext = &HBControllerScanCoreContext; -static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; @interface HBController () <HBPresetsViewControllerDelegate, HBTitleSelectionDelegate, NSDraggingDestination, NSPopoverDelegate> { @@ -279,13 +278,9 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial context:HBControllerScanCoreContext]; - [self.queue.core addObserver:self forKeyPath:@"state" - options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial - context:HBControllerQueueCoreContext]; - - [self.queue addObserver:self forKeyPath:@"pendingItemsCount" - options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial - context:HBControllerQueueCoreContext]; + [NSNotificationCenter.defaultCenter addObserverForName:HBQueueDidChangeStateNotification object:_queue queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull note) { + [self updateQueueUI]; + }]; [NSNotificationCenter.defaultCenter addObserverForName:HBQueueDidStartNotification object:_queue queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull note) { self.bottomConstrain.animator.constant = 0; @@ -383,24 +378,25 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; [self _touchBar_validateUserInterfaceItems]; } } - else if (context == HBControllerQueueCoreContext) - { - [self updateToolbarButtonsState]; - [self.window.toolbar validateVisibleItems]; - if (@available(macOS 10.12.2, *)) - { - [self _touchBar_updateQueueButtonsState]; - [self _touchBar_validateUserInterfaceItems]; - } - NSUInteger count = self.queue.pendingItemsCount; - self.showQueueToolbarItem.badgeValue = count ? @(count).stringValue : nil; - } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } } +- (void)updateQueueUI +{ + [self updateToolbarButtonsState]; + [self.window.toolbar validateVisibleItems]; + if (@available(macOS 10.12.2, *)) + { + [self _touchBar_updateQueueButtonsState]; + [self _touchBar_validateUserInterfaceItems]; + } + NSUInteger count = self.queue.pendingItemsCount; + self.showQueueToolbarItem.badgeValue = count ? @(count).stringValue : nil; +} + - (void)updateToolbarButtonsStateForScanCore:(HBState)state { if (state == HBStateIdle) |