OSDN Git Service

MacGui: Warn of duplicate output filenames when adding to the queue.
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 14 Jan 2008 13:58:19 +0000 (13:58 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 14 Jan 2008 13:58:19 +0000 (13:58 +0000)
- Thanks travistex

git-svn-id: svn://localhost/HandBrake/trunk@1192 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.mm
macosx/HBQueueController.h
macosx/HBQueueController.mm
macosx/InstantHandBrake/InstantHandBrake.xcodeproj/project.pbxproj

index 4e53fa1..8915642 100644 (file)
@@ -1700,6 +1700,19 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             [fDstFile2Field stringValue]] );
         // overwriteAddToQueueAlertDone: will be called when the alert is dismissed.
     }
+    
+    // Warn if another pending job in the queue has the same destination path
+    else if ([fQueueController pendingJobGroupWithDestinationPath:[fDstFile2Field stringValue]] != nil)
+    {
+        NSBeginCriticalAlertSheet( _( @"Another queued encode has specified the same destination." ),
+            _( @"Cancel" ), _( @"Overwrite" ), NULL, fWindow, self,
+            @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ),
+            NULL, NULL, [NSString stringWithFormat:
+            _( @"Do you want to overwrite %@?" ),
+            [fDstFile2Field stringValue]] );
+        // overwriteAddToQueueAlertDone: will be called when the alert is dismissed.
+    }
+    
     else
     {
         [self doAddToQueue];
index d1bb0c7..2070f04 100644 (file)
@@ -178,7 +178,7 @@ BOOL                        fIsDragging;
 - (HBQueueJobGroupStatus)  status;
 - (void)               setPresetName: (NSString *)name;
 - (NSString *)         presetName;
-- (NSString *)         path;
+- (NSString *)         destinationPath;
 - (NSString *)         name;
 
 // Creating a description
@@ -264,6 +264,9 @@ BOOL                        fIsDragging;
 - (HBJobGroup *) currentJobGroup;
 - (HBJob *) currentJob;
 
+// Getting job groups
+- (HBJobGroup *) pendingJobGroupWithDestinationPath: (NSString *)path;
+
 // Getting queue statistics
 - (unsigned int) pendingCount;
 - (unsigned int) completedCount;
index 6743b37..75095af 100644 (file)
@@ -805,7 +805,7 @@ NSString *HBJobGroupStatusNotification = @"HBJobGroupStatusNotification";
     return firstJob ? firstJob->titleName : nil;
 }
 
-- (NSString *) path
+- (NSString *) destinationPath
 {
     HBJob * firstJob = [self jobAtIndex:0];
     return firstJob ? firstJob->file : nil;
@@ -907,6 +907,8 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
     return fCurrentJob;
 }
 
+#pragma mark -
+
 //------------------------------------------------------------------------------------
 // Displays and brings the queue window to the front
 //------------------------------------------------------------------------------------
@@ -976,6 +978,24 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
     fCurrentJobGroup = aJobGroup;
 }
 
+#pragma mark - Finding job groups
+
+//------------------------------------------------------------------------------------
+// Returns the first pending job with a specified destination path or nil if no such
+// job exists.
+//------------------------------------------------------------------------------------
+- (HBJobGroup *) pendingJobGroupWithDestinationPath: (NSString *)path
+{
+    HBJobGroup * aJobGroup;
+    NSEnumerator * groupEnum = [fJobGroups objectEnumerator];
+    while ( (aJobGroup = [groupEnum nextObject]) )
+    {
+        if ([[aJobGroup destinationPath] isEqualToString: path])
+            return aJobGroup;
+    }
+    return nil;
+}
+
 //------------------------------------------------------------------------------------
 // Locates and returns a HBJob whose sequence_id matches a specified value.
 //------------------------------------------------------------------------------------
@@ -1604,8 +1624,8 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
         while (row != NSNotFound)
         {
             HBJobGroup * jobGroup = [fOutlineView itemAtRow: row];
-            if ([[jobGroup path] length])
-                [[NSWorkspace sharedWorkspace] selectFile:[jobGroup path] inFileViewerRootedAtPath:nil];
+            if ([[jobGroup destinationPath] length])
+                [[NSWorkspace sharedWorkspace] selectFile:[jobGroup destinationPath] inFileViewerRootedAtPath:nil];
         
             row = [selectedRows indexGreaterThanIndex: row];
         }
index 5264013..a62c18d 100644 (file)
                        isa = PBXContainerItemProxy;
                        containerPortal = A9DB3A080D37EC2800F77345 /* libhb.xcodeproj */;
                        proxyType = 2;
-                       remoteGlobalIDString = 0DFF0B720B6BC6E600549488 /* libhb.a */;
+                       remoteGlobalIDString = 0DFF0B720B6BC6E600549488;
                        remoteInfo = libhb;
                };
                A9DB3A100D37EC2800F77345 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = A9DB3A080D37EC2800F77345 /* libhb.xcodeproj */;
                        proxyType = 2;
-                       remoteGlobalIDString = 0D096DFF0B707D1200A845D4 /* libhb.dylib */;
+                       remoteGlobalIDString = 0D096DFF0B707D1200A845D4;
                        remoteInfo = "libhb dlib";
                };
                A9DB3A120D37EC2800F77345 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = A9DB3A080D37EC2800F77345 /* libhb.xcodeproj */;
                        proxyType = 2;
-                       remoteGlobalIDString = A9DB38E00D37E9BA00F77345 /* HB.framework */;
+                       remoteGlobalIDString = A9DB38E00D37E9BA00F77345;
                        remoteInfo = HB;
                };
                A9DB3A140D37EC4200F77345 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = A9DB3A080D37EC2800F77345 /* libhb.xcodeproj */;
                        proxyType = 1;
-                       remoteGlobalIDString = 0DFF0B710B6BC6E600549488 /* libhb */;
+                       remoteGlobalIDString = 0DFF0B710B6BC6E600549488;
                        remoteInfo = libhb;
                };
 /* End PBXContainerItemProxy section */