X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fwxwidgets%2Fdialogs%2Fopen.cpp;h=d2d1f4d926bcda32466c1d454ecf5622895ac412;hb=36edd71568f3b577bbb8ef59d5e2749388ac9009;hp=e0b3575d9876e894847a81fa05b62f79b81e8513;hpb=02a21822760ca4e1534f4e4d41fdfb4404e3e258;p=vlc diff --git a/modules/gui/wxwidgets/dialogs/open.cpp b/modules/gui/wxwidgets/dialogs/open.cpp index e0b3575d98..d2d1f4d926 100644 --- a/modules/gui/wxwidgets/dialogs/open.cpp +++ b/modules/gui/wxwidgets/dialogs/open.cpp @@ -29,7 +29,7 @@ #include "dialogs/preferences_widgets.h" #include "dialogs/subtitles.hpp" -#include "charset.h" +#include "vlc_charset.h" #undef HAVE_LIBCDIO // Disable broken code @@ -51,9 +51,6 @@ #include #include -#include - - #ifndef wxRB_SINGLE # define wxRB_SINGLE 0 #endif @@ -222,16 +219,20 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog, intf_thread_t *_p_intf, const module_t *p_module ) : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ), - name( wxU(p_module->psz_object_name) ), + name( wxU(module_get_object(p_module)) ), p_advanced_mrl_combo( NULL ), p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL ) { wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL ); - module_config_t *p_item = p_module->p_config; bool b_advanced = false; + unsigned int i_confsize; + module_config_t *p_config; + int n; - if( p_item ) do + p_config = module_config_get (p_module, &i_confsize); + for( n = 0; n < i_confsize; n++ ) { + module_config_t *p_item = p_config + n; if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced ) b_advanced = true; @@ -250,7 +251,6 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog, sizer->Add( control, 0, wxEXPAND | wxALL, 2 ); } - while( p_item->i_type != CONFIG_HINT_END && p_item++ ); if( b_advanced ) { @@ -262,8 +262,8 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog, /* Build the advanced dialog */ p_advanced_dialog = new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) + - wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"), - wxDefaultPosition, wxDefaultSize, + wxT(" (") + wxU( module_GetLongName(p_module) ) + + wxT(")"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ); wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL ); @@ -286,9 +286,9 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog, sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 ); /* Add advanced options to panel */ - module_config_t *p_item = p_module->p_config; - if( p_item ) do + for( n = 0; n < i_confsize; n++ ) { + module_config_t *p_item = p_config + n; if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced ) continue; @@ -306,7 +306,6 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog, sizer->Add( control, 0, wxEXPAND | wxALL, 2 ); } - while( p_item->i_type != CONFIG_HINT_END && p_item++ ); /* Separation */ wxPanel *dummy_panel = new wxPanel( p_advanced_dialog, -1 ); @@ -317,20 +316,22 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog, /* Create buttons */ wxButton *ok_button = - new wxButton( p_advanced_dialog, wxID_OK ); + new wxButton( p_advanced_dialog, wxID_OK, wxU(_("&OK")) ); ok_button->SetDefault(); wxButton *cancel_button = - new wxButton( p_advanced_dialog, wxID_CANCEL ); - wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); - button_sizer->Add( ok_button, 0, wxALL, 5 ); - button_sizer->Add( cancel_button, 0, wxALL, 5 ); - button_sizer->Layout(); - sizer->Add( button_sizer, 0, wxALL, 0 ); + new wxButton( p_advanced_dialog, wxID_CANCEL, wxU(_("&Cancel")) ); + wxStdDialogButtonSizer *button_sizer = new wxStdDialogButtonSizer; + button_sizer->AddButton( ok_button ); + button_sizer->AddButton( cancel_button ); + button_sizer->Realize(); + sizer->Add( button_sizer, 0, wxEXPAND|wxALL, 5 ); sizer->SetMinSize( 400, -1 ); p_advanced_dialog->SetSizerAndFit( sizer ); } + module_config_free (p_config); + this->SetSizerAndFit( sizer ); } @@ -443,7 +444,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, sout_button->Enable(); subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) ); } - if( psz_sout ) free( psz_sout ); + free( psz_sout ); common_opt_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); @@ -487,9 +488,10 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK ); /* Create the buttons */ - wxButton *ok_button = new wxButton( panel, wxID_OK ); + wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("&OK")) ); ok_button->SetDefault(); - wxButton *cancel_button = new wxButton( panel, wxID_CANCEL ); + wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, + wxU(_("&Cancel")) ); /* Create notebook */ notebook = new wxNotebook( panel, Notebook_Event ); @@ -505,47 +507,39 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, notebook->AddPage( NetPanel( notebook ), wxU(_("Network")), i_access_method == NET_ACCESS ); - module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" ); - if( p_module ) + if( module_exists( "v4l" ) ) { AutoBuiltPanel *autopanel = new AutoBuiltPanel( notebook, this, p_intf, p_module ); input_tab_array.Add( autopanel ); - notebook->AddPage( autopanel, wxU( p_module->psz_shortname ? - p_module->psz_shortname : p_module->psz_object_name ), + notebook->AddPage( autopanel, wxU( module_get_name(p_module, 0) ), i_access_method == CAPTURE_ACCESS ); } - p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" ); - if( p_module ) + if( module_exists( "pvr" ) ) { AutoBuiltPanel *autopanel = new AutoBuiltPanel( notebook, this, p_intf, p_module ); input_tab_array.Add( autopanel ); - notebook->AddPage( autopanel, wxU( p_module->psz_shortname ? - p_module->psz_shortname : p_module->psz_object_name ), + notebook->AddPage( autopanel, wxU( module_get_name(p_module, 0) ), i_access_method == CAPTURE_ACCESS ); } - p_module = config_FindModule( VLC_OBJECT(p_intf), "dvb" ); - if( p_module ) + if( module_exists( "dvb" ) ) { AutoBuiltPanel *autopanel = new AutoBuiltPanel( notebook, this, p_intf, p_module ); input_tab_array.Add( autopanel ); - notebook->AddPage( autopanel, wxU( p_module->psz_shortname ? - p_module->psz_shortname : p_module->psz_object_name ), + notebook->AddPage( autopanel, wxU( module_get_name(p_module, 0) ), i_access_method == CAPTURE_ACCESS ); } - p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" ); - if( p_module ) + if( module_exists( "dshow" ) ) { AutoBuiltPanel *autopanel = new AutoBuiltPanel( notebook, this, p_intf, p_module ); input_tab_array.Add( autopanel ); - notebook->AddPage( autopanel, wxU( p_module->psz_shortname ? - p_module->psz_shortname : p_module->psz_object_name ), + notebook->AddPage( autopanel, wxU( module_get_name(p_module, 0) ), i_access_method == CAPTURE_ACCESS ); } @@ -562,10 +556,10 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, OnPageChange( event ); /* Place everything in sizers */ - wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); - button_sizer->Add( cancel_button, 0, wxALL, 5 ); - button_sizer->Add( ok_button, 0, wxALL, 5 ); - button_sizer->Layout(); + wxStdDialogButtonSizer *button_sizer = new wxStdDialogButtonSizer; + button_sizer->AddButton( cancel_button ); + button_sizer->AddButton( ok_button ); + button_sizer->Realize(); wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); #if (!wxCHECK_VERSION(2,5,2)) @@ -575,7 +569,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, #endif panel_sizer->Add( adv_sizer, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 ); - panel_sizer->Add( button_sizer, 0, wxALIGN_RIGHT | wxALL, 5 ); + panel_sizer->Add( button_sizer, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Layout(); panel->SetSizerAndFit( panel_sizer ); main_sizer->Add( panel, 1, wxGROW, 0 ); @@ -586,9 +580,9 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, OpenDialog::~OpenDialog() { /* Clean up */ - if( file_dialog ) delete file_dialog; - if( sout_dialog ) delete sout_dialog; - if( subsfile_dialog ) delete subsfile_dialog; + delete file_dialog; + delete sout_dialog; + delete subsfile_dialog; } int OpenDialog::Show( int i_access_method, int i_arg ) @@ -659,7 +653,7 @@ wxPanel *OpenDialog::FilePanel( wxWindow* parent ) 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); subfile_combo = new wxComboBox( panel, SubFileName_Event, wxL2U( psz_subsfile ) ); - if( psz_subsfile ) free( psz_subsfile ); + free( psz_subsfile ); subbrowse_button = new wxButton( panel, SubFileBrowse_Event, wxU(_("Browse...")) ); subfile_sizer->Add( subfile_combo, 1, wxALL | wxALIGN_CENTER_VERTICAL, 5 ); @@ -1130,7 +1124,7 @@ void OpenDialog::UpdateMRL( int i_access_method ) } else { - int i_value = config_GetInt( p_intf, caching_name.mb_str() ); + int i_value = config_GetInt( p_intf, caching_name.mb_str(wxConvUTF8) ); caching_value->SetValue( i_value ); } } @@ -1156,27 +1150,25 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) } /* Update the playlist */ - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Hold( p_intf ); if( p_playlist == NULL ) return; for( int i = 0; i < (int)mrl.GetCount(); i++ ) { - vlc_bool_t b_start = !i && i_open_arg; - playlist_item_t *p_item; + bool b_start = !i && i_open_arg; + input_item_t *p_input; char *psz_utf8; psz_utf8 = wxFromLocale( mrl[i] ); - p_item = playlist_ItemNew( p_intf, psz_utf8, psz_utf8 ); + p_input = input_item_New( p_intf, psz_utf8, NULL ); wxLocaleFree( psz_utf8 ); /* Insert options */ while( i + 1 < (int)mrl.GetCount() && - ((const char *)mrl[i + 1].mb_str())[0] == ':' ) + ((const char *)mrl[i + 1].mb_str(wxConvUTF8))[0] == ':' ) { psz_utf8 = wxFromLocale( mrl[i + 1] ); - playlist_ItemAddOption( p_item, psz_utf8 ); + input_item_AddOption( p_input, psz_utf8, VLC_INPUT_OPTION_TRUSTED ); wxLocaleFree( psz_utf8 ); i++; } @@ -1187,7 +1179,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ ) { psz_utf8 = wxFromLocale( subsfile_mrl[j] ); - playlist_ItemAddOption( p_item, psz_utf8 ); + input_item_AddOption( p_input, psz_utf8, VLC_INPUT_OPTION_TRUSTED ); wxLocaleFree( psz_utf8 ); } } @@ -1198,28 +1190,18 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) for( int j = 0; j < (int)sout_mrl.GetCount(); j++ ) { psz_utf8 = wxFromLocale( sout_mrl[j] ); - playlist_ItemAddOption( p_item, psz_utf8 ); + input_item_AddOption( p_input, psz_utf8, VLC_INPUT_OPTION_TRUSTED ); wxLocaleFree( psz_utf8 ); } } - - if( b_start ) - { - playlist_AddItem( p_playlist, p_item, - PLAYLIST_APPEND, - PLAYLIST_END ); - playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item ); - } - else - { - playlist_AddItem( p_playlist, p_item, - PLAYLIST_APPEND|PLAYLIST_PREPARSE, - PLAYLIST_END ); - } + /* FIXME: playlist_AddInput() can fail */ + playlist_AddInput( p_playlist, p_input, + PLAYLIST_APPEND | ( b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE ), + PLAYLIST_END, true, pl_Unlocked ); + vlc_gc_decref( p_input ); } - - vlc_object_release( p_playlist ); + pl_Release( p_intf ); Hide(); @@ -1263,6 +1245,12 @@ void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) ) file_dialog = new wxFileDialog( this, wxU(_("Open File")), wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE ); + 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( file_dialog && file_dialog->ShowModal() == wxID_OK ) { wxArrayString paths; @@ -1634,7 +1622,7 @@ void OpenDialog::OnDiscProbe( wxCommandEvent& WXUNUSED(event) ) break; } - free(psz_device); + free( psz_device ); disc_probe->SetValue(FALSE); UpdateMRL( DISC_ACCESS ); @@ -1665,14 +1653,12 @@ void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) ) disc_audio->SetRange( 0, 7 ); // up to 8 audio channels disc_chapter->SetRange( 0, 255 ); disc_title->SetToolTip( wxU(_("Title number.")) ); - // \bug [string] needs to be DVDs instead of DVD's disc_sub->SetToolTip( wxU(_( - "DVD's can have up to 32 subtitles numbered 0..31. " + "DVDs can have up to 32 subtitles numbered 0..31. " "Note this is not the same thing as a subtitle name (e.g. 'en'). " "If a value -1 is used, no subtitle will be shown." )) ); - // \bug [string] needs to be DVDs instead of DVD's disc_audio->SetToolTip( wxU(_("Audio track number. " - "DVD's can have up to 8 audio tracks numbered 0..7." + "DVDs can have up to 8 audio tracks numbered 0..7." )) ); break; @@ -1708,13 +1694,11 @@ void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) ) disc_title->SetRange( 0, 99 ); // only 100 tracks allowed on VCDs disc_sub->SetRange( -1, 3 ); // up to 4 subtitles -1 = no subtitle disc_audio->SetRange( 0, 1 ); // up to 2 audio tracks - // \bug [string] needs to be SVCDs instead of SVCD's disc_sub->SetToolTip( wxU(_( - "SVCD's can have up to 4 subtitles numbered 0..3. " + "SVCDs can have up to 4 subtitles numbered 0..3. " "If a value -1 is used, no subtitle will be shown." )) ); - // \bug [string] needs to be SVCDs instead of SVCD's disc_audio->SetToolTip( wxU(_("Audio track number. " - "VCD's can have up to 2 audio tracks numbered 0 or 1. " + "VCDs can have up to 2 audio tracks numbered 0 or 1. " )) ); break; @@ -1752,7 +1736,7 @@ void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) ) disc_title->SetValue( 0 ); i_disc_title = 0; disc_chapter->SetValue( 0 ); i_disc_chapter = 0; - if( psz_device ) free( psz_device ); + free( psz_device ); UpdateMRL( DISC_ACCESS ); } @@ -1835,8 +1819,8 @@ void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) ) (int)subsfile_dialog->size_combo->GetClientData( subsfile_dialog->size_combo->GetSelection()) ) ); } - subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"), - subsfile_dialog->fps_spinctrl->GetValue() ) ); + subsfile_mrl.Add( wxString( wxT("sub-fps="))+ + subsfile_dialog->fps_ctrl->GetValue() ); subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"), subsfile_dialog->delay_spinctrl->GetValue() ) ); } @@ -1889,7 +1873,7 @@ void OpenDialog::OnCachingChange( wxCommandEvent& event ) *****************************************************************************/ wxArrayString SeparateEntries( wxString entries ) { - vlc_bool_t b_quotes_mode = VLC_FALSE; + bool b_quotes_mode = false; wxArrayString entries_array; wxString entry; @@ -1906,13 +1890,13 @@ wxArrayString SeparateEntries( wxString entries ) { /* Enters quotes mode */ entry.RemoveLast(); - b_quotes_mode = VLC_TRUE; + b_quotes_mode = true; } else if( b_quotes_mode && entry.Last() == wxT('\"') ) { /* Finished the quotes mode */ entry.RemoveLast(); - b_quotes_mode = VLC_FALSE; + b_quotes_mode = false; } else if( !b_quotes_mode && entry.Last() != wxT('\"') ) {