[MPlayer-cvslog] r32810 - in trunk/gui/mplayer/gtk: fs.c pl.c

ib subversion at mplayerhq.hu
Fri Jan 21 16:33:12 CET 2011


Author: ib
Date: Fri Jan 21 16:33:12 2011
New Revision: 32810

Log:
Check conversion to and from UTF-8.

(If G_FILENAME_ENCODING isn't properly set, the conversion
may fail. In this case we go with the original names.)

Modified:
   trunk/gui/mplayer/gtk/fs.c
   trunk/gui/mplayer/gtk/pl.c

Modified: trunk/gui/mplayer/gtk/fs.c
==============================================================================
--- trunk/gui/mplayer/gtk/fs.c	Fri Jan 21 16:24:18 2011	(r32809)
+++ trunk/gui/mplayer/gtk/fs.c	Fri Jan 21 16:33:12 2011	(r32810)
@@ -161,6 +161,7 @@ static char * get_current_dir_name_utf8(
  char * dir, * utf8dir;
  dir = get_current_dir_name();
  utf8dir = g_filename_to_utf8( dir, -1, NULL, NULL, NULL );
+ if ( !utf8dir ) utf8dir = g_strdup( dir );
  free( dir );
  return utf8dir;
 }
@@ -184,7 +185,7 @@ static void clist_append_fname(GtkWidget
   gchar *filename, *str[2];
   filename = g_filename_to_utf8(fname, -1, NULL, NULL, NULL);
   str[0] = NULL;
-  str[1] = filename;
+  str[1] = filename ? filename : fname;
   pos = gtk_clist_append(GTK_CLIST(list), str);
   gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask);
   g_free(filename);
@@ -430,7 +431,7 @@ static void fs_fsPathCombo_activate( Gtk
 
  str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
  dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL );
- if ( chdir( dirname ) != -1 ) CheckDir( fsFNameList );
+ if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList );
  g_free( dirname );
 }
 
@@ -442,7 +443,7 @@ static void fs_fsPathCombo_changed( GtkE
 
  str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
  dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL );
- if ( chdir( dirname ) != -1 ) CheckDir( fsFNameList );
+ if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList );
  g_free( dirname );
 }
 
@@ -524,7 +525,7 @@ static void fs_fsFNameList_select_row( G
  gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile );
  g_free( fsSelectedFileUtf8 );
  fsSelectedFileUtf8 = g_filename_from_utf8( fsSelectedFile, -1, NULL, NULL, NULL );
- fsSelectedFile = fsSelectedFileUtf8;
+ if ( fsSelectedFileUtf8 ) fsSelectedFile = fsSelectedFileUtf8;
  if( bevent && bevent->type == GDK_BUTTON_PRESS )  gtk_button_released( GTK_BUTTON( fsOk ) );
 }
 

Modified: trunk/gui/mplayer/gtk/pl.c
==============================================================================
--- trunk/gui/mplayer/gtk/pl.c	Fri Jan 21 16:24:18 2011	(r32809)
+++ trunk/gui/mplayer/gtk/pl.c	Fri Jan 21 16:33:12 2011	(r32810)
@@ -181,8 +181,8 @@ void ShowPlayList( void )
      char * text[1][3]; text[0][2]="";
      name = g_filename_to_utf8( next->name, -1, NULL, NULL, NULL );
      path = g_filename_to_utf8( next->path, -1, NULL, NULL, NULL );
-     text[0][0]=name;
-     text[0][1]=path;
+     text[0][0]=name ? name : next->name;
+     text[0][1]=path ? path : next->path;
      gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
      g_free( path );
      g_free( name );
@@ -242,7 +242,9 @@ static void plButtonReleased( GtkButton 
 	  gtk_clist_get_text( GTK_CLIST( CLSelected ),i,0,&text[0] );
 	  gtk_clist_get_text( GTK_CLIST( CLSelected ),i,1,&text[1] );
 	  item->name=g_filename_from_utf8( text[0], -1, NULL, NULL, NULL );
+	  if ( !item->name ) item->name = strdup( text[0] );
 	  item->path=g_filename_from_utf8( text[1], -1, NULL, NULL, NULL );
+	  if ( !item->path ) item->path = strdup( text[1] );
 	  gtkSet( gtkAddPlItem,0,(void*)item );
 	 }
 	if ( plCurrent )
@@ -301,7 +303,7 @@ static void plButtonReleased( GtkButton 
 	      CLListSelected[NrOfSelected - 1]=0;
 	      gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,(char **)&itext );
 	      cpath=g_filename_to_utf8( current_path, -1, NULL, NULL, NULL );
-	      text[0][0]=itext[0][0]; text[0][1]=cpath;
+	      text[0][0]=itext[0][0]; text[0][1]=cpath ? cpath : current_path;
 	      gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
 	      g_free( cpath );
 	     }
@@ -373,7 +375,7 @@ static void plCTree( GtkCTree * ctree,Gt
 	{
 	 DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=0; DirNode->path=strdup( path );
 	 subdir=check_for_subdir( path );
-	 node=gtk_ctree_insert_node( ctree,parent_node,NULL,&name,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE );
+	 node=gtk_ctree_insert_node( ctree,parent_node,NULL,(name ? &name : &text ),4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE );
 	 gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL );
 	 if ( subdir ) node=gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE );
 	}
@@ -408,7 +410,7 @@ static void scan_dir( char * path )
 	 if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) )
 	  {
 	   name=g_filename_to_utf8( dirent->d_name, -1, NULL, NULL, NULL );
-	   text[0][0]=name;
+	   text[0][0]=name ? name : dirent->d_name;
 	   gtk_clist_append( GTK_CLIST( CLFiles ), text[0] );
 	   g_free( name );
 	   NrOfEntrys++;


More information about the MPlayer-cvslog mailing list