summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordynaflash <[email protected]>2009-03-16 14:55:44 +0000
committerdynaflash <[email protected]>2009-03-16 14:55:44 +0000
commitda30360f3e7d4c953e5ff9fe8f435db7a887596e (patch)
tree60ff3ac65cd8115ce29787760e408f0b4e9114e4
parent48f7c00f4e9aa893f97c425746dd1cace8215620 (diff)
MacGui: When launching a second instance of HB, warn of existing instance and do not alter the existing queue.
- Note: this does not mean multi-instance encoding off of one queue file works. For now its just better than messing up the first instances queue. Also useful for ui developing on one instance sans encoding while actually encoding with another instance. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2261 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--macosx/Controller.h2
-rw-r--r--macosx/Controller.mm77
2 files changed, 62 insertions, 17 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h
index b3c425e53..619fb8817 100644
--- a/macosx/Controller.h
+++ b/macosx/Controller.h
@@ -394,5 +394,7 @@ BOOL fIsDragging;
- (void) remindUserOfSleepOrShutdown;
- (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
+
+- (int) hbInstances;
@end
diff --git a/macosx/Controller.mm b/macosx/Controller.mm
index 36cd1b79c..f56e622f7 100644
--- a/macosx/Controller.mm
+++ b/macosx/Controller.mm
@@ -142,26 +142,48 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
/*On Screen Notification*/
NSString * alertTitle;
- if (fWorkingCount > 0)
+
+ /* We check to see if there is already another instance of hb running.
+ * Note: hbInstances == 1 means we are the only instance of HandBrake.app
+ */
+ if ([self hbInstances] > 1)
{
- alertTitle = [NSString stringWithFormat:
- NSLocalizedString(@"HandBrake Has Detected %d Previously Encoding Item and %d Pending Item(s) In Your Queue.", @""),
- fWorkingCount,fPendingCount];
+ alertTitle = [NSString stringWithFormat:
+ NSLocalizedString(@"There is already an instance of HandBrake running.", @"")];
+ NSBeginCriticalAlertSheet(
+ alertTitle,
+ NSLocalizedString(@"Reload Queue", nil),
+ nil,
+ nil,
+ fWindow, self,
+ nil, @selector(didDimissReloadQueue:returnCode:contextInfo:), nil,
+ NSLocalizedString(@" HandBrake will now load up the existing queue.", nil));
}
else
{
- alertTitle = [NSString stringWithFormat:
- NSLocalizedString(@"HandBrake Has Detected %d Pending Item(s) In Your Queue.", @""),
- fPendingCount];
+ if (fWorkingCount > 0)
+ {
+ alertTitle = [NSString stringWithFormat:
+ NSLocalizedString(@"HandBrake Has Detected %d Previously Encoding Item and %d Pending Item(s) In Your Queue.", @""),
+ fWorkingCount,fPendingCount];
+ }
+ else
+ {
+ alertTitle = [NSString stringWithFormat:
+ NSLocalizedString(@"HandBrake Has Detected %d Pending Item(s) In Your Queue.", @""),
+ fPendingCount];
+ }
+
+ NSBeginCriticalAlertSheet(
+ alertTitle,
+ NSLocalizedString(@"Reload Queue", nil),
+ nil,
+ NSLocalizedString(@"Empty Queue", nil),
+ fWindow, self,
+ nil, @selector(didDimissReloadQueue:returnCode:contextInfo:), nil,
+ NSLocalizedString(@" Do you want to reload them ?", nil));
}
- NSBeginCriticalAlertSheet(
- alertTitle,
- NSLocalizedString(@"Reload Queue", nil),
- nil,
- NSLocalizedString(@"Empty Queue", nil),
- fWindow, self,
- nil, @selector(didDimissReloadQueue:returnCode:contextInfo:), nil,
- NSLocalizedString(@" Do you want to reload them ?", nil));
+
// call didDimissReloadQueue: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
// right below to either clear the old queue or keep it loaded up.
}
@@ -180,6 +202,24 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
}
}
+- (int) hbInstances
+{
+ /* check to see if another instance of HandBrake.app is running */
+ NSArray *runningAppDictionaries = [[NSWorkspace sharedWorkspace] launchedApplications];
+ NSDictionary *aDictionary;
+ int hbInstances = 0;
+ for (aDictionary in runningAppDictionaries)
+ {
+ // NSLog(@"Open App: %@", [aDictionary valueForKey:@"NSApplicationName"]);
+
+ if ([[aDictionary valueForKey:@"NSApplicationName"] isEqualToString:@"HandBrake"])
+ {
+ hbInstances++;
+ }
+ }
+ return hbInstances;
+}
+
- (void) didDimissReloadQueue: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
{
if (returnCode == NSAlertOtherReturn)
@@ -198,8 +238,11 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
}
else
{
- [self setQueueEncodingItemsAsPending];
- [self showQueueWindow:NULL];
+ if ([self hbInstances] == 1)
+ {
+ [self setQueueEncodingItemsAsPending];
+ }
+ [self showQueueWindow:NULL];
}
}