]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/open.m
Remove access-filter timeshift from OSX open dialog.
[vlc] / modules / gui / macosx / open.m
index c5c47bc1be79c0df73ecb592fcdbfbf01171dbfc..617e3775cd25ebb9c1ca8c3abac29b1ecb49d5e5 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * open.m: MacOS X module for vlc
  *****************************************************************************
- * Copyright (C) 2002-2007 the VideoLAN team
+ * Copyright (C) 2002-2008 the VideoLAN team
  * $Id$
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
 #import "output.h"
 #import "eyetv.h"
 
+#define setEyeTVUnconnected \
+[o_capture_lbl setStringValue: _NS("No device connected")]; \
+[o_capture_long_lbl setStringValue: _NS("VLC could not detect any EyeTV compatible device.\n\nCheck the device's connection, make sure that the latest EyeTV software is installed and try again.")]; \
+[o_capture_lbl displayIfNeeded]; \
+[o_capture_long_lbl displayIfNeeded]; \
+[self showCaptureView: o_capture_label_view]
+
+
 /*****************************************************************************
  * GetEjectableMediaOfClass
  *****************************************************************************/
@@ -144,6 +152,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
         [self dealloc];
     } else {
         _o_sharedMainInstance = [super init];
+        p_intf = VLCIntf;
     }
  
     return _o_sharedMainInstance;
