summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-11-24 11:27:06 +0100
committerDamiano Galassi <[email protected]>2017-11-24 11:27:06 +0100
commit13c8582eff580913d290b98bc0a58970121ee088 (patch)
treeeb4fa7ab1263664d65ed3ca53f5e807d88180cd7 /macosx
parent47d7b716b2c1f99c9d6a0ba6d2e834012d0a4d68 (diff)
MacGui: use KVO to get a good part of the change notification in the summary view.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/English.lproj/HBSummaryViewController.xib31
-rw-r--r--macosx/HBAudio.h2
-rw-r--r--macosx/HBAudio.m4
-rw-r--r--macosx/HBController.m4
-rw-r--r--macosx/HBJob+UIAdditions.m19
-rw-r--r--macosx/HBPicture+UIAdditions.h1
-rw-r--r--macosx/HBPicture+UIAdditions.m5
-rw-r--r--macosx/HBSummaryViewController.m195
8 files changed, 231 insertions, 30 deletions
diff --git a/macosx/English.lproj/HBSummaryViewController.xib b/macosx/English.lproj/HBSummaryViewController.xib
index 38037d14c..f67b58170 100644
--- a/macosx/English.lproj/HBSummaryViewController.xib
+++ b/macosx/English.lproj/HBSummaryViewController.xib
@@ -9,6 +9,7 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="HBSummaryViewController">
<connections>
+ <outlet property="dimensionLabel" destination="Jaw-pH-rhf" id="L85-25-Ec7"/>
<outlet property="filtersLabel" destination="BHq-Mt-3eA" id="EGb-du-wYa"/>
<outlet property="previewView" destination="m5a-0z-QQ4" id="1G9-3A-dM4"/>
<outlet property="tracksLabel" destination="yRE-5c-FhX" id="iAo-rN-HdQ"/>
@@ -123,7 +124,7 @@
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="GCn-2c-Fql">
<rect key="frame" x="18" y="249" width="45" height="14"/>
- <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Tracks:" id="3mF-Bb-Gon">
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Tracks:" id="3mF-Bb-Gon">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@@ -131,7 +132,7 @@
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0kh-Uy-Yo3">
<rect key="frame" x="18" y="219" width="45" height="14"/>
- <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Filters:" id="OCw-f6-uA0">
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Filters:" id="OCw-f6-uA0">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@@ -162,15 +163,36 @@
<customView wantsLayer="YES" translatesAutoresizingMaskIntoConstraints="NO" id="m5a-0z-QQ4" customClass="HBPreviewView">
<rect key="frame" x="254" y="16" width="597" height="334"/>
</customView>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Jgq-K8-z3W">
+ <rect key="frame" x="18" y="189" width="45" height="14"/>
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Size:" id="B4a-co-0ly">
+ <font key="font" metaFont="smallSystem"/>
+ <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
+ <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" preferredMaxLayoutWidth="170" translatesAutoresizingMaskIntoConstraints="NO" id="Jaw-pH-rhf">
+ <rect key="frame" x="66" y="189" width="174" height="14"/>
+ <constraints>
+ <constraint firstAttribute="width" constant="170" id="x6E-oo-KCt"/>
+ </constraints>
+ <textFieldCell key="cell" controlSize="mini" selectable="YES" sendsActionOnEndEditing="YES" title="None" id="xmy-Jl-mR4">
+ <font key="font" metaFont="smallSystem"/>
+ <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
</subviews>
<constraints>
<constraint firstItem="m5a-0z-QQ4" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="16" id="2Lv-KO-aKx"/>
<constraint firstItem="0kh-Uy-Yo3" firstAttribute="width" secondItem="bpr-UY-4al" secondAttribute="width" id="3C6-tC-wvc"/>
<constraint firstItem="bpr-UY-4al" firstAttribute="baseline" secondItem="txV-1R-WoD" secondAttribute="baseline" id="5R4-0i-jLq"/>
<constraint firstItem="m5a-0z-QQ4" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="QKv-GR-d2g" secondAttribute="trailing" constant="16" id="8XE-8g-Ufn"/>
+ <constraint firstItem="Jgq-K8-z3W" firstAttribute="leading" secondItem="bpr-UY-4al" secondAttribute="leading" id="9F0-cz-tgC"/>
<constraint firstItem="QKv-GR-d2g" firstAttribute="top" secondItem="fPv-Vw-I89" secondAttribute="bottom" constant="6" id="9NP-48-LS7"/>
<constraint firstItem="lUi-Oc-208" firstAttribute="leading" secondItem="txV-1R-WoD" secondAttribute="leading" id="BPd-g8-Zr2"/>
<constraint firstItem="QKv-GR-d2g" firstAttribute="leading" secondItem="txV-1R-WoD" secondAttribute="leading" id="E60-lK-Qyk"/>
+ <constraint firstItem="Jaw-pH-rhf" firstAttribute="top" secondItem="BHq-Mt-3eA" secondAttribute="bottom" constant="16" id="Enc-zm-i04"/>
<constraint firstAttribute="trailing" secondItem="m5a-0z-QQ4" secondAttribute="trailing" constant="20" id="GYQ-6W-S3N"/>
<constraint firstItem="GCn-2c-Fql" firstAttribute="width" secondItem="bpr-UY-4al" secondAttribute="width" id="HE8-Du-yhU"/>
<constraint firstItem="txV-1R-WoD" firstAttribute="leading" secondItem="bpr-UY-4al" secondAttribute="trailing" constant="8" symbolic="YES" id="I9H-1U-iqt"/>
@@ -182,9 +204,12 @@
<constraint firstItem="bpr-UY-4al" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="16" id="VFQ-Vg-ESJ"/>
<constraint firstItem="0kh-Uy-Yo3" firstAttribute="leading" secondItem="bpr-UY-4al" secondAttribute="leading" id="ZSW-w5-hfn"/>
<constraint firstItem="m5a-0z-QQ4" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="fPv-Vw-I89" secondAttribute="trailing" constant="16" id="bWj-yH-VEO"/>
+ <constraint firstItem="Jaw-pH-rhf" firstAttribute="leading" secondItem="Jgq-K8-z3W" secondAttribute="trailing" constant="7" id="beE-wT-2DH"/>
<constraint firstItem="fPv-Vw-I89" firstAttribute="top" secondItem="lUi-Oc-208" secondAttribute="bottom" constant="6" id="bxR-uJ-u4M"/>
<constraint firstItem="lUi-Oc-208" firstAttribute="top" secondItem="txV-1R-WoD" secondAttribute="bottom" constant="8" id="cJz-xA-oz4"/>
<constraint firstItem="BHq-Mt-3eA" firstAttribute="leading" secondItem="0kh-Uy-Yo3" secondAttribute="trailing" constant="7" id="dZN-9S-z89"/>
+ <constraint firstItem="Jgq-K8-z3W" firstAttribute="top" secondItem="Jaw-pH-rhf" secondAttribute="top" id="gFS-AW-Tdp"/>
+ <constraint firstItem="Jgq-K8-z3W" firstAttribute="width" secondItem="bpr-UY-4al" secondAttribute="width" id="j4u-XL-c2Z"/>
<constraint firstItem="GCn-2c-Fql" firstAttribute="top" secondItem="yRE-5c-FhX" secondAttribute="top" id="jTa-bA-Weo"/>
<constraint firstItem="0kh-Uy-Yo3" firstAttribute="top" secondItem="BHq-Mt-3eA" secondAttribute="top" id="nwz-Xj-cMt"/>
<constraint firstAttribute="bottom" secondItem="m5a-0z-QQ4" secondAttribute="bottom" constant="16" id="ouA-jz-Qs8"/>
@@ -193,7 +218,7 @@
<constraint firstItem="GCn-2c-Fql" firstAttribute="leading" secondItem="bpr-UY-4al" secondAttribute="leading" id="utH-I5-f9B"/>
<constraint firstItem="m5a-0z-QQ4" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="txV-1R-WoD" secondAttribute="trailing" constant="16" id="vr4-76-FcH"/>
</constraints>
- <point key="canvasLocation" x="249" y="22"/>
+ <point key="canvasLocation" x="14" y="25"/>
</customView>
</objects>
</document>
diff --git a/macosx/HBAudio.h b/macosx/HBAudio.h
index 899c8dc88..6613a6f2c 100644
--- a/macosx/HBAudio.h
+++ b/macosx/HBAudio.h
@@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN
-extern NSString *HBAudioChangedNotification;
+extern NSString *HBAudioEncoderChangedNotification;
@interface HBAudio : NSObject <NSSecureCoding, NSCopying>
diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m
index cb0c5a294..0d7958668 100644
--- a/macosx/HBAudio.m
+++ b/macosx/HBAudio.m
@@ -20,7 +20,7 @@
#define NONE_TRACK_INDEX 0
-NSString *HBAudioChangedNotification = @"HBAudioChangedNotification";
+NSString *HBAudioEncoderChangedNotification = @"HBAudioEncoderChangedNotification";
@interface HBAudio () <HBAudioTrackDataSource, HBAudioTrackDelegate>
@@ -224,7 +224,7 @@ NSString *HBAudioChangedNotification = @"HBAudioChangedNotification";
- (void)encoderChanged
{
- [[NSNotificationCenter defaultCenter] postNotificationName:HBAudioChangedNotification object:self];
+ [[NSNotificationCenter defaultCenter] postNotificationName:HBAudioEncoderChangedNotification object:self];
}
#pragma mark - NSCopying
diff --git a/macosx/HBController.m b/macosx/HBController.m
index 2cd279343..32995f738 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -764,7 +764,7 @@
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBPictureChangedNotification object:_job.picture];
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBFiltersChangedNotification object:_job.filters];
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBVideoChangedNotification object:_job.video];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HBAudioChangedNotification object:_job.audio];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:HBAudioEncoderChangedNotification object:_job.audio];
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBChaptersChangedNotification object:_job];
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBRangeChangedNotification object:_job.range];
}
@@ -783,7 +783,7 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(customSettingUsed) name:HBPictureChangedNotification object:_job.picture];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(customSettingUsed) name:HBFiltersChangedNotification object:_job.filters];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(customSettingUsed) name:HBVideoChangedNotification object:_job.video];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateFileExtension:) name:HBAudioChangedNotification object:_job.audio];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateFileExtension:) name:HBAudioEncoderChangedNotification object:_job.audio];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateFileExtension:) name:HBChaptersChangedNotification object:_job];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(chapterPopUpChanged:) name:HBRangeChangedNotification object:_job.range];
}
diff --git a/macosx/HBJob+UIAdditions.m b/macosx/HBJob+UIAdditions.m
index d78f2b377..24ff6c219 100644
--- a/macosx/HBJob+UIAdditions.m
+++ b/macosx/HBJob+UIAdditions.m
@@ -722,6 +722,7 @@ static NSDictionary *shortHeightAttr;
{
NSMutableString *info = [NSMutableString string];
+ NSUInteger index = 0;
for (HBSubtitlesTrack *track in self.subtitles.tracks)
{
// Ignore the none track.
@@ -737,6 +738,24 @@ static NSDictionary *shortHeightAttr;
[info appendString:@"\n"];
}
+
+ if (index == 1) {
+ break;
+ }
+ index += 1;
+ }
+
+ if (self.subtitles.tracks.count > 3)
+ {
+ NSUInteger count = self.subtitles.tracks.count - 3;
+ if (count == 1)
+ {
+ [info appendString:NSLocalizedString(@"+ 1 additional subtitles track", nil)];
+ }
+ else
+ {
+ [info appendFormat:NSLocalizedString(@"+ %lu additional subtitles tracks", nil), (unsigned long)count];
+ }
}
if ([info hasSuffix:@"\n"])
diff --git a/macosx/HBPicture+UIAdditions.h b/macosx/HBPicture+UIAdditions.h
index 3e1fa2f60..38c0e5519 100644
--- a/macosx/HBPicture+UIAdditions.h
+++ b/macosx/HBPicture+UIAdditions.h
@@ -14,6 +14,7 @@
*/
@property (nonatomic, readonly) NSString *info;
@property (nonatomic, readonly) NSString *sourceInfo;
+@property (nonatomic, readonly) NSString *shortInfo;
@property (nonatomic, readonly) NSString *summary;
@property (nonatomic, readonly) int maxWidth;
diff --git a/macosx/HBPicture+UIAdditions.m b/macosx/HBPicture+UIAdditions.m
index a3a996942..be4140b56 100644
--- a/macosx/HBPicture+UIAdditions.m
+++ b/macosx/HBPicture+UIAdditions.m
@@ -89,6 +89,11 @@
return sizeInfo;
}
+- (NSString *)shortInfo
+{
+ return [NSString stringWithFormat:@"%dx%d storage, %dx%d display", self.width, self.height, self.displayWidth, self.height];
+}
+
- (NSString *)sourceInfo
{
NSString *sizeInfo = @"";
diff --git a/macosx/HBSummaryViewController.m b/macosx/HBSummaryViewController.m
index 63fb45957..7a4d84284 100644
--- a/macosx/HBSummaryViewController.m
+++ b/macosx/HBSummaryViewController.m
@@ -10,32 +10,53 @@
@import HandBrakeKit;
+static void *HBSummaryViewControllerContext = &HBSummaryViewControllerContext;
+
@interface HBSummaryViewController ()
@property (strong) IBOutlet HBPreviewView *previewView;
@property (strong) IBOutlet NSTextField *tracksLabel;
@property (strong) IBOutlet NSTextField *filtersLabel;
+@property (strong) IBOutlet NSTextField *dimensionLabel;
+
+@property (nonatomic) BOOL tracksReloadInQueue;
+@property (nonatomic) BOOL filtersReloadInQueue;
+@property (nonatomic) BOOL pictureReloadInQueue;
+
+@property (nonatomic) BOOL visible;
@end
@implementation HBSummaryViewController
-- (void)loadView {
+- (void)loadView
+{
[super loadView];
self.previewView.showShadow = NO;
[self resetLabels];
}
+- (void)viewDidAppear
+{
+ self.visible = YES;
+ if (self.pictureReloadInQueue || self.previewView.image == NULL)
+ {
+ [self updatePicture];
+ }
+}
+
+- (void)viewDidDisappear
+{
+ self.visible = NO;
+}
+
- (void)setGenerator:(HBPreviewGenerator *)generator
{
_generator = generator;
if (generator)
{
- NSUInteger index = generator.imagesCount > 1 ? 1 : 0;
- CGImageRef fPreviewImage = [generator copyImageAtIndex:index shouldCache:NO];
- self.previewView.image = fPreviewImage;
- CFRelease(fPreviewImage);
+ [self updatePicture];
}
else
{
@@ -47,9 +68,11 @@
{
if (job)
{
+ [self removeJobObservers];
_job = job;
[self addJobObservers];
- [self updateLabels];
+ [self updateTracksLabel];
+ [self updateFiltersLabel];
}
else
{
@@ -59,51 +82,179 @@
}
}
+#pragma mark - KVO
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+ if (context == HBSummaryViewControllerContext)
+ {
+ if ([keyPath isEqualToString:@"audio.tracks"])
+ {
+ if ([change[@"kind"] integerValue] == NSKeyValueChangeInsertion)
+ {
+ [self addAudioTracksObservers:change[@"new"]];
+ }
+ else if ([change[@"kind"] integerValue]== NSKeyValueChangeRemoval)
+ {
+ [self removeAudioTracksObservers:change[@"old"]];
+ }
+ }
+ else if ([keyPath isEqualToString:@"subtitles.tracks"])
+ {
+ if ([change[@"kind"] integerValue] == NSKeyValueChangeInsertion)
+ {
+ [self addSubtitlesTracksObservers:change[@"new"]];
+ }
+ else if ([change[@"kind"] integerValue]== NSKeyValueChangeRemoval)
+ {
+ [self removeSubtitlesTracksObservers:change[@"old"]];
+ }
+ }
+
+ [self updateTracks:nil];
+ }
+ else
+ {
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+ }
+}
+
+- (void)addAudioTracksObservers:(NSArray<HBAudioTrack *> *)tracks
+{
+ for (HBAudioTrack *track in tracks)
+ {
+ [track addObserver:self forKeyPath:@"encoder" options:0 context:HBSummaryViewControllerContext];
+ [track addObserver:self forKeyPath:@"mixdown" options:0 context:HBSummaryViewControllerContext];
+ }
+}
+
+- (void)removeAudioTracksObservers:(NSArray<HBAudioTrack *> *)tracks
+{
+ for (HBAudioTrack *track in tracks)
+ {
+ [track removeObserver:self forKeyPath:@"encoder"];
+ [track removeObserver:self forKeyPath:@"mixdown"];
+ }
+}
+
+- (void)addSubtitlesTracksObservers:(NSArray<HBSubtitlesTrack *> *)tracks
+{
+ for (HBSubtitlesTrack *track in tracks)
+ {
+ [track addObserver:self forKeyPath:@"burnedIn" options:0 context:HBSummaryViewControllerContext];
+ }
+}
+
+- (void)removeSubtitlesTracksObservers:(NSArray<HBSubtitlesTrack *> *)tracks
+{
+ for (HBSubtitlesTrack *track in tracks)
+ {
+ [track removeObserver:self forKeyPath:@"burnedIn"];
+ }
+}
+
+- (void)addJobObservers
+{
+ if (_job)
+ {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePicture:) name:HBPictureChangedNotification object:_job.picture];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateFilters:) name:HBFiltersChangedNotification object:_job.filters];
+
+ [_job addObserver:self forKeyPath:@"video.encoder" options:0 context:HBSummaryViewControllerContext];
+ [_job addObserver:self forKeyPath:@"video.frameRate" options:0 context:HBSummaryViewControllerContext];
+ [_job addObserver:self forKeyPath:@"video.frameRateMode" options:0 context:HBSummaryViewControllerContext];
+ [_job addObserver:self forKeyPath:@"container" options:0 context:HBSummaryViewControllerContext];
+ [_job addObserver:self forKeyPath:@"chaptersEnabled" options:0 context:HBSummaryViewControllerContext];
+ [_job addObserver:self forKeyPath:@"audio.tracks" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:HBSummaryViewControllerContext];
+ [_job addObserver:self forKeyPath:@"subtitles.tracks" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:HBSummaryViewControllerContext];
+
+ [self addAudioTracksObservers:_job.audio.tracks];
+ [self addSubtitlesTracksObservers:_job.subtitles.tracks];
+ }
+}
+
- (void)removeJobObservers
{
- if (self.job)
+ if (_job)
{
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HBContainerChangedNotification object:_job];
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBPictureChangedNotification object:_job.picture];
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBFiltersChangedNotification object:_job.filters];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HBVideoChangedNotification object:_job.video];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HBAudioChangedNotification object:_job.audio];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HBChaptersChangedNotification object:_job];
+
+ [_job removeObserver:self forKeyPath:@"video.encoder"];
+ [_job removeObserver:self forKeyPath:@"video.frameRate"];
+ [_job removeObserver:self forKeyPath:@"video.frameRateMode"];
+ [_job removeObserver:self forKeyPath:@"container"];
+ [_job removeObserver:self forKeyPath:@"chaptersEnabled"];
+ [_job removeObserver:self forKeyPath:@"audio.tracks"];
+ [_job removeObserver:self forKeyPath:@"subtitles.tracks"];
+
+ [self removeAudioTracksObservers:_job.audio.tracks];
+ [self removeSubtitlesTracksObservers:_job.subtitles.tracks];
}
}
- (void)updateTracks:(NSNotification *)notification
{
- self.tracksLabel.stringValue = self.job.shortDescription;
+ if (self.tracksReloadInQueue == NO)
+ {
+ [[NSRunLoop mainRunLoop] performSelector:@selector(updateTracksLabel) target:self argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
+ self.tracksReloadInQueue = YES;
+ }
}
- (void)updateFilters:(NSNotification *)notification
{
- self.filtersLabel.stringValue = self.job.filtersShortDescription;
+ if (self.filtersReloadInQueue == NO)
+ {
+ [[NSRunLoop mainRunLoop] performSelector:@selector(updateFiltersLabel) target:self argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
+ self.filtersReloadInQueue = YES;
+ }
+}
+
+- (void)updatePicture:(NSNotification *)notification
+{
+ // Enquee the reload call on the main runloop
+ // to avoid reloading the same image multiple times.
+ if (self.pictureReloadInQueue == NO)
+ {
+ [[NSRunLoop mainRunLoop] performSelector:@selector(updatePicture) target:self argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
+ self.pictureReloadInQueue = YES;
+ }
}
- (void)resetLabels
{
self.tracksLabel.stringValue = NSLocalizedString(@"None", nil);
self.filtersLabel.stringValue = NSLocalizedString(@"None", nil);
+ self.dimensionLabel.stringValue = NSLocalizedString(@"None", nil);
+ self.tracksReloadInQueue = NO;
+ self.filtersReloadInQueue = NO;
+ self.pictureReloadInQueue = NO;
}
-- (void)updateLabels
+- (void)updateTracksLabel
{
self.tracksLabel.stringValue = self.job.shortDescription;
+ self.tracksReloadInQueue = NO;
+}
+
+- (void)updateFiltersLabel
+{
self.filtersLabel.stringValue = self.job.filtersShortDescription;
+ self.filtersReloadInQueue = NO;
}
-- (void)addJobObservers
+- (void)updatePicture
{
- if (self.job)
+ if (self.visible && self.generator)
{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBContainerChangedNotification object:_job];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBPictureChangedNotification object:_job.picture];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateFilters:) name:HBFiltersChangedNotification object:_job.filters];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBVideoChangedNotification object:_job.video];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBAudioChangedNotification object:_job.audio];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBChaptersChangedNotification object:_job];
+ NSUInteger index = self.generator.imagesCount > 1 ? 1 : 0;
+ CGImageRef fPreviewImage = [self.generator copyImageAtIndex:index shouldCache:NO];
+ self.previewView.image = fPreviewImage;
+ CFRelease(fPreviewImage);
+ self.pictureReloadInQueue = NO;
+
+ self.dimensionLabel.stringValue = self.job.picture.shortInfo;
}
}