* modules/gui/wxwindows/*, modules/gui/skins/src/vlcproc.cpp: The open dialog box...
authorGildas Bazin <gbazin@videolan.org>
Tue, 20 May 2003 23:17:59 +0000 (23:17 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 20 May 2003 23:17:59 +0000 (23:17 +0000)
modules/gui/skins/src/vlcproc.cpp
modules/gui/wxwindows/interface.cpp
modules/gui/wxwindows/open.cpp
modules/gui/wxwindows/playlist.cpp
modules/gui/wxwindows/streamout.cpp
modules/gui/wxwindows/subtitles.cpp
modules/gui/wxwindows/wxwindows.h

index f009a0d..3a015c3 100644 (file)
@@ -2,7 +2,7 @@
  * vlcproc.cpp: VlcProc class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: vlcproc.cpp,v 1.22 2003/05/12 17:33:19 gbazin Exp $
+ * $Id: vlcproc.cpp,v 1.23 2003/05/20 23:17:59 gbazin Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
@@ -342,10 +342,10 @@ void VlcProc::LoadSkin()
         if( dialog.ShowModal() == wxID_OK )
         {
             p_intf->p_sys->p_new_theme_file =
-                new char[dialog.GetPath().Length()];
+                new char[strlen(dialog.GetPath().mb_str()) + 1];
 
             strcpy( p_intf->p_sys->p_new_theme_file,
-                    dialog.GetPath().c_str() );
+                    dialog.GetPath().mb_str() );
 
             // Tell vlc to change skin after hiding interface
             OSAPI_PostMessage( NULL, VLC_HIDE, VLC_LOAD_SKIN, 0 );
@@ -408,18 +408,24 @@ void VlcProc::OpenFile( bool play )
     if( play )
     {
         // Append and play
-        playlist_Add( p_playlist,
-                      (char *)p_intf->p_sys->OpenDlg->mrl.c_str(),
-                      PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+        for( size_t i = 0; i < p_open_dialog->mrl.GetCount(); i++ )
+        {
+            playlist_Add( p_playlist,
+                (const char *)p_intf->p_sys->OpenDlg->mrl[i].mb_str(),
+                PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
+        }
 
         p_intf->p_sys->p_theme->EvtBank->Get( "play" )->SendEvent();
     }
     else
     {
         // Append only
-        playlist_Add( p_playlist,
-                        (char *)p_intf->p_sys->OpenDlg->mrl.c_str(),
-                        PLAYLIST_APPEND, PLAYLIST_END );
+        for( size_t i = 0; i < p_open_dialog->mrl.GetCount(); i++ )
+        {
+            playlist_Add( p_playlist,
+                (const char *)p_intf->p_sys->OpenDlg->mrl[i].mb_str(),
+                PLAYLIST_APPEND, PLAYLIST_END );
+        }
     }
 
     // Refresh interface !
index adcc28c..6b21a5d 100644 (file)
@@ -2,7 +2,7 @@
  * interface.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: interface.cpp,v 1.30 2003/05/18 19:46:35 gbazin Exp $
+ * $Id: interface.cpp,v 1.31 2003/05/20 23:17:59 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -423,8 +423,12 @@ void Interface::Open( int i_access_method )
             return;
         }
 
-        playlist_Add( p_playlist, (const char *)p_open_dialog->mrl.mb_str(),
-                      PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+        for( size_t i = 0; i < p_open_dialog->mrl.GetCount(); i++ )
+        {
+            playlist_Add( p_playlist,
+                (const char *)p_open_dialog->mrl[i].mb_str(),
+                PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
+        }
 
         TogglePlayButton( PLAYING_S );
 
@@ -829,8 +833,6 @@ DragAndDrop::DragAndDrop( intf_thread_t *_p_intf )
 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
                                const wxArrayString& filenames )
 {
-    unsigned int i;
-
     /* Add dropped files to the playlist */
 
     playlist_t *p_playlist =
@@ -841,9 +843,9 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
         return FALSE;
     }
 
-    for( i = 0; i < filenames.GetCount(); i++ )
+    for( size_t i = 0; i < filenames.GetCount(); i++ )
         playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),
-                      PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+                      PLAYLIST_APPEND | i ? 0 : PLAYLIST_GO, PLAYLIST_END );
 
     vlc_object_release( p_playlist );
 
index 3364440..a2248d7 100644 (file)
@@ -2,7 +2,7 @@
  * open.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: open.cpp,v 1.24 2003/05/18 12:18:46 gbazin Exp $
+ * $Id: open.cpp,v 1.25 2003/05/20 23:17:59 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -46,6 +46,7 @@
 #include <wx/combobox.h>
 #include <wx/spinctrl.h>
 #include <wx/statline.h>
+#include <wx/tokenzr.h>
 
 #include <vlc/intf.h>
 
@@ -171,7 +172,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
                                                         wxHORIZONTAL );
     wxStaticText *mrl_label = new wxStaticText( panel, -1,
                                                 wxU(_("Open Target:")) );
