Changeset 238:380bad9f6852 for dwt/widgets/FileDialog.d
- Timestamp:
- 05/04/08 18:42:55 (4 years ago)
- Files:
-
- dwt/widgets/FileDialog.d (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/widgets/FileDialog.d
r200 r238 44 44 */ 45 45 public class FileDialog : Dialog { 46 char[][] filterNames;47 char[][] filterExtensions;48 char[]filterPath = "";49 char[]fileName = "";50 char[][] fileNames;51 char[]fullPath = "";46 String [] filterNames; 47 String [] filterExtensions; 48 String filterPath = ""; 49 String fileName = ""; 50 String[] fileNames; 51 String fullPath = ""; 52 52 GtkWidget* handle; 53 53 static final char SEPARATOR = tango.io.FileConst.FileConst.PathSeparatorChar; … … 98 98 checkSubclass (); 99 99 } 100 char[]computeResultChooserDialog () {100 String computeResultChooserDialog () { 101 101 /* MULTI is only valid if the native dialog's action is Open */ 102 102 fullPath = null; … … 104 104 auto list = OS.gtk_file_chooser_get_filenames (handle); 105 105 int listLength = OS.g_slist_length (list); 106 fileNames = new char[][listLength];106 fileNames = new String [listLength]; 107 107 auto current = list; 108 108 int writePos = 0; … … 122 122 } 123 123 if (writePos !is 0 && writePos !is listLength) { 124 char[] [] validFileNames = new char[][writePos];124 String [] validFileNames = new String [writePos]; 125 125 System.arraycopy (fileNames, 0, validFileNames, 0, writePos); 126 126 fileNames = validFileNames; … … 135 135 if (utf8Ptr !is null) { 136 136 fullPath = utf8Ptr[ 0 .. items_written ].dup; 137 fileNames = new char[][1];137 fileNames = new String [1]; 138 138 int start = tango.text.Util.locatePrior( fullPath, SEPARATOR); 139 139 if( start == fullPath.length ) start = -1; … … 151 151 return fullPath; 152 152 } 153 char[]computeResultClassicDialog () {153 String computeResultClassicDialog () { 154 154 GtkFileSelection* selection = cast(GtkFileSelection*)handle; 155 155 auto entry = selection.selection_entry; 156 156 auto entryText = OS.gtk_entry_get_text (entry); 157 char[]txt = tango.stdc.stringz.fromStringz( entryText );157 String txt = tango.stdc.stringz.fromStringz( entryText ); 158 158 if (txt.length is 0) { 159 159 auto fileList = selection.file_list; … … 185 185 uint items_written; 186 186 auto utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, &items_written, null); 187 char[]osAnswer = utf8Ptr[ 0 .. items_written ].dup;187 String osAnswer = utf8Ptr[ 0 .. items_written ].dup; 188 188 OS.g_free (utf8Ptr); 189 189 … … 193 193 if (separatorIndex+1 is osAnswer.length ) return null; 194 194 195 char[]answer = fullPath = osAnswer;195 String answer = fullPath = osAnswer; 196 196 fileName = fullPath[ separatorIndex+1 .. $ ]; 197 197 filterPath = fullPath[ 0 .. separatorIndex ]; … … 207 207 namePtr = namesPtr1[length_]; 208 208 } 209 fileNames = new char[][](length_);209 fileNames = new String[](length_); 210 210 for (int i = 0; i < length_; i++) { 211 211 utf8Ptr = OS.g_filename_to_utf8 (namesPtr [i], -1, null, &items_written, null); 212 char[]name = utf8Ptr[ 0 .. items_written ].dup;212 String name = utf8Ptr[ 0 .. items_written ].dup; 213 213 int start = tango.text.Util.locatePrior( name, SEPARATOR); 214 214 if( start == name.length ) start = -1; … … 227 227 * @return the relative path of the file 228 228 */ 229 public char[]getFileName () {229 public String getFileName () { 230 230 return fileName; 231 231 } … … 236 236 * @return the relative paths of the files 237 237 */ 238 public char[][] getFileNames () {238 public String [] getFileNames () { 239 239 return fileNames; 240 240 } … … 245 245 * @return the file extensions filter 246 246 */ 247 public char[][] getFilterExtensions () {247 public String [] getFilterExtensions () { 248 248 return filterExtensions; 249 249 } … … 254 254 * @return the list of filter names 255 255 */ 256 public char[][] getFilterNames () {256 public String [] getFilterNames () { 257 257 return filterNames; 258 258 } … … 266 266 * @see #setFilterExtensions 267 267 */ 268 public char[]getFilterPath () {268 public String getFilterPath () { 269 269 return filterPath; 270 270 } … … 281 281 * </ul> 282 282 */ 283 public char[]open () {283 public String open () { 284 284 bool useChooserDialog = OS.GTK_VERSION >= OS.buildVERSION (2, 4, 10); 285 285 if (useChooserDialog) { … … 289 289 } 290 290 } 291 char[]openChooserDialog () {291 String openChooserDialog () { 292 292 char* titleBytes = tango.stdc.stringz.toStringz( title ); 293 293 int action = (style & DWT.SAVE) !is 0 ? … … 309 309 Display display = parent !is null ? parent.getDisplay (): Display.getCurrent (); 310 310 display.addIdleProc (); 311 char[]answer = null;311 String answer = null; 312 312 if (OS.gtk_dialog_run (handle) is OS.GTK_RESPONSE_OK) { 313 313 answer = computeResultChooserDialog (); … … 317 317 return answer; 318 318 } 319 char[]openClassicDialog () {319 String openClassicDialog () { 320 320 char* titleBytes = tango.stdc.stringz.toStringz( title ); 321 321 handle = OS.gtk_file_selection_new (titleBytes); … … 332 332 Display display = parent !is null ? parent.getDisplay (): Display.getCurrent (); 333 333 display.addIdleProc (); 334 char[]answer = null;334 String answer = null; 335 335 if (OS.gtk_dialog_run (handle) is OS.GTK_RESPONSE_OK) { 336 336 answer = computeResultClassicDialog (); … … 412 412 int index = tango.text.Util.locate( filterExtensions [i], EXTENSION_SEPARATOR ); 413 413 while (index !is filterExtensions [i].length ) { 414 char[]current = filterExtensions [i][ start .. index ];414 String current = filterExtensions [i][ start .. index ]; 415 415 char* filterString = tango.stdc.stringz.toStringz(current); 416 416 OS.gtk_file_filter_add_pattern (filter, filterString); … … 418 418 index = tango.text.Util.locate( filterExtensions [i], EXTENSION_SEPARATOR, start); 419 419 } 420 char[]current = filterExtensions [i][ start .. $ ];420 String current = filterExtensions [i][ start .. $ ]; 421 421 char* filterString = tango.stdc.stringz.toStringz(current); 422 422 OS.gtk_file_filter_add_pattern (filter, filterString); … … 465 465 * @param string the file name 466 466 */ 467 public void setFileName ( char[]string) {467 public void setFileName (String string) { 468 468 fileName = string; 469 469 } … … 483 483 * names corresponding to the extensions 484 484 */ 485 public void setFilterExtensions ( char[][] extensions) {485 public void setFilterExtensions (String [] extensions) { 486 486 filterExtensions = extensions; 487 487 } … … 500 500 * @see #setFilterExtensions 501 501 */ 502 public void setFilterNames ( char[][] names) {502 public void setFilterNames (String [] names) { 503 503 filterNames = names; 504 504 } … … 520 520 * @see #setFilterExtensions 521 521 */ 522 public void setFilterPath ( char[]string) {522 public void setFilterPath (String string) { 523 523 filterPath = string; 524 524 }
