OSDN Git Service

MacGui: Add warning if "Sleep" or "Shutdown" is going to occur after encoding is...
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 12 Sep 2007 14:27:25 +0000 (14:27 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 12 Sep 2007 14:27:25 +0000 (14:27 +0000)
- Thanks hawkman!

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

macosx/Controller.h
macosx/Controller.mm

index 18d4681..560f4e9 100644 (file)
 -(IBAction)showGrowlDoneNotification:(id)sender;
 - (IBAction)showDebugOutputPanel:(id)sender;
 - (void)setupToolbar;
+
+- (void) remindUserOfSleepOrShutdown;
 @end
 
index 2323029..b439348 100644 (file)
@@ -793,6 +793,9 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
                 frame.origin.y -= 36;
                 [fWindow setFrame:frame display:YES animate:YES];
                 fRipIndicatorShown = YES;
+                /* We check to see if we need to warn the user that the computer will go to sleep
+                   or shut down when encoding is finished */
+                [self remindUserOfSleepOrShutdown];
             }
 
             /* Update dock icon */
@@ -1788,6 +1791,36 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     [NSApp terminate: self];
 }
 
+- (void) remindUserOfSleepOrShutdown
+{
+       if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"])
+       {
+               /*Warn that computer will sleep after encoding*/
+               int reminduser;
+               NSBeep();
+               reminduser = NSRunAlertPanel(@"The computer will sleep after encoding is done.",@"You have selected to sleep the computer after encoding. To turn off sleeping, go to the HandBrake preferences.", @"OK", @"Preferences...", nil);
+               [NSApp requestUserAttention:NSCriticalRequest];
+               if ( reminduser == NSAlertAlternateReturn ) 
+               {
+                       [self showPreferencesWindow:NULL];
+               }
+       } 
+       else if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"])
+       {
+               /*Warn that computer will shut down after encoding*/
+               int reminduser;
+               NSBeep();
+               reminduser = NSRunAlertPanel(@"The computer will shut down after encoding is done.",@"You have selected to shut down the computer after encoding. To turn off shut down, go to the HandBrake preferences.", @"OK", @"Preferences...", nil);
+               [NSApp requestUserAttention:NSCriticalRequest];
+               if ( reminduser == NSAlertAlternateReturn ) 
+               {
+                       [self showPreferencesWindow:NULL];
+               }
+       }
+
+}
+
+
 - (void) doRip
 {
     /* Let libhb do the job */