]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/open.cpp
* modules/gui/wxwindows/open.cpp: added a DVB tab and display module shortnames inste...
[vlc] / modules / gui / wxwindows / open.cpp
index 7da86db0e28ff54833a8a1181ceda426789a8bf5..10d6e9fd77395b6fc91e2eba570a7c1c04a0ff28 100644 (file)
@@ -1,10 +1,10 @@
 /*****************************************************************************
  * open.cpp : wxWindows plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000, 2001, 2003 VideoLAN
- * $Id: open.cpp,v 1.58 2003/12/16 13:35:12 gbazin Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
  *
- * Authors: Gildas Bazin <gbazin@netcourrier.com>
+ * Authors: Gildas Bazin <gbazin@videolan.org>
  *
  * 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
 
 #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>
 #include <wx/statline.h>
 #include <wx/tokenzr.h>
 
 #include <vlc/intf.h>
 
 #include "wxwindows.h"
-
 #include "preferences_widgets.h"
 
 #ifndef wxRB_SINGLE
@@ -82,21 +68,16 @@ enum
     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
     NetForceIPv6_Event,
 
-#ifndef WIN32
-    VideoType_Event,
-    VideoDevice_Event,
-    VideoChannel_Event,
-    V4LSettings_Event,
-#endif
-
     SubsFileEnable_Event,
     SubsFileSettings_Event,
 
     SoutEnable_Event,
     SoutSettings_Event,
+
+    AdvancedOptions_Event
 };
 
-BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
+BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
     /* Button events */
     EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
     EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
@@ -134,14 +115,6 @@ BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
     EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
     EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
 
-#ifndef WIN32
-    /* Events generated by the v4l panel */
-    EVT_RADIOBOX(VideoType_Event, OpenDialog::OnV4LTypeChange)
-    EVT_TEXT(VideoDevice_Event, OpenDialog::OnV4LPanelChange)
-    EVT_SPINCTRL(VideoChannel_Event, OpenDialog::OnV4LPanelChange)
-    EVT_BUTTON(V4LSettings_Event, OpenDialog::OnV4LSettingsChange)
-#endif
-
     /* Events generated by the subtitle file buttons */
     EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
     EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
@@ -170,30 +143,54 @@ public:
 
     virtual ~AutoBuiltPanel() {}
 
+    void UpdateAdvancedMRL();
+
     wxString name;
     ArrayOfConfigControls config_array;
+    ArrayOfConfigControls advanced_config_array;
+    wxComboBox *p_advanced_mrl_combo;
 
 private:
     intf_thread_t *p_intf;
+    OpenDialog *p_open_dialog;
+
+    void OnAdvanced( wxCommandEvent& event );
+    wxDialog *p_advanced_dialog;
+
+    DECLARE_EVENT_TABLE();
 };
 
-void AutoBuildCallback( void *p_data )
+BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
+    EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
+END_EVENT_TABLE()
+
+static void AutoBuildCallback( void *p_data )
 {
     ((OpenDialog *)p_data)->UpdateMRL();
 }
 
+static void AutoBuildAdvancedCallback( void *p_data )
+{
+    ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
+}
+
 AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
                                 intf_thread_t *_p_intf,
                                 const module_t *p_module )
