open.cpp 44.7 KB
Newer Older
gbazin's avatar
   
gbazin committed
1
2
3
/*****************************************************************************
 * open.cpp : wxWindows plugin for vlc
 *****************************************************************************
hartman's avatar
hartman committed
4
 * Copyright (C) 2000-2004 VideoLAN
Carlo Calabrò's avatar
Carlo Calabrò committed
5
 * $Id$
gbazin's avatar
   
gbazin committed
6
 *
7
 * Authors: Gildas Bazin <gbazin@videolan.org>
gbazin's avatar
   
gbazin committed
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
 *
 * 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>

#include <wx/combobox.h>
gbazin's avatar
   
gbazin committed
35
#include <wx/statline.h>
gbazin's avatar
   
gbazin committed
36
#include <wx/tokenzr.h>
gbazin's avatar
   
gbazin committed
37
38
39

#include <vlc/intf.h>

gbazin's avatar
   
gbazin committed
40
#include "wxwindows.h"
gbazin's avatar
   
gbazin committed
41
42
#include "preferences_widgets.h"

43
#ifndef wxRB_SINGLE
gbazin's avatar
   
gbazin committed
44
#   define wxRB_SINGLE 0
45
46
#endif

gbazin's avatar
   
gbazin committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*****************************************************************************
 * 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,
66
    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
gbazin's avatar
   
gbazin committed
67
    NetPort1_Event, NetPort2_Event, NetPort3_Event,
68
    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
69
    NetForceIPv6_Event,
gbazin's avatar
   
gbazin committed
70

gbazin's avatar
   
gbazin committed
71
72
73
    SubsFileEnable_Event,
    SubsFileSettings_Event,

gbazin's avatar
   
gbazin committed
74
75
    SoutEnable_Event,
    SoutSettings_Event,
76
77

    AdvancedOptions_Event
gbazin's avatar
   
gbazin committed
78
79
};

gbazin's avatar
   
gbazin committed
80
BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
gbazin's avatar
   
gbazin committed
81
82
83
84
85
86
    /* Button events */
    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)

    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)

87
    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
gbazin's avatar
   
gbazin committed
88
89
90

    /* Events generated by the file panel */
    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
gbazin's avatar
   
gbazin committed
91
    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
gbazin's avatar
   
gbazin committed
92
93
94

    /* Events generated by the disc panel */
    EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
yoann's avatar
yoann committed
95
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
gbazin's avatar
   
gbazin committed
96
97
98
99
100
101
102
103
104
105
    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)
106
    EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
gbazin's avatar
   
gbazin committed
107
108
109
110
111
112
113
114
    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)
115
    EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
116
    EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
gbazin's avatar
   
gbazin committed
117

gbazin's avatar
   
gbazin committed
118
119
120
121
    /* Events generated by the subtitle file buttons */
    EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
    EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)

gbazin's avatar
   
gbazin committed
122
123
124
    /* Events generated by the stream output buttons */
    EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
    EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
gbazin's avatar
   
gbazin committed
125

gbazin's avatar
   
gbazin committed
126
127
128
    /* Hide the window when the user closes the window */
    EVT_CLOSE(OpenDialog::OnCancel)

gbazin's avatar
   
gbazin committed
129
130
END_EVENT_TABLE()

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*****************************************************************************
 * AutoBuiltPanel.
 *****************************************************************************/
WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);

class AutoBuiltPanel : public wxPanel
{
public:

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

    virtual ~AutoBuiltPanel() {}

146
147
    void UpdateAdvancedMRL();

148
149
    wxString name;
    ArrayOfConfigControls config_array;
150
151
    ArrayOfConfigControls advanced_config_array;
    wxComboBox *p_advanced_mrl_combo;
152
153
154

private:
    intf_thread_t *p_intf;
155
156
157
158
159
160
    OpenDialog *p_open_dialog;

    void OnAdvanced( wxCommandEvent& event );
    wxDialog *p_advanced_dialog;

    DECLARE_EVENT_TABLE();
161
162
};

163
164
165
166
167
168
BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
    EVT_BUTTON(wxID_OK, AutoBuiltPanel::OnAdvanced)
    EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
END_EVENT_TABLE()

static void AutoBuildCallback( void *p_data )
169
170
171
172
{
    ((OpenDialog *)p_data)->UpdateMRL();
}

173
174
175
176
177
static void AutoBuildAdvancedCallback( void *p_data )
{
    ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
}

178
179
180
AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
                                intf_thread_t *_p_intf,
                                const module_t *p_module )
181
182
183
184
  : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
    name( wxU(p_module->psz_object_name) ),
    p_advanced_mrl_combo( NULL ),
    p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
