# HG changeset patch # User ib # Date 1310396065 0 # Node ID 42feff0f8a7bd738afcaf630d4cd1e7f52372398 # Parent 0d3d8db05a594cec628eb9e4314c7959a590ce0b Start all file dialogs always in last active directory. This starts the "add subtitle" and "add external audio" dialogs in the directory of the chosen or started movie. Don't change the directory just to retrieve its name and prepend the active directory instead of appending it. This closes Bugzilla #977. diff -r 0d3d8db05a59 -r 42feff0f8a7b gui/ui/gtk/fileselect.c --- a/gui/ui/gtk/fileselect.c Mon Jul 11 12:40:30 2011 +0000 +++ b/gui/ui/gtk/fileselect.c Mon Jul 11 14:54:25 2011 +0000 @@ -53,6 +53,7 @@ gchar * fsSelectedFile = NULL; gchar * fsSelectedFileUtf8 = NULL; gchar * fsSelectedDirectory = NULL; +gchar * fsSelectedDirectoryUtf8 = NULL; unsigned char * fsThatDir = "."; const gchar * fsFilter = "*"; @@ -248,8 +249,8 @@ void ShowFileSelect( int type,int modal ) { - int i, k; - char * tmp = NULL; + int i, k, fsMedium; + char * tmp = NULL, * dir = NULL; if ( fsFileSelect ) gtkActive( fsFileSelect ); else fsFileSelect=create_FileSelect(); @@ -313,10 +314,14 @@ break; } + fsMedium=(fsType == fsVideoSelector || fsType == fsSubtitleSelector || fsType == fsAudioSelector); + + if ( !tmp && fsMedium ) tmp=guiInfo.Filename; + if ( tmp && tmp[0] ) { struct stat f; - char * dir = strdup( tmp ); + dir = strdup( tmp ); do { @@ -326,22 +331,27 @@ if ( c ) *c=0; } while ( strrchr( dir,'/' ) ); - if ( dir[0] ) chdir( dir ); - - free( dir ); + if ( !dir[0] ) nfree( dir ); } if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL; { unsigned int i, c = 1; - if ( fsType == fsVideoSelector ) + + if ( fsMedium ) { for ( i=0;i < FF_ARRAY_ELEMS(fsHistory);i++ ) - if ( fsHistory[i] ) { fsTopList_items=g_list_append( fsTopList_items,fsHistory[i] ); c=0; } + if ( fsHistory[i] ) { fsTopList_items=g_list_append( fsTopList_items,fsHistory[i] ); if ( c ) c=gstrcmp( dir,fsHistory[i] ); } } - if ( c ) fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name_utf8() ); + if ( c && dir ) + { + g_free( fsSelectedDirectoryUtf8 ); + fsSelectedDirectoryUtf8=g_filename_to_utf8( dir, -1, NULL, NULL, NULL ); + fsTopList_items=g_list_prepend( fsTopList_items,fsSelectedDirectoryUtf8 ); + } } + free( dir ); if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); fsTopList_items=g_list_append( fsTopList_items,"/home" ); fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); @@ -582,6 +592,8 @@ { g_free( fsSelectedFileUtf8 ); fsSelectedFileUtf8 = NULL; + g_free( fsSelectedDirectoryUtf8 ); + fsSelectedDirectoryUtf8 = NULL; WidgetDestroy( fsFileSelect, &fsFileSelect ); }