OSDN Git Service

MacGui: Enhance Growl notifications and send to metaX so that each encode is handled...
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 7 Apr 2008 20:11:46 +0000 (20:11 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 7 Apr 2008 20:11:46 +0000 (20:11 +0000)
- Previously only the last encode of a queue gave the finished growl notification and was sent to metaX. Now if specified by the user they happen as the encodes progress through the queue.

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

macosx/Controller.h
macosx/Controller.mm
macosx/HBQueueController.mm

index a9ed52e..1afd667 100644 (file)
@@ -354,10 +354,10 @@ BOOL                        fIsDragging;
 - (IBAction)deletePreset:(id)sender;
 - (IBAction)getDefaultPresets:(id)sender;
 
-
+-(void)sendToMetaX:(NSString *) filePath;
     // Growl methods
 - (NSDictionary *) registrationDictionaryForGrowl;
--(IBAction)showGrowlDoneNotification:(id)sender;
+-(void)showGrowlDoneNotification:(NSString *) filePath;
 - (IBAction)showDebugOutputPanel:(id)sender;
 - (void)setupToolbar;
 
index 2f7b522..6861655 100644 (file)
@@ -637,14 +637,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             /* Check to see if the encode state has not been cancelled
                                to determine if we should check for encode done notifications */
                        if (fEncodeState != 2)                  {
-                               /* If Growl Notification or Window and Growl has been selected */
-                               if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] || 
-                                       [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
-                {
-                                       /*Growl Notification*/
-                                       [self showGrowlDoneNotification: NULL];
-                }
-                /* If Alert Window or Window and Growl has been selected */
+                               /* If Alert Window or Window and Growl has been selected */
                                if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] || 
                                        [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
                 {
@@ -687,16 +680,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
                [self enableUI: YES]; 
                 }
                        
-                                               // MetaX insertion via AppleScript
-                       if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES)
-                       {
-                       NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@", @"tell application \"MetaX\" to open (POSIX file \"", [fDstFile2Field stringValue], @"\")"]];
-                       [myScript executeAndReturnError: nil];
-                       [myScript release];
-                       }
-                       
-                       
-                       }
+            }
                        else
                        {
                                [self enableUI: YES];
@@ -981,7 +965,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 }
 
 #pragma mark -
-#pragma mark Growl
+#pragma mark Encode Done Actions
 // register a test notification and make
 // it enabled by default
 #define SERVICE_NAME @"Encode Done"
@@ -995,18 +979,37 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     return registrationDictionary; 
 } 
 
--(IBAction)showGrowlDoneNotification:(id)sender
+-(void)showGrowlDoneNotification:(NSString *) filePath
 {
-  [GrowlApplicationBridge 
-            notifyWithTitle:@"Put down that cocktail..." 
-                description:@"your HandBrake encode is done!" 
-           notificationName:SERVICE_NAME
-                   iconData:nil 
-                   priority:0 
-                   isSticky:1 
-               clickContext:nil];
+    /* This is called from HBQueueController as jobs roll off of the queue in currentJobChanged */
+    NSString * finishedEncode = filePath;
+    /* strip off the path to just show the file name */
+    finishedEncode = [finishedEncode lastPathComponent];
+    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] || 
+        [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
+    {
+        NSString * growlMssg = [NSString stringWithFormat: @"your HandBrake encode %@ is done!",finishedEncode];
+        [GrowlApplicationBridge 
+         notifyWithTitle:@"Put down that cocktail..." 
+         description:growlMssg 
+         notificationName:SERVICE_NAME
+         iconData:nil 
+         priority:0 
+         isSticky:1 
+         clickContext:nil];
+    }
+    
+}
+-(void)sendToMetaX:(NSString *) filePath
+{
+    /* This is called from HBQueueController as jobs roll off of the queue in currentJobChanged */
+    if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES)
+    {
+        NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@", @"tell application \"MetaX\" to open (POSIX file \"", filePath, @"\")"]];
+        [myScript executeAndReturnError: nil];
+        [myScript release];
+    }
 }
-
 #pragma mark -
 #pragma mark Get New Source
 
index a024133..3e0668e 100644 (file)
@@ -1473,6 +1473,8 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
         [fProgressBar setIndeterminate:NO];
         [fProgressBar stopAnimation:nil];
         [fProgressBar setDoubleValue:0.0];
+        
+        
     }
     
     else
@@ -1571,9 +1573,12 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
                          withSubtitleInfo: YES]];
         }
     }
-    
     else
+    {
         [fJobDescTextField setStringValue: @"No encodes pending"];
+    
+    }
+    
 }
 
 //------------------------------------------------------------------------------------
@@ -1748,6 +1753,19 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
 //------------------------------------------------------------------------------------
 - (void)currentJobChanged: (HBJob *) currentJob
 {
+    /* if the job has a destination path, lets perform finished job notifications in fHBController 
+     * We call this here so that we pickup the last job in the queue and single encodes before fCurrentJob
+     * is released. So for the first job and the beginning of single encodes we check for the existence
+     * of a valid fCurrentJob jobGroup
+     */
+    if ([[fCurrentJob jobGroup] destinationPath] && [fCurrentJobGroup status] != HBStatusCanceled)
+    {
+        /* Try to send the growl notification destinationPath*/
+        [fHBController showGrowlDoneNotification: [[fCurrentJob jobGroup] destinationPath]];
+        /* Try to send the file to metax*/
+        [fHBController sendToMetaX: [[fCurrentJob jobGroup] destinationPath]];
+    }
+    
     [currentJob retain];
     [fCurrentJob release];
     fCurrentJob = currentJob;
@@ -1770,7 +1788,11 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
             // all other cases are assumed to be a successful encode. BTW, libhb
             // doesn't currently report errors back to the GUI.
             if ([fCurrentJobGroup status] != HBStatusCanceled)
+            {
                 [fCurrentJobGroup setStatus:HBStatusCompleted];
+            }
+            
+            
         }
         
         // Set the new group