1 /*****************************************************************************
2 * open.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: open.cpp,v 1.27 2003/06/14 21:18:36 gbazin Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
34 #ifdef WIN32 /* mingw32 hack */
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
42 #include <wx/wxprec.h>
44 #include <wx/notebook.h>
45 #include <wx/textctrl.h>
46 #include <wx/combobox.h>
47 #include <wx/spinctrl.h>
48 #include <wx/statline.h>
49 #include <wx/tokenzr.h>
53 #if defined MODULE_NAME_IS_skins
54 # include "../skins/src/skin_common.h"
57 #include "wxwindows.h"
60 # define wxRB_SINGLE 0
63 /*****************************************************************************
65 *****************************************************************************/
67 /* IDs for the controls and the menu commands */
70 Notebook_Event = wxID_HIGHEST,
82 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event,
83 NetPort1_Event, NetPort2_Event, NetPort3_Event,
84 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
87 SubsFileSettings_Event,
93 DemuxDumpEnable_Event,
94 DemuxDumpBrowse_Event,
97 BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
99 EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
100 EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
102 EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
104 EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
106 /* Events generated by the file panel */
107 EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
108 EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
110 /* Events generated by the disc panel */
111 EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
112 EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
113 EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
114 EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
115 EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
116 EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
118 /* Events generated by the net panel */
119 EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
120 EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
121 EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
122 EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
123 EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
124 EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
125 EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
126 EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
127 EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
128 EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
129 EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
131 /* Events generated by the subtitle file buttons */
132 EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
133 EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
135 /* Events generated by the stream output buttons */
136 EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
137 EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
139 /* Events generated by the demux dump buttons */
140 EVT_CHECKBOX(DemuxDumpEnable_Event, OpenDialog::OnDemuxDumpEnable)
141 EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
142 EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)
146 /*****************************************************************************
148 *****************************************************************************/
149 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
150 int i_access_method ):
151 wxDialog( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
152 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
154 /* Initializations */
156 p_parent = _p_parent;
157 SetIcon( *p_intf->p_sys->p_icon );
160 subsfile_dialog = NULL;
161 demuxdump_dialog = NULL;
163 /* Create a panel to put everything in */
164 wxPanel *panel = new wxPanel( this, -1 );
165 panel->SetAutoLayout( TRUE );
167 /* Create MRL combobox */
168 wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
169 wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
170 wxU(_("Media Resource Locator (MRL)")) );
171 wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
173 wxStaticText *mrl_label = new wxStaticText( panel, -1,
174 wxU(_("Open Target:")) );
175 mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
176 wxPoint(20,25), wxSize(120, -1),
178 mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
179 "the full MRL you want to open.\n""Alternatively, the field will be "
180 "filled automatically when you use the controls below.")) );
182 mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
183 mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
184 mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
187 /* Create Static Text */
188 wxStaticText *label = new wxStaticText( panel, -1,
189 wxU(_("Alternatively, you can build an MRL using one of the "
190 "following predefined targets:")) );
192 /* Create Subtitles File checkox */
193 wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
194 subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
195 wxU(_("Subtitles file")) );
196 subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
197 "Currently only works with AVI files.")) );
198 subsfile_sizer->Add( subsfile_checkbox, 0,
199 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
200 subsfile_button = new wxButton( panel, SubsFileSettings_Event,
201 wxU(_("Settings...")) );
202 subsfile_button->Disable();
204 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
205 if( psz_subsfile && *psz_subsfile )
207 subsfile_checkbox->SetValue(TRUE);
208 subsfile_button->Enable();
210 if( psz_subsfile ) free( psz_subsfile );
212 subsfile_sizer->Add( subsfile_button, 1,
213 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
215 /* Create Stream Output checkox */
216 wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
217 sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
218 wxU(_("Stream output")) );
219 sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
220 sout_sizer->Add( sout_checkbox, 0,
221 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
222 sout_button = new wxButton( panel, SoutSettings_Event,
223 wxU(_("Settings...")) );
224 sout_button->Disable();
226 char *psz_sout = config_GetPsz( p_intf, "sout" );
227 if( psz_sout && *psz_sout )
229 sout_checkbox->SetValue(TRUE);
230 sout_button->Enable();
232 if( psz_sout ) free( psz_sout );
234 sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
236 /* Create Demux Dump checkox */
237 wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
238 demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
239 wxU(_("Capture input stream")) );
240 demuxdump_checkbox->SetToolTip(
241 wxU(_("Capture the stream you are playing to a file")) );
242 demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
243 wxDefaultPosition, wxDefaultSize,
245 demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
246 wxU(_("Browse...")) );
248 char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
249 if( psz_demuxdump && *psz_demuxdump )
251 demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
253 if( psz_demuxdump ) free( psz_demuxdump );
255 demuxdump_textctrl->Disable();
256 demuxdump_button->Disable();
257 demuxdump_sizer->Add( demuxdump_checkbox, 0,
258 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
259 demuxdump_sizer->Add( demuxdump_button, 0,
260 wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 );
261 demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 );
264 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
266 /* Create the buttons */
267 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
268 ok_button->SetDefault();
269 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
272 /* Create notebook */
273 notebook = new wxNotebook( panel, Notebook_Event );
274 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
276 notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
277 i_access_method == FILE_ACCESS );
278 notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
279 i_access_method == DISC_ACCESS );
280 notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
281 i_access_method == NET_ACCESS );
283 notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
284 i_access_method == SAT_ACCESS );
287 /* Update Disc panel */
288 wxCommandEvent dummy_event;
289 OnDiscTypeChange( dummy_event );
291 /* Update Net panel */
292 dummy_event.SetId( NetRadio1_Event );
293 OnNetTypeChange( dummy_event );
296 wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
297 OnPageChange( event );
299 /* Place everything in sizers */
300 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
301 button_sizer->Add( ok_button, 0, wxALL, 5 );
302 button_sizer->Add( cancel_button, 0, wxALL, 5 );
303 button_sizer->Layout();
304 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
305 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
306 panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
307 panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
308 panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
309 panel_sizer->Add( subsfile_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
310 panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
311 panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
312 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
313 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
314 panel_sizer->Layout();
315 panel->SetSizerAndFit( panel_sizer );
316 main_sizer->Add( panel, 1, wxGROW, 0 );
317 main_sizer->Layout();
318 SetSizerAndFit( main_sizer );
321 OpenDialog::~OpenDialog()
324 if( file_dialog ) delete file_dialog;
325 if( sout_dialog ) delete sout_dialog;
326 if( subsfile_dialog ) delete subsfile_dialog;
327 if( demuxdump_dialog ) delete demuxdump_dialog;
330 int OpenDialog::ShowModal( int i_access_method )
332 notebook->SetSelection( i_access_method );
333 return wxDialog::ShowModal();
336 int OpenDialog::ShowModal()
338 return wxDialog::ShowModal();
341 /*****************************************************************************
343 *****************************************************************************/
344 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
346 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
349 wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
351 file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
352 wxPoint(20,25), wxSize(200, -1), 0, NULL );
353 wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
354 wxU(_("Browse...")) );
355 sizer->Add( file_combo, 1, wxALL, 5 );
356 sizer->Add( browse_button, 0, wxALL, 5 );
358 panel->SetSizerAndFit( sizer );
362 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
364 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
367 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
368 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
370 static const wxString disc_type_array[] =
372 wxU(_("DVD (menus support)")),
379 disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
380 wxDefaultPosition, wxDefaultSize,
381 WXSIZEOF(disc_type_array), disc_type_array,
382 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
383 sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
385 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
386 disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
387 wxDefaultPosition, wxDefaultSize,
390 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
391 sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
393 label = new wxStaticText( panel, -1, wxU(_("Title")) );
394 disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
396 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
397 sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
399 label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
400 disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
401 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
402 sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
403 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
405 panel->SetSizerAndFit( sizer_row );
409 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
412 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
415 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
416 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
418 static const wxString net_type_array[] =
421 wxU(_("UDP/RTP Multicast")),
422 wxU(_("HTTP/FTP/MMS"))
427 net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
429 wxDefaultPosition, wxDefaultSize,
432 net_subpanels[i] = new wxPanel( panel, -1,
433 wxDefaultPosition, wxDefaultSize );
437 wxFlexGridSizer *subpanel_sizer;
439 int val = config_GetInt( p_intf, "server-port" );
440 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
441 label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
442 net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
443 wxString::Format(wxT("%d"), val),
444 wxDefaultPosition, wxDefaultSize,
448 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
449 subpanel_sizer->Add( net_ports[0], 1,
450 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
451 net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
452 net_radios[0]->SetValue( TRUE );
454 /* UDP/RTP Multicast row */
455 subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
456 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
457 net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
458 wxDefaultPosition, wxDefaultSize,
460 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
461 subpanel_sizer->Add( net_addrs[1], 1,
462 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
464 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
465 net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
466 wxString::Format(wxT("%d"), val),
467 wxDefaultPosition, wxDefaultSize,
471 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
472 subpanel_sizer->Add( net_ports[1], 1,
473 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
474 net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
477 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
478 label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
479 net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
480 wxDefaultPosition, wxSize( 200, -1 ),
482 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
483 subpanel_sizer->Add( net_addrs[2], 1,
484 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
485 net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
487 /* Stuff everything into the main panel */
490 sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
492 sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
493 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
496 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
498 panel->SetSizerAndFit( sizer_row );
502 wxPanel *OpenDialog::SatPanel( wxWindow* parent )
504 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
509 void OpenDialog::UpdateMRL( int i_access_method )
511 wxString demux, mrltemp;
513 i_current_access_method = i_access_method;
515 /* Check if the user asked for demuxdump */
516 if( demuxdump_checkbox->GetValue() )
518 demux = wxT("/demuxdump");
521 switch( i_access_method )
524 //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
525 mrltemp = file_combo->GetValue();
528 mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
529 disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
530 disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
532 + disc_device->GetLineText(0)
533 + wxString::Format( wxT("@%d:%d"),
534 disc_title->GetValue(),
535 disc_chapter->GetValue() );
541 if( net_ports[0]->GetValue() !=
542 config_GetInt( p_intf, "server-port" ) )
544 mrltemp = wxT("udp") + demux +
545 wxString::Format( wxT("://@:%d"),
546 net_ports[0]->GetValue() );
550 mrltemp = wxT("udp") + demux + wxT("://");
555 mrltemp = wxT("udp") + demux + wxT("://@") +
556 net_addrs[1]->GetLineText(0);
557 if( net_ports[1]->GetValue() !=
558 config_GetInt( p_intf, "server-port" ) )
560 mrltemp = mrltemp + wxString::Format( wxT(":%d"),
561 net_ports[1]->GetValue() );
567 mrltemp = wxT("http") + demux + wxT("://") +
568 net_addrs[2]->GetLineText(0);
573 mrltemp = wxT("satellite") + demux + wxT("://");
579 mrl_combo->SetValue( mrltemp );
582 wxArrayString OpenDialog::SeparateEntries( wxString entries )
584 vlc_bool_t b_quotes_mode = VLC_FALSE;
586 wxArrayString entries_array;
589 wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
591 while( token.HasMoreTokens() )
593 entry += token.GetNextToken();
595 if( entry.IsEmpty() ) continue;
597 if( !b_quotes_mode && entry.Last() == wxT('\"') )
599 /* Enters quotes mode */
601 b_quotes_mode = VLC_TRUE;
603 else if( b_quotes_mode && entry.Last() == wxT('\"') )
605 /* Finished the quotes mode */
607 if( !entry.IsEmpty() ) entries_array.Add( entry );
609 b_quotes_mode = VLC_FALSE;
611 else if( !b_quotes_mode && entry.Last() != wxT('\"') )
613 /* we found a non-quoted standalone string */
614 if( token.HasMoreTokens() ||
615 entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
616 entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
618 if( !entry.IsEmpty() ) entries_array.Add( entry );
625 if( !entry.IsEmpty() ) entries_array.Add( entry );
627 return entries_array;
630 /*****************************************************************************
632 *****************************************************************************/
633 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
635 mrl = SeparateEntries( mrl_combo->GetValue() );
636 mrl_combo->Append( mrl_combo->GetValue() );
637 if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
638 mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
642 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
644 EndModal( wxID_CANCEL );
647 void OpenDialog::OnPageChange( wxNotebookEvent& event )
649 UpdateMRL( event.GetSelection() );
652 void OpenDialog::OnMRLChange( wxCommandEvent& event )
654 //mrl = SeparateEntries( event.GetString() );
657 /*****************************************************************************
658 * File panel event methods.
659 *****************************************************************************/
660 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
662 UpdateMRL( FILE_ACCESS );
665 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
667 if( file_dialog == NULL )
668 file_dialog = new wxFileDialog( this, wxU(_("Open file")),
669 wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
671 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
676 file_dialog->GetPaths( paths );
678 for( size_t i = 0; i < paths.GetCount(); i++ )
680 if( paths[i].Find( wxT(' ') ) >= 0 )
681 path += wxT("\"") + paths[i] + wxT("\" ");
683 path += paths[i] + wxT(" ");
686 file_combo->SetValue( path );
687 file_combo->Append( path );
688 if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
689 UpdateMRL( FILE_ACCESS );
693 /*****************************************************************************
694 * Disc panel event methods.
695 *****************************************************************************/
696 void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
698 UpdateMRL( DISC_ACCESS );
701 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
705 switch( disc_type->GetSelection() )
708 psz_device = config_GetPsz( p_intf, "vcd" );
709 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
713 psz_device = config_GetPsz( p_intf, "dvd" );
714 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
718 if( psz_device ) free( psz_device );
720 switch( disc_type->GetSelection() )
723 disc_title->SetRange( 0, 255 );
724 disc_title->SetValue( 0 );
728 disc_title->SetRange( 1, 255 );
729 disc_title->SetValue( 1 );
733 disc_chapter->SetRange( 1, 255 );
734 disc_chapter->SetValue( 1 );
736 UpdateMRL( DISC_ACCESS );
739 /*****************************************************************************
740 * Net panel event methods.
741 *****************************************************************************/
742 void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
744 UpdateMRL( NET_ACCESS );
747 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
751 i_net_type = event.GetId() - NetRadio1_Event;
755 net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
756 net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
759 UpdateMRL( NET_ACCESS );
762 /*****************************************************************************
763 * Subtitles file event methods.
764 *****************************************************************************/
765 void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
767 subsfile_button->Enable( event.GetInt() != 0 );
768 if( !event.GetInt() )
770 config_PutPsz( p_intf, "sub-file", "" );
774 demuxdump_checkbox->SetValue( 0 );
775 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
777 OnDemuxDumpEnable( event );
781 void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
783 /* Show/hide the open dialog */
784 if( subsfile_dialog == NULL )
785 subsfile_dialog = new SubsFileDialog( p_intf, p_parent );
787 if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
789 config_PutPsz( p_intf, "sub-file",
790 (const char *)subsfile_dialog->file_combo->GetValue().mb_str() );
791 config_PutInt( p_intf, "sub-delay",
792 subsfile_dialog->delay_spinctrl->GetValue() );
793 config_PutFloat( p_intf, "sub-fps",
794 subsfile_dialog->fps_spinctrl->GetValue() );
798 /*****************************************************************************
799 * Stream output event methods.
800 *****************************************************************************/
801 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
803 sout_button->Enable( event.GetInt() != 0 );
804 if( !event.GetInt() )
806 config_PutPsz( p_intf, "sout", "" );
810 demuxdump_checkbox->SetValue( 0 );
811 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
813 OnDemuxDumpEnable( event );
817 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
819 /* Show/hide the open dialog */
820 if( sout_dialog == NULL )
821 sout_dialog = new SoutDialog( p_intf, p_parent );
823 if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
825 config_PutPsz( p_intf, "sout",
826 (const char *)sout_dialog->mrl.mb_str() );
830 /*****************************************************************************
831 * Demux dump event methods.
832 *****************************************************************************/
833 void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
835 demuxdump_textctrl->Enable( event.GetInt() != 0 );
836 demuxdump_button->Enable( event.GetInt() != 0 );
840 sout_checkbox->SetValue( 0 );
841 subsfile_checkbox->SetValue( 0 );
842 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
844 OnSoutEnable( event );
845 OnSubsFileEnable( event );
848 UpdateMRL( i_current_access_method );
851 void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
853 if( demuxdump_dialog == NULL )
854 demuxdump_dialog = new wxFileDialog( this, wxU(_("Save file")),
855 wxT(""), wxT(""), wxT("*"), wxSAVE );
857 if( demuxdump_dialog && demuxdump_dialog->ShowModal() == wxID_OK )
859 demuxdump_textctrl->SetValue( demuxdump_dialog->GetPath() );
860 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
861 OnDemuxDumpChange( event );
865 void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
867 config_PutPsz( p_intf, "demuxdump-file",
868 demuxdump_textctrl->GetValue().mb_str() );