217629fa5b28675249149d5ba93547fa5c74009d
[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.19 2003/05/12 17:33:19 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         sizer->Add( net_subpanels[i], 1,
438                     wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
439     }
440
441     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
442
443     panel->SetSizerAndFit( sizer_row );
444     return panel;
445 }
446
447 wxPanel *OpenDialog::SatPanel( wxWindow* parent )
448 {
449     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
450                                   wxSize(200, 200) );
451     return panel;
452 }
453
454 void OpenDialog::UpdateMRL( int i_access_method )
455 {
456     wxString demux;
457
458     i_current_access_method = i_access_method;
459
460     /* Check if the user asked for demuxdump */
461     if( demuxdump_checkbox->GetValue() )
462     {
463         demux = wxT("/demuxdump");
464     }
465
466     switch( i_access_method )
467     {
468     case FILE_ACCESS:
469         mrl = wxT("file") + demux + wxT("://") + file_combo->GetValue();
470         break;
471     case DISC_ACCESS:
472         mrl = ( disc_type->GetSelection() == 0 ? wxT("dvdold") :
473                 disc_type->GetSelection() == 1 ? wxT("dvd") : wxT("vcd") )
474                   + demux + wxT("://")
475                   + disc_device->GetLineText(0)
476                   + wxString::Format( wxT("@%d:%d"),
477                                       disc_title->GetValue(),
478                                       disc_chapter->GetValue() );
479         break;
480     case NET_ACCESS:
481         switch( i_net_type )
482         {
483         case 0:
484             if( net_ports[0]->GetValue() !=
485                 config_GetInt( p_intf, "server-port" ) )
486             {
487                 mrl = wxT("udp") + demux +
488                        wxString::Format( wxT("://@:%d"),
489                                          net_ports[0]->GetValue() );
490             }
491             else
492             {
493                 mrl = wxT("udp") + demux + wxT("://");
494             }
495             break;
496
497         case 1:
498             mrl = wxT("udp") + demux + wxT("://@") +
499                   net_addrs[1]->GetLineText(0);
500             if( net_ports[1]->GetValue() !=
501                 config_GetInt( p_intf, "server-port" ) )
502             {
503                 mrl = mrl + wxString::Format( wxT(":%d"),
504                                               net_ports[1]->GetValue() );
505             }
506             break;
507
508         case 2:
509             /* http access */     
510             mrl = wxT("http") + demux + wxT("://") +
511                   net_addrs[2]->GetLineText(0);
512             break;
513         }
514         break;
515     case SAT_ACCESS:
516         mrl = wxT("satellite") + demux + wxT("://");
517         break;
518     default:
519         break;
520     }
521
522     mrl_combo->SetValue( mrl );
523 }
524
525 /*****************************************************************************
526  * Events methods.
527  *****************************************************************************/
528 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
529 {
530     EndModal( wxID_OK );
531 }
532
533 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
534 {
535     EndModal( wxID_CANCEL );
536 }
537
538 void OpenDialog::OnPageChange( wxNotebookEvent& event )
539 {
540     UpdateMRL( event.GetSelection() );
541 }
542
543 void OpenDialog::OnMRLChange( wxCommandEvent& event )
544 {
545     mrl = event.GetString();
546 }
547
548 /*****************************************************************************
549  * File panel event methods.
550  *****************************************************************************/
551 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
552 {
553     UpdateMRL( FILE_ACCESS );
554 }
555
556 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
557 {
558     wxFileDialog dialog( this, wxU(_("Open file")),
559                          wxT(""), wxT(""), wxT("*.*"), wxOPEN );
560
561     if( dialog.ShowModal() == wxID_OK )
562     {
563         file_combo->SetValue( dialog.GetPath() );      
564         UpdateMRL( FILE_ACCESS );
565     }
566 }
567
568 /*****************************************************************************
569  * Disc panel event methods.
570  *****************************************************************************/
571 void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
572 {
573     UpdateMRL( DISC_ACCESS );
574 }
575
576 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
577 {
578     char *psz_device;
579
580     switch( disc_type->GetSelection() )
581     {
582     case 2:
583         psz_device = config_GetPsz( p_intf, "vcd" );
584         disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
585         break;
586
587     default:
588         psz_device = config_GetPsz( p_intf, "dvd" );
589         disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
590         break;
591     }
592
593     if( psz_device ) free( psz_device );
594
595     switch( disc_type->GetSelection() )
596     {
597     case 1:
598         disc_title->SetRange( 0, 255 );
599         disc_title->SetValue( 0 );
600         break;
601
602     default:
603         disc_title->SetRange( 1, 255 );
604         disc_title->SetValue( 1 );
605         break;
606     }
607
608     disc_chapter->SetRange( 1, 255 );
609     disc_chapter->SetValue( 1 );
610
611     UpdateMRL( DISC_ACCESS );
612 }
613
614 /*****************************************************************************
615  * Net panel event methods.
616  *****************************************************************************/
617 void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
618 {
619     UpdateMRL( NET_ACCESS );
620 }
621
622 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
623 {
624     int i;
625
626     i_net_type = event.GetId() - NetRadio1_Event;
627
628     for(i=0; i<3; i++)
629     {
630         net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
631         net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
632     }
633
634     UpdateMRL( NET_ACCESS );
635 }
636
637 /*****************************************************************************
638  * Stream output event methods.
639  *****************************************************************************/
640 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
641 {
642     sout_button->Enable( event.GetInt() != 0 );
643     if( !event.GetInt() )
644     {
645         config_PutPsz( p_intf, "sout", "" );
646     }
647     else
648     {
649         demuxdump_checkbox->SetValue( 0 );
650         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
651         event.SetInt( 0 );
652         OnDemuxDumpEnable( event );
653     }
654 }
655
656 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
657 {
658     /* Show/hide the open dialog */
659     SoutDialog dialog( p_intf, p_parent );
660
661     if( dialog.ShowModal() == wxID_OK )
662     {
663         config_PutPsz( p_intf, "sout", (const char *)dialog.mrl.mb_str() );
664     }
665 }
666
667 /*****************************************************************************
668  * Demux dump event methods.
669  *****************************************************************************/
670 void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
671 {
672     demuxdump_textctrl->Enable( event.GetInt() != 0 );
673     demuxdump_button->Enable( event.GetInt() != 0 );
674
675     if( event.GetInt() )
676     {
677         sout_checkbox->SetValue( 0 );
678         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
679         event.SetInt( 0 );
680         OnSoutEnable( event );
681     }
682
683     UpdateMRL( i_current_access_method );
684 }
685
686 void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
687 {
688     wxFileDialog dialog( this, wxU(_("Save file")),
689                          wxT(""), wxT(""), wxT("*.*"), wxSAVE );
690
691     if( dialog.ShowModal() == wxID_OK )
692     {
693         demuxdump_textctrl->SetValue( dialog.GetPath() );
694         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
695         OnDemuxDumpChange( event );
696     }
697 }
698
699 void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
700 {
701     config_PutPsz( p_intf, "demuxdump-file",
702                    demuxdump_textctrl->GetValue().mb_str() );
703 }