* modules/gui/wxwindows/*: the wxWindows plugin is now UNICODE happy.
[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.18 2003/05/11 13:22:23 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 #   include "../skins/src/wxdialogs.h"
55 #else
56 #   include "wxwindows.h"
57 #endif
58
59 #ifndef wxRB_SINGLE
60 #   define wxRB_SINGLE 0
61 #endif
62
63 /*****************************************************************************
64  * Event Table.
65  *****************************************************************************/
66
67 /* IDs for the controls and the menu commands */
68 enum
69 {
70     Notebook_Event = wxID_HIGHEST,
71     MRL_Event,
72
73     FileBrowse_Event,
74     FileName_Event,
75
76     DiscType_Event,
77     DiscDevice_Event,
78     DiscTitle_Event,
79     DiscChapter_Event,
80
81     NetType_Event,
82     NetRadio1_Event, NetRadio2_Event, NetRadio3_Event,
83     NetPort1_Event, NetPort2_Event, NetPort3_Event,
84     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
85
86     SoutEnable_Event,
87     SoutSettings_Event,
88
89     DemuxDump_Event,
90     DemuxDumpEnable_Event,
91     DemuxDumpBrowse_Event,
92 };
93
94 BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
95     /* Button events */
96     EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
97     EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
98
99     EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
100
101     EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange) 
102
103     /* Events generated by the file panel */
104     EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
105     EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
106
107     /* Events generated by the disc panel */
108     EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
109     EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
110     EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
111     EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
112     EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
113     EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
114
115     /* Events generated by the net panel */
116     EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
117     EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
118     EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
119     EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
120     EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
121     EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
122     EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
123     EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
124     EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
125     EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
126     EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
127
128     /* Events generated by the stream output buttons */
129     EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
130     EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
131
132     /* Events generated by the demux dump buttons */
133     EVT_CHECKBOX(DemuxDumpEnable_Event, OpenDialog::OnDemuxDumpEnable)
134     EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
135     EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)
136
137 END_EVENT_TABLE()
138
139 /*****************************************************************************
140  * Constructor.
141  *****************************************************************************/
142 OpenDialog::OpenDialog( intf_thread_t *_p_intf, Interface *_p_main_interface,
143                         int i_access_method ):
144     wxDialog( _p_main_interface, -1, wxU(_("Open Target")), wxDefaultPosition,
145              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
146 {
147     /* Initializations */
148     p_intf = _p_intf;
149     p_main_interface = _p_main_interface;
150     SetIcon( *p_intf->p_sys->p_icon );
151
152     /* Create a panel to put everything in */
153     wxPanel *panel = new wxPanel( this, -1 );
154     panel->SetAutoLayout( TRUE );
155
156     /* Create MRL combobox */
157     wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
158     wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
159                                wxU(_("Media Resource Locator (MRL)")) );
160     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
161                                                         wxHORIZONTAL );
162     wxStaticText *mrl_label = new wxStaticText( panel, -1,
163                                                 wxU(_("Open Target:")) );
164     mrl_combo = new wxComboBox( panel, MRL_Event, mrl,
165                                 wxPoint(20,25), wxSize(120, -1),
166                                 0, NULL );
167     mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
168         "the full MRL you want to open.\n""Alternatively, the field will be "
169         "filled automatically when you use the controls below")) );
170
171     mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
172     mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
173     mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
174
175
176     /* Create Static Text */
177     wxStaticText *label = new wxStaticText( panel, -1,
178         wxU(_("Alternatively, you can build an MRL using one of the "
179               "following predefined targets:")) );
180
181     /* Create Stream Output checkox */
182     wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
183     sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
184                                     wxU(_("Stream output")) );
185     sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
186     sout_sizer->Add( sout_checkbox, 0,
187                      wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
188     sout_button = new wxButton( panel, SoutSettings_Event,
189                                 wxU(_("Settings...")) );
190     sout_button->Disable();
191
192     char *psz_sout = config_GetPsz( p_intf, "sout" );
193     if( psz_sout && *psz_sout )
194     {
195         sout_checkbox->SetValue(TRUE);
196         sout_button->Enable();
197     }
198     if( psz_sout ) free( psz_sout );
199
200     sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
201
202     /* Create Demux Dump checkox */
203     wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
204     demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
205                                wxU(_("Capture input stream")) );
206     demuxdump_checkbox->SetToolTip(
207         wxU(_("Capture the stream you are playing to a file")) );
208     demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
209                                          wxDefaultPosition, wxDefaultSize,
210                                          wxTE_PROCESS_ENTER);
211     demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
212                                      wxU(_("Browse...")) );
213
214     char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
215     if( psz_demuxdump && *psz_demuxdump )
216     {
217         demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
218     }
219     if( psz_demuxdump ) free( psz_demuxdump );
220
221     demuxdump_textctrl->Disable();
222     demuxdump_button->Disable();
223     demuxdump_sizer->Add( demuxdump_checkbox, 0,
224                           wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 10 );
225     demuxdump_sizer->Add( demuxdump_button, 0,
226                           wxALL | wxALIGN_CENTER_VERTICAL, 10 );
227     demuxdump_sizer->Add( demuxdump_textctrl, 1, wxALL, 10 );
228
229     /* Separation */
230     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
231
232     /* Create the buttons */
233     wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
234     ok_button->SetDefault();
235     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
236                                             wxU(_("Cancel")) );
237
238     /* Create notebook */
239     wxNotebook *notebook = new wxNotebook( panel, Notebook_Event );
240     wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
241
242     notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
243                        i_access_method == FILE_ACCESS );
244     notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
245                        i_access_method == DISC_ACCESS );
246     notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
247                        i_access_method == NET_ACCESS );
248 #ifndef WIN32
249     notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
250                        i_access_method == SAT_ACCESS );
251 #endif
252
253     /* Update Disc panel */
254     wxCommandEvent dummy_event;
255     OnDiscTypeChange( dummy_event );
256
257     /* Update Net panel */
258     dummy_event.SetId( NetRadio1_Event );
259     OnNetTypeChange( dummy_event );
260
261     /* Update MRL */
262     wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
263     OnPageChange( event );
264
265     /* Place everything in sizers */
266     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
267     button_sizer->Add( ok_button, 0, wxALL, 5 );
268     button_sizer->Add( cancel_button, 0, wxALL, 5 );
269     button_sizer->Layout();
270     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
271     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
272     panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
273     panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
274     panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
275     panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
276     panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
277     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
278     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
279     panel_sizer->Layout();
280     panel->SetSizerAndFit( panel_sizer );
281     main_sizer->Add( panel, 1, wxGROW, 0 );
282     main_sizer->Layout();
283     SetSizerAndFit( main_sizer );
284 }
285
286 OpenDialog::~OpenDialog()
287 {
288 }
289
290 /*****************************************************************************
291  * Private methods.
292  *****************************************************************************/
293 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
294 {
295     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
296                                   wxSize(200, 200) );
297
298     wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
299
300     file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
301                                  wxPoint(20,25), wxSize(200, -1), 0, NULL );
302     wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
303                                             wxU(_("Browse...")) );
304     sizer->Add( file_combo, 1, wxALL, 5 );
305     sizer->Add( browse_button, 0, wxALL, 5 );
306
307     panel->SetSizerAndFit( sizer );
308     return panel;
309 }
310
311 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
312 {
313     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
314                                   wxSize(200, 200) );
315
316     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
317     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
318
319     static const wxString disc_type_array[] =
320     {
321         wxU(_("DVD")),
322         wxU(_("DVD (menus support)")),
323         wxU(_("VCD"))
324     };
325
326     disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
327                                 wxDefaultPosition, wxDefaultSize,
328                                 WXSIZEOF(disc_type_array), disc_type_array,
329                                 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
330     sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
331
332     wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
333     disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
334                                   wxDefaultPosition, wxDefaultSize,
335                                   wxTE_PROCESS_ENTER);
336
337     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
338     sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
339
340     label = new wxStaticText( panel, -1, wxU(_("Title")) );
341     disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
342
343     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
344     sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
345
346     label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
347     disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
348     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
349     sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
350     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
351
352     panel->SetSizerAndFit( sizer_row );
353     return panel;
354 }
355
356 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
357 {
358     int i;
359     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
360                                   wxSize(200, 200) );
361
362     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
363     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
364
365     static const wxString net_type_array[] =
366     {
367         wxU(_("UDP/RTP")),
368         wxU(_("UDP/RTP Multicast")),
369         wxU(_("HTTP/FTP/MMS"))
370     };
371
372     for( i=0; i<3; i++ )
373     {
374         net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
375                                            net_type_array[i],
376                                            wxDefaultPosition, wxDefaultSize,
377                                            wxRB_SINGLE );
378
379         net_subpanels[i] = new wxPanel( panel, -1,
380                                         wxDefaultPosition, wxDefaultSize );
381     }
382
383     /* UDP/RTP row */
384     wxFlexGridSizer *subpanel_sizer;
385     wxStaticText *label;
386     int val = config_GetInt( p_intf, "server-port" );
387     subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
388     label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
389     net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
390                                    wxString::Format(wxT("%d"), val),
391                                    wxDefaultPosition, wxDefaultSize,
392                                    wxSP_ARROW_KEYS,
393                                    0, 16000, val);
394
395     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
396     subpanel_sizer->Add( net_ports[0], 1,
397                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
398     net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
399     net_radios[0]->SetValue( TRUE );
400
401     /* UDP/RTP Multicast row */
402     subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
403     label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
404     net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
405                                    wxDefaultPosition, wxDefaultSize,
406                                    wxTE_PROCESS_ENTER);
407     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
408     subpanel_sizer->Add( net_addrs[1], 1,
409                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
410
411     label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
412     net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
413                                    wxString::Format(wxT("%d"), val),
414                                    wxDefaultPosition, wxDefaultSize,
415                                    wxSP_ARROW_KEYS,
416                                    0, 16000, val);
417
418     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
419     subpanel_sizer->Add( net_ports[1], 1,
420                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
421     net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
422
423     /* HTTP row */
424     subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
425     label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
426     net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
427                                    wxDefaultPosition, wxSize( 200, -1 ),
428                                    wxTE_PROCESS_ENTER);
429     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
430     subpanel_sizer->Add( net_addrs[2], 1,
431                          wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
432     net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
433
434     /* Stuff everything into the main panel */
435     for( i=0; i<3; i++ )
436     {
437         sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
438         sizer->Add( net_subpanels[i], 1,
439                     wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
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_main_interface );
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 }