changeset 36563:5e8ada8eae44

Improve the dialog for subtitle encodings with iconv. Allow a (preset) encoding that is not part of the list of available encodings. Insert this encoding into the selection list.
author ib
date Mon, 20 Jan 2014 16:45:13 +0000
parents 6df17a667447
children d22374047528
files gui/dialog/preferences.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gui/dialog/preferences.c	Mon Jan 20 14:21:58 2014 +0000
+++ b/gui/dialog/preferences.c	Mon Jan 20 16:45:13 2014 +0000
@@ -240,7 +240,11 @@
         for ( i=0;lEncoding[i].name;i++ )
 	  if ( !gstrcmp( lEncoding[i].comment,comment ) ) break;
 	if ( lEncoding[i].comment ) mplayer( MPLAYER_SET_SUB_ENCODING,0,lEncoding[i].name );
-	 else mplayer( MPLAYER_SET_SUB_ENCODING,0,NULL );
+	else
+	{
+	 if ( strcmp( comment,MSGTR_PREFERENCES_DefaultEnc ) == 0 ) comment=NULL;
+	 mplayer( MPLAYER_SET_SUB_ENCODING,0,(char *)comment );
+	}
 	break;
 #endif
   }
@@ -790,7 +794,7 @@
   gtk_box_pack_start( GTK_BOX( vbox10 ),CBSubEncoding,TRUE,FALSE,0 );
   CBSubEncoding_items=g_list_append( CBSubEncoding_items,MSGTR_PREFERENCES_DefaultEnc );
   {
-   int i;
+   int i, listed=(sub_cp == NULL);
    iconv_t cd;
    for ( i=0;lEncoding[i].name;i++ )
    {
@@ -800,8 +804,12 @@
     {
      iconv_close(cd);
      CBSubEncoding_items=g_list_append( CBSubEncoding_items,lEncoding[i].comment );
+
+     if ( !listed )
+      if ( strcasecmp ( lEncoding[i].name, sub_cp ) == 0 ) listed=True;
     }
    }
+   if ( !listed ) CBSubEncoding_items=g_list_insert( CBSubEncoding_items,sub_cp,1 );
   }
   gtk_combo_set_popdown_strings( GTK_COMBO( CBSubEncoding ),CBSubEncoding_items );
   g_list_free( CBSubEncoding_items );
@@ -1234,6 +1242,7 @@
    for ( i=0;lEncoding[i].name;i++ )
     if ( !strcasecmp( sub_cp,lEncoding[i].name ) ) break;
    if ( lEncoding[i].name ) gtk_entry_set_text( GTK_ENTRY( ESubEncoding ),lEncoding[i].comment );
+   else gtk_entry_set_text( GTK_ENTRY( ESubEncoding ),sub_cp );
   }
 #endif