3 * Rob Zimmermann. All rights reserved.
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
13 static const char sccsid
[] = "$Id: m_util.c,v 8.11 2001/06/25 15:19:28 skimo Exp $ (Berkeley) $Date: 2001/06/25 15:19:28 $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <X11/Intrinsic.h>
20 #include <X11/StringDefs.h>
21 #include <X11/Shell.h>
22 #include <X11/Xatom.h>
24 #include <bitstring.h>
28 #include "../common/common.h"
29 #include "../ipc/ip.h"
33 /* Widget hierarchy routines
35 * void XutShowWidgetTree( FILE *fp, Widget root, int indent )
36 * prints the widgets and sub-widgets beneath the named root widget
40 void XutShowWidgetTree( FILE *fp
, Widget root
, int indent
)
42 void XutShowWidgetTree( fp
, root
, indent
)
48 #if ! defined(DECWINDOWS)
52 /* print where we are right now */
54 "%*.*swidget => 0x%x name => \"%s\"\n\r",
61 /* get the correct widget values */
62 XtVaGetValues( root
, XtNchildren
, &l
, 0 );
63 XtVaGetValues( root
, XtNchildren
, &l2
, 0 );
64 XtVaGetValues( root
, XtNnumChildren
, &count
, 0 );
66 /* print the sub-widgets */
67 for ( i
=0; i
<count
; i
++ ) {
68 XutShowWidgetTree( fp
, l
[i
], indent
+4 );
71 /* tidy up if this thing contained children */
73 /* we may or may not have to free the children */
76 XtFree( (char *) l2
);
84 /* Utilities for converting X resources...
86 * __XutConvertResources( Widget, String root, XutResource *, int count )
87 * The resource block is loaded with converted values
88 * If the X resource does not exist, no change is made to the value
89 * 'root' should be the application name.
91 * PUBLIC: void __XutConvertResources __P((Widget, String, XutResource *, int));
93 void __XutConvertResources(Widget wid
, String root
, XutResource
*resources
, int count
)
98 Boolean success
= True
;
100 /* for each resource */
101 for (i
=0; i
<count
; i
++) {
103 /* is there a value in the database? */
104 from
.addr
= XGetDefault( XtDisplay(wid
), root
, resources
[i
].name
);
105 if ( from
.addr
== NULL
|| *from
.addr
== '\0' )
108 /* load common parameters */
109 from
.size
= strlen( from
.addr
);
110 to
.addr
= resources
[i
].value
;
112 /* load type-specific parameters */
113 switch ( resources
[i
].kind
) {
115 to
.size
= sizeof(int);
120 /* String to Boolean */
121 to
.size
= sizeof(Boolean
);
126 /* String to Font structure */
127 to
.size
= sizeof(XFontStruct
*);
128 kind
= XtRFontStruct
;
131 case XutRKpixelBackup
:
132 /* String to Pixel backup algorithm */
133 if ( success
) continue;
137 /* String to Pixel */
138 to
.size
= sizeof(Pixel
);
143 /* String to Cursor */
144 to
.size
= sizeof(int);
152 /* call the converter */
153 success
= XtConvertAndStore( wid
, XtRString
, &from
, kind
, &to
);