@begin(header)
author: ackerman=ag@.ics.uci.edu
show_author: ShowNone
author_organization: Harvard X Class
node_expert: ackerman=ag@ics.uci.edu 
expiration_date: 11/25/93
last_modifier: ackerman=ag@.ics.uci.edu
last_mod_date: 11/25/91
mod_num: 1
@end(header)
-------------------------
File Selection Box Widget
-------------------------

@begin(Q)
What is libPW.a and do I need it?  My manual says I need to link in
libPW.a to use the File Selection Box.  I can't find it on my system.
@end(Q)

@begin(A)
The libPW.a is the Programers Workbench library which is an ATT
product not included in Berkeley based systems, hence it is not found
in SunOS or Ultrix, but is found on HP-UX (a Berkeley/ATT hybrid which
chose ATT in this case).  It contains the regex(3) routines.  Some
systems which don't have these in the libc.a need to link with -lPW.
Some systems which have the regex(3) routines in there also have the
libPW.a.  If you have regex(3) in libc, and it works, don't link with
libPW.  If you don't have regex(3) in libc, and you don't have a
libPW, then check some sites on the net for public domain replacements
(several exist), or call your vendor.

In most versions of Motif (see the doco), you can compile FileSB.c
with -DNO_REGEX if you don't have it.

				Motif FAQ 8/12/91
@end(A)

@begin(Q)
What's wrong with the Motif 1.0 File Selection Box?  I can't set the
directory, change the directory or get the file mask to work.
@end(Q)

@begin(A)
The 1.0 File Selection Box is broken, and these don't work.  They
weren't fixed until Motif 1.04.  Use these later versions of 1.0 or
switch to Motif 1.1 where it changed a lot.

Joe Hildebrand has a work-around for some of this: Before popping up
an XmFileSelectionDialog, change to the directory you want.  When a
file is selected, check if it is a directory, so that we can change to
it.  i.e.

static void show_file_box_CB(w, client_data, call_data)
   Widget               w;
   Widget               client_data;
   XmAnyCallbackStruct  *call_data;
{
   chdir("/users/hildjj/files");
   XtManageChild(client_data);
}

static void val_save(w, client_data, call_data)
   Widget       w;
   Widget       client_data;
   XmSelectionBoxCallbackStruct *call_data;
{
   struct stat buf;  /* struct stat is defined in stat.h */
   char *filename;

   /* get the file name from the FileSelectionBox */
   filename = SmX(call_data->value);

   /* get the status of the file named filename, and put it into buf */
   if (!stat(filename, &buf))
   {
      /* if it's a directory */
      /* if it's a directory */
      if(S_ISDIR(buf.st_mode))
      {
         /* change to that directory, and update the FileSelectionBox */
        chdir(filename);
        XmFileSelectionDoSearch(w, NULL);
      }
      else
         /* if it's a regualr file */
         if(S_ISREG(buf.st_mode))
            /* ask if it should be overwritten */
            XtManageChild(valbox);
         else
            /* it's another kind of file.  What type, i can't think of,
               but it might happen */
            pop_up_error_box(client_data, "Error saving file");
   }
   else  /* we couldn't get the file status */
   {
      /* if it's because the file doesn't exist, we're golden */
      if (errno == ENOENT)
         save_file();
      else   /* there is some other problem getting the status.
                e.g. bad path */
         pop_up_error_box(client_data, "Error saving file");
   }
}

this still doesn't implement the file masking stuff.


				Motif FAQ 8/12/91
@end(A)