-  : wxPanel( parent, -1, wxDefaultPosition, wxSize(200, 200) ),
-    name( wxU(p_module->psz_object_name) ), p_intf( _p_intf )
+  : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
+    name( wxU(p_module->psz_object_name) ),
+    p_advanced_mrl_combo( NULL ),
+    p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
 {
     wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
-
     module_config_t *p_item = p_module->p_config;
+    bool b_advanced = false;
 
     if( p_item ) do
     {
+        if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
+            b_advanced = true;
+
         if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
             continue;
 
@@ -211,15 +208,143 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
     }
     while( p_item->i_type != CONFIG_HINT_END && p_item++ );
 
+    if( b_advanced )
+    {
+        wxPanel *dummy_panel = new wxPanel( this, -1 );
+        sizer->Add( dummy_panel, 1 );
+
+        wxButton *button =
+            new wxButton( this, AdvancedOptions_Event,
+                          wxU(_("Advanced options...")) );
+        sizer->Add( button, 0, wxALL, 5 );
+
+        /* Build the advanced dialog */
+        p_advanced_dialog =
+            new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
+                          wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
+                          wxDefaultPosition, wxDefaultSize,
+                          wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
+
+        wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
+
+        /* Create MRL combobox */
+        wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
+        wxStaticBox *mrl_box =
+            new wxStaticBox( p_advanced_dialog, -1,
+                             wxU(_("Advanced options")) );
+        wxStaticBoxSizer *mrl_sizer =
+            new wxStaticBoxSizer( mrl_box, wxHORIZONTAL );
+        wxStaticText *mrl_label =
+            new wxStaticText( p_advanced_dialog, -1, wxU(_("Options:")) );
+        p_advanced_mrl_combo =
+            new wxComboBox( p_advanced_dialog, MRL_Event, wxT(""),
+                            wxDefaultPosition, wxDefaultSize );
+        mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
+        mrl_sizer->Add( p_advanced_mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
+        mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
+        sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 );
+
+        /* Add advanced options to panel */
+        module_config_t *p_item = p_module->p_config;
+        if( p_item ) do
+        {
+            if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced )
+                continue;
+
+            ConfigControl *control =
+                CreateConfigControl( VLC_OBJECT(p_intf), p_item,
+                                     p_advanced_dialog );
+
+            advanced_config_array.Add( control );
+
+            /* Don't add items that were not recognized */
+            if( control == NULL ) continue;
+
+            control->SetUpdateCallback( AutoBuildAdvancedCallback,
+                                        (void *)this );
+
+            sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
+        }
+        while( p_item->i_type != CONFIG_HINT_END && p_item++ );
+
+        /* Separation */
+        dummy_panel = new wxPanel( p_advanced_dialog, -1 );
+        sizer->Add( dummy_panel, 1 );
+        wxStaticLine *static_line =
+            new wxStaticLine( p_advanced_dialog, wxID_OK );
+        sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
+
+        /* Create buttons */
+        wxButton *ok_button =
+            new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
+        ok_button->SetDefault();
+        wxButton *cancel_button =
+            new wxButton( p_advanced_dialog, wxID_CANCEL, wxU(_("Cancel")) );
+        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();
+        sizer->Add( button_sizer, 0, wxALL, 0 );
+
+        sizer->SetMinSize( 400, -1 );
+        p_advanced_dialog->SetSizerAndFit( sizer );
+    }
+
     this->SetSizerAndFit( sizer );
 }
 
+void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
+{
+    if( p_advanced_dialog->ShowModal() == wxID_OK )
+    {
+        UpdateAdvancedMRL();
+        p_open_dialog->UpdateMRL();
+    }
+}
+
+void AutoBuiltPanel::UpdateAdvancedMRL()
+{
+    wxString mrltemp;
+
+    for( int i = 0; i < (int)advanced_config_array.GetCount(); i++ )
+    {
+        ConfigControl *control = advanced_config_array.Item(i);
+
+        mrltemp += (i ? wxT(" :") : wxT(":"));
+
+        if( control->GetType() == CONFIG_ITEM_BOOL &&
+            !control->GetIntValue() ) mrltemp += wxT("no-");
+
+        mrltemp += control->GetName();
+
+        switch( control->GetType() )
+        {
+        case CONFIG_ITEM_STRING:
+        case CONFIG_ITEM_FILE:
+        case CONFIG_ITEM_DIRECTORY:
+        case CONFIG_ITEM_MODULE:
+            mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
+            break;
+        case CONFIG_ITEM_INTEGER:
+            mrltemp +=
+                wxString::Format( wxT("=%i"), control->GetIntValue() );
+            break;
+        case CONFIG_ITEM_FLOAT:
+            mrltemp +=
+                wxString::Format(wxT("=%f"), control->GetFloatValue());
+            break;
+        }
+    }
+
+    p_advanced_mrl_combo->SetValue( mrltemp );
+}
+
 /*****************************************************************************
  * Constructor.
  *****************************************************************************/
 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
                         int i_access_method, int i_arg ):
-    wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
+      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 {
     OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
@@ -227,7 +352,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
 
 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
                         int i_access_method, int i_arg, int _i_method ):
