~ubuntu-branches/debian/wheezy/vlc/wheezy

« back to all changes in this revision

Viewing changes to modules/gui/wxwindows/open.cpp

Tags: upstream-0.7.2.final
ImportĀ upstreamĀ versionĀ 0.7.2.final

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 * open.cpp : wxWindows plugin for vlc
 
3
 *****************************************************************************
 
4
 * Copyright (C) 2000-2004 VideoLAN
 
5
 * $Id: open.cpp 7728 2004-05-20 10:16:52Z gbazin $
 
6
 *
 
7
 * Authors: Gildas Bazin <gbazin@videolan.org>
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation; either version 2 of the License, or
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program; if not, write to the Free Software
 
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 
22
 *****************************************************************************/
 
23
 
 
24
/*****************************************************************************
 
25
 * Preamble
 
26
 *****************************************************************************/
 
27
#include <stdlib.h>                                      /* malloc(), free() */
 
28
#include <errno.h>                                                 /* ENOMEM */
 
29
#include <string.h>                                            /* strerror() */
 
30
#include <stdio.h>
 
31
 
 
32
#include <vlc/vlc.h>
 
33
 
 
34
#include <wx/combobox.h>
 
35
#include <wx/statline.h>
 
36
#include <wx/tokenzr.h>
 
37
 
 
38
#include <vlc/intf.h>
 
39
 
 
40
#include "wxwindows.h"
 
41
#include "preferences_widgets.h"
 
42
 
 
43
#ifndef wxRB_SINGLE
 
44
#   define wxRB_SINGLE 0
 
45
#endif
 
46
 
 
47
/*****************************************************************************
 
48
 * Event Table.
 
49
 *****************************************************************************/
 
50
 
 
51
/* IDs for the controls and the menu commands */
 
52
enum
 
53
{
 
54
    Notebook_Event = wxID_HIGHEST,
 
55
    MRL_Event,
 
56
 
 
57
    FileBrowse_Event,
 
58
    FileName_Event,
 
59
 
 
60
    DiscType_Event,
 
61
    DiscDevice_Event,
 
62
    DiscTitle_Event,
 
63
    DiscChapter_Event,
 
64
 
 
65
    NetType_Event,
 
66
    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
 
67
    NetPort1_Event, NetPort2_Event, NetPort3_Event,
 
68
    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
 
69
    NetForceIPv6_Event,
 
70
 
 
71
    SubsFileEnable_Event,
 
72
    SubsFileSettings_Event,
 
73
 
 
74
    SoutEnable_Event,
 
75
    SoutSettings_Event,
 
76
 
 
77
    AdvancedOptions_Event
 
78
};
 
79
 
 
80
BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
 
81
    /* Button events */
 
82
    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
 
83
    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
 
84
 
 
85
    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
 
86
 
 
87
    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
 
88
 
 
89
    /* Events generated by the file panel */
 
90
    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
 
91
    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
 
92
 
 
93
    /* Events generated by the disc panel */
 
94
    EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
 
95
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
 
96
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
 
97
    EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
 
98
    EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
 
99
    EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
 
100
    EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
 
101
 
 
102
    /* Events generated by the net panel */
 
103
    EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
 
104
    EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
 
105
    EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
 
106
    EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
 
107
    EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
 
108
    EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
 
109
    EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
 
110
    EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
 
111
    EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
 
112
    EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
 
113
    EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
 
114
    EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
 
115
    EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
 
116
    EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
 
117
 
 
118
    /* Events generated by the subtitle file buttons */
 
119
    EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
 
120
    EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
 
121
 
 
122
    /* Events generated by the stream output buttons */
 
123
    EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
 
124
    EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
 
125
 
 
126
    /* Hide the window when the user closes the window */
 
127
    EVT_CLOSE(OpenDialog::OnCancel)
 
128
 
 
129
END_EVENT_TABLE()
 
130
 
 
131
/*****************************************************************************
 
132
 * AutoBuiltPanel.
 
133
 *****************************************************************************/
 
134
WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
 
135
 
 
136
class AutoBuiltPanel : public wxPanel
 
137
{
 
138
public:
 
139
 
 
140
    AutoBuiltPanel() { }
 
141
    AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *,
 
142
                    const module_t * );
 
143
 
 
144
    virtual ~AutoBuiltPanel() {}
 
145
 
 
146
    void UpdateAdvancedMRL();
 
147
 
 
148
    wxString name;
 
149
    ArrayOfConfigControls config_array;
 
150
    ArrayOfConfigControls advanced_config_array;
 
151
    wxComboBox *p_advanced_mrl_combo;
 
152
 
 
153
private:
 
154
    intf_thread_t *p_intf;
 
155
    OpenDialog *p_open_dialog;
 
156
 
 
157
    void OnAdvanced( wxCommandEvent& event );
 
158
    wxDialog *p_advanced_dialog;
 
159
 
 
160
    DECLARE_EVENT_TABLE();
 
161
};
 
162
 
 
163
BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
 
164
    EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
 
165
END_EVENT_TABLE()
 
166
 
 
167
static void AutoBuildCallback( void *p_data )
 
168
{
 
169
    ((OpenDialog *)p_data)->UpdateMRL();
 
170
}
 
171
 
 
172
static void AutoBuildAdvancedCallback( void *p_data )
 
173
{
 
174
    ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
 
175
}
 
176
 
 
177
AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
 
178
                                intf_thread_t *_p_intf,
 
179
                                const module_t *p_module )
 
180
  : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
 
181
    name( wxU(p_module->psz_object_name) ),
 
182
    p_advanced_mrl_combo( NULL ),
 
183
    p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
 
