open.cpp 43.4 KB
Newer Older
gbazin's avatar
   
gbazin committed
1
2
3
/*****************************************************************************
 * open.cpp : wxWindows plugin for vlc
 *****************************************************************************
4
 * Copyright (C) 2000, 2001, 2003 VideoLAN
5
 * $Id: open.cpp,v 1.58 2003/12/16 13:35:12 gbazin Exp $
gbazin's avatar
   
gbazin committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 *
 * Authors: Gildas Bazin <gbazin@netcourrier.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <stdlib.h>                                      /* malloc(), free() */
#include <errno.h>                                                 /* ENOMEM */
#include <string.h>                                            /* strerror() */
#include <stdio.h>

#include <vlc/vlc.h>

#ifdef WIN32                                                 /* mingw32 hack */
#undef Yield
#undef CreateDialog
#endif

/* Let vlc take care of the i18n stuff */
#define WXINTL_NO_GETTEXT_MACRO

#include <wx/wxprec.h>
#include <wx/wx.h>
#include <wx/notebook.h>
#include <wx/textctrl.h>
#include <wx/combobox.h>
#include <wx/spinctrl.h>
gbazin's avatar
   
gbazin committed
48
#include <wx/statline.h>
gbazin's avatar
   
gbazin committed
49
#include <wx/tokenzr.h>
gbazin's avatar
   
gbazin committed
50
51
52

#include <vlc/intf.h>

gbazin's avatar
   
gbazin committed
53
54
#include "wxwindows.h"

gbazin's avatar
   
gbazin committed
55
56
#include "preferences_widgets.h"

57
#ifndef wxRB_SINGLE
gbazin's avatar
   
gbazin committed
58
#   define wxRB_SINGLE 0
59
60
#endif

gbazin's avatar
   
gbazin committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*****************************************************************************
 * Event Table.
 *****************************************************************************/

/* IDs for the controls and the menu commands */
enum
{
    Notebook_Event = wxID_HIGHEST,
    MRL_Event,

    FileBrowse_Event,
    FileName_Event,

    DiscType_Event,
    DiscDevice_Event,
    DiscTitle_Event,
    DiscChapter_Event,

    NetType_Event,
80
    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
gbazin's avatar
   
gbazin committed
81
    NetPort1_Event, NetPort2_Event, NetPort3_Event,
82
    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
83
    NetForceIPv6_Event,
gbazin's avatar
   
gbazin committed
84

85
#ifndef WIN32
86
87
88
89
    VideoType_Event,
    VideoDevice_Event,
    VideoChannel_Event,
    V4LSettings_Event,
90
#endif
91

gbazin's avatar
   
gbazin committed
92
93
94
    SubsFileEnable_Event,
    SubsFileSettings_Event,

gbazin's avatar
   
gbazin committed
95
96
    SoutEnable_Event,
    SoutSettings_Event,
gbazin's avatar
   
gbazin committed
97
98
};

gbazin's avatar
   
gbazin committed
99
BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
gbazin's avatar
   
gbazin committed
100
101
102
103
104
105
    /* Button events */
    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)

    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)

106
    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
gbazin's avatar
   
gbazin committed
107
108
109

    /* Events generated by the file panel */
    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
gbazin's avatar
   
gbazin committed
110
    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
gbazin's avatar
   
gbazin committed
111
112
113

    /* Events generated by the disc panel */
    EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
yoann's avatar
yoann committed
114
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
gbazin's avatar
   
gbazin committed
115
116
117
118
119
120
121
122
123
124
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
    EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
    EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
    EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
    EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)

    /* Events generated by the net panel */
    EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
125
    EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
gbazin's avatar
   
gbazin committed
126
127
128
129
130
131
132
133
    EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
    EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
    EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
    EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
134
    EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
135
    EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
gbazin's avatar
   
gbazin committed
136

137
#ifndef WIN32
138
139
140
141
142
    /* Events generated by the v4l panel */
    EVT_RADIOBOX(VideoType_Event, OpenDialog::OnV4LTypeChange)
    EVT_TEXT(VideoDevice_Event, OpenDialog::OnV4LPanelChange)
    EVT_SPINCTRL(VideoChannel_Event, OpenDialog::OnV4LPanelChange)
    EVT_BUTTON(V4LSettings_Event, OpenDialog::OnV4LSettingsChange)
143
#endif
144

gbazin's avatar
   
gbazin committed
145
146
147
148
    /* Events generated by the subtitle file buttons */
    EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
    EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)

gbazin's avatar
   
gbazin committed
149
150
151
    /* Events generated by the stream output buttons */
    EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
    EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
gbazin's avatar
   
gbazin committed
152

gbazin's avatar
   
gbazin committed
153
154
155
    /* Hide the window when the user closes the window */
    EVT_CLOSE(OpenDialog::OnCancel)

gbazin's avatar
   
gbazin committed
156
157
END_EVENT_TABLE()

158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*****************************************************************************
 * AutoBuiltPanel.
 *****************************************************************************/
WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);

class AutoBuiltPanel : public wxPanel
{
public:

    AutoBuiltPanel() { }
    AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *,
                    const module_t * );

    virtual ~AutoBuiltPanel() {}

    wxString name;
    ArrayOfConfigControls config_array;

private:
    intf_thread_t *p_intf;
};

void AutoBuildCallback( void *p_data )
{
    ((OpenDialog *)p_data)->UpdateMRL();
}

AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
                                intf_thread_t *_p_intf,
                                const module_t *p_module )
  : wxPanel( parent, -1, wxDefaultPosition, wxSize(200, 200) ),
    name( wxU(p_module->psz_object_name) ), p_intf( _p_intf )
{
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

    module_config_t *p_item = p_module->p_config;

    if( p_item ) do
    {
        if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
            continue;

        ConfigControl *control =
            CreateConfigControl( VLC_OBJECT(p_intf), p_item, this );

        config_array.Add( control );

        /* Don't add items that were not recognized */
        if( control == NULL ) continue;

        control->SetUpdateCallback( AutoBuildCallback, (void *)dialog );

        sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
    }
    while( p_item->i_type != CONFIG_HINT_END && p_item++ );

    this->SetSizerAndFit( sizer );
}

gbazin's avatar
   
gbazin committed
217
218
219
/*****************************************************************************
 * Constructor.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
220
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
gbazin's avatar
   
gbazin committed
221
222
                        int i_access_method, int i_arg ):
    wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
gbazin's avatar
   
gbazin committed
223
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
zorglub's avatar
zorglub committed
224
225
226
227
228
229
230
231
{
    OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
}

OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
                        int i_access_method, int i_arg, int _i_method ):
    wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
gbazin's avatar
   
gbazin committed
232
233
{
    /* Initializations */
zorglub's avatar
zorglub committed
234
    i_method = _i_method;
gbazin's avatar
   
gbazin committed
235
    p_intf = _p_intf;
gbazin's avatar
   
gbazin committed
236
    p_parent = _p_parent;
gbazin's avatar
   
gbazin committed
237
    SetIcon( *p_intf->p_sys->p_icon );
gbazin's avatar
   
gbazin committed
238
    file_dialog = NULL;
239
240
    i_disc_type_selection = 0;
    
241
#ifndef WIN32
242
    v4l_dialog = NULL;
243
#endif
gbazin's avatar
   
gbazin committed
244
245
    sout_dialog = NULL;
    subsfile_dialog = NULL;
yoann's avatar
yoann committed
246
    b_disc_device_changed = false;
gbazin's avatar
   
gbazin committed
247
248
249
250
251
252
253
254

    /* Create a panel to put everything in */
    wxPanel *panel = new wxPanel( this, -1 );
    panel->SetAutoLayout( TRUE );

    /* Create MRL combobox */
    wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
    wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
gbazin's avatar
   
gbazin committed
255
                               wxU(_("Media Resource Locator (MRL)")) );
gbazin's avatar
   
gbazin committed
256
257
258
    wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
                                                        wxHORIZONTAL );
    wxStaticText *mrl_label = new wxStaticText( panel, -1,
gbazin's avatar
   
gbazin committed
259
                                                wxU(_("Open Target:")) );
gbazin's avatar
   
gbazin committed
260
    mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
gbazin's avatar
   
gbazin committed
261
262
                                wxPoint(20,25), wxSize(120, -1),
                                0, NULL );
gbazin's avatar
   
gbazin committed
263
264
    mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
        "the full MRL you want to open.\n""Alternatively, the field will be "
gbazin's avatar
   
gbazin committed
265
        "filled automatically when you use the controls below.")) );
gbazin's avatar
   
gbazin committed
266

gbazin's avatar
   
gbazin committed
267
268
    mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
    mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
gbazin's avatar
   
gbazin committed
269
270
271
272
273
    mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );


    /* Create Static Text */
    wxStaticText *label = new wxStaticText( panel, -1,
gbazin's avatar
   
gbazin committed
274
275
        wxU(_("Alternatively, you can build an MRL using one of the "
              "following predefined targets:")) );
gbazin's avatar
   
gbazin committed
276

zorglub's avatar
zorglub committed
277
278
279
280
    wxFlexGridSizer *sout_sizer = NULL;
    wxStaticLine *static_line = NULL;

    if( i_method == OPEN_NORMAL )
gbazin's avatar
   
gbazin committed
281
    {
zorglub's avatar
zorglub committed
282
283
        /* Create Stream Output checkox */
        sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
gbazin's avatar
   
gbazin committed
284
285


zorglub's avatar
zorglub committed
286
287
288
289
290
291
292
        sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
                                         wxU(_("Stream output")) );
        sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
        sout_sizer->Add( sout_checkbox, 0,
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
        sout_button = new wxButton( panel, SoutSettings_Event,
                                    wxU(_("Settings...")) );
yoann's avatar
yoann committed
293
        sout_button->Disable();
zorglub's avatar
zorglub committed
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309

        char *psz_sout = config_GetPsz( p_intf, "sout" );
        if( psz_sout && *psz_sout )
        {
            sout_checkbox->SetValue(TRUE);
            sout_button->Enable();
            subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) );
        }
        if( psz_sout ) free( psz_sout );

        sout_sizer->Add( sout_button, 1, wxALIGN_LEFT |
                         wxALIGN_CENTER_VERTICAL );

        /* Separation */
        static_line = new wxStaticLine( panel, wxID_OK );
    }
gbazin's avatar
   
gbazin committed
310

gbazin's avatar
   
gbazin committed
311
    /* Create the buttons */
gbazin's avatar
   
gbazin committed
312
    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
gbazin's avatar
   
gbazin committed
313
    ok_button->SetDefault();
gbazin's avatar
   
gbazin committed
314
315
    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
                                            wxU(_("Cancel")) );
gbazin's avatar
   
gbazin committed
316

gbazin's avatar
   
gbazin committed
317
    /* Create notebook */
gbazin's avatar
   