-    wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
+      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 {
     /* Initializations */
@@ -237,10 +362,8 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
     SetIcon( *p_intf->p_sys->p_icon );
     file_dialog = NULL;
     i_disc_type_selection = 0;
-    
-#ifndef WIN32
-    v4l_dialog = NULL;
-#endif
+    i_open_arg = i_arg;
+
     sout_dialog = NULL;
     subsfile_dialog = NULL;
     b_disc_device_changed = false;
@@ -256,7 +379,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
                                                         wxHORIZONTAL );
     wxStaticText *mrl_label = new wxStaticText( panel, -1,
-                                                wxU(_("Open Target:")) );
+                                                wxU(_("Open:")) );
     mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
                                 wxPoint(20,25), wxSize(120, -1),
                                 0, NULL );
@@ -285,7 +408,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
 
         sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
                                          wxU(_("Stream output")) );
-        sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
+        sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
         sout_sizer->Add( sout_checkbox, 0,
                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
         sout_button = new wxButton( panel, SoutSettings_Event,
@@ -297,7 +420,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
         {
             sout_checkbox->SetValue(TRUE);
             sout_button->Enable();
-            subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) );
+            subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
         }
         if( psz_sout ) free( psz_sout );
 
@@ -324,18 +447,45 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
                        i_access_method == DISC_ACCESS );
     notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
                        i_access_method == NET_ACCESS );
-#ifndef WIN32
-    notebook->AddPage( V4LPanel( notebook ), wxU(_("Video For Linux")),
-                       i_access_method == V4L_ACCESS );
-#endif
 
-    module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
+    module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" );
+    if( p_module )
+    {
+        AutoBuiltPanel *autopanel =
+            new AutoBuiltPanel( notebook, this, p_intf, p_module );
+        input_tab_array.Add( autopanel );
+        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
+                           i_access_method == CAPTURE_ACCESS );
+    }
+
+    p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" );
+    if( p_module )
+    {
+        AutoBuiltPanel *autopanel =
+            new AutoBuiltPanel( notebook, this, p_intf, p_module );
+        input_tab_array.Add( autopanel );
+        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
+                           i_access_method == CAPTURE_ACCESS );
+    }
+
+    p_module = config_FindModule( VLC_OBJECT(p_intf), "dvb" );
+    if( p_module )
+    {
+        AutoBuiltPanel *autopanel =
+            new AutoBuiltPanel( notebook, this, p_intf, p_module );
+        input_tab_array.Add( autopanel );
+        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
+                           i_access_method == CAPTURE_ACCESS );
+    }
+
+    p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
     if( p_module )
     {
         AutoBuiltPanel *autopanel =
             new AutoBuiltPanel( notebook, this, p_intf, p_module );
         input_tab_array.Add( autopanel );
-        notebook->AddPage( autopanel, wxU( p_module->psz_longname ) );
+        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
+                           i_access_method == CAPTURE_ACCESS );
     }
 
     /* Update Disc panel */
@@ -346,12 +496,6 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
     dummy_event.SetId( NetRadio1_Event );
     OnNetTypeChange( dummy_event );
 
-#ifndef WIN32
-    /* Update v4l panel */
-    dummy_event.SetId( VideoType_Event );
-    OnV4LTypeChange( dummy_event );
-#endif
-
     /* Update MRL */
     wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
     OnPageChange( event );
