(2012-01-21) (Matt)
openjdk/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c
The intent of this patch is to cause the FileDialog to return the
full path
information when used on gtk+3, where multiple files can be selected
that have different paths.
I have been careful about writing these changes, but I do not have
a build chain setup to compile the native source. The expected behavior
is that when files are selected from "Recently Used" the
'current_directory'
is set to NULL. When this happens the returned values will be, the
root
directory, '/', and the filenames will contain complete path
information.
Without this patch, the 'current_directory' is set to null. Then
the files returned
will have the cwd + filename. The consequence is that 'Recent
Files' cannot
be used with the awt.FileDialog.
(sunbug=7132194)
173a174,217
> /**
> * Convert a GSList to an array of filenames (with the parent folder)
> */
> static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list)
> {
> jstring str;
> jclass stringCls;
> GSList *iterator;
> jobjectArray array;
> int i;
> char* entry;
>
>
> if (NULL == list) {
> return NULL;
> }
>
> stringCls = (*env)->FindClass(env, "java/lang/String");
> if (stringCls == NULL) {
> JNU_ThrowInternalError(env, "Could not get java.lang.String class");
> return NULL;
> }
>
> array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list),
> stringCls,
> NULL);
> if (array == NULL) {
> JNU_ThrowInternalError(env, "Could not instantiate array files
> array");
> return NULL;
> }
>
> i = 0;
> for (iterator = list; iterator; iterator = iterator->next) {
> entry = (char*) iterator->data;
> //check for leading slash.
> if( (entry-strchr(entry, '/')) == 0) entry++;
>
> str = (*env)->NewStringUTF(env, entry);
> (*env)->SetObjectArrayElement(env, array, i, str);
> i++;
> }
>
> return array;
> }
>
186c230,231
<
---
> bool full_path_names = FALSE;
>
189a235,237
> if(NULL == current_folder){
> full_path_names=TRUE;
> }
192,195c240,249
<
< jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
< jfilenames = toFilenamesArray(env, filenames);
<
---
> if(full_path_names){
> //This is a hack for use with "Recent Folders" in gtk where each
> //file could have its own directory.
> jcurrent_folder = (*env)->NewStringUTF(env, "/");
> jfilenames = toPathAndFilenamesArray(env, filenames);
>
> } else{
> jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
> jfilenames = toFilenamesArray(env, filenames);
> }