184
{
 
185
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
 
186
    module_config_t *p_item = p_module->p_config;
 
187
    bool b_advanced = false;
 
188
 
 
189
    if( p_item ) do
 
190
    {
 
191
        if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
 
192
            b_advanced = true;
 
193
 
 
194
        if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
 
195
            continue;
 
196
 
 
197
        ConfigControl *control =
 
198
            CreateConfigControl( VLC_OBJECT(p_intf), p_item, this );
 
199
 
 
200
        config_array.Add( control );
 
201
 
 
202
        /* Don't add items that were not recognized */
 
203
        if( control == NULL ) continue;
 
204
 
 
205
        control->SetUpdateCallback( AutoBuildCallback, (void *)dialog );
 
206
 
 
207
        sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
 
208
    }
 
209
    while( p_item->i_type != CONFIG_HINT_END && p_item++ );
 
210
 
 
211
    if( b_advanced )
 
212
    {
 
213
        wxPanel *dummy_panel = new wxPanel( this, -1 );
 
214
        sizer->Add( dummy_panel, 1 );
 
215
 
 
216
        wxButton *button =
 
217
            new wxButton( this, AdvancedOptions_Event,
 
218
                          wxU(_("Advanced options...")) );
 
219
        sizer->Add( button, 0, wxALL, 5 );
 
220
 
 
221
        /* Build the advanced dialog */
 
222
        p_advanced_dialog =
 
223
            new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
 
224
                          wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
 
225
                          wxDefaultPosition, wxDefaultSize,
 
226
                          wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
 
227
 
 
228
        wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
 
229
 
 
230
        /* Create MRL combobox */
 
231
        wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
 
232
        wxStaticBox *mrl_box =
 
233
            new wxStaticBox( p_advanced_dialog, -1,
 
234
                             wxU(_("Advanced options")) );
 
235
        wxStaticBoxSizer *mrl_sizer =
 
236
            new wxStaticBoxSizer( mrl_box, wxHORIZONTAL );
 
237
        wxStaticText *mrl_label =
 
238
            new wxStaticText( p_advanced_dialog, -1, wxU(_("Options:")) );
 
239
        p_advanced_mrl_combo =
 
240
            new wxComboBox( p_advanced_dialog, MRL_Event, wxT(""),
 
241
                            wxDefaultPosition, wxDefaultSize );
 
242
        mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
 
243
        mrl_sizer->Add( p_advanced_mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
 
244
        mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
 
245
        sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 );
 
246
 
 
247
        /* Add advanced options to panel */
 
248
        module_config_t *p_item = p_module->p_config;
 
249
        if( p_item ) do
 
250
        {
 
251
            if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced )
 
252
                continue;
 
253
 
 
254
            ConfigControl *control =
 
255
                CreateConfigControl( VLC_OBJECT(p_intf), p_item,
 
256
                                     p_advanced_dialog );
 
257
 
 
258
            advanced_config_array.Add( control );
 
259
 
 
260
            /* Don't add items that were not recognized */
 
261
            if( control == NULL ) continue;
 
262
 
 
263
            control->SetUpdateCallback( AutoBuildAdvancedCallback,
 
264
                                        (void *)this );
 
265
 
 
266
            sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
 
267
        }
 
268
        while( p_item->i_type != CONFIG_HINT_END && p_item++ );
 
269
 
 
270
        /* Separation */
 
271
        dummy_panel = new wxPanel( p_advanced_dialog, -1 );
 
272
        sizer->Add( dummy_panel, 1 );
 
273
        wxStaticLine *static_line =
 
274
            new wxStaticLine( p_advanced_dialog, wxID_OK );
 
275
        sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
 
276
 
 
277
        /* Create buttons */
 
278
        wxButton *ok_button =
 
279
            new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
 
280
        ok_button->SetDefault();
 
281
        wxButton *cancel_button =
 
282
            new wxButton( p_advanced_dialog, wxID_CANCEL, wxU(_("Cancel")) );
 
283
        wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
 
284
        button_sizer->Add( ok_button, 0, wxALL, 5 );
 
285
        button_sizer->Add( cancel_button, 0, wxALL, 5 );
 
286
        button_sizer->Layout();
 
287
        sizer->Add( button_sizer, 0, wxALL, 0 );
 
288
 
 
289
        sizer->SetMinSize( 400, -1 );
 
290
        p_advanced_dialog->SetSizerAndFit( sizer );
 
291
    }
 
292
 
 
293
    this->SetSizerAndFit( sizer );
 
294
}
 
295
 
 
296
void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
 
297
{
 
298
    if( p_advanced_dialog->ShowModal() == wxID_OK )
 
299
    {
 
300
        UpdateAdvancedMRL();
 
301
        p_open_dialog->UpdateMRL();
 
302
    }
 
303
}
 
304
 
 
305
void AutoBuiltPanel::UpdateAdvancedMRL()
 
306
{
 
307
    wxString mrltemp;
 
308
 
 
309
    for( int i = 0; i < (int)advanced_config_array.GetCount(); i++ )
 
310
    {
 
311
        ConfigControl *control = advanced_config_array.Item(i);
 
312
 
 
313
        mrltemp += (i ? wxT(" :") : wxT(":"));
 
314
 
 
315
        if( control->GetType() == CONFIG_ITEM_BOOL &&
 
316
            !control->GetIntValue() ) mrltemp += wxT("no-");
 
317
 
 
318
        mrltemp += control->GetName();
 
319
 
 
320
        switch( control->GetType() )
 
321
        {
 
322
        case CONFIG_ITEM_STRING:
 
323
        case CONFIG_ITEM_FILE:
 
324
        case CONFIG_ITEM_DIRECTORY:
 
325
        case CONFIG_ITEM_MODULE:
 
326
            mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
 
327
            break;
 
328
        case CONFIG_ITEM_INTEGER:
 
329
            mrltemp +=
 
330
                wxString::Format( wxT("=%i"), control->GetIntValue() );
 
331
            break;
 
332
        case CONFIG_ITEM_FLOAT:
 
333
            mrltemp +=
 
334
                wxString::Format(wxT("=%f"), control->GetFloatValue());
 
335
            break;
 
336
        }
 
337
    }
 
338
 
 
339
    p_advanced_mrl_combo->SetValue( mrltemp );
 
340
}
 
341
 
 
342
/*****************************************************************************
 
343
 * Constructor.
 
344
 *****************************************************************************/
 
345
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
 
346
                        int i_access_method, int i_arg ):
 
347
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
 
348
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 
349
{
 
350
    OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
 
351
}
 
352
 
 
353
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
 
354
                        int i_access_method, int i_arg, int _i_method ):
 
355
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
 
