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

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

#include <vlc/vlc.h>

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

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

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

#include <vlc/intf.h>

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

55
#ifndef wxRB_SINGLE
gbazin's avatar
   
gbazin committed
56
#   define wxRB_SINGLE 0
57
58
#endif

gbazin's avatar
   
gbazin committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*****************************************************************************
 * 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,
gbazin's avatar
   
gbazin committed
78
79
80
    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event,
    NetPort1_Event, NetPort2_Event, NetPort3_Event,
    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
gbazin's avatar
   
gbazin committed
81

gbazin's avatar
   
gbazin committed
82
83
84
    SubsFileEnable_Event,
    SubsFileSettings_Event,

gbazin's avatar
   
gbazin committed
85
86
    SoutEnable_Event,
    SoutSettings_Event,
gbazin's avatar
   
gbazin committed
87
88
89
90

    DemuxDump_Event,
    DemuxDumpEnable_Event,
    DemuxDumpBrowse_Event,
gbazin's avatar
   
gbazin committed
91
92
};

gbazin's avatar
   
gbazin committed
93
BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
gbazin's avatar
   
gbazin committed
94
95
96
97
98
99
100
101
102
103
    /* Button events */
    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)

    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)

    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange) 

    /* Events generated by the file panel */
    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
gbazin's avatar
   
gbazin committed
104
    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
gbazin's avatar
   
gbazin committed
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

    /* Events generated by the disc panel */
    EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
    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)
    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)

gbazin's avatar
   
gbazin committed
127
128
129
130
    /* Events generated by the subtitle file buttons */
    EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
    EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)

gbazin's avatar
   
gbazin committed
131
132
133
    /* Events generated by the stream output buttons */
    EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
    EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
gbazin's avatar
   
gbazin committed
134
135
136
137
138
139

    /* Events generated by the demux dump buttons */
    EVT_CHECKBOX(DemuxDumpEnable_Event, OpenDialog::OnDemuxDumpEnable)
    EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
    EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)

gbazin's avatar
   
gbazin committed
140
141
142
    /* Hide the window when the user closes the window */
    EVT_CLOSE(OpenDialog::OnCancel)

gbazin's avatar
   
gbazin committed
143
144
145
146
147
END_EVENT_TABLE()

/*****************************************************************************
 * Constructor.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
148
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
gbazin's avatar
   
gbazin committed
149
150
                        int i_access_method, int i_arg ):
    wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
gbazin's avatar
   
gbazin committed
151
152
153
154
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{
    /* Initializations */
    p_intf = _p_intf;
gbazin's avatar
   
gbazin committed
155
    p_parent = _p_parent;
gbazin's avatar
   
gbazin committed
156
    SetIcon( *p_intf->p_sys->p_icon );
gbazin's avatar
   
gbazin committed
157
158
159
160
    file_dialog = NULL;
    sout_dialog = NULL;
    subsfile_dialog = NULL;
    demuxdump_dialog = NULL;
gbazin's avatar
   
gbazin committed
161
162
163
164
165
166
167
168

    /* 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
169
                               wxU(_("Media Resource Locator (MRL)")) );
gbazin's avatar
   
gbazin committed
170
171
172
    wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
                                                        wxHORIZONTAL );
    wxStaticText *mrl_label = new wxStaticText( panel, -1,
gbazin's avatar
   
gbazin committed
173
                                                wxU(_("Open Target:")) );
gbazin's avatar
   
gbazin committed
174
    mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
gbazin's avatar
   
gbazin committed
175
176
                                wxPoint(20,25), wxSize(120, -1),
                                0, NULL );
gbazin's avatar
   
gbazin committed
177
178
    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
179
        "filled automatically when you use the controls below.")) );
gbazin's avatar
   
gbazin committed
180

gbazin's avatar
   
gbazin committed
181
182
    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
183
184
185
186
187
    mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );


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

gbazin's avatar
   
gbazin committed
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
    /* Create Subtitles File checkox */
    wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
    subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
                                        wxU(_("Subtitles file")) );
    subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
                                   "Currently only works with AVI files.")) );
    subsfile_sizer->Add( subsfile_checkbox, 0,
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subsfile_button = new wxButton( panel, SubsFileSettings_Event,
                                    wxU(_("Settings...")) );
    subsfile_button->Disable();

    char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
    if( psz_subsfile && *psz_subsfile )
    {
        subsfile_checkbox->SetValue(TRUE);
        subsfile_button->Enable();
208
        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxU(psz_subsfile) );
gbazin's avatar
   
gbazin committed
209
210
211
212
213
214
    }
    if( psz_subsfile ) free( psz_subsfile );

    subsfile_sizer->Add( subsfile_button, 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

gbazin's avatar
   
gbazin committed
215
216
    /* Create Stream Output checkox */
    wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
gbazin's avatar
   
gbazin committed
217
    sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
gbazin's avatar
   
gbazin committed
218
219
                                    wxU(_("Stream output")) );
    sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
