void DialogAttachments::AttachFile(wxFileDialog &diag, AssEntryGroup group, wxString const& commit_msg) { if (diag.ShowModal() == wxID_CANCEL) return; wxArrayString filenames; diag.GetFilenames(filenames); wxArrayString paths; diag.GetPaths(paths); // Create attachments for (size_t i = 0; i < filenames.size(); ++i) { AssAttachment *newAttach = new AssAttachment(filenames[i], group); try { newAttach->Import(paths[i]); } catch (...) { delete newAttach; return; } ass->InsertLine(newAttach); } ass->Commit(commit_msg, AssFile::COMMIT_ATTACHMENT); UpdateList(); }
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( NULL ); 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(wxConvUTF8) ); } } /* Callback */ if( p_arg->pf_callback ) { p_arg->pf_callback( p_arg ); } 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 ); }
void DialogAttachments::AttachFile(wxFileDialog &diag, wxString const& commit_msg) { if (diag.ShowModal() == wxID_CANCEL) return; wxArrayString paths; diag.GetPaths(paths); for (auto const& fn : paths) ass->InsertAttachment(agi::fs::path(fn)); ass->Commit(commit_msg, AssFile::COMMIT_ATTACHMENT); UpdateList(); }
void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event ) { playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return; } if( p_file_dialog == NULL ) p_file_dialog = new wxFileDialog( NULL, wxU(_("Open File")), wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE ); p_file_dialog->SetWildcard(wxU(_("All Files (*.*)|*" "|Sound Files (*.mp3, *.ogg, etc.)|" EXTENSIONS_AUDIO "|Video Files (*.avi, *.mpg, etc.)|" EXTENSIONS_VIDEO "|Playlist Files (*.m3u, *.pls, etc.)|" EXTENSIONS_PLAYLIST "|Subtitle Files (*.srt, *.sub, etc.)|" EXTENSIONS_SUBTITLE))); if( p_file_dialog && p_file_dialog->ShowModal() == wxID_OK ) { wxArrayString paths; p_file_dialog->GetPaths( paths ); for( size_t i = 0; i < paths.GetCount(); i++ ) { char *psz_utf8 = wxFromLocale( paths[i] ); if( event.GetInt() ) playlist_Add( p_playlist, psz_utf8, psz_utf8, PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) | (i ? PLAYLIST_PREPARSE : 0 ), PLAYLIST_END ); else playlist_Add( p_playlist, psz_utf8, psz_utf8, PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END ); wxLocaleFree( psz_utf8 ); } } vlc_object_release( p_playlist ); }