356
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 
357
{
 
358
    /* Initializations */
 
359
    i_method = _i_method;
 
360
    p_intf = _p_intf;
 
361
    p_parent = _p_parent;
 
362
    SetIcon( *p_intf->p_sys->p_icon );
 
363
    file_dialog = NULL;
 
364
    i_disc_type_selection = 0;
 
365
    i_open_arg = i_arg;
 
366
 
 
367
    sout_dialog = NULL;
 
368
    subsfile_dialog = NULL;
 
369
    b_disc_device_changed = false;
 
370
 
 
371
    /* Create a panel to put everything in */
 
372
    wxPanel *panel = new wxPanel( this, -1 );
 
373
    panel->SetAutoLayout( TRUE );
 
374
 
 
375
    /* Create MRL combobox */
 
376
    wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
 
377
    wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
 
378
                               wxU(_("Media Resource Locator (MRL)")) );
 
379
    wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
 
380
                                                        wxHORIZONTAL );
 
381
    wxStaticText *mrl_label = new wxStaticText( panel, -1,
 
382
                                                wxU(_("Open:")) );
 
383
    mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
 
384
                                wxPoint(20,25), wxSize(120, -1),
 
385
                                0, NULL );
 
386
    mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
 
387
        "the full MRL you want to open.\n""Alternatively, the field will be "
 
388
        "filled automatically when you use the controls below.")) );
 
389
 
 
390
    mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
 
391
    mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
 
392
    mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
 
393
 
 
394
 
 
395
    /* Create Static Text */
 
396
    wxStaticText *label = new wxStaticText( panel, -1,
 
397
        wxU(_("Alternatively, you can build an MRL using one of the "
 
398
              "following predefined targets:")) );
 
399
 
 
400
    wxFlexGridSizer *sout_sizer = NULL;
 
401
    wxStaticLine *static_line = NULL;
 
402
 
 
403
    if( i_method == OPEN_NORMAL )
 
404
    {
 
405
        /* Create Stream Output checkox */
 
406
        sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
 
407
 
 
408
 
 
409
        sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
 
410
                                         wxU(_("Stream output")) );
 
411
        sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
 
412
        sout_sizer->Add( sout_checkbox, 0,
 
413
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
 
414
        sout_button = new wxButton( panel, SoutSettings_Event,
 
415
                                    wxU(_("Settings...")) );
 
416
        sout_button->Disable();
 
417
 
 
418
        char *psz_sout = config_GetPsz( p_intf, "sout" );
 
419
        if( psz_sout && *psz_sout )
 
420
        {
 
421
            sout_checkbox->SetValue(TRUE);
 
422
            sout_button->Enable();
 
423
            subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
 
424
        }
 
425
        if( psz_sout ) free( psz_sout );
 
426
 
 
427
        sout_sizer->Add( sout_button, 1, wxALIGN_LEFT |
 
428
                         wxALIGN_CENTER_VERTICAL );
 
429
 
 
430
        /* Separation */
 
431
        static_line = new wxStaticLine( panel, wxID_OK );
 
432
    }
 
433
 
 
434
    /* Create the buttons */
 
435
    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
 
436
    ok_button->SetDefault();
 
437
    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
 
438
                                            wxU(_("Cancel")) );
 
439
 
 
440
    /* Create notebook */
 
441
    notebook = new wxNotebook( panel, Notebook_Event );
 
442
    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
 
443
 
 
444
    notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
 
445
                       i_access_method == FILE_ACCESS );
 
446
    notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
 
447
                       i_access_method == DISC_ACCESS );
 
448
    notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
 
449
                       i_access_method == NET_ACCESS );
 
450
 
 
451
    module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" );
 
452
    if( p_module )
 
453
    {
 
454
        AutoBuiltPanel *autopanel =
 
455
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
 
456
        input_tab_array.Add( autopanel );
 
457
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
 
458
                           i_access_method == CAPTURE_ACCESS );
 
459
    }
 
460
 
 
461
    p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" );
 
462
    if( p_module )
 
463
    {
 
464
        AutoBuiltPanel *autopanel =
 
465
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
 
466
        input_tab_array.Add( autopanel );
 
467
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
 
468
                           i_access_method == CAPTURE_ACCESS );
 
469
    }
 
470
 
 
471
    p_module = config_FindModule( VLC_OBJECT(p_intf), "dvb" );
 
472
    if( p_module )
 
473
    {
 
474
        AutoBuiltPanel *autopanel =
 
475
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
 
476
        input_tab_array.Add( autopanel );
 
477
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
 
478
                           i_access_method == CAPTURE_ACCESS );
 
479
    }
 
480
 
 
481
    p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
 
482
    if( p_module )
 
483
    {
 
484
        AutoBuiltPanel *autopanel =
 
485
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
 
486
        input_tab_array.Add( autopanel );
 
487
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
 
488
                           i_access_method == CAPTURE_ACCESS );
 
489
    }
 
490
 
 
491
    /* Update Disc panel */
 
492
    wxCommandEvent dummy_event;
 
493
    OnDiscTypeChange( dummy_event );
 
494
 
 
495
    /* Update Net panel */
 
496
    dummy_event.SetId( NetRadio1_Event );
 
497
    OnNetTypeChange( dummy_event );
 
498
 
 
499
    /* Update MRL */
 
500
    wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
 
501
    OnPageChange( event );
 
502
 
 
503
    /* Place everything in sizers */
 
504
    wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
 
505
    button_sizer->Add( ok_button, 0, wxALL, 5 );
 
506
    button_sizer->Add( cancel_button, 0, wxALL, 5 );
 
507
    button_sizer->Layout();
 
508
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
 
509
    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
 
510
    panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
 
511
    panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
 
512
    panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
 
513
    if( i_method == OPEN_NORMAL)
 
514
    {
 
515
        panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
 
516
        panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
 
517
    }
 
518
    panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
 
519
    panel_sizer->Layout();
 
520
    panel->SetSizerAndFit( panel_sizer );
 
521
    main_sizer->Add( panel, 1, wxGROW, 0 );
 
522
    main_sizer->Layout();
 
523
    SetSizerAndFit( main_sizer );
 
524
}
 
525
 
 
526
OpenDialog::~OpenDialog()
 
