From: Eric Petit Date: Tue, 14 Jan 2003 22:03:38 +0000 (+0000) Subject: Fixed playlist behaviour (draging a file replaces the playlist, and X-Git-Tag: 0.5.0~310 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=1e4d28428f96cb5a1927e7b5eeda0e924f75b1a5;p=vlc Fixed playlist behaviour (draging a file replaces the playlist, and draging a file while pressing the 'Shift' key appends it while the current one keeps playing. --- diff --git a/modules/gui/beos/InterfaceWindow.cpp b/modules/gui/beos/InterfaceWindow.cpp index c18f111f59..9912dbac3c 100644 --- a/modules/gui/beos/InterfaceWindow.cpp +++ b/modules/gui/beos/InterfaceWindow.cpp @@ -2,7 +2,7 @@ * InterfaceWindow.cpp: beos interface ***************************************************************************** * Copyright (C) 1999, 2000, 2001 VideoLAN - * $Id: InterfaceWindow.cpp,v 1.16 2003/01/14 14:48:55 titer Exp $ + * $Id: InterfaceWindow.cpp,v 1.17 2003/01/14 22:03:38 titer Exp $ * * Authors: Jean-Marc Dressler * Samuel Hocevar @@ -443,10 +443,13 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) case B_REFS_RECEIVED: case B_SIMPLE_DATA: { - // figure out if user wants files replaced or added + /* file(s) opened by the File menu -> append to the playlist; + * file(s) opened by drag & drop -> replace playlist; + * file(s) opened by 'shift' + drag & drop -> append */ bool replace = false; if ( p_message->WasDropped() ) replace = !( modifiers() & B_SHIFT_KEY ); + // build list of files to be played from message contents entry_ref ref; BList files; @@ -454,8 +457,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) { BPath path( &ref ); if ( path.InitCheck() == B_OK ) - // the BString objects will be deleted - // by the wrapper function further down files.AddItem( new BString( (char*)path.Path() ) ); } // give the list to VLC diff --git a/modules/gui/beos/VlcWrapper.cpp b/modules/gui/beos/VlcWrapper.cpp index 172efe18ad..4f74c1f75a 100644 --- a/modules/gui/beos/VlcWrapper.cpp +++ b/modules/gui/beos/VlcWrapper.cpp @@ -2,7 +2,7 @@ * VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port) ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: VlcWrapper.cpp,v 1.18 2003/01/14 14:48:55 titer Exp $ + * $Id: VlcWrapper.cpp,v 1.19 2003/01/14 22:03:38 titer Exp $ * * Authors: Florian G. Pflug * Jon Lech Johansen @@ -222,13 +222,31 @@ BList * VlcWrapper::InputGetChannels( int i_cat ) void VlcWrapper::openFiles( BList* o_files, bool replace ) { BString *o_file; + int size = PlaylistSize(); + bool wasEmpty = ( size < 1 ); + /* delete current playlist */ + if( replace ) + { + for( int i = 0; i < size; i++ ) + { + playlist_Delete( p_playlist, 0 ); + } + } + + /* append files */ while( ( o_file = (BString *)o_files->LastItem() ) ) { - o_files->RemoveItem(o_files->CountItems() - 1); playlist_Add( p_playlist, o_file->String(), - PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); - delete o_file; + PLAYLIST_APPEND, PLAYLIST_END ); + o_files->RemoveItem(o_files->CountItems() - 1); + } + + /* eventually restart playing */ + if( replace || wasEmpty ) + { + playlist_Stop( p_playlist ); + playlist_Play( p_playlist ); } }