185
186
187
{
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
    module_config_t *p_item = p_module->p_config;
188
    bool b_advanced = false;
189
190
191

    if( p_item ) do
    {
192
193
194
        if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
            b_advanced = true;

195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
        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++ );

212
213
214
215
216
217
218
219
220
221
222
223
    if( b_advanced )
    {
        wxPanel *dummy_panel = new wxPanel( this, -1 );
        sizer->Add( dummy_panel, 1 );

        wxButton *button =
            new wxButton( this, AdvancedOptions_Event,
                          wxU(_("Advanced options...")) );
        sizer->Add( button, 0, wxALL, 5 );

        /* Build the advanced dialog */
        p_advanced_dialog =
224
225
            new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
                          wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
                          wxDefaultPosition, wxDefaultSize,
                          wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );

        wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

        /* Create MRL combobox */
        wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
        wxStaticBox *mrl_box =
            new wxStaticBox( p_advanced_dialog, -1,
                             wxU(_("Advanced options")) );
        wxStaticBoxSizer *mrl_sizer =
            new wxStaticBoxSizer( mrl_box, wxHORIZONTAL );
        wxStaticText *mrl_label =
            new wxStaticText( p_advanced_dialog, -1, wxU(_("Options:")) );
        p_advanced_mrl_combo =
            new wxComboBox( p_advanced_dialog, MRL_Event, wxT(""),
                            wxDefaultPosition, wxDefaultSize );
        mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
        mrl_sizer->Add( p_advanced_mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
        mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
        sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 );

        /* Add advanced options to panel */
        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,
                                     p_advanced_dialog );

            advanced_config_array.Add( control );

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

            control->SetUpdateCallback( AutoBuildAdvancedCallback,
                                        (void *)this );

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

        /* Separation */
        dummy_panel = new wxPanel( p_advanced_dialog, -1 );
        sizer->Add( dummy_panel, 1 );
        wxStaticLine *static_line =
            new wxStaticLine( p_advanced_dialog, wxID_OK );
        sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );

        /* Create OK button */
        wxButton *ok_button =
            new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
        ok_button->SetDefault();
        sizer->Add( ok_button, 0, wxALL, 5 );

        sizer->SetMinSize( 400, -1 );
        p_advanced_dialog->SetSizerAndFit( sizer );
    }

288
289
290
    this->SetSizerAndFit( sizer );
}

291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
{
    p_advanced_dialog->Show( !p_advanced_dialog->IsShown() );
    UpdateAdvancedMRL();
    p_open_dialog->UpdateMRL();
}

void AutoBuiltPanel::UpdateAdvancedMRL()
{
    wxString mrltemp;

    for( int i = 0; i < (int)advanced_config_array.GetCount(); i++ )
    {
        ConfigControl *control = advanced_config_array.Item(i);

        mrltemp += wxT(":");

        if( control->GetType() == CONFIG_ITEM_BOOL &&
            !control->GetIntValue() ) mrltemp += wxT("no-");

        mrltemp += control->GetName();

        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:
            mrltemp +=
                wxString::Format( wxT("=%i"), control->GetIntValue() );
            break;
        case CONFIG_ITEM_FLOAT:
            mrltemp +=
                wxString::Format(wxT("=%f"), control->GetFloatValue());
            break;
        }
    }

    p_advanced_mrl_combo->SetValue( mrltemp );
}

gbazin's avatar
   
gbazin committed
335
336
337
/*****************************************************************************
 * Constructor.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
338
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
gbazin's avatar
   
gbazin committed
339
                        int i_access_method, int i_arg ):
hartman's avatar
hartman committed
340
    wxFrame( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
gbazin's avatar
   
gbazin committed
341
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
zorglub's avatar
zorglub committed
342
343
344
345
346
347
{
    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 ):
hartman's avatar
hartman committed
348
    wxFrame( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
zorglub's avatar
zorglub committed
349
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
gbazin's avatar
   
gbazin committed
350
351
{
    /* Initializations */
zorglub's avatar
zorglub committed
352
    i_method = _i_method;
gbazin's avatar
   
gbazin committed
353
    p_intf = _p_intf;
gbazin's avatar
   
gbazin committed
354
    p_parent = _p_parent;
gbazin's avatar
   
gbazin committed
355
    SetIcon( *p_intf->p_sys->p_icon );
gbazin's avatar
   
gbazin committed
356
    file_dialog = NULL;
357
    i_disc_type_selection = 0;
gbazin's avatar
   
gbazin committed
358
    i_open_arg = i_arg;
Sam Hocevar's avatar
Sam Hocevar committed
359

