[comp.windows.x.motif] Motif examples

argv@Eng.Sun.COM (Dan Heller) (09/26/90)

[Adding motif-talk and comp.windows.x.motif to this discussion
 for possible feedback from others...]

On Sep 25,  1:24pm, Adrian wrote:
> > > Looking back at them now, I notice that they use a different
> > > technique for popping up widgets than I have been using
> > > with Motif 1.1.  I just use XtManageChild, not XtPopup.
> > 
> > XtPopup() is necessary if the routine is called more than once.
> > For example, when you create a dialog, it will be popped up
> > when you XtManageChild(), but if you call the routine again to
> > "repop it up (assuming the dialog is static), then you need to
> > call XtPopup().  Otherwise, XtManageChild() won't do anything.
> 
> Not in 1.1.  The built-in Dialog  OK button callback must
> do the unmanaging so that  managing does the  same thing
> every time.

Oh -- I think I see what you're saying.  Basically, because the
"Ok" button unmanages the dialog, the only way to bring it back
is to manage it again using XtManageChild().  Yes, this is true
in 1.0 as well.  However, I was having problems with it working
reliably.  I therefore *always* set XmNautoUnmanage to False and
when the XmNokCallback routine is called (user hit OK), I call
XtPopdown().  When the user requests to bring the dialog back,
I call XtPopup() and XRaiseWindow(XtDisplay(dialog), XtWindow(dialog)).

I advise this method over allowing Motif to automatically take
it down because Motif makes no assumptions about the "success"
of the Ok action.  If there is an error in one of the settings
in the dialog that prevents whatever action "Ok" is supposed to
take, then you don't wan to have the dialog taken down.  You may
wish to post an error dialog and allow the user to try again
without requiring him to bring the dialog back himself. You can
overcome this in two ways: the first I already mentioned (set
auto-unmanage to false and bring it down manually); the second 
is to call XtManageChild() in the XmNokCallback routine.  However,
this is not reliable because:

Whenever widgets are added to a dialog box (a bulletinboard widget),
its InsertChild() routine tests for auto-unmanage and, if true
(the default) adds a callback routine to unmanage the parent.
The problem is, that function may be inserted at an unpredictable
location in the callback list -- especially if you add or delete
callbacks for that widget, if you create and add the widget yourself,
or any number of other things.  Thus, if you call XtManagedChild()
from within the ok-callback routine, you are not guaranteed that
it will be called *after* the auto-unmanagement takes place.  If
the sequence goes out of order such that the call to XtUnmanageChild()
occurs -last- then you cannot prevent the dialog from going down.

By keeping XmNautoUnmanage off and explicitly taking down dialogs
yourself, you are assured that things will work as expected and
the stream of the code is much more straightforward.


--dan

rpjday@ccu.umanitoba.ca (02/20/91)

  In the FAQ posting, there is a reference to some files of Motif
examples, one from D. Young's book on Motif.  The two files,
young.motif.tar.Z and young.examples.tar.Z, are allegedly 
available from expo.lcs.mit.edu.  The files are there, but when
I ftp them over and try to uncompress them, what I get is
pure garbage (corrupt input).  A 150K compressed file expands
into over 22M.  Comments, anyone?

rich@MAX7.llnl.gov (Rich Mayfield) (02/20/91)

I've had the same problem ftp-ing files from expo.lcs.mit.edu.  I get
HUGE outputs after running uncompress on these files too.  I can ftp
from other locations but this one has given me problems.  That makes
two of us, anyone else?

wolfson@motcid.UUCP (Steve Wolfson) (02/21/91)

rich@MAX7.llnl.gov (Rich Mayfield) writes:

>I've had the same problem ftp-ing files from expo.lcs.mit.edu.  I get
>HUGE outputs after running uncompress on these files too.  I can ftp

I had no problems using the files from expo.  I picked up the files
about 2 weeks ago. Are you sure you didn't make a mistake and forget
to set ftp to binary?

- Steve Wolfson

akkana@Apple.COM (Akkana Peck) (02/21/91)

rpjday@ccu.umanitoba.ca writes, and others agree:
[The Doug Young motif examples uncompress into huge files ]

You probably ftp'ed them using text mode.  Try typing "binary" at the
ftp prompt before transferring the files.

	...Akkana		(akkana@apple.com)