-    mrl_combo = new wxComboBox( panel, MRL_Event, mrl,
+    mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
                                 wxPoint(20,25), wxSize(120, -1),
                                 0, NULL );
     mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
@@ -496,7 +497,7 @@ wxPanel *OpenDialog::SatPanel( wxWindow* parent )
 
 void OpenDialog::UpdateMRL( int i_access_method )
 {
-    wxString demux;
+    wxString demux, mrltemp;
 
     i_current_access_method = i_access_method;
 
@@ -509,13 +510,14 @@ void OpenDialog::UpdateMRL( int i_access_method )
     switch( i_access_method )
     {
     case FILE_ACCESS:
-        mrl = wxT("file") + demux + wxT("://") + file_combo->GetValue();
+        //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
+        mrltemp = file_combo->GetValue();
         break;
     case DISC_ACCESS:
-        mrl = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
+        mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
                 disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
                 disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
-                  + demux + wxT("://")
+                  + demux + wxT(":")
                   + disc_device->GetLineText(0)
                   + wxString::Format( wxT("@%d:%d"),
                                       disc_title->GetValue(),
@@ -528,42 +530,87 @@ void OpenDialog::UpdateMRL( int i_access_method )
             if( net_ports[0]->GetValue() !=
                 config_GetInt( p_intf, "server-port" ) )
             {
-                mrl = wxT("udp") + demux +
-                       wxString::Format( wxT("://@:%d"),
-                                         net_ports[0]->GetValue() );
+                mrltemp = wxT("udp") + demux +
+                          wxString::Format( wxT("://@:%d"),
+                                            net_ports[0]->GetValue() );
             }
             else
             {
-                mrl = wxT("udp") + demux + wxT("://");
+                mrltemp = wxT("udp") + demux + wxT("://");
             }
             break;
 
         case 1:
-            mrl = wxT("udp") + demux + wxT("://@") +
-                  net_addrs[1]->GetLineText(0);
+            mrltemp = wxT("udp") + demux + wxT("://@") +
+                      net_addrs[1]->GetLineText(0);
             if( net_ports[1]->GetValue() !=
                 config_GetInt( p_intf, "server-port" ) )
             {
-                mrl = mrl + wxString::Format( wxT(":%d"),
+                mrltemp = mrltemp + wxString::Format( wxT(":%d"),
                                               net_ports[1]->GetValue() );
             }
             break;
 
         case 2:
             /* http access */     
-            mrl = wxT("http") + demux + wxT("://") +
-                  net_addrs[2]->GetLineText(0);
+            mrltemp = wxT("http") + demux + wxT("://") +
+                      net_addrs[2]->GetLineText(0);
             break;
         }
         break;
     case SAT_ACCESS:
-        mrl = wxT("satellite") + demux + wxT("://");
+        mrltemp = wxT("satellite") + demux + wxT("://");
         break;
     default:
         break;
     }
 
-    mrl_combo->SetValue( mrl );
+    mrl_combo->SetValue( mrltemp );
+}
+
+wxArrayString OpenDialog::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 */
+            entry.RemoveLast();
+            if( !entry.IsEmpty() ) entries_array.Add( entry );
+            entry.Empty();
+        } 
+        else
+        {;}
+    }
+
+    if( !entry.IsEmpty() ) entries_array.Add( entry );
+
+    return entries_array;
 }
 
 /*****************************************************************************
@@ -571,6 +618,8 @@ void OpenDialog::UpdateMRL( int i_access_method )
  *****************************************************************************/
 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
 {
+    mrl_combo->Append( mrl_combo->GetValue() );
+    mrl = SeparateEntries( mrl_combo->GetValue() );
     EndModal( wxID_OK );
 }
 