@@ -151,8 +160,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (void)awakeFromNib
 {
-    intf_thread_t * p_intf = VLCIntf;
-
     [o_panel setTitle: _NS("Open Source")];
     [o_mrl_lbl setTitle: _NS("Media Resource Locator (MRL)")];
 
@@ -162,6 +169,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
     [[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
     [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
+    [[o_tabview tabViewItemAtIndex: 3] setLabel: _NS("Capture")];
 
     [o_file_btn_browse setTitle: _NS("Browse...")];
     [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
@@ -185,16 +193,34 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [[o_net_mode cellAtRow:0 column:0] setTitle: _NS("UDP/RTP")];
     [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("UDP/RTP Multicast")];
     [[o_net_mode cellAtRow:2 column:0] setTitle: _NS("HTTP/FTP/MMS/RTSP")];
-    [o_net_timeshift_ckbox setTitle: _NS("Allow timeshifting")];
 
     [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
     [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
+
     [o_eyetv_chn_bgbar setUsesThreadedAnimation: YES];
-    /* FIXME: implement EyeTV l10n here */
-    [self setSubPanel];
 
+    [o_capture_mode_pop removeAllItems];
+    if( MACOS_VERSION > 10.4f )
+        [o_capture_mode_pop addItemWithTitle: @"iSight"];
+    [o_capture_mode_pop addItemWithTitle: _NS("Screen")];
+    [o_capture_mode_pop addItemWithTitle: @"EyeTV"];
+    [o_screen_lbl setStringValue: _NS("Screen Capture Input")];
+    [o_screen_long_lbl setStringValue: _NS("This facility allows you to process your screen's output.")];
+    [o_screen_fps_lbl setStringValue: _NS("Frames per Second:")];
+    [o_screen_left_lbl setStringValue: _NS("Subscreen left:")];
+    [o_screen_top_lbl setStringValue: _NS("Subscreen top:")];
+    [o_screen_width_lbl setStringValue: _NS("Subscreen width:")];
+    [o_screen_height_lbl setStringValue: _NS("Subscreen height:")];
+    [o_eyetv_currentChannel_lbl setStringValue: _NS("Current channel:")];
+    [o_eyetv_previousProgram_btn setTitle: _NS("Previous Channel")];
+    [o_eyetv_nextProgram_btn setTitle: _NS("Next Channel")];
+    [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
+    [o_eyetv_noInstance_lbl setStringValue: _NS("EyeTV is not launched")];
+    [o_eyetv_noInstanceLong_lbl setStringValue: _NS("VLC could not connect to EyeTV.\nMake sure that you installed VLC's EyeTV plugin.")];
+    [o_eyetv_launchEyeTV_btn setTitle: _NS("Launch EyeTV now")];
+    [o_eyetv_getPlugin_btn setTitle: _NS("Download Plugin")];
+
+    [self setSubPanel];
 
     [[NSNotificationCenter defaultCenter] addObserver: self
         selector: @selector(openFilePathChanged:)
@@ -235,26 +261,17 @@ static VLCOpen *_o_sharedMainInstance = nil;
         name: NSControlTextDidChangeNotification
         object: o_net_http_url];
 
-    /* wake up with the correct EyeTV GUI */
-    if( [[[VLCMain sharedInstance] getEyeTVController] isEyeTVrunning] == YES )
-    {
-        if( [[[VLCMain sharedInstance] getEyeTVController] isDeviceConnected] == YES )
-        {
-            [o_eyetv_tabView selectTabViewItemWithIdentifier:@"eyetvup"];
-            [self setupChannelInfo];
-        }
-        else 
-            [o_eyetv_tabView selectTabViewItemWithIdentifier:@"nodevice"];
-    }
-    else
-        [o_eyetv_tabView selectTabViewItemWithIdentifier:@"noeyetv"];
-
     [[NSDistributedNotificationCenter defaultCenter] addObserver: self
                                                         selector: @selector(eyetvChanged:)
                                                             name: NULL
                                                           object: @"VLCEyeTVSupport"
                                               suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately];
+
+    [[NSNotificationCenter defaultCenter] addObserver: self
+                                             selector: @selector(screenFPSfieldChanged:)
+                                                 name: NSControlTextDidChangeNotification
+                                               object: o_screen_fps_fld];
+
     /* register clicks on text fields */
     [[NSNotificationCenter defaultCenter] addObserver: self
                                              selector: @selector(textFieldWasClicked:)
@@ -264,7 +281,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (void)setSubPanel
 {
-    intf_thread_t * p_intf = VLCIntf;
     int i_index;
     module_config_t * p_item;
 
@@ -333,7 +349,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
 - (void)openTarget:(int)i_type
 {
     int i_result;
-    intf_thread_t * p_intf = VLCIntf;
 
     b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
 
@@ -385,11 +400,21 @@ static VLCOpen *_o_sharedMainInstance = nil;
                       [[(VLCOutput *)o_sout_options getMRL] objectAtIndex: i]]];
             }
         }
-        if( [o_net_timeshift_ckbox state] == NSOnState )
+        if( [[[o_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")] )
         {
-            [o_options addObject: [NSString stringWithString:
-                                                @"access-filter=timeshift"]];
+            if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
+                [o_options addObject: [NSString stringWithFormat: @"screen-fps=%f", [o_screen_fps_fld floatValue]]];
+                [o_options addObject: [NSString stringWithFormat: @"screen-left=%i", [o_screen_left_fld intValue]]];
+                [o_options addObject: [NSString stringWithFormat: @"screen-top=%i", [o_screen_top_fld intValue]]];
+                [o_options addObject: [NSString stringWithFormat: @"screen-width=%i", [o_screen_width_fld intValue]]];
+                [o_options addObject: [NSString stringWithFormat: @"screen-height=%i", [o_screen_height_fld intValue]]];
+                if( [o_screen_follow_mouse_ckb intValue] == YES )
+                    [o_options addObject: @"screen-follow-mouse"];
+                else
+                    [o_options addObject: @"no-screen-follow-mouse"];
         }
+
+        /* apply the options to our item(s) */
         [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
         if( b_autoplay )
             [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
@@ -414,9 +439,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
     {
         [self openNetInfoChanged: nil];
     }
-    else if( [o_label isEqualToString: _NS("EyeTV")] )
+    else if( [o_label isEqualToString: _NS("Capture")] )
     {
-        [o_mrl setStringValue: @"eyetv://"];
+        [self openCaptureModeChanged: nil];
     }
 }
 
@@ -438,6 +463,13 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [self openTarget: 2];
 }
 
+- (void)openCapture
+{
+    [self openCaptureModeChanged: nil];
+    [self showCaptureView: o_capture_label_view];
+    [self openTarget: 3];
+}
+
 - (void)openFilePathChanged:(NSNotification *)o_notification
 {
     NSString *o_mrl_string;
@@ -450,7 +482,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     if( b_dir )
     {
-        o_mrl_string = [NSString stringWithFormat: @"dir:%@", o_filename];
+        o_mrl_string = [NSString stringWithFormat: @"directory://%@/", o_filename];
     }
     else if( [o_ext isEqualToString: @"bin"] ||
         [o_ext isEqualToString: @"cue"] ||
@@ -728,7 +760,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
 {
     NSString *o_mode;
     NSString *o_mrl_string = [NSString string];
-    intf_thread_t * p_intf = VLCIntf;
 
     o_mode = [[o_net_mode selectedCell] title];
 
@@ -801,6 +832,82 @@ static VLCOpen *_o_sharedMainInstance = nil;
     }
 }
 
+- (void)showCaptureView: theView
+{
+    NSRect o_view_rect;
+    o_view_rect = [theView frame];
+    if( o_currentCaptureView )
+    {
+        [o_currentCaptureView removeFromSuperviewWithoutNeedingDisplay];
+        [o_currentCaptureView release];
+    }
+    [theView setFrame: NSMakeRect( 0, -10, o_view_rect.size.width, o_view_rect.size.height)];
+    [theView setNeedsDisplay: YES];
+    [theView setAutoresizesSubviews: YES];
+    [[[o_tabview tabViewItemAtIndex: 3] view] addSubview: theView];
+    [theView displayIfNeeded];
+    o_currentCaptureView = theView;
+    [o_currentCaptureView retain];
+}
+
+- (IBAction)openCaptureModeChanged:(id)sender
+{
+    if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"EyeTV"] )
+    {
+        if( [[[VLCMain sharedInstance] getEyeTVController] isEyeTVrunning] == YES )
+        {
+            if( [[[VLCMain sharedInstance] getEyeTVController] isDeviceConnected] == YES )
+            {
+                [self showCaptureView: o_eyetv_running_view];
+                [self setupChannelInfo];
+            }
+            else
+            {
+                setEyeTVUnconnected;
+            }
+        }
+        else
+            [self showCaptureView: o_eyetv_notLaunched_view];
+        [o_mrl setStringValue: @""];
+    } 
+    else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
+    {
+        [self showCaptureView: o_screen_view];
+        [o_mrl setStringValue: @"screen://"];
+        [o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )];
+        [o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )];
+        [o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )];
+        [o_screen_left_fld setIntValue: config_GetInt( p_intf, "screen-left" )];
+        [o_screen_top_fld setIntValue: config_GetInt( p_intf, "screen-top" )];
+        [o_screen_follow_mouse_ckb setIntValue: config_GetInt( p_intf, "screen-follow-mouse" )];
+    }
+    else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"iSight"] )
+    {
+        [o_capture_lbl setStringValue: _NS("iSight Capture Input")];
+        [o_capture_long_lbl setStringValue: _NS("This facility allows you to process your iSight's input signal.\n\nNo settings are available in this version, so you will be provided a 640px*480px raw video stream.\n\nLive Audio input is not supported.")];
+        [o_capture_lbl displayIfNeeded];
+        [o_capture_long_lbl displayIfNeeded];
+        
+        [self showCaptureView: o_capture_label_view];
+        [o_mrl setStringValue: @"qtcapture://"];
+    }
+}
+
+- (IBAction)screenStepperChanged:(id)sender
+{
+    [o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]];
+    [o_panel makeFirstResponder: o_screen_fps_fld];
+    [o_mrl setStringValue: @"screen://"];
+}
+
+- (void)screenFPSfieldChanged:(NSNotification *)o_notification
+{
+    [o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
+    if( [[o_screen_fps_fld stringValue] isEqualToString: @""] )
+        [o_screen_fps_fld setFloatValue: 1.0];
+    [o_mrl setStringValue: @"screen://"];
+}
+
 - (IBAction)eyetvSwitchChannel:(id)sender
 {
     if( sender == o_eyetv_nextProgram_btn )
@@ -830,12 +937,17 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [[[VLCMain sharedInstance] getEyeTVController] launchEyeTV];
 }
 
+- (IBAction)eyetvGetPlugin:(id)sender
+{
+    [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: @"http://www.videolan.org/vlc/eyetv"]];
+}
+
 - (void)eyetvChanged:(NSNotification *)o_notification
 {
     if( [[o_notification name] isEqualToString: @"DeviceAdded"] )
     {
         msg_Dbg( VLCIntf, "eyetv device was added" );
-        [o_eyetv_tabView selectTabViewItemWithIdentifier:@"eyetvup"];
+        [self showCaptureView: o_eyetv_running_view];
         [self setupChannelInfo];
     }
     else if( [[o_notification name] isEqualToString: @"DeviceRemoved"] )
@@ -843,23 +955,23 @@ static VLCOpen *_o_sharedMainInstance = nil;
         /* leave the channel selection like that,
          * switch to our "no device" tab */
         msg_Dbg( VLCIntf, "eyetv device was removed" );
-        [o_eyetv_tabView selectTabViewItemWithIdentifier:@"nodevice"];
+        setEyeTVUnconnected;
     }
     else if( [[o_notification name] isEqualToString: @"PluginQuit"] )
     {
         /* switch to the "launch eyetv" tab */
         msg_Dbg( VLCIntf, "eyetv was terminated" );
-        [o_eyetv_tabView selectTabViewItemWithIdentifier:@"noeyetv"];
+        [self showCaptureView: o_eyetv_notLaunched_view];
     }
     else if( [[o_notification name] isEqualToString: @"PluginInit"] )
     {
         /* we got no device yet */
         msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
-        [o_eyetv_tabView selectTabViewItemWithIdentifier:@"nodevice"];
+        setEyeTVUnconnected;
     }
     else
         msg_Warn( VLCIntf, "unknown external notify '%s' received", [[o_notification name] UTF8String] );
-}
+}    
 
 /* little helper method, since this code needs to be run by multiple objects */
 - (void)setupChannelInfo