[MPlayer-cvslog] r33875 - trunk/gui/ui/gtk/fileselect.c

ib subversion at mplayerhq.hu
Mon Jul 11 16:54:25 CEST 2011


Author: ib
Date: Mon Jul 11 16:54:25 2011
New Revision: 33875

Log:
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.

Modified:
   trunk/gui/ui/gtk/fileselect.c

Modified: trunk/gui/ui/gtk/fileselect.c
==============================================================================
--- trunk/gui/ui/gtk/fileselect.c	Mon Jul 11 14:40:30 2011	(r33874)
+++ trunk/gui/ui/gtk/fileselect.c	Mon Jul 11 16:54:25 2011	(r33875)
@@ -53,6 +53,7 @@ char * get_current_dir_name( void );
 gchar         * fsSelectedFile = NULL;
 gchar         * fsSelectedFileUtf8 = NULL;
 gchar         * fsSelectedDirectory = NULL;
+gchar         * fsSelectedDirectoryUtf8 = NULL;
 unsigned char * fsThatDir = ".";
 const gchar   * fsFilter = "*";
 
@@ -248,8 +249,8 @@ static void CheckDir( GtkWidget * list )
 
 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 @@ void ShowFileSelect( int type,int modal 
 	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 @@ void ShowFileSelect( int type,int modal 
      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 && dir )
+   {
+     g_free( fsSelectedDirectoryUtf8 );
+     fsSelectedDirectoryUtf8=g_filename_to_utf8( dir, -1, NULL, NULL, NULL );
+     fsTopList_items=g_list_prepend( fsTopList_items,fsSelectedDirectoryUtf8 );
    }
-  if ( c ) fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name_utf8() );
  }
+ 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 @@ static void fs_Destroy( void )
 {
  g_free( fsSelectedFileUtf8 );
  fsSelectedFileUtf8 = NULL;
+ g_free( fsSelectedDirectoryUtf8 );
+ fsSelectedDirectoryUtf8 = NULL;
  WidgetDestroy( fsFileSelect, &fsFileSelect );
 }
 


More information about the MPlayer-cvslog mailing list