gbazin committed
318
    notebook = new wxNotebook( panel, Notebook_Event );
gbazin's avatar
   
gbazin committed
319
320
    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );

gbazin's avatar
   
gbazin committed
321
    notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
gbazin's avatar
   
gbazin committed
322
                       i_access_method == FILE_ACCESS );
gbazin's avatar
   
gbazin committed
323
    notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
gbazin's avatar
   
gbazin committed
324
                       i_access_method == DISC_ACCESS );
gbazin's avatar
   
gbazin committed
325
    notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
gbazin's avatar
   
gbazin committed
326
                       i_access_method == NET_ACCESS );
gbazin's avatar
   
gbazin committed
327
#ifndef WIN32
328
329
    notebook->AddPage( V4LPanel( notebook ), wxU(_("Video For Linux")),
                       i_access_method == V4L_ACCESS );
330
#endif
331

gbazin's avatar
   
gbazin committed
332
333
334
    module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
    if( p_module )
    {
335
336
337
338
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
        notebook->AddPage( autopanel, wxU( p_module->psz_longname ) );
gbazin's avatar
   
gbazin committed
339
340
    }

gbazin's avatar
   
gbazin committed
341
342
343
344
    /* Update Disc panel */
    wxCommandEvent dummy_event;
    OnDiscTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
345
346
347
348
    /* Update Net panel */
    dummy_event.SetId( NetRadio1_Event );
    OnNetTypeChange( dummy_event );

349
#ifndef WIN32
350
351
352
    /* Update v4l panel */
    dummy_event.SetId( VideoType_Event );
    OnV4LTypeChange( dummy_event );
353
#endif
354

gbazin's avatar
   
gbazin committed
355
    /* Update MRL */
356
    wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
gbazin's avatar
   
gbazin committed
357
358
359
360
361
362
363
364
365
366
367
    OnPageChange( event );

    /* Place everything in sizers */
    wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
    button_sizer->Add( ok_button, 0, wxALL, 5 );
    button_sizer->Add( cancel_button, 0, wxALL, 5 );
    button_sizer->Layout();
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
    panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
    panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
368
    panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
zorglub's avatar
zorglub committed
369
370
371
372
373
    if( i_method == OPEN_NORMAL)
    {
        panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
        panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
    }
gbazin's avatar
   
gbazin committed
374
    panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
gbazin's avatar
   
gbazin committed
375
376
377
378
379
380
381
382
383
    panel_sizer->Layout();
    panel->SetSizerAndFit( panel_sizer );
    main_sizer->Add( panel, 1, wxGROW, 0 );
    main_sizer->Layout();
    SetSizerAndFit( main_sizer );
}

OpenDialog::~OpenDialog()
{
gbazin's avatar
   
gbazin committed
384
385
    /* Clean up */
    if( file_dialog ) delete file_dialog;
386
#ifndef WIN32
387
    if( v4l_dialog ) delete v4l_dialog;
388
#endif
gbazin's avatar
   
gbazin committed
389
390
    if( sout_dialog ) delete sout_dialog;
    if( subsfile_dialog ) delete subsfile_dialog;
gbazin's avatar
   
gbazin committed
391
392
}

gbazin's avatar
   
gbazin committed
393
int OpenDialog::Show( int i_access_method, int i_arg )
gbazin's avatar
   
gbazin committed
394
{
gbazin's avatar
   
gbazin committed
395
    int i_ret;
gbazin's avatar
   
gbazin committed
396
    notebook->SetSelection( i_access_method );
gbazin's avatar
   
gbazin committed
397
398
399
400
    i_ret = wxFrame::Show();
    Raise();
    SetFocus();
    return i_ret;
gbazin's avatar
   
gbazin committed
401
402
}

gbazin's avatar
   
gbazin committed
403
int OpenDialog::Show()
gbazin's avatar
   
gbazin committed
404
{
gbazin's avatar
   
gbazin committed
405
406
407
408
409
    int i_ret;
    i_ret = wxFrame::Show();
    Raise();
    SetFocus();
    return i_ret;
gbazin's avatar
   
gbazin committed
410
411
}

gbazin's avatar
   
gbazin committed
412
413
414
415
416
417
418
419
/*****************************************************************************
 * Private methods.
 *****************************************************************************/
wxPanel *OpenDialog::FilePanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

gbazin's avatar
   
gbazin committed
420
421
422
423
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

    /* Create browse file line */
    wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
gbazin's avatar
   
gbazin committed
424

gbazin's avatar
   
gbazin committed
425
    file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
gbazin's avatar
   
gbazin committed
426
427
                                 wxPoint(20,25), wxSize(200, -1), 0, NULL );
    wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
gbazin's avatar
   
gbazin committed
428
                                            wxU(_("Browse...")) );
gbazin's avatar
   
gbazin committed
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
    file_sizer->Add( file_combo, 1, wxALL, 5 );
    file_sizer->Add( browse_button, 0, wxALL, 5 );

    /* Create Subtitles File checkox */
    wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
    subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
                                        wxU(_("Subtitles file")) );
    subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
                                   "Currently only works with AVI files.")) );
    subsfile_sizer->Add( subsfile_checkbox, 0,
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subsfile_button = new wxButton( panel, SubsFileSettings_Event,
                                    wxU(_("Settings...")) );
    subsfile_button->Disable();

    char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
    if( psz_subsfile && *psz_subsfile )
    {
        subsfile_checkbox->SetValue(TRUE);
        subsfile_button->Enable();
        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxU(psz_subsfile) );
    }
    if( psz_subsfile ) free( psz_subsfile );

    subsfile_sizer->Add( subsfile_button, 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
455

gbazin's avatar
   
gbazin committed
456
457
    sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
    sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
458
459
460
461
462
463
464
465
466
467
468
469
470
471
    panel->SetSizerAndFit( sizer );
    return panel;
}

wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );

    static const wxString disc_type_array[] =
    {
gbazin's avatar
   
gbazin committed
472
        wxU(_("DVD (menus support)")),
gbazin's avatar
   
gbazin committed
473
474
475
476
        wxU(_("DVD")),
        wxU(_("VCD")),
        wxU(_("CD Audio"))

gbazin's avatar
   
gbazin committed
477
478
    };

gbazin's avatar
   
gbazin committed
479
    disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
gbazin's avatar
   
gbazin committed
480
481
482
                                wxDefaultPosition, wxDefaultSize,
                                WXSIZEOF(disc_type_array), disc_type_array,
                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
483
484
    
    sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
485

gbazin's avatar
   
gbazin committed
486
487
    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
    disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
gbazin's avatar
   
gbazin committed
488
489
490
491
492
493
                                  wxDefaultPosition, wxDefaultSize,
                                  wxTE_PROCESS_ENTER);

    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

494
    disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
gbazin's avatar
   
gbazin committed
495
    disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
gbazin's avatar
   
gbazin committed
496

497
    sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
498
499
    sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

500
    disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
gbazin's avatar
   
gbazin committed
501
    disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
502
503
    sizer->Add( disc_chapter_label, 0, 
		wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
504
505
506
507
508
509
510
511
512
513
514
515
516
517
    sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );

    panel->SetSizerAndFit( sizer_row );
    return panel;
}

wxPanel *OpenDialog::NetPanel( wxWindow* parent )
{
    int i;
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
518
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
gbazin's avatar
   
gbazin committed
519
520
521

    static const wxString net_type_array[] =
    {
gbazin's avatar
   
gbazin committed
522
523
        wxU(_("UDP/RTP")),
        wxU(_("UDP/RTP Multicast")),
524
525
        wxU(_("HTTP/FTP/MMS")),
        wxU(_("RTSP"))
gbazin's avatar
   
gbazin committed
526
527
    };

528
    for( i=0; i<4; i++ )
gbazin's avatar
   
gbazin committed
529
530
531
532
533
534
535
536
537
538
539
540
541
    {
        net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
                                           net_type_array[i],
                                           wxDefaultPosition, wxDefaultSize,
                                           wxRB_SINGLE );

        net_subpanels[i] = new wxPanel( panel, -1,
                                        wxDefaultPosition, wxDefaultSize );
    }

    /* UDP/RTP row */
    wxFlexGridSizer *subpanel_sizer;
    wxStaticText *label;
gbazin's avatar
   
gbazin committed
542
    i_net_ports[0] = config_GetInt( p_intf, "server-port" );
543
    subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
gbazin's avatar
   
gbazin committed
544
    label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
545
    net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
gbazin's avatar
   
gbazin committed
546
                                   wxString::Format(wxT("%d"), i_net_ports[0]),
gbazin's avatar
   
gbazin committed
547
548
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
gbazin's avatar
   
gbazin committed
549
                                   0, 16000, i_net_ports[0] );
gbazin's avatar
   
gbazin committed
550
551
552
553

    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_ports[0], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
554
555
556
557
    net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
                               wxU(_("Force IPv6")));
    subpanel_sizer->Add( net_ipv6, 0,
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
558
    net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
gbazin's avatar
   
gbazin committed
559
    net_radios[0]->SetValue( TRUE );
gbazin's avatar
   
gbazin committed
560
561
562

    /* UDP/RTP Multicast row */
    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
gbazin's avatar
   
gbazin committed
563
564
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
    net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
gbazin's avatar
   
gbazin committed
565
566
567
568
569
570
                                   wxDefaultPosition, wxDefaultSize,
                                   wxTE_PROCESS_ENTER);
    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_addrs[1], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

gbazin's avatar
   
gbazin committed
571
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
572
    i_net_ports[1] = i_net_ports[0];
gbazin's avatar
   
gbazin committed
573
    net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
gbazin's avatar
   
gbazin committed
574
                                   wxString::Format(wxT("%d"), i_net_ports[1]),
gbazin's avatar
   
gbazin committed
575
576
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
gbazin's avatar
   
gbazin committed
577
                                   0, 16000, i_net_ports[1] );
gbazin's avatar
   
gbazin committed
578
579
580
581
582
583

    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_ports[1], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    net_subpanels[1]->SetSizerAndFit( subpanel_sizer );

584
585
586
587
588
589
590
591
592
593
594
595
596
597
    /* HTTP and RTSP rows */
    for( i=2; i<4; i++ )
    {
        subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
        label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
        net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
                                       wxT((i == 2) ? "" : "rtsp://"),
                                       wxDefaultPosition, wxSize( 200, -1 ),
                                       wxTE_PROCESS_ENTER);
        subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
        subpanel_sizer->Add( net_addrs[i], 1,
                             wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
        net_subpanels[i]->SetSizerAndFit( subpanel_sizer );
    }
gbazin's avatar
   
gbazin committed
598
599

    /* Stuff everything into the main panel */
600
    for( i=0; i<4; i++ )
gbazin's avatar
   