gbazin's avatar
   
gbazin committed
360
361
    sout_dialog = NULL;
    subsfile_dialog = NULL;
yoann's avatar
yoann committed
362
    b_disc_device_changed = false;
gbazin's avatar
   
gbazin committed
363
364
365
366
367
368
369
370

    /* 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
371
                               wxU(_("Media Resource Locator (MRL)")) );
gbazin's avatar
   
gbazin committed
372
373
374
    wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
                                                        wxHORIZONTAL );
    wxStaticText *mrl_label = new wxStaticText( panel, -1,
Carlo Calabrò's avatar
Carlo Calabrò committed
375
                                                wxU(_("Open:")) );
gbazin's avatar
   
gbazin committed
376
    mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
gbazin's avatar
   
gbazin committed
377
378
                                wxPoint(20,25), wxSize(120, -1),
                                0, NULL );
gbazin's avatar
   
gbazin committed
379
380
    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
381
        "filled automatically when you use the controls below.")) );
gbazin's avatar
   
gbazin committed
382

gbazin's avatar
   
gbazin committed
383
384
    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
385
386
387
388
389
    mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );


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

zorglub's avatar
zorglub committed
393
394
395
396
    wxFlexGridSizer *sout_sizer = NULL;
    wxStaticLine *static_line = NULL;

    if( i_method == OPEN_NORMAL )
gbazin's avatar
   
gbazin committed
397
    {
zorglub's avatar
zorglub committed
398
399
        /* Create Stream Output checkox */
        sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
gbazin's avatar
   
gbazin committed
400
401


zorglub's avatar
zorglub committed
402
403
        sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
                                         wxU(_("Stream output")) );
hartman's avatar
hartman committed
404
        sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
zorglub's avatar
zorglub committed
405
406
407
408
        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
409
        sout_button->Disable();
zorglub's avatar
zorglub committed
410
411
412
413
414
415

        char *psz_sout = config_GetPsz( p_intf, "sout" );
        if( psz_sout && *psz_sout )
        {
            sout_checkbox->SetValue(TRUE);
            sout_button->Enable();
gbazin's avatar
   
gbazin committed
416
            subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
zorglub's avatar
zorglub committed
417
418
419
420
421
422
423
424
425
        }
        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
426

gbazin's avatar
   
gbazin committed
427
    /* Create the buttons */
gbazin's avatar
   
gbazin committed
428
    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
gbazin's avatar
   
gbazin committed
429
    ok_button->SetDefault();
gbazin's avatar
   
gbazin committed
430
431
    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
                                            wxU(_("Cancel")) );
gbazin's avatar
   
gbazin committed
432

gbazin's avatar
   
gbazin committed
433
    /* Create notebook */
gbazin's avatar
   
gbazin committed
434
    notebook = new wxNotebook( panel, Notebook_Event );
gbazin's avatar
   
gbazin committed
435
436
    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );

gbazin's avatar
   
gbazin committed
437
    notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
gbazin's avatar
   
gbazin committed
438
                       i_access_method == FILE_ACCESS );
gbazin's avatar
   
gbazin committed
439
    notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
gbazin's avatar
   
gbazin committed
440
                       i_access_method == DISC_ACCESS );
gbazin's avatar
   
gbazin committed
441
    notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
gbazin's avatar
   
gbazin committed
442
                       i_access_method == NET_ACCESS );
443

444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
    module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" );
    if( p_module )
    {
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
        notebook->AddPage( autopanel, wxU( p_module->psz_longname ),
                           i_access_method == CAPTURE_ACCESS );
    }

    p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" );
    if( p_module )
    {
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
        notebook->AddPage( autopanel, wxU( p_module->psz_longname ),
                           i_access_method == CAPTURE_ACCESS );
    }

    p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
gbazin's avatar
   
gbazin committed
465
466
    if( p_module )
    {
467
468
469
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
gbazin's avatar
gbazin committed
470
471
        notebook->AddPage( autopanel, wxU( p_module->psz_longname ),
                           i_access_method == CAPTURE_ACCESS );
gbazin's avatar
   
gbazin committed
472
473
    }

gbazin's avatar
   
gbazin committed
474
475
476
477
    /* Update Disc panel */
    wxCommandEvent dummy_event;
    OnDiscTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
478
479
480
481
    /* Update Net panel */
    dummy_event.SetId( NetRadio1_Event );
    OnNetTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
482
    /* Update MRL */
483
    wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
gbazin's avatar
   
gbazin committed
484
485
486
487
488
489
490
491
492
493
494
    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
495
    panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
zorglub's avatar
zorglub committed
496
497
498
499
500
    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