@@ -383,27 +527,23 @@ OpenDialog::~OpenDialog()
 {
     /* Clean up */
     if( file_dialog ) delete file_dialog;
-#ifndef WIN32
-    if( v4l_dialog ) delete v4l_dialog;
-#endif
     if( sout_dialog ) delete sout_dialog;
     if( subsfile_dialog ) delete subsfile_dialog;
 }
 
 int OpenDialog::Show( int i_access_method, int i_arg )
 {
-    int i_ret;
     notebook->SetSelection( i_access_method );
-    i_ret = wxFrame::Show();
+    int i_ret = wxDialog::Show();
     Raise();
     SetFocus();
+    i_open_arg = i_arg;
     return i_ret;
 }
 
 int OpenDialog::Show()
 {
-    int i_ret;
-    i_ret = wxFrame::Show();
+    int i_ret = wxDialog::Show();
     Raise();
     SetFocus();
     return i_ret;
@@ -432,9 +572,8 @@ wxPanel *OpenDialog::FilePanel( wxWindow* parent )
     /* 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.")) );
+                                        wxU(_("Subtitle options")) );
+    subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
     subsfile_sizer->Add( subsfile_checkbox, 0,
                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
     subsfile_button = new wxButton( panel, SubsFileSettings_Event,
@@ -446,7 +585,7 @@ wxPanel *OpenDialog::FilePanel( wxWindow* parent )
     {
         subsfile_checkbox->SetValue(TRUE);
         subsfile_button->Enable();
-        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxU(psz_subsfile) );
+        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
     }
     if( psz_subsfile ) free( psz_subsfile );
 
@@ -472,15 +611,15 @@ wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
         wxU(_("DVD (menus support)")),
         wxU(_("DVD")),
         wxU(_("VCD")),
-        wxU(_("CD Audio"))
-
+        wxU(_("Audio CD")),
+        wxU(_("DVD (experimental)"))
     };
 
     disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
                                 wxDefaultPosition, wxDefaultSize,
                                 WXSIZEOF(disc_type_array), disc_type_array,
                                 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
-    
+
     sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
 
     wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
@@ -499,8 +638,8 @@ wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
 
     disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
     disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
-    sizer->Add( disc_chapter_label, 0, 
-               wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    sizer->Add( disc_chapter_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 );
 
@@ -587,7 +726,7 @@ wxPanel *OpenDialog::NetPanel( wxWindow* parent )
         subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
         label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
         net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
-                                       wxT((i == 2) ? "" : "rtsp://"),
+                                       (i == 2) ? wxT("") : wxT("rtsp://"),
                                        wxDefaultPosition, wxSize( 200, -1 ),
                                        wxTE_PROCESS_ENTER);
         subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
@@ -611,65 +750,6 @@ wxPanel *OpenDialog::NetPanel( wxWindow* parent )
     return panel;
 }
 
-#ifndef WIN32
-wxPanel *OpenDialog::V4LPanel( wxWindow* parent )
-{
-    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
-                                  wxSize(200, 200) );
-
-    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
-    wxFlexGridSizer *sizer = new wxFlexGridSizer( 1, 4, 20 );
-
-    static const wxString video_type_array[] =
-    {
-        wxU(_("WebCam")),
-        wxU(_("TV Card")),
-        wxU(_("PVR")),
-        wxU(_("Kfir")),
-    };
-
-    video_type = new wxRadioBox( panel, VideoType_Event,
-            wxU(_("Video Device Type")),
-            wxDefaultPosition, wxDefaultSize,
-            WXSIZEOF(video_type_array), video_type_array,
-            WXSIZEOF(video_type_array), wxRA_SPECIFY_COLS );
-
-    sizer_row->Add( video_type, 0, wxEXPAND | wxALL, 5 );
-
-
-    /* Video Options */
-    wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 2, 20 );
-    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Video Device")) );
-    video_device = new wxTextCtrl( panel, VideoDevice_Event, wxT(""),
-                                  wxDefaultPosition, wxDefaultSize,
-                                  wxTE_PROCESS_ENTER);
-    video_device->SetToolTip( wxU(_("Device corresponding to your acquisition "
-                                    "card or your webcam")) );
-    video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
-    video_sizer->Add( video_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
-
-    label = new wxStaticText( panel, -1, wxU(_("Channel")) );
-    video_channel = new wxSpinCtrl( panel, VideoChannel_Event, wxT("0") );
-    video_channel->SetToolTip( wxU(_("Usually 0 is for tuner, 1 for composite "
-                                     "and 2 for svideo")) );
-    video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
-    video_sizer->Add( video_channel, 1, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
-    sizer->Add( video_sizer, 0, wxEXPAND | wxALL, 5 );
-
-    wxBoxSizer *v4lbutton_sizer = new wxBoxSizer( wxHORIZONTAL );
-    v4l_button = new wxButton( panel, V4LSettings_Event,
-                            wxU(_("Advanced Settings...")) );
-
-    v4lbutton_sizer->Add( v4l_button, 0, wxALIGN_RIGHT, 5 );
-
-    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
-    sizer_row->Add( v4lbutton_sizer, 0, wxEXPAND | wxALL, 5 );
-
-    panel->SetSizerAndFit( sizer_row );
-    return panel;
-}
-#endif
-
 void OpenDialog::UpdateMRL()
 {
     UpdateMRL( i_current_access_method );
@@ -691,71 +771,93 @@ void OpenDialog::UpdateMRL( int i_access_method )
       i_disc_type_selection = disc_type->GetSelection();
 
       switch ( i_disc_type_selection )
-       {
-       case 0:
-         disc_chapter->Enable();
-         disc_chapter_label->Enable();
+        {
+        case 0: /* DVD with menues */
+          disc_chapter->Enable();
+          disc_chapter_label->Enable();
           mrltemp = wxT("dvd://")
                   + disc_device->GetValue()
                   + wxString::Format( wxT("@%d:%d"),
                                       disc_title->GetValue(),
                                       disc_chapter->GetValue() );
-         break;
-       case 1:
-         disc_chapter->Enable();
-         disc_chapter_label->Enable();
-         mrltemp = wxT("dvdsimple://")
+          break;
+
+        case 1: /* DVD of some sort */
+          disc_chapter->Enable();
+          disc_chapter_label->Enable();
+          mrltemp = wxT("dvdsimple://")
                   + disc_device->GetValue()
                   + wxString::Format( wxT("@%d:%d"),
                                       disc_title->GetValue(),
                                       disc_chapter->GetValue() );
-         break;
-       case 2:
-         disc_chapter->Disable();
-         disc_chapter_label->Disable();
+          break;
+
+        case 2:  /* VCD of some sort */
+          {
+            /* The chapter object is used for subtitles */
+
+            int i_subtitle = disc_chapter->GetValue();
+            config_PutInt( p_intf, "spu-channel", i_subtitle );
+            
+            disc_chapter->Enable();
+            disc_chapter_label->Enable();
 #ifdef HAVE_VCDX
-         if ( disc_title->GetValue() )
-           mrltemp = wxT("vcdx://")
-             + disc_device->GetValue()
-             + wxString::Format( wxT("@%c%d"),
-                                 config_GetInt( p_intf, "vcdx-PBC"  )
-                                 ? 'P' : 'E',
-                                 disc_title->GetValue()
-                                 );
-         else
-           mrltemp = wxT("vcdx://")
-                  + disc_device->GetValue();
+          if ( disc_title->GetValue() )
+            mrltemp = wxT("vcdx://")
+              + disc_device->GetValue()
+              + wxString::Format( wxT("@%c%d"),
+                                  config_GetInt( p_intf, "vcdx-PBC"  )
+                                  ? 'P' : 'E',
+                                  disc_title->GetValue()
+                                  );
+          else
+            mrltemp = wxT("vcdx://")
+              + disc_device->GetValue();
 #else
-         mrltemp = wxT("vcd://")
-                  + disc_device->GetValue()
-                  + wxString::Format( wxT("@%d"),
-                                      disc_title->GetValue() );
+          mrltemp = wxT("vcd://")
+            + disc_device->GetValue()
+            + wxString::Format( wxT("@%d"),
+                                disc_title->GetValue() );
 #endif
-         break;
-       case 3:
-         disc_chapter->Disable();
-         disc_chapter_label->Disable();
+          break;
+          }
+          
+
+        case 3: /* CD-DA */
+          disc_chapter->Disable();
+          disc_chapter_label->Disable();
 #ifdef HAVE_CDDAX
-         if ( disc_title->GetValue() )
-           mrltemp =  wxT("cddax://")
-                 + disc_device->GetValue()
+          if ( disc_title->GetValue() )
+            mrltemp =  wxT("cddax://")
+                  + disc_device->GetValue()
                   + wxString::Format( wxT("@T%d"),
                                       disc_title->GetValue() );
-         else
-           mrltemp = wxT("cddax://")
-                 + disc_device->GetValue();
+          else
+            mrltemp = wxT("cddax://")
+                  + disc_device->GetValue();
 
 #else
-         mrltemp =  wxT("cdda://")
+          mrltemp =  wxT("cdda://")
                   + disc_device->GetValue()
                   + wxString::Format( wxT("@%d"),
                                       disc_title->GetValue() );
 #endif
-         break;
-       default: ;
-         msg_Err( p_intf, "invalid selection (%d)",
-                  disc_type->GetSelection() );
-       }
+          break;
+
+        case 4: /* DVD of some sort */
+          disc_chapter->Enable();
+          disc_chapter_label->Enable();
+          mrltemp = wxT("dvdnav://")
+                  + disc_device->GetValue()
+                  + wxString::Format( wxT("@%d:%d"),
+                                      disc_title->GetValue(),
+                                      disc_chapter->GetValue() );
+          break;
+
+        default: ;
+          msg_Err( p_intf, "invalid selection (%d)",
+                   disc_type->GetSelection() );
+        }
 
         break;
     case NET_ACCESS:
@@ -813,29 +915,6 @@ void OpenDialog::UpdateMRL( int i_access_method )
         }
         break;
 
-#ifndef WIN32
-    case V4L_ACCESS:
-        mrltemp = ( video_type->GetSelection() == 0 ? wxT("v4l") :
-                    video_type->GetSelection() == 1 ? wxT("v4l") :
-                    video_type->GetSelection() == 2 ? wxT("pvr") :
-                                                      wxT("kfir") )
-            + demux + wxT(":")
-            + video_device->GetLineText( 0 );
-
-        if( video_type->GetSelection() == 1 )
-        {
-            mrltemp += wxString::Format( wxT(":channel=%d"),
-                                         video_channel->GetValue() );
-        }
-
-        if ( /* v4l_dialog != NULL && */ !v4l_mrl.IsEmpty() )
-        {
-            mrltemp += v4l_mrl[0];
-        }
-
-        break;
-#endif
-
     default:
         {
             int i_item = i_access_method - MAX_ACCESS;
@@ -850,7 +929,13 @@ void OpenDialog::UpdateMRL( int i_access_method )
             for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
             {
                 ConfigControl *control = input_panel->config_array.Item(i);
-                mrltemp += wxT(" :") + control->GetName() + wxT("=");
+
+                mrltemp += wxT(" :");
+
+                if( control->GetType() == CONFIG_ITEM_BOOL &&
+                    !control->GetIntValue() ) mrltemp += wxT("no-");
+
+                mrltemp += control->GetName();
 
                 switch( control->GetType() )
                 {
@@ -858,19 +943,25 @@ void OpenDialog::UpdateMRL( int i_access_method )
                 case CONFIG_ITEM_FILE:
                 case CONFIG_ITEM_DIRECTORY:
                 case CONFIG_ITEM_MODULE:
-                    mrltemp += wxT("\"") + control->GetPszValue() + wxT("\"");
+                    mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
                     break;
                 case CONFIG_ITEM_INTEGER:
-                case CONFIG_ITEM_BOOL:
                     mrltemp +=
-                        wxString::Format( wxT("%i"), control->GetIntValue() );
+                        wxString::Format( wxT("=%i"), control->GetIntValue() );
                     break;
                 case CONFIG_ITEM_FLOAT:
                     mrltemp +=
-                        wxString::Format( wxT("%f"), control->GetFloatValue());
+                        wxString::Format(wxT("=%f"), control->GetFloatValue());
                     break;
                 }
             }
+
+            if( input_panel->p_advanced_mrl_combo &&
+                input_panel->p_advanced_mrl_combo->GetValue() )
+            {
+                mrltemp += wxT(" ") +
+                    input_panel->p_advanced_mrl_combo->GetValue();
+            }
         }
         break;
     }