gbazin committed
601
    {
gbazin's avatar
   
gbazin committed
602
603
604
605
        sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
                    wxALL, 5 );
        sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
                    wxALIGN_CENTER_VERTICAL | wxALL, 5  );
gbazin's avatar
   
gbazin committed
606
607
608
609
610
611
612
613
    }

    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );

    panel->SetSizerAndFit( sizer_row );
    return panel;
}

614
#ifndef WIN32
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
wxPanel *OpenDialog::V4LPanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 1, 4, 20 );

    static const wxString video_type_array[] =
    {
        wxU(_("WebCam")),
        wxU(_("TV Card")),
        wxU(_("PVR")),
        wxU(_("Kfir")),
    };

    video_type = new wxRadioBox( panel, VideoType_Event,
            wxU(_("Video Device Type")),
            wxDefaultPosition, wxDefaultSize,
            WXSIZEOF(video_type_array), video_type_array,
            WXSIZEOF(video_type_array), wxRA_SPECIFY_COLS );

    sizer_row->Add( video_type, 0, wxEXPAND | wxALL, 5 );


    /* Video Options */
    wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 2, 20 );
    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Video Device")) );
    video_device = new wxTextCtrl( panel, VideoDevice_Event, wxT(""),
                                  wxDefaultPosition, wxDefaultSize,
                                  wxTE_PROCESS_ENTER);
646
647
    video_device->SetToolTip( wxU(_("Device corresponding to your acquisition "
                                    "card or your webcam")) );
