diff Gui/mplayer/mw.h @ 6977:7242f1840f8d

kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
author pontscho
date Sun, 11 Aug 2002 19:12:09 +0000
parents 0fa27966ac47
children 163f78ece9c2
line wrap: on
line diff
--- a/Gui/mplayer/mw.h	Sun Aug 11 18:52:55 2002 +0000
+++ b/Gui/mplayer/mw.h	Sun Aug 11 19:12:09 2002 +0000
@@ -665,26 +665,42 @@
 
   /* 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] );