]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/open.m
Qt: messages dialog: new verbosity spinbox
[vlc] / modules / gui / macosx / open.m
index 174c0b4b8c3e64ac33f7345f74d2c01625faf4bd..030742625d8361700ca31708f51b12750bd3ae05 100644 (file)
@@ -45,6 +45,8 @@
 #import "output.h"
 #import "eyetv.h"
 
+#include <vlc_url.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.")]; \
@@ -158,10 +160,17 @@ static VLCOpen *_o_sharedMainInstance = nil;
     return _o_sharedMainInstance;
 }
 
+- (void)dealloc
+{
+    if( o_file_slave_path )
+        [o_file_slave_path release];
+    [super dealloc];
+}
+
 - (void)awakeFromNib
 {
     [o_panel setTitle: _NS("Open Source")];
-    [o_mrl_lbl setTitle: _NS("Media Resource Locator (MRL)")];
+    [o_mrl_lbl setStringValue: _NS("Media Resource Locator (MRL)")];
 
     [o_btn_ok setTitle: _NS("Open")];
     [o_btn_cancel setTitle: _NS("Cancel")];
@@ -173,6 +182,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     [o_file_btn_browse setTitle: _NS("Browse...")];
     [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
+    [o_file_slave_ckbox setTitle: _NS("Play another media synchronously")];
+    [o_file_slave_select_btn setTitle: _NS("Choose...")];
+    [o_file_slave_filename_txt setStringValue: @""];
 
     [o_disc_device_lbl setStringValue: _NS("Device name")];
     [o_disc_title_lbl setStringValue: _NS("Title")];
@@ -189,14 +201,17 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_net_udpm_addr_lbl setStringValue: _NS("IP Address")];
     [o_net_udpm_port_lbl setStringValue: _NS("Port")];
     [o_net_http_url_lbl setStringValue: _NS("URL")];
-    [o_net_help_lbl setStringValue: _NS("To Open a usual network stream (HTTP, RTSP, MMS, FTP, etc.), just enter the URL in the field above. If you want to open a RTP or UDP stream, press the button below.")];
-    [o_net_help_udp_lbl setStringValue: _NS("If you want to open a multicast stream, enter the respective IP address given by the stream provider. In unicast mode, VLC use your machine's IP automatically.\n\nTo open a stream using a different protocol, just press Cancel to close this sheet.")];
+    [o_net_help_lbl setStringValue: _NS("To Open a usual network stream (HTTP, RTSP, RTMP, MMS, FTP, etc.), just enter the URL in the field above. If you want to open a RTP or UDP stream, press the button below.")];
+    [o_net_help_udp_lbl setStringValue: _NS("If you want to open a multicast stream, enter the respective IP address given by the stream provider. In unicast mode, VLC will use your machine's IP automatically.\n\nTo open a stream using a different protocol, just press Cancel to close this sheet.")];
     [o_net_udp_cancel_btn setTitle: _NS("Cancel")];
     [o_net_udp_ok_btn setTitle: _NS("Open")];
     [o_net_openUDP_btn setTitle: _NS("Open RTP/UDP Stream")];
+    [o_net_udp_mode_lbl setStringValue: _NS("Mode")];
+    [o_net_udp_protocol_lbl setStringValue: _NS("Protocol")];
+    [o_net_udp_address_lbl setStringValue: _NS("Address")];
 
-    [[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:0 column:0] setTitle: _NS("Unicast")];
+    [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("Multicast")];
 
     [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
     [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
@@ -214,6 +229,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [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_screen_follow_mouse_ckb setTitle: _NS("Follow the mouse")];
     [o_eyetv_currentChannel_lbl setStringValue: _NS("Current channel:")];
     [o_eyetv_previousProgram_btn setTitle: _NS("Previous Channel")];
     [o_eyetv_nextProgram_btn setTitle: _NS("Next Channel")];
@@ -397,12 +413,14 @@ static VLCOpen *_o_sharedMainInstance = nil;
         }
         if( [o_output_ckbox state] == NSOnState )
         {
-            for (i = 0 ; i < [[o_sout_options getMRL] count] ; i++)
+            for (i = 0 ; i < [[o_sout_options mrl] count] ; i++)
             {
                 [o_options addObject: [NSString stringWithString:
-                      [[(VLCOutput *)o_sout_options getMRL] objectAtIndex: i]]];
+                      [[(VLCOutput *)o_sout_options mrl] objectAtIndex: i]]];
             }
         }