648
649
650
651
    video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    video_sizer->Add( video_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

    label = new wxStaticText( panel, -1, wxU(_("Channel")) );
652
653
654
    video_channel = new wxSpinCtrl( panel, VideoChannel_Event, wxT("0") );
    video_channel->SetToolTip( wxU(_("Usually 0 is for tuner, 1 for composite "
                                     "and 2 for svideo")) );
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
    video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
    video_sizer->Add( video_channel, 1, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
    sizer->Add( video_sizer, 0, wxEXPAND | wxALL, 5 );

    wxBoxSizer *v4lbutton_sizer = new wxBoxSizer( wxHORIZONTAL );
    v4l_button = new wxButton( panel, V4LSettings_Event,
                            wxU(_("Advanced Settings...")) );

    v4lbutton_sizer->Add( v4l_button, 0, wxALIGN_RIGHT, 5 );

    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
    sizer_row->Add( v4lbutton_sizer, 0, wxEXPAND | wxALL, 5 );

    panel->SetSizerAndFit( sizer_row );
    return panel;
}
671
#endif
672

673
void OpenDialog::UpdateMRL()
gbazin's avatar
   
gbazin committed
674
{
675
    UpdateMRL( i_current_access_method );
gbazin's avatar
   
gbazin committed
676
677
678
679
}

void OpenDialog::UpdateMRL( int i_access_method )
{
gbazin's avatar
   
gbazin committed
680
    wxString demux, mrltemp;
gbazin's avatar
   
gbazin committed
681
682
683

    i_current_access_method = i_access_method;

gbazin's avatar
   
gbazin committed
684
685
686
    switch( i_access_method )
    {
    case FILE_ACCESS:
gbazin's avatar
   
gbazin committed
687
688
        //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
        mrltemp = file_combo->GetValue();
gbazin's avatar
   
gbazin committed
689
690
        break;
    case DISC_ACCESS:
691
692
      i_disc_type_selection = disc_type->GetSelection();

693
      switch ( i_disc_type_selection )
Rocky Bernstein's avatar
Rocky Bernstein committed
694
695
	{
	case 0:
696
697
	  disc_chapter->Enable();
	  disc_chapter_label->Enable();
698
          mrltemp = wxT("dvd://")
yoann's avatar
yoann committed
699
                  + disc_device->GetValue()
gbazin's avatar
   
gbazin committed
700
                  + wxString::Format( wxT("@%d:%d"),
gbazin's avatar
   
gbazin committed
701
702
                                      disc_title->GetValue(),
                                      disc_chapter->GetValue() );
Rocky Bernstein's avatar
Rocky Bernstein committed
703
704
	  break;
	case 1:
705
706
	  disc_chapter->Enable();
	  disc_chapter_label->Enable();
707
	  mrltemp = wxT("dvdsimple://")
Rocky Bernstein's avatar
Rocky Bernstein committed
708
709
710
711
712
713
                  + disc_device->GetValue()
                  + wxString::Format( wxT("@%d:%d"),
                                      disc_title->GetValue(),
                                      disc_chapter->GetValue() );
	  break;
	case 2:
714
715
	  disc_chapter->Disable();
	  disc_chapter_label->Disable();
Rocky Bernstein's avatar
Rocky Bernstein committed
716
#ifdef HAVE_VCDX
717
	  if ( disc_title->GetValue() )
718
	    mrltemp = wxT("vcdx://")
719
	      + disc_device->GetValue()
720
	      + wxString::Format( wxT("@%c%d"),
721
722
723
724
				  config_GetInt( p_intf, "vcdx-PBC"  )
				  ? 'P' : 'E',
				  disc_title->GetValue()
				  );
725
	  else
726
727
	    mrltemp = wxT("vcdx://")
                  + disc_device->GetValue();
Rocky Bernstein's avatar
Rocky Bernstein committed
728
#else
729
	  mrltemp = wxT("vcd://")
Rocky Bernstein's avatar
Rocky Bernstein committed
730
                  + disc_device->GetValue()
731
732
                  + wxString::Format( wxT("@%d"),
                                      disc_title->GetValue() );
Rocky Bernstein's avatar
Rocky Bernstein committed
733
734
735
#endif
	  break;
	case 3:
736
737
	  disc_chapter->Disable();
	  disc_chapter_label->Disable();
Rocky Bernstein's avatar
Rocky Bernstein committed
738
#ifdef HAVE_CDDAX
739
	  if ( disc_title->GetValue() )
740
	    mrltemp =  wxT("cddax://")
741
742
743
	          + disc_device->GetValue()
                  + wxString::Format( wxT("@T%d"),
                                      disc_title->GetValue() );
744
	  else
745
746
	    mrltemp = wxT("cddax://")
	          + disc_device->GetValue();
747

Rocky Bernstein's avatar
Rocky Bernstein committed
748
#else
749
	  mrltemp =  wxT("cdda://")
Rocky Bernstein's avatar
Rocky Bernstein committed
750
751
752
753
754
755
                  + disc_device->GetValue()
                  + wxString::Format( wxT("@%d"),
                                      disc_title->GetValue() );
#endif
	  break;
	default: ;
756
	  msg_Err( p_intf, "invalid selection (%d)",
Rocky Bernstein's avatar
Rocky Bernstein committed
757
758
		   disc_type->GetSelection() );
	}
759

gbazin's avatar
   
gbazin committed
760
761
762
763
764
        break;
    case NET_ACCESS:
        switch( i_net_type )
        {
        case 0:
765
            mrltemp = wxT("udp") + demux + wxT("://");
766
767
768
769
            if ( net_ipv6->GetValue() )
            {
                mrltemp += wxT("@[::]");
            }
gbazin's avatar
   
gbazin committed
770
            if( i_net_ports[0] !=
gbazin's avatar
   
gbazin committed
771
772
                config_GetInt( p_intf, "server-port" ) )
            {
773
                mrltemp += wxString::Format( wxT("@:%d"), i_net_ports[0] );
gbazin's avatar
   
gbazin committed
774
775
776
777
            }
            break;

        case 1:
778
779
780
781
782
783
784
785
786
787
788
789
790
            mrltemp = wxT("udp") + demux + wxT("://@");
            if ((net_addrs[1]->GetLineText(0).Find (':') != -1)
                && (net_addrs[1]->GetLineText(0)[0u] != '['))
            {
                /* automatically adds '[' and ']' to IPv6 addresses */
                mrltemp += wxT("[") + net_addrs[1]->GetLineText(0)
                         + wxT("]");
            }
            else
            {
                mrltemp += net_addrs[1]->GetLineText(0);
            }
            if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
gbazin's avatar
   
gbazin committed
791
            {
792
                mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
gbazin's avatar
   
gbazin committed
793
794
795
796
            }
            break;

        case 2:
797
            /* http access */
gbazin's avatar
   
gbazin committed
798
            if( net_addrs[2]->GetLineText(0).Find(wxT("http://")) )
799
800
801
            {
                mrltemp = wxT("http") + demux + wxT("://");
            }
802
803
804
805
806
            mrltemp += net_addrs[2]->GetLineText(0);
            break;

        case 3:
            /* RTSP access */
807
            if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
808
809
810
811
            {
                mrltemp = wxT("rtsp") + demux + wxT("://");
            }
            mrltemp += net_addrs[3]->GetLineText(0);
gbazin's avatar
   
gbazin committed
812
813
814
            break;
        }
        break;
815

816
#ifndef WIN32
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
    case V4L_ACCESS:
        mrltemp = ( video_type->GetSelection() == 0 ? wxT("v4l") :
                    video_type->GetSelection() == 1 ? wxT("v4l") :
                    video_type->GetSelection() == 2 ? wxT("pvr") :
                                                      wxT("kfir") )
            + demux + wxT(":")
            + video_device->GetLineText( 0 );

        if( video_type->GetSelection() == 1 )
        {
            mrltemp += wxString::Format( wxT(":channel=%d"),
                                         video_channel->GetValue() );
        }

        if ( /* v4l_dialog != NULL && */ !v4l_mrl.IsEmpty() )
        {
            mrltemp += v4l_mrl[0];
        }

        break;
837
#endif
838

gbazin's avatar
   
gbazin committed
839
    default:
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
        {
            int i_item = i_access_method - MAX_ACCESS;

            if( i_item < 0 || i_item >= (int)input_tab_array.GetCount() )
                break;

            AutoBuiltPanel *input_panel = input_tab_array.Item( i_item );

            mrltemp = input_panel->name + wxT("://");

            for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
            {
                ConfigControl *control = input_panel->config_array.Item(i);
                mrltemp += wxT(" :") + control->GetName() + wxT("=");

                switch( control->GetType() )
                {
                case CONFIG_ITEM_STRING:
                case CONFIG_ITEM_FILE:
                case CONFIG_ITEM_DIRECTORY:
                case CONFIG_ITEM_MODULE:
                    mrltemp += wxT("\"") + control->GetPszValue() + wxT("\"");
                    break;
                case CONFIG_ITEM_INTEGER:
                case CONFIG_ITEM_BOOL:
                    mrltemp +=
gbazin's avatar
   
gbazin committed
866
                        wxString::Format( wxT("%i"), control->GetIntValue() );
867
868
869
                    break;
                case CONFIG_ITEM_FLOAT:
                    mrltemp +=
gbazin's avatar
   
gbazin committed
870
                        wxString::Format( wxT("%f"), control->GetFloatValue());
871
872
873
874
                    break;
                }
            }
        }
gbazin's avatar
   
gbazin committed
875
876
877
        break;
    }

gbazin's avatar
   
gbazin committed
878
879
880
    mrl_combo->SetValue( mrltemp );
}

gbazin's avatar
   
gbazin committed
881
882
883
884
885
/*****************************************************************************
 * Events methods.
 *****************************************************************************/
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
886
    mrl = SeparateEntries( mrl_combo->GetValue() );
gbazin's avatar
   
gbazin committed
887
888
889
    mrl_combo->Append( mrl_combo->GetValue() );
    if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
    mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
gbazin's avatar
   
gbazin committed
890

zorglub's avatar
zorglub committed
891
892
893
894
895
896
    if( i_method == OPEN_STREAM )
    {
        Hide();
        return;
    }

gbazin's avatar
   
gbazin committed
897
898
899
    /* Update the playlist */
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
900
                                       FIND_ANYWHERE );
