* open.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: open.cpp,v 1.17 2003/05/07 12:23:06 gbazin Exp $
+ * $Id: open.cpp,v 1.37 2003/08/19 21:16:09 adn 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>
-#if defined MODULE_NAME_IS_skins
-# include "../skins/src/skin_common.h"
-# include "../skins/src/wxdialogs.h"
-#else
-# include "wxwindows.h"
-#endif
+#include "wxwindows.h"
#ifndef wxRB_SINGLE
# define wxRB_SINGLE 0
NetPort1_Event, NetPort2_Event, NetPort3_Event,
NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
+ VideoType_Event,
+ VideoDevice_Event,
+ VideoChannel_Event,
+ V4LSettings_Event,
+
+ SubsFileEnable_Event,
+ SubsFileSettings_Event,
+
SoutEnable_Event,
SoutSettings_Event,
DemuxDumpBrowse_Event,
};
-BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
+BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
/* Button events */
EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
- EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
+ EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
/* Events generated by the file panel */
EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
+ /* Events generated by the v4l panel */
+ EVT_RADIOBOX(VideoType_Event, OpenDialog::OnV4LTypeChange)
+ EVT_TEXT(VideoDevice_Event, OpenDialog::OnV4LPanelChange)
+ EVT_SPINCTRL(VideoChannel_Event, OpenDialog::OnV4LPanelChange)
+ EVT_BUTTON(V4LSettings_Event, OpenDialog::OnV4LSettingsChange)
+
+ /* 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)
EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)
+ /* Hide the window when the user closes the window */
+ EVT_CLOSE(OpenDialog::OnCancel)
+
END_EVENT_TABLE()
/*****************************************************************************
* Constructor.
*****************************************************************************/
-OpenDialog::OpenDialog( intf_thread_t *_p_intf, Interface *_p_main_interface,
- int i_access_method ):
- wxDialog( _p_main_interface, -1, _("Open Target"), wxDefaultPosition,
+OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
+ int i_access_method, int i_arg ):
+ wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{
/* Initializations */
p_intf = _p_intf;
- p_main_interface = _p_main_interface;
+ p_parent = _p_parent;
SetIcon( *p_intf->p_sys->p_icon );
+ file_dialog = NULL;
+ v4l_dialog = NULL;
+ sout_dialog = NULL;
+ subsfile_dialog = NULL;
+ demuxdump_dialog = NULL;
/* Create a panel to put everything in */
wxPanel *panel = new wxPanel( this, -1 );
/* Create MRL combobox */
wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
- _("Media Resource Locator (MRL)") );
+ wxU(_("Media Resource Locator (MRL)")) );
wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
wxHORIZONTAL );
wxStaticText *mrl_label = new wxStaticText( panel, -1,
- _("Open Target:") );
- mrl_combo = new wxComboBox( panel, MRL_Event, mrl,
+ wxU(_("Open Target:")) );
+ mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
wxPoint(20,25), wxSize(120, -1),
0, NULL );
- mrl_combo->SetToolTip( _("You can use this field directly by typing the "
- "full MRL you want to open.\n""Alternatively, the field will be "
- "filled automatically when you use the controls below") );
+ mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
+ "the full MRL you want to open.\n""Alternatively, the field will be "
+ "filled automatically when you use the controls below.")) );
mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
/* Create Static Text */
wxStaticText *label = new wxStaticText( panel, -1,
- _("Alternatively, you can build an MRL using one of the "
- "following predefined targets:") );
+ wxU(_("Alternatively, you can build an MRL using one of the "
+ "following predefined targets:")) );
/* Create Stream Output checkox */
wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
- _("Stream output") );
- sout_checkbox->SetToolTip( _("Use VLC as a stream server") );
+ wxU(_("Stream output")) );
+ sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
sout_sizer->Add( sout_checkbox, 0,
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
- sout_button = new wxButton( panel, SoutSettings_Event, _("Settings...") );
+ sout_button = new wxButton( panel, SoutSettings_Event,
+ wxU(_("Settings...")) );
sout_button->Disable();
char *psz_sout = config_GetPsz( p_intf, "sout" );
{
sout_checkbox->SetValue(TRUE);
sout_button->Enable();
+ subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) );
}
if( psz_sout ) free( psz_sout );
/* Create Demux Dump checkox */
wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
- _("Capture input stream") );
+ wxU(_("Capture input stream")) );
demuxdump_checkbox->SetToolTip(
- _("Capture the stream you are playing to a file") );
- demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event,
- "", wxDefaultPosition, wxDefaultSize,
- wxTE_PROCESS_ENTER);
+ wxU(_("Capture the stream you are playing to a file")) );
+ demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxTE_PROCESS_ENTER );
demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
- _("Browse...") );
+ wxU(_("Browse...")) );
char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
if( psz_demuxdump && *psz_demuxdump )
{
- demuxdump_textctrl->SetValue( psz_demuxdump );
+ demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
}
if( psz_demuxdump ) free( psz_demuxdump );
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 );
/* Create the buttons */
- wxButton *ok_button = new wxButton( panel, wxID_OK, _("OK") );
+ wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
ok_button->SetDefault();
- wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, _("Cancel") );
+ wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
+ 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 ), _("File"),
+ notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
i_access_method == FILE_ACCESS );
- notebook->AddPage( DiscPanel( notebook ), _("Disc"),
+ notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
i_access_method == DISC_ACCESS );
- notebook->AddPage( NetPanel( notebook ), _("Network"),
+ notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
i_access_method == NET_ACCESS );
#ifndef WIN32
- notebook->AddPage( SatPanel( notebook ), _("Satellite"),
+ notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
i_access_method == SAT_ACCESS );
#endif
+ notebook->AddPage( V4LPanel( notebook ), wxU(_("Video For Linux")),
+ i_access_method == V4L_ACCESS );
+
/* Update Disc panel */
wxCommandEvent dummy_event;
OnDiscTypeChange( dummy_event );
dummy_event.SetId( NetRadio1_Event );
OnNetTypeChange( dummy_event );
+ /* Update v4l panel */
+ dummy_event.SetId( VideoType_Event );
+ OnV4LTypeChange( dummy_event );
+
/* Update MRL */
- wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
+ wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
OnPageChange( event );
/* Place everything in sizers */
OpenDialog::~OpenDialog()
{
+ /* Clean up */
+ if( file_dialog ) delete file_dialog;
+ if( v4l_dialog ) delete v4l_dialog;
+ if( sout_dialog ) delete sout_dialog;
+ if( subsfile_dialog ) delete subsfile_dialog;
+ if( demuxdump_dialog ) delete demuxdump_dialog;
+}
+
+int OpenDialog::Show( int i_access_method, int i_arg )
+{
+ int i_ret;
+ notebook->SetSelection( i_access_method );
+ i_ret = wxFrame::Show();
+ Raise();
+ SetFocus();
+ return i_ret;
+}
+
+int OpenDialog::Show()
+{
+ int i_ret;
+ i_ret = wxFrame::Show();
+ Raise();
+ SetFocus();
+ return i_ret;
}
/*****************************************************************************
wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
wxSize(200, 200) );
- wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
+ wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
- file_combo = new wxComboBox( panel, FileName_Event, "",
+ /* Create browse file line */
+ wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
+
+ file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
wxPoint(20,25), wxSize(200, -1), 0, NULL );
wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
- _("Browse...") );
- sizer->Add( file_combo, 1, wxALL, 5 );
- sizer->Add( browse_button, 0, wxALL, 5 );
+ wxU(_("Browse...")) );
+ file_sizer->Add( file_combo, 1, wxALL, 5 );
+ file_sizer->Add( browse_button, 0, wxALL, 5 );
+
+ /* 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();
+ subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxU(psz_subsfile) );
+ }
+ if( psz_subsfile ) free( psz_subsfile );
+
+ subsfile_sizer->Add( subsfile_button, 1,
+ wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+ sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
+ sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
panel->SetSizerAndFit( sizer );
return panel;
}
static const wxString disc_type_array[] =
{
- _("DVD"),
- _("DVD (menus support)"),
- _("VCD")
+ wxU(_("DVD (menus support)")),
+ wxU(_("DVD")),
+ wxU(_("VCD")),
+ wxU(_("CD Audio"))
+
};
- disc_type = new wxRadioBox( panel, DiscType_Event, _("Disc type"),
+ disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(disc_type_array), disc_type_array,
WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
- wxStaticText *label = new wxStaticText( panel, -1, _("Device name") );
- disc_device = new wxTextCtrl( panel, DiscDevice_Event, "",
+ wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
+ disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER);
sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
- label = new wxStaticText( panel, -1, _("Title") );
+ label = new wxStaticText( panel, -1, wxU(_("Title")) );
disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
- label = new wxStaticText( panel, -1, _("Chapter") );
+ label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
static const wxString net_type_array[] =
{
- _("UDP/RTP"),
- _("UDP/RTP Multicast"),
- _("HTTP/FTP/MMS")
+ wxU(_("UDP/RTP")),
+ wxU(_("UDP/RTP Multicast")),
+ wxU(_("HTTP/FTP/MMS"))
};
for( i=0; i<3; i++ )
/* UDP/RTP row */
wxFlexGridSizer *subpanel_sizer;
wxStaticText *label;
- int val = config_GetInt( p_intf, "server-port" );
+ i_net_ports[0] = config_GetInt( p_intf, "server-port" );
subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
- label = new wxStaticText( net_subpanels[0], -1, _("Port") );
+ label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
- wxString::Format("%d", val),
+ wxString::Format(wxT("%d"), i_net_ports[0]),
wxDefaultPosition, wxDefaultSize,
wxSP_ARROW_KEYS,
- 0, 16000, val);
+ 0, 16000, i_net_ports[0] );
subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
subpanel_sizer->Add( net_ports[0], 1,
/* UDP/RTP Multicast row */
subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
- label = new wxStaticText( net_subpanels[1], -1, _("Address") );
- net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, "",
+ label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
+ net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER);
subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
subpanel_sizer->Add( net_addrs[1], 1,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
- label = new wxStaticText( net_subpanels[1], -1, _("Port") );
+ label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
+ i_net_ports[1] = i_net_ports[0];
net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
- wxString::Format("%d", val),
+ wxString::Format(wxT("%d"), i_net_ports[1]),
wxDefaultPosition, wxDefaultSize,
wxSP_ARROW_KEYS,
- 0, 16000, val);
+ 0, 16000, i_net_ports[1] );
subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
subpanel_sizer->Add( net_ports[1], 1,
/* HTTP row */
subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
- label = new wxStaticText( net_subpanels[2], -1, _("URL") );
- net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, "",
+ label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
+ net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
wxDefaultPosition, wxSize( 200, -1 ),
wxTE_PROCESS_ENTER);
subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
/* Stuff everything into the main panel */
for( i=0; i<3; i++ )
{
- sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
- sizer->Add( net_subpanels[i], 1,
- wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+ sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
+ wxALL, 5 );
+ sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
+ wxALIGN_CENTER_VERTICAL | wxALL, 5 );
}
sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
return panel;
}
+wxPanel *OpenDialog::V4LPanel( wxWindow* parent )
+{
+ wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
+ wxSize(200, 200) );
+
+ wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
+ wxFlexGridSizer *sizer = new wxFlexGridSizer( 1, 4, 20 );
+
+ static const wxString video_type_array[] =
+ {
+ wxU(_("WebCam")),
+ wxU(_("TV Card")),
+ wxU(_("PVR")),
+ wxU(_("Kfir")),
+ };
+
+ video_type = new wxRadioBox( panel, VideoType_Event,
+ wxU(_("Video Device Type")),
+ wxDefaultPosition, wxDefaultSize,
+ WXSIZEOF(video_type_array), video_type_array,
+ WXSIZEOF(video_type_array), wxRA_SPECIFY_COLS );
+
+ sizer_row->Add( video_type, 0, wxEXPAND | wxALL, 5 );
+
+
+ /* Video Options */
+ wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 2, 20 );
+ wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Video Device")) );
+ video_device = new wxTextCtrl( panel, VideoDevice_Event, wxT(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxTE_PROCESS_ENTER);
+
+ video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+ video_sizer->Add( video_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+
+ label = new wxStaticText( panel, -1, wxU(_("Channel")) );
+ video_channel = new wxSpinCtrl( panel, VideoChannel_Event );
+
+ video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
+ video_sizer->Add( video_channel, 1, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
+ sizer->Add( video_sizer, 0, wxEXPAND | wxALL, 5 );
+
+ wxBoxSizer *v4lbutton_sizer = new wxBoxSizer( wxHORIZONTAL );
+ v4l_button = new wxButton( panel, V4LSettings_Event,
+ wxU(_("Advanced Settings...")) );
+
+ v4lbutton_sizer->Add( v4l_button, 0, wxALIGN_RIGHT, 5 );
+
+ sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
+ sizer_row->Add( v4lbutton_sizer, 0, wxEXPAND | wxALL, 5 );
+
+ panel->SetSizerAndFit( sizer_row );
+ return panel;
+}
+
wxPanel *OpenDialog::SatPanel( wxWindow* parent )
{
wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
void OpenDialog::UpdateMRL( int i_access_method )
{
- wxString demux;
+ wxString demux, mrltemp;
i_current_access_method = i_access_method;
/* Check if the user asked for demuxdump */
if( demuxdump_checkbox->GetValue() )
{
- demux = "/demuxdump";
+ demux = wxT("/demuxdump");
}
switch( i_access_method )
{
case FILE_ACCESS:
- mrl = "file" + demux + "://" + file_combo->GetValue();
+ //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
+ mrltemp = file_combo->GetValue();
break;
case DISC_ACCESS:
- mrl = ( disc_type->GetSelection() == 0 ? "dvdold" :
- disc_type->GetSelection() == 1 ? "dvd" : "vcd" )
- + demux + "://"
+ 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( "@%d:%d",
- disc_title->GetValue(),
- disc_chapter->GetValue() );
+ + wxString::Format( wxT("@%d:%d"),
+ i_disc_title, i_disc_chapter );
break;
case NET_ACCESS:
switch( i_net_type )
{
case 0:
- if( net_ports[0]->GetValue() !=
+ if( i_net_ports[0] !=
config_GetInt( p_intf, "server-port" ) )
{
- mrl = "udp" + demux +
- wxString::Format( "://@:%d", net_ports[0]->GetValue() );
+ mrltemp = wxT("udp") + demux +
+ wxString::Format( wxT("://@:%d"),
+ i_net_ports[0] );
}
else
{
- mrl = "udp" + demux + "://";
+ mrltemp = wxT("udp") + demux + wxT("://");
}
break;
case 1:
- mrl = "udp" + demux + "://@" + net_addrs[1]->GetLineText(0);
- if( net_ports[1]->GetValue() !=
+ mrltemp = wxT("udp") + demux + wxT("://@") +
+ net_addrs[1]->GetLineText(0);
+ if( i_net_ports[1] !=
config_GetInt( p_intf, "server-port" ) )
{
- mrl = mrl + wxString::Format( ":%d",
- net_ports[1]->GetValue() );
+ mrltemp = mrltemp + wxString::Format( wxT(":%d"),
+ i_net_ports[1] );
}
break;
case 2:
- /* http access */
- mrl = "http" + demux + "://" + net_addrs[2]->GetLineText(0);
+ /* http access */
+ mrltemp = wxT("http") + demux + wxT("://") +
+ net_addrs[2]->GetLineText(0);
break;
}
break;
case SAT_ACCESS:
- mrl = "satellite" + demux + "://";
+ mrltemp = wxT("satellite") + demux + wxT("://");
break;
+
+ case V4L_ACCESS:
+ mrltemp = ( video_type->GetSelection() == 0 ? wxT("v4l") :
+ video_type->GetSelection() == 1 ? wxT("v4l") :
+ video_type->GetSelection() == 2 ? wxT("pvr") :
+ wxT("kfir") )
+ + demux + wxT(":")
+ + video_device->GetLineText( 0 );
+
+ if( video_type->GetSelection() == 1 )
+ {
+ mrltemp += wxString::Format( wxT(":channel=%d"),
+ video_channel->GetValue() );
+ }
+
+ if ( /* v4l_dialog != NULL && */ !v4l_mrl.IsEmpty() )
+ {
+ mrltemp += v4l_mrl[0];
+ }
+
+ break;
+
default:
break;
}
- mrl_combo->SetValue( mrl );
+ mrl_combo->SetValue( mrltemp );
}
/*****************************************************************************
*****************************************************************************/
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{
- EndModal( wxID_OK );
+ mrl = SeparateEntries( mrl_combo->GetValue() );
+ mrl_combo->Append( mrl_combo->GetValue() );
+ if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
+ mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
+
+ /* Update the playlist */
+ playlist_t *p_playlist =
+ (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL ) return;
+
+ for( int i = 0; i < (int)mrl.GetCount(); i++ )
+ {
+ int i_options = 0, i_total_options;
+ char **ppsz_options = NULL;
+
+ /* Count the input options */
+ while( i + i_options + 1 < (int)mrl.GetCount() &&
+ ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
+ {
+ i_options++;
+ }
+
+ /* Allocate ppsz_options */
+ for( int j = 0; j < i_options; j++ )
+ {
+ if( !ppsz_options )
+ ppsz_options = (char **)malloc( sizeof(char *) * i_options );
+
+ ppsz_options[j] = strdup( mrl[i + j + 1].mb_str() );
+ }
+
+ i_total_options = i_options;
+
+ /* Get the options from the subtitles dialog */
+ if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
+ {
+ ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
+ (i_total_options + subsfile_mrl.GetCount()) );
+
+ for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
+ {
+ ppsz_options[i_total_options + j] =
+ strdup( subsfile_mrl[j].mb_str() );
+ }
+
+ i_total_options += subsfile_mrl.GetCount();
+ }
+
+ /* Get the options from the v4l dialog */
+/* if( v4l_mrl.GetCount() )
+ {
+ ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
+ (i_total_options + v4l_mrl.GetCount()) );
+
+ for( int j = 0; j < (int)v4l_mrl.GetCount(); j++ )
+ {
+ ppsz_options[i_total_options + j] =
+ strdup( v4l_mrl[j].mb_str() );
+ }
+
+ i_total_options += v4l_mrl.GetCount();
+
+ }
+*/
+ /* Get the options from the stream output dialog */
+ if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
+ {
+ ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
+ (i_total_options + sout_mrl.GetCount()) );
+
+ for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
+ {
+ ppsz_options[i_total_options + j] =
+ strdup( sout_mrl[j].mb_str() );
+ }
+
+ i_total_options += sout_mrl.GetCount();
+
+ }
+
+ playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
+ (const char **)ppsz_options, i_total_options,
+ PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
+
+ /* clean up */
+ for( int j = 0; j < i_total_options; j++ )
+ free( ppsz_options[j] );
+ if( ppsz_options ) free( ppsz_options );
+
+ i += i_options;
+ }
+
+ //TogglePlayButton( PLAYING_S );
+
+ vlc_object_release( p_playlist );
+
+ Hide();
}
void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
{
- EndModal( wxID_CANCEL );
+ Hide();
}
void OpenDialog::OnPageChange( wxNotebookEvent& event )
void OpenDialog::OnMRLChange( wxCommandEvent& event )
{
- mrl = event.GetString();
+ //mrl = SeparateEntries( event.GetString() );
}
/*****************************************************************************
void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
{
- wxFileDialog dialog( this, _("Open file"), "", "", "*.*",
- 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 );
+ if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
UpdateMRL( FILE_ACCESS );
}
}
/*****************************************************************************
* Disc panel event methods.
*****************************************************************************/
-void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
+void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
{
+ if( event.GetId() == DiscTitle_Event )
+ i_disc_title = event.GetInt();
+ else if( event.GetId() == DiscChapter_Event )
+ i_disc_chapter = event.GetInt();
+
UpdateMRL( DISC_ACCESS );
}
{
case 2:
psz_device = config_GetPsz( p_intf, "vcd" );
- disc_device->SetValue( psz_device ? psz_device : "" );
+ disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
break;
default:
psz_device = config_GetPsz( p_intf, "dvd" );
- disc_device->SetValue( psz_device ? psz_device : "" );
+ disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
break;
}
switch( disc_type->GetSelection() )
{
- case 1:
+ case 0:
disc_title->SetRange( 0, 255 );
disc_title->SetValue( 0 );
+ i_disc_title = 0;
break;
default:
disc_title->SetRange( 1, 255 );
disc_title->SetValue( 1 );
+ i_disc_title = 1;
break;
}
+ i_disc_chapter = 1;
disc_chapter->SetRange( 1, 255 );
disc_chapter->SetValue( 1 );
/*****************************************************************************
* Net panel event methods.
*****************************************************************************/
-void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
+void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
{
+ if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
+ {
+ i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
+ }
+
UpdateMRL( NET_ACCESS );
}
UpdateMRL( NET_ACCESS );
}
+/*****************************************************************************
+ * v4l panel event methods.
+ *****************************************************************************/
+void OpenDialog::OnV4LPanelChange( wxCommandEvent& WXUNUSED(event) )
+{
+ UpdateMRL( V4L_ACCESS );
+}
+
+void OpenDialog::OnV4LTypeChange( wxCommandEvent& WXUNUSED(event) )
+{
+ video_device->SetValue( wxU( "/dev/video" ) );
+
+ v4l_button->Enable();
+ video_channel->Disable();
+
+ switch( video_type->GetSelection() )
+ {
+ case 1:
+ video_channel->Enable();
+ video_channel->SetRange( 0, 255 );
+ video_channel->SetValue( 0 );
+ break;
+ case 3:
+ v4l_button->Disable();
+ break;
+ default:
+ break;
+ }
+
+ UpdateMRL( V4L_ACCESS );
+}
+
+void OpenDialog::OnV4LSettingsChange( wxCommandEvent& WXUNUSED(event) )
+{
+ /* Show/hide the open dialog */
+ if( v4l_dialog == NULL )
+ v4l_dialog = new V4LDialog( p_intf, this );
+
+ if( v4l_dialog && v4l_dialog->ShowModal() == wxID_OK )
+ {
+ v4l_mrl = v4l_dialog->GetOptions();
+ }
+
+ UpdateMRL( V4L_ACCESS );
+}
+
+/*****************************************************************************
+ * Subtitles file event methods.
+ *****************************************************************************/
+void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
+{
+ subsfile_button->Enable( event.GetInt() != 0 );
+ if( event.GetInt() && demuxdump_checkbox->IsChecked() )
+ {
+ 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, this );
+
+ if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
+ {
+ subsfile_mrl.Empty();
+ subsfile_mrl.Add( wxString(wxT("sub-file=")) +
+ subsfile_dialog->file_combo->GetValue() );
+ if( subsfile_dialog->encoding_combo )
+ subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
+ subsfile_dialog->encoding_combo->GetValue() );
+ subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
+ subsfile_dialog->delay_spinctrl->GetValue() ) );
+ subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
+ subsfile_dialog->fps_spinctrl->GetValue() ) );
+ }
+}
+
/*****************************************************************************
* Stream output event methods.
*****************************************************************************/
void OpenDialog::OnSoutEnable( wxCommandEvent& event )
{
sout_button->Enable( event.GetInt() != 0 );
- if( !event.GetInt() )
- {
- config_PutPsz( p_intf, "sout", "" );
- }
- else
+ if( event.GetInt() && demuxdump_checkbox->IsChecked() )
{
demuxdump_checkbox->SetValue( 0 );
wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
{
/* Show/hide the open dialog */
- SoutDialog dialog( p_intf, p_main_interface );
+ if( sout_dialog == NULL )
+ sout_dialog = new SoutDialog( p_intf, this );
- if( dialog.ShowModal() == wxID_OK )
+ if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
{
- config_PutPsz( p_intf, "sout", (char *)dialog.mrl.c_str() );
+ sout_mrl = sout_dialog->GetOptions();
}
}
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, _("Save file"), "", "", "*.*", 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 );
}
void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
{
config_PutPsz( p_intf, "demuxdump-file",
- demuxdump_textctrl->GetValue() );
+ demuxdump_textctrl->GetValue().mb_str() );
+}
+
+/*****************************************************************************
+ * Utility functions.
+ *****************************************************************************/
+wxArrayString 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 */
+ if( token.HasMoreTokens() ||
+ entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
+ entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
+ entry.RemoveLast();
+ if( !entry.IsEmpty() ) entries_array.Add( entry );
+ entry.Empty();
+ }
+ else
+ {;}
+ }
+
+ if( !entry.IsEmpty() ) entries_array.Add( entry );
+
+ return entries_array;
}