527
{
 
528
    /* Clean up */
 
529
    if( file_dialog ) delete file_dialog;
 
530
    if( sout_dialog ) delete sout_dialog;
 
531
    if( subsfile_dialog ) delete subsfile_dialog;
 
532
}
 
533
 
 
534
int OpenDialog::Show( int i_access_method, int i_arg )
 
535
{
 
536
    notebook->SetSelection( i_access_method );
 
537
    int i_ret = wxDialog::Show();
 
538
    Raise();
 
539
    SetFocus();
 
540
    i_open_arg = i_arg;
 
541
    return i_ret;
 
542
}
 
543
 
 
544
int OpenDialog::Show()
 
545
{
 
546
    int i_ret = wxDialog::Show();
 
547
    Raise();
 
548
    SetFocus();
 
549
    return i_ret;
 
550
}
 
551
 
 
552
/*****************************************************************************
 
553
 * Private methods.
 
554
 *****************************************************************************/
 
555
wxPanel *OpenDialog::FilePanel( wxWindow* parent )
 
556
{
 
557
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
 
558
                                  wxSize(200, 200) );
 
559
 
 
560
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
 
561
 
 
562
    /* Create browse file line */
 
563
    wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
 
564
 
 
565
    file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
 
566
                                 wxPoint(20,25), wxSize(200, -1), 0, NULL );
 
567
    wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
 
568
                                            wxU(_("Browse...")) );
 
569
    file_sizer->Add( file_combo, 1, wxALL, 5 );
 
570
    file_sizer->Add( browse_button, 0, wxALL, 5 );
 
571
 
 
572
    /* Create Subtitles File checkox */
 
573
    wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
 
574
    subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
 
575
                                        wxU(_("Subtitle options")) );
 
576
    subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
 
577
    subsfile_sizer->Add( subsfile_checkbox, 0,
 
578
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
 
579
    subsfile_button = new wxButton( panel, SubsFileSettings_Event,
 
580
                                    wxU(_("Settings...")) );
 
581
    subsfile_button->Disable();
 
582
 
 
583
    char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
 
584
    if( psz_subsfile && *psz_subsfile )
 
585
    {
 
586
        subsfile_checkbox->SetValue(TRUE);
 
587
        subsfile_button->Enable();
 
588
        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
 
589
    }
 
590
    if( psz_subsfile ) free( psz_subsfile );
 
591
 
 
592
    subsfile_sizer->Add( subsfile_button, 1,
 
593
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
594
 
 
595
    sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
 
596
    sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
 
597
    panel->SetSizerAndFit( sizer );
 
598
    return panel;
 
599
}
 
600
 
 
601
wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
 
602
{
 
603
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
 
604
                                  wxSize(200, 200) );
 
605
 
 
606
    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
 
607
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
 
608
 
 
609
    static const wxString disc_type_array[] =
 
610
    {
 
611
        wxU(_("DVD (menus)")),
 
612
        wxU(_("DVD")),
 
613
        wxU(_("VCD")),
 
614
        wxU(_("Audio CD")),
 
615
        wxU(_("DVD (test)"))
 
616
    };
 
617
 
 
618
    disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
 
619
                                wxDefaultPosition, wxDefaultSize,
 
620
                                WXSIZEOF(disc_type_array), disc_type_array,
 
621
                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
 
622
 
 
623
    sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
 
624
 
 
625
    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
 
626
    disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
 
627
                                  wxDefaultPosition, wxDefaultSize,
 
628
                                  wxTE_PROCESS_ENTER);
 
629
 
 
630
    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
631
    sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
632
 
 
633
    disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
 
634
    disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
 
635
 
 
636
    sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
637
    sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
638
 
 
639
    disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
 
640
    disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
 
641
    sizer->Add( disc_chapter_label, 0,
 
642
                wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
643
    sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
644
    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
 
645
 
 
646
    panel->SetSizerAndFit( sizer_row );
 
647
    return panel;
 
648
}
 
649
 
 
650
wxPanel *OpenDialog::NetPanel( wxWindow* parent )
 
651
{
 
652
    int i;
 
653
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
 
654
                                  wxSize(200, 200) );
 
655
 
 
656
    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
 
657
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
 
658
 
 
659
    static const wxString net_type_array[] =
 
660
    {
 
661
        wxU(_("UDP/RTP")),
 
662
        wxU(_("UDP/RTP Multicast")),
 
663
        wxU(_("HTTP/FTP/MMS")),
 
664
        wxU(_("RTSP"))
 
665
    };
 
666
 
 
667
    for( i=0; i<4; i++ )
 
668
    {
 
669
        net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
 
670
                                           net_type_array[i],
 
671
                                           wxDefaultPosition, wxDefaultSize,
 
672
                                           wxRB_SINGLE );
 
673
 
 
674
        net_subpanels[i] = new wxPanel( panel, -1,
 
675
                                        wxDefaultPosition, wxDefaultSize );
 
676
    }
 
677
 
 
678
    /* UDP/RTP row */
 
679
    wxFlexGridSizer *subpanel_sizer;
 
680
    wxStaticText *label;
 
681
    i_net_ports[0] = config_GetInt( p_intf, "server-port" );
 
682
    subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
 
683
    label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
 
684
    net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
 
685
                                   wxString::Format(wxT("%d"), i_net_ports[0]),
 
686
                                   wxDefaultPosition, wxDefaultSize,
 
687
                                   wxSP_ARROW_KEYS,
 
688
                                   0, 16000, i_net_ports[0] );
 
689
 
 
690
    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
 
691
    subpanel_sizer->Add( net_ports[0], 1,
 
692
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
693
    net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
 
694
                               wxU(_("Force IPv6")));
 
695
    subpanel_sizer->Add( net_ipv6, 0,
 
696
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
 
697
    net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
 
698
    net_radios[0]->SetValue( TRUE );
 
699
 
 
700
    /* UDP/RTP Multicast row */
 
701
    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
 
702
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
 
703
    net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
 
704
                                   wxDefaultPosition, wxDefaultSize,
 
705
                                   wxTE_PROCESS_ENTER);
 
706
    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
 
