gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog),(gchar *)str);
if( (dir=opendir(str)) ){ closedir(dir); gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog),(gchar *)str); }
void GUI_FileSel(const char *label, SELFILE_CB * cb, int rw,char **rname){				/* Create the selector */    	GtkWidget *dialog;	char *name=NULL;	char *tmpname;	gchar *selected_filename;	if(rname)		*rname=NULL;	dialog=create_fileselection1();	gtk_window_set_title (GTK_WINDOW (dialog),label);	gtk_transient(dialog);	if( prefs->get(LASTDIR,&tmpname))	{	//	printf("tmpname : %s\n",tmpname);		char *str=PathCanonize(tmpname);	//	printf("tmpname : %s\n",str);		PathStripName(str);	//	printf("tmpname : *%s*\n",str);		gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog),(gchar *)str);		delete [] str;	}	if(gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_OK)	{			selected_filename= (gchar *) 	gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog));			 if (*(selected_filename + strlen(selected_filename) - 1) == '/')      	  					GUI_Alert("Cannot open directory as file !");			else			{						name=strdup(selected_filename);						char *str=PathCanonize(name);						PathStripName(str);						prefs->set(LASTDIR,str);									delete [] str;			}	}	gtk_widget_destroy(dialog);	if(name)	{		if(cb)		{			if(rw==0) // read			{				// try to open it..				FILE *fd;				fd=fopen(name,"rb");				if(!fd)				{						GUI_Alert("Cannot open this file !");						return;				}				fclose(fd);				cb(name);				free(name);			}			else // write			{				FILE *fd;				fd=fopen(name,"rb");				if(fd)					{							fclose(fd);							if(!GUI_Question("Overwrite file ?"))								return;					}				// check we have right access to it				fd=fopen(name,"wb");				if(!fd)					{						GUI_Alert("No write access to that file !");						return;					}				fclose(fd);				cb(name);				free(name);			}		} // no callback -> return value		else		{			*rname=name;		}	}}