501
    panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
gbazin's avatar
   
gbazin committed
502
503
504
505
506
507
508
509
510
    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
511
512
513
514
    /* Clean up */
    if( file_dialog ) delete file_dialog;
    if( sout_dialog ) delete sout_dialog;
    if( subsfile_dialog ) delete subsfile_dialog;
gbazin's avatar
   
gbazin committed
515
516
}

gbazin's avatar
   
gbazin committed
517
int OpenDialog::Show( int i_access_method, int i_arg )
gbazin's avatar
   
gbazin committed
518
{
gbazin's avatar
   
gbazin committed
519
    int i_ret;
gbazin's avatar
   
gbazin committed
520
    notebook->SetSelection( i_access_method );
gbazin's avatar
   
gbazin committed
521
522
523
    i_ret = wxFrame::Show();
    Raise();
    SetFocus();
gbazin's avatar
   
gbazin committed
524
    i_open_arg = i_arg;
gbazin's avatar
   
gbazin committed
525
    return i_ret;
gbazin's avatar
   
gbazin committed
526
527
}

gbazin's avatar
   
gbazin committed
528
int OpenDialog::Show()
gbazin's avatar
   
gbazin committed
529
{
gbazin's avatar
   
gbazin committed
530
531
532
533
534
    int i_ret;
    i_ret = wxFrame::Show();
    Raise();
    SetFocus();
    return i_ret;
gbazin's avatar
   
gbazin committed
535
536
}

gbazin's avatar
   
gbazin committed
537
538
539
540
541
542
543
544
/*****************************************************************************
 * Private methods.
 *****************************************************************************/
wxPanel *OpenDialog::FilePanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

gbazin's avatar
   
gbazin committed
545
546
547
548
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

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

gbazin's avatar
   
gbazin committed
550
    file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
gbazin's avatar
   
gbazin committed
551
552
                                 wxPoint(20,25), wxSize(200, -1), 0, NULL );
    wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
gbazin's avatar
   
gbazin committed
553
                                            wxU(_("Browse...")) );
gbazin's avatar
   
gbazin committed
554
555
556
557
558
559
    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,
hartman's avatar
hartman committed
560
                                        wxU(_("Subtitle options")) );
Carlo Calabrò's avatar
Carlo Calabrò committed
561
    subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
gbazin's avatar
   
gbazin committed
562
563
564
565
566
567
568
569
570
571
572
    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();
gbazin's avatar
   
gbazin committed
573
        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
gbazin's avatar
   
gbazin committed
574
575
576
577
578
    }
    if( psz_subsfile ) free( psz_subsfile );

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

gbazin's avatar
   
gbazin committed
580
581
    sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
    sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
582
583
584
585
586
587
588
589
590
591
592
593
594
595
    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
596
        wxU(_("DVD (menus support)")),
gbazin's avatar
   
gbazin committed
597
598
        wxU(_("DVD")),
        wxU(_("VCD")),
Sam Hocevar's avatar
Sam Hocevar committed
599
        wxU(_("Audio CD"))
gbazin's avatar
   
gbazin committed
600

gbazin's avatar
   
gbazin committed
601
602
    };

gbazin's avatar
   
gbazin committed
603
    disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
gbazin's avatar
   
gbazin committed
604
605
606
                                wxDefaultPosition, wxDefaultSize,
                                WXSIZEOF(disc_type_array), disc_type_array,
                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
Sam Hocevar's avatar
Sam Hocevar committed
607

608
    sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
609

gbazin's avatar
   
gbazin committed
610
611
    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
    disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
gbazin's avatar
   
gbazin committed
612
613
614
615
616
617
                                  wxDefaultPosition, wxDefaultSize,
                                  wxTE_PROCESS_ENTER);

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

618
    disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
gbazin's avatar
   
gbazin committed
619
    disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
gbazin's avatar
   
gbazin committed
620

621
    sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
622
623
    sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

624
    disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
gbazin's avatar
   
gbazin committed
625
    disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
Sam Hocevar's avatar
Sam Hocevar committed
626
627
    sizer->Add( disc_chapter_label, 0,
                wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
628
629
630
631
632
633
634
635
636
637
638
639
640
641
    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 );
642
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
gbazin's avatar
   
gbazin committed
643
644
645

    static const wxString net_type_array[] =
    {
gbazin's avatar
   
gbazin committed
646
647
        wxU(_("UDP/RTP")),
        wxU(_("UDP/RTP Multicast")),
648
649
        wxU(_("HTTP/FTP/MMS")),
        wxU(_("RTSP"))
gbazin's avatar
   
gbazin committed
650
651
    };