@@ -891,6 +982,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
     if( i_method == OPEN_STREAM )
     {
         Hide();
+        if( IsModal() ) EndModal( wxID_OK );
         return;
     }
 
@@ -902,80 +994,59 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
 
     for( int i = 0; i < (int)mrl.GetCount(); i++ )
     {
-        int i_options = 0, i_total_options;
-        char **ppsz_options = NULL;
-
-        /* Count the input options */
-        while( i + i_options + 1 < (int)mrl.GetCount() &&
-               ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
-        {
-            i_options++;
-        }
-
-        /* Allocate ppsz_options */
-        for( int j = 0; j < i_options; j++ )
+        vlc_bool_t b_start = !i && i_open_arg;
+        playlist_item_t *p_item =
+            playlist_ItemNew( p_intf, (const char*)mrl[i].mb_str(),
+                              (const char *)mrl[i].mb_str() );
+
+        /* Insert options */
+        while( i + 1 < (int)mrl.GetCount() &&
+               ((const char *)mrl[i + 1].mb_str())[0] == ':' )
         {
-            if( !ppsz_options )
-                ppsz_options = (char **)malloc( sizeof(char *) * i_options );
-
-            ppsz_options[j] = strdup( mrl[i + j  + 1].mb_str() );
+            playlist_ItemAddOption( p_item, mrl[i + 1].mb_str() );
+            i++;
         }
 
-        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() );
+                playlist_ItemAddOption( p_item, 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() );
+                playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() );
             }
