[Mplayer-cvslog] CVS: main/Gui/mplayer mw.c,1.97,1.98

Zoltan Ponekker pontscho at mplayerhq.hu
Mon Dec 16 21:16:32 CET 2002


Update of /cvsroot/mplayer/main/Gui/mplayer
In directory mail:/var/tmp.root/cvs-serv31850

Modified Files:
	mw.c 
Log Message:
applied Gregory's patch

Index: mw.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/mplayer/mw.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- mw.c	11 Dec 2002 01:21:09 -0000	1.97
+++ mw.c	16 Dec 2002 20:16:29 -0000	1.98
@@ -688,11 +688,12 @@
   struct stat buf;
   int f = 0;
 
+  char* subtitles = NULL;
+  char* filename = NULL;
+
   if (num <= 0)
     return;
 
-  /* clear playlist */
-  gtkSet(gtkDelPl,0,NULL);
 
   /* now fill it with new items */
   for(f=0; f < num; f++){
@@ -710,16 +711,42 @@
     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);
+      
+      /* check if it is a subtitle file */
+      {
+	char* ext = strrchr(str,'.');
+	if (ext) {
+	  static char supported[] = "utf/sub/srt/smi/rt//txt/ssa/aqt/";
+	  char* type;
+	  int len;
+	  if((len=strlen(++ext)) && (type=strstr(supported,ext)) &&\
+	     (type-supported)%4 == 0 && *(type+len) == '/'){
+	    /* handle subtitle file */
+	    gfree((void**)&subtitles);
+	    subtitles = str;
+	    continue;
+	  }
+	}
+      }
+
+      /* clear playlist */
+      if (filename == NULL) {
+	filename = files[f];
+	gtkSet(gtkDelPl,0,NULL);
+      }
+
       item = calloc(1,sizeof(plItem));
       
       /* FIXME: decompose file name ? */
       /* yes -- Pontscho */
-      if ( strrchr( str,'/' ) )
-       {
+      if ( strrchr( str,'/' ) ) {
 	char * s = strrchr( str,'/' ); *s=0; s++;
-        item->name = gstrdup( s );
-        item->path = gstrdup( str );
-       } else { item->name = strdup(str); item->path = strdup(""); }
+	item->name = gstrdup( s );
+	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);
@@ -727,8 +754,14 @@
     free( str );
   }
 
-  mplSetFileName( NULL,files[0],STREAMTYPE_FILE );
-  if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evStop,0 );
-  mplEventHandling( evPlay,0 );
-
+  if (filename) {
+    mplSetFileName( NULL,filename,STREAMTYPE_FILE );
+    if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evStop,0 );
+    mplEventHandling( evPlay,0 );
+  }
+  if (subtitles) {
+    gfree((void**)&guiIntfStruct.Subtitlename);
+    guiIntfStruct.Subtitlename = subtitles;
+    guiLoadSubtitle(guiIntfStruct.Subtitlename);
+  }
 }




More information about the MPlayer-cvslog mailing list