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