vlc/vlc-2.0 | branch: master | David Fuhrmann <[email protected]> | Mon Jun 11 18:08:33 2012 +0200| [c67061862d6747cf34298d991a3dcc6e7732e249] | committer: David Fuhrmann
macosx: add multiple files dragged to dock icon together close #4358 (cherry picked from commit 13e2c3bdfba86c9a1400deb9b14e201bbb40ec9e) (cherry picked from commit cfaaf916909b5483d6128cd6cd9b36deb72779df) (cherry picked from commit a89495bbddc454522e777a2f8abf2cb90424787a) Signed-off-by: David Fuhrmann <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=c67061862d6747cf34298d991a3dcc6e7732e249 --- modules/gui/macosx/intf.h | 2 +- modules/gui/macosx/intf.m | 49 +++++++++++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index b1ec6c0..eff1f78 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -196,7 +196,7 @@ struct intf_sys_t - (void)showFullscreenController; - (void)updateDelays; - (void)initStrings; -- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename; +- (BOOL)application:(NSApplication *)o_app openFiles:(NSString *)o_filename; - (IBAction)crashReporterAction:(id)sender; - (IBAction)openCrashLog:(id)sender; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index f0470d9..9df99fc 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -900,39 +900,48 @@ static VLCMain *_o_sharedMainInstance = nil; } #pragma mark - -#pragma mark File opening +#pragma mark File opening over dock icon -- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename +- (BOOL)application:(NSApplication *)o_app openFiles:(NSArray *)o_names { BOOL b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" ); - char *psz_uri = make_URI([o_filename UTF8String], "file" ); - if( !psz_uri ) - return( FALSE ); + char *psz_uri = make_URI([[o_names objectAtIndex:0] UTF8String], "file" ); - input_thread_t * p_input = pl_CurrentInput( VLCIntf ); - BOOL b_returned = NO; - - if (p_input) + // try to add file as subtitle + if( [o_names count] == 1 && psz_uri ) { - b_returned = input_AddSubtitle( p_input, psz_uri, true ); - vlc_object_release( p_input ); - if(!b_returned) + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); + if( p_input ) { - free( psz_uri ); - return YES; + BOOL b_returned = NO; + b_returned = input_AddSubtitle( p_input, psz_uri, true ); + vlc_object_release( p_input ); + if( !b_returned ) + { + free( psz_uri ); + return YES; + } } } - else if( p_input ) - vlc_object_release( p_input ); + free( psz_uri ); - NSDictionary *o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"]; + NSArray *o_sorted_names = [o_names sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)]; + NSMutableArray *o_result = [NSMutableArray arrayWithCapacity: [o_sorted_names count]]; + for( int i = 0; i < [o_sorted_names count]; i++ ) + { + psz_uri = make_URI([[o_sorted_names objectAtIndex: i] UTF8String], "file" ); + if( !psz_uri ) + continue; - free( psz_uri ); + NSDictionary *o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"]; + free( psz_uri ); + [o_result addObject: o_dic]; + } if( b_autoplay ) - [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue: NO]; + [o_playlist appendArray: o_result atPos: -1 enqueue: NO]; else - [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue: YES]; + [o_playlist appendArray: o_result atPos: -1 enqueue: YES]; return( TRUE ); } _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