@@ -586,7 +635,7 @@ void OpenDialog::OnPageChange( wxNotebookEvent& event )
 
 void OpenDialog::OnMRLChange( wxCommandEvent& event )
 {
-    mrl = event.GetString();
+    //mrl = SeparateEntries( event.GetString() );
 }
 
 /*****************************************************************************
@@ -601,11 +650,25 @@ void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
 {
     if( file_dialog == NULL )
         file_dialog = new wxFileDialog( this, wxU(_("Open file")),
-                                        wxT(""), wxT(""), wxT("*.*"), wxOPEN );
+            wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
 
     if( file_dialog && file_dialog->ShowModal() == wxID_OK )
     {
-        file_combo->SetValue( file_dialog->GetPath() );      
+        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 );
         UpdateMRL( FILE_ACCESS );
     }
 }
@@ -772,7 +835,7 @@ void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
 {
     if( demuxdump_dialog == NULL )
         demuxdump_dialog = new wxFileDialog( this, wxU(_("Save file")),
-                               wxT(""), wxT(""), wxT("*.*"), wxSAVE );
+                               wxT(""), wxT(""), wxT("*"), wxSAVE );
 
     if( demuxdump_dialog && demuxdump_dialog->ShowModal() == wxID_OK )
     {
index fb6f407..dafdbc5 100644 (file)
@@ -2,7 +2,7 @@
  * playlist.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: playlist.cpp,v 1.10 2003/05/18 16:27:18 gbazin Exp $
+ * $Id: playlist.cpp,v 1.11 2003/05/20 23:17:59 gbazin Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *
@@ -328,7 +328,7 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
     }
 
     wxFileDialog dialog( this, wxU(_("Save playlist")),
-                         wxT(""), wxT(""), wxT("*.*"), wxSAVE );
+                         wxT(""), wxT(""), wxT("*"), wxSAVE );
 
     if( dialog.ShowModal() == wxID_OK )
     {
@@ -349,7 +349,7 @@ void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
     }
 
     wxFileDialog dialog( this, wxU(_("Open playlist")),
-                         wxT(""), wxT(""), wxT("*.*"), wxOPEN );
+                         wxT(""), wxT(""), wxT("*"), wxOPEN );
 
     if( dialog.ShowModal() == wxID_OK )
     {
@@ -377,9 +377,13 @@ void Playlist::OnAddMRL( wxCommandEvent& WXUNUSED(event) )
     if( p_main_interface->p_open_dialog &&
         p_main_interface->p_open_dialog->ShowModal() == wxID_OK )
     {
-        playlist_Add( p_playlist,
-            (const char *)p_main_interface->p_open_dialog->mrl.mb_str(),
-            PLAYLIST_APPEND, PLAYLIST_END );
+        for( size_t i = 0;
+             i < p_main_interface->p_open_dialog->mrl.GetCount(); i++ )
+        {
+            playlist_Add( p_playlist,
+                (const char *)p_main_interface->p_open_dialog->mrl[i].mb_str(),
+                PLAYLIST_APPEND, PLAYLIST_END );
+        }
     }
 
     vlc_object_release( p_playlist );
index 23d7ede..1306e31 100644 (file)
@@ -2,7 +2,7 @@
  * streamout.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: streamout.cpp,v 1.12 2003/05/17 22:48:09 gbazin Exp $
+ * $Id: streamout.cpp,v 1.13 2003/05/20 23:17:59 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -583,6 +583,7 @@ wxPanel *SoutDialog::TranscodingPanel( wxWindow* parent )
     return panel;
 }
 
+#if 0
 void SoutDialog::ParseMRL()
 {
     /* Initialise MRL value */
@@ -665,6 +666,7 @@ void SoutDialog::ParseMRL()
     dummy_event.SetId( EncapsulationRadio1_Event + i_encapsulation_type );
     OnEncapsulationChange( dummy_event );
 }
+#endif
 
 /*****************************************************************************
  * Events methods.
@@ -724,7 +726,7 @@ void SoutDialog::OnFileChange( wxCommandEvent& WXUNUSED(event) )
 void SoutDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
 {
     wxFileDialog dialog( this, wxU(_("Save file")),
-                         wxT(""), wxT(""), wxT("*.*"), wxSAVE );
+                         wxT(""), wxT(""), wxT("*"), wxSAVE );
 
     if( dialog.ShowModal() == wxID_OK )
     {
index e858452..f12cc96 100644 (file)
@@ -2,7 +2,7 @@
  * subtitles.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: subtitles.cpp,v 1.1 2003/05/13 22:59:16 gbazin Exp $
+ * $Id: subtitles.cpp,v 1.2 2003/05/20 23:17:59 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -194,7 +194,7 @@ void SubsFileDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
 void SubsFileDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
 {
     wxFileDialog dialog( this, wxU(_("Open file")),
-                         wxT(""), wxT(""), wxT("*.*"), wxOPEN );
+                         wxT(""), wxT(""), wxT("*"), wxOPEN );
 
     if( dialog.ShowModal() == wxID_OK )
     {
index 1fad589..d6a7951 100644 (file)
@@ -2,7 +2,7 @@
  * wxwindows.h: private wxWindows interface description
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: wxwindows.h,v 1.29 2003/05/18 19:46:35 gbazin Exp $
+ * $Id: wxwindows.h,v 1.30 2003/05/20 23:17:59 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -141,8 +141,6 @@ public:
 
     wxMenu      *p_popup_menu;
 
-    wxArrayString mrl_history;
-
 private:
     void CreateOurMenuBar();
     void CreateOurToolBar();
@@ -208,7 +206,7 @@ public:
                 int i_access_method );
     virtual ~OpenDialog();
 
-    wxString mrl;
+    wxArrayString mrl;
 
 private:
     wxPanel *FilePanel( wxWindow* parent );
@@ -217,6 +215,7 @@ private:
     wxPanel *SatPanel( wxWindow* parent );
 
     void UpdateMRL( int i_access_method );
+    wxArrayString SeparateEntries( wxString );
 
     /* Event handlers (these functions should _not_ be virtual) */
     void OnOk( wxCommandEvent& event );