summaryrefslogtreecommitdiffstats
path: root/macosx/HBController.m
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/HBController.m')
-rw-r--r--macosx/HBController.m74
1 files changed, 43 insertions, 31 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m
index fa57e1141..5cb51da8b 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -621,81 +621,93 @@
self.window.representedURL = mediaURL;
self.window.title = mediaURL.lastPathComponent;
-
- completionHandler(self.core.titles);
}
else
{
// We display a message if a valid source was not chosen
fSrcDVD2Field.stringValue = NSLocalizedString(@"No Valid Source Found", @"");
}
+
+ completionHandler(self.core.titles);
[self.window.toolbar validateVisibleItems];
}];
}
+ else
+ {
+ completionHandler(@[]);
+ }
}
- (void)openURL:(NSURL *)fileURL titleIndex:(NSUInteger)index
{
[self scanURL:fileURL titleIndex:index completionHandler:^(NSArray<HBTitle *> *titles)
{
- [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:fileURL];
-
- HBTitle *featuredTitle = titles.firstObject;
- for (HBTitle *title in titles)
+ if (titles.count)
{
- if (title.isFeatured)
+ [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:fileURL];
+
+ HBTitle *featuredTitle = titles.firstObject;
+ for (HBTitle *title in titles)
{
- featuredTitle = title;
+ if (title.isFeatured)
+ {
+ featuredTitle = title;
+ }
}
- }
- HBJob *job = [self jobFromTitle:featuredTitle];
- self.job = job;
+ HBJob *job = [self jobFromTitle:featuredTitle];
+ self.job = job;
+ }
}];
}
-- (BOOL)openURL:(NSURL *)fileURL
+- (void)openURL:(NSURL *)fileURL
{
if (self.core.state != HBStateScanning)
{
[self openURL:fileURL titleIndex:0];
- return YES;
}
- return NO;
}
/**
* Rescans the a job back into the main window
*/
-- (BOOL)openJob:(HBJob *)job
+- (void)openJob:(HBJob *)job completionHandler:(void (^)(BOOL result))handler
{
if (self.core.state != HBStateScanning)
{
[self scanURL:job.fileURL titleIndex:job.titleIdx completionHandler:^(NSArray<HBTitle *> *titles)
{
- // If the scan was cached, reselect
- // the original title
- for (HBTitle *title in titles)
+ if (titles.count)
{
- if (title.index == job.titleIdx)
+ // If the scan was cached, reselect
+ // the original title
+ for (HBTitle *title in titles)
{
- job.title = title;
- break;
+ if (title.index == job.titleIdx)
+ {
+ job.title = title;
+ break;
+ }
}
- }
- // Else just one title or a title specific rescan
- // select the first title
- if (!job.title)
- {
- job.title = titles.firstObject;
+ // Else just one title or a title specific rescan
+ // select the first title
+ if (!job.title)
+ {
+ job.title = titles.firstObject;
+ }
+ self.job = job;
+
+ handler(YES);
}
- self.job = job;
+ handler(NO);
}];
-
- return YES;
}
- return NO;
+ else
+ {
+ handler(NO);
+ }
}
- (HBJob *)jobFromTitle:(HBTitle *)title