From afdbb16a2f91f7b0ea7f6b53522e2447407d6917 Mon Sep 17 00:00:00 2001 From: pontscho Date: Sun, 11 Aug 2002 19:12:09 +0000 Subject: kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6978 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Gui/mplayer/mw.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'Gui/mplayer') diff --git a/Gui/mplayer/mw.h b/Gui/mplayer/mw.h index bf86bd8edd..8cc410403e 100644 --- a/Gui/mplayer/mw.h +++ b/Gui/mplayer/mw.h @@ -665,26 +665,42 @@ void mplDandDHandler(int num,const char** files) /* now fill it with new items */ for(f=0; f < num; f++){ - char* str = files[f]; + char* str = strdup( files[f] ); plItem* item; + + if ( strchr( str,'%' ) ) + { + char * t = calloc( 1,strlen( str ) ); + int i,c = 0; + for ( i=0;i < strlen( str );i++ ) + if ( str[i] != '%' ) t[c++]=str[i]; + else + { + char tmp[4] = "0xXX"; +// if ( str[++i] == '%' ) { t[c++]='%'; continue; }; + tmp[2]=str[++i]; tmp[3]=str[++i]; t[c++]=(char)strtol( tmp,(char **)NULL,16 ); + } + free( str ); str=t; + } + if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) { /* this is not a directory so try to play it */ printf("Received D&D %s\n",str); item = calloc(1,sizeof(plItem)); + /* FIXME: decompose file name ? */ /* yes -- Pontscho */ if ( strrchr( str,'/' ) ) { - char * t = strdup( str ); - char * s = strrchr( t,'/' ); *s=0; s++; + char * s = strrchr( str,'/' ); *s=0; s++; item->name = gstrdup( s ); - item->path = gstrdup( t ); - free( t ); + item->path = gstrdup( str ); } else { item->name = strdup(str); item->path = strdup(""); } gtkSet(gtkAddPlItem,0,(void*)item); } else { printf("Received not a file: %s !\n",str); } + free( str ); } mplSetFileName( NULL,files[0] ); -- cgit v1.2.3