summaryrefslogtreecommitdiffstats
path: root/macosx/HBQueueController.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2015-02-02 11:12:54 +0000
committerritsuka <[email protected]>2015-02-02 11:12:54 +0000
commit786042401cf317426ac50b497b390a52b53693f6 (patch)
treed51e868a03bbc3146b93d2839e9b86457f7e000d /macosx/HBQueueController.m
parent7d6e17b7089c82aafee0f4013943a9f40866465b (diff)
MacGui: add a "Clear All" and "Clear completed items" menu items to the queue contextual menu.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6860 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBQueueController.m')
-rw-r--r--macosx/HBQueueController.m56
1 files changed, 44 insertions, 12 deletions
diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m
index 054db0568..46d9bae69 100644
--- a/macosx/HBQueueController.m
+++ b/macosx/HBQueueController.m
@@ -172,7 +172,14 @@
return (self.core.state == HBStateWorking || self.core.state == HBStatePaused);
}
-
+
+ if (action == @selector(editSelectedQueueItem:) ||
+ action == @selector(removeSelectedQueueItem:) ||
+ action == @selector(revealSelectedQueueItem:))
+ {
+ return (self.outlineView.selectedRow != -1 || self.outlineView.clickedRow != -1);
+ }
+
return YES;
}
@@ -370,18 +377,10 @@
- (void)clearEncodedJobs
{
[self.jobs beginTransaction];
- NSMutableArray *encodedJobs = [NSMutableArray array];
- for (HBJob *job in self.jobs)
- {
- if (job.state == HBJobStateCompleted || job.state == HBJobStateCanceled)
- {
- [encodedJobs addObject:job];
- }
- }
-
- [self.jobs removeObjectsInArray:encodedJobs];
+ [self removeItemsUsingBlock:^BOOL(HBJob *item) {
+ return (item.state == HBJobStateCompleted || item.state == HBJobStateCanceled);
+ }];
[self.jobs commit];
-
[self reloadQueue];
}
@@ -397,6 +396,19 @@
[self reloadQueue];
}
+- (void)removeItemsUsingBlock:(BOOL (^)(HBJob *item))predicate
+{
+ NSMutableArray *encodedJobs = [NSMutableArray array];
+ for (HBJob *job in self.jobs)
+ {
+ if (predicate(job))
+ {
+ [encodedJobs addObject:job];
+ }
+ }
+ [self.jobs removeObjectsInArray:encodedJobs];
+}
+
/**
* this is actually called from the queue controller to modify the queue array and return it back to the queue controller
*/
@@ -1122,6 +1134,26 @@
}
}
+- (IBAction)clearAll:(id)sender
+{
+ [self.jobs beginTransaction];
+ [self removeItemsUsingBlock:^BOOL(HBJob *item) {
+ return (item.state != HBJobStateWorking);
+ }];
+ [self.jobs commit];
+ [self reloadQueue];
+}
+
+- (IBAction)clearCompleted:(id)sender
+{
+ [self.jobs beginTransaction];
+ [self removeItemsUsingBlock:^BOOL(HBJob *item) {
+ return (item.state == HBJobStateCompleted);
+ }];
+ [self.jobs commit];
+ [self reloadQueue];
+}
+
#pragma mark -
#pragma mark NSOutlineView delegate