changeset 9056:3086611e8213

- add subcp - fix some 10l in gui - fix one 10l bug in subreader
author pontscho
date Tue, 21 Jan 2003 19:12:46 +0000
parents 4a42c0604ce1
children 99a3ab65891d
files Gui/cfg.c Gui/interface.c Gui/interface.h Gui/mplayer/gtk/fs.c Gui/mplayer/gtk/opts.c mplayer.h subreader.c
diffstat 7 files changed, 106 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/Gui/cfg.c	Tue Jan 21 13:33:40 2003 +0000
+++ b/Gui/cfg.c	Tue Jan 21 19:12:46 2003 +0000
@@ -116,6 +116,7 @@
  { "sub_unicode",&sub_unicode,CONF_TYPE_FLAG,0,0,1,NULL },
  { "sub_pos",&sub_pos,CONF_TYPE_INT,CONF_RANGE,0,200,NULL },
  { "sub_overlap",&suboverlap_enabled,CONF_TYPE_FLAG,0,0,0,NULL },
+ { "sub_cp",&sub_cp,CONF_TYPE_STRING,0,0,0,NULL },
  { "font_factor",&font_factor,CONF_TYPE_FLOAT,CONF_RANGE,0.0,10.0,NULL },
  { "font_name",&font_name,CONF_TYPE_STRING,0,0,0,NULL },
 #ifdef HAVE_FREETYPE 
--- a/Gui/interface.c	Tue Jan 21 13:33:40 2003 +0000
+++ b/Gui/interface.c	Tue Jan 21 19:12:46 2003 +0000
@@ -386,6 +386,7 @@
    mp_msg( MSGT_GPLAYER,MSGL_INFO,"[gui] Delete Load subtitle: %s\n",name );
    sub_name=gstrdup( name );
    subtitles=sub_read_file( sub_name,guiIntfStruct.FPS );
+   if ( !subtitles ) mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_CantLoadSub,name );
   }
 }
 #endif
@@ -862,7 +863,6 @@
          } else { url_item->next=NULL; URLList=url_item; }
         return NULL;
 // --- subtitle
-#if defined( USE_OSD ) || defined( USE_SUB )
 #ifndef HAVE_FREETYPE
    case gtkSetFontFactor:
         font_factor=fparam;
@@ -886,7 +886,7 @@
 	guiLoadFont();
 	return NULL;
    case gtkSetFontEncoding:
-        if ( subtitle_font_encoding ) free( subtitle_font_encoding );
+	gfree( (void **)&subtitle_font_encoding );
 	subtitle_font_encoding=gstrdup( (char *)vparam );
 	guiLoadFont();
 	return NULL;
@@ -895,6 +895,11 @@
 	guiLoadFont();
 	return NULL;
 #endif
+#ifdef USE_ICONV
+   case gtkSetSubEncoding:
+	gfree( (void **)&sub_cp );
+	sub_cp=gstrdup( (char *)vparam );
+	break;
 #endif
 // --- misc
    case gtkClearStruct:
--- a/Gui/interface.h	Tue Jan 21 13:33:40 2003 +0000
+++ b/Gui/interface.h	Tue Jan 21 19:12:46 2003 +0000
@@ -195,6 +195,7 @@
 #define gtkSetFontOSDScale  19
 #define gtkSetFontEncoding  20
 #define gtkSetFontAutoScale 21
+#define gtkSetSubEncoding   22
 
 extern float gtkEquChannels[6][10];
 
