[MPlayer-cvslog] r32795 - in trunk/gui/mplayer/gtk: fs.c pl.c
ib
subversion at mplayerhq.hu
Tue Jan 18 12:30:47 CET 2011
Author: ib
Date: Tue Jan 18 12:30:46 2011
New Revision: 32795
Log:
Enable non-UTF-8 encoded filenames
(with G_FILENAME_ENCODING set to a specific character set name, not @locale)
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 Tue Jan 18 11:57:52 2011 (r32794)
+++ trunk/gui/mplayer/gtk/fs.c Tue Jan 18 12:30:46 2011 (r32795)
@@ -48,6 +48,7 @@ char * get_current_dir_name( void );
#endif
gchar * fsSelectedFile = NULL;
+gchar * fsSelectedFileUtf8 = NULL;
gchar * fsSelectedDirectory = NULL;
unsigned char * fsThatDir = ".";
const gchar * fsFilter = "*";
@@ -155,6 +156,15 @@ GdkPixmap * fpixmap;
GdkBitmap * dmask;
GdkBitmap * fmask;
+static char * get_current_dir_name_utf8( void )
+{
+ char * dir, * utf8dir;
+ dir = get_current_dir_name();
+ utf8dir = g_filename_to_utf8( dir, -1, NULL, NULL, NULL );
+ free( dir );
+ return utf8dir;
+}
+
static char * Filter( const char * name )
{
static char tmp[32];
@@ -171,11 +181,13 @@ static char * Filter( const char * name
static void clist_append_fname(GtkWidget * list, char *fname,
GdkPixmap *pixmap, GdkPixmap *mask) {
gint pos;
- gchar *str[2];
+ gchar *filename, *str[2];
+ filename = g_filename_to_utf8(fname, -1, NULL, NULL, NULL);
str[0] = NULL;
- str[1] = fname;
+ str[1] = filename;
pos = gtk_clist_append(GTK_CLIST(list), str);
gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask);
+ g_free(filename);
}
static void CheckDir( GtkWidget * list,char * directory )
@@ -414,18 +426,24 @@ static void fs_fsPathCombo_activate( Gtk
gpointer user_data )
{
const unsigned char * str;
+ gchar * dirname;
str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
- if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() );
+ dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL );
+ if ( chdir( dirname ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() );
+ g_free( dirname );
}
static void fs_fsPathCombo_changed( GtkEditable * editable,
gpointer user_data )
{
const unsigned char * str;
+ gchar * dirname;
str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
- if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() );
+ dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL );
+ if ( chdir( dirname ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() );
+ g_free( dirname );
}
static void fs_Up_released( GtkButton * button, gpointer user_data )
@@ -433,7 +451,7 @@ static void fs_Up_released( GtkButton *
chdir( ".." );
fsSelectedFile=fsThatDir;
CheckDir( fsFNameList,get_current_dir_name() );
- gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() );
+ gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() );
return;
}
@@ -449,7 +467,7 @@ static void fs_Ok_released( GtkButton *
chdir( fsSelectedFile );
fsSelectedFile=fsThatDir;
CheckDir( fsFNameList,get_current_dir_name() );
- gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() );
+ gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() );
return;
}
@@ -462,7 +480,7 @@ static void fs_Ok_released( GtkButton *
guiIntfStruct.FilenameChanged=1; sub_fps=0;
gfree( (void **)&guiIntfStruct.AudioFile );
gfree( (void **)&guiIntfStruct.Subtitlename );
- fs_PersistantHistory( fsSelectedDirectory ); //totem, write into history
+ fs_PersistantHistory( get_current_dir_name_utf8() ); //totem, write into history
break;
case fsSubtitleSelector:
guiSetDF( guiIntfStruct.Subtitlename,fsSelectedDirectory,fsSelectedFile );
@@ -497,13 +515,16 @@ static void fs_Ok_released( GtkButton *
static void fs_Cancel_released( GtkButton * button,gpointer user_data )
{
HideFileSelect();
- fs_PersistantHistory( get_current_dir_name() ); //totem, write into history file
+ fs_PersistantHistory( get_current_dir_name_utf8() ); //totem, write into history file
}
static void fs_fsFNameList_select_row( GtkWidget * widget, gint row, gint column,
GdkEventButton *bevent, gpointer user_data)
{
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( bevent && bevent->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) );
}
@@ -526,6 +547,13 @@ static gboolean on_FileSelect_key_releas
return FALSE;
}
+static void fs_Destroy( void )
+{
+ g_free( fsSelectedFileUtf8 );
+ fsSelectedFileUtf8 = NULL;
+ WidgetDestroy( fsFileSelect, &fsFileSelect );
+}
+
GtkWidget * create_FileSelect( void )
{
GtkWidget * vbox4;
@@ -635,7 +663,7 @@ GtkWidget * create_FileSelect( void )
fsOk=AddButton( MSGTR_Ok,hbuttonbox3 );
fsCancel=AddButton( MSGTR_Cancel,hbuttonbox3 );
- gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&fsFileSelect );
+ gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( fs_Destroy ), NULL );
gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL );
gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo );
Modified: trunk/gui/mplayer/gtk/pl.c
==============================================================================
--- trunk/gui/mplayer/gtk/pl.c Tue Jan 18 11:57:52 2011 (r32794)
+++ trunk/gui/mplayer/gtk/pl.c Tue Jan 18 12:30:46 2011 (r32795)
@@ -174,13 +174,18 @@ void ShowPlayList( void )
gtk_clist_clear( GTK_CLIST( CLSelected ) );
if ( plList )
{
+ gchar * name, * path;
plItem * next = plList;
while ( next || next->next )
{
char * text[1][3]; text[0][2]="";
- text[0][0]=next->name;
- text[0][1]=next->path;
+ 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;
gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
+ g_free( path );
+ g_free( name );
NrOfSelected++;
if ( next->next ) next=next->next; else break;
}
@@ -236,8 +241,8 @@ static void plButtonReleased( GtkButton
item=calloc( 1,sizeof( plItem ) );
gtk_clist_get_text( GTK_CLIST( CLSelected ),i,0,&text[0] );
gtk_clist_get_text( GTK_CLIST( CLSelected ),i,1,&text[1] );
- item->name=strdup( text[0] );
- item->path=strdup( text[1] );
+ item->name=g_filename_from_utf8( text[0], -1, NULL, NULL, NULL );
+ item->path=g_filename_from_utf8( text[1], -1, NULL, NULL, NULL );
gtkSet( gtkAddPlItem,0,(void*)item );
}
if ( plCurrent )
@@ -279,6 +284,7 @@ static void plButtonReleased( GtkButton
{
int i;
char * itext[1][2];
+ gchar * cpath;
char * text[1][3]; text[0][2]="";
gtk_clist_freeze( GTK_CLIST( CLSelected ) );
for ( i=0;i<NrOfEntrys;i++ )
@@ -286,8 +292,10 @@ static void plButtonReleased( GtkButton
if ( CLFileSelected[i] )
{
gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,(char **)&itext );
- text[0][0]=itext[0][0]; text[0][1]=current_path;
+ cpath=g_filename_to_utf8( current_path, -1, NULL, NULL, NULL );
+ text[0][0]=itext[0][0]; text[0][1]=cpath;
gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
+ g_free( cpath );
NrOfSelected++;
CLListSelected=realloc( CLListSelected,NrOfSelected * sizeof( int ) );
CLListSelected[NrOfSelected - 1]=0;
@@ -328,7 +336,7 @@ static void plCTree( GtkCTree * ctree,Gt
{
GtkCTreeNode * node;
DirNodeType * DirNode;
- gchar * text;
+ gchar * text, * name = NULL;
gchar * dummy = "dummy";
int subdir = 1;
DIR * dir = NULL;
@@ -352,12 +360,14 @@ static void plCTree( GtkCTree * ctree,Gt
if ( !strcmp( current_path,"/" ) ) sprintf( path,"/%s",dirent->d_name );
else sprintf( path,"%s/%s",current_path,dirent->d_name );
text=dirent->d_name;
+ g_free( name );
+ name=g_filename_to_utf8( text, -1, NULL, NULL, NULL );
if ( stat( path,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) && dirent->d_name[0] != '.' )
{
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,&text,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE );
+ node=gtk_ctree_insert_node( ctree,parent_node,NULL,&name,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 );
}
@@ -369,6 +379,8 @@ static void plCTree( GtkCTree * ctree,Gt
gtk_ctree_sort_node( ctree,parent_node );
gtk_clist_thaw( GTK_CLIST( ctree ) );
}
+
+ g_free( name );
}
static void scan_dir( char * path )
@@ -377,6 +389,7 @@ static void scan_dir( char * path )
char * curr;
struct dirent * dirent;
struct stat statbuf;
+ gchar * name;
char * text[1][2]; text[0][1]="";
gtk_clist_clear( GTK_CLIST( CLFiles ) );
@@ -388,8 +401,10 @@ static void scan_dir( char * path )
curr=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); sprintf( curr,"%s/%s",path,dirent->d_name );
if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) )
{
- text[0][0]=dirent->d_name;
- gtk_clist_append( GTK_CLIST( CLFiles ),text[0] );
+ name=g_filename_to_utf8( dirent->d_name, -1, NULL, NULL, NULL );
+ text[0][0]=name;
+ gtk_clist_append( GTK_CLIST( CLFiles ), text[0] );
+ g_free( name );
NrOfEntrys++;
}
free( curr );
More information about the MPlayer-cvslog
mailing list