+        if( [o_file_slave_ckbox state] && o_file_slave_path )
+           [o_options addObject: [NSString stringWithFormat: @"input-slave=%@", o_file_slave_path]];
         if( [[[o_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")] )
         {
             if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
@@ -448,6 +466,67 @@ static VLCOpen *_o_sharedMainInstance = nil;
     }
 }
 
+- (IBAction)expandMRLfieldAction:(id)sender
+{
+    NSRect o_win_rect, o_view_rect;
+    o_win_rect = [o_panel frame];
+    o_view_rect = [o_mrl_view frame];
+
+    if( [o_mrl_btn state] == NSOffState )
+    {
+        /* we need to collaps, restore the panel size */
+        o_win_rect.size.height = o_win_rect.size.height - o_view_rect.size.height;
+        o_win_rect.origin.y = ( o_win_rect.origin.y + o_view_rect.size.height ) - o_view_rect.size.height;
+
+        /* remove the MRL view */
+        [o_mrl_view removeFromSuperviewWithoutNeedingDisplay];
+    } else {
+        /* we need to expand */
+        [o_mrl_view setFrame: NSMakeRect( 0,
+                                         [o_mrl_btn frame].origin.y,
+                                         o_view_rect.size.width,
+                                         o_view_rect.size.height )];
+        [o_mrl_view setNeedsDisplay: YES];
+        [o_mrl_view setAutoresizesSubviews: YES];
+
+        /* add the MRL view */
+        [[o_panel contentView] addSubview: o_mrl_view];
+        o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
+    }
+
+    [o_panel setFrame: o_win_rect display:YES animate: YES];
+    [o_panel displayIfNeeded];
+}
+
+- (IBAction)inputSlaveAction:(id)sender
+{
+    if( sender == o_file_slave_ckbox )
+        [o_file_slave_select_btn setEnabled: [o_file_slave_ckbox state]];
+    else
+    {
+        NSOpenPanel *o_open_panel;
+        o_open_panel = [NSOpenPanel openPanel];
+        [o_open_panel setCanChooseFiles: YES];
+        [o_open_panel setCanChooseDirectories: NO];
+        if( [o_open_panel runModalForDirectory: nil file: nil types: nil] == NSOKButton )
+        {
+            if( o_file_slave_path )
+                [o_file_slave_path release];
+            o_file_slave_path = [[o_open_panel filenames] objectAtIndex: 0];
+            [o_file_slave_path retain];
+        }
+        else
+            [o_file_slave_filename_txt setStringValue: @""];
+    }
+    if( o_file_slave_path )
+    {
+        NSFileWrapper *o_file_wrapper;
+        o_file_wrapper = [[NSFileWrapper alloc] initWithPath: o_file_slave_path];
+        [o_file_slave_filename_txt setStringValue: [NSString stringWithFormat: @"\"%@\"", [o_file_wrapper preferredFilename]]];
+        [o_file_wrapper release];
+    }
+}
+
 - (void)openFileGeneric
 {
     [self openFilePathChanged: nil];
@@ -475,30 +554,26 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (void)openFilePathChanged:(NSNotification *)o_notification
 {
-    NSString *o_mrl_string;
     NSString *o_filename = [o_file_path stringValue];
-    NSString *o_ext = [o_filename pathExtension];
     bool b_stream = [o_file_stream state];
     BOOL b_dir = NO;
+
     [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
 
+    char *psz_uri = make_URI([o_filename UTF8String], "file");
+    if( !psz_uri ) return;
+
+    NSMutableString *o_mrl_string = [NSMutableString stringWithUTF8String: psz_uri ];
+    NSRange offile = [o_mrl_string rangeOfString:@"file"];
+    free( psz_uri );
+
     if( b_dir )
     {
-        o_mrl_string = [NSString stringWithFormat: @"directory://%@/", o_filename];
+        [o_mrl_string replaceCharactersInRange:offile withString: @"directory"];
     }
-    else if( [o_ext isEqualToString: @"bin"] ||
-        [o_ext isEqualToString: @"cue"] ||
-        [o_ext isEqualToString: @"vob"] ||
-        [o_ext isEqualToString: @"iso"] )
+    else if( b_stream )
     {
-        o_mrl_string = o_filename;
-    }
-    else
-    {
-        o_mrl_string = [NSString stringWithFormat: @"%s://%@",
-                        b_stream ? "stream" : "file",
-                        o_filename];
+        [o_mrl_string replaceCharactersInRange:offile withString: @"stream"];
     }
     [o_mrl setStringValue: o_mrl_string];
 }
@@ -548,7 +623,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
  
     o_type = [[o_disc_type selectedCell] title];
 
-    if ( [o_type isEqualToString: _NS("VIDEO_TS directory")] )
+    if ( [o_type isEqualToString: _NS("VIDEO_TS folder")] )
     {
         b_device = NO; b_no_menus = YES;
     }
@@ -727,13 +802,15 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (IBAction)openNetModeChanged:(id)sender
 {
-    if( [[sender selectedCell] tag] == 0 )
-        [o_panel makeFirstResponder: o_net_udp_port];
-    else if ( [[sender selectedCell] tag] == 1 )
-        [o_panel makeFirstResponder: o_net_udpm_addr];
-    else
-        msg_Warn( p_intf, "Unknown sender tried to change UDP/RTP mode" );
-
+    if( sender == o_net_mode )
+    {
+        if( [[sender selectedCell] tag] == 0 )
+            [o_panel makeFirstResponder: o_net_udp_port];
+        else if ( [[sender selectedCell] tag] == 1 )
+            [o_panel makeFirstResponder: o_net_udpm_addr];
+        else
+            msg_Warn( p_intf, "Unknown sender tried to change UDP/RTP mode" );
+    }
 
     [self openNetInfoChanged: nil];
 }
@@ -769,11 +846,14 @@ static VLCOpen *_o_sharedMainInstance = nil;
         NSString *o_mode;
         o_mode = [[o_net_mode selectedCell] title];
 
-        if( [o_mode isEqualToString: _NS("UDP/RTP")] )
+        if( [o_mode isEqualToString: _NS("Unicast")] )
         {
             int i_port = [o_net_udp_port intValue];
 
-            o_mrl_string = [NSString stringWithString: @"udp://"];
+            if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
+                o_mrl_string = [NSString stringWithString: @"udp://"];
+            else
+                o_mrl_string = [NSString stringWithString: @"rtp://"];
 
             if( i_port != config_GetInt( p_intf, "server-port" ) )
             {
@@ -781,12 +861,15 @@ static VLCOpen *_o_sharedMainInstance = nil;
                     [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
             }
         }
-        else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] )
+        else if( [o_mode isEqualToString: _NS("Multicast")] )
         {
             NSString *o_addr = [o_net_udpm_addr stringValue];
             int i_port = [o_net_udpm_port intValue];
 
-            o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
+            if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
+                o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
+            else
+                o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
 
             if( i_port != config_GetInt( p_intf, "server-port" ) )
             {
@@ -797,13 +880,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     }
     else
     {
-        NSString *o_url = [o_net_http_url stringValue];
-
-        if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
-              && ![o_url hasPrefix:@"mms"] && ![o_url hasPrefix:@"rtsp"] )
-            o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
-        else
-            o_mrl_string = o_url;
+        o_mrl_string = [o_net_http_url stringValue];
     }
     [o_mrl setStringValue: o_mrl_string];
 }
@@ -817,6 +894,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
             modalDelegate: self
            didEndSelector: NULL
               contextInfo: nil];
+        [self openNetInfoChanged: nil];
     }
     else if( sender == o_net_udp_cancel_btn )
     {
@@ -826,25 +904,31 @@ static VLCOpen *_o_sharedMainInstance = nil;
     else if( sender == o_net_udp_ok_btn )
     {
         NSString *o_mrl_string = [NSString string];
-        if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("UDP/RTP")] )
+        if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Unicast")] )
         {
             int i_port = [o_net_udp_port intValue];
             
-            o_mrl_string = [NSString stringWithString: @"udp://"];
-            
+            if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
+                o_mrl_string = [NSString stringWithString: @"udp://"];
+            else
+                o_mrl_string = [NSString stringWithString: @"rtp://"];
+
             if( i_port != config_GetInt( p_intf, "server-port" ) )
             {
                 o_mrl_string =
                 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
             }
         }
-        else if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("UDP/RTP Multicast")] )
+        else if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Multicast")] )
         {
             NSString *o_addr = [o_net_udpm_addr stringValue];
             int i_port = [o_net_udpm_port intValue];
             
-            o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
-            
+            if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
+                o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
+            else
+                o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
+
             if( i_port != config_GetInt( p_intf, "server-port" ) )
             {
                 o_mrl_string =
@@ -852,6 +936,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
             }
         }
         [o_mrl setStringValue: o_mrl_string];
