Mercurial > mplayer.hg
changeset 35925:59c6618f384b
Support mixed filename encodings.
This also supports falsely stated filename encodings.
Part 1 of 3: file selector file list.
In order for the filenames to look readable, it's necessary to
set G_FILENAME_ENCODING (for non-UTF8 or mixed encodings only).
Based on a patch by reimar.
author | ib |
---|---|
date | Tue, 19 Mar 2013 17:18:59 +0000 |
parents | d16e3d64b946 |
children | eab9c3e8a565 |
files | gui/dialog/fileselect.c |
diffstat | 1 files changed, 7 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/dialog/fileselect.c Tue Mar 19 16:50:29 2013 +0000 +++ b/gui/dialog/fileselect.c Tue Mar 19 17:18:59 2013 +0000 @@ -53,8 +53,7 @@ char * get_current_dir_name( void ); #endif -gchar * fsSelectedFile = NULL; -gchar * fsSelectedFileUtf8 = NULL; +char * fsSelectedFile = NULL; gchar * fsSelectedDirectory = NULL; gchar * fsSelectedDirectoryUtf8 = NULL; unsigned char * fsThatDir = "."; @@ -173,13 +172,13 @@ static void clist_append_fname(GtkWidget * list, char *fname, GdkPixmap *pixmap, GdkPixmap *mask) { gint pos; - gchar *filename_utf8, *str[2]; - filename_utf8 = g_filename_to_utf8(fname, -1, NULL, NULL, NULL); + gchar *str[2]; str[0] = NULL; - str[1] = filename_utf8 ? filename_utf8 : fname; + str[1] = g_filename_display_name(fname); pos = gtk_clist_append(GTK_CLIST(list), str); + gtk_clist_set_row_data_full(GTK_CLIST(list), pos, strdup(fname), free); gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask); - g_free(filename_utf8); + g_free(str[1]); } static void CheckDir( GtkWidget * list ) @@ -560,10 +559,7 @@ GdkEvent * event, gpointer user_data) { fsCurrFNameListSelected = row; - gtk_clist_get_text( clist,row,1,&fsSelectedFile ); - g_free( fsSelectedFileUtf8 ); - fsSelectedFileUtf8 = g_filename_from_utf8( fsSelectedFile, -1, NULL, NULL, NULL ); - if ( fsSelectedFileUtf8 ) fsSelectedFile = fsSelectedFileUtf8; + fsSelectedFile = gtk_clist_get_row_data(clist, row); if( event && event->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); } @@ -607,10 +603,7 @@ { if ( gtk_clist_get_selection_info( GTK_CLIST( widget ), bevent->x, bevent->y, &row, &col ) ) { - gtk_clist_get_text( GTK_CLIST( widget ), row, 1, &fsSelectedFile ); - g_free( fsSelectedFileUtf8 ); - fsSelectedFileUtf8 = g_filename_from_utf8( fsSelectedFile, -1, NULL, NULL, NULL ); - if ( fsSelectedFileUtf8 ) fsSelectedFile = fsSelectedFileUtf8; + fsSelectedFile = gtk_clist_get_row_data(GTK_CLIST(widget), row); gtk_button_released( GTK_BUTTON( fsOk ) ); return TRUE; } @@ -621,8 +614,6 @@ static void fs_Destroy( void ) { - g_free( fsSelectedFileUtf8 ); - fsSelectedFileUtf8 = NULL; g_free( fsSelectedDirectoryUtf8 ); fsSelectedDirectoryUtf8 = NULL; WidgetDestroy( fsFileSelect, &fsFileSelect );