if (!XmStringGetLtoR (cbs−>value, XmFONTLIST_DEFAULT_TAG, &filename))
return; /* must have been an internal error */
if (!*filename) { /* nothing typed? */
puts ("No file selected.");
XtFree( filename); /* even "" is an allocated byte */
return;
}
printf ("Filename given:
XtFree (filename);
}
The program simply prints the selected file when the user activates the OK button. The user can change the file by
selecting an item from the files list or by typing directly in the selection text entry area. The user can also activate the
dialog by double−clicking on an item in the files list. The FileSelectionDialog itself is very simple to create; most of
the work in the program is done by the callback routine for the OK button.
7.5.2 Internal Widgets
A FileSelectionDialog is made up of a number of subwidgets, including Text, List, and PushButton widgets. You can
get the handles to these children using the routine XmFileSelectionBoxGetChild(), which takes the
following form:
Widget
XmFileSelectionBoxGetChild(widget, child)
XmFileSelectionBox widget;
unsigned char child;
The widget parameter is a handle to a dialog widget, not its DialogShell parent. The child parameter is an
enumerated value that specifies a particular subwidget in the dialog. The parameter can have any one of the following
values:
XmDIALOG_APPLY_BUTTON
XmDIALOG_CANCEL_BUTTON
XmDIALOG_DEFAULT_BUTTON
XmDIALOG_DIR_LIST
XmDIALOG_DIR_LIST_LABEL
XmDIALOG_FILTER_LABEL
XmDIALOG_FILTER_TEXT
XmDIALOG_HELP_BUTTON
XmDIALOG_LIST
XmDIALOG_LIST_LABEL ...