Function: GgiFileBrowser Purpose: Ggi element for browsing directories and selecting files Category: USER-INTERFACE File: ggi.src Author: J.P. Terlouw Use: #include "ggi.h" ident element; int opcode; element = GgiFileBrowser(opcode, ...); ... is a variable argument list of which the elements depend on the value of opcode. The following variants exist: - create the element: element = GgiFileBrowser(ggiCreate, key, message, converter); char *key - keyword receiving file name char message - explanatory message GgiNameconverterProc converter - converter function pointer or NULL. prototype: char *function(char *) - delete the element: (void)GgiFileBrowser(ggiDelete, element); ident element - element to be deleted - find existing element, given file name keyword: element = GgiFileBrowser(ggiIdent, name); char *name - user input keyword for file name - set immediate selection; no OK button: element = GgiFileBrowser(ggiNowait, element); ident element - element to be modified - set immediate close after selection: element = GgiFileBrowser(ggiCloseOnOK, element); ident element - element to be modified - specify name converter function for detailed information: element = GgiFileBrowser(ggiFileInfo, element, proc); ident element - element to be modified GgiNameconverterProc proc - name converter Description: GgiFileBrowser creates or manipulates a pop-up window for browsing directories and selecting files. It consists of an input/output field for the current directory, two panes, an input/output field for resulting file name a close-button and an optional ok-button. The left pane lists all directories in the current directory and the right page lists the file names, possibly filtered by the optional converter function. The browser allows the user to specify a directory either by typing in the directory field or by selecting it in the left pane. Likewise, a name can be typed in the file name field or selected in the right pane. If an ok-button is present, this must be pressed first before the name becomes effective, i.e. before it is written to the output keyword. The function specified through the argument 'converter' enables the programmer to select and/or modify the file names found in the current directory. If this function returns NULL for a particular argument, no reference to this file will be included in the list. Modifying a file name can be useful for chopping off the filename 'extension'. The following example converter function selects GDS sets and chops off the .descr extension: static char *setnames(char *name) { int namlen=strlen(name); static char result[FILENAME_MAX]; if (namlen<7) return NULL; if (strcmp(name+namlen-6, ".descr")) return NULL; strcpy(result, name); result[namlen-6] = '\0'; return result; } If a converter for detailed information has been specified, the element will receive an extra button labelled "DETAILS". When this button is depressed, the right pane will display the information generated by the converter. This function is called with the possibly already filtered and modified name. The result of a selection from the list is not affected by the format of the list entries. Keywords: All keywords beginning with "_GGIFB" are reserved for internal use by GgiFileBrowser. Updates: Nov 25, 1999: JPT, Document created. Dec 9, 1999: JPT, Improved internal keyword scheme. Mar 30, 2000: JPT, Immediate close implemented. Jul 11, 2000: JPT, Use keyword identifiers. Jul 21, 2000: JPT, Detailed information converter implemented.