--- a/Gui/mplayer/gtk/fs.c	Tue Jan 21 13:33:40 2003 +0000
+++ b/Gui/mplayer/gtk/fs.c	Tue Jan 21 19:12:46 2003 +0000
@@ -334,7 +334,12 @@
 {
  int i;
 
- for ( i=0;i < fsPersistant_MaxPos;i++ ) if ( fsHistory[i] && !strcmp( fsHistory[i],subject ) ) return 0;
+ for ( i=0;i < fsPersistant_MaxPos;i++ )
+  if ( fsHistory[i] && !strcmp( fsHistory[i],subject ) )
+   {
+    char * tmp = fsHistory[i]; fsHistory[i]=fsHistory[0]; fsHistory[0]=tmp;
+    return 0;
+   }
  gfree( (void **)&fsHistory[fsPersistant_MaxPos - 1] );
  for ( i=fsPersistant_MaxPos - 1;i;i-- ) fsHistory[i]=fsHistory[i - 1];
  fsHistory[0]=gstrdup( subject );
--- a/Gui/mplayer/gtk/opts.c	Tue Jan 21 13:33:40 2003 +0000
+++ b/Gui/mplayer/gtk/opts.c	Tue Jan 21 19:12:46 2003 +0000
@@ -106,7 +106,11 @@
 //static GtkWidget     * AutoScale;
 #endif
 
-#ifdef HAVE_FREETYPE
+#ifdef USE_ICONV
+static GtkWidget     * CBSubEncoding, * ESubEncoding;
+#endif
+
+#if defined( HAVE_FREETYPE ) || defined( USE_ICONV )
 static struct 
 {
  char * name;
@@ -137,6 +141,7 @@
   { NULL,NULL } 
  };
 char * lCEncoding = NULL;
+char * lSEncoding = NULL;
 #endif
 	    
 static int    old_audio_driver = 0;
@@ -160,7 +165,7 @@
 static void prToggled( GtkToggleButton * togglebutton,gpointer user_data );
 static void prCListRow( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data );
 #ifdef HAVE_FREETYPE
-static void prEntry( GtkContainer * container,GtkWidget * widget,gpointer user_data );
+static void prEntry( GtkContainer * container,gpointer user_data );
 #endif
 
 extern int    muted;
@@ -248,7 +253,7 @@
 #endif
  }
  
-  gtk_adjustment_set_value( HSFPS,force_fps );
+  gtk_adjustment_set_value( HSFPSadj,force_fps );
 
 // -- 3. page
  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBSubOverlap ),suboverlap_enabled );
@@ -270,6 +275,17 @@
  if ( guiIntfStruct.Subtitlename ) gtk_entry_set_text( GTK_ENTRY( ESubtitleName ),guiIntfStruct.Subtitlename );
 #endif
 
+#ifdef USE_ICONV
+ if ( sub_cp )
+  {
+   int i;
+   for ( i=0;lEncoding[i].name;i++ ) 
+    if ( !gstrcmp( sub_cp,lEncoding[i].name ) ) break;
+   if ( lEncoding[i].name ) lSEncoding=lEncoding[i].comment;
+   gtk_entry_set_text( GTK_ENTRY( ESubEncoding ),lSEncoding );
+  }
+#endif
+
 // --- 4. page
  // font ...
  if ( font_name ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name );
@@ -411,7 +427,10 @@
  gtk_signal_connect( GTK_OBJECT( HSFontOutLine ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)7 );
  gtk_signal_connect( GTK_OBJECT( HSFontTextScale ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)8 );
  gtk_signal_connect( GTK_OBJECT( HSFontOSDScale ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)9 );
- gtk_signal_connect( GTK_OBJECT( EFontEncoding ),"changed",GTK_SIGNAL_FUNC( prEntry ),NULL );
+ gtk_signal_connect( GTK_OBJECT( EFontEncoding ),"changed",GTK_SIGNAL_FUNC( prEntry ),(void *)0 );
+#endif
+#ifdef USE_ICONV
+ gtk_signal_connect( GTK_OBJECT( ESubEncoding ),"changed",GTK_SIGNAL_FUNC( prEntry ),(void *)1 );
 #endif
  gtk_signal_connect( GTK_OBJECT( HSPPQuality ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)10 );
  
@@ -447,16 +466,32 @@
 #endif
 }
 
