widget = XtCreatePopupShell(name, fileSelectorWidgetClass, ...);
This widget can either be used as a stand-alone widget with it own OK and Cancel buttons, or as part of a larger widget. When used as part of a larger composite widget, the OK and Cancel buttons can be turned off and replaced by global ter mination buttons for the larger widget.
The File Selector has two scrolled text lists side by side. The left list contains the current directory path from the root to the current directory, listed one directory per line. The right list shows the files in the current direc tory that pass a user-specified filter function, and are sorted by a user specified sorting order. Files can be selected by typing them in by clicking on the appropriate file in the right list. Clicking on a directory will enter that directory and list its files and directories.
The source code in the Dir directory of the FWF distribution contains system-independent file listing functions that are required by FileSelector.
The XtNflagLinks resource allows symbolic links to be spe cially identified with an `@' sign after the file name. This identification is only done if XtNflagLinks is true.
The XtNcheckExistence resource determines whether file names have to exist before they can be selected. Typically this resource is set to True when searching for a file to read or modify, but set to False if the user should be able to enter new file names.
XtNfileSelected is a read only resource which indicates if a file is currently selected. XtNcurrentDirectory and XtNcur rentFile allow the current path and file name to be speci fied. The title of the file selector is specified via XtNtitle.
The filter pattern is specified in the string XtNpattern. The method used to sort the file list is specified in XtNsortMode. The sort mode is encoded as an integer. The integers are defined in the DirMgr.h file which is part of the libDir directory management package included in the FWF release. Sample XtNsortMode values are depicted below:
typedef struct _XfwfFileSelectorOkButtonReturnStruct
{
char *path;
char *file;
char *file_box_text;
} XfwfFileSelectorOkButtonReturnStruct;
typedef struct _XfwfFileSelectorSelectionChangeReturnStruct
{
Boolean file_selected;
char *path;
char *file;
} XfwfFileSelectorSelectionChangeReturnStruct;
This routine changes the current directory of the File Selector widget <fsw> to be the directory <dir>.
void XfwfFileSelectorRefresh(fsw)
XfwfFileSelectorWidget fsw;
This routine causes the FileSelector widget to re-read the current directory, refreshing the widget. Changes to the file system will not automatically propogate to the widget. This routine forces the refresh.
void XfwfFileSelectorGetStatus(fsw,ssp)
XfwfFileSelectorWidget fsw;
XfwfFileSelectorStatusStruct *ssp;
This routine obtains current information form the File Selector widget pertaining to the selection state of the widget. The structure pointed to by <ssp> is filled in with the currently selected file and direc tory, as well as the current contents of the file box text. This routine allows status information to be queried from the widget at any time. The structure <ssp> which is passed into the routine is described below:
typedef struct _XfwfFileSelectorStatusStruct
{
Boolean file_selected;
char *path;
char *file;
char *file_box_text;
} XfwfFileSelectorStatusStruct;