gbazin's avatar
   
gbazin committed
220
221
    sout_sizer->Add( sout_checkbox, 0,
                     wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
222
223
    sout_button = new wxButton( panel, SoutSettings_Event,
                                wxU(_("Settings...")) );
gbazin's avatar
   
gbazin committed
224
225
226
227
228
    sout_button->Disable();

    char *psz_sout = config_GetPsz( p_intf, "sout" );
    if( psz_sout && *psz_sout )
    {
gbazin's avatar
   
gbazin committed
229
        sout_checkbox->SetValue(TRUE);
gbazin's avatar
   
gbazin committed
230
        sout_button->Enable();
231
        subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) );
gbazin's avatar
   
gbazin committed
232
233
234
235
236
    }
    if( psz_sout ) free( psz_sout );

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

gbazin's avatar
   
gbazin committed
237
238
239
    /* Create Demux Dump checkox */
    wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
    demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
gbazin's avatar
   
gbazin committed
240
                               wxU(_("Capture input stream")) );
gbazin's avatar
   
gbazin committed
241
    demuxdump_checkbox->SetToolTip(
gbazin's avatar
   
gbazin committed
242
243
244
        wxU(_("Capture the stream you are playing to a file")) );
    demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
                                         wxDefaultPosition, wxDefaultSize,
gbazin's avatar
   
gbazin committed
245
246
                                         wxTE_PROCESS_ENTER);
    demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
gbazin's avatar
   
gbazin committed
247
                                     wxU(_("Browse...")) );
gbazin's avatar
   
gbazin committed
248
249
250
251

    char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
    if( psz_demuxdump && *psz_demuxdump )
    {
gbazin's avatar
   
gbazin committed
252
        demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
gbazin's avatar
   
gbazin committed
253
254
255
256
257
258
    }
    if( psz_demuxdump ) free( psz_demuxdump );

    demuxdump_textctrl->Disable();
    demuxdump_button->Disable();
    demuxdump_sizer->Add( demuxdump_checkbox, 0,
gbazin's avatar
   
gbazin committed
259
                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
260
    demuxdump_sizer->Add( demuxdump_button, 0,
gbazin's avatar
   
gbazin committed
261
262
                          wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 );
    demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 );
gbazin's avatar
   
gbazin committed
263

gbazin's avatar
   
gbazin committed
264
265
266
    /* Separation */
    wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );

gbazin's avatar
   
gbazin committed
267
    /* Create the buttons */
gbazin's avatar
   
gbazin committed
268
    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
gbazin's avatar
   
gbazin committed
269
    ok_button->SetDefault();
gbazin's avatar
   
gbazin committed
270
271
    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
                                            wxU(_("Cancel")) );
gbazin's avatar
   
gbazin committed
272

gbazin's avatar
   
gbazin committed
273
    /* Create notebook */
gbazin's avatar
   
gbazin committed
274
    notebook = new wxNotebook( panel, Notebook_Event );
gbazin's avatar
   
gbazin committed
275
276
    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );

gbazin's avatar
   
gbazin committed
277
    notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
gbazin's avatar
   
gbazin committed
278
                       i_access_method == FILE_ACCESS );
gbazin's avatar
   
gbazin committed
279
    notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
gbazin's avatar
   
gbazin committed
280
                       i_access_method == DISC_ACCESS );
gbazin's avatar
   
gbazin committed
281
    notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
gbazin's avatar
   
gbazin committed
282
                       i_access_method == NET_ACCESS );
gbazin's avatar
   
gbazin committed
283
#ifndef WIN32
gbazin's avatar
   
gbazin committed
284
    notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
gbazin's avatar
   
gbazin committed
285
                       i_access_method == SAT_ACCESS );
gbazin's avatar
   
gbazin committed
286
#endif
gbazin's avatar
   
gbazin committed
287

gbazin's avatar
   
gbazin committed
288
289
290
291
    /* Update Disc panel */
    wxCommandEvent dummy_event;
    OnDiscTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
292
293
294
295
    /* Update Net panel */
    dummy_event.SetId( NetRadio1_Event );
    OnNetTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
296
    /* Update MRL */
297
    wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
gbazin's avatar
   
gbazin committed
298
299
300
301
302
303
304
305
306
307
308
    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
309
    panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
310
    panel_sizer->Add( subsfile_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
gbazin's avatar
   
gbazin committed
311
    panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
gbazin's avatar
   
gbazin committed
312
    panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
gbazin's avatar
   
gbazin committed
313
314
    panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
    panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
gbazin's avatar
   
gbazin committed
315
316
317
318
319
320
321
322
323
    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
324
325
326
327
328
    /* Clean up */
    if( file_dialog ) delete file_dialog;
    if( sout_dialog ) delete sout_dialog;
    if( subsfile_dialog ) delete subsfile_dialog;
    if( demuxdump_dialog ) delete demuxdump_dialog;
gbazin's avatar
   
gbazin committed
329
330
}

gbazin's avatar
   
gbazin committed
331
int OpenDialog::Show( int i_access_method, int i_arg )
gbazin's avatar
   
gbazin committed
332
{
gbazin's avatar
   
gbazin committed
333
    int i_ret;
gbazin's avatar
   
gbazin committed
334
    notebook->SetSelection( i_access_method );
gbazin's avatar
   
gbazin committed
335
336
337
338
    i_ret = wxFrame::Show();
    Raise();
    SetFocus();
    return i_ret;
gbazin's avatar
   
gbazin committed
339
340
}

gbazin's avatar
   
gbazin committed
341
int OpenDialog::Show()
gbazin's avatar
   
gbazin committed
342
{
gbazin's avatar
   
gbazin committed
343
344
345
346
347
    int i_ret;
    i_ret = wxFrame::Show();
    Raise();
    SetFocus();
    return i_ret;
gbazin's avatar
   
gbazin committed
348
349
}

gbazin's avatar
   
gbazin committed
350
351
352
353
354
355
356
357
358
359
/*****************************************************************************
 * Private methods.
 *****************************************************************************/
wxPanel *OpenDialog::FilePanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

    wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );

gbazin's avatar
   
gbazin committed
360
    file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
gbazin's avatar
   
gbazin committed
361
362
                                 wxPoint(20,25), wxSize(200, -1), 0, NULL );
    wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
gbazin's avatar
   
gbazin committed
363
                                            wxU(_("Browse...")) );
gbazin's avatar
   
gbazin committed
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
    sizer->Add( file_combo, 1, wxALL, 5 );
    sizer->Add( browse_button, 0, wxALL, 5 );

    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
381
        wxU(_("DVD (menus support)")),
gbazin's avatar
   
gbazin committed
382
383
384
385
        wxU(_("DVD")),
        wxU(_("VCD")),
        wxU(_("CD Audio"))

gbazin's avatar
   
gbazin committed
386
387
    };

gbazin's avatar
   
gbazin committed
388
    disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
gbazin's avatar
   
gbazin committed
389
390
391
392
393
                                wxDefaultPosition, wxDefaultSize,
                                WXSIZEOF(disc_type_array), disc_type_array,
                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
    sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );

gbazin's avatar
   
gbazin committed
394
395
    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
    disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
gbazin's avatar
   
gbazin committed
396
397
398
399
400
401
                                  wxDefaultPosition, wxDefaultSize,
                                  wxTE_PROCESS_ENTER);

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

gbazin's avatar
   
gbazin committed
402
    label = new wxStaticText( panel, -1, wxU(_("Title")) );
gbazin's avatar
   
gbazin committed
403
    disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
gbazin's avatar
   
gbazin committed
404
405
406
407

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

gbazin's avatar
   
gbazin committed
408
    label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
gbazin's avatar
   
gbazin committed
409
    disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
gbazin's avatar
   
gbazin committed
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    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 );
gbazin's avatar
   
gbazin committed
425
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
gbazin's avatar
   
gbazin committed
426
427
428

    static const wxString net_type_array[] =
    {
gbazin's avatar
   
gbazin committed
429
430
431
        wxU(_("UDP/RTP")),
        wxU(_("UDP/RTP Multicast")),
        wxU(_("HTTP/FTP/MMS"))
gbazin's avatar
   
gbazin committed
432
433
    };

gbazin's avatar
   
gbazin committed
434
    for( i=0; i<3; i++ )
gbazin's avatar
   
gbazin committed
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
    {
        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;
    int val = config_GetInt( p_intf, "server-port" );
    subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
gbazin's avatar
   
gbazin committed
450
    label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
451
    net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
gbazin's avatar
   
gbazin committed
452
                                   wxString::Format(wxT("%d"), val),
gbazin's avatar
   
gbazin committed
453
454
455
456
457
458
459
460
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
                                   0, 16000, val);

    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_ports[0], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
gbazin's avatar
   
gbazin committed
461
    net_radios[0]->SetValue( TRUE );
gbazin's avatar
   
gbazin committed
462
463
464

    /* UDP/RTP Multicast row */
    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
gbazin's avatar
   
gbazin committed
465
466
    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
467
468
469
470
471
472
                                   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
473
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
474
    net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
gbazin's avatar
   
gbazin committed
475
                                   wxString::Format(wxT("%d"), val),
gbazin's avatar
   
gbazin committed
476
477
478
479
480
481
482
483
484
485
486
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
                                   0, 16000, val);

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

    /* HTTP row */
    subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
gbazin's avatar
   
gbazin committed
487
488
    label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
    net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
gbazin's avatar
   
gbazin committed
489
490
491
                                   wxDefaultPosition, wxSize( 200, -1 ),
                                   wxTE_PROCESS_ENTER);
    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
492
    subpanel_sizer->Add( net_addrs[2], 1,
gbazin's avatar
   
gbazin committed
493
                         wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
494
    net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
gbazin's avatar
   
gbazin committed
495
496

    /* Stuff everything into the main panel */
gbazin's avatar
   
gbazin committed
497
    for( i=0; i<3; i++ )
gbazin's avatar
   
gbazin committed
498
    {
gbazin's avatar
   
gbazin committed
499
500
501
502
        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
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
    }

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

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

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

void OpenDialog::UpdateMRL( int i_access_method )
{
gbazin's avatar
   
gbazin committed
520
    wxString demux, mrltemp;
gbazin's avatar
   
gbazin committed
521
522
523
524
525
526

    i_current_access_method = i_access_method;

    /* Check if the user asked for demuxdump */
    if( demuxdump_checkbox->GetValue() )
    {
gbazin's avatar
   
gbazin committed
527
        demux = wxT("/demuxdump");
gbazin's avatar
   
gbazin committed
528
529
    }

gbazin's avatar
   
gbazin committed
530
531
532
    switch( i_access_method )
    {
    case FILE_ACCESS:
gbazin's avatar
   
gbazin committed
533
534
        //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
        mrltemp = file_combo->GetValue();
gbazin's avatar
   
gbazin committed
535
536
        break;
    case DISC_ACCESS:
gbazin's avatar
   
gbazin committed
537
        mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
gbazin's avatar
   
gbazin committed
538
                disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
gbazin's avatar
   
gbazin committed
539
                disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
gbazin's avatar
   
gbazin committed
540
                  + demux + wxT(":")
gbazin's avatar
   
gbazin committed
541
                  + disc_device->GetLineText(0)
gbazin's avatar
   
gbazin committed
542
                  + wxString::Format( wxT("@%d:%d"),
gbazin's avatar
   
gbazin committed
543
544
545
546
547
548
549
550
551
552
                                      disc_title->GetValue(),
                                      disc_chapter->GetValue() );
        break;
    case NET_ACCESS:
        switch( i_net_type )
        {
        case 0:
            if( net_ports[0]->GetValue() !=
                config_GetInt( p_intf, "server-port" ) )
            {
gbazin's avatar
   
gbazin committed
553
554
555
                mrltemp = wxT("udp") + demux +
                          wxString::Format( wxT("://@:%d"),
                                            net_ports[0]->GetValue() );
gbazin's avatar
   
gbazin committed
556
557
558
            }
            else
            {
gbazin's avatar
   
gbazin committed
559
                mrltemp = wxT("udp") + demux + wxT("://");
gbazin's avatar
   
gbazin committed
560
561
562
563
            }
            break;

        case 1:
gbazin's avatar
   
gbazin committed
564
565
            mrltemp = wxT("udp") + demux + wxT("://@") +
                      net_addrs[1]->GetLineText(0);
gbazin's avatar
   
gbazin committed
566
567
568
            if( net_ports[1]->GetValue() !=
                config_GetInt( p_intf, "server-port" ) )
            {
gbazin's avatar
   
gbazin committed
569
                mrltemp = mrltemp + wxString::Format( wxT(":%d"),
gbazin's avatar
   
gbazin committed
570
571
572
573
574
575
                                              net_ports[1]->GetValue() );
            }
            break;

        case 2:
            /* http access */     
gbazin's avatar
   
gbazin committed
576
577
            mrltemp = wxT("http") + demux + wxT("://") +
                      net_addrs[2]->GetLineText(0);
gbazin's avatar
   
gbazin committed
578
579
580
581
            break;
        }
        break;
    case SAT_ACCESS:
gbazin's avatar
   
gbazin committed
582
        mrltemp = wxT("satellite") + demux + wxT("://");
gbazin's avatar
   
gbazin committed
583
584
585
586
587
        break;
    default:
        break;
    }

gbazin's avatar
   
gbazin committed
588
589
590
    mrl_combo->SetValue( mrltemp );
}

gbazin's avatar
   
gbazin committed
591
592
593
594
595
/*****************************************************************************
 * Events methods.
 *****************************************************************************/
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
596
    mrl = SeparateEntries( mrl_combo->GetValue() );
gbazin's avatar
   
gbazin committed
597
598
599
    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
600
601
602
603
604

    /* Update the playlist */
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
				       FIND_ANYWHERE );
605
    if( p_playlist == NULL ) return;
gbazin's avatar
   
gbazin committed
606

607
    for( int i = 0; i < (int)mrl.GetCount(); i++ )
gbazin's avatar
   
gbazin committed
608
    {
609
610
611
612
613
        int i_options = 0, i_total_options;
        char **ppsz_options = NULL;

        /* Count the input options */
        while( i + i_options + 1 < (int)mrl.GetCount() &&
gbazin's avatar
   
gbazin committed
614
               ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
        {
            i_options++;
        }

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

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

	i_total_options = i_options;

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

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

            i_total_options += subsfile_mrl.GetCount();
        }

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

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

            i_total_options += sout_mrl.GetCount();
        }

gbazin's avatar
   
gbazin committed
660
        playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
661
                      (const char **)ppsz_options, i_total_options,
gbazin's avatar
   
gbazin committed
662
                      PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
663
664
665
666
667
668
669
670

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

        i += i_options;
   }
gbazin's avatar
   
gbazin committed
671
672
673
674
675
676

    //TogglePlayButton( PLAYING_S );

    vlc_object_release( p_playlist );

    Hide();
gbazin's avatar
   
gbazin committed
677
678
679
680
}

void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
681
    Hide();
gbazin's avatar
   
gbazin committed
682
683
684
685
686
687
688
689
690
}

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

void OpenDialog::OnMRLChange( wxCommandEvent& event )
{
gbazin's avatar
   
gbazin committed
691
    //mrl = SeparateEntries( event.GetString() );
gbazin's avatar
   
gbazin committed
692
693
694
695
696
697
698
699
700
701
702
703
}

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

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

gbazin's avatar
   
gbazin committed
708
    if( file_dialog && file_dialog->ShowModal() == wxID_OK )
gbazin's avatar
   
gbazin committed
709
    {
gbazin's avatar
   
gbazin committed
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
        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
725
        if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
gbazin's avatar
   
gbazin committed
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
        UpdateMRL( FILE_ACCESS );
    }
}

/*****************************************************************************
 * Disc panel event methods.
 *****************************************************************************/
void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
{
    UpdateMRL( DISC_ACCESS );
}

void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
{
    char *psz_device;

    switch( disc_type->GetSelection() )
    {
gbazin's avatar
   
gbazin committed
744
    case 2:
gbazin's avatar
   
gbazin committed
745
        psz_device = config_GetPsz( p_intf, "vcd" );
gbazin's avatar
   
gbazin committed
746
        disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
gbazin's avatar
   
gbazin committed
747
748
749
750
        break;

    default:
        psz_device = config_GetPsz( p_intf, "dvd" );
gbazin's avatar
   
gbazin committed
751
        disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
gbazin's avatar
   
gbazin committed
752
753
754
755
        break;
    }

    if( psz_device ) free( psz_device );
gbazin's avatar
   
gbazin committed
756

gbazin's avatar
   
gbazin committed
757
758
    switch( disc_type->GetSelection() )
    {
gbazin's avatar
   
gbazin committed
759
    case 0:
gbazin's avatar
   
gbazin committed
760
761
762
763
764
765
766
767
768
769
770
771
772
        disc_title->SetRange( 0, 255 );
        disc_title->SetValue( 0 );
        break;

    default:
        disc_title->SetRange( 1, 255 );
        disc_title->SetValue( 1 );
        break;
    }

    disc_chapter->SetRange( 1, 255 );
    disc_chapter->SetValue( 1 );

gbazin's avatar
   
gbazin committed
773
    UpdateMRL( DISC_ACCESS );
gbazin's avatar
   
gbazin committed
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
}

/*****************************************************************************
 * Net panel event methods.
 *****************************************************************************/
void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
{
    UpdateMRL( NET_ACCESS );
}

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

    i_net_type = event.GetId() - NetRadio1_Event;

gbazin's avatar
   
gbazin committed
790
    for(i=0; i<3; i++)
gbazin's avatar
   
gbazin committed
791
    {
gbazin's avatar
   
gbazin committed
792
        net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
gbazin's avatar
   
gbazin committed
793
794
795
796
797
        net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
    }

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

gbazin's avatar
   
gbazin committed
799
800
801
802
803
804
/*****************************************************************************
 * Subtitles file event methods.
 *****************************************************************************/
void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
{
    subsfile_button->Enable( event.GetInt() != 0 );
805
    if( event.GetInt() && demuxdump_checkbox->IsChecked() )
gbazin's avatar
   
gbazin committed
806
807
808
809
810
811
812
813
814
815
816
    {
        demuxdump_checkbox->SetValue( 0 );
        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
        event.SetInt( 0 );
        OnDemuxDumpEnable( event );
    }
}

void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the open dialog */
gbazin's avatar
   
gbazin committed
817
    if( subsfile_dialog == NULL )
gbazin's avatar
   
gbazin committed
818
        subsfile_dialog = new SubsFileDialog( p_intf, this );
gbazin's avatar
   
gbazin committed
819

gbazin's avatar
   
gbazin committed
820
    if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
gbazin's avatar
   
gbazin committed
821
    {
822
823
824
825
826
827
828
        subsfile_mrl.Empty();
        subsfile_mrl.Add( wxString(wxT("sub-file=")) +
                          subsfile_dialog->file_combo->GetValue() );
        subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
                          subsfile_dialog->delay_spinctrl->GetValue() ) );
        subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
                          subsfile_dialog->fps_spinctrl->GetValue() ) );
gbazin's avatar
   
gbazin committed
829
830
831
    }
}

gbazin's avatar
   
gbazin committed
832
833
834
835
836
837
/*****************************************************************************
 * Stream output event methods.
 *****************************************************************************/
void OpenDialog::OnSoutEnable( wxCommandEvent& event )
{
    sout_button->Enable( event.GetInt() != 0 );
838
    if( event.GetInt() && demuxdump_checkbox->IsChecked() )
gbazin's avatar
   
gbazin committed
839
840
841
842
843
844
    {
        demuxdump_checkbox->SetValue( 0 );
        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
        event.SetInt( 0 );
        OnDemuxDumpEnable( event );
    }
gbazin's avatar
   
gbazin committed
845
846
847
848
849
}

void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the open dialog */
gbazin's avatar
   
gbazin committed
850
    if( sout_dialog == NULL )
gbazin's avatar
   
gbazin committed
851
        sout_dialog = new SoutDialog( p_intf, this );
gbazin's avatar
   
gbazin committed
852

gbazin's avatar
   
gbazin committed
853
    if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
gbazin's avatar
   
gbazin committed
854
    {
gbazin's avatar
   
gbazin committed
855
        sout_mrl = sout_dialog->GetOptions();
gbazin's avatar
   
gbazin committed
856
857
    }
}
gbazin's avatar
   
gbazin committed
858
859
860
861
862
863
864
865
866
867
868
869

/*****************************************************************************
 * Demux dump event methods.
 *****************************************************************************/
void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
{
    demuxdump_textctrl->Enable( event.GetInt() != 0 );
    demuxdump_button->Enable( event.GetInt() != 0 );

    if( event.GetInt() )
    {
        sout_checkbox->SetValue( 0 );
gbazin's avatar
   
gbazin committed
870
        subsfile_checkbox->SetValue( 0 );
gbazin's avatar
   
gbazin committed
871
872
873
        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
        event.SetInt( 0 );
        OnSoutEnable( event );
gbazin's avatar
   
gbazin committed
874
        OnSubsFileEnable( event );
gbazin's avatar
   
gbazin committed
875
876
877
878
879
880
881
    }

    UpdateMRL( i_current_access_method );
}

void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
882
883
    if( demuxdump_dialog == NULL )
        demuxdump_dialog = new wxFileDialog( this, wxU(_("Save file")),
gbazin's avatar
   
gbazin committed
884
                               wxT(""), wxT(""), wxT("*"), wxSAVE );
gbazin's avatar
   
gbazin committed
885

gbazin's avatar
   
gbazin committed
886
    if( demuxdump_dialog && demuxdump_dialog->ShowModal() == wxID_OK )
gbazin's avatar
   
gbazin committed
887
    {
gbazin's avatar
   
gbazin committed
888
        demuxdump_textctrl->SetValue( demuxdump_dialog->GetPath() );
gbazin's avatar
   
gbazin committed
889
890
891
892
893
894
895
896
        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
        OnDemuxDumpChange( event );
    }
}

void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
{
    config_PutPsz( p_intf, "demuxdump-file",
gbazin's avatar
   
gbazin committed
897
                   demuxdump_textctrl->GetValue().mb_str() );
gbazin's avatar
   
gbazin committed
898
}
gbazin's avatar
   
gbazin committed
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949

/*****************************************************************************
 * Utility functions.
 *****************************************************************************/
wxArrayString SeparateEntries( wxString entries )
{
    vlc_bool_t b_quotes_mode = VLC_FALSE;

    wxArrayString entries_array;
    wxString entry;

    wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );

    while( token.HasMoreTokens() )
    {
        entry += token.GetNextToken();

        if( entry.IsEmpty() ) continue;

        if( !b_quotes_mode && entry.Last() == wxT('\"') )
        {
            /* Enters quotes mode */
            entry.RemoveLast();
            b_quotes_mode = VLC_TRUE;
        }
        else if( b_quotes_mode && entry.Last() == wxT('\"') )
        {
            /* Finished the quotes mode */
            entry.RemoveLast();
            if( !entry.IsEmpty() ) entries_array.Add( entry );
            entry.Empty();
            b_quotes_mode = VLC_FALSE;
        }
        else if( !b_quotes_mode && entry.Last() != wxT('\"') )
        {
            /* we found a non-quoted standalone string */
            if( token.HasMoreTokens() ||
                entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
                entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
                entry.RemoveLast();
            if( !entry.IsEmpty() ) entries_array.Add( entry );
            entry.Empty();
        }
        else
        {;}
    }

    if( !entry.IsEmpty() ) entries_array.Add( entry );

    return entries_array;
}