707
    subpanel_sizer->Add( net_addrs[1], 1,
 
708
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
709
 
 
710
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
 
711
    i_net_ports[1] = i_net_ports[0];
 
712
    net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
 
713
                                   wxString::Format(wxT("%d"), i_net_ports[1]),
 
714
                                   wxDefaultPosition, wxDefaultSize,
 
715
                                   wxSP_ARROW_KEYS,
 
716
                                   0, 16000, i_net_ports[1] );
 
717
 
 
718
    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
 
719
    subpanel_sizer->Add( net_ports[1], 1,
 
720
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
721
    net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
 
722
 
 
723
    /* HTTP and RTSP rows */
 
724
    for( i=2; i<4; i++ )
 
725
    {
 
726
        subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
 
727
        label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
 
728
        net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
 
729
                                       (i == 2) ? wxT("") : wxT("rtsp://"),
 
730
                                       wxDefaultPosition, wxSize( 200, -1 ),
 
731
                                       wxTE_PROCESS_ENTER);
 
732
        subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
 
733
        subpanel_sizer->Add( net_addrs[i], 1,
 
734
                             wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
735
        net_subpanels[i]->SetSizerAndFit( subpanel_sizer );
 
736
    }
 
737
 
 
738
    /* Stuff everything into the main panel */
 
739
    for( i=0; i<4; i++ )
 
740
    {
 
741
        sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
 
742
                    wxALL, 5 );
 
743
        sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
 
744
                    wxALIGN_CENTER_VERTICAL | wxALL, 5  );
 
745
    }
 
746
 
 
747
    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
 
748
 
 
749
    panel->SetSizerAndFit( sizer_row );
 
750
    return panel;
 
751
}
 
752
 
 
753
void OpenDialog::UpdateMRL()
 
754
{
 
755
    UpdateMRL( i_current_access_method );
 
756
}
 
757
 
 
758
void OpenDialog::UpdateMRL( int i_access_method )
 
759
{
 
760
    wxString demux, mrltemp;
 
761
 
 
762
    i_current_access_method = i_access_method;
 
763
 
 
764
    switch( i_access_method )
 
765
    {
 
766
    case FILE_ACCESS:
 
767
        //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
 
768
        mrltemp = file_combo->GetValue();
 
769
        break;
 
770
    case DISC_ACCESS:
 
771
      i_disc_type_selection = disc_type->GetSelection();
 
772
 
 
773
      switch ( i_disc_type_selection )
 
774
        {
 
775
        case 0: /* DVD with menues */
 
776
          disc_chapter->Enable();
 
777
          disc_chapter_label->Enable();
 
778
          mrltemp = wxT("dvd://")
 
779
                  + disc_device->GetValue()
 
780
                  + wxString::Format( wxT("@%d:%d"),
 
781
                                      disc_title->GetValue(),
 
782
                                      disc_chapter->GetValue() );
 
783
          break;
 
784
 
 
785
        case 1: /* DVD of some sort */
 
786
          disc_chapter->Enable();
 
787
          disc_chapter_label->Enable();
 
788
          mrltemp = wxT("dvdsimple://")
 
789
                  + disc_device->GetValue()
 
790
                  + wxString::Format( wxT("@%d:%d"),
 
791
                                      disc_title->GetValue(),
 
792
                                      disc_chapter->GetValue() );
 
793
          break;
 
794
 
 
795
        case 2:  /* VCD of some sort */
 
796
          {
 
797
            /* The chapter object is used for subtitles */
 
798
 
 
799
            int i_subtitle = disc_chapter->GetValue();
 
800
            config_PutInt( p_intf, "spu-channel", i_subtitle );
 
801
            
 
802
            disc_chapter->Enable();
 
803
            disc_chapter_label->Enable();
 
804
#ifdef HAVE_VCDX
 
805
          if ( disc_title->GetValue() )
 
806
            mrltemp = wxT("vcdx://")
 
807
              + disc_device->GetValue()
 
808
              + wxString::Format( wxT("@%c%d"),
 
809
                                  config_GetInt( p_intf, "vcdx-PBC"  )
 
810
                                  ? 'P' : 'E',
 
811
                                  disc_title->GetValue()
 
812
                                  );
 
813
          else
 
814
            mrltemp = wxT("vcdx://")
 
815
              + disc_device->GetValue();
 
816
#else
 
817
          mrltemp = wxT("vcd://")
 
818
            + disc_device->GetValue()
 
819
            + wxString::Format( wxT("@%d"),
 
820
                                disc_title->GetValue() );
 
821
#endif
 
822
          break;
 
823
          }
 
824
          
 
825
 
 
826
        case 3: /* CD-DA */
 
827
          disc_chapter->Disable();
 
828
          disc_chapter_label->Disable();
 
829
#ifdef HAVE_CDDAX
 
830
          if ( disc_title->GetValue() )
 
831
            mrltemp =  wxT("cddax://")
 
832
                  + disc_device->GetValue()
 
833
                  + wxString::Format( wxT("@T%d"),
 
834
                                      disc_title->GetValue() );
 
835
          else
 
836
            mrltemp = wxT("cddax://")
 
837
                  + disc_device->GetValue();
 
838
 
 
839
#else
 
840
          mrltemp =  wxT("cdda://")
 
841
                  + disc_device->GetValue()
 
842
                  + wxString::Format( wxT("@%d"),
 
843
                                      disc_title->GetValue() );
 
844
#endif
 
845
          break;
 
846
 
 
847
        case 4: /* DVD of some sort */
 
848
          disc_chapter->Enable();
 
849
          disc_chapter_label->Enable();
 
850
          mrltemp = wxT("dvdnav://")
 
851
                  + disc_device->GetValue()
 
852
                  + wxString::Format( wxT("@%d:%d"),
 
853
                                      disc_title->GetValue(),
 
854
                                      disc_chapter->GetValue() );
 
855
          break;
 
856
 
 
857
        default: ;
 
858
          msg_Err( p_intf, "invalid selection (%d)",
 
859
                   disc_type->GetSelection() );
 
860
        }
 
861
 
 
862
        break;
 
863
    case NET_ACCESS:
 
864
        switch( i_net_type )
 
865
        {
 
866
        case 0:
 
867
            mrltemp = wxT("udp") + demux + wxT("://");
 
868
            if ( net_ipv6->GetValue() )
 
869
            {
 
870
                mrltemp += wxT("@[::]");
 
871
            }
 
872
            if( i_net_ports[0] !=
 
873
                config_GetInt( p_intf, "server-port" ) )
 
874
            {
 
875
                mrltemp += wxString::Format( wxT("@:%d"), i_net_ports[0] );
 
876
            }
 
877
            break;
 
878
 
 
879
        case 1:
 
880
            mrltemp = wxT("udp") + demux + wxT("://@");
 
881
            if ((net_addrs[1]->GetLineText(0).Find (':') != -1)
 
882
                && (net_addrs[1]->GetLineText(0)[0u] != '['))
 
883
            {
 
884
                /* automatically adds '[' and ']' to IPv6 addresses */
 
885
                mrltemp += wxT("[") + net_addrs[1]->GetLineText(0)
 
886
                         + wxT("]");
 
887
            }
 
888
            else
 
889
            {
 
890
                mrltemp += net_addrs[1]->GetLineText(0);
 
891
            }
 
892
            if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
 
893
            {
 
894
                mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
 
895
            }
 
896
            break;
 
897
 
 
898
        case 2:
 
899
            /* http access */
 
900
            if( net_addrs[2]->GetLineText(0).Find(wxT("http://")) )
 
901
            {
 
902
                mrltemp = wxT("http") + demux + wxT("://");
 
903
            }
 
904
            mrltemp += net_addrs[2]->GetLineText(0);
 
905
            break;
 
906
 
 
907
        case 3:
 
908
            /* RTSP access */
 
909
            if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
 
910
            {
 
911
                mrltemp = wxT("rtsp") + demux + wxT("://");
 
912
            }
 
913
            mrltemp += net_addrs[3]->GetLineText(0);
 
914
            break;
 
915
        }
 
916
        break;
 
917
 
 
918
    default:
 
919
        {
 
920
            int i_item = i_access_method - MAX_ACCESS;
 
921
 
 
922
            if( i_item < 0 || i_item >= (int)input_tab_array.GetCount() )
 
923
                break;
 
924
 
 
925
            AutoBuiltPanel *input_panel = input_tab_array.Item( i_item );
 
926
 
 
927
            mrltemp = input_panel->name + wxT("://");
 
928
 
 
929
            for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
 
930
            {
 
931
                ConfigControl *control = input_panel->config_array.Item(i);
 
932
 
 
933
                mrltemp += wxT(" :");
 
934
 
 
935
                if( control->GetType() == CONFIG_ITEM_BOOL &&
 
936
                    !control->GetIntValue() ) mrltemp += wxT("no-");
 
937
 
 
938
                mrltemp += control->GetName();
 
939
 
 
940
                switch( control->GetType() )
 
941
                {
 
942
                case CONFIG_ITEM_STRING:
 
943
                case CONFIG_ITEM_FILE:
 
944
                case CONFIG_ITEM_DIRECTORY:
 
945
                case CONFIG_ITEM_MODULE:
 
946
                    mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
 
947
                    break;
 
948
                case CONFIG_ITEM_INTEGER:
 
949
                    mrltemp +=
 
950
                        wxString::Format( wxT("=%i"), control->GetIntValue() );
 
951
                    break;
 
952
                case CONFIG_ITEM_FLOAT:
 
953
                    mrltemp +=
 
954
                        wxString::Format(wxT("=%f"), control->GetFloatValue());
 
955
                    break;
 
956
                }
 
957
            }
 
958
 
 
959
            if( input_panel->p_advanced_mrl_combo &&
 
960
                input_panel->p_advanced_mrl_combo->GetValue() )
 
961
            {
 
962
                mrltemp += wxT(" ") +
 
963
                    input_panel->p_advanced_mrl_combo->GetValue();
 
964
            }
 
965
        }
 
966
        break;
 
967
    }
 
968
 
 
969
    mrl_combo->SetValue( mrltemp );
 
970
}
 