901
    if( p_playlist == NULL ) return;
gbazin's avatar
   
gbazin committed
902

903
    for( int i = 0; i < (int)mrl.GetCount(); i++ )
gbazin's avatar
   
gbazin committed
904
    {
905
906
907
908
909
        int i_options = 0, i_total_options;
        char **ppsz_options = NULL;

        /* Count the input options */
        while( i + i_options + 1 < (int)mrl.GetCount() &&
gbazin's avatar
   
gbazin committed
910
               ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
911
912
913
914
915
916
917
918
919
920
921
922
923
        {
            i_options++;
        }

        /* Allocate ppsz_options */
        for( int j = 0; j < i_options; j++ )
        {
            if( !ppsz_options )
                ppsz_options = (char **)malloc( sizeof(char *) * i_options );

            ppsz_options[j] = strdup( mrl[i + j  + 1].mb_str() );
        }

924
        i_total_options = i_options;
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953

        /* Get the options from the subtitles dialog */
        if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
        {
            ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
                               (i_total_options + subsfile_mrl.GetCount()) );

            for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
            {
                ppsz_options[i_total_options + j] =
                    strdup( subsfile_mrl[j].mb_str() );
            }

            i_total_options += subsfile_mrl.GetCount();
        }

        /* Get the options from the stream output dialog */
        if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
        {
            ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
                               (i_total_options + sout_mrl.GetCount()) );

            for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
            {
                ppsz_options[i_total_options + j] =
                    strdup( sout_mrl[j].mb_str() );
            }

            i_total_options += sout_mrl.GetCount();
954

955
956
        }

gbazin's avatar
   
gbazin committed
957
        playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
958
                      (const char **)ppsz_options, i_total_options,
gbazin's avatar
   
gbazin committed
959
                      PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
960
961
962
963
964
965
966

        /* clean up */
        for( int j = 0; j < i_total_options; j++ )
            free( ppsz_options[j] );
        if( ppsz_options ) free( ppsz_options );

        i += i_options;
967
    }
gbazin's avatar
   
gbazin committed
968
969
970
971
972
973

    //TogglePlayButton( PLAYING_S );

    vlc_object_release( p_playlist );

    Hide();
gbazin's avatar
   
gbazin committed
974
975
976
977
}

void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
978
    Hide();
gbazin's avatar
   
gbazin committed
979
980
981
982
983
984
985
986
987
}

void OpenDialog::OnPageChange( wxNotebookEvent& event )
{
    UpdateMRL( event.GetSelection() );
}

void OpenDialog::OnMRLChange( wxCommandEvent& event )
{
gbazin's avatar
   
gbazin committed
988
    //mrl = SeparateEntries( event.GetString() );
gbazin's avatar
   
gbazin committed
989
990
991
992
993
994
995
996
997
998
999
1000
}

/*****************************************************************************
 * File panel event methods.
 *****************************************************************************/
void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
{
    UpdateMRL( FILE_ACCESS );
}

void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
1001
1002
    if( file_dialog == NULL )
        file_dialog = new wxFileDialog( this, wxU(_("Open file")),
gbazin's avatar
   
gbazin committed
1003
            wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
gbazin's avatar
   
gbazin committed
1004

gbazin's avatar
   
gbazin committed
1005
    if( file_dialog && file_dialog->ShowModal() == wxID_OK )
gbazin's avatar
   
gbazin committed
1006
    {
gbazin's avatar
   
gbazin committed
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
        wxArrayString paths;
        wxString path;

        file_dialog->GetPaths( paths );

        for( size_t i = 0; i < paths.GetCount(); i++ )
        {
            if( paths[i].Find( wxT(' ') ) >= 0 )
                path += wxT("\"") + paths[i] + wxT("\" ");
            else
                path += paths[i] + wxT(" ");
        }

        file_combo->SetValue( path );
        file_combo->Append( path );
gbazin's avatar
   
gbazin committed
1022
        if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
gbazin's avatar
   
gbazin committed
1023
1024
1025
1026
1027
1028
1029
        UpdateMRL( FILE_ACCESS );
    }
}

