[vlc-commits] commit: skins(Linux): add support for multiple files in drag&drap ( Erwan Tulou )
git at videolan.org
git at videolan.org
Sun Apr 11 21:51:18 CEST 2010
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sun Apr 11 21:39:08 2010 +0200| [95848385ab76356275c0dedde28b29e19b523a95] | committer: Erwan Tulou
skins(Linux): add support for multiple files in drag&drap
selection is made of several items separated with '\n' and terminated with a final '\0'. When selection is limited to one item, the '\n' is missing.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=95848385ab76356275c0dedde28b29e19b523a95
---
modules/gui/skins2/x11/x11_dragdrop.cpp | 37 +++++++++++--------------------
1 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/modules/gui/skins2/x11/x11_dragdrop.cpp b/modules/gui/skins2/x11/x11_dragdrop.cpp
index 6e9fc78..ff327e7 100644
--- a/modules/gui/skins2/x11/x11_dragdrop.cpp
+++ b/modules/gui/skins2/x11/x11_dragdrop.cpp
@@ -163,35 +163,24 @@ void X11DragDrop::dndDrop( ldata_t data )
XGetWindowProperty( XDISPLAY, src, propAtom, 0, 1024, False,
AnyPropertyType, &type, &format, &nitems, &nbytes,
(unsigned char**)&buffer );
- string selection = "";
- if( buffer != NULL )
- {
- selection = buffer;
- XFree( buffer );
- }
- if( selection != "" )
+ if( buffer != NULL )
{
- // TODO: multiple files handling
- string::size_type end = selection.find( "\n", 0 );
- selection = selection.substr( 0, end - 1 );
- end = selection.find( "\r", 0 );
- selection = selection.substr( 0, end - 1 );
-
- // Find the protocol, if any
- if( selection.find( "file://", 0 ) == 0 )
+ char* psz_dup = strdup( buffer );
+ char* psz_new = psz_dup;
+ while( psz_new && *psz_new )
{
- selection.erase( 0, 7 );
- }
-
- char *psz_fileName = new char[selection.size() + 1];
- strncpy( psz_fileName, selection.c_str(), selection.size() + 1 );
+ char* psz_end = strchr( psz_new, '\n' );
+ if( psz_end )
+ *psz_end = '\0';
- // Add the file
- CmdAddItem cmd( getIntf(), psz_fileName, m_playOnDrop );
- cmd.execute();
+ CmdAddItem cmd( getIntf(), psz_new, m_playOnDrop );
+ cmd.execute();
- delete[] psz_fileName;
+ psz_new = psz_end ? psz_end + 1 : NULL;
+ }
+ free( psz_dup );
+ XFree( buffer );
}
// Tell the source we accepted the drop
More information about the vlc-commits
mailing list