971
 
 
972
/*****************************************************************************
 
973
 * Events methods.
 
974
 *****************************************************************************/
 
975
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
 
976
{
 
977
    mrl = SeparateEntries( mrl_combo->GetValue() );
 
978
    mrl_combo->Append( mrl_combo->GetValue() );
 
979
    if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
 
980
    mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
 
981
 
 
982
    if( i_method == OPEN_STREAM )
 
983
    {
 
984
        Hide();
 
985
        if( IsModal() ) EndModal( wxID_OK );
 
986
        return;
 
987
    }
 
988
 
 
989
    /* Update the playlist */
 
990
    playlist_t *p_playlist =
 
991
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
 
992
                                       FIND_ANYWHERE );
 
993
    if( p_playlist == NULL ) return;
 
994
 
 
995
    for( int i = 0; i < (int)mrl.GetCount(); i++ )
 
996
    {
 
997
        vlc_bool_t b_start = !i && i_open_arg;
 
998
        playlist_item_t *p_item =
 
999
            playlist_ItemNew( p_intf, (const char*)mrl[i].mb_str(),
 
1000
                              (const char *)mrl[i].mb_str() );
 
1001
 
 
1002
        /* Insert options */
 
1003
        while( i + 1 < (int)mrl.GetCount() &&
 
1004
               ((const char *)mrl[i + 1].mb_str())[0] == ':' )
 
1005
        {
 
1006
            playlist_ItemAddOption( p_item, mrl[i + 1].mb_str() );
 
1007
            i++;
 
1008
        }
 
1009
 
 
1010
        /* Get the options from the subtitles dialog */
 
1011
        if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
 
1012
        {
 
1013
            for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
 
1014
            {
 
1015
                playlist_ItemAddOption( p_item, subsfile_mrl[j].mb_str() );
 
1016
            }
 
1017
        }
 
1018
 
 
1019
        /* Get the options from the stream output dialog */
 
1020
        if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
 
1021
        {
 
1022
            for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
 
1023
            {
 
1024
                playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() );
 
1025
            }
 
1026
        }
 
1027
 
 
1028
        int i_id = playlist_AddItem( p_playlist, p_item,
 
1029
                                     PLAYLIST_APPEND, PLAYLIST_END );
 
1030
 
 
1031
        if( b_start )
 
