int length = OS.strlen (ptr); buffer = new byte [length]; OS.memmove (buffer, ptr, length); OS.gtk_file_chooser_set_filename (handle, buffer);
OS.gtk_file_chooser_set_filename (handle, ptr);
void presetChooserDialog () {	/* MULTI is only valid if the native dialog's action is Open */   	if ((style & (SWT.SAVE | SWT.MULTI)) == SWT.MULTI) {		OS.gtk_file_chooser_set_select_multiple (handle, true);	}	if (filterPath == null) filterPath = "";	if (fileName == null) fileName = "";	if (filterPath.length () > 0) {		StringBuffer stringBuffer = new StringBuffer ();		/* filename must be a full path */		if (filterPath.charAt (0) != SEPARATOR) {			stringBuffer.append (SEPARATOR);		}		stringBuffer.append (filterPath);		if (filterPath.charAt (filterPath.length () - 1) != SEPARATOR) {			stringBuffer.append (SEPARATOR);		}		if (fileName.length () > 0) {			stringBuffer.append (fileName);		} else {			/* go into the specified directory */			stringBuffer.append ('.');		}		byte [] buffer = Converter.wcsToMbcs (null, stringBuffer.toString (), true);		/*		* Bug in GTK. GtkFileChooser may crash on GTK versions 2.4.10 to 2.6		* when setting a file name that is not a true canonical path. 		* The fix is to use the canonical path.		*/		int /*long*/ ptr = OS.realpath (buffer, null);		if (ptr != 0) {			int length = OS.strlen (ptr);			buffer = new byte [length];			OS.memmove (buffer, ptr, length);			OS.gtk_file_chooser_set_filename (handle, buffer);			OS.g_free (ptr);		}	} else {		if (fileName.length () > 0) {			if (fileName.charAt (0) == SEPARATOR) {				byte [] buffer = Converter.wcsToMbcs (null, fileName, true);				/*				* Bug in GTK. GtkFileChooser may crash on GTK versions 2.4.10 to 2.6				* when setting a file name that is not a true canonical path. 				* The fix is to use the canonical path.				*/				int /*long*/ ptr = OS.realpath (buffer, null);				if (ptr != 0) {					int length = OS.strlen (ptr);					buffer = new byte [length];					OS.memmove (buffer, ptr, length);					OS.gtk_file_chooser_set_filename (handle, buffer);					OS.g_free (ptr);				}			}		}	}	if ((style & SWT.SAVE) != 0 && fileName.length () > 0) {		byte [] buffer = Converter.wcsToMbcs (null, fileName, true);		OS.gtk_file_chooser_set_current_name (handle, buffer);	}	/* Set the extension filters */	if (filterNames == null) filterNames = new String [0];	if (filterExtensions == null) filterExtensions = new String [0];	for (int i = 0; i < filterExtensions.length; i++) {		if (filterExtensions [i] != null) {			int /*long*/ filter = OS.gtk_file_filter_new ();			if (filterNames.length > i && filterNames [i] != null) {				byte [] name = Converter.wcsToMbcs (null, filterNames [i], true);				OS.gtk_file_filter_set_name (filter, name);			} else {				byte [] name = Converter.wcsToMbcs (null, filterExtensions [i], true);				OS.gtk_file_filter_set_name (filter, name);			}			int start = 0;			int index = filterExtensions [i].indexOf (EXTENSION_SEPARATOR);			while (index != -1) {				String current = filterExtensions [i].substring (start, index);				byte [] filterString = Converter.wcsToMbcs (null, current, true);				OS.gtk_file_filter_add_pattern (filter, filterString);				start = index + 1;				index = filterExtensions [i].indexOf (EXTENSION_SEPARATOR, start);			}			String current = filterExtensions [i].substring (start);			byte [] filterString = Converter.wcsToMbcs (null, current, true);			OS.gtk_file_filter_add_pattern (filter, filterString);			OS.gtk_file_chooser_add_filter (handle, filter);		}	}	fullPath = null;	fileNames = new String [0];}