OSDN Git Service

MacGui: Store live previews in a sub directory in "~/Library/Application Support...
[handbrake-jp/handbrake-jp-git.git] / macosx / HBPreviewController.m
index 2f6e981..c0db129 100644 (file)
     [fMovieTimer release];
     [fMovieView setHidden:YES];
        [fMovieView setMovie:nil];
-    [self pictureSliderChanged:nil];
 
     hudTimerSeconds = 0;
     [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PreviewWindowIsOpen"];
 }
 
 #pragma mark Hud Control Overlay
+/* enableHudControls and disableHudControls are used to sync enableUI
+ * in HBController so that during a scan we do not attempt to access source
+ * images, etc. which can cause a crash. In general this ui behavior will mirror
+ * the main window ui's enableUI method and in fact is called from there */
+- (void) enableHudControls
+{
+    [fPictureSlider setEnabled:YES];
+    [fScaleToScreenToggleButton setEnabled:YES];
+    [fCreatePreviewMovieButton setEnabled:YES];
+    [fGoToStillPreviewButton setEnabled:YES];
+    [fHBController writeToActivityLog: "Preview: Enabling HUD Controls"];
+}
+
+- (void) disableHudControls
+{
+    [fPictureSlider setEnabled:NO];
+    [fScaleToScreenToggleButton setEnabled:NO];
+    [fCreatePreviewMovieButton setEnabled:NO];
+    [fGoToStillPreviewButton setEnabled:NO];
+    [fHBController writeToActivityLog: "Preview: Disabling HUD Controls"];
+}
+
 - (void) mouseMoved:(NSEvent *)theEvent
 {
     [super mouseMoved:theEvent];
     
     [fHBController prepareJobForPreview];
     
+    /* Make sure we have a Preview sub directory with our pidnum attached */
+    NSString *PreviewDirectory = [NSString stringWithFormat:@"~/Library/Application Support/HandBrake/Previews/%d", [fHBController getPidnum]];
+    PreviewDirectory = [PreviewDirectory stringByExpandingTildeInPath];
+    if( ![[NSFileManager defaultManager] fileExistsAtPath:PreviewDirectory] )
+    {
+        [[NSFileManager defaultManager] createDirectoryAtPath:PreviewDirectory 
+                                  withIntermediateDirectories:NO 
+                                                   attributes:nil 
+                                                        error:nil];
+    }
     /* Destination file. We set this to our preview directory
      * changing the extension appropriately.*/
     if (fTitle->job->mux == HB_MUX_MP4) // MP4 file
     {
         /* we use .m4v for our mp4 files so that ac3 and chapters in mp4 will play properly */
-        fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.m4v";
+        fPreviewMoviePath = [PreviewDirectory stringByAppendingString:@"/preview_temp.m4v"];
     }
     else if (fTitle->job->mux == HB_MUX_MKV) // MKV file
     {
-        fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.mkv";
-    }
-    else if (fTitle->job->mux == HB_MUX_AVI) // AVI file
-    {
-        fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.avi";
-    }
-    else if (fTitle->job->mux == HB_MUX_OGM) // OGM file
-    {
-        fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.ogm";
+        fPreviewMoviePath = [PreviewDirectory stringByAppendingString:@"/preview_temp.mkv"];
     }
     
     fPreviewMoviePath = [[fPreviewMoviePath stringByExpandingTildeInPath]retain];
     
+    [fHBController writeToActivityLog: "Movie Preview path attempt: %s",[fPreviewMoviePath UTF8String] ];
+    
+    
     /* See if there is an existing preview file, if so, delete it */
     if( ![[NSFileManager defaultManager] fileExistsAtPath:fPreviewMoviePath] )
     {