-
-            i_total_options += sout_mrl.GetCount();
-
         }
 
-        playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
-                      (const char **)ppsz_options, i_total_options,
-                      PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
-
-        /* clean up */
-        for( int j = 0; j < i_total_options; j++ )
-            free( ppsz_options[j] );
-        if( ppsz_options ) free( ppsz_options );
+        int i_id = playlist_AddItem( p_playlist, p_item,
+                                     PLAYLIST_APPEND, PLAYLIST_END );
 
-        i += i_options;
+        if( b_start )
+        {
+            int i_pos = playlist_GetPositionById( p_playlist , i_id );
+            playlist_Command( p_playlist, PLAYLIST_GOTO, i_pos );
+        }
     }
 
-    //TogglePlayButton( PLAYING_S );
-
     vlc_object_release( p_playlist );
 
     Hide();
+
+    if( IsModal() ) EndModal( wxID_OK );
 }
 
 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
 {
     Hide();
+
+    if( IsModal() ) EndModal( wxID_CANCEL );
 }
 
 void OpenDialog::OnPageChange( wxNotebookEvent& event )
@@ -999,7 +1070,7 @@ void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
 {
     if( file_dialog == NULL )
-        file_dialog = new wxFileDialog( this, wxU(_("Open file")),
+        file_dialog = new wxFileDialog( this, wxU(_("Open File")),
             wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
 
     if( file_dialog && file_dialog->ShowModal() == wxID_OK )
@@ -1050,10 +1121,10 @@ void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
             psz_device = config_GetPsz( p_intf, "dvd" );
             break;
     }
-    
+
     if ( !psz_device ) psz_device = "";
 
-    if( disc_device->GetValue().Cmp( wxU( psz_device ) ) )
+    if( disc_device->GetValue().Cmp( wxL2U( psz_device ) ) )
     {
         b_disc_device_changed = true;
     }
@@ -1069,74 +1140,90 @@ void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
     switch( disc_type->GetSelection() )
     {
 
-    case 0: /* DVD with menues */
-      i_selection=0;
-      /* Fall through... */
+    case 0: /* DVD with menus */
+    case 4: /* DVD with menus (dvdnav) */
+        i_selection=0;
+        /* Fall through... */
 
     case 1: /* DVD of some sort */
-      {
         psz_device = config_GetPsz( p_intf, "dvd" );
         if( !b_disc_device_changed )
         {
-            disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
-           disc_title_label->SetLabel ( wxT("Title") );
-       }
-       disc_title->SetRange( i_selection, 255 );
-       disc_title->SetValue( i_selection );
-       break;
-      }
-       
+            if( psz_device )
+                disc_device->SetValue( wxL2U(psz_device) );
+            else
+                disc_device->SetValue( wxT("") );
+
+            disc_title_label->SetLabel ( wxU(_("Title")) );
+        }
+        disc_title->SetRange( i_selection, 255 );
+        disc_title->SetValue( i_selection );
+
+        disc_chapter->SetRange( 1, 255 );
+        disc_chapter->SetValue( 1 );
+        disc_chapter_label->SetLabel ( wxU(_("Chapter")) );
+
+        break;
+
     case 2:  /* VCD of some sort */
         psz_device = config_GetPsz( p_intf, "vcd" );
         if( !b_disc_device_changed )
         {
-            disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
+            if( psz_device )
+                disc_device->SetValue( wxL2U(psz_device) );
+            else
+                disc_device->SetValue( wxT("") );
         }
 
-       /* There are at most 98, tracks in a VCD, 999 Segments, 500 entries
-          I don't know what the limit is for LIDs, 999 is probably safe
-          though. 
+        /* There are at most 98, tracks in a VCD, 999 Segments, 500 entries
+           I don't know what the limit is for LIDs, 999 is probably safe
+           though.
 
-          FIXME: it would be better however to get the information for
-          this particular Media possibly from the General Info area.
-       */
+           FIXME: it would be better however to get the information for
+           this particular Media possibly from the General Info area.
+         */
 #ifdef HAVE_VCDX
-       disc_title_label->SetLabel ( config_GetInt( p_intf, "vcdx-PBC"  )
-                                    ? wxT("PBC LID") : wxT("Entry") );
-        disc_title->SetRange( 0, 999 ); 
+        disc_title_label->SetLabel ( config_GetInt( p_intf, "vcdx-PBC"  )
+                                     ? wxT("Playback LID") : wxT("Entry") );
+        disc_title->SetRange( 0, 999 );
         i_selection = 0;
 #else
-       disc_title_label->SetLabel ( wxT("Track") );
-        disc_title->SetRange( 1, 98 ); 
+        disc_title_label->SetLabel ( wxU(_("Track")) );
+        disc_title->SetRange( 1, 98 );
 #endif
         disc_title->SetValue( i_selection );
+
+        /* We use the chapter to set subtitle number */
+        disc_chapter_label->SetLabel ( wxU(_("Subtitle")) );
+        disc_chapter->SetRange( -1, 4 );
+        disc_chapter->SetValue( config_GetInt( p_intf, "spu-channel" ) );
         break;
 
     case 3: /* CD-DA */
         psz_device = config_GetPsz( p_intf, "cd-audio" );
         if( !b_disc_device_changed )
         {
-            disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
+            if( psz_device )
+                disc_device->SetValue( wxL2U(psz_device) );
+            else
+                disc_device->SetValue( wxT("") );
         }
-       disc_title_label->SetLabel ( wxT("Track") );
+        disc_title_label->SetLabel ( wxU(_("Track")) );
 #ifdef HAVE_CDDAX
         i_selection = 0;
 #endif
        /* There are at most 99 tracks in a CD-DA */
-        disc_title->SetRange( i_selection, 99 ); 
+        disc_title->SetRange( i_selection, 99 );
         disc_title->SetValue( i_selection );
         break;
-    default: 
-        msg_Err( p_intf, "invalid Disc type selection (%d)", 
-              disc_type->GetSelection() );
+    default:
+        msg_Err( p_intf, "invalid Disc type selection (%d)",
+                 disc_type->GetSelection() );
         break;
     }
 
     if( psz_device ) free( psz_device );
 
-    disc_chapter->SetRange( 1, 255 );
-    disc_chapter->SetValue( 1 );
-
     UpdateMRL( DISC_ACCESS );
 }
 
