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.12 2003/11/05 17:10:00 skimo Exp (Berkeley) Date: 2003/11/05 17:10:00 ";
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>
29 #include "../common/common.h"
30 #include "../ipc/ip.h"
34 /* Widget hierarchy routines
36 * void XutShowWidgetTree( FILE *fp, Widget root, int indent )
37 * prints the widgets and sub-widgets beneath the named root widget
41 void XutShowWidgetTree( FILE *fp
, Widget root
, int indent
)
43 void XutShowWidgetTree( fp
, root
, indent
)
49 #if ! defined(DECWINDOWS)
53 /* print where we are right now */
55 "%*.*swidget => 0x%x name => \"%s\"\n\r",
62 /* get the correct widget values */
63 XtVaGetValues( root
, XtNchildren
, &l
, 0 );
64 XtVaGetValues( root
, XtNchildren
, &l2
, 0 );
65 XtVaGetValues( root
, XtNnumChildren
, &count
, 0 );
67 /* print the sub-widgets */
68 for ( i
=0; i
<count
; i
++ ) {
69 XutShowWidgetTree( fp
, l
[i
], indent
+4 );
72 /* tidy up if this thing contained children */
74 /* we may or may not have to free the children */
77 XtFree( (char *) l2
);
85 /* Utilities for converting X resources...
87 * __XutConvertResources( Widget, String root, XutResource *, int count )
88 * The resource block is loaded with converted values
89 * If the X resource does not exist, no change is made to the value
90 * 'root' should be the application name.
92 * PUBLIC: void __XutConvertResources __P((Widget, String, XutResource *, int));
94 void __XutConvertResources(Widget wid
, String root
, XutResource
*resources
, int count
)
99 Boolean success
= True
;
101 /* for each resource */
102 for (i
=0; i
<count
; i
++) {
104 /* is there a value in the database? */
105 from
.addr
= XGetDefault( XtDisplay(wid
), root
, resources
[i
].name
);
106 if ( from
.addr
== NULL
|| *from
.addr
== '\0' )
109 /* load common parameters */
110 from
.size
= strlen( from
.addr
);
111 to
.addr
= resources
[i
].value
;
113 /* load type-specific parameters */
114 switch ( resources
[i
].kind
) {
116 to
.size
= sizeof(int);
121 /* String to Boolean */
122 to
.size
= sizeof(Boolean
);
127 /* String to Font structure */
128 to
.size
= sizeof(XFontStruct
*);
129 kind
= XtRFontStruct
;
132 case XutRKpixelBackup
:
133 /* String to Pixel backup algorithm */
134 if ( success
) continue;
138 /* String to Pixel */
139 to
.size
= sizeof(Pixel
);
144 /* String to Cursor */
145 to
.size
= sizeof(int);
153 /* call the converter */
154 success
= XtConvertAndStore( wid
, XtRString
, &from
, kind
, &to
);