+        [o_net_http_url setStringValue: o_mrl_string];
         [o_net_udp_panel orderOut: sender];
         [NSApp endSheet: o_net_udp_panel];
     }
@@ -878,7 +963,14 @@ static VLCOpen *_o_sharedMainInstance = nil;
         for( i = 0; i < (int)[o_values count]; i++)
         {
             NSDictionary *o_dic;
-            o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
+            char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], "file");
+            if( !psz_uri )
+                continue;
+
+            o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
+
+            free( psz_uri );
+
             o_array = [o_array arrayByAddingObject: o_dic];
         }
         if( b_autoplay )
@@ -910,9 +1002,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
 {
     if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"EyeTV"] )
     {
-        if( [[[VLCMain sharedInstance] getEyeTVController] isEyeTVrunning] == YES )
+        if( [[[VLCMain sharedInstance] eyeTVController] isEyeTVrunning] == YES )
         {
-            if( [[[VLCMain sharedInstance] getEyeTVController] isDeviceConnected] == YES )
+            if( [[[VLCMain sharedInstance] eyeTVController] isDeviceConnected] == YES )
             {
                 [self showCaptureView: o_eyetv_running_view];
                 [self setupChannelInfo];
@@ -968,20 +1060,20 @@ static VLCOpen *_o_sharedMainInstance = nil;
 {
     if( sender == o_eyetv_nextProgram_btn )
     {
-        int chanNum = [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: YES];
+        int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES];
         [o_eyetv_channels_pop selectItemWithTag:chanNum];
         [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
     }
     else if( sender == o_eyetv_previousProgram_btn )
     {
-        int chanNum = [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: NO];
+        int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO];
         [o_eyetv_channels_pop selectItemWithTag:chanNum];
         [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
     }
     else if( sender == o_eyetv_channels_pop )
     {
         int chanNum = [[sender selectedItem] tag];
-        [[[VLCMain sharedInstance] getEyeTVController] selectChannel:chanNum];
+        [[[VLCMain sharedInstance] eyeTVController] selectChannel:chanNum];
         [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
     }
     else
@@ -990,7 +1082,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (IBAction)eyetvLaunch:(id)sender
 {
-    [[[VLCMain sharedInstance] getEyeTVController] launchEyeTV];
+    [[[VLCMain sharedInstance] eyeTVController] launchEyeTV];
 }
 
 - (IBAction)eyetvGetPlugin:(id)sender
@@ -1040,7 +1132,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_eyetv_chn_status_txt setHidden: NO];
  
     /* retrieve info */
-    NSEnumerator *channels = [[[VLCMain sharedInstance] getEyeTVController] allChannels];
+    NSEnumerator *channels = [[[VLCMain sharedInstance] eyeTVController] allChannels];
     int x = -2;
     [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("Composite input")
                                                action: nil
@@ -1061,7 +1153,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
                                             keyEquivalent: @""] setTag:++x];
         }
         /* make Tuner the default */
-        [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] getEyeTVController] currentChannel]];
+        [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] eyeTVController] currentChannel]];
     }
  
     /* clean up GUI */