* modules/gui/wxwindows/preferences.cpp: the config panels are now generated on deman...
[vlc.git] / modules / gui / wxwindows / open.cpp
1 /*****************************************************************************
2  * open.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2001 VideoLAN
5  * $Id: open.cpp,v 1.20 2003/05/12 21:55:01 gbazin Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <errno.h>                                                 /* ENOMEM */
29 #include <string.h>                                            /* strerror() */
30 #include <stdio.h>
31
32 #include <vlc/vlc.h>
33
34 #ifdef WIN32                                                 /* mingw32 hack */
35 #undef Yield
36 #undef CreateDialog
37 #endif
38
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
41
42 #include <wx/wxprec.h>
43 #include <wx/wx.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
50 #include <vlc/intf.h>
51
52 #if defined MODULE_NAME_IS_skins
53 #   include "../skins/src/skin_common.h"
54 #endif
55
56 #include "wxwindows.h"
57
58 #ifndef wxRB_SINGLE
59 #   define wxRB_SINGLE 0
60 #endif
61
62 /*****************************************************************************
63  * Event Table.
64  *****************************************************************************/
65
66 /* IDs for the controls and the menu commands */
67 enum
68 {
69     Notebook_Event = wxID_HIGHEST,
70     MRL_Event,
71
72     FileBrowse_Event,
73     FileName_Event,
74
75     DiscType_Event,
76     DiscDevice_Event,
77     DiscTitle_Event,
78     DiscChapter_Event,
79
80     NetType_Event,
81     NetRadio1_Event, NetRadio2_Event, NetRadio3_Event,
82     NetPort1_Event, NetPort2_Event, NetPort3_Event,
83     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
84
85     SoutEnable_Event,
86     SoutSettings_Event,
87
88     DemuxDump_Event,
89     DemuxDumpEnable_Event,
90     DemuxDumpBrowse_Event,
91 };
92
93 BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
94     /* Button events */
95     EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
96     EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
97
98     EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
99
100     EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange) 
101
102     /* Events generated by the file panel */
103     EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
104     EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
105
106     /* Events generated by the disc panel */
107     EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
108     EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
109     EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
110     EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
111     EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
112     EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
113
114     /* Events generated by the net panel */
115     EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
116     EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
117     EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
118     EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
119     EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
120     EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
121     EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
122     EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
123     EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
124     EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
125     EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
126
127     /* Events generated by the stream output buttons */
128     EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
129     EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
130
131     /* Events generated by the demux dump buttons */
132     EVT_CHECKBOX(DemuxDumpEnable_Event, OpenDialog::OnDemuxDumpEnable)
133     EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
134     EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)
135
136 END_EVENT_TABLE()
137
138 /*****************************************************************************
139  * Constructor.
140  *****************************************************************************/
141 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
142                         int i_access_method ):
143     wxDialog( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
144              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
145 {
146     /* Initializations */
147     p_intf = _p_intf;
148     p_parent = _p_parent;
149     SetIcon( *p_intf->p_sys->p_icon );
150
151     /* Create a panel to put everything in */
152     wxPanel *panel = new wxPanel( this, -1 );
153     panel->SetAutoLayout( TRUE );
154
155     /* Create MRL combobox */
156     wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
157     wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
158                                wxU(_("Media Resource Locator (MRL)")) );
159     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
160                                                         wxHORIZONTAL );
161     wxStaticText *mrl_label = new wxStaticText( panel, -1,
162                                                 wxU(_("Open Target:")) );
163     mrl_combo = new wxComboBox( panel, MRL_Event, mrl,
164                                 wxPoint(20,25), wxSize(120, -1),
165                                 0, NULL );
166     mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
167         "the full MRL you want to open.\n""Alternatively, the field will be "
168         "filled automatically when you use the controls below.")) );
169
170     mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
171     mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
172     mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
173
174
175     /* Create Static Text */
176     wxStaticText *label = new wxStaticText( panel, -1,
177         wxU(_("Alternatively, you can build an MRL using one of the "
178               "following predefined targets:")) );
179
180     /* Create Stream Output checkox */
181     wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
182     sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
183                                     wxU(_("Stream output")) );
184     sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
185     sout_sizer->Add( sout_checkbox, 0,
186                      wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
187     sout_button = new wxButton( panel, SoutSettings_Event,
188                                 wxU(_("Settings...")) );
189     sout_button->Disable();
190
191     char *psz_sout = config_GetPsz( p_intf, "sout" );
192     if( psz_sout && *psz_sout )
193     {
194         sout_checkbox->SetValue(TRUE);
195         sout_button->Enable();
196     }
197     if( psz_sout ) free( psz_sout );
198
199     sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
200
201     /* Create Demux Dump checkox */
202     wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
203     demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
204                                wxU(_("Capture input stream")) );
205     demuxdump_checkbox->SetToolTip(
206         wxU(_("Capture the stream you are playing to a file")) );
207     demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
208                                          wxDefaultPosition, wxDefaultSize,
209                                          wxTE_PROCESS_ENTER);
210     demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
211                                      wxU(_("Browse...")) );
212
213     char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
214     if( psz_demuxdump && *psz_demuxdump )
215     {
216         demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
217     }
218     if( psz_demuxdump ) free( psz_demuxdump );
219
220     demuxdump_textctrl->Disable();
221     demuxdump_button->Disable();
222     demuxdump_sizer->Add( demuxdump_checkbox, 0,
223                           wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 10 );
224     demuxdump_sizer->Add( demuxdump_button, 0,
225                           wxALL | wxALIGN_CENTER_VERTICAL, 10 );
226     demuxdump_sizer->Add( demuxdump_textctrl, 1, wxALL, 10 );
227
228     /* Separation */
229     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
230
231     /* Create the buttons */
232     wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
233     ok_button->SetDefault();
234     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
235                                             wxU(_("Cancel")) );
236
237     /* Create notebook */
238     wxNotebook *notebook = new wxNotebook( panel, Notebook_Event );
239     wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
240
241     notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
242                        i_access_method == FILE_ACCESS );
243     notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
244                        i_access_method == DISC_ACCESS );
245     notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
246                        i_access_method == NET_ACCESS );
247 #ifndef WIN32
248     notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
249                        i_access_method == SAT_ACCESS );
250 #endif
251
252     /* Update Disc panel */
253     wxCommandEvent dummy_event;
254     OnDiscTypeChange( dummy_event );
255
256     /* Update Net panel */
257     dummy_event.SetId( NetRadio1_Event );
258     OnNetTypeChange( dummy_event );
259
260     /* Update MRL */
261     wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
262     OnPageChange( event );
263
264     /* Place everything in sizers */
265     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
266     button_sizer->Add( ok_button, 0, wxALL, 5 );
267     button_sizer->Add( cancel_button, 0, wxALL, 5 );
268     button_sizer->Layout();
269     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
270     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
271     panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
272     panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
273     panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
274     panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
275     panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
276     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
277     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
278     panel_sizer->Layout();
279     panel->SetSizerAndFit( panel_sizer );
280     main_sizer->Add( panel, 1, wxGROW, 0 );
281     main_sizer->Layout();
282     SetSizerAndFit( main_sizer );
283 }
284
285 OpenDialog::~OpenDialog()
286 {
287 }
288
289 /*****************************************************************************
290  * Private methods.
291  *****************************************************************************/
292 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
293 {
294     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
295                                   wxSize(200, 200) );
296
297     wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
298
299     file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
300                                  wxPoint(20,25), wxSize(200, -1), 0, NULL );
301     wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
302                                             wxU(_("Browse...")) );
303     sizer->Add( file_combo, 1, wxALL, 5 );
304     sizer->Add( browse_button, 0, wxALL, 5 );
305
306     panel->SetSizerAndFit( sizer );
307     return panel;
308 }
309
310 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
311 {
312     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
313                                   wxSize(200, 200) );
314
315     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
316     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
317
318     static const wxString disc_type_array[] =
319     {
320         wxU(_("DVD")),
321         wxU(_("DVD (menus support)")),
322         wxU(_("VCD"))
323     };
324
325     disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
326                                 wxDefaultPosition, wxDefaultSize,
327                                 WXSIZEOF(disc_type_array), disc_type_array,
328                                 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
329     sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
330
331     wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
332     disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
333                                   wxDefaultPosition, wxDefaultSize,
334                                   wxTE_PROCESS_ENTER);
335
336     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
337     sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
338
339     label = new wxStaticText( panel, -1, wxU(_("Title")) );
340     disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
341
342     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
343     sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
344
345     label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
346     disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
347     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
348     sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
349     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
350
351     panel->SetSizerAndFit( sizer_row );
352     return panel;
353 }
354
355 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
356 {
357     int i;
358     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
359                                   wxSize(200, 200) );
360
361     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
362     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
363
364     static const wxString net_type_array[] =
365     {
366         wxU(_("UDP/RTP")),
367         wxU(_("UDP/RTP Multicast")),
368         wxU(_("HTTP/FTP/MMS"))
369     };
370
371     for( i=0; i<3; i++ )
372     {
373         net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
374                                            net_type_array[i],
375                                            wxDefaultPosition, wxDefaultSize,
376                                            wxRB_SINGLE );
377
378         net_subpanels[i] = new wxPanel( panel, -1,
379                                         wxDefaultPosition, wxDefaultSize );
380     }
381
382     /* UDP/RTP row */
383     wxFlexGridSizer *subpanel_sizer;
384     wxStaticText *label;
385     int val = config_GetInt( p_intf, "server-port" );
386     subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
387     label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
388     net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
389                                    wxString::Format(wxT("%d"), val),
390                                    wxDefaultPosition, wxDefaultSize,
391                                    wxSP_ARROW_KEYS,
392                                    0, 16000, val);
393
394     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
395     subpanel_sizer->Add( net_ports[0], 1,
396                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
397     net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
398     net_radios[0]->SetValue( TRUE );
399
400     /* UDP/RTP Multicast row */
401     subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
402     label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
403     net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
404                                    wxDefaultPosition, wxDefaultSize,
405                                    wxTE_PROCESS_ENTER);
406     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
407     subpanel_sizer->Add( net_addrs[1], 1,
408                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
409
410     label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
411     net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
412                                    wxString::Format(wxT("%d"), val),
413                                    wxDefaultPosition, wxDefaultSize,
414                                    wxSP_ARROW_KEYS,
415                                    0, 16000, val);
416
417     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
418     subpanel_sizer->Add( net_ports[1], 1,
419                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
420     net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
421
422     /* HTTP row */
423     subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
424     label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
425     net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
426                                    wxDefaultPosition, wxSize( 200, -1 ),
427                                    wxTE_PROCESS_ENTER);
428     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
429     subpanel_sizer->Add( net_addrs[2], 1,
430                          wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
431     net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
432
433     /* Stuff everything into the main panel */
434     for( i=0; i<3; i++ )
435     {
436         sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
437                     wxALL, 5 );
438         sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
439                     wxALIGN_CENTER_VERTICAL | wxALL, 5  );
440     }
441
442     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
443
444     panel->SetSizerAndFit( sizer_row );
445     return panel;
446 }
447
448 wxPanel *OpenDialog::SatPanel( wxWindow* parent )
449 {
450     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
451                                   wxSize(200, 200) );
452     return panel;
453 }
454
455 void OpenDialog::UpdateMRL( int i_access_method )
456 {
457     wxString demux;
458
459     i_current_access_method = i_access_method;
460
461     /* Check if the user asked for demuxdump */
462     if( demuxdump_checkbox->GetValue() )
463     {
464         demux = wxT("/demuxdump");
465     }
466
467     switch( i_access_method )
468     {
469     case FILE_ACCESS:
470         mrl = wxT("file") + demux + wxT("://") + file_combo->GetValue();
471         break;
472     case DISC_ACCESS:
473         mrl = ( disc_type->GetSelection() == 0 ? wxT("dvdold") :
474                 disc_type->GetSelection() == 1 ? wxT("dvd") : wxT("vcd") )
475                   + demux + wxT("://")
476                   + disc_device->GetLineText(0)
477                   + wxString::Format( wxT("@%d:%d"),
478                                       disc_title->GetValue(),
479                                       disc_chapter->GetValue() );
480         break;
481     case NET_ACCESS:
482         switch( i_net_type )
483         {
484         case 0:
485             if( net_ports[0]->GetValue() !=
486                 config_GetInt( p_intf, "server-port" ) )
487             {
488                 mrl = wxT("udp") + demux +
489                        wxString::Format( wxT("://@:%d"),
490                                          net_ports[0]->GetValue() );
491             }
492             else
493             {
494                 mrl = wxT("udp") + demux + wxT("://");
495             }
496             break;
497
498         case 1:
499             mrl = wxT("udp") + demux + wxT("://@") +
500                   net_addrs[1]->GetLineText(0);
501             if( net_ports[1]->GetValue() !=
502                 config_GetInt( p_intf, "server-port" ) )
503             {
504                 mrl = mrl + wxString::Format( wxT(":%d"),
505                                               net_ports[1]->GetValue() );
506             }
507             break;
508
509         case 2:
510             /* http access */     
511             mrl = wxT("http") + demux + wxT("://") +
512                   net_addrs[2]->GetLineText(0);
513             break;
514         }
515         break;
516     case SAT_ACCESS:
517         mrl = wxT("satellite") + demux + wxT("://");
518         break;
519     default:
520         break;
521     }
522
523     mrl_combo->SetValue( mrl );
524 }
525
526 /*****************************************************************************
527  * Events methods.
528  *****************************************************************************/
529 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
530 {
531     EndModal( wxID_OK );
532 }
533
534 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
535 {
536     EndModal( wxID_CANCEL );
537 }
538
539 void OpenDialog::OnPageChange( wxNotebookEvent& event )
540 {
541     UpdateMRL( event.GetSelection() );
542 }
543
544 void OpenDialog::OnMRLChange( wxCommandEvent& event )
545 {
546     mrl = event.GetString();
547 }
548
549 /*****************************************************************************
550  * File panel event methods.
551  *****************************************************************************/
552 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
553 {
554     UpdateMRL( FILE_ACCESS );
555 }
556
557 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
558 {
559     wxFileDialog dialog( this, wxU(_("Open file")),
560                          wxT(""), wxT(""), wxT("*.*"), wxOPEN );
561
562     if( dialog.ShowModal() == wxID_OK )
563     {
564         file_combo->SetValue( dialog.GetPath() );      
565         UpdateMRL( FILE_ACCESS );
566     }
567 }
568
569 /*****************************************************************************
570  * Disc panel event methods.
571  *****************************************************************************/
572 void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
573 {
574     UpdateMRL( DISC_ACCESS );
575 }
576
577 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
578 {
579     char *psz_device;
580
581     switch( disc_type->GetSelection() )
582     {
583     case 2:
584         psz_device = config_GetPsz( p_intf, "vcd" );
585         disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
586         break;
587
588     default:
589         psz_device = config_GetPsz( p_intf, "dvd" );
590         disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
591         break;
592     }
593
594     if( psz_device ) free( psz_device );
595
596     switch( disc_type->GetSelection() )
597     {
598     case 1:
599         disc_title->SetRange( 0, 255 );
600         disc_title->SetValue( 0 );
601         break;
602
603     default:
604         disc_title->SetRange( 1, 255 );
605         disc_title->SetValue( 1 );
606         break;
607     }
608
609     disc_chapter->SetRange( 1, 255 );
610     disc_chapter->SetValue( 1 );
611
612     UpdateMRL( DISC_ACCESS );
613 }
614
615 /*****************************************************************************
616  * Net panel event methods.
617  *****************************************************************************/
618 void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
619 {
620     UpdateMRL( NET_ACCESS );
621 }
622
623 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
624 {
625     int i;
626
627     i_net_type = event.GetId() - NetRadio1_Event;
628
629     for(i=0; i<3; i++)
630     {
631         net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
632         net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
633     }
634
635     UpdateMRL( NET_ACCESS );
636 }
637
638 /*****************************************************************************
639  * Stream output event methods.
640  *****************************************************************************/
641 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
642 {
643     sout_button->Enable( event.GetInt() != 0 );
644     if( !event.GetInt() )
645     {
646         config_PutPsz( p_intf, "sout", "" );
647     }
648     else
649     {
650         demuxdump_checkbox->SetValue( 0 );
651         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
652         event.SetInt( 0 );
653         OnDemuxDumpEnable( event );
654     }
655 }
656
657 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
658 {
659     /* Show/hide the open dialog */
660     SoutDialog dialog( p_intf, p_parent );
661
662     if( dialog.ShowModal() == wxID_OK )
663     {
664         config_PutPsz( p_intf, "sout", (const char *)dialog.mrl.mb_str() );
665     }
666 }
667
668 /*****************************************************************************
669  * Demux dump event methods.
670  *****************************************************************************/
671 void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
672 {
673     demuxdump_textctrl->Enable( event.GetInt() != 0 );
674     demuxdump_button->Enable( event.GetInt() != 0 );
675
676     if( event.GetInt() )
677     {
678         sout_checkbox->SetValue( 0 );
679         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
680         event.SetInt( 0 );
681         OnSoutEnable( event );
682     }
683
684     UpdateMRL( i_current_access_method );
685 }
686
687 void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
688 {
689     wxFileDialog dialog( this, wxU(_("Save file")),
690                          wxT(""), wxT(""), wxT("*.*"), wxSAVE );
691
692     if( dialog.ShowModal() == wxID_OK )
693     {
694         demuxdump_textctrl->SetValue( dialog.GetPath() );
695         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
696         OnDemuxDumpChange( event );
697     }
698 }
699
700 void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
701 {
702     config_PutPsz( p_intf, "demuxdump-file",
703                    demuxdump_textctrl->GetValue().mb_str() );
704 }