next up previous contents index
Next: Function_Bar1d Up: Classes and Methods Previous: Cycle_Button

FileList

  (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);
}

   GRAPE(filelist, "get-files")()
FILELIST *filelist
Default method to be used as directory reading method, to fill the FileList.

   GRAPE(FileList, "new-instance")(meth, inst, name, ext, fmodus)
CLASS *FileList
char *meth
INSTANCE *inst
char *name
char *ext
OPEN_MODE fmodus
Creates a new FileList, which will show all files matching the wildcard ext. If a file is selected, the method meth will be send to the instance inst. The easiest way to use a FileList is to use XList_Button- "new-for-filelist".

   GRAPE(filelist, "share-path")(other)
FILELIST *filelist, * other
filelist and other share one path variable now. This is good for coupled read/write lists like in the manag menu.


next up previous contents index
Next: Function_Bar1d Up: Classes and Methods Previous: Cycle_Button

SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.