-#ifdef HAVE_FREETYPE
-static void prEntry( GtkContainer * container,GtkWidget * widget,gpointer user_data )
+#if defined( HAVE_FREETYPE ) || defined( USE_ICONV )
+static void prEntry( GtkContainer * container,gpointer user_data )
 {
- char * comment = gtk_entry_get_text( GTK_ENTRY( EFontEncoding ) );
+ char * comment;
  int    i;
- 
- for ( i=0;lEncoding[i].name;i++ )
-  if ( !gstrcmp( lEncoding[i].comment,comment ) ) break;
-  
- if ( lEncoding[i].comment ) gtkSet( gtkSetFontEncoding,0,lEncoding[i].name );
+
+ switch( (int)user_data )
+  {
+#ifdef HAVE_FREETYPE
+   case 0: // font encoding
+        comment=gtk_entry_get_text( GTK_ENTRY( EFontEncoding ) );
+        for ( i=0;lEncoding[i].name;i++ )
+	  if ( !gstrcmp( lEncoding[i].comment,comment ) ) break;
+	if ( lEncoding[i].comment ) gtkSet( gtkSetFontEncoding,0,lEncoding[i].name );
+	break;
+#endif
+#ifdef USE_ICONV
+   case 1: // sub encoding
+        comment=gtk_entry_get_text( GTK_ENTRY( ESubEncoding ) );
+        for ( i=0;lEncoding[i].name;i++ )
+	  if ( !gstrcmp( lEncoding[i].comment,comment ) ) break;
+	if ( lEncoding[i].comment ) gtkSet( gtkSetSubEncoding,0,lEncoding[i].name );
+	 else gtkSet( gtkSetSubEncoding,0,NULL );
+	break;
+#endif
+  }
 }
 #endif
 
@@ -492,6 +527,8 @@
 
 	flip=-1;
 	if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBFlip ) ) ) flip=1;
+
+	force_fps=HSFPSadj->value;
 	
 	// -- 3. page
 	suboverlap_enabled=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBSubOverlap ) );
@@ -502,11 +539,11 @@
 	sub_delay=HSSubDelayadj->value;
 	sub_fps=HSSubFPSadj->value;
 	sub_pos=(int)HSSubPositionadj->value;
-	force_fps=HSFPSadj->value;
 	if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBOSDNone ) ) ) osd_level=0;
 	if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBOSDIndicator ) ) ) osd_level=1;
 	if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBOSDTandP ) ) ) osd_level=2;
 	if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBOSDTPTT ) ) ) osd_level=3;
+	
 
         // --- 4. page
 	guiSetFilename( font_name,gtk_entry_get_text( GTK_ENTRY( prEFontName ) ) );
@@ -712,6 +749,7 @@
   GSList    * OSD_group = NULL;
   GSList    * Font_group = NULL;
   GList     * CBFontEncoding_items = NULL;
+  GList	    * CBSubEncoding_items = NULL;
   GtkWidget * vbox7;
   GtkWidget * vbox8;
   GtkWidget * table1;
@@ -917,6 +955,11 @@
   label=AddLabel( MSGTR_PREFERENCES_SUB_FPS,NULL );
     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,2,3,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
 
