]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/open.m
macosx: implemented on-the-fly activation of the Media Key support
[vlc] / modules / gui / macosx / open.m
index 174c0b4b8c3e64ac33f7345f74d2c01625faf4bd..ea01ab83d382363cc7575443ba4fb9b179b6fd60 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.")]; \
@@ -161,7 +163,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
 - (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")];
@@ -190,13 +192,16 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [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_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 +219,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,10 +403,10 @@ 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_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")] )
@@ -448,6 +454,38 @@ 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];
+}
+
 - (void)openFileGeneric
 {
     [self openFilePathChanged: nil];
@@ -475,30 +513,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]);
+    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 +582,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 +761,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 +805,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 +820,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" ) )
             {
@@ -817,6 +859,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 +869,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 +901,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];
     }
@@ -910,9 +960,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 +1018,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 +1040,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (IBAction)eyetvLaunch:(id)sender
 {
-    [[[VLCMain sharedInstance] getEyeTVController] launchEyeTV];
+    [[[VLCMain sharedInstance] eyeTVController] launchEyeTV];
 }
 
 - (IBAction)eyetvGetPlugin:(id)sender
@@ -1040,7 +1090,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 +1111,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 */