Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

Motif FAQ (Part 5 of 9)
Section - 123) What's wrong with the Motif 1.0 File Selection Box? I can't

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Forum ]


Top Document: Motif FAQ (Part 5 of 9)
Previous Document: 122) What are these compile errors: Undefined symbol _regcmp and
Next Document: 124) How can I keep my file selection boxes from resizing when I
See reader questions & answers on this topic! - Help others by sharing your knowledge
set the directory, change the directory or get the file mask to work.

Answer: 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 regular 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.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:




Top Document: Motif FAQ (Part 5 of 9)
Previous Document: 122) What are these compile errors: Undefined symbol _regcmp and
Next Document: 124) How can I keep my file selection boxes from resizing when I

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
kenton@rahul.net (Ken Lee)





Last Update March 27 2014 @ 02:11 PM