(subclass of 9.1.3.30 XList)
In contrast to the Xlist a FileList is filled with data automatically. The only information needed are the path, a wildcard for the file names and the open mode, which specifies if the files need to be readable, writable or both. If the user has finished his selection, the FileList will call a method on an instance, both defined from the programmer. This method gets a pointer to the FileList as a parameter. Using this parameter, for example named fl, the called method can determine which item was chosen by the user. The selection can be found in fl->chosen. If the user canceled the selection, using the cancel-button, fl->chosen will be equal to NULL. If the FileList is implemented as an overlay menu in its own layer, the helper function g_hide_layer will automatically hide the layer of the FileList. A FileList which is created using XList_Button- "new-for-filelist" has got its own layer, so the above helper functions can be used.
typedef enum open_mode { omRead, omWrite, omWriteRead } OPEN_MODE;
Example: a Button which pops up a FileList to read data of instance inst.
INST *inst_file_selected (FILELIST *filelist) { ... if (filelist->chosen) { ... /* Read data from the standard TextDevice */ } else { /* User pressed "Cancel" or file doesn't exist */ } g_hide_layer ((ITEM *)filelist); ... } { XLIST_BUTTON *button; button = (XLIST_BUTTON *) GRAPE (XList_Button, "new-for-filelist") ("file-selected", inst, "Load File", "get-files", "*.st", omRead); }
Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.