* open.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: open.cpp,v 1.20 2003/05/12 21:55:01 gbazin Exp $
+ * $Id: open.cpp,v 1.26 2003/05/24 17:52:49 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
#include <wx/combobox.h>
#include <wx/spinctrl.h>
#include <wx/statline.h>
+#include <wx/tokenzr.h>
#include <vlc/intf.h>
NetPort1_Event, NetPort2_Event, NetPort3_Event,
NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
+ SubsFileEnable_Event,
+ SubsFileSettings_Event,
+
SoutEnable_Event,
SoutSettings_Event,
EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
+ /* Events generated by the subtitle file buttons */
+ EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
+ EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
+
/* Events generated by the stream output buttons */
EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
p_intf = _p_intf;
p_parent = _p_parent;
SetIcon( *p_intf->p_sys->p_icon );
+ file_dialog = NULL;
+ sout_dialog = NULL;
+ subsfile_dialog = NULL;
+ demuxdump_dialog = NULL;
/* Create a panel to put everything in */
wxPanel *panel = new wxPanel( this, -1 );
wxHORIZONTAL );
wxStaticText *mrl_label = new wxStaticText( panel, -1,
wxU(_("Open Target:")) );
- mrl_combo = new wxComboBox( panel, MRL_Event, mrl,
+ mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
wxPoint(20,25), wxSize(120, -1),
0, NULL );
mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
wxU(_("Alternatively, you can build an MRL using one of the "
"following predefined targets:")) );
+ /* Create Subtitles File checkox */
+ wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
+ subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
+ wxU(_("Subtitles file")) );
+ subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
+ "Currently only works with AVI files.")) );
+ subsfile_sizer->Add( subsfile_checkbox, 0,
+ wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+ subsfile_button = new wxButton( panel, SubsFileSettings_Event,
+ wxU(_("Settings...")) );
+ subsfile_button->Disable();
+
+ char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
+ if( psz_subsfile && *psz_subsfile )
+ {
+ subsfile_checkbox->SetValue(TRUE);
+ subsfile_button->Enable();
+ }
+ if( psz_subsfile ) free( psz_subsfile );
+
+ subsfile_sizer->Add( subsfile_button, 1,
+ wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+
/* Create Stream Output checkox */
wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
demuxdump_textctrl->Disable();
demuxdump_button->Disable();
demuxdump_sizer->Add( demuxdump_checkbox, 0,
- wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 10 );
+ wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
demuxdump_sizer->Add( demuxdump_button, 0,
- wxALL | wxALIGN_CENTER_VERTICAL, 10 );
- demuxdump_sizer->Add( demuxdump_textctrl, 1, wxALL, 10 );
+ wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 );
+ demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 );
/* Separation */
wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
wxU(_("Cancel")) );
/* Create notebook */
- wxNotebook *notebook = new wxNotebook( panel, Notebook_Event );
+ notebook = new wxNotebook( panel, Notebook_Event );
wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
+ panel_sizer->Add( subsfile_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
OpenDialog::~OpenDialog()
{
+ /* Clean up */
+ if( file_dialog ) delete file_dialog;
+ if( sout_dialog ) delete sout_dialog;
+ if( subsfile_dialog ) delete subsfile_dialog;
+ if( demuxdump_dialog ) delete demuxdump_dialog;
+}
+
+int OpenDialog::ShowModal( int i_access_method )
+{
+ notebook->SetSelection( i_access_method );
+ return wxDialog::ShowModal();
+}
+
+int OpenDialog::ShowModal()
+{
+ return wxDialog::ShowModal();
}
/*****************************************************************************
static const wxString disc_type_array[] =
{
- wxU(_("DVD")),
wxU(_("DVD (menus support)")),
- wxU(_("VCD"))
+ wxU(_("DVD")),
+ wxU(_("VCD")),
+ wxU(_("CD Audio"))
+
};
disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
void OpenDialog::UpdateMRL( int i_access_method )
{
- wxString demux;
+ wxString demux, mrltemp;
i_current_access_method = i_access_method;
switch( i_access_method )
{
case FILE_ACCESS:
- mrl = wxT("file") + demux + wxT("://") + file_combo->GetValue();
+ //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
+ mrltemp = file_combo->GetValue();
break;
case DISC_ACCESS:
- mrl = ( disc_type->GetSelection() == 0 ? wxT("dvdold") :
- disc_type->GetSelection() == 1 ? wxT("dvd") : wxT("vcd") )
- + demux + wxT("://")
+ mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
+ disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
+ disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
+ + demux + wxT(":")
+ disc_device->GetLineText(0)
+ wxString::Format( wxT("@%d:%d"),
disc_title->GetValue(),
if( net_ports[0]->GetValue() !=
config_GetInt( p_intf, "server-port" ) )
{
- mrl = wxT("udp") + demux +
- wxString::Format( wxT("://@:%d"),
- net_ports[0]->GetValue() );
+ mrltemp = wxT("udp") + demux +
+ wxString::Format( wxT("://@:%d"),
+ net_ports[0]->GetValue() );
}
else
{
- mrl = wxT("udp") + demux + wxT("://");
+ mrltemp = wxT("udp") + demux + wxT("://");
}
break;
case 1:
- mrl = wxT("udp") + demux + wxT("://@") +
- net_addrs[1]->GetLineText(0);
+ mrltemp = wxT("udp") + demux + wxT("://@") +
+ net_addrs[1]->GetLineText(0);
if( net_ports[1]->GetValue() !=
config_GetInt( p_intf, "server-port" ) )
{
- mrl = mrl + wxString::Format( wxT(":%d"),
+ mrltemp = mrltemp + wxString::Format( wxT(":%d"),
net_ports[1]->GetValue() );
}
break;
case 2:
/* http access */
- mrl = wxT("http") + demux + wxT("://") +
- net_addrs[2]->GetLineText(0);
+ mrltemp = wxT("http") + demux + wxT("://") +
+ net_addrs[2]->GetLineText(0);
break;
}
break;
case SAT_ACCESS:
- mrl = wxT("satellite") + demux + wxT("://");
+ mrltemp = wxT("satellite") + demux + wxT("://");
break;
default:
break;
}
- mrl_combo->SetValue( mrl );
+ mrl_combo->SetValue( mrltemp );
+}
+
+wxArrayString OpenDialog::SeparateEntries( wxString entries )
+{
+ vlc_bool_t b_quotes_mode = VLC_FALSE;
+
+ wxArrayString entries_array;
+ wxString entry;
+
+ wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
+
+ while( token.HasMoreTokens() )
+ {
+ entry += token.GetNextToken();
+
+ if( entry.IsEmpty() ) continue;
+
+ if( !b_quotes_mode && entry.Last() == wxT('\"') )
+ {
+ /* Enters quotes mode */
+ entry.RemoveLast();
+ b_quotes_mode = VLC_TRUE;
+ }
+ else if( b_quotes_mode && entry.Last() == wxT('\"') )
+ {
+ /* Finished the quotes mode */
+ entry.RemoveLast();
+ if( !entry.IsEmpty() ) entries_array.Add( entry );
+ entry.Empty();
+ b_quotes_mode = VLC_FALSE;
+ }
+ else if( !b_quotes_mode && entry.Last() != wxT('\"') )
+ {
+ /* we found a non-quoted standalone string */
+ entry.RemoveLast();
+ if( !entry.IsEmpty() ) entries_array.Add( entry );
+ entry.Empty();
+ }
+ else
+ {;}
+ }
+
+ if( !entry.IsEmpty() ) entries_array.Add( entry );
+
+ return entries_array;
}
/*****************************************************************************
*****************************************************************************/
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{
+ mrl_combo->Append( mrl_combo->GetValue() );
+ mrl = SeparateEntries( mrl_combo->GetValue() );
EndModal( wxID_OK );
}
void OpenDialog::OnMRLChange( wxCommandEvent& event )
{
- mrl = event.GetString();
+ //mrl = SeparateEntries( event.GetString() );
}
/*****************************************************************************
void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
{
- wxFileDialog dialog( this, wxU(_("Open file")),
- wxT(""), wxT(""), wxT("*.*"), wxOPEN );
+ if( file_dialog == NULL )
+ file_dialog = new wxFileDialog( this, wxU(_("Open file")),
+ wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
- if( dialog.ShowModal() == wxID_OK )
+ if( file_dialog && file_dialog->ShowModal() == wxID_OK )
{
- file_combo->SetValue( dialog.GetPath() );
+ wxArrayString paths;
+ wxString path;
+
+ file_dialog->GetPaths( paths );
+
+ for( size_t i = 0; i < paths.GetCount(); i++ )
+ {
+ if( paths[i].Find( wxT(' ') ) >= 0 )
+ path += wxT("\"") + paths[i] + wxT("\" ");
+ else
+ path += paths[i] + wxT(" ");
+ }
+
+ file_combo->SetValue( path );
+ file_combo->Append( path );
UpdateMRL( FILE_ACCESS );
}
}
switch( disc_type->GetSelection() )
{
- case 1:
+ case 0:
disc_title->SetRange( 0, 255 );
disc_title->SetValue( 0 );
break;
UpdateMRL( NET_ACCESS );
}
+/*****************************************************************************
+ * Subtitles file event methods.
+ *****************************************************************************/
+void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
+{
+ subsfile_button->Enable( event.GetInt() != 0 );
+ if( !event.GetInt() )
+ {
+ config_PutPsz( p_intf, "sub-file", "" );
+ }
+ else
+ {
+ demuxdump_checkbox->SetValue( 0 );
+ wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
+ event.SetInt( 0 );
+ OnDemuxDumpEnable( event );
+ }
+}
+
+void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
+{
+ /* Show/hide the open dialog */
+ if( subsfile_dialog == NULL )
+ subsfile_dialog = new SubsFileDialog( p_intf, p_parent );
+
+ if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
+ {
+ config_PutPsz( p_intf, "sub-file",
+ (const char *)subsfile_dialog->file_combo->GetValue().mb_str() );
+ config_PutInt( p_intf, "sub-delay",
+ subsfile_dialog->delay_spinctrl->GetValue() );
+ config_PutFloat( p_intf, "sub-fps",
+ subsfile_dialog->fps_spinctrl->GetValue() );
+ }
+}
+
/*****************************************************************************
* Stream output event methods.
*****************************************************************************/
void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
{
/* Show/hide the open dialog */
- SoutDialog dialog( p_intf, p_parent );
+ if( sout_dialog == NULL )
+ sout_dialog = new SoutDialog( p_intf, p_parent );
- if( dialog.ShowModal() == wxID_OK )
+ if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
{
- config_PutPsz( p_intf, "sout", (const char *)dialog.mrl.mb_str() );
+ config_PutPsz( p_intf, "sout",
+ (const char *)sout_dialog->mrl.mb_str() );
}
}
if( event.GetInt() )
{
sout_checkbox->SetValue( 0 );
+ subsfile_checkbox->SetValue( 0 );
wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
event.SetInt( 0 );
OnSoutEnable( event );
+ OnSubsFileEnable( event );
}
UpdateMRL( i_current_access_method );
void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
{
- wxFileDialog dialog( this, wxU(_("Save file")),
- wxT(""), wxT(""), wxT("*.*"), wxSAVE );
+ if( demuxdump_dialog == NULL )
+ demuxdump_dialog = new wxFileDialog( this, wxU(_("Save file")),
+ wxT(""), wxT(""), wxT("*"), wxSAVE );
- if( dialog.ShowModal() == wxID_OK )
+ if( demuxdump_dialog && demuxdump_dialog->ShowModal() == wxID_OK )
{
- demuxdump_textctrl->SetValue( dialog.GetPath() );
+ demuxdump_textctrl->SetValue( demuxdump_dialog->GetPath() );
wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
OnDemuxDumpChange( event );
}