[comp.windows.x.motif] Getting the name of a Gadget

montnaro@spyder.crd.ge.com (Skip Montanaro) (06/13/91)

In my application I have a form that contains, among other things, a
PushButtonGadget ("cancel") and a SeparatorGadget ("separator"). The
topWidget resource of "cancel" is "separator".

In a resource printing routine, I have a handle on the XtResourceList entry
for cancel's topWidget. It is:

    (gdb) print *r
    $7 = {
      resource_name = 0x517ca8 "topWidget", 
      resource_class = 0x50d534 "Widget", 
      resource_type = 0x4d800c "Window", 
      resource_size = 4, 
      resource_offset = 56, 
      default_type = 0x4d800c "Window", 
      default_addr = 0x0
    }

Based upon the resource type field, I print out a more or less informative
description of the widget (gadget in this case). In particular, for resource
type "Window", I can safely call XtName() if it's a true widget, but not if
it's a gadget. Is there some way I can detect that the resource value is
actually a gadget, and call some other function or macro to get its name?
Perhaps it's not kosher to use gadgets as resource values in forms?

I saw nothing in the FAQ list regarding what can and can't be done with
gadgets. Berlage's and Young's books are vague about gadget limitations, and
the Motif Programmer's Reference and Programmer's Guide were equally
uninformative.

--
Skip (montanaro@crdgw1.ge.com)

pete@IRIS49.BIOSYM.COM (Pete Ware) (06/14/91)

XtName() safely works for gadgets.  If you have the Asente & Swick
book (highly recomended), look on page 865 for a list of functions
that except Objects as arguments.  Be sure to check for NULL before
calling it, of course.

--pete
Pete Ware / Biosym / San Diego CA / (619) 546-5532
     email: pete@biosym.com