1 /*****************************************************************************
2 * open.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: open.cpp,v 1.28 2003/07/17 17:30:40 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, wxFrame)
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)
144 /* Hide the window when the user closes the window */
145 EVT_CLOSE(OpenDialog::OnCancel)
149 /*****************************************************************************
151 *****************************************************************************/
152 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
153 int i_access_method, int i_arg ):
154 wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
155 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
157 /* Initializations */
159 p_parent = _p_parent;
160 SetIcon( *p_intf->p_sys->p_icon );
163 subsfile_dialog = NULL;
164 demuxdump_dialog = NULL;
166 /* Create a panel to put everything in */
167 wxPanel *panel = new wxPanel( this, -1 );
168 panel->SetAutoLayout( TRUE );
170 /* Create MRL combobox */
171 wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
172 wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
173 wxU(_("Media Resource Locator (MRL)")) );
174 wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
176 wxStaticText *mrl_label = new wxStaticText( panel, -1,
177 wxU(_("Open Target:")) );
178 mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
179 wxPoint(20,25), wxSize(120, -1),
181 mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
182 "the full MRL you want to open.\n""Alternatively, the field will be "
183 "filled automatically when you use the controls below.")) );
185 mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
186 mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
187 mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
190 /* Create Static Text */
191 wxStaticText *label = new wxStaticText( panel, -1,
192 wxU(_("Alternatively, you can build an MRL using one of the "
193 "following predefined targets:")) );
195 /* Create Subtitles File checkox */
196 wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
197 subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
198 wxU(_("Subtitles file")) );
199 subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
200 "Currently only works with AVI files.")) );
201 subsfile_sizer->Add( subsfile_checkbox, 0,
202 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
203 subsfile_button = new wxButton( panel, SubsFileSettings_Event,
204 wxU(_("Settings...")) );
205 subsfile_button->Disable();
207 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
208 if( psz_subsfile && *psz_subsfile )
210 subsfile_checkbox->SetValue(TRUE);
211 subsfile_button->Enable();
213 if( psz_subsfile ) free( psz_subsfile );
215 subsfile_sizer->Add( subsfile_button, 1,
216 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
218 /* Create Stream Output checkox */
219 wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
220 sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
221 wxU(_("Stream output")) );
222 sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
223 sout_sizer->Add( sout_checkbox, 0,
224 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
225 sout_button = new wxButton( panel, SoutSettings_Event,
226 wxU(_("Settings...")) );
227 sout_button->Disable();
229 char *psz_sout = config_GetPsz( p_intf, "sout" );
230 if( psz_sout && *psz_sout )
232 sout_checkbox->SetValue(TRUE);
233 sout_button->Enable();
235 if( psz_sout ) free( psz_sout );
237 sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
239 /* Create Demux Dump checkox */
240 wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
241 demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
242 wxU(_("Capture input stream")) );
243 demuxdump_checkbox->SetToolTip(
244 wxU(_("Capture the stream you are playing to a file")) );
245 demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
246 wxDefaultPosition, wxDefaultSize,
248 demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
249 wxU(_("Browse...")) );
251 char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
252 if( psz_demuxdump && *psz_demuxdump )
254 demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
256 if( psz_demuxdump ) free( psz_demuxdump );
258 demuxdump_textctrl->Disable();
259 demuxdump_button->Disable();
260 demuxdump_sizer->Add( demuxdump_checkbox, 0,
261 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
262 demuxdump_sizer->Add( demuxdump_button, 0,
263 wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 );
264 demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 );
267 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
269 /* Create the buttons */
270 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
271 ok_button->SetDefault();
272 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
275 /* Create notebook */
276 notebook = new wxNotebook( panel, Notebook_Event );
277 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
279 notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
280 i_access_method == FILE_ACCESS );
281 notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
282 i_access_method == DISC_ACCESS );
283 notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
284 i_access_method == NET_ACCESS );
286 notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
287 i_access_method == SAT_ACCESS );
290 /* Update Disc panel */
291 wxCommandEvent dummy_event;
292 OnDiscTypeChange( dummy_event );
294 /* Update Net panel */
295 dummy_event.SetId( NetRadio1_Event );
296 OnNetTypeChange( dummy_event );
299 wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
300 OnPageChange( event );
302 /* Place everything in sizers */
303 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
304 button_sizer->Add( ok_button, 0, wxALL, 5 );
305 button_sizer->Add( cancel_button, 0, wxALL, 5 );
306 button_sizer->Layout();
307 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
308 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
309 panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
310 panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
311 panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
312 panel_sizer->Add( subsfile_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
313 panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
314 panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
315 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
316 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
317 panel_sizer->Layout();
318 panel->SetSizerAndFit( panel_sizer );
319 main_sizer->Add( panel, 1, wxGROW, 0 );
320 main_sizer->Layout();
321 SetSizerAndFit( main_sizer );
324 OpenDialog::~OpenDialog()
327 if( file_dialog ) delete file_dialog;
328 if( sout_dialog ) delete sout_dialog;
329 if( subsfile_dialog ) delete subsfile_dialog;
330 if( demuxdump_dialog ) delete demuxdump_dialog;
333 int OpenDialog::Show( int i_access_method, int i_arg )
336 notebook->SetSelection( i_access_method );
337 i_ret = wxFrame::Show();
343 int OpenDialog::Show()
346 i_ret = wxFrame::Show();
352 /*****************************************************************************
354 *****************************************************************************/
355 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
357 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
360 wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
362 file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
363 wxPoint(20,25), wxSize(200, -1), 0, NULL );
364 wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
365 wxU(_("Browse...")) );
366 sizer->Add( file_combo, 1, wxALL, 5 );
367 sizer->Add( browse_button, 0, wxALL, 5 );
369 panel->SetSizerAndFit( sizer );
373 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
375 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
378 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
379 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
381 static const wxString disc_type_array[] =
383 wxU(_("DVD (menus support)")),
390 disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
391 wxDefaultPosition, wxDefaultSize,
392 WXSIZEOF(disc_type_array), disc_type_array,
393 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
394 sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
396 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
397 disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
398 wxDefaultPosition, wxDefaultSize,
401 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
402 sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
404 label = new wxStaticText( panel, -1, wxU(_("Title")) );
405 disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
407 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
408 sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
410 label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
411 disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
412 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
413 sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
414 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
416 panel->SetSizerAndFit( sizer_row );
420 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
423 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
426 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
427 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
429 static const wxString net_type_array[] =
432 wxU(_("UDP/RTP Multicast")),
433 wxU(_("HTTP/FTP/MMS"))
438 net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
440 wxDefaultPosition, wxDefaultSize,
443 net_subpanels[i] = new wxPanel( panel, -1,
444 wxDefaultPosition, wxDefaultSize );
448 wxFlexGridSizer *subpanel_sizer;
450 int val = config_GetInt( p_intf, "server-port" );
451 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
452 label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
453 net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
454 wxString::Format(wxT("%d"), val),
455 wxDefaultPosition, wxDefaultSize,
459 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
460 subpanel_sizer->Add( net_ports[0], 1,
461 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
462 net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
463 net_radios[0]->SetValue( TRUE );
465 /* UDP/RTP Multicast row */
466 subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
467 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
468 net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
469 wxDefaultPosition, wxDefaultSize,
471 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
472 subpanel_sizer->Add( net_addrs[1], 1,
473 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
475 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
476 net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
477 wxString::Format(wxT("%d"), val),
478 wxDefaultPosition, wxDefaultSize,
482 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
483 subpanel_sizer->Add( net_ports[1], 1,
484 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
485 net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
488 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
489 label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
490 net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
491 wxDefaultPosition, wxSize( 200, -1 ),
493 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
494 subpanel_sizer->Add( net_addrs[2], 1,
495 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
496 net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
498 /* Stuff everything into the main panel */
501 sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
503 sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
504 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
507 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
509 panel->SetSizerAndFit( sizer_row );
513 wxPanel *OpenDialog::SatPanel( wxWindow* parent )
515 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
520 void OpenDialog::UpdateMRL( int i_access_method )
522 wxString demux, mrltemp;
524 i_current_access_method = i_access_method;
526 /* Check if the user asked for demuxdump */
527 if( demuxdump_checkbox->GetValue() )
529 demux = wxT("/demuxdump");
532 switch( i_access_method )
535 //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
536 mrltemp = file_combo->GetValue();
539 mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
540 disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
541 disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
543 + disc_device->GetLineText(0)
544 + wxString::Format( wxT("@%d:%d"),
545 disc_title->GetValue(),
546 disc_chapter->GetValue() );
552 if( net_ports[0]->GetValue() !=
553 config_GetInt( p_intf, "server-port" ) )
555 mrltemp = wxT("udp") + demux +
556 wxString::Format( wxT("://@:%d"),
557 net_ports[0]->GetValue() );
561 mrltemp = wxT("udp") + demux + wxT("://");
566 mrltemp = wxT("udp") + demux + wxT("://@") +
567 net_addrs[1]->GetLineText(0);
568 if( net_ports[1]->GetValue() !=
569 config_GetInt( p_intf, "server-port" ) )
571 mrltemp = mrltemp + wxString::Format( wxT(":%d"),
572 net_ports[1]->GetValue() );
578 mrltemp = wxT("http") + demux + wxT("://") +
579 net_addrs[2]->GetLineText(0);
584 mrltemp = wxT("satellite") + demux + wxT("://");
590 mrl_combo->SetValue( mrltemp );
593 wxArrayString OpenDialog::SeparateEntries( wxString entries )
595 vlc_bool_t b_quotes_mode = VLC_FALSE;
597 wxArrayString entries_array;
600 wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
602 while( token.HasMoreTokens() )
604 entry += token.GetNextToken();
606 if( entry.IsEmpty() ) continue;
608 if( !b_quotes_mode && entry.Last() == wxT('\"') )
610 /* Enters quotes mode */
612 b_quotes_mode = VLC_TRUE;
614 else if( b_quotes_mode && entry.Last() == wxT('\"') )
616 /* Finished the quotes mode */
618 if( !entry.IsEmpty() ) entries_array.Add( entry );
620 b_quotes_mode = VLC_FALSE;
622 else if( !b_quotes_mode && entry.Last() != wxT('\"') )
624 /* we found a non-quoted standalone string */
625 if( token.HasMoreTokens() ||
626 entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
627 entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
629 if( !entry.IsEmpty() ) entries_array.Add( entry );
636 if( !entry.IsEmpty() ) entries_array.Add( entry );
638 return entries_array;
641 /*****************************************************************************
643 *****************************************************************************/
644 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
646 mrl = SeparateEntries( mrl_combo->GetValue() );
647 mrl_combo->Append( mrl_combo->GetValue() );
648 if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
649 mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
651 /* Update the playlist */
652 playlist_t *p_playlist =
653 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
655 if( p_playlist == NULL )
660 for( size_t i = 0; i < mrl.GetCount(); i++ )
662 playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
663 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
666 //TogglePlayButton( PLAYING_S );
668 vlc_object_release( p_playlist );
673 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
678 void OpenDialog::OnPageChange( wxNotebookEvent& event )
680 UpdateMRL( event.GetSelection() );
683 void OpenDialog::OnMRLChange( wxCommandEvent& event )
685 //mrl = SeparateEntries( event.GetString() );
688 /*****************************************************************************
689 * File panel event methods.
690 *****************************************************************************/
691 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
693 UpdateMRL( FILE_ACCESS );
696 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
698 if( file_dialog == NULL )
699 file_dialog = new wxFileDialog( this, wxU(_("Open file")),
700 wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
702 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
707 file_dialog->GetPaths( paths );
709 for( size_t i = 0; i < paths.GetCount(); i++ )
711 if( paths[i].Find( wxT(' ') ) >= 0 )
712 path += wxT("\"") + paths[i] + wxT("\" ");
714 path += paths[i] + wxT(" ");
717 file_combo->SetValue( path );
718 file_combo->Append( path );
719 if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
720 UpdateMRL( FILE_ACCESS );
724 /*****************************************************************************
725 * Disc panel event methods.
726 *****************************************************************************/
727 void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
729 UpdateMRL( DISC_ACCESS );
732 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
736 switch( disc_type->GetSelection() )
739 psz_device = config_GetPsz( p_intf, "vcd" );
740 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
744 psz_device = config_GetPsz( p_intf, "dvd" );
745 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
749 if( psz_device ) free( psz_device );
751 switch( disc_type->GetSelection() )
754 disc_title->SetRange( 0, 255 );
755 disc_title->SetValue( 0 );
759 disc_title->SetRange( 1, 255 );
760 disc_title->SetValue( 1 );
764 disc_chapter->SetRange( 1, 255 );
765 disc_chapter->SetValue( 1 );
767 UpdateMRL( DISC_ACCESS );
770 /*****************************************************************************
771 * Net panel event methods.
772 *****************************************************************************/
773 void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
775 UpdateMRL( NET_ACCESS );
778 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
782 i_net_type = event.GetId() - NetRadio1_Event;
786 net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
787 net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
790 UpdateMRL( NET_ACCESS );
793 /*****************************************************************************
794 * Subtitles file event methods.
795 *****************************************************************************/
796 void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
798 subsfile_button->Enable( event.GetInt() != 0 );
799 if( !event.GetInt() )
801 config_PutPsz( p_intf, "sub-file", "" );
805 demuxdump_checkbox->SetValue( 0 );
806 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
808 OnDemuxDumpEnable( event );
812 void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
814 /* Show/hide the open dialog */
815 if( subsfile_dialog == NULL )
816 subsfile_dialog = new SubsFileDialog( p_intf, this );
818 if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
820 config_PutPsz( p_intf, "sub-file",
821 (const char *)subsfile_dialog->file_combo->GetValue().mb_str() );
822 config_PutInt( p_intf, "sub-delay",
823 subsfile_dialog->delay_spinctrl->GetValue() );
824 config_PutFloat( p_intf, "sub-fps",
825 subsfile_dialog->fps_spinctrl->GetValue() );
829 /*****************************************************************************
830 * Stream output event methods.
831 *****************************************************************************/
832 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
834 sout_button->Enable( event.GetInt() != 0 );
835 if( !event.GetInt() )
837 config_PutPsz( p_intf, "sout", "" );
841 demuxdump_checkbox->SetValue( 0 );
842 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
844 OnDemuxDumpEnable( event );
848 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
850 /* Show/hide the open dialog */
851 if( sout_dialog == NULL )
852 sout_dialog = new SoutDialog( p_intf, this );
854 if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
856 config_PutPsz( p_intf, "sout",
857 (const char *)sout_dialog->mrl.mb_str() );
861 /*****************************************************************************
862 * Demux dump event methods.
863 *****************************************************************************/
864 void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
866 demuxdump_textctrl->Enable( event.GetInt() != 0 );
867 demuxdump_button->Enable( event.GetInt() != 0 );
871 sout_checkbox->SetValue( 0 );
872 subsfile_checkbox->SetValue( 0 );
873 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
875 OnSoutEnable( event );
876 OnSubsFileEnable( event );
879 UpdateMRL( i_current_access_method );
882 void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
884 if( demuxdump_dialog == NULL )
885 demuxdump_dialog = new wxFileDialog( this, wxU(_("Save file")),
886 wxT(""), wxT(""), wxT("*"), wxSAVE );
888 if( demuxdump_dialog && demuxdump_dialog->ShowModal() == wxID_OK )
890 demuxdump_textctrl->SetValue( demuxdump_dialog->GetPath() );
891 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
892 OnDemuxDumpChange( event );
896 void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
898 config_PutPsz( p_intf, "demuxdump-file",
899 demuxdump_textctrl->GetValue().mb_str() );