652
    for( i=0; i<4; i++ )
gbazin's avatar
   
gbazin committed
653
654
655
656
657
658
659
660
661
662
663
664
665
    {
        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
666
    i_net_ports[0] = config_GetInt( p_intf, "server-port" );
667
    subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
gbazin's avatar
   
gbazin committed
668
    label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
669
    net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
gbazin's avatar
   
gbazin committed
670
                                   wxString::Format(wxT("%d"), i_net_ports[0]),
gbazin's avatar
   
gbazin committed
671
672
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
gbazin's avatar
   
gbazin committed
673
                                   0, 16000, i_net_ports[0] );
gbazin's avatar
   
gbazin committed
674
675
676
677

    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_ports[0], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
678
679
680
681
    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
682
    net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
gbazin's avatar
   
gbazin committed
683
    net_radios[0]->SetValue( TRUE );
gbazin's avatar
   
gbazin committed
684
685
686

    /* UDP/RTP Multicast row */
    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
gbazin's avatar
   
gbazin committed
687
688
    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
689
690
691
692
693
694
                                   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
695
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
696
    i_net_ports[1] = i_net_ports[0];
gbazin's avatar
   
gbazin committed
697
    net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
gbazin's avatar
   
gbazin committed
698
                                   wxString::Format(wxT("%d"), i_net_ports[1]),
gbazin's avatar
   
gbazin committed
699
700
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
gbazin's avatar
   
gbazin committed
701
                                   0, 16000, i_net_ports[1] );
gbazin's avatar
   
gbazin committed
702
703
704
705
706
707

    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 );

708
709
710
711
712
713
    /* 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,
gbazin's avatar
   
gbazin committed
714
                                       (i == 2) ? wxT("") : wxT("rtsp://"),
715
716
717
718
719
720
721
                                       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
722
723

    /* Stuff everything into the main panel */
724
    for( i=0; i<4; i++ )
gbazin's avatar
   
gbazin committed
725
    {
gbazin's avatar
   
gbazin committed
726
727
728
729
        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
730
731
732
733
734
735
736
737
    }

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

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

738
void OpenDialog::UpdateMRL()
gbazin's avatar
   
gbazin committed
739
{
740
    UpdateMRL( i_current_access_method );
gbazin's avatar
   
gbazin committed
741
742
743
744
}

