+void DialogsProvider::OnOpenFileGeneric( wxCommandEvent& event )
+{
+ intf_dialog_args_t *p_arg = (intf_dialog_args_t *)event.GetClientData();
+
+ if( p_arg == NULL )
+ {
+ msg_Dbg( p_intf, "OnOpenFileGeneric() called with NULL arg" );
+ return;
+ }
+
+ if( p_file_generic_dialog == NULL )
+ p_file_generic_dialog = new wxFileDialog( this );
+
+ if( p_file_generic_dialog )
+ {
+ p_file_generic_dialog->SetMessage( wxU(p_arg->psz_title) );
+ p_file_generic_dialog->SetWildcard( wxU(p_arg->psz_extensions) );
+ p_file_generic_dialog->SetStyle( (p_arg->b_save ? wxSAVE : wxOPEN) |
+ (p_arg->b_multiple ? wxMULTIPLE:0) );
+ }
+
+ if( p_file_generic_dialog &&
+ p_file_generic_dialog->ShowModal() == wxID_OK )
+ {
+ wxArrayString paths;
+
+ p_file_generic_dialog->GetPaths( paths );
+
+ p_arg->i_results = paths.GetCount();
+ p_arg->psz_results = (char **)malloc( p_arg->i_results *
+ sizeof(char *) );
+ for( size_t i = 0; i < paths.GetCount(); i++ )
+ {
+ p_arg->psz_results[i] = strdup( paths[i].mb_str() );
+ }
+ }
+
+ /* Callback */
+ if( p_arg->pf_callback )
+ {
+ p_arg->pf_callback( p_arg );
+ }
+
+ /* Blocking or not ? */
+ if( p_arg->b_blocking )
+ {
+ vlc_mutex_lock( &p_arg->lock );
+ p_arg->b_ready = 1;
+ vlc_cond_signal( &p_arg->wait );
+ vlc_mutex_unlock( &p_arg->lock );
+ }
+
+ /* Clean-up */
+ if( p_arg->b_blocking )
+ {
+ vlc_mutex_destroy( &p_arg->lock );
+ vlc_cond_destroy( &p_arg->wait );
+ }
+ if( p_arg->psz_results )
+ {
+ for( int i = 0; i < p_arg->i_results; i++ )
+ {
+ free( p_arg->psz_results[i] );
+ }
+ free( p_arg->psz_results );
+ }
+ if( p_arg->psz_title ) free( p_arg->psz_title );
+ if( p_arg->psz_extensions ) free( p_arg->psz_extensions );
+ free( p_arg );
+}
+