+#ifdef USE_ICONV
+  label=AddLabel( MSGTR_PREFERENCES_FontEncoding,NULL );
+    gtk_table_attach( GTK_TABLE( table1 ),label,0,1,3,4,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
+#endif
+
   HSSubDelayadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-10.0,10,0.01,0,0 ) );
   HSSubDelay=AddHScaler( HSSubDelayadj,NULL,1 );
     gtk_table_attach( GTK_TABLE( table1 ),HSSubDelay,1,2,0,1,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
@@ -933,6 +976,25 @@
     gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( HSSubFPS ),TRUE );
     gtk_table_attach( GTK_TABLE( table1 ),HSSubFPS,1,2,2,3,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
 
+#ifdef USE_ICONV
+  CBSubEncoding=gtk_combo_new();
+  gtk_widget_set_name( CBSubEncoding,"CBSubEncoding" );
+  gtk_widget_show( CBSubEncoding );
+  gtk_table_attach( GTK_TABLE( table1 ),CBSubEncoding,1,2,3,4,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
+  CBSubEncoding_items=g_list_append( CBSubEncoding_items,MSGTR_PREFERENCES_None );
+  {
+   int i;
+   for ( i=0;lEncoding[i].name;i++ ) CBSubEncoding_items=g_list_append( CBSubEncoding_items,lEncoding[i].comment );
+  }
+  gtk_combo_set_popdown_strings( GTK_COMBO( CBSubEncoding ),CBSubEncoding_items );
+  g_list_free( CBSubEncoding_items );
+
+  ESubEncoding=GTK_COMBO( CBSubEncoding )->entry;
+  gtk_widget_set_name( ESubEncoding,"ESubEncoding" );
+  gtk_entry_set_editable( GTK_ENTRY( ESubEncoding ),FALSE );
+  gtk_widget_show( ESubEncoding );
+#endif
+
   vbox9=AddVBox( vbox8,0 );
 
   CBSubOverlap=AddCheckButton( MSGTR_PREFERENCES_SUB_Overlap,vbox9 );
--- a/mplayer.h	Tue Jan 21 13:33:40 2003 +0000
+++ b/mplayer.h	Tue Jan 21 19:12:46 2003 +0000
@@ -34,6 +34,7 @@
 extern int    sub_auto;
 extern int    sub_pos;
 extern int    sub_unicode;
+extern char * sub_cp;
 extern subtitle* subtitles;
 extern subtitle* vo_sub;
 extern int    suboverlap_enabled;
--- a/subreader.c	Tue Jan 21 13:33:40 2003 +0000
+++ b/subreader.c	Tue Jan 21 19:12:46 2003 +0000
@@ -904,6 +904,7 @@
 int sub_utf8=0;
 #else
 extern int sub_utf8;
+int sub_utf8_prev=0;
 #endif
 
 extern float sub_delay;
@@ -916,9 +917,11 @@
 {
 	char *tocp = "UTF-8";
 	icdsc = (iconv_t)(-1);
+
 	if (sub_cp){
 		if ((icdsc = iconv_open (tocp, sub_cp)) != (iconv_t)(-1)){
 			mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: opened iconv descriptor.\n");
+			sub_utf8_prev=sub_utf8;
 			sub_utf8 = 2;
 		} else
 			mp_msg(MSGT_SUBREADER,MSGL_ERR,"SUB: error opening iconv descriptor.\n");
@@ -929,6 +932,7 @@
 {
 	if (icdsc != (iconv_t)(-1)){
 		(void) iconv_close (icdsc);
+		sub_utf8=sub_utf8_prev;
 	   	mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: closed iconv descriptor.\n");
 	}
 }
@@ -947,10 +951,10 @@
 		ip = sub->text[--l];
 		ileft = strlen(ip);
 		oleft = ICBUFFSIZE - 1;
-		
+
 		if (iconv(icdsc, &ip, &ileft,
 			  &op, &oleft) == (size_t)(-1)) {
-			mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line.\n");
+			mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line (1).\n");
 			l++;
 			break;
 		}
@@ -988,7 +992,7 @@
 		
      if (iconv(icdsc, &ip, &ileft,
 	      &op, &oleft) == (size_t)(-1)) {
-	mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line.\n");
+	mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line (2).\n");
 	return sub;
      }
      *op='\0' ;
@@ -1119,6 +1123,14 @@
 #ifdef USE_ICONV
 	if ((sub!=ERR) && (sub_utf8 & 2)) sub=subcp_recode(sub);
 #endif
+	if ( sub == ERR )
+	 {
+#ifdef USE_ICONV
+          subcp_close();
+#endif
+    	  if ( first ) free(first);
+	  return NULL; 
+	 }
         // Apply any post processing that needs recoding first
         if ((sub!=ERR) && srp->post) srp->post(sub);
 #ifdef USE_SORTSUB