void OpenDialog::UpdateMRL( int i_access_method )
{
gbazin's avatar
   
gbazin committed
745
    wxString demux, mrltemp;
gbazin's avatar
   
gbazin committed
746
747
748

    i_current_access_method = i_access_method;

gbazin's avatar
   
gbazin committed
749
750
751
    switch( i_access_method )
    {
    case FILE_ACCESS:
gbazin's avatar
   
gbazin committed
752
753
        //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
        mrltemp = file_combo->GetValue();
gbazin's avatar
   
gbazin committed
754
755
        break;
    case DISC_ACCESS:
756
757
      i_disc_type_selection = disc_type->GetSelection();

758
      switch ( i_disc_type_selection )
Sam Hocevar's avatar
Sam Hocevar committed
759
        {
760
        case 0: /* DVD with menues */
Sam Hocevar's avatar
Sam Hocevar committed
761
762
          disc_chapter->Enable();
          disc_chapter_label->Enable();
763
          mrltemp = wxT("dvd://")
yoann's avatar
yoann committed
764
                  + disc_device->GetValue()
gbazin's avatar
   
gbazin committed
765
                  + wxString::Format( wxT("@%d:%d"),
gbazin's avatar
   
gbazin committed
766
767
                                      disc_title->GetValue(),
                                      disc_chapter->GetValue() );
Sam Hocevar's avatar
Sam Hocevar committed
768
          break;
769

770
        case 1: /* DVD of some sort */
Sam Hocevar's avatar
Sam Hocevar committed
771
772
773
          disc_chapter->Enable();
          disc_chapter_label->Enable();
          mrltemp = wxT("dvdsimple://")
Rocky Bernstein's avatar
Rocky Bernstein committed
774
775
776
777
                  + disc_device->GetValue()
                  + wxString::Format( wxT("@%d:%d"),
                                      disc_title->GetValue(),
                                      disc_chapter->GetValue() );
Sam Hocevar's avatar
Sam Hocevar committed
778
          break;
779

780
781
782
        case 2:  /* VCD of some sort */
          {
            /* The chapter object is used for subtitles */
783

784
785
786
787
788
            int i_subtitle = disc_chapter->GetValue();
            config_PutInt( p_intf, "spu-channel", i_subtitle );
            
            disc_chapter->Enable();
            disc_chapter_label->Enable();
Rocky Bernstein's avatar
Rocky Bernstein committed
789
#ifdef HAVE_VCDX
Sam Hocevar's avatar
Sam Hocevar committed
790
791
792
793
794
795
796
797
798
799
          if ( disc_title->GetValue() )
            mrltemp = wxT("vcdx://")
              + disc_device->GetValue()
              + wxString::Format( wxT("@%c%d"),
                                  config_GetInt( p_intf, "vcdx-PBC"  )
                                  ? 'P' : 'E',
                                  disc_title->GetValue()
                                  );
          else
            mrltemp = wxT("vcdx://")
800
              + disc_device->GetValue();
Rocky Bernstein's avatar
Rocky Bernstein committed
801
#else
Sam Hocevar's avatar
Sam Hocevar committed
802
          mrltemp = wxT("vcd://")
803
804
805
            + disc_device->GetValue()
            + wxString::Format( wxT("@%d"),
                                disc_title->GetValue() );
Rocky Bernstein's avatar
Rocky Bernstein committed
806
#endif
Sam Hocevar's avatar
Sam Hocevar committed
807
          break;
808
809
          }
          
810

811
        case 3: /* CD-DA */
Sam Hocevar's avatar
Sam Hocevar committed
812
813
          disc_chapter->Disable();
          disc_chapter_label->Disable();
Rocky Bernstein's avatar
Rocky Bernstein committed
814
#ifdef HAVE_CDDAX
Sam Hocevar's avatar
Sam Hocevar committed
815
816
817
          if ( disc_title->GetValue() )
            mrltemp =  wxT("cddax://")
                  + disc_device->GetValue()
818
819
                  + wxString::Format( wxT("@T%d"),
                                      disc_title->GetValue() );
Sam Hocevar's avatar
Sam Hocevar committed
820
821
822
          else
            mrltemp = wxT("cddax://")
                  + disc_device->GetValue();
823

Rocky Bernstein's avatar
Rocky Bernstein committed
824
#else
Sam Hocevar's avatar
Sam Hocevar committed
825
          mrltemp =  wxT("cdda://")
Rocky Bernstein's avatar
Rocky Bernstein committed
826
827
828
829
                  + disc_device->GetValue()
                  + wxString::Format( wxT("@%d"),
                                      disc_title->GetValue() );
#endif
Sam Hocevar's avatar
Sam Hocevar committed
830
831
832
833
834
          break;
        default: ;
          msg_Err( p_intf, "invalid selection (%d)",
                   disc_type->GetSelection() );
        }
835

gbazin's avatar
   
gbazin committed
836
837
838
839
840
        break;
    case NET_ACCESS:
        switch( i_net_type )
        {
        case 0:
841
            mrltemp = wxT("udp") + demux + wxT("://");
842
843
844
845
            if ( net_ipv6->GetValue() )
            {
                mrltemp += wxT("@[::]");
            }
gbazin's avatar
   
gbazin committed
846
            if( i_net_ports[0] !=
gbazin's avatar
   
gbazin committed
847
848
                config_GetInt( p_intf, "server-port" ) )
            {
849
                mrltemp += wxString::Format( wxT("@:%d"), i_net_ports[0] );
gbazin's avatar
   
gbazin committed
850
851
852
853
            }
            break;

        case 1:
854
855
856
857
858
859
860
861
862
863
864
865
866
            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
867
            {
868
                mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
gbazin's avatar
   
gbazin committed
869
870
871
872
            }
            break;

        case 2:
873
            /* http access */
gbazin's avatar
   
gbazin committed
874
            if( net_addrs[2]->GetLineText(0).Find(wxT("http://")) )
875
876
877
            {
                mrltemp = wxT("http") + demux + wxT("://");
            }
878
879
880
881
882
            mrltemp += net_addrs[2]->GetLineText(0);
            break;

        case 3:
            /* RTSP access */
883
            if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
884
885
886
887
            {
                mrltemp = wxT("rtsp") + demux + wxT("://");
            }
            mrltemp += net_addrs[3]->GetLineText(0);
gbazin's avatar
   
gbazin committed
888
889
890
            break;
        }
        break;
891

gbazin's avatar
   
gbazin committed
892
    default:
893
894
895
896
897
898
899
900
901
902
903
904
905
        {
            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);
906
907
908
909
910
911
912

                mrltemp += wxT(" :");

                if( control->GetType() == CONFIG_ITEM_BOOL &&
                    !control->GetIntValue() ) mrltemp += wxT("no-");

                mrltemp += control->GetName();
913
914
915
916
917
918
919

                switch( control->GetType() )
                {
                case CONFIG_ITEM_STRING:
                case CONFIG_ITEM_FILE:
                case CONFIG_ITEM_DIRECTORY:
                case CONFIG_ITEM_MODULE:
920
                    mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
921
922
923
                    break;
                case CONFIG_ITEM_INTEGER:
                    mrltemp +=
924
                        wxString::Format( wxT("=%i"), control->GetIntValue() );
925
926
927
                    break;
                case CONFIG_ITEM_FLOAT:
                    mrltemp +=
928
                        wxString::Format(wxT("=%f"), control->GetFloatValue());
929
930
931
                    break;
                }
            }
932
933
934
935
936
937
938

            if( input_panel->p_advanced_mrl_combo &&
                input_panel->p_advanced_mrl_combo->GetValue() )
            {
                mrltemp += wxT(" ") +
                    input_panel->p_advanced_mrl_combo->GetValue();
            }
939
        }
