Commit 2f57ccdf authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: disable the open button if we don't have a valid MRL

fixes #4679
parent bfe08d36
This source diff could not be displayed because it is too large. You can view the blob instead.
/***************************************************************************** /*****************************************************************************
* open.h: Open dialogues for VLC's MacOS X port * open.h: Open dialogues for VLC's MacOS X port
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2009 the VideoLAN team * Copyright (C) 2002-2011 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -35,7 +35,7 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class ); ...@@ -35,7 +35,7 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class );
IBOutlet id o_panel; IBOutlet id o_panel;
IBOutlet id o_mrl; IBOutlet id o_mrl_fld;
IBOutlet id o_mrl_lbl; IBOutlet id o_mrl_lbl;
IBOutlet id o_mrl_view; IBOutlet id o_mrl_view;
IBOutlet id o_mrl_btn; IBOutlet id o_mrl_btn;
...@@ -162,11 +162,15 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class ); ...@@ -162,11 +162,15 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class );
BOOL b_autoplay; BOOL b_autoplay;
id o_currentCaptureView; id o_currentCaptureView;
NSString *o_file_slave_path; NSString *o_file_slave_path;
NSString *o_mrl;
intf_thread_t * p_intf; intf_thread_t * p_intf;
} }
+ (VLCOpen *)sharedInstance; + (VLCOpen *)sharedInstance;
- (void)setMRL:(NSString *)mrl;
- (NSString *)MRL;
- (void)setSubPanel; - (void)setSubPanel;
- (void)openTarget:(int)i_type; - (void)openTarget:(int)i_type;
- (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi; - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi;
......
...@@ -164,6 +164,7 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -164,6 +164,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
{ {
if( o_file_slave_path ) if( o_file_slave_path )
[o_file_slave_path release]; [o_file_slave_path release];
[o_mrl release];
[super dealloc]; [super dealloc];
} }
...@@ -296,6 +297,25 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -296,6 +297,25 @@ static VLCOpen *_o_sharedMainInstance = nil;
selector: @selector(textFieldWasClicked:) selector: @selector(textFieldWasClicked:)
name: @"VLCOpenTextFieldWasClicked" name: @"VLCOpenTextFieldWasClicked"
object: nil]; object: nil];
[self setMRL: @""];
}
- (void)setMRL:(NSString *)newMRL
{
[o_mrl release];
o_mrl = newMRL;
[o_mrl retain];
[o_mrl_fld setStringValue: newMRL];
if ([o_mrl length] > 0)
[o_btn_ok setEnabled: YES];
else
[o_btn_ok setEnabled: NO];
}
- (NSString *)MRL
{
return o_mrl;
} }
- (void)setSubPanel - (void)setSubPanel
...@@ -383,7 +403,7 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -383,7 +403,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
NSMutableArray *o_options = [NSMutableArray array]; NSMutableArray *o_options = [NSMutableArray array];
unsigned int i; unsigned int i;
o_dic = [NSMutableDictionary dictionaryWithObject: [o_mrl stringValue] forKey: @"ITEM_URL"]; o_dic = [NSMutableDictionary dictionaryWithObject: [self MRL] forKey: @"ITEM_URL"];
if( [o_file_sub_ckbox state] == NSOnState ) if( [o_file_sub_ckbox state] == NSOnState )
{ {
module_config_t * p_item; module_config_t * p_item;
...@@ -556,6 +576,9 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -556,6 +576,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
- (void)openFilePathChanged:(NSNotification *)o_notification - (void)openFilePathChanged:(NSNotification *)o_notification
{ {
NSString *o_filename = [o_file_path stringValue]; NSString *o_filename = [o_file_path stringValue];
if ( o_filename && [o_filename > 0] )
{
bool b_stream = [o_file_stream state]; bool b_stream = [o_file_stream state];
BOOL b_dir = NO; BOOL b_dir = NO;
...@@ -569,14 +592,13 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -569,14 +592,13 @@ static VLCOpen *_o_sharedMainInstance = nil;
free( psz_uri ); free( psz_uri );
if( b_dir ) if( b_dir )
{
[o_mrl_string replaceCharactersInRange:offile withString: @"directory"]; [o_mrl_string replaceCharactersInRange:offile withString: @"directory"];
}
else if( b_stream ) else if( b_stream )
{
[o_mrl_string replaceCharactersInRange:offile withString: @"stream"]; [o_mrl_string replaceCharactersInRange:offile withString: @"stream"];
[self setMRL: o_mrl_string];
} }
[o_mrl setStringValue: o_mrl_string]; [self setMRL: @""];
} }
- (IBAction)openFileBrowse:(id)sender - (IBAction)openFileBrowse:(id)sender
...@@ -751,16 +773,22 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -751,16 +773,22 @@ static VLCOpen *_o_sharedMainInstance = nil;
} }
else /* VIDEO_TS folder */ else /* VIDEO_TS folder */
{
if ([o_videots length] > 0)
{ {
if ( b_no_menus ) if ( b_no_menus )
o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i", o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i", o_videots, i_title, i_chapter];
o_videots, i_title, i_chapter];
else else
o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@", o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@", o_videots];
o_videots]; }
else
o_mrl_string = @"";
} }
[o_mrl setStringValue: o_mrl_string]; if ([o_device length] > 0)
[self setMRL: o_mrl_string];
else
[self setMRL: @""];
} }
- (IBAction)openDiscMenusChanged:(id)sender - (IBAction)openDiscMenusChanged:(id)sender
...@@ -882,7 +910,7 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -882,7 +910,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
{ {
o_mrl_string = [o_net_http_url stringValue]; o_mrl_string = [o_net_http_url stringValue];
} }
[o_mrl setStringValue: o_mrl_string]; [self setMRL: o_mrl_string];
} }
- (IBAction)openNetUDPButtonAction:(id)sender - (IBAction)openNetUDPButtonAction:(id)sender
...@@ -935,7 +963,7 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -935,7 +963,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
[o_mrl_string stringByAppendingFormat: @":%i", i_port]; [o_mrl_string stringByAppendingFormat: @":%i", i_port];
} }
} }
[o_mrl setStringValue: o_mrl_string]; [self setMRL: o_mrl_string];
[o_net_http_url setStringValue: o_mrl_string]; [o_net_http_url setStringValue: o_mrl_string];
[o_net_udp_panel orderOut: sender]; [o_net_udp_panel orderOut: sender];
[NSApp endSheet: o_net_udp_panel]; [NSApp endSheet: o_net_udp_panel];
...@@ -1015,12 +1043,12 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -1015,12 +1043,12 @@ static VLCOpen *_o_sharedMainInstance = nil;
} }
else else
[self showCaptureView: o_eyetv_notLaunched_view]; [self showCaptureView: o_eyetv_notLaunched_view];
[o_mrl setStringValue: @""]; [self setMRL: @""];
} }
else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] ) else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
{ {
[self showCaptureView: o_screen_view]; [self showCaptureView: o_screen_view];
[o_mrl setStringValue: @"screen://"]; [self setMRL: @"screen://"];
[o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )]; [o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )];
[o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )]; [o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )];
[o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )]; [o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )];
...@@ -1036,7 +1064,7 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -1036,7 +1064,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
[o_capture_long_lbl displayIfNeeded]; [o_capture_long_lbl displayIfNeeded];
[self showCaptureView: o_capture_label_view]; [self showCaptureView: o_capture_label_view];
[o_mrl setStringValue: @"qtcapture://"]; [self setMRL: @"qtcapture://"];
} }
} }
...@@ -1044,7 +1072,7 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -1044,7 +1072,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
{ {
[o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]]; [o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]];
[o_panel makeFirstResponder: o_screen_fps_fld]; [o_panel makeFirstResponder: o_screen_fps_fld];
[o_mrl setStringValue: @"screen://"]; [self setMRL: @"screen://"];
} }
- (void)screenFPSfieldChanged:(NSNotification *)o_notification - (void)screenFPSfieldChanged:(NSNotification *)o_notification
...@@ -1052,7 +1080,7 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -1052,7 +1080,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
[o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]]; [o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
if( [[o_screen_fps_fld stringValue] isEqualToString: @""] ) if( [[o_screen_fps_fld stringValue] isEqualToString: @""] )
[o_screen_fps_fld setFloatValue: 1.0]; [o_screen_fps_fld setFloatValue: 1.0];
[o_mrl setStringValue: @"screen://"]; [self setMRL: @"screen://"];
} }
- (IBAction)eyetvSwitchChannel:(id)sender - (IBAction)eyetvSwitchChannel:(id)sender
...@@ -1061,19 +1089,19 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -1061,19 +1089,19 @@ static VLCOpen *_o_sharedMainInstance = nil;
{ {
int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES]; int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES];
[o_eyetv_channels_pop selectItemWithTag:chanNum]; [o_eyetv_channels_pop selectItemWithTag:chanNum];
[o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]]; [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
} }
else if( sender == o_eyetv_previousProgram_btn ) else if( sender == o_eyetv_previousProgram_btn )
{ {
int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO]; int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO];
[o_eyetv_channels_pop selectItemWithTag:chanNum]; [o_eyetv_channels_pop selectItemWithTag:chanNum];
[o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]]; [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
} }
else if( sender == o_eyetv_channels_pop ) else if( sender == o_eyetv_channels_pop )
{ {
int chanNum = [[sender selectedItem] tag]; int chanNum = [[sender selectedItem] tag];
[[[VLCMain sharedInstance] eyeTVController] selectChannel:chanNum]; [[[VLCMain sharedInstance] eyeTVController] selectChannel:chanNum];
[o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]]; [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
} }
else else
msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" ); msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
...@@ -1228,14 +1256,10 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -1228,14 +1256,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
- (IBAction)panelOk:(id)sender - (IBAction)panelOk:(id)sender
{ {
if( [[o_mrl stringValue] length] ) if( [[self MRL] length] )
{
[NSApp stopModalWithCode: 1]; [NSApp stopModalWithCode: 1];
}
else else
{
NSBeep(); NSBeep();
}
} }
@end @end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment