open.cpp 64.5 KB
Newer Older
Gildas Bazin's avatar
 
Gildas Bazin committed
1
/*****************************************************************************
2
 * open.cpp : Open dialog box
Gildas Bazin's avatar
 
Gildas Bazin committed
3
 *****************************************************************************
4
 * Copyright (C) 2000-2005 the VideoLAN team
Carlo Calabrò's avatar
Carlo Calabrò committed
5
 * $Id$
Gildas Bazin's avatar
 
Gildas Bazin committed
6
 *
7
 * Authors: Gildas Bazin <gbazin@videolan.org>
Gildas Bazin's avatar
 
Gildas Bazin committed
8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * 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
Antoine Cellerier's avatar
Antoine Cellerier committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
Gildas Bazin's avatar
 
Gildas Bazin committed
22 23 24 25 26
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
27 28 29 30
#include "dialogs/open.hpp"
#include "dialogs/streamout.hpp"
#include "dialogs/preferences_widgets.h"
#include "dialogs/subtitles.hpp"
31

Clément Stenac's avatar
Clément Stenac committed
32
#include "vlc_charset.h"
33

34
#undef HAVE_LIBCDIO // Disable broken code
Clément Stenac's avatar
Clément Stenac committed
35

36 37 38
#ifdef HAVE_LIBCDIO
#include <cdio/cdio.h>
#include <cdio/cd_types.h>
39
#include <cdio/logging.h>
40
#endif /* HAVE_LIBCDIO */
41

42 43
#ifdef HAVE_VCDINFO
#include <libvcd/version.h>
44 45 46 47
/* There was a bug in libvcdinfo <= 23 which prevented C++ compilation */
#if LIBVCD_VERSION_NUM > 23
#include <libvcd/info.h>
#endif /* LIBVCD_VERSION_NUM > 23 */
48
#endif /* HAVE_VCDINFO */
Gildas Bazin's avatar
 
Gildas Bazin committed
49 50

#include <wx/combobox.h>
Gildas Bazin's avatar
 
Gildas Bazin committed
51
#include <wx/statline.h>
Gildas Bazin's avatar
 
Gildas Bazin committed
52
#include <wx/tokenzr.h>
Gildas Bazin's avatar
 
Gildas Bazin committed
53

54
#ifndef wxRB_SINGLE
Gildas Bazin's avatar
 
Gildas Bazin committed
55
#   define wxRB_SINGLE 0
56 57
#endif

58 59 60 61 62
#define SELECTION_DISC_TYPE_DVD_MENUS 0
#define SELECTION_DISC_TYPE_DVD       1
#define SELECTION_DISC_TYPE_VCD       2
#define SELECTION_DISC_TYPE_CDDA      3

Gildas Bazin's avatar
 
Gildas Bazin committed
63 64 65 66 67 68 69 70 71 72 73
/*****************************************************************************
 * Event Table.
 *****************************************************************************/

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

    FileBrowse_Event,
Clément Stenac's avatar
Clément Stenac committed
74
    SubFileBrowse_Event,
Gildas Bazin's avatar
 
Gildas Bazin committed
75
    FileName_Event,
Clément Stenac's avatar
Clément Stenac committed
76
    SubFileName_Event,
Gildas Bazin's avatar
 
Gildas Bazin committed
77 78

    DiscType_Event,
79 80 81
#ifdef HAVE_LIBCDIO
    DiscProbe_Event,
#endif
Gildas Bazin's avatar
 
Gildas Bazin committed
82 83 84
    DiscDevice_Event,
    DiscTitle_Event,
    DiscChapter_Event,
85
    DiscSub_Event,
86
    DiscAudio_Event,
Gildas Bazin's avatar
 
Gildas Bazin committed
87 88

    NetType_Event,
89
    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
Gildas Bazin's avatar
 
Gildas Bazin committed
90
    NetPort1_Event, NetPort2_Event, NetPort3_Event,
91
    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
92
    NetForceIPv6_Event, NetTimeshift_Event,
Gildas Bazin's avatar
 
Gildas Bazin committed
93

Gildas Bazin's avatar
 
Gildas Bazin committed
94 95 96
    SubsFileEnable_Event,
    SubsFileSettings_Event,

Gildas Bazin's avatar
 
Gildas Bazin committed
97 98
    SoutEnable_Event,
    SoutSettings_Event,
99

100 101 102
    CachingEnable_Event,
    CachingChange_Event,

103
    AdvancedOptions_Event
Gildas Bazin's avatar
 
Gildas Bazin committed
104 105
};

106
BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
Gildas Bazin's avatar
 
Gildas Bazin committed
107 108 109 110 111 112
    /* Button events */
    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)

    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)

113
    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
Gildas Bazin's avatar
 
Gildas Bazin committed
114 115 116

    /* Events generated by the file panel */
    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
Gildas Bazin's avatar
 
Gildas Bazin committed
117
    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
Clément Stenac's avatar
Clément Stenac committed
118 119
    EVT_TEXT(SubFileName_Event, OpenDialog::OnSubFileChange)
    EVT_BUTTON(SubFileBrowse_Event, OpenDialog::OnSubFileBrowse)
Gildas Bazin's avatar
 
Gildas Bazin committed
120 121 122

    /* Events generated by the disc panel */
    EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
123 124 125
#ifdef HAVE_LIBCDIO
    EVT_CHECKBOX(DiscProbe_Event, OpenDialog::OnDiscProbe)
#endif
126
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
Gildas Bazin's avatar
 
Gildas Bazin committed
127 128
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
    EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
129
    EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChangeSpin)
Gildas Bazin's avatar
 
Gildas Bazin committed
130
    EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
131
    EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChangeSpin)
132
    EVT_TEXT(DiscSub_Event, OpenDialog::OnDiscPanelChange)
133
    EVT_TEXT(DiscAudio_Event, OpenDialog::OnDiscPanelChange)
134
    EVT_SPINCTRL(DiscSub_Event, OpenDialog::OnDiscPanelChangeSpin)
Gildas Bazin's avatar
 
Gildas Bazin committed
135 136 137 138 139

    /* Events generated by the net panel */
    EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
140
    EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
Gildas Bazin's avatar
 
Gildas Bazin committed
141
    EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
142
    EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChangeSpin)
Gildas Bazin's avatar
 
Gildas Bazin committed
143
    EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
144
    EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChangeSpin)
Gildas Bazin's avatar
 
Gildas Bazin committed
145
    EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
146
    EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChangeSpin)
Gildas Bazin's avatar
 
Gildas Bazin committed
147 148
    EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
149
    EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
150
    EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
151
    EVT_CHECKBOX(NetTimeshift_Event, OpenDialog::OnNetPanelChange)
Gildas Bazin's avatar
 
Gildas Bazin committed
152

Gildas Bazin's avatar
 
Gildas Bazin committed
153 154 155 156
    /* Events generated by the subtitle file buttons */
    EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
    EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)

Gildas Bazin's avatar
 
Gildas Bazin committed
157 158 159
    /* Events generated by the stream output buttons */
    EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
    EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
Gildas Bazin's avatar
 
Gildas Bazin committed
160

161 162 163
    /* Events generated by the caching button */
    EVT_CHECKBOX(CachingEnable_Event, OpenDialog::OnCachingEnable)
    EVT_TEXT(CachingChange_Event, OpenDialog::OnCachingChange)
164
    EVT_SPINCTRL(CachingChange_Event, OpenDialog::OnCachingChangeSpin)
165

Gildas Bazin's avatar
 
Gildas Bazin committed
166
    /* Hide the window when the user closes the window */
167
    EVT_CLOSE(OpenDialog::OnClose)
Gildas Bazin's avatar
 
Gildas Bazin committed
168

Gildas Bazin's avatar
 
Gildas Bazin committed
169 170
END_EVENT_TABLE()

171

172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
/*****************************************************************************
 * AutoBuiltPanel.
 *****************************************************************************/
WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);

class AutoBuiltPanel : public wxPanel
{
public:

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

    virtual ~AutoBuiltPanel() {}

187 188
    void UpdateAdvancedMRL();

189 190
    wxString name;
    ArrayOfConfigControls config_array;
191 192
    ArrayOfConfigControls advanced_config_array;
    wxComboBox *p_advanced_mrl_combo;
193 194 195

private:
    intf_thread_t *p_intf;
196 197 198 199 200 201
    OpenDialog *p_open_dialog;

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

    DECLARE_EVENT_TABLE();
202 203
};

204 205 206 207 208
BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
    EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
END_EVENT_TABLE()

static void AutoBuildCallback( void *p_data )
209 210 211 212
{
    ((OpenDialog *)p_data)->UpdateMRL();
}

213 214 215 216 217
static void AutoBuildAdvancedCallback( void *p_data )
{
    ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
}

218 219 220
AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
                                intf_thread_t *_p_intf,
                                const module_t *p_module )
221
  : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
222
    name( wxU(module_get_object(p_module)) ),
223 224
    p_advanced_mrl_combo( NULL ),
    p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
225 226
{
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
227
    bool b_advanced = false;
228 229
    unsigned int i_confsize; 
    module_config_t *p_config;
230
    int n;
231

232
    p_config = module_config_get (p_module, &i_confsize);
233
    for( n = 0; n < i_confsize; n++ )
234
    {
235
        module_config_t *p_item = p_config + n;
236 237 238
        if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
            b_advanced = true;

239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
        if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
            continue;

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

        config_array.Add( control );

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

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

        sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
    }

255 256 257 258 259 260 261 262 263
    if( b_advanced )
    {
        wxButton *button =
            new wxButton( this, AdvancedOptions_Event,
                          wxU(_("Advanced options...")) );
        sizer->Add( button, 0, wxALL, 5 );

        /* Build the advanced dialog */
        p_advanced_dialog =
264
            new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
265 266
                          wxT(" (") + wxU( module_GetLongName(p_module) ) +
                          wxT(")"), wxDefaultPosition, wxDefaultSize,
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
                          wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );

        wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

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

        /* Add advanced options to panel */
289
        for( n = 0; n < i_confsize; n++ )
290
        {
291
            module_config_t *p_item = p_config + n;
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
            if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced )
                continue;

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

            advanced_config_array.Add( control );

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

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

            sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
        }

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

317
        /* Create buttons */
318
        wxButton *ok_button =
319
            new wxButton( p_advanced_dialog, wxID_OK, wxU(_("&OK")) );
320
        ok_button->SetDefault();
321
        wxButton *cancel_button =
322
            new wxButton( p_advanced_dialog, wxID_CANCEL, wxU(_("&Cancel")) );
323 324 325 326 327
        wxStdDialogButtonSizer *button_sizer = new wxStdDialogButtonSizer;
        button_sizer->AddButton( ok_button );
        button_sizer->AddButton( cancel_button );
        button_sizer->Realize();
        sizer->Add( button_sizer, 0, wxEXPAND|wxALL, 5 );
328 329 330 331 332

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

333
    module_config_free (p_config);
334

335 336 337
    this->SetSizerAndFit( sizer );
}

338 339
void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
{
340 341 342 343 344
    if( p_advanced_dialog->ShowModal() == wxID_OK )
    {
        UpdateAdvancedMRL();
        p_open_dialog->UpdateMRL();
    }
345 346 347 348 349 350 351 352 353 354
}

void AutoBuiltPanel::UpdateAdvancedMRL()
{
    wxString mrltemp;

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

355
        mrltemp += (i ? wxT(" :") : wxT(":"));
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383

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

        mrltemp += control->GetName();

        switch( control->GetType() )
        {
        case CONFIG_ITEM_STRING:
        case CONFIG_ITEM_FILE:
        case CONFIG_ITEM_DIRECTORY:
        case CONFIG_ITEM_MODULE:
            mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
            break;
        case CONFIG_ITEM_INTEGER:
            mrltemp +=
                wxString::Format( wxT("=%i"), control->GetIntValue() );
            break;
        case CONFIG_ITEM_FLOAT:
            mrltemp +=
                wxString::Format(wxT("=%f"), control->GetFloatValue());
            break;
        }
    }

    p_advanced_mrl_combo->SetValue( mrltemp );
}

Gildas Bazin's avatar
 
Gildas Bazin committed
384 385 386
/*****************************************************************************
 * Constructor.
 *****************************************************************************/
Gildas Bazin's avatar
 
Gildas Bazin committed
387
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
Gildas Bazin's avatar
 
Gildas Bazin committed
388
                        int i_access_method, int i_arg ):
389
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
Gildas Bazin's avatar
 
Gildas Bazin committed
390
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
391 392 393 394 395 396
{
    OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
}

OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
                        int i_access_method, int i_arg, int _i_method ):
397
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
398
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
Gildas Bazin's avatar
 
Gildas Bazin committed
399 400
{
    /* Initializations */
401
    i_method = _i_method;
Gildas Bazin's avatar
 
Gildas Bazin committed
402
    p_intf = _p_intf;
Gildas Bazin's avatar
 
Gildas Bazin committed
403
    p_parent = _p_parent;
Gildas Bazin's avatar
 
Gildas Bazin committed
404
    SetIcon( *p_intf->p_sys->p_icon );
Gildas Bazin's avatar
 
Gildas Bazin committed
405
    file_dialog = NULL;
406
    i_disc_type_selection = 0;
Clément Stenac's avatar
Clément Stenac committed
407
    i_disc_title = 0;
Gildas Bazin's avatar
 
Gildas Bazin committed
408
    i_open_arg = i_arg;
Sam Hocevar's avatar
Sam Hocevar committed
409

Gildas Bazin's avatar
 
Gildas Bazin committed
410 411
    sout_dialog = NULL;
    subsfile_dialog = NULL;
412
    b_disc_device_changed = false;
Gildas Bazin's avatar
 
Gildas Bazin committed
413 414 415 416 417 418

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


Clément Stenac's avatar
Clément Stenac committed
419 420 421 422 423
    /* Advanced options */
    wxStaticBox *adv_box = new wxStaticBox( panel, -1,
                               wxU(_("Advanced options")) );
    wxStaticBoxSizer *adv_sizer = new wxStaticBoxSizer( adv_box,
                                                        wxVERTICAL );
Gildas Bazin's avatar
 
Gildas Bazin committed
424 425


426
    wxFlexGridSizer *common_opt_sizer = new wxFlexGridSizer( 5, 1, 20 );
427
    if( i_method == OPEN_NORMAL )
Gildas Bazin's avatar
 
Gildas Bazin committed
428
    {
429 430
        /* Create Stream Output checkox */
        sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
Clément Stenac's avatar
Clément Stenac committed
431
                                         wxU(_("Stream/Save")) );
432
        sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
433 434 435
        common_opt_sizer->Add( sout_checkbox, 0,
                               wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );

436 437
        sout_button = new wxButton( panel, SoutSettings_Event,
                                    wxU(_("Settings...")) );
438
        sout_button->Disable();
439 440 441 442 443 444

        char *psz_sout = config_GetPsz( p_intf, "sout" );
        if( psz_sout && *psz_sout )
        {
            sout_checkbox->SetValue(TRUE);
            sout_button->Enable();
Gildas Bazin's avatar
 
Gildas Bazin committed
445
            subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
446
        }
447
        free( psz_sout );
448

449 450
        common_opt_sizer->Add( sout_button, 1, wxALIGN_LEFT |
                               wxALIGN_CENTER_VERTICAL );
451

452 453
        common_opt_sizer->Add( new wxPanel( this, -1 ), 1,
                               wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
454
    }
Gildas Bazin's avatar
 
Gildas Bazin committed
455

456 457 458 459
    /* Create caching options */
    caching_checkbox = new wxCheckBox( panel, CachingEnable_Event,
                                       wxU(_("Caching")) );
    caching_checkbox->SetToolTip( wxU(_("Change the default caching value "
460
                                        "(in milliseconds)")) );
461 462 463 464 465 466 467 468
    common_opt_sizer->Add( caching_checkbox, 0,
                           wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    caching_value = new wxSpinCtrl( panel, CachingChange_Event );
    caching_value->SetRange( 0, 1000000 );
    caching_value->Disable();
    common_opt_sizer->Add( caching_value, 0,
                           wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );

Clément Stenac's avatar
Clément Stenac committed
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486

    wxBoxSizer *mrl_sizer = new wxBoxSizer( wxHORIZONTAL );
    wxStaticText *mrl_label = new wxStaticText( panel, -1,
                                                wxU(_("Customize:")) );
    mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
                                wxDefaultPosition, wxDefaultSize );
    //Point(20,25), wxSize(120, -1) );
    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 "
        "filled automatically when you use the controls above.")) );

    mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
    mrl_sizer->Add( mrl_combo, 1, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL,
                    5 );

    adv_sizer->Add( common_opt_sizer, 0, wxTOP | wxLEFT|wxRIGHT | wxEXPAND, 5 );
    adv_sizer->Add( mrl_sizer, 0, wxBOTTOM  | wxLEFT|wxRIGHT  | wxEXPAND, 5 );

487 488 489
    /* Separation */
    wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );

Gildas Bazin's avatar
 
Gildas Bazin committed
490
    /* Create the buttons */
491
    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("&OK")) );
Gildas Bazin's avatar
 
Gildas Bazin committed
492
    ok_button->SetDefault();
493 494
    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
                                            wxU(_("&Cancel")) );
Gildas Bazin's avatar
 
Gildas Bazin committed
495

Gildas Bazin's avatar
 
Gildas Bazin committed
496
    /* Create notebook */
Gildas Bazin's avatar
 
Gildas Bazin committed
497
    notebook = new wxNotebook( panel, Notebook_Event );
498

499
#if (!wxCHECK_VERSION(2,5,2))
Gildas Bazin's avatar
 
Gildas Bazin committed
500
    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
Clément Stenac's avatar
Clément Stenac committed
501
#endif
Gildas Bazin's avatar
 
Gildas Bazin committed
502

Gildas Bazin's avatar
 
Gildas Bazin committed
503
    notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
Gildas Bazin's avatar
 
Gildas Bazin committed
504
                       i_access_method == FILE_ACCESS );
Gildas Bazin's avatar
 
Gildas Bazin committed
505
    notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
Gildas Bazin's avatar
 
Gildas Bazin committed
506
                       i_access_method == DISC_ACCESS );
Gildas Bazin's avatar
 
Gildas Bazin committed
507
    notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
Gildas Bazin's avatar
 
Gildas Bazin committed
508
                       i_access_method == NET_ACCESS );
509

510
    if( module_exists( "v4l" ) )
511 512 513 514
    {
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
515
        notebook->AddPage( autopanel, wxU( module_get_name(p_module, 0) ),
516 517 518
                           i_access_method == CAPTURE_ACCESS );
    }

519
    if( module_exists( "pvr" ) )
520 521 522 523
    {
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
524
        notebook->AddPage( autopanel, wxU( module_get_name(p_module, 0) ),
525 526 527
                           i_access_method == CAPTURE_ACCESS );
    }

528
    if( module_exists( "dvb" ) )
529 530 531 532
    {
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
533
        notebook->AddPage( autopanel, wxU( module_get_name(p_module, 0) ),
534 535 536
                           i_access_method == CAPTURE_ACCESS );
    }

537
    if( module_exists( "dshow" ) )
Gildas Bazin's avatar
 
Gildas Bazin committed
538
    {
539 540 541
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
542
        notebook->AddPage( autopanel, wxU( module_get_name(p_module, 0) ),
Gildas Bazin's avatar
Gildas Bazin committed
543
                           i_access_method == CAPTURE_ACCESS );
Gildas Bazin's avatar
 
Gildas Bazin committed
544 545
    }

Gildas Bazin's avatar
 
Gildas Bazin committed
546 547 548 549
    /* Update Disc panel */
    wxCommandEvent dummy_event;
    OnDiscTypeChange( dummy_event );

Gildas Bazin's avatar
 
Gildas Bazin committed
550 551 552 553
    /* Update Net panel */
    dummy_event.SetId( NetRadio1_Event );
    OnNetTypeChange( dummy_event );

Gildas Bazin's avatar
 
Gildas Bazin committed
554
    /* Update MRL */
555
    wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
Gildas Bazin's avatar
 
Gildas Bazin committed
556 557 558
    OnPageChange( event );

    /* Place everything in sizers */
559 560 561 562
    wxStdDialogButtonSizer *button_sizer = new wxStdDialogButtonSizer;
    button_sizer->AddButton( cancel_button );
    button_sizer->AddButton( ok_button );
    button_sizer->Realize();
Gildas Bazin's avatar
 
Gildas Bazin committed
563 564
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
565
#if (!wxCHECK_VERSION(2,5,2))
Gildas Bazin's avatar
 
Gildas Bazin committed
566
    panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
Clément Stenac's avatar
Clément Stenac committed
567 568
#else
    panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
Clément Stenac's avatar
Clément Stenac committed
569
#endif
Clément Stenac's avatar
Clément Stenac committed
570
    panel_sizer->Add( adv_sizer, 0, wxEXPAND | wxALL, 5 );
571
    panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
572
    panel_sizer->Add( button_sizer, 0, wxEXPAND | wxALL, 5 );
Gildas Bazin's avatar
 
Gildas Bazin committed
573 574 575 576 577 578 579 580 581
    panel_sizer->Layout();
    panel->SetSizerAndFit( panel_sizer );
    main_sizer->Add( panel, 1, wxGROW, 0 );
    main_sizer->Layout();
    SetSizerAndFit( main_sizer );
}

OpenDialog::~OpenDialog()
{
Gildas Bazin's avatar
 
Gildas Bazin committed
582
    /* Clean up */
583 584 585
    delete file_dialog;
    delete sout_dialog;
    delete subsfile_dialog;
Gildas Bazin's avatar
 
Gildas Bazin committed
586 587
}

Gildas Bazin's avatar
 
Gildas Bazin committed
588
int OpenDialog::Show( int i_access_method, int i_arg )
Gildas Bazin's avatar
 
Gildas Bazin committed
589 590
{
    notebook->SetSelection( i_access_method );
591
    int i_ret = wxDialog::Show();
Gildas Bazin's avatar
 
Gildas Bazin committed
592 593
    Raise();
    SetFocus();
Gildas Bazin's avatar
 
Gildas Bazin committed
594
    i_open_arg = i_arg;
Gildas Bazin's avatar
 
Gildas Bazin committed
595
    return i_ret;
Gildas Bazin's avatar
 
Gildas Bazin committed
596 597
}

Gildas Bazin's avatar
 
Gildas Bazin committed
598
int OpenDialog::Show()
Gildas Bazin's avatar
 
Gildas Bazin committed
599
{
600
    int i_ret = wxDialog::Show();
Gildas Bazin's avatar
 
Gildas Bazin committed
601 602 603
    Raise();
    SetFocus();
    return i_ret;
Gildas Bazin's avatar
 
Gildas Bazin committed
604 605
}

Gildas Bazin's avatar
 
Gildas Bazin committed
606 607 608 609 610 611 612 613
/*****************************************************************************
 * Private methods.
 *****************************************************************************/
wxPanel *OpenDialog::FilePanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

Gildas Bazin's avatar
 
Gildas Bazin committed
614 615 616 617
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

    /* Create browse file line */
    wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
Gildas Bazin's avatar
 
Gildas Bazin committed
618

Clément Stenac's avatar
Clément Stenac committed
619 620 621 622
    file_sizer->Add( new wxStaticText( panel, -1, wxU(_("Open:") ) ), 0,
                     wxALL | wxALIGN_CENTER_VERTICAL, 5 );

    file_combo = new wxComboBox( panel, FileName_Event, wxT("") );
Gildas Bazin's avatar
 
Gildas Bazin committed
623
    wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
Gildas Bazin's avatar
 
Gildas Bazin committed
624
                                            wxU(_("Browse...")) );
Clément Stenac's avatar
Clément Stenac committed
625 626
    file_sizer->Add( file_combo, 1, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
    file_sizer->Add( browse_button, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
Gildas Bazin's avatar
 
Gildas Bazin committed
627

Clément Stenac's avatar
Clément Stenac committed
628 629
    /* Create Subtitles File checkox - button  */
    wxFlexGridSizer *subtitles_sizer = new wxFlexGridSizer( 2, 1, 20 );
Gildas Bazin's avatar
 
Gildas Bazin committed
630
    subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
Clément Stenac's avatar
Clément Stenac committed
631 632 633 634
                                        wxU(_("Use a subtitles file")) );
    subsfile_checkbox->SetToolTip( wxU(_("Use an external subtitles file.")) );
    subtitles_sizer->Add( subsfile_checkbox, 0,  wxALIGN_CENTER_VERTICAL |
                          wxALL, 5 );
Gildas Bazin's avatar
 
Gildas Bazin committed
635
    subsfile_button = new wxButton( panel, SubsFileSettings_Event,
Clément Stenac's avatar
Clément Stenac committed
636
                                    wxU(_("Advanced Settings...")) );
Gildas Bazin's avatar
 
Gildas Bazin committed
637
    subsfile_button->Disable();
Clément Stenac's avatar
Clément Stenac committed
638 639 640 641 642
    subtitles_sizer->Add( subsfile_button, 1, wxALIGN_CENTER_VERTICAL |
                           wxALL, 5 );

    /* Create subtitles file line */
    wxBoxSizer *subfile_sizer = new wxBoxSizer( wxHORIZONTAL );
Gildas Bazin's avatar
 
Gildas Bazin committed
643 644 645 646 647 648

    char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
    if( psz_subsfile && *psz_subsfile )
    {
        subsfile_checkbox->SetValue(TRUE);
        subsfile_button->Enable();
Gildas Bazin's avatar
 
Gildas Bazin committed
649
        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
Gildas Bazin's avatar
 
Gildas Bazin committed
650
    }
Clément Stenac's avatar
Clément Stenac committed
651 652 653 654 655
    if( !psz_subsfile )  psz_subsfile = strdup("");
    subfile_sizer->Add( new wxStaticText( panel, -1, wxU(_("File:") ) ),
                        0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
    subfile_combo = new wxComboBox( panel, SubFileName_Event,
                                    wxL2U( psz_subsfile ) );
656
    free( psz_subsfile );
Clément Stenac's avatar
Clément Stenac committed
657 658 659 660
    subbrowse_button = new wxButton( panel, SubFileBrowse_Event,
                                     wxU(_("Browse...")) );
    subfile_sizer->Add( subfile_combo, 1, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
    subfile_sizer->Add( subbrowse_button, 0, wxALL |wxALIGN_CENTER_VERTICAL, 5 );
Gildas Bazin's avatar
 
Gildas Bazin committed
661

Clément Stenac's avatar
Clément Stenac committed
662 663 664 665 666 667 668 669 670
    subfile_combo->Disable();
    subbrowse_button->Disable();

    psz_subsfile = config_GetPsz( p_intf, "sub-file" );
    if( psz_subsfile && *psz_subsfile )
    {
        subfile_combo->Enable();
        subbrowse_button->Enable();
    }
Gildas Bazin's avatar
 
Gildas Bazin committed
671

Gildas Bazin's avatar
 
Gildas Bazin committed
672
    sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
Clément Stenac's avatar
Clément Stenac committed
673 674
    sizer->Add( subtitles_sizer, 0, wxLEFT | wxRIGHT | wxTOP, 5 );
    sizer->Add( subfile_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT| wxBOTTOM, 5 );
Gildas Bazin's avatar
 
Gildas Bazin committed
675 676 677 678 679 680 681 682 683 684 685 686 687 688
    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[] =
    {
689
        wxU(_("DVD (menus)")),
Gildas Bazin's avatar
 
Gildas Bazin committed
690 691
        wxU(_("DVD")),
        wxU(_("VCD")),
692
        wxU(_("Audio CD")),
Gildas Bazin's avatar
 
Gildas Bazin committed
693 694
    };

Gildas Bazin's avatar
 
Gildas Bazin committed
695
    disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
Gildas Bazin's avatar
 
Gildas Bazin committed
696 697 698
                                wxDefaultPosition, wxDefaultSize,
                                WXSIZEOF(disc_type_array), disc_type_array,
                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
Sam Hocevar's avatar
Sam Hocevar committed
699

700
#ifdef HAVE_LIBCDIO
701
    disc_probe = new wxCheckBox( panel, DiscProbe_Event,
702
                                 wxU(_("Probe Disc(s)")) );
703
    disc_probe->SetToolTip( wxU(_("Probe for a DVD, VCD or audio CD. "
704 705 706 707
"First try the Device name entered for the selected Disc type "
"(DVD, DVD Menu, VCD, audio CD). If that doesn't find media, try any device "
"for the Disc type.  If that doesn't work, then try looking for CD-ROMs or "
"DVD drives. The Disc type, Device name, and some parameter ranges are set "
708
"based on media we find.")) );
709 710
#endif

711
    sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
712
#ifdef HAVE_LIBCDIO
713
    sizer_row->Add( disc_probe, 0, wxEXPAND | wxALL );
714
#endif
Gildas Bazin's avatar
 
Gildas Bazin committed
715

Gildas Bazin's avatar
 
Gildas Bazin committed
716 717
    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
    disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
Gildas Bazin's avatar
 
Gildas Bazin committed
718 719 720
                                  wxDefaultPosition, wxDefaultSize,
                                  wxTE_PROCESS_ENTER);

721 722
#ifdef WIN32
    char psz_default_device[3] = {0};
Clément Stenac's avatar
Clément Stenac committed
723
    char *psz_forced;
724 725 726 727 728 729 730

    /* find the drive_name for the first cdrom drive,
     * which is probably "D:" and put the drive_name into
     * psz_default_device... */
    for( char drive_letter = 'A'; drive_letter <= 'Z'; ++drive_letter )
    {
        char drive_name[3] = {drive_letter, ':', 0};
731
        UINT type = GetDriveTypeA( drive_name );
732 733 734 735 736 737 738 739
        if( type == DRIVE_CDROM )
        {
            psz_default_device[0] = drive_letter;
            psz_default_device[1] = ':';
            break;
        }
    }

Clément Stenac's avatar
Clément Stenac committed
740
    psz_forced = config_GetPsz( p_intf, "dvd" );
741

Clément Stenac's avatar
Clément Stenac committed
742 743
    if( strlen(psz_default_device) > 0 &&
        ( !psz_forced || psz_forced && !*psz_forced ) )
744 745 746 747 748 749
    {
        if(disc_device)
            disc_device->SetValue( wxL2U(psz_default_device) );
    }
#endif

Gildas Bazin's avatar
 
Gildas Bazin committed
750 751 752
    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

753
    disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
Gildas Bazin's avatar
 
Gildas Bazin committed
754
    disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
755
    sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
Gildas Bazin's avatar
 
Gildas Bazin committed
756 757
    sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

758
    disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
Gildas Bazin's avatar
 
Gildas Bazin committed
759
    disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
Sam Hocevar's avatar
Sam Hocevar committed
760 761
    sizer->Add( disc_chapter_label, 0,
                wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
Gildas Bazin's avatar
 
Gildas Bazin committed
762
    sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
763 764 765 766 767 768

    disc_sub_label = new wxStaticText( panel, -1, wxU(_("Subtitles track")) );
    disc_sub = new wxSpinCtrl( panel, DiscSub_Event );
    sizer->Add( disc_sub_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    sizer->Add( disc_sub, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    disc_sub->SetRange( -1, 255 );
769
    i_disc_sub = config_GetInt( p_intf, "sub-track" );
770 771
    disc_sub->SetValue( i_disc_sub );

772 773 774 775 776 777 778 779
    disc_audio_label = new wxStaticText( panel, -1, wxU(_("Audio track")) );
    disc_audio = new wxSpinCtrl( panel, DiscAudio_Event );
    sizer->Add( disc_audio_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    sizer->Add( disc_audio, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    disc_audio->SetRange( -1, 255 );
    i_disc_audio = config_GetInt( p_intf, "audio-track" );
    disc_audio->SetValue( i_disc_audio );

Gildas Bazin's avatar
 
Gildas Bazin committed
780 781 782 783 784 785 786 787 788 789 790 791 792
    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 );
793
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
Gildas Bazin's avatar
 
Gildas Bazin committed
794 795 796

    static const wxString net_type_array[] =
    {
Gildas Bazin's avatar
 
Gildas Bazin committed
797 798
        wxU(_("UDP/RTP")),
        wxU(_("UDP/RTP Multicast")),
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
799
        wxU(_("HTTP/HTTPS/FTP/MMS")),
800
        wxU(_("RTSP"))
Gildas Bazin's avatar
 
Gildas Bazin committed
801 802
    };

803
    for( i=0; i<4; i++ )
Gildas Bazin's avatar
 
Gildas Bazin committed
804 805 806 807 808 809 810 811 812 813
    {
        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 );
    }

814 815 816 817
    /* Timeshift */
    net_timeshift  = new wxCheckBox( panel, NetTimeshift_Event,
                                     wxU(_("Allow timeshifting")) );

Gildas Bazin's avatar
 
Gildas Bazin committed
818 819 820
    /* UDP/RTP row */
    wxFlexGridSizer *subpanel_sizer;
    wxStaticText *label;
Gildas Bazin's avatar
 
Gildas Bazin committed
821
    i_net_ports[0] = config_GetInt( p_intf, "server-port" );
822
    subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
Gildas Bazin's avatar
 
Gildas Bazin committed
823
    label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
Gildas Bazin's avatar
 
Gildas Bazin committed
824
    net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
Gildas Bazin's avatar
 
Gildas Bazin committed
825
                                   wxString::Format(wxT("%d"), i_net_ports[0]),
Gildas Bazin's avatar
 
Gildas Bazin committed
826 827
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
828
                                   0, 65535, i_net_ports[0] );
Gildas Bazin's avatar
 
Gildas Bazin committed
829 830 831 832

    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_ports[0], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
833 834 835 836
    net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
                               wxU(_("Force IPv6")));
    subpanel_sizer->Add( net_ipv6, 0,
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
Gildas Bazin's avatar
 
Gildas Bazin committed
837
    net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
Gildas Bazin's avatar
 
Gildas Bazin committed
838
    net_radios[0]->SetValue( TRUE );
Gildas Bazin's avatar
 
Gildas Bazin committed
839 840 841

    /* UDP/RTP Multicast row */
    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
Gildas Bazin's avatar
 
Gildas Bazin committed
842 843
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
    net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
Gildas Bazin's avatar
 
Gildas Bazin committed
844 845 846 847 848 849
                                   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 );

Gildas Bazin's avatar
 
Gildas Bazin committed
850
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
Gildas Bazin's avatar
 
Gildas Bazin committed
851
    i_net_ports[1] = i_net_ports[0];
Gildas Bazin's avatar
 
Gildas Bazin committed
852
    net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
Gildas Bazin's avatar
 
Gildas Bazin committed
853
                                   wxString::Format(wxT("%d"), i_net_ports[1]),
Gildas Bazin's avatar
 
Gildas Bazin committed
854 855
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
856
                                   0, 65535, i_net_ports[1] );
Gildas Bazin's avatar
 
Gildas Bazin committed
857 858 859 860 861 862

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

863 864 865 866 867 868
    /* HTTP and RTSP rows */
    for( i=2; i<4; i++ )
    {
        subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
        label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
        net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
Gildas Bazin's avatar
 
Gildas Bazin committed
869
                                       (i == 2) ? wxT("") : wxT("rtsp://"),
870 871 872 873 874 875 876
                                       wxDefaultPosition, wxSize( 200, -1 ),
                                       wxTE_PROCESS_ENTER);
        subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
        subpanel_sizer->Add( net_addrs[i], 1,
                             wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
        net_subpanels[i]->SetSizerAndFit( subpanel_sizer );
    }
Gildas Bazin's avatar
 
Gildas Bazin committed
877 878

    /* Stuff everything into the main panel */
879
    for( i=0; i<4; i++ )
Gildas Bazin's avatar
 
Gildas Bazin committed
880
    {
Gildas Bazin's avatar
 
Gildas Bazin committed
881 882 883 884
        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  );
Gildas Bazin's avatar
 
Gildas Bazin committed
885
    }
886 887
    sizer->Add( net_timeshift, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
                wxALL, 5 );
Gildas Bazin's avatar
 
Gildas Bazin committed
888 889 890 891 892 893 894

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

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

895
void OpenDialog::UpdateMRL()
Gildas Bazin's avatar
 
Gildas Bazin committed
896
{
897
    UpdateMRL( i_current_access_method );
Gildas Bazin's avatar
 
Gildas Bazin committed
898 899 900 901
}

void OpenDialog::UpdateMRL( int i_access_method )
{
902
    wxString mrltemp, caching_name;
Gildas Bazin's avatar
 
Gildas Bazin committed
903 904 905

    i_current_access_method = i_access_method;

Gildas Bazin's avatar
 
Gildas Bazin committed
906 907 908
    switch( i_access_method )
    {
    case FILE_ACCESS:
Gildas Bazin's avatar
 
Gildas Bazin committed
909
        mrltemp = file_combo->GetValue();
910
        caching_name = wxT("file-caching");
Gildas Bazin's avatar
 
Gildas Bazin committed
911
        break;
912

Gildas Bazin's avatar
 
Gildas Bazin committed
913
    case DISC_ACCESS:
914
        i_disc_type_selection = disc_type->GetSelection();
915

916
        switch ( i_disc_type_selection )
Sam Hocevar's avatar
Sam Hocevar committed
917
        {
918 919
        case 0: /* DVD with menus */
        case 1: /* DVD without menus */
920
            disc_device->SetToolTip( wxU(_("DVD device to use" ) )  );
921
            if( i_disc_type_selection == 0 )
922
            {
923
                mrltemp = wxT("dvd://") + disc_device->GetValue();
924
                caching_name = wxT("dvdnav-caching");
925
            }
926
            else
927
            {
928
                mrltemp = wxT("dvdsimple://") + disc_device->GetValue();
929
                caching_name = wxT("dvdread-caching");
930
            }
931 932 933 934 935 936 937 938 939 940

            if( i_disc_title > 0 )
            {
                mrltemp += wxString::Format( wxT("@%d"), i_disc_title );

                if( i_disc_chapter > 0 )
                    mrltemp += wxString::Format( wxT(":%d"), i_disc_chapter );
            }

            if( i_disc_sub >= 0 )