gbazin's avatar
   
gbazin committed
940
941
942
        break;
    }

gbazin's avatar
   
gbazin committed
943
944
945
    mrl_combo->SetValue( mrltemp );
}

gbazin's avatar
   
gbazin committed
946
947
948
949
950
/*****************************************************************************
 * Events methods.
 *****************************************************************************/
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
951
    mrl = SeparateEntries( mrl_combo->GetValue() );
gbazin's avatar
   
gbazin committed
952
953
954
    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
955

zorglub's avatar
zorglub committed
956
957
958
959
960
961
    if( i_method == OPEN_STREAM )
    {
        Hide();
        return;
    }

gbazin's avatar
   
gbazin committed
962
963
964
    /* Update the playlist */
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
965
                                       FIND_ANYWHERE );
966
    if( p_playlist == NULL ) return;
gbazin's avatar
   
gbazin committed
967

968
    for( int i = 0; i < (int)mrl.GetCount(); i++ )
gbazin's avatar
   
gbazin committed
969
    {
gbazin's avatar
   
gbazin committed
970
        vlc_bool_t b_start = !i && i_open_arg;
971
        playlist_item_t *p_item =
gbazin's avatar
   
gbazin committed
972
973
            playlist_ItemNew( p_intf, (const char*)mrl[i].mb_str(),
                              (const char *)mrl[i].mb_str() );
974

975
        /* Insert options */
gbazin's avatar
   
gbazin committed
976
977
        while( i + 1 < (int)mrl.GetCount() &&
               ((const char *)mrl[i + 1].mb_str())[0] == ':' )
978
        {
gbazin's avatar
   
gbazin committed
979
980
            playlist_ItemAddOption( p_item, mrl[i + 1].mb_str() );
            i++;
981
982
983
984
985
986
987
        }

        /* Get the options from the subtitles dialog */
        if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
        {
            for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
            {
988
                playlist_ItemAddOption( p_item, subsfile_mrl[j].mb_str() );
989
990
991
992
993
994
995
996
            }
        }

        /* Get the options from the stream output dialog */
        if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
        {
            for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
            {
997
                playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() );
998
999
            }
        }
gbazin's avatar
   
gbazin committed
1000

gbazin's avatar
   
gbazin committed
1001
1002
        int i_id = playlist_AddItem( p_playlist, p_item,
                                     PLAYLIST_APPEND, PLAYLIST_END );
1003

gbazin's avatar
   
gbazin committed
1004
        if( b_start )
gbazin's avatar
   
gbazin committed
1005
1006
1007
1008
        {
            int i_pos = playlist_GetPositionById( p_playlist , i_id );
            playlist_Command( p_playlist, PLAYLIST_GOTO, i_pos );
        }
1009
    }
gbazin's avatar
   
gbazin committed
1010
1011
1012
1013

    vlc_object_release( p_playlist );

    Hide();
gbazin's avatar
   
gbazin committed
1014
1015
1016
1017
}

void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
1018
    Hide();
gbazin's avatar
   
gbazin committed
1019
1020
1021
1022
1023
1024
1025
1026
1027
}

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

void OpenDialog::OnMRLChange( wxCommandEvent& event )
{
gbazin's avatar
   
gbazin committed
1028
    //mrl = SeparateEntries( event.GetString() );
gbazin's avatar
   
gbazin committed
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
}

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

void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
1041
    if( file_dialog == NULL )