1032
        {
 
1033
            int i_pos = playlist_GetPositionById( p_playlist , i_id );
 
1034
            playlist_Command( p_playlist, PLAYLIST_GOTO, i_pos );
 
1035
        }
 
1036
    }
 
1037
 
 
1038
    vlc_object_release( p_playlist );
 
1039
 
 
1040
    Hide();
 
1041
 
 
1042
    if( IsModal() ) EndModal( wxID_OK );
 
1043
}
 
1044
 
 
1045
void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
 
1046
{
 
1047
    Hide();
 
1048
 
 
1049
    if( IsModal() ) EndModal( wxID_CANCEL );
 
1050
}
 
1051
 
 
1052
void OpenDialog::OnPageChange( wxNotebookEvent& event )
 
1053
{
 
1054
    UpdateMRL( event.GetSelection() );
 
1055
}
 
1056
 
 
1057
void OpenDialog::OnMRLChange( wxCommandEvent& event )
 
1058
{
 
1059
    //mrl = SeparateEntries( event.GetString() );
 
1060
}
 
1061
 
 
1062
/*****************************************************************************
 
1063
 * File panel event methods.
 
1064
 *****************************************************************************/
 
1065
void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
 
1066
{
 
1067
    UpdateMRL( FILE_ACCESS );
 
1068
}
 
1069
 
 
1070
void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
 
1071
{
 
1072
    if( file_dialog == NULL )
 
1073
        file_dialog = new wxFileDialog( this, wxU(_("Open File")),
 
1074
            wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
 
1075
 
 
1076
    if( file_dialog && file_dialog->ShowModal() == wxID_OK )
 
1077
    {
 
1078
        wxArrayString paths;
 
1079
        wxString path;
 
1080
 
 
1081
        file_dialog->GetPaths( paths );
 
1082
 
 
1083
        for( size_t i = 0; i < paths.GetCount(); i++ )
 
1084
        {
 
1085
            if( paths[i].Find( wxT(' ') ) >= 0 )
 
1086
                path += wxT("\"") + paths[i] + wxT("\" ");
 
1087
            else
 
1088
                path += paths[i] + wxT(" ");
 
1089
        }
 
1090
 
 
1091
        file_combo->SetValue( path );
 
1092
        file_combo->Append( path );
 
1093
        if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
 
1094
        UpdateMRL( FILE_ACCESS );
 
1095
    }
 
1096
}
 
1097
 
 
1098
/*****************************************************************************
 
1099
 * Disc panel event methods.
 
1100
 *****************************************************************************/
 
1101
void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
 
1102
{
 
1103
    UpdateMRL( DISC_ACCESS );
 
1104
}
 
1105
 
 
1106
void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
 
1107
{
 
1108
    char *psz_device;
 
1109
 
 
1110
    switch( disc_type->GetSelection() )
 
1111
    {
 
1112
        case 3:
 
1113
            psz_device = config_GetPsz( p_intf, "cd-audio" );
 
1114
            break;
 
1115
 
 
1116
        case 2:
 
1117
            psz_device = config_GetPsz( p_intf, "vcd" );
 
1118
            break;
 
1119
 
 
1120
        default:
 
1121
            psz_device = config_GetPsz( p_intf, "dvd" );
 
1122
            break;
 
1123
    }
 
1124
 
 
1125
    if ( !psz_device ) psz_device = "";
 
1126
 
 
1127
    if( disc_device->GetValue().Cmp( wxL2U( psz_device ) ) )
 
1128
    {
 
1129
        b_disc_device_changed = true;
 
1130
    }
 
1131
 
 
1132
    UpdateMRL( DISC_ACCESS );
 
1133
}
 
1134
 
 
1135
void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
 
1136
{
 
1137
    char *psz_device = NULL;
 
1138
    int  i_selection = 1; /* Default Title/Track selection number*/
 
1139
 
 
1140
    switch( disc_type->GetSelection() )
 
1141
    {
 
1142
 
 
1143
    case 0: /* DVD with menus */
 
1144
    case 4: /* DVD with menus (dvdnav) */
 
1145
        i_selection=0;
 
1146
        /* Fall through... */
 
1147
 
 
1148
    case 1: /* DVD of some sort */
 
1149
        psz_device = config_GetPsz( p_intf, "dvd" );
 
1150
        if( !b_disc_device_changed )
 
1151
        {
 
1152
            if( psz_device )
 
1153
                disc_device->SetValue( wxL2U(psz_device) );
 
1154
            else
 
1155
                disc_device->SetValue( wxT("") );
 
1156
 
 
1157
            disc_title_label->SetLabel ( wxU(_("Title")) );
 
1158
        }
 
1159
        disc_title->SetRange( i_selection, 255 );
 
1160
        disc_title->SetValue( i_selection );
 
1161
 
 
1162
        disc_chapter->SetRange( 1, 255 );
 
1163
        disc_chapter->SetValue( 1 );
 
1164
        disc_chapter_label->SetLabel ( wxU(_("Chapter")) );
 
1165
 
 
1166
        break;
 
1167
 
 
1168
    case 2:  /* VCD of some sort */
 
1169
        psz_device = config_GetPsz( p_intf, "vcd" );
 
1170
        if( !b_disc_device_changed )
 
1171
        {
 
1172
            if( psz_device )
 
1173
                disc_device->SetValue( wxL2U(psz_device) );
 
1174
            else
 
1175
                disc_device->SetValue( wxT("") );
 
1176
        }
 
1177
 
 
1178
        /* There are at most 98, tracks in a VCD, 999 Segments, 500 entries
 
1179
           I don't know what the limit is for LIDs, 999 is probably safe
 
1180
           though.
 
1181
 
 
1182
           FIXME: it would be better however to get the information for
 
1183
           this particular Media possibly from the General Info area.
 
1184
         */
 
1185
#ifdef HAVE_VCDX
 
1186
        disc_title_label->SetLabel ( config_GetInt( p_intf, "vcdx-PBC"  )
 
1187
                                     ? wxT("Playback LID") : wxT("Entry") );
 
1188
        disc_title->SetRange( 0, 999 );
 
1189
        i_selection = 0;
 
1190
#else
 
1191
        disc_title_label->SetLabel ( wxU(_("Track")) );
 
1192
        disc_title->SetRange( 1, 98 );
 
1193
#endif
 
1194
        disc_title->SetValue( i_selection );
 
1195
 
 
1196
        /* We use the chapter to set subtitle number */
 
1197
        disc_chapter_label->SetLabel ( wxU(_("Subtitle")) );
 
1198
        disc_chapter->SetRange( -1, 4 );
 
1199
        disc_chapter->SetValue( config_GetInt( p_intf, "spu-channel" ) );
 
1200
        break;
 
1201
 
 
1202
    case 3: /* CD-DA */
 
1203
        psz_device = config_GetPsz( p_intf, "cd-audio" );
 
1204
        if( !b_disc_device_changed )
 
1205
        {
 
1206
            if( psz_device )
 
1207
                disc_device->SetValue( wxL2U(psz_device) );
 
1208
            else
 
1209
                disc_device->SetValue( wxT("") );
 
1210
        }
 
1211
        disc_title_label->SetLabel ( wxU(_("Track")) );
 
1212
#ifdef HAVE_CDDAX
 
1213
        i_selection = 0;
 
1214
#endif
 
1215
       /* There are at most 99 tracks in a CD-DA */
 
1216
        disc_title->SetRange( i_selection, 99 );
 
1217
        disc_title->SetValue( i_selection );
 
1218
        break;
 
1219
    default:
 
1220
        msg_Err( p_intf, "invalid Disc type selection (%d)",
 
1221
                 disc_type->GetSelection() );
 
1222
        break;
 
1223
    }
 
1224
 
 
1225
    if( psz_device ) free( psz_device );
 
1226
 
 
1227
    UpdateMRL( DISC_ACCESS );
 
1228
}
 
1229
 
 
1230
/*****************************************************************************
 
1231
 * Net panel event methods.
 
1232
 *****************************************************************************/
 
1233
void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
 
1234
{
 
1235
    if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
 
1236
    {
 
1237
        i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
 
1238
    }
 
1239
 
 
1240
    UpdateMRL( NET_ACCESS );
 
1241
}
 
1242
 
 
1243
void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
 
1244
{
 
1245
    int i;
 
1246
 
 
1247
    i_net_type = event.GetId() - NetRadio1_Event;
 
1248
 
 
1249
    for(i=0; i<4; i++)
 
1250
    {
 
1251
        net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
 
1252
        net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
 
1253
    }
 
1254
 
 
1255
    UpdateMRL( NET_ACCESS );
 
1256
}
 
1257
 
 
1258
/*****************************************************************************
 
1259
 * Subtitles file event methods.
 
1260
 *****************************************************************************/
 
1261
void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
 
1262
{
 
1263
    subsfile_button->Enable( event.GetInt() != 0 );
 
1264
}
 
1265
 
 
1266
void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
 
1267
{
 
1268
    /* Show/hide the open dialog */
 
1269
    if( subsfile_dialog == NULL )
 
1270
        subsfile_dialog = new SubsFileDialog( p_intf, this );
 
1271
 
 
1272
    if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
 
1273
    {
 
1274
        subsfile_mrl.Empty();
 
1275
        subsfile_mrl.Add( wxString(wxT("sub-file=")) +
 
1276
                          subsfile_dialog->file_combo->GetValue() );
 
1277
        if( subsfile_dialog->encoding_combo )
 
1278
            subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
 
1279
                              subsfile_dialog->encoding_combo->GetValue() );
 
1280
        subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
 
1281
                          subsfile_dialog->delay_spinctrl->GetValue() ) );
 