/*****************************************************************************
 * Disc panel event methods.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
1030
void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
gbazin's avatar
   
gbazin committed
1031
1032
1033
1034
{
    UpdateMRL( DISC_ACCESS );
}

yoann's avatar
yoann committed
1035
1036
1037
1038
1039
1040
1041
1042
1043
void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
{
    char *psz_device;

    switch( disc_type->GetSelection() )
    {
        case 3:
            psz_device = config_GetPsz( p_intf, "cd-audio" );
            break;
1044

yoann's avatar
yoann committed
1045
1046
1047
        case 2:
            psz_device = config_GetPsz( p_intf, "vcd" );
            break;
1048

yoann's avatar
yoann committed
1049
1050
1051
1052
        default:
            psz_device = config_GetPsz( p_intf, "dvd" );
            break;
    }
1053
1054
    
    if ( !psz_device ) psz_device = "";
yoann's avatar
yoann committed
1055

1056
    if( disc_device->GetValue().Cmp( wxU( psz_device ) ) )
yoann's avatar
yoann committed
1057
1058
1059
1060
1061
1062
1063
    {
        b_disc_device_changed = true;
    }

    UpdateMRL( DISC_ACCESS );
}

gbazin's avatar
   
gbazin committed
1064
1065
void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
{
1066
1067
    char *psz_device = NULL;
    int  i_selection = 1; /* Default Title/Track selection number*/
gbazin's avatar
   
gbazin committed
1068
1069
1070

    switch( disc_type->GetSelection() )
    {
yoann's avatar
yoann committed
1071

1072
1073
1074
    case 0: /* DVD with menues */
      i_selection=0;
      /* Fall through... */
gbazin's avatar
   
gbazin committed
1075

1076
1077
    case 1: /* DVD of some sort */
      {
gbazin's avatar
   
gbazin committed
1078
        psz_device = config_GetPsz( p_intf, "dvd" );
yoann's avatar
yoann committed
1079
1080
1081
        if( !b_disc_device_changed )
        {
            disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
1082
	    disc_title_label->SetLabel ( wxT("Title") );
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
	}
	disc_title->SetRange( i_selection, 255 );
	disc_title->SetValue( i_selection );
	break;
      }
	
    case 2:  /* VCD of some sort */
        psz_device = config_GetPsz( p_intf, "vcd" );
        if( !b_disc_device_changed )
        {
            disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
yoann's avatar
yoann committed
1094
        }
gbazin's avatar
   
gbazin committed
1095

1096
1097
1098
	/* There are at most 98, tracks in a VCD, 999 Segments, 500 entries
	   I don't know what the limit is for LIDs, 999 is probably safe
	   though. 
gbazin's avatar
   
gbazin committed
1099

1100
1101
1102
	   FIXME: it would be better however to get the information for
	   this particular Media possibly from the General Info area.
	*/
1103
#ifdef HAVE_VCDX
1104
1105
1106
1107
	disc_title_label->SetLabel ( config_GetInt( p_intf, "vcdx-PBC"  )
				     ? wxT("PBC LID") : wxT("Entry") );
        disc_title->SetRange( 0, 999 ); 
        i_selection = 0;
1108
#else
1109
1110
	disc_title_label->SetLabel ( wxT("Track") );
        disc_title->SetRange( 1, 98 ); 
1111
#endif
1112
        disc_title->SetValue( i_selection );
1113
        break;
1114
1115
1116
1117
1118
1119
1120
1121

    case 3: /* CD-DA */
        psz_device = config_GetPsz( p_intf, "cd-audio" );
        if( !b_disc_device_changed )
        {
            disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
        }
	disc_title_label->SetLabel ( wxT("Track") );
1122
#ifdef HAVE_CDDAX
1123
        i_selection = 0;
1124
#endif
1125
1126
1127
       /* There are at most 99 tracks in a CD-DA */
        disc_title->SetRange( i_selection, 99 ); 
        disc_title->SetValue( i_selection );
1128
        break;
1129
1130
1131
    default: 
        msg_Err( p_intf, "invalid Disc type selection (%d)", 
	       disc_type->GetSelection() );
gbazin's avatar
   
gbazin committed
1132
1133
1134
        break;
    }

1135
1136
    if( psz_device ) free( psz_device );

gbazin's avatar
   
gbazin committed
1137
1138
1139
    disc_chapter->SetRange( 1, 255 );
    disc_chapter->SetValue( 1 );

gbazin's avatar
   
gbazin committed
1140
    UpdateMRL( DISC_ACCESS );
gbazin's avatar
   
gbazin committed
1141
1142
1143
1144
1145
}

/*****************************************************************************
 * Net panel event methods.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
1146
void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
gbazin's avatar
   
gbazin committed
1147
{
gbazin's avatar
   
gbazin committed
1148
1149
1150
1151
1152
    if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
    {
        i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
    }

gbazin's avatar
   
gbazin committed
1153
1154
1155
1156
1157
1158
1159
1160
1161
    UpdateMRL( NET_ACCESS );
}

void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
{
    int i;

    i_net_type = event.GetId() - NetRadio1_Event;

1162
    for(i=0; i<4; i++)
gbazin's avatar
   
gbazin committed
1163
    {
gbazin's avatar
   
gbazin committed
1164
        net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
gbazin's avatar
   
gbazin committed
1165
1166
1167
1168
1169
        net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
    }

    UpdateMRL( NET_ACCESS );
}
gbazin's avatar
   
gbazin committed
1170

1171
#ifndef WIN32
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
/*****************************************************************************
 * v4l panel event methods.
 *****************************************************************************/
void OpenDialog::OnV4LPanelChange( wxCommandEvent& WXUNUSED(event) )
{
    UpdateMRL( V4L_ACCESS );
}

void OpenDialog::OnV4LTypeChange( wxCommandEvent& WXUNUSED(event) )
{
    video_device->SetValue( wxU( "/dev/video" ) );

    v4l_button->Enable();
    video_channel->Disable();

    switch( video_type->GetSelection()