5 * Rob Zimmermann. All rights reserved.
7 * Keith Bostic. All rights reserved.
9 * See the LICENSE file for redistribution information.
15 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";
18 #include <sys/types.h>
19 #include <sys/queue.h>
21 #include <X11/Intrinsic.h>
22 #include <X11/StringDefs.h>
23 #include <X11/Shell.h>
24 #include <X11/Xatom.h>
26 #include <bitstring.h>
31 #include "../common/common.h"
32 #include "../ipc/ip.h"
36 /* Widget hierarchy routines
38 * void XutShowWidgetTree( FILE *fp, Widget root, int indent )
39 * prints the widgets and sub-widgets beneath the named root widget
43 void XutShowWidgetTree( FILE *fp
, Widget root
, int indent
)
45 void XutShowWidgetTree( fp
, root
, indent
)
51 #if ! defined(DECWINDOWS)
55 /* print where we are right now */
57 "%*.*swidget => 0x%x name => \"%s\"\n\r",
64 /* get the correct widget values */
65 XtVaGetValues( root
, XtNchildren
, &l
, 0 );
66 XtVaGetValues( root
, XtNchildren
, &l2
, 0 );
67 XtVaGetValues( root
, XtNnumChildren
, &count
, 0 );
69 /* print the sub-widgets */
70 for ( i
=0; i
<count
; i
++ ) {
71 XutShowWidgetTree( fp
, l
[i
], indent
+4 );
74 /* tidy up if this thing contained children */
76 /* we may or may not have to free the children */
79 XtFree( (char *) l2
);
87 /* Utilities for converting X resources...
89 * __XutConvertResources( Widget, String root, XutResource *, int count )
90 * The resource block is loaded with converted values
91 * If the X resource does not exist, no change is made to the value
92 * 'root' should be the application name.
94 * PUBLIC: void __XutConvertResources __P((Widget, String, XutResource *, int));
96 void __XutConvertResources(Widget wid
, String root
, XutResource
*resources
, int count
)
101 Boolean success
= True
;
103 /* for each resource */
104 for (i
=0; i
<count
; i
++) {
106 /* is there a value in the database? */
107 from
.addr
= XGetDefault( XtDisplay(wid
), root
, resources
[i
].name
);
108 if ( from
.addr
== NULL
|| *from
.addr
== '\0' )
111 /* load common parameters */
112 from
.size
= strlen( from
.addr
);
113 to
.addr
= resources
[i
].value
;
115 /* load type-specific parameters */
116 switch ( resources
[i
].kind
) {
118 to
.size
= sizeof(int);
123 /* String to Boolean */
124 to
.size
= sizeof(Boolean
);
129 /* String to Font structure */
130 to
.size
= sizeof(XFontStruct
*);
131 kind
= XtRFontStruct
;
134 case XutRKpixelBackup
:
135 /* String to Pixel backup algorithm */
136 if ( success
) continue;
140 /* String to Pixel */
141 to
.size
= sizeof(Pixel
);
146 /* String to Cursor */
147 to
.size
= sizeof(int);
155 /* call the converter */
156 success
= XtConvertAndStore( wid
, XtRString
, &from
, kind
, &to
);