1282
        subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
 
1283
                          subsfile_dialog->fps_spinctrl->GetValue() ) );
 
1284
    }
 
1285
}
 
1286
 
 
1287
/*****************************************************************************
 
1288
 * Stream output event methods.
 
1289
 *****************************************************************************/
 
1290
void OpenDialog::OnSoutEnable( wxCommandEvent& event )
 
1291
{
 
1292
    sout_button->Enable( event.GetInt() != 0 );
 
1293
}
 
1294
 
 
1295
void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
 
1296
{
 
1297
    /* Show/hide the open dialog */
 
1298
    if( sout_dialog == NULL )
 
1299
        sout_dialog = new SoutDialog( p_intf, this );
 
1300
 
 
1301
    if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
 
1302
    {
 
1303
        sout_mrl = sout_dialog->GetOptions();
 
1304
    }
 
1305
}
 
1306
 
 
1307
/*****************************************************************************
 
1308
 * Utility functions.
 
1309
 *****************************************************************************/
 
1310
wxArrayString SeparateEntries( wxString entries )
 
1311
{
 
1312
    vlc_bool_t b_quotes_mode = VLC_FALSE;
 
1313
 
 
1314
    wxArrayString entries_array;
 
1315
    wxString entry;
 
1316
 
 
1317
    wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
 
1318
 
 
1319
    while( token.HasMoreTokens() )
 
1320
    {
 
1321
        entry += token.GetNextToken();
 
1322
 
 
1323
        if( entry.IsEmpty() ) continue;
 
1324
 
 
1325
        if( !b_quotes_mode && entry.Last() == wxT('\"') )
 
1326
        {
 
1327
            /* Enters quotes mode */
 
1328
            entry.RemoveLast();
 
1329
            b_quotes_mode = VLC_TRUE;
 
1330
        }
 
1331
        else if( b_quotes_mode && entry.Last() == wxT('\"') )
 
1332
        {
 
1333
            /* Finished the quotes mode */
 
1334
            entry.RemoveLast();
 
1335
            b_quotes_mode = VLC_FALSE;
 
1336
        }
 
1337
        else if( !b_quotes_mode && entry.Last() != wxT('\"') )
 
1338
        {
 
1339
            /* we found a non-quoted standalone string */
 
1340
            if( token.HasMoreTokens() ||
 
1341
                entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
 
1342
                entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
 
1343
                entry.RemoveLast();
 
1344
            if( !entry.IsEmpty() ) entries_array.Add( entry );
 
1345
            entry.Empty();
 
1346
        }
 
1347
        else
 
1348
        {;}
 
1349
    }
 
1350
 
 
1351
    if( !entry.IsEmpty() ) entries_array.Add( entry );
 
1352
 
 
1353
    return entries_array;
 
1354
}