Source code for xsample.
Compiling xsample
gcc -o xsample xsample.c -L/usr/X11R6/lib -lXaw -lXmu -lXt -lXext -lX11
C-Shell alias I use to compile small X applications
alias cxt '/usr/bin/gcc -Wall -ansi -pedantic -o \ `/bin/basename \!* .c` \!* -L/usr/X11R6/lib \ -lXaw -lXmu -lXt -lXext -lX11'
Use /usr/X11R6/bin/editres to find customizable resources.
X applications can be customized by the following listed in order of precedence. All source code examples are taken from the xsample application shown above.
Arg arglist[] = { XtNwidth, 180,
XtNbackground, (XtArgVal)"red",
XtNlabel, (XtArgVal)"HardCoded Resource" };
XtSetValues( (Widget)client_data, arglist, XtNumber( arglist ) );
/* Create widget */
quitButton = XtVaCreateManagedWidget(
"quitButton",
commandWidgetClass,
container,
XtNwidth, 180, /* hard coded X resource */
NULL );
/home/matthew> xterm -bg yellow -fg "blue" /home/matthew> xsample -xrm ".xsample.*font: fixed"
/home/matthew> echo "xsample.*font: fixed" | xrdb -merge
- or -
/home/matthew> xrdb -merge < xsampleResourceFile
/home/matthew> xsample
/home/matthew> cat ~/.Xdefaults #ifdef COLOR *customization: -color #endif .xsample.*font: lucidasans-italic-24 /home/matthew> xsample
/home/matthew> cat /usr/X11R6/lib/X11/app-defaults/XSample .xsample.container.quitButton.label: Quit .xsample.*font: lucidasans-italic-24 /home/matthew> xsample
static String fallbackResources[] = {
".xsample.*font: lucidasans-bold-12",
NULL };
/* Initialize the toolkit */
topwidget = XtVaAppInitialize(
&appcontext, /* application context */
"XSample", /* application class */
NULL, 0, /* command line option list */
&argc, argv, /* command line arguments */
fallbackResources, /* fallback resource settings */
NULL ); /* terminate varags list */
Last Modified: 14 June 1997
St. Louis Unix Users Group - Linux SIG