1 /*****************************************************************************
2 * open.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2005 VideoLAN (Centrale Réseaux) and its contributors
7 * Authors: Gildas Bazin <gbazin@videolan.org>
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 #include <wx/combobox.h>
35 #include <wx/statline.h>
36 #include <wx/tokenzr.h>
42 #include "wxwindows.h"
43 #include "preferences_widgets.h"
46 # define wxRB_SINGLE 0
49 /*****************************************************************************
51 *****************************************************************************/
53 /* IDs for the controls and the menu commands */
56 Notebook_Event = wxID_HIGHEST,
69 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
70 NetPort1_Event, NetPort2_Event, NetPort3_Event,
71 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
72 NetForceIPv6_Event, NetTimeshift_Event,
75 SubsFileSettings_Event,
86 BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
88 EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
89 EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
91 EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
93 EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
95 /* Events generated by the file panel */
96 EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
97 EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
99 /* Events generated by the disc panel */
100 EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
101 EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
102 EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
103 EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
104 EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChangeSpin)
105 EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
106 EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChangeSpin)
107 EVT_TEXT(DiscSub_Event, OpenDialog::OnDiscPanelChange)
108 EVT_SPINCTRL(DiscSub_Event, OpenDialog::OnDiscPanelChangeSpin)
110 /* Events generated by the net panel */
111 EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
112 EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
113 EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
114 EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
115 EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
116 EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChangeSpin)
117 EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
118 EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChangeSpin)
119 EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
120 EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChangeSpin)
121 EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
122 EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
123 EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
124 EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
125 EVT_CHECKBOX(NetTimeshift_Event, OpenDialog::OnNetPanelChange)
127 /* Events generated by the subtitle file buttons */
128 EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
129 EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
131 /* Events generated by the stream output buttons */
132 EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
133 EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
135 /* Events generated by the caching button */
136 EVT_CHECKBOX(CachingEnable_Event, OpenDialog::OnCachingEnable)
137 EVT_TEXT(CachingChange_Event, OpenDialog::OnCachingChange)
138 EVT_SPINCTRL(CachingChange_Event, OpenDialog::OnCachingChangeSpin)
140 /* Hide the window when the user closes the window */
141 EVT_CLOSE(OpenDialog::OnClose)
145 /*****************************************************************************
147 *****************************************************************************/
148 WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
150 class AutoBuiltPanel : public wxPanel
155 AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *,
158 virtual ~AutoBuiltPanel() {}
160 void UpdateAdvancedMRL();
163 ArrayOfConfigControls config_array;
164 ArrayOfConfigControls advanced_config_array;
165 wxComboBox *p_advanced_mrl_combo;
168 intf_thread_t *p_intf;
169 OpenDialog *p_open_dialog;
171 void OnAdvanced( wxCommandEvent& event );
172 wxDialog *p_advanced_dialog;
174 DECLARE_EVENT_TABLE();
177 BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
178 EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
181 static void AutoBuildCallback( void *p_data )
183 ((OpenDialog *)p_data)->UpdateMRL();
186 static void AutoBuildAdvancedCallback( void *p_data )
188 ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
191 AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
192 intf_thread_t *_p_intf,
193 const module_t *p_module )
194 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
195 name( wxU(p_module->psz_object_name) ),
196 p_advanced_mrl_combo( NULL ),
197 p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
199 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
200 module_config_t *p_item = p_module->p_config;
201 bool b_advanced = false;
205 if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
208 if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
211 ConfigControl *control =
212 CreateConfigControl( VLC_OBJECT(p_intf), p_item, this );
214 config_array.Add( control );
216 /* Don't add items that were not recognized */
217 if( control == NULL ) continue;
219 control->SetUpdateCallback( AutoBuildCallback, (void *)dialog );
221 sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
223 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
228 new wxButton( this, AdvancedOptions_Event,
229 wxU(_("Advanced options...")) );
230 sizer->Add( button, 0, wxALL, 5 );
232 /* Build the advanced dialog */
234 new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
235 wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
236 wxDefaultPosition, wxDefaultSize,
237 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
239 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
241 /* Create MRL combobox */
242 wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
243 wxStaticBox *mrl_box =
244 new wxStaticBox( p_advanced_dialog, -1,
245 wxU(_("Advanced options")) );
246 wxStaticBoxSizer *mrl_sizer =
247 new wxStaticBoxSizer( mrl_box, wxHORIZONTAL );
248 wxStaticText *mrl_label =
249 new wxStaticText( p_advanced_dialog, -1, wxU(_("Options:")) );
250 p_advanced_mrl_combo =
251 new wxComboBox( p_advanced_dialog, MRL_Event, wxT(""),
252 wxDefaultPosition, wxDefaultSize );
253 mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
254 mrl_sizer->Add( p_advanced_mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
255 mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
256 sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 );
258 /* Add advanced options to panel */
259 module_config_t *p_item = p_module->p_config;
262 if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced )
265 ConfigControl *control =
266 CreateConfigControl( VLC_OBJECT(p_intf), p_item,
269 advanced_config_array.Add( control );
271 /* Don't add items that were not recognized */
272 if( control == NULL ) continue;
274 control->SetUpdateCallback( AutoBuildAdvancedCallback,
277 sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
279 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
282 wxPanel *dummy_panel = new wxPanel( p_advanced_dialog, -1 );
283 sizer->Add( dummy_panel, 1 );
284 wxStaticLine *static_line =
285 new wxStaticLine( p_advanced_dialog, wxID_OK );
286 sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
289 wxButton *ok_button =
290 new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
291 ok_button->SetDefault();
292 wxButton *cancel_button =
293 new wxButton( p_advanced_dialog, wxID_CANCEL, wxU(_("Cancel")) );
294 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
295 button_sizer->Add( ok_button, 0, wxALL, 5 );
296 button_sizer->Add( cancel_button, 0, wxALL, 5 );
297 button_sizer->Layout();
298 sizer->Add( button_sizer, 0, wxALL, 0 );
300 sizer->SetMinSize( 400, -1 );
301 p_advanced_dialog->SetSizerAndFit( sizer );
304 this->SetSizerAndFit( sizer );
307 void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
309 if( p_advanced_dialog->ShowModal() == wxID_OK )
312 p_open_dialog->UpdateMRL();
316 void AutoBuiltPanel::UpdateAdvancedMRL()
320 for( int i = 0; i < (int)advanced_config_array.GetCount(); i++ )
322 ConfigControl *control = advanced_config_array.Item(i);
324 mrltemp += (i ? wxT(" :") : wxT(":"));
326 if( control->GetType() == CONFIG_ITEM_BOOL &&
327 !control->GetIntValue() ) mrltemp += wxT("no-");
329 mrltemp += control->GetName();
331 switch( control->GetType() )
333 case CONFIG_ITEM_STRING:
334 case CONFIG_ITEM_FILE:
335 case CONFIG_ITEM_DIRECTORY:
336 case CONFIG_ITEM_MODULE:
337 mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
339 case CONFIG_ITEM_INTEGER:
341 wxString::Format( wxT("=%i"), control->GetIntValue() );
343 case CONFIG_ITEM_FLOAT:
345 wxString::Format(wxT("=%f"), control->GetFloatValue());
350 p_advanced_mrl_combo->SetValue( mrltemp );
353 /*****************************************************************************
355 *****************************************************************************/
356 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
357 int i_access_method, int i_arg ):
358 wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
359 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
361 OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
364 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
365 int i_access_method, int i_arg, int _i_method ):
366 wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
367 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
369 /* Initializations */
370 i_method = _i_method;
372 p_parent = _p_parent;
373 SetIcon( *p_intf->p_sys->p_icon );
375 i_disc_type_selection = 0;
380 subsfile_dialog = NULL;
381 b_disc_device_changed = false;
383 /* Create a panel to put everything in */
384 wxPanel *panel = new wxPanel( this, -1 );
385 panel->SetAutoLayout( TRUE );
387 /* Create MRL combobox */
388 wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
389 wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
390 wxU(_("Media Resource Locator (MRL)")) );
391 wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
393 wxStaticText *mrl_label = new wxStaticText( panel, -1,
395 mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
396 wxPoint(20,25), wxSize(120, -1) );
397 mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
398 "the full MRL you want to open.\n""Alternatively, the field will be "
399 "filled automatically when you use the controls below.")) );
401 mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
402 mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
403 mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
406 /* Create Static Text */
407 wxStaticText *label = new wxStaticText( panel, -1,
408 wxU(_("Alternatively, you can build an MRL using one of the "
409 "following predefined targets:")) );
411 wxFlexGridSizer *common_opt_sizer = new wxFlexGridSizer( 5, 1, 20 );
413 if( i_method == OPEN_NORMAL )
415 /* Create Stream Output checkox */
416 sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
417 wxU(_("Stream output")) );
418 sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
419 common_opt_sizer->Add( sout_checkbox, 0,
420 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
422 sout_button = new wxButton( panel, SoutSettings_Event,
423 wxU(_("Settings...")) );
424 sout_button->Disable();
426 char *psz_sout = config_GetPsz( p_intf, "sout" );
427 if( psz_sout && *psz_sout )
429 sout_checkbox->SetValue(TRUE);
430 sout_button->Enable();
431 subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
433 if( psz_sout ) free( psz_sout );
435 common_opt_sizer->Add( sout_button, 1, wxALIGN_LEFT |
436 wxALIGN_CENTER_VERTICAL );
438 common_opt_sizer->Add( new wxPanel( this, -1 ), 1,
439 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
442 /* Create caching options */
443 caching_checkbox = new wxCheckBox( panel, CachingEnable_Event,
445 caching_checkbox->SetToolTip( wxU(_("Change the default caching value "
446 "(in milliseconds)")) );
447 common_opt_sizer->Add( caching_checkbox, 0,
448 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
449 caching_value = new wxSpinCtrl( panel, CachingChange_Event );
450 caching_value->SetRange( 0, 1000000 );
451 caching_value->Disable();
452 common_opt_sizer->Add( caching_value, 0,
453 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
456 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
458 /* Create the buttons */
459 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
460 ok_button->SetDefault();
461 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
464 /* Create notebook */
465 notebook = new wxNotebook( panel, Notebook_Event );
467 #if (!wxCHECK_VERSION(2,5,0))
468 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
471 notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
472 i_access_method == FILE_ACCESS );
473 notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
474 i_access_method == DISC_ACCESS );
475 notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
476 i_access_method == NET_ACCESS );
478 module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" );
481 AutoBuiltPanel *autopanel =
482 new AutoBuiltPanel( notebook, this, p_intf, p_module );
483 input_tab_array.Add( autopanel );
484 notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
485 p_module->psz_shortname : p_module->psz_object_name ),
486 i_access_method == CAPTURE_ACCESS );
489 p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" );
492 AutoBuiltPanel *autopanel =
493 new AutoBuiltPanel( notebook, this, p_intf, p_module );
494 input_tab_array.Add( autopanel );
495 notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
496 p_module->psz_shortname : p_module->psz_object_name ),
497 i_access_method == CAPTURE_ACCESS );
500 p_module = config_FindModule( VLC_OBJECT(p_intf), "dvb" );
503 AutoBuiltPanel *autopanel =
504 new AutoBuiltPanel( notebook, this, p_intf, p_module );
505 input_tab_array.Add( autopanel );
506 notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
507 p_module->psz_shortname : p_module->psz_object_name ),
508 i_access_method == CAPTURE_ACCESS );
511 p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
514 AutoBuiltPanel *autopanel =
515 new AutoBuiltPanel( notebook, this, p_intf, p_module );
516 input_tab_array.Add( autopanel );
517 notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
518 p_module->psz_shortname : p_module->psz_object_name ),
519 i_access_method == CAPTURE_ACCESS );
522 /* Update Disc panel */
523 wxCommandEvent dummy_event;
524 OnDiscTypeChange( dummy_event );
526 /* Update Net panel */
527 dummy_event.SetId( NetRadio1_Event );
528 OnNetTypeChange( dummy_event );
531 wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
532 OnPageChange( event );
534 /* Place everything in sizers */
535 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
536 button_sizer->Add( ok_button, 0, wxALL, 5 );
537 button_sizer->Add( cancel_button, 0, wxALL, 5 );
538 button_sizer->Layout();
539 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
540 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
541 panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
542 panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
543 #if (!wxCHECK_VERSION(2,5,0))
544 panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
546 panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
548 panel_sizer->Add( common_opt_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
549 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
550 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
551 panel_sizer->Layout();
552 panel->SetSizerAndFit( panel_sizer );
553 main_sizer->Add( panel, 1, wxGROW, 0 );
554 main_sizer->Layout();
555 SetSizerAndFit( main_sizer );
558 OpenDialog::~OpenDialog()
561 if( file_dialog ) delete file_dialog;
562 if( sout_dialog ) delete sout_dialog;
563 if( subsfile_dialog ) delete subsfile_dialog;
566 int OpenDialog::Show( int i_access_method, int i_arg )
568 notebook->SetSelection( i_access_method );
569 int i_ret = wxDialog::Show();
576 int OpenDialog::Show()
578 int i_ret = wxDialog::Show();
584 /*****************************************************************************
586 *****************************************************************************/
587 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
589 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
592 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
594 /* Create browse file line */
595 wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
597 file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
598 wxPoint(20,25), wxSize(200, -1) );
599 wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
600 wxU(_("Browse...")) );
601 file_sizer->Add( file_combo, 1, wxALL, 5 );
602 file_sizer->Add( browse_button, 0, wxALL, 5 );
604 /* Create Subtitles File checkox */
605 wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
606 subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
607 wxU(_("Subtitle options")) );
608 subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
609 subsfile_sizer->Add( subsfile_checkbox, 0,
610 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
611 subsfile_button = new wxButton( panel, SubsFileSettings_Event,
612 wxU(_("Settings...")) );
613 subsfile_button->Disable();
615 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
616 if( psz_subsfile && *psz_subsfile )
618 subsfile_checkbox->SetValue(TRUE);
619 subsfile_button->Enable();
620 subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
622 if( psz_subsfile ) free( psz_subsfile );
624 subsfile_sizer->Add( subsfile_button, 1,
625 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
627 sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
628 sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
629 panel->SetSizerAndFit( sizer );
633 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
635 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
638 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
639 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
641 static const wxString disc_type_array[] =
643 wxU(_("DVD (menus)")),
649 disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
650 wxDefaultPosition, wxDefaultSize,
651 WXSIZEOF(disc_type_array), disc_type_array,
652 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
654 sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
656 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
657 disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
658 wxDefaultPosition, wxDefaultSize,
661 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
662 sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
664 disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
665 disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
666 sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
667 sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
669 disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
670 disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
671 sizer->Add( disc_chapter_label, 0,
672 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
673 sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
675 disc_sub_label = new wxStaticText( panel, -1, wxU(_("Subtitles track")) );
676 disc_sub = new wxSpinCtrl( panel, DiscSub_Event );
677 sizer->Add( disc_sub_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
678 sizer->Add( disc_sub, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
679 disc_sub->SetRange( -1, 255 );
680 i_disc_sub = config_GetInt( p_intf, "sub-track" );
681 disc_sub->SetValue( i_disc_sub );
683 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
685 panel->SetSizerAndFit( sizer_row );
689 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
692 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
695 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
696 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
698 static const wxString net_type_array[] =
701 wxU(_("UDP/RTP Multicast")),
702 wxU(_("HTTP/HTTPS/FTP/MMS")),
708 net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
710 wxDefaultPosition, wxDefaultSize,
713 net_subpanels[i] = new wxPanel( panel, -1,
714 wxDefaultPosition, wxDefaultSize );
718 net_timeshift = new wxCheckBox( panel, NetTimeshift_Event,
719 wxU(_("Allow timeshifting")) );
722 wxFlexGridSizer *subpanel_sizer;
724 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
725 subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
726 label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
727 net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
728 wxString::Format(wxT("%d"), i_net_ports[0]),
729 wxDefaultPosition, wxDefaultSize,
731 0, 65535, i_net_ports[0] );
733 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
734 subpanel_sizer->Add( net_ports[0], 1,
735 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
736 net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
737 wxU(_("Force IPv6")));
738 subpanel_sizer->Add( net_ipv6, 0,
739 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
740 net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
741 net_radios[0]->SetValue( TRUE );
743 /* UDP/RTP Multicast row */
744 subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
745 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
746 net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
747 wxDefaultPosition, wxDefaultSize,
749 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
750 subpanel_sizer->Add( net_addrs[1], 1,
751 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
753 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
754 i_net_ports[1] = i_net_ports[0];
755 net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
756 wxString::Format(wxT("%d"), i_net_ports[1]),
757 wxDefaultPosition, wxDefaultSize,
759 0, 65535, i_net_ports[1] );
761 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
762 subpanel_sizer->Add( net_ports[1], 1,
763 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
764 net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
766 /* HTTP and RTSP rows */
769 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
770 label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
771 net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
772 (i == 2) ? wxT("") : wxT("rtsp://"),
773 wxDefaultPosition, wxSize( 200, -1 ),
775 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
776 subpanel_sizer->Add( net_addrs[i], 1,
777 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
778 net_subpanels[i]->SetSizerAndFit( subpanel_sizer );
781 /* Stuff everything into the main panel */
784 sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
786 sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
787 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
789 sizer->Add( net_timeshift, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
792 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
794 panel->SetSizerAndFit( sizer_row );
798 void OpenDialog::UpdateMRL()
800 UpdateMRL( i_current_access_method );
803 void OpenDialog::UpdateMRL( int i_access_method )
805 wxString mrltemp, caching_name;
807 i_current_access_method = i_access_method;
809 switch( i_access_method )
812 mrltemp = file_combo->GetValue();
813 caching_name = wxT("file-caching");
817 i_disc_type_selection = disc_type->GetSelection();
819 switch ( i_disc_type_selection )
821 case 0: /* DVD with menus */
822 case 1: /* DVD without menus */
823 if( i_disc_type_selection == 0 )
825 mrltemp = wxT("dvd://") + disc_device->GetValue();
826 caching_name = wxT("dvdnav-caching");
830 mrltemp = wxT("dvdsimple://") + disc_device->GetValue();
831 caching_name = wxT("dvdread-caching");
834 if( i_disc_title > 0 )
836 mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
838 if( i_disc_chapter > 0 )
839 mrltemp += wxString::Format( wxT(":%d"), i_disc_chapter );
842 if( i_disc_sub >= 0 )
843 mrltemp += wxString::Format( wxT(" :sub-track=%d"),
847 case 2: /* VCD of some sort */
849 mrltemp = wxT("vcdx://") + disc_device->GetValue();
850 if( i_disc_title > 0 )
851 mrltemp += wxString::Format( wxT("@%c%d"),
852 config_GetInt( p_intf, "vcdx-PBC" )
853 ? 'P' : 'E', i_disc_title );
855 mrltemp = wxT("vcd://") + disc_device->GetValue();
856 if( i_disc_title > 0 )
857 mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
860 if( i_disc_sub >= 0 )
861 mrltemp += wxString::Format( wxT(" :sub-track=%d"),
864 caching_name = wxT("vcd-caching");
874 + disc_device->GetValue();
875 if( i_disc_title > 0 )
876 mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
878 caching_name = wxT("cdda-caching");
882 msg_Err( p_intf, "invalid selection (%d)",
883 disc_type->GetSelection() );
892 mrltemp = wxT("udp://@");
893 if ( net_ipv6->GetValue() )
895 mrltemp += wxT("[::]");
897 if( i_net_ports[0] !=
898 config_GetInt( p_intf, "server-port" ) )
900 mrltemp += wxString::Format( wxT(":%d"), i_net_ports[0] );
903 caching_name = wxT("udp-caching");
907 mrltemp = wxT("udp://@");
908 if ((net_addrs[1]->GetLineText(0).Find (':') != -1)
909 && (net_addrs[1]->GetLineText(0)[0u] != '['))
911 /* automatically adds '[' and ']' to IPv6 addresses */
912 mrltemp += wxT("[") + net_addrs[1]->GetLineText(0)
917 mrltemp += net_addrs[1]->GetLineText(0);
919 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
921 mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
924 caching_name = wxT("udp-caching");
929 if( net_addrs[2]->GetLineText(0).Find(wxT("://")) == -1 )
930 mrltemp = wxT("http://");
932 mrltemp += net_addrs[2]->GetLineText(0);
934 caching_name = wxT("http-caching");
939 if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
941 mrltemp = wxT("rtsp://");
943 mrltemp += net_addrs[3]->GetLineText(0);
945 caching_name = wxT("rtsp-caching");
948 if( net_timeshift->IsEnabled() && net_timeshift->IsChecked() )
949 mrltemp += wxT(" :access-filter=timeshift");
954 int i_item = i_access_method - MAX_ACCESS;
956 if( i_item < 0 || i_item >= (int)input_tab_array.GetCount() )
959 AutoBuiltPanel *input_panel = input_tab_array.Item( i_item );
961 mrltemp = input_panel->name + wxT("://");
963 for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
965 ConfigControl *control = input_panel->config_array.Item(i);
967 mrltemp += wxT(" :");
969 if( control->GetType() == CONFIG_ITEM_BOOL &&
970 !control->GetIntValue() ) mrltemp += wxT("no-");
972 mrltemp += control->GetName();
974 switch( control->GetType() )
976 case CONFIG_ITEM_STRING:
977 case CONFIG_ITEM_FILE:
978 case CONFIG_ITEM_DIRECTORY:
979 case CONFIG_ITEM_MODULE:
980 mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
982 case CONFIG_ITEM_INTEGER:
984 wxString::Format( wxT("=%i"), control->GetIntValue() );
986 case CONFIG_ITEM_FLOAT:
988 wxString::Format(wxT("=%f"), control->GetFloatValue());
993 if( input_panel->p_advanced_mrl_combo &&
994 input_panel->p_advanced_mrl_combo->GetValue() )
996 mrltemp += wxT(" ") +
997 input_panel->p_advanced_mrl_combo->GetValue();
1003 if( caching_name.size() )
1005 if( caching_value->IsEnabled() )
1007 mrltemp += wxT(" :") + caching_name +
1008 wxString::Format( wxT("=%d"), i_caching );
1012 int i_value = config_GetInt( p_intf, caching_name.mb_str() );
1013 caching_value->SetValue( i_value );
1017 mrl_combo->SetValue( mrltemp );
1020 /*****************************************************************************
1022 *****************************************************************************/
1023 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
1025 mrl = SeparateEntries( mrl_combo->GetValue() );
1026 mrl_combo->Append( mrl_combo->GetValue() );
1027 if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
1028 mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
1030 if( i_method == OPEN_STREAM )
1032 if( IsModal() ) EndModal( wxID_OK );
1037 /* Update the playlist */
1038 playlist_t *p_playlist =
1039 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1041 if( p_playlist == NULL ) return;
1043 for( int i = 0; i < (int)mrl.GetCount(); i++ )
1045 vlc_bool_t b_start = !i && i_open_arg;
1046 playlist_item_t *p_item =
1047 playlist_ItemNew( p_intf, (const char*)mrl[i].mb_str(),
1048 (const char *)mrl[i].mb_str() );
1050 /* Insert options */
1051 while( i + 1 < (int)mrl.GetCount() &&
1052 ((const char *)mrl[i + 1].mb_str())[0] == ':' )
1054 playlist_ItemAddOption( p_item, mrl[i + 1].mb_str() );
1058 /* Get the options from the subtitles dialog */
1059 if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
1061 for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
1063 playlist_ItemAddOption( p_item, subsfile_mrl[j].mb_str() );
1067 /* Get the options from the stream output dialog */
1068 if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
1070 for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
1072 playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() );
1076 playlist_AddItem( p_playlist, p_item,
1077 PLAYLIST_APPEND, PLAYLIST_END );
1081 playlist_Control( p_playlist, PLAYLIST_ITEMPLAY , p_item );
1085 vlc_object_release( p_playlist );
1089 if( IsModal() ) EndModal( wxID_OK );
1092 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
1094 wxCloseEvent cevent;
1098 void OpenDialog::OnClose( wxCloseEvent& WXUNUSED(event) )
1102 if( IsModal() ) EndModal( wxID_CANCEL );
1105 void OpenDialog::OnPageChange( wxNotebookEvent& event )
1107 UpdateMRL( event.GetSelection() );
1110 void OpenDialog::OnMRLChange( wxCommandEvent& event )
1112 //mrl = SeparateEntries( event.GetString() );
1115 /*****************************************************************************
1116 * File panel event methods.
1117 *****************************************************************************/
1118 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
1120 UpdateMRL( FILE_ACCESS );
1123 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
1125 if( file_dialog == NULL )
1126 file_dialog = new wxFileDialog( this, wxU(_("Open File")),
1127 wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
1129 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
1131 wxArrayString paths;
1134 file_dialog->GetPaths( paths );
1136 for( size_t i = 0; i < paths.GetCount(); i++ )
1138 if( paths[i].Find( wxT(' ') ) >= 0 )
1139 path += wxT("\"") + paths[i] + wxT("\" ");
1141 path += paths[i] + wxT(" ");
1144 file_combo->SetValue( path );
1145 file_combo->Append( path );
1146 if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
1147 UpdateMRL( FILE_ACCESS );
1151 /*****************************************************************************
1152 * Disc panel event methods.
1153 *****************************************************************************/
1154 void OpenDialog::OnDiscPanelChangeSpin( wxSpinEvent& event )
1156 wxCommandEvent cevent;
1157 cevent.SetId(event.GetId());
1158 cevent.SetInt(event.GetPosition());
1159 OnDiscPanelChange(cevent);
1162 void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
1164 if( event.GetId() == DiscTitle_Event ) i_disc_title = event.GetInt();
1165 if( event.GetId() == DiscChapter_Event ) i_disc_chapter = event.GetInt();
1166 if( event.GetId() == DiscSub_Event ) i_disc_sub = event.GetInt();
1168 UpdateMRL( DISC_ACCESS );
1171 void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
1175 switch( disc_type->GetSelection() )
1178 psz_device = config_GetPsz( p_intf, "cd-audio" );
1182 psz_device = config_GetPsz( p_intf, "vcd" );
1186 psz_device = config_GetPsz( p_intf, "dvd" );
1190 if ( !psz_device ) psz_device = "";
1192 if( disc_device->GetValue().Cmp( wxL2U( psz_device ) ) )
1194 b_disc_device_changed = true;
1197 UpdateMRL( DISC_ACCESS );
1200 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
1202 char *psz_device = NULL;
1204 switch( disc_type->GetSelection() )
1207 case 0: /* DVD with menus */
1208 case 1: /* DVD without menus */
1209 disc_sub->Enable(); disc_sub_label->Enable();
1210 disc_chapter->Enable(); disc_chapter_label->Enable();
1211 disc_title_label->SetLabel ( wxU(_("Title")) );
1212 psz_device = config_GetPsz( p_intf, "dvd" );
1213 if( !b_disc_device_changed )
1215 if( psz_device ) disc_device->SetValue( wxL2U(psz_device) );
1216 else disc_device->SetValue( wxT("") );
1218 disc_title->SetRange( 0, 255 );
1219 disc_chapter->SetRange( 0, 255 );
1222 case 2: /* VCD of some sort */
1223 disc_sub->Enable(); disc_sub_label->Enable();
1224 disc_chapter->Disable(); disc_chapter_label->Disable();
1225 psz_device = config_GetPsz( p_intf, "vcd" );
1226 if( !b_disc_device_changed )
1228 if( psz_device ) disc_device->SetValue( wxL2U(psz_device) );
1229 else disc_device->SetValue( wxT("") );
1233 disc_title_label->SetLabel ( config_GetInt( p_intf, "vcdx-PBC" )
1234 ? wxT("Playback LID") : wxT("Entry") );
1236 disc_title_label->SetLabel ( wxU(_("Track")) );
1238 disc_title->SetRange( 0, 999 );
1242 disc_sub->Disable(); disc_sub_label->Disable();
1243 disc_chapter->Disable(); disc_chapter_label->Disable();
1244 disc_title_label->SetLabel ( wxU(_("Track")) );
1245 psz_device = config_GetPsz( p_intf, "cd-audio" );
1246 if( !b_disc_device_changed )
1248 if( psz_device ) disc_device->SetValue( wxL2U(psz_device) );
1249 else disc_device->SetValue( wxT("") );
1252 /* There are at most 99 tracks in a CD-DA */
1253 disc_title->SetRange( 0, 99 );
1257 msg_Err( p_intf, "invalid Disc type selection (%d)",
1258 disc_type->GetSelection() );
1262 disc_title->SetValue( 0 ); i_disc_title = 0;
1263 disc_chapter->SetValue( 0 ); i_disc_chapter = 0;
1265 if( psz_device ) free( psz_device );
1267 UpdateMRL( DISC_ACCESS );
1270 /*****************************************************************************
1271 * Net panel event methods.
1272 *****************************************************************************/
1273 void OpenDialog::OnNetPanelChangeSpin( wxSpinEvent& event )
1275 wxCommandEvent cevent;
1276 cevent.SetId(event.GetId());
1277 cevent.SetInt(event.GetPosition());
1278 OnNetPanelChange(cevent);
1281 void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
1283 if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
1285 i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
1288 UpdateMRL( NET_ACCESS );
1291 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
1295 i_net_type = event.GetId() - NetRadio1_Event;
1299 net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
1300 net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
1302 /* UDP Unicast or multicast -> timeshift */
1303 if( i_net_type == 0 || i_net_type == 1 )
1304 net_timeshift->Enable();
1306 net_timeshift->Disable();
1308 UpdateMRL( NET_ACCESS );
1311 /*****************************************************************************
1312 * Subtitles file event methods.
1313 *****************************************************************************/
1314 void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
1316 subsfile_button->Enable( event.GetInt() != 0 );
1319 void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
1321 /* Show/hide the open dialog */
1322 if( subsfile_dialog == NULL )
1323 subsfile_dialog = new SubsFileDialog( p_intf, this );
1325 if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
1327 subsfile_mrl.Empty();
1328 subsfile_mrl.Add( wxString(wxT("sub-file=")) +
1329 subsfile_dialog->file_combo->GetValue() );
1330 if( subsfile_dialog->encoding_combo )
1332 subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
1333 subsfile_dialog->encoding_combo->GetValue() );
1335 if( subsfile_dialog->align_combo )
1337 subsfile_mrl.Add( wxString::Format(wxT("subsdec-align=%i"),
1338 (int)subsfile_dialog->align_combo->GetClientData(
1339 subsfile_dialog->align_combo->GetSelection()) ) );
1341 if( subsfile_dialog->size_combo )
1343 subsfile_mrl.Add( wxString::Format( wxT("freetype-rel-fontsize=%i"),
1344 (int)subsfile_dialog->size_combo->GetClientData(
1345 subsfile_dialog->size_combo->GetSelection()) ) );
1347 subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
1348 subsfile_dialog->fps_spinctrl->GetValue() ) );
1349 subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
1350 subsfile_dialog->delay_spinctrl->GetValue() ) );
1354 /*****************************************************************************
1355 * Stream output event methods.
1356 *****************************************************************************/
1357 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
1359 sout_button->Enable( event.GetInt() != 0 );
1362 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
1364 /* Show/hide the open dialog */
1365 if( sout_dialog == NULL )
1366 sout_dialog = new SoutDialog( p_intf, this );
1368 if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
1370 sout_mrl = sout_dialog->GetOptions();
1374 /*****************************************************************************
1375 * Caching event methods.
1376 *****************************************************************************/
1377 void OpenDialog::OnCachingEnable( wxCommandEvent& event )
1379 caching_value->Enable( event.GetInt() != 0 );
1380 i_caching = caching_value->GetValue();
1384 void OpenDialog::OnCachingChangeSpin( wxSpinEvent& event )
1386 wxCommandEvent cevent;
1387 OnCachingChange(cevent);
1390 void OpenDialog::OnCachingChange( wxCommandEvent& event )
1392 i_caching = event.GetInt();
1396 /*****************************************************************************
1397 * Utility functions.
1398 *****************************************************************************/
1399 wxArrayString SeparateEntries( wxString entries )
1401 vlc_bool_t b_quotes_mode = VLC_FALSE;
1403 wxArrayString entries_array;
1406 wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
1408 while( token.HasMoreTokens() )
1410 entry += token.GetNextToken();
1412 if( entry.IsEmpty() ) continue;
1414 if( !b_quotes_mode && entry.Last() == wxT('\"') )
1416 /* Enters quotes mode */
1418 b_quotes_mode = VLC_TRUE;
1420 else if( b_quotes_mode && entry.Last() == wxT('\"') )
1422 /* Finished the quotes mode */
1424 b_quotes_mode = VLC_FALSE;
1426 else if( !b_quotes_mode && entry.Last() != wxT('\"') )
1428 /* we found a non-quoted standalone string */
1429 if( token.HasMoreTokens() ||
1430 entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
1431 entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
1433 if( !entry.IsEmpty() ) entries_array.Add( entry );
1440 if( !entry.IsEmpty() ) entries_array.Add( entry );
1442 return entries_array;