hartman's avatar
hartman committed
1042
        file_dialog = new wxFileDialog( this, wxU(_("Open File")),
gbazin's avatar
   
gbazin committed
1043
            wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
gbazin's avatar
   
gbazin committed
1044

gbazin's avatar
   
gbazin committed
1045
    if( file_dialog && file_dialog->ShowModal() == wxID_OK )
gbazin's avatar
   
gbazin committed
1046
    {
gbazin's avatar
   
gbazin committed
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
        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
1062
        if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
gbazin's avatar
   
gbazin committed
1063
1064
1065
1066
1067
1068
1069
        UpdateMRL( FILE_ACCESS );
    }
}

/*****************************************************************************
 * Disc panel event methods.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
1070
void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
gbazin's avatar
   
gbazin committed
1071
1072
1073
1074
{
    UpdateMRL( DISC_ACCESS );
}

yoann's avatar
yoann committed
1075
1076
1077
1078
1079
1080
1081
1082
1083
void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
{
    char *psz_device;

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

yoann's avatar
yoann committed
1085
1086
1087
        case 2:
            psz_device = config_GetPsz( p_intf, "vcd" );
            break;
1088

yoann's avatar
yoann committed
1089
1090
1091
1092
        default:
            psz_device = config_GetPsz( p_intf, "dvd" );
            break;
    }
Sam Hocevar's avatar
Sam Hocevar committed
1093

1094
    if ( !psz_device ) psz_device = "";
yoann's avatar
yoann committed
1095

gbazin's avatar
   
gbazin committed
1096
    if( disc_device->GetValue().Cmp( wxL2U( psz_device ) ) )
yoann's avatar
yoann committed
1097
1098
1099
1100
1101
1102
1103
    {
        b_disc_device_changed = true;
    }

    UpdateMRL( DISC_ACCESS );
}

gbazin's avatar
   
gbazin committed
1104
1105
void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
{
1106
1107
    char *psz_device = NULL;
    int  i_selection = 1; /* Default Title/Track selection number*/
gbazin's avatar
   
gbazin committed
1108
1109
1110

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

1112
1113
1114
    case 0: /* DVD with menues */
      i_selection=0;
      /* Fall through... */
gbazin's avatar
   
gbazin committed
1115

1116
    case 1: /* DVD of some sort */
gbazin's avatar
   
gbazin committed
1117
        psz_device = config_GetPsz( p_intf, "dvd" );
yoann's avatar
yoann committed
1118
1119
        if( !b_disc_device_changed )
        {
gbazin's avatar
   
gbazin committed
1120
1121
1122
1123
1124
            if( psz_device )
                disc_device->SetValue( wxL2U(psz_device) );
            else
                disc_device->SetValue( wxT("") );

hartman's avatar
hartman committed
1125
            disc_title_label->SetLabel ( wxU(_("Title")) );
Sam Hocevar's avatar
Sam Hocevar committed
1126
1127
1128
        }
        disc_title->SetRange( i_selection, 255 );
        disc_title->SetValue( i_selection );
1129

1130
1131
1132
        disc_chapter->SetRange( 1, 255 );
        disc_chapter->SetValue( 1 );
        disc_chapter_label->SetLabel ( wxU(_("Chapter")) );
1133

Sam Hocevar's avatar
Sam Hocevar committed
1134
1135
        break;

1136
1137
1138
1139
    case 2:  /* VCD of some sort */
        psz_device = config_GetPsz( p_intf, "vcd" );
        if( !b_disc_device_changed )
        {
gbazin's avatar
   
gbazin committed
1140
1141
1142
1143
            if( psz_device )
                disc_device->SetValue( wxL2U(psz_device) );
            else
                disc_device->SetValue( wxT("") );
yoann's avatar
yoann committed
1144
        }
gbazin's avatar
   
gbazin committed
1145

Sam Hocevar's avatar
Sam Hocevar committed
1146
1147
1148
        /* 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
1149

Sam Hocevar's avatar
Sam Hocevar committed
1150
1151
           FIXME: it would be better however to get the information for
           this particular Media possibly from the General Info area.
gbazin's avatar
   
gbazin committed
1152
         */
1153
#ifdef HAVE_VCDX
Sam Hocevar's avatar
Sam Hocevar committed
1154
        disc_title_label->SetLabel ( config_GetInt( p_intf, "vcdx-PBC"  )
1155
                                     ? wxT("Playback LID") : wxT("Entry") );
Sam Hocevar's avatar
Sam Hocevar committed
1156
        disc_title->SetRange( 0, 999 );
1157
        i_selection = 0;
1158
#else
hartman's avatar
hartman committed
1159
        disc_title_label->SetLabel ( wxU(_("Track")) );
Sam Hocevar's avatar
Sam Hocevar committed
1160
        disc_title->SetRange( 1, 98 );
1161
#endif
1162
        disc_title->SetValue( i_selection );
1163

gbazin's avatar