@@ -1168,53 +1255,6 @@ void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
     UpdateMRL( NET_ACCESS );
 }
 
-#ifndef WIN32
-/*****************************************************************************
- * v4l panel event methods.
- *****************************************************************************/
-void OpenDialog::OnV4LPanelChange( wxCommandEvent& WXUNUSED(event) )
-{
-    UpdateMRL( V4L_ACCESS );
-}
-
-void OpenDialog::OnV4LTypeChange( wxCommandEvent& WXUNUSED(event) )
-{
-    video_device->SetValue( wxU( "/dev/video" ) );
-
-    v4l_button->Enable();
-    video_channel->Disable();
-
-    switch( video_type->GetSelection() )
-    {
-        case 1:
-            video_channel->Enable();
-            video_channel->SetRange( 0, 255 );
-           break;
-        case 3:
-            v4l_button->Disable();
-            break;
-        default:
-            break;
-    }
-
-    UpdateMRL( V4L_ACCESS );
-}
-
-void OpenDialog::OnV4LSettingsChange( wxCommandEvent& WXUNUSED(event) )
-{
-    /* Show/hide the open dialog */
-    if( v4l_dialog == NULL )
-        v4l_dialog = new V4LDialog( p_intf, this );
-
-    if( v4l_dialog && v4l_dialog->ShowModal() == wxID_OK )
-    {
-        v4l_mrl = v4l_dialog->GetOptions();
-    }
-
-    UpdateMRL( V4L_ACCESS );
-}
-#endif
-
 /*****************************************************************************
  * Subtitles file event methods.
  *****************************************************************************/
@@ -1292,8 +1332,6 @@ wxArrayString SeparateEntries( wxString entries )
         {
             /* 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('\"') )