handler.c revision 33c89af1
133c89af1Smrg/*
233c89af1Smrg * $Xorg: handler.c,v 1.4 2001/02/09 02:05:29 xorgcvs Exp $
333c89af1Smrg *
433c89af1SmrgCopyright 1989, 1998  The Open Group
533c89af1Smrg
633c89af1SmrgPermission to use, copy, modify, distribute, and sell this software and its
733c89af1Smrgdocumentation for any purpose is hereby granted without fee, provided that
833c89af1Smrgthe above copyright notice appear in all copies and that both that
933c89af1Smrgcopyright notice and this permission notice appear in supporting
1033c89af1Smrgdocumentation.
1133c89af1Smrg
1233c89af1SmrgThe above copyright notice and this permission notice shall be included in
1333c89af1Smrgall copies or substantial portions of the Software.
1433c89af1Smrg
1533c89af1SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1633c89af1SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1733c89af1SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
1833c89af1SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
1933c89af1SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2033c89af1SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2133c89af1Smrg
2233c89af1SmrgExcept as contained in this notice, the name of The Open Group shall not be
2333c89af1Smrgused in advertising or otherwise to promote the sale, use or other dealings
2433c89af1Smrgin this Software without prior written authorization from The Open Group.
2533c89af1Smrg */
2633c89af1Smrg
2733c89af1Smrg/* $XFree86: xc/programs/editres/handler.c,v 1.7tsi Exp $ */
2833c89af1Smrg
2933c89af1Smrg#include <X11/Intrinsic.h>
3033c89af1Smrg#include <X11/StringDefs.h>
3133c89af1Smrg
3233c89af1Smrg#include <X11/Xaw/Cardinals.h>
3333c89af1Smrg#include <X11/Xaw/List.h>
3433c89af1Smrg#include <X11/Xaw/Panner.h>
3533c89af1Smrg#include <X11/Xaw/Toggle.h>
3633c89af1Smrg#include <X11/Xfuncs.h>
3733c89af1Smrg#include <X11/Xos.h>		/* for W_OK def */
3833c89af1Smrg
3933c89af1Smrg#include <stdio.h>
4033c89af1Smrg#include <stdlib.h>
4133c89af1Smrg
4233c89af1Smrg#include "editresP.h"
4333c89af1Smrg
4433c89af1Smrg/*
4533c89af1Smrg * Local function definitions.
4633c89af1Smrg */
4733c89af1Smrgstatic char * GetResourceName ( ResourceBoxInfo * res_box );
4833c89af1Smrgstatic void _AppendResourceString ( Widget w, XtPointer res_box_ptr,
4933c89af1Smrg				    XtPointer filename_ptr );
5033c89af1Smrgstatic void _SetResourcesFile ( Widget w, XtPointer junk,
5133c89af1Smrg				XtPointer filename_ptr );
5233c89af1Smrgstatic void ObtainResource ( XtPointer node_ptr );
5333c89af1Smrgstatic void CreateSetValuesCommand ( WNode * node, XtPointer info_ptr );
5433c89af1Smrgstatic void SetOnlyMatchingWidgets ( WNode * node, XtPointer info_ptr );
5533c89af1Smrg
5633c89af1Smrg/*	Function Name: Quit
5733c89af1Smrg *	Description: This function prints a message to stdout.
5833c89af1Smrg *	Arguments: w - ** UNUSED **
5933c89af1Smrg *                 call_data - ** UNUSED **
6033c89af1Smrg *                 client_data - ** UNUSED **
6133c89af1Smrg *	Returns: none
6233c89af1Smrg */
6333c89af1Smrg
6433c89af1Smrg/* ARGSUSED */
6533c89af1Smrgvoid
6633c89af1SmrgQuit(w, client_data, call_data)
6733c89af1SmrgWidget w;
6833c89af1SmrgXtPointer call_data, client_data;
6933c89af1Smrg{
7033c89af1Smrg    XtDestroyApplicationContext(XtWidgetToApplicationContext(w));
7133c89af1Smrg    exit(0);
7233c89af1Smrg}
7333c89af1Smrg
7433c89af1Smrg/*	Function Name: SendTree
7533c89af1Smrg *	Description: This function initiates the client communication.
7633c89af1Smrg *                   by getting the resource tree.
7733c89af1Smrg *	Arguments: w - the widget that made the selection.
7833c89af1Smrg *                 value - a boolean value stored as a pointer.
7933c89af1Smrg *                         if True then get a new client, otherwise
8033c89af1Smrg *                         refresh the current client.
8133c89af1Smrg *                 call_data - ** UNUSED **
8233c89af1Smrg *	Returns: none
8333c89af1Smrg */
8433c89af1Smrg
8533c89af1Smrg/* ARGSUSED */
8633c89af1Smrgvoid
8733c89af1SmrgSendTree(w, value, call_data)
8833c89af1SmrgWidget w;
8933c89af1SmrgXtPointer value, call_data;
9033c89af1Smrg{
9133c89af1Smrg    if ((Boolean)(long) value)
9233c89af1Smrg	global_client.window = None;
9333c89af1Smrg
9433c89af1Smrg    if (!XtIsWidget(w))     /* Make sure that we use a "Real" widget here. */
9533c89af1Smrg	w = XtParent(w);
9633c89af1Smrg
9733c89af1Smrg    _XEditResResetStream(&(global_client.stream)); /* an empty message. */
9833c89af1Smrg
9933c89af1Smrg    SetCommand(w, LocalSendWidgetTree, NULL);
10033c89af1Smrg}
10133c89af1Smrg
10233c89af1Smrg/*	Function Name: FindWidget
10333c89af1Smrg *	Description: Maps a widget in the client to one in the currently
10433c89af1Smrg *                   displayed widget tree.
10533c89af1Smrg *	Arguments: w - the widget that invoked this action.
10633c89af1Smrg *                 call_data, client_data ** UNUSED **
10733c89af1Smrg *	Returns: none
10833c89af1Smrg */
10933c89af1Smrg
11033c89af1Smrg/* ARGSUSED */
11133c89af1Smrgvoid
11233c89af1SmrgFindWidget(w, client_data, call_data)
11333c89af1SmrgWidget w;
11433c89af1SmrgXtPointer client_data, call_data;
11533c89af1Smrg{
11633c89af1Smrg
11733c89af1Smrg    _FindWidget(XtParent(w));	/* Use parent since it is a "real"
11833c89af1Smrg				   widget not a rect_obj. */
11933c89af1Smrg}
12033c89af1Smrg
12133c89af1Smrg/*	Function Name: InitSetValues
12233c89af1Smrg *	Description: This function pops up the setvalues dialog
12333c89af1Smrg *	Arguments: w - the widget caused this action.
12433c89af1Smrg *                 call_data - ** UNUSED **
12533c89af1Smrg *                 client_data - ** UNUSED **
12633c89af1Smrg *	Returns: none
12733c89af1Smrg */
12833c89af1Smrg
12933c89af1Smrg/* ARGSUSED */
13033c89af1Smrgvoid
13133c89af1SmrgInitSetValues(w, client_data, call_data)
13233c89af1SmrgWidget w;
13333c89af1SmrgXtPointer call_data, client_data;
13433c89af1Smrg{
13533c89af1Smrg    if (!XtIsWidget(w))     /* Make sure that we use a "Real" widget here. */
13633c89af1Smrg	w = XtParent(w);
13733c89af1Smrg
13833c89af1Smrg    PopupSetValues(w, NULL);
13933c89af1Smrg}
14033c89af1Smrg
14133c89af1Smrg/*	Function Name: TreeSelect
14233c89af1Smrg *	Description: Selects all widgets.
14333c89af1Smrg *	Arguments: w - the widget caused this action.
14433c89af1Smrg *                 call_data - ** UNUSED **
14533c89af1Smrg *                 client_data - The type of thing to select.
14633c89af1Smrg *	Returns: none
14733c89af1Smrg */
14833c89af1Smrg
14933c89af1Smrg/* ARGSUSED */
15033c89af1Smrgvoid
15133c89af1SmrgTreeSelect(w, client_data, call_data)
15233c89af1SmrgWidget w;
15333c89af1SmrgXtPointer call_data, client_data;
15433c89af1Smrg{
15533c89af1Smrg    SelectTypes type = (SelectTypes) (unsigned long) client_data;
15633c89af1Smrg
15733c89af1Smrg    _TreeSelect(global_tree_info, type);
15833c89af1Smrg}
15933c89af1Smrg
16033c89af1Smrg/*	Function Name: TreeRelabel
16133c89af1Smrg *	Description: Relabels a tree to the type specified.
16233c89af1Smrg *	Arguments: w - the widget caused this action.
16333c89af1Smrg *                 call_data - ** UNUSED **
16433c89af1Smrg *                 client_data - the type of label to assign to each node.
16533c89af1Smrg *	Returns: none
16633c89af1Smrg */
16733c89af1Smrg
16833c89af1Smrg/* ARGSUSED */
16933c89af1Smrgvoid
17033c89af1SmrgTreeRelabel(w, client_data, call_data)
17133c89af1SmrgWidget w;
17233c89af1SmrgXtPointer call_data, client_data;
17333c89af1Smrg{
17433c89af1Smrg    LabelTypes type = (LabelTypes) (unsigned long) client_data;
17533c89af1Smrg
17633c89af1Smrg    _TreeRelabel(global_tree_info, type);
17733c89af1Smrg}
17833c89af1Smrg
17933c89af1Smrg/*	Function Name: PannerCallback
18033c89af1Smrg *	Description: called when the panner has moved.
18133c89af1Smrg *	Arguments: panner - the panner widget.
18233c89af1Smrg *                 closure - *** NOT USED ***.
18333c89af1Smrg *                 report_ptr - the panner record.
18433c89af1Smrg *	Returns: none.
18533c89af1Smrg */
18633c89af1Smrg
18733c89af1Smrg/* ARGSUSED */
18833c89af1Smrgvoid
18933c89af1SmrgPannerCallback(w, closure, report_ptr)
19033c89af1SmrgWidget w;
19133c89af1SmrgXtPointer closure, report_ptr;
19233c89af1Smrg{
19333c89af1Smrg    Arg args[2];
19433c89af1Smrg    XawPannerReport *report = (XawPannerReport *) report_ptr;
19533c89af1Smrg
19633c89af1Smrg    if (global_tree_info == NULL)
19733c89af1Smrg	return;
19833c89af1Smrg
19933c89af1Smrg    XtSetArg (args[0], XtNx, -report->slider_x);
20033c89af1Smrg    XtSetArg (args[1], XtNy, -report->slider_y);
20133c89af1Smrg
20233c89af1Smrg    XtSetValues(global_tree_info->tree_widget, args, TWO);
20333c89af1Smrg}
20433c89af1Smrg
20533c89af1Smrg/*	Function Name: PortholeCallback
20633c89af1Smrg *	Description: called when the porthole or its child has
20733c89af1Smrg *                   changed
20833c89af1Smrg *	Arguments: porthole - the porthole widget.
20933c89af1Smrg *                 panner_ptr - the panner widget.
21033c89af1Smrg *                 report_ptr - the porthole record.
21133c89af1Smrg *	Returns: none.
21233c89af1Smrg */
21333c89af1Smrg
21433c89af1Smrg/* ARGSUSED */
21533c89af1Smrgvoid
21633c89af1SmrgPortholeCallback(w, panner_ptr, report_ptr)
21733c89af1SmrgWidget w;
21833c89af1SmrgXtPointer panner_ptr, report_ptr;
21933c89af1Smrg{
22033c89af1Smrg    Arg args[10];
22133c89af1Smrg    Cardinal n = 0;
22233c89af1Smrg    XawPannerReport *report = (XawPannerReport *) report_ptr;
22333c89af1Smrg    Widget panner = (Widget) panner_ptr;
22433c89af1Smrg
22533c89af1Smrg    XtSetArg (args[n], XtNsliderX, report->slider_x); n++;
22633c89af1Smrg    XtSetArg (args[n], XtNsliderY, report->slider_y); n++;
22733c89af1Smrg    if (report->changed != (XawPRSliderX | XawPRSliderY)) {
22833c89af1Smrg	XtSetArg (args[n], XtNsliderWidth, report->slider_width); n++;
22933c89af1Smrg	XtSetArg (args[n], XtNsliderHeight, report->slider_height); n++;
23033c89af1Smrg	XtSetArg (args[n], XtNcanvasWidth, report->canvas_width); n++;
23133c89af1Smrg	XtSetArg (args[n], XtNcanvasHeight, report->canvas_height); n++;
23233c89af1Smrg    }
23333c89af1Smrg    XtSetValues (panner, args, n);
23433c89af1Smrg}
23533c89af1Smrg
23633c89af1Smrg/*	Function Name: FlashActiveWidgets
23733c89af1Smrg *	Description: called to flass all active widgets in the display.
23833c89af1Smrg *	Arguments: *** NOT USED ***
23933c89af1Smrg *	Returns: none.
24033c89af1Smrg */
24133c89af1Smrg
24233c89af1Smrg/* ARGSUSED */
24333c89af1Smrgvoid
24433c89af1SmrgFlashActiveWidgets(w, junk, garbage)
24533c89af1SmrgWidget w;
24633c89af1SmrgXtPointer junk, garbage;
24733c89af1Smrg{
24833c89af1Smrg    _FlashActiveWidgets(global_tree_info);
24933c89af1Smrg}
25033c89af1Smrg
25133c89af1Smrg/*	Function Name: GetResourceList
25233c89af1Smrg *	Description: Gets the resources lists of all active widgets.
25333c89af1Smrg *	Arguments: ** NOT USED **
25433c89af1Smrg *	Returns: none
25533c89af1Smrg */
25633c89af1Smrg
25733c89af1Smrg/* ARGSUSED */
25833c89af1Smrgvoid
25933c89af1SmrgGetResourceList(w, junk, garbage)
26033c89af1SmrgWidget w;
26133c89af1SmrgXtPointer junk, garbage;
26233c89af1Smrg{
26333c89af1Smrg    WNode * node;
26433c89af1Smrg    ProtocolStream * stream = &(global_client.stream);
26533c89af1Smrg
26633c89af1Smrg    if (global_tree_info == NULL) {
26733c89af1Smrg	SetMessage(global_screen_data.info_label,
26833c89af1Smrg		   res_labels[17]);
26933c89af1Smrg	return;
27033c89af1Smrg    }
27133c89af1Smrg
27233c89af1Smrg    if (global_tree_info->num_nodes != 1) {
27333c89af1Smrg	SetMessage(global_screen_data.info_label,
27433c89af1Smrg	      res_labels[19]);
27533c89af1Smrg	return;
27633c89af1Smrg    }
27733c89af1Smrg
27833c89af1Smrg    node = global_tree_info->active_nodes[0];
27933c89af1Smrg    if (node->resources != NULL) {
28033c89af1Smrg	char * errors = NULL;
28133c89af1Smrg	CreateResourceBox(node, &errors);
28233c89af1Smrg	if (errors != NULL) {
28333c89af1Smrg	    SetMessage(global_screen_data.info_label, errors);
28433c89af1Smrg	    XtFree(errors);
28533c89af1Smrg	}
28633c89af1Smrg	return;
28733c89af1Smrg    }
28833c89af1Smrg
28933c89af1Smrg    /*
29033c89af1Smrg     * No resoruces, fetch them from the client.
29133c89af1Smrg     */
29233c89af1Smrg
29333c89af1Smrg    _XEditResResetStream(stream);
29433c89af1Smrg    _XEditResPut16(stream, (unsigned short) 1);
29533c89af1Smrg    InsertWidgetFromNode(stream, node);
29633c89af1Smrg    SetCommand(global_tree_info->tree_widget, LocalGetResources, NULL);
29733c89af1Smrg}
29833c89af1Smrg
29933c89af1Smrg/*	Function Name: DumpTreeToFile
30033c89af1Smrg *	Description: Dumps all widgets in the tree to a file.
30133c89af1Smrg *	Arguments: w - the widget that activated this callback.
30233c89af1Smrg *                 junk, garbage - ** NOT USED **.
30333c89af1Smrg *	Returns: none.
30433c89af1Smrg */
30533c89af1Smrg
30633c89af1Smrg/* ARGSUSED */
30733c89af1Smrgvoid
30833c89af1SmrgDumpTreeToFile(w, junk, garbage)
30933c89af1SmrgWidget w;
31033c89af1SmrgXtPointer junk, garbage;
31133c89af1Smrg{
31233c89af1Smrg    _PopupFileDialog(XtParent(w), "Enter the filename:", "",
31333c89af1Smrg		     _DumpTreeToFile, (XtPointer) global_tree_info);
31433c89af1Smrg}
31533c89af1Smrg
31633c89af1Smrg/************************************************************
31733c89af1Smrg *
31833c89af1Smrg * Callbacks for the Resource Box.
31933c89af1Smrg *
32033c89af1Smrg ************************************************************/
32133c89af1Smrg
32233c89af1Smrg
32333c89af1Smrg/*	Function Name: AnyChosen
32433c89af1Smrg *	Description: Callback that is called when the "any" widget
32533c89af1Smrg *                   is activated.
32633c89af1Smrg *	Arguments: w - the "any" widget that activated this callback.
32733c89af1Smrg *                 any_info_ptr - pointer to struct containing
32833c89af1Smrg *                                dot and star widgets to lock.
32933c89af1Smrg *                 state_ptr - state of the any toggle.
33033c89af1Smrg *	Returns: none.
33133c89af1Smrg */
33233c89af1Smrg
33333c89af1Smrg/* ARGSUSED */
33433c89af1Smrgvoid
33533c89af1SmrgAnyChosen(w, any_info_ptr, state_ptr)
33633c89af1SmrgWidget w;
33733c89af1SmrgXtPointer any_info_ptr, state_ptr;
33833c89af1Smrg{
33933c89af1Smrg    AnyInfo * any_info = (AnyInfo *) any_info_ptr;
34033c89af1Smrg    Boolean state = (Boolean)(long) state_ptr;
34133c89af1Smrg    Arg args[1];
34233c89af1Smrg
34333c89af1Smrg    if (state) {
34433c89af1Smrg
34533c89af1Smrg	if (any_info->left_count == 0) {
34633c89af1Smrg	    XtSetSensitive(any_info->left_dot, FALSE);
34733c89af1Smrg	    XtSetSensitive(any_info->left_star, FALSE);
34833c89af1Smrg
34933c89af1Smrg	    XtSetArg(args[0], XtNstate, TRUE);
35033c89af1Smrg	    XtSetValues(any_info->left_star, args, ONE);
35133c89af1Smrg	}
35233c89af1Smrg
35333c89af1Smrg	if ((any_info->right_count == NULL)||(*any_info->right_count == 0)) {
35433c89af1Smrg	    XtSetSensitive(any_info->right_dot, FALSE);
35533c89af1Smrg	    XtSetSensitive(any_info->right_star, FALSE);
35633c89af1Smrg
35733c89af1Smrg	    XtSetArg(args[0], XtNstate, TRUE);
35833c89af1Smrg	    XtSetValues(any_info->right_star, args, ONE);
35933c89af1Smrg	}
36033c89af1Smrg	any_info->left_count++;
36133c89af1Smrg
36233c89af1Smrg	if (any_info->right_count != NULL)
36333c89af1Smrg	    (*any_info->right_count)++;
36433c89af1Smrg    }
36533c89af1Smrg    else {			/* state == 0 */
36633c89af1Smrg	if (any_info->left_count > 0)
36733c89af1Smrg	    any_info->left_count--;
36833c89af1Smrg	if ((any_info->right_count != NULL)&&(*any_info->right_count > 0))
36933c89af1Smrg	    (*any_info->right_count)--;
37033c89af1Smrg
37133c89af1Smrg	if (any_info->left_count == 0) {
37233c89af1Smrg	    XtSetSensitive(any_info->left_dot, TRUE);
37333c89af1Smrg	    XtSetSensitive(any_info->left_star, TRUE);
37433c89af1Smrg
37533c89af1Smrg	    XtSetArg(args[0], XtNstate, TRUE);
37633c89af1Smrg	    XtSetValues(any_info->left_dot, args, ONE);
37733c89af1Smrg	}
37833c89af1Smrg
37933c89af1Smrg	if ((any_info->right_count == NULL)||(*any_info->right_count == 0)) {
38033c89af1Smrg	    XtSetSensitive(any_info->right_dot, TRUE);
38133c89af1Smrg	    XtSetSensitive(any_info->right_star, TRUE);
38233c89af1Smrg
38333c89af1Smrg	    XtSetArg(args[0], XtNstate, TRUE);
38433c89af1Smrg	    XtSetValues(any_info->right_dot, args, ONE);
38533c89af1Smrg	}
38633c89af1Smrg    }
38733c89af1Smrg    SetResourceString(NULL, (XtPointer) any_info->node, NULL);
38833c89af1Smrg    ActivateResourceWidgets(NULL, (XtPointer) any_info->node, NULL);
38933c89af1Smrg}
39033c89af1Smrg
39133c89af1Smrg/*	Function Name: GetResourceName
39233c89af1Smrg *	Description: Gets the name of the current resource.
39333c89af1Smrg *	Arguments: res_box - the resource box.
39433c89af1Smrg *	Returns: the name of the currently selected resource.
39533c89af1Smrg */
39633c89af1Smrg
39733c89af1Smrg
39833c89af1Smrgstatic char *
39933c89af1SmrgGetResourceName(res_box)
40033c89af1SmrgResourceBoxInfo * res_box;
40133c89af1Smrg{
40233c89af1Smrg    XawListReturnStruct * list_info;
40333c89af1Smrg    char * result;
40433c89af1Smrg
40533c89af1Smrg    list_info = XawListShowCurrent(res_box->norm_list);
40633c89af1Smrg    if ((list_info->list_index == XAW_LIST_NONE) &&
40733c89af1Smrg	(res_box->cons_list != NULL)) {
40833c89af1Smrg	list_info = XawListShowCurrent(res_box->cons_list);
40933c89af1Smrg    }
41033c89af1Smrg
41133c89af1Smrg    if (list_info->list_index == XAW_LIST_NONE)
41233c89af1Smrg	result = "unknown";
41333c89af1Smrg    else
41433c89af1Smrg	result = list_info->string;
41533c89af1Smrg
41633c89af1Smrg    return(result);
41733c89af1Smrg}
41833c89af1Smrg
41933c89af1Smrg
42033c89af1Smrg/*	Function Name: ActivateWidgetsAndSetResourceString
42133c89af1Smrg *	Description: Sets the new resources string, then
42233c89af1Smrg *                   activates all widgets that match this resource,
42333c89af1Smrg *	Arguments: w - the widget that activated this.
42433c89af1Smrg *                 node_ptr - the node that owns this resource box.
42533c89af1Smrg *                 call_data - passed on to other callbacks.
42633c89af1Smrg *	Returns: none.
42733c89af1Smrg *
42833c89af1Smrg * NOTE: I cannot just have two callback routines, since I care which
42933c89af1Smrg *       order that these are executed in, sigh...
43033c89af1Smrg */
43133c89af1Smrg
43233c89af1Smrgvoid
43333c89af1SmrgActivateWidgetsAndSetResourceString(w, node_ptr, call_data)
43433c89af1SmrgWidget w;
43533c89af1SmrgXtPointer node_ptr, call_data;
43633c89af1Smrg{
43733c89af1Smrg    SetResourceString(w, node_ptr, call_data);
43833c89af1Smrg    ActivateResourceWidgets(w, node_ptr, call_data);
43933c89af1Smrg}
44033c89af1Smrg
44133c89af1Smrg/*	Function Name: SetResourceString
44233c89af1Smrg *	Description: Sets the resource label to correspond to the currently
44333c89af1Smrg *                   chosen string.
44433c89af1Smrg *	Arguments: w - The widget that invoked this callback, or NULL.
44533c89af1Smrg *                 node_ptr - pointer to widget node contating this res box.
44633c89af1Smrg *                 call_data - The call data for the action that invoked
44733c89af1Smrg *                             this callback.
44833c89af1Smrg *	Returns: none.
44933c89af1Smrg */
45033c89af1Smrg
45133c89af1Smrgvoid
45233c89af1SmrgSetResourceString(w, node_ptr, junk)
45333c89af1SmrgWidget w;
45433c89af1SmrgXtPointer node_ptr, junk;
45533c89af1Smrg{
45633c89af1Smrg    static char * malloc_string; /* These are both inited to zero. */
45733c89af1Smrg    static Cardinal malloc_size;
45833c89af1Smrg
45933c89af1Smrg    WNode * node = (WNode *) node_ptr;
46033c89af1Smrg    ResourceBoxInfo * res_box = node->resources->res_box;
46133c89af1Smrg    char * temp, buf[BUFSIZ * 10];	/* here's hoping it's big enough. */
46233c89af1Smrg    NameInfo * name_node = res_box->name_info;
46333c89af1Smrg    Arg args[1];
46433c89af1Smrg    int len;
46533c89af1Smrg
46633c89af1Smrg    if ((w != NULL) && XtIsSubclass(w, toggleWidgetClass)) {
46733c89af1Smrg	/*
46833c89af1Smrg	 * Only set resources when toggles are activated, not when they are
46933c89af1Smrg	 * deactivated.
47033c89af1Smrg	 */
47133c89af1Smrg	if (!((Boolean)(long) junk))
47233c89af1Smrg	    return;
47333c89af1Smrg    }
47433c89af1Smrg
47533c89af1Smrg    buf[0] = '\0';		/* clear out string. */
47633c89af1Smrg
47733c89af1Smrg    /*
47833c89af1Smrg     * Get the widget name/class info.
47933c89af1Smrg     */
48033c89af1Smrg
48133c89af1Smrg    if ((temp = (char *) XawToggleGetCurrent(name_node->sep_leader)) != NULL)
48233c89af1Smrg	strcat(buf, temp);
48333c89af1Smrg
48433c89af1Smrg    for ( ; name_node->next != NULL ; name_node = name_node->next) {
48533c89af1Smrg	temp = (char *) XawToggleGetCurrent(name_node->name_leader);
48633c89af1Smrg	if ( (temp != NULL) && !streq(temp, ANY_RADIO_DATA) ) {
48733c89af1Smrg	    strcat(buf, temp);
48833c89af1Smrg	    temp = (char *) XawToggleGetCurrent(name_node->next->sep_leader);
48933c89af1Smrg	    if (temp == NULL)
49033c89af1Smrg		strcat(buf, "!");
49133c89af1Smrg	    else
49233c89af1Smrg		strcat(buf, temp);
49333c89af1Smrg	}
49433c89af1Smrg    }
49533c89af1Smrg
49633c89af1Smrg    strcat(buf, GetResourceName(res_box));
49733c89af1Smrg    len = strlen(buf) + 2; /* Leave space for ':' and '\0' */
49833c89af1Smrg
49933c89af1Smrg#ifdef notdef
50033c89af1Smrg    XtSetArg(args[0], XtNstring, &temp);
50133c89af1Smrg    XtGetValues(res_box->value_wid, args, ONE);
50233c89af1Smrg    len += strlen(temp);
50333c89af1Smrg#endif
50433c89af1Smrg
50533c89af1Smrg    if (len > malloc_size) {
50633c89af1Smrg	malloc_string = XtRealloc(malloc_string, sizeof(char) * len);
50733c89af1Smrg	malloc_size = len;
50833c89af1Smrg    }
50933c89af1Smrg
51033c89af1Smrg    strcpy(malloc_string, buf);
51133c89af1Smrg    strcat(malloc_string, ":");
51233c89af1Smrg#ifdef notdef
51333c89af1Smrg    strcat(malloc_string, temp);
51433c89af1Smrg#endif
51533c89af1Smrg
51633c89af1Smrg    XtSetArg(args[0], XtNlabel, malloc_string);
51733c89af1Smrg    XtSetValues(res_box->res_label, args, ONE);
51833c89af1Smrg}
51933c89af1Smrg
52033c89af1Smrg/*	Function Name: ResourceListCallback
52133c89af1Smrg *	Description: Callback functions for the resource lists.  This
52233c89af1Smrg *                   routine is essentialy called by the list widgets
52333c89af1Smrg *                   Notify action.  If action EnableGetVal has been
52433c89af1Smrg *                   invoked,  ResourceListCallback will perform a
52533c89af1Smrg *                   GetValues protocol request.
52633c89af1Smrg *	Arguments: list - the list widget that we are dealing with.
52733c89af1Smrg *                 node_ptr - pointer to widget node contating this res box.
52833c89af1Smrg *                 junk - UNUSED.
52933c89af1Smrg *	Returns: none
53033c89af1Smrg */
53133c89af1Smrg
53233c89af1Smrgextern Boolean do_get_values;
53333c89af1Smrg
53433c89af1Smrgvoid
53533c89af1SmrgResourceListCallback(list, node_ptr, junk)
53633c89af1SmrgWidget list;
53733c89af1SmrgXtPointer node_ptr, junk;
53833c89af1Smrg{
53933c89af1Smrg    Widget o_list;
54033c89af1Smrg    WNode * node = (WNode *) node_ptr;
54133c89af1Smrg    ResourceBoxInfo * res_box = node->resources->res_box;
54233c89af1Smrg
54333c89af1Smrg    if (list == res_box->norm_list)
54433c89af1Smrg	o_list = res_box->cons_list;
54533c89af1Smrg    else
54633c89af1Smrg	o_list = res_box->norm_list;
54733c89af1Smrg
54833c89af1Smrg    if (o_list != NULL)
54933c89af1Smrg	XawListUnhighlight(o_list);
55033c89af1Smrg
55133c89af1Smrg    SetResourceString(list, node_ptr, junk);
55233c89af1Smrg
55333c89af1Smrg    /* get the resource value from the application */
55433c89af1Smrg    if (global_effective_protocol_version >=
55533c89af1Smrg	PROTOCOL_VERSION_ONE_POINT_ONE && do_get_values) {
55633c89af1Smrg      ObtainResource(node_ptr);
55733c89af1Smrg      do_get_values = False;
55833c89af1Smrg    }
55933c89af1Smrg}
56033c89af1Smrg
56133c89af1Smrg/*	Function Name: PopdownResBox
56233c89af1Smrg *	Description: Pops down the resource box.
56333c89af1Smrg *	Arguments: w - UNUSED
56433c89af1Smrg *                 shell_ptr - pointer to the shell to pop down.
56533c89af1Smrg *                 junk - UNUSED.
56633c89af1Smrg *	Returns: none
56733c89af1Smrg */
56833c89af1Smrg
56933c89af1Smrg/* ARGSUSED */
57033c89af1Smrgvoid
57133c89af1SmrgPopdownResBox(w, shell_ptr, junk)
57233c89af1SmrgWidget w;
57333c89af1SmrgXtPointer shell_ptr, junk;
57433c89af1Smrg{
57533c89af1Smrg    Widget shell = (Widget) shell_ptr;
57633c89af1Smrg
57733c89af1Smrg    XtPopdown(shell);
57833c89af1Smrg    XtDestroyWidget(shell);
57933c89af1Smrg}
58033c89af1Smrg
58133c89af1Smrg/* ARGSUSED */
58233c89af1Smrgstatic void
58333c89af1Smrg_AppendResourceString(w, res_box_ptr, filename_ptr)
58433c89af1SmrgWidget w;
58533c89af1SmrgXtPointer res_box_ptr, filename_ptr;
58633c89af1Smrg{
58733c89af1Smrg    Arg args[1];
58833c89af1Smrg    FILE * fp;
58933c89af1Smrg    char buf[BUFSIZ], * resource_string, *filename = (char *) filename_ptr;
59033c89af1Smrg    ResourceBoxInfo * res_box = (ResourceBoxInfo *) res_box_ptr;
59133c89af1Smrg    char *value_ptr;
59233c89af1Smrg
59333c89af1Smrg    if (filename != NULL) {
59433c89af1Smrg	if (global_resources.allocated_save_resources_file)
59533c89af1Smrg	    XtFree(global_resources.save_resources_file);
59633c89af1Smrg	else
59733c89af1Smrg	    global_resources.allocated_save_resources_file = TRUE;
59833c89af1Smrg
59933c89af1Smrg	global_resources.save_resources_file = XtNewString(filename);
60033c89af1Smrg    }
60133c89af1Smrg
60233c89af1Smrg    if ((fp = fopen(global_resources.save_resources_file, "a+")) == NULL) {
60333c89af1Smrg	sprintf(buf, "Unable to open this file for writing, would %s",
60433c89af1Smrg		"you like To try again?");
60533c89af1Smrg	_PopupFileDialog(global_toplevel ,buf,
60633c89af1Smrg			global_resources.save_resources_file,
60733c89af1Smrg			_AppendResourceString, res_box_ptr);
60833c89af1Smrg	return;
60933c89af1Smrg    }
61033c89af1Smrg
61133c89af1Smrg    XtSetArg(args[0], XtNlabel, &resource_string);
61233c89af1Smrg    XtGetValues(res_box->res_label, args, ONE);
61333c89af1Smrg
61433c89af1Smrg    XtSetArg(args[0], XtNstring, &value_ptr);
61533c89af1Smrg    XtGetValues(res_box->value_wid, args, ONE);
61633c89af1Smrg
61733c89af1Smrg    fprintf(fp, "%s %s\n", resource_string, value_ptr);
61833c89af1Smrg
61933c89af1Smrg    fclose(fp);
62033c89af1Smrg}
62133c89af1Smrg
62233c89af1Smrg/*	Function Name: SaveResource
62333c89af1Smrg *	Description: Save the current resource to your resource file
62433c89af1Smrg *	Arguments: w - any widget in the application.
62533c89af1Smrg *                 res_box_ptr - the resource box info.
62633c89af1Smrg *                 junk - UNUSED.
62733c89af1Smrg *	Returns: none
62833c89af1Smrg */
62933c89af1Smrg
63033c89af1Smrg/* ARGSUSED */
63133c89af1Smrgvoid
63233c89af1SmrgSaveResource(w, res_box_ptr, junk)
63333c89af1SmrgWidget w;
63433c89af1SmrgXtPointer res_box_ptr, junk;
63533c89af1Smrg{
63633c89af1Smrg    /*
63733c89af1Smrg     * If there is no filename the ask for one, otherwise just save to
63833c89af1Smrg     * current file.
63933c89af1Smrg     */
64033c89af1Smrg
64133c89af1Smrg    if (streq(global_resources.save_resources_file, ""))
64233c89af1Smrg	_PopupFileDialog(XtParent(w), "Enter file to dump resources into:",
64333c89af1Smrg			 global_resources.save_resources_file,
64433c89af1Smrg			 _AppendResourceString, res_box_ptr);
64533c89af1Smrg    else
64633c89af1Smrg	_AppendResourceString(w, res_box_ptr, NULL);
64733c89af1Smrg}
64833c89af1Smrg
64933c89af1Smrg/*	Function Name: _SetResourcesFile
65033c89af1Smrg *	Description: Sets the filename of the file to save the resources to.
65133c89af1Smrg *	Arguments: w - UNUSED
65233c89af1Smrg *                 junk - UNUSED
65333c89af1Smrg *                 filename_ptr - a pointer to the filename;
65433c89af1Smrg *	Returns: none
65533c89af1Smrg */
65633c89af1Smrg
65733c89af1Smrg/* ARGSUSED */
65833c89af1Smrgstatic void
65933c89af1Smrg_SetResourcesFile(w, junk, filename_ptr)
66033c89af1SmrgWidget w;
66133c89af1SmrgXtPointer junk, filename_ptr;
66233c89af1Smrg{
66333c89af1Smrg    char *filename = (char *) filename_ptr;
66433c89af1Smrg
66533c89af1Smrg    if (global_resources.allocated_save_resources_file)
66633c89af1Smrg	XtFree(global_resources.save_resources_file);
66733c89af1Smrg    else
66833c89af1Smrg	global_resources.allocated_save_resources_file = TRUE;
66933c89af1Smrg
67033c89af1Smrg    global_resources.save_resources_file = XtNewString(filename);
67133c89af1Smrg}
67233c89af1Smrg
67333c89af1Smrg/*	Function Name: SetFile
67433c89af1Smrg *	Description: Changes the current save file
67533c89af1Smrg *	Arguments: w - UNUSED.
67633c89af1Smrg *                 res_box_ptr - UNUSED.
67733c89af1Smrg *                 junk - UNUSED.
67833c89af1Smrg *	Returns: none
67933c89af1Smrg */
68033c89af1Smrg
68133c89af1Smrg/* ARGSUSED */
68233c89af1Smrgvoid
68333c89af1SmrgSetFile(w, junk, garbage)
68433c89af1SmrgWidget w;
68533c89af1SmrgXtPointer junk, garbage;
68633c89af1Smrg{
68733c89af1Smrg    /*
68833c89af1Smrg     * If there is no filename the ask for one, otherwise just save to
68933c89af1Smrg     * current file.
69033c89af1Smrg     */
69133c89af1Smrg
69233c89af1Smrg    _PopupFileDialog(XtParent(w), "Enter file to dump resources into:",
69333c89af1Smrg		     global_resources.save_resources_file,
69433c89af1Smrg		     _SetResourcesFile, NULL);
69533c89af1Smrg}
69633c89af1Smrg
69733c89af1Smrg/*	Function Name: ApplyResource
69833c89af1Smrg *	Description: Apply the current resource to the running application.
69933c89af1Smrg *	Arguments: w - any widget in the application.
70033c89af1Smrg *                 node_ptr - a pointer to the node containing
70133c89af1Smrg *                            the current resouce box.
70233c89af1Smrg *                 junk - UNUSED.
70333c89af1Smrg *	Returns: none
70433c89af1Smrg */
70533c89af1Smrg
70633c89af1Smrg/* ARGSUSED */
70733c89af1Smrgvoid
70833c89af1SmrgApplyResource(w, node_ptr, junk)
70933c89af1SmrgWidget w;
71033c89af1SmrgXtPointer node_ptr, junk;
71133c89af1Smrg{
71233c89af1Smrg    ProtocolStream * stream = &(global_client.stream);
71333c89af1Smrg    ApplyResourcesInfo info;
71433c89af1Smrg    WNode * node = (WNode *) node_ptr;
71533c89af1Smrg    char * value;
71633c89af1Smrg    unsigned short size, i;
71733c89af1Smrg    long len;
71833c89af1Smrg    Arg args[1];
71933c89af1Smrg
72033c89af1Smrg    info.name = GetResourceName(node->resources->res_box);
72133c89af1Smrg    info.class = "IGNORE_ME";	/* Not currently used.  */
72233c89af1Smrg    info.stream = stream;
72333c89af1Smrg    info.count = 0;
72433c89af1Smrg
72533c89af1Smrg    XtSetArg(args[0], XtNlabel, &value);
72633c89af1Smrg    XtGetValues(node->resources->res_box->res_label, args, ONE);
72733c89af1Smrg
72833c89af1Smrg    info.database = NULL;
72933c89af1Smrg    XrmPutLineResource(&(info.database), value);
73033c89af1Smrg
73133c89af1Smrg
73233c89af1Smrg    _XEditResResetStream(stream);
73333c89af1Smrg    _XEditResPutString8(stream, info.name); /* Insert name */
73433c89af1Smrg    _XEditResPutString8(stream, XtRString); /* insert type */
73533c89af1Smrg
73633c89af1Smrg    /*
73733c89af1Smrg     * Insert value.
73833c89af1Smrg     */
73933c89af1Smrg
74033c89af1Smrg    value = GetResourceValueForSetValues(node, &size);
74133c89af1Smrg    _XEditResPut16(stream, size);
74233c89af1Smrg    for (i = 0; i < size; i++)
74333c89af1Smrg	_XEditResPut8(stream, value[i]);
74433c89af1Smrg    XtFree(value);
74533c89af1Smrg    len = stream->current - stream->top;
74633c89af1Smrg
74733c89af1Smrg    /*
74833c89af1Smrg     * Insert the widget count, overriden later.
74933c89af1Smrg     */
75033c89af1Smrg
75133c89af1Smrg    _XEditResPut16(stream, 0);
75233c89af1Smrg
75333c89af1Smrg    ExecuteOverAllNodes(node->tree_info->top_node,
75433c89af1Smrg			CreateSetValuesCommand, (XtPointer) &info);
75533c89af1Smrg
75633c89af1Smrg    if (info.count > 0) {
75733c89af1Smrg	*(stream->top + len++) = info.count >> XER_NBBY; /* Set the correct */
75833c89af1Smrg	*(stream->top + len) = info.count;               /* count. */
75933c89af1Smrg
76033c89af1Smrg	SetCommand(node->tree_info->tree_widget, LocalSetValues, NULL);
76133c89af1Smrg    }
76233c89af1Smrg    else
76333c89af1Smrg	SetMessage(global_screen_data.info_label,
76433c89af1Smrg		   res_labels[20]);
76533c89af1Smrg
76633c89af1Smrg    XrmDestroyDatabase(info.database);
76733c89af1Smrg}
76833c89af1Smrg
76933c89af1Smrg/*	Function Name: ObtainResource
77033c89af1Smrg *	Description: Obtain the current resource from the running application.
77133c89af1Smrg *	Arguments: node_ptr - a pointer to the node containing
77233c89af1Smrg *                            the current resouce box.
77333c89af1Smrg *	Returns: none
77433c89af1Smrg */
77533c89af1Smrg
77633c89af1Smrg/* ARGSUSED */
77733c89af1Smrgstatic void
77833c89af1SmrgObtainResource(node_ptr)
77933c89af1SmrgXtPointer node_ptr;
78033c89af1Smrg{
78133c89af1Smrg    ProtocolStream * stream = &(global_client.stream);
78233c89af1Smrg    ObtainResourcesInfo info;
78333c89af1Smrg    WNode * node = (WNode *) node_ptr;
78433c89af1Smrg    char * value;
78533c89af1Smrg    Arg args[1];
78633c89af1Smrg
78733c89af1Smrg    info.name = GetResourceName(node->resources->res_box);
78833c89af1Smrg    info.class = "IGNORE_ME";	/* Not currently used.  */
78933c89af1Smrg    info.stream = stream;
79033c89af1Smrg    info.count = 1;
79133c89af1Smrg
79233c89af1Smrg    XtSetArg(args[0], XtNlabel, &value);
79333c89af1Smrg    XtGetValues(node->resources->res_box->res_label, args, ONE);
79433c89af1Smrg
79533c89af1Smrg    info.database = NULL;
79633c89af1Smrg    XrmPutLineResource(&(info.database), value);
79733c89af1Smrg
79833c89af1Smrg    _XEditResResetStream(stream);
79933c89af1Smrg    _XEditResPutString8(stream, info.name); /* insert name */
80033c89af1Smrg
80133c89af1Smrg    /*
80233c89af1Smrg     * Insert the widget count, always 1
80333c89af1Smrg     */
80433c89af1Smrg
80533c89af1Smrg    _XEditResPut16(stream, 1);
80633c89af1Smrg
80733c89af1Smrg    /*CreateGetValuesCommand(node, (XtPointer)&info);  Inserts widget */
80833c89af1Smrg
80933c89af1Smrg    /* Insert widget */
81033c89af1Smrg    InsertWidgetFromNode(stream, node);
81133c89af1Smrg
81233c89af1Smrg    SetCommand(node->tree_info->tree_widget, LocalGetValues, NULL);
81333c89af1Smrg}
81433c89af1Smrg
81533c89af1Smrg/*	Function Name: CreateSetValuesCommand
81633c89af1Smrg *	Description: Creates the SetValues command if this widget
81733c89af1Smrg *                   matches the resource string in the database.
81833c89af1Smrg *	Arguments: node - the current node.
81933c89af1Smrg *                 info_ptr - the pointer to the apply info.
82033c89af1Smrg *	Returns: none
82133c89af1Smrg */
82233c89af1Smrg
82333c89af1Smrgstatic void
82433c89af1SmrgCreateSetValuesCommand(node, info_ptr)
82533c89af1SmrgWNode * node;
82633c89af1SmrgXtPointer info_ptr;
82733c89af1Smrg{
82833c89af1Smrg    ApplyResourcesInfo * info = (ApplyResourcesInfo *) info_ptr;
82933c89af1Smrg    XrmNameList name_quarks;
83033c89af1Smrg    XrmClassList class_quarks;
83133c89af1Smrg    char ** names, **classes;
83233c89af1Smrg
83333c89af1Smrg    GetNamesAndClasses(node, &names, &classes);
83433c89af1Smrg    name_quarks = (XrmNameList) Quarkify(names, info->name);
83533c89af1Smrg    class_quarks = (XrmNameList) Quarkify(classes, info->class);
83633c89af1Smrg
83733c89af1Smrg    if (CheckDatabase(info->database, name_quarks, class_quarks)) {
83833c89af1Smrg	InsertWidgetFromNode(info->stream, node);
83933c89af1Smrg	info->count++;
84033c89af1Smrg    }
84133c89af1Smrg
84233c89af1Smrg    XtFree((char *)names);
84333c89af1Smrg    XtFree((char *)classes);
84433c89af1Smrg    XtFree((char *)name_quarks);
84533c89af1Smrg    XtFree((char *)class_quarks);
84633c89af1Smrg}
84733c89af1Smrg
84833c89af1Smrg/*	Function Name: CreateGetValuesCommand
84933c89af1Smrg *	Description: Creates the GetValues command.
85033c89af1Smrg *	Arguments: node - the current node.
85133c89af1Smrg *                 info_ptr - the pointer to the apply info.
85233c89af1Smrg *	Returns: none
85333c89af1Smrg */
85433c89af1Smrg
85533c89af1Smrg/*****
85633c89af1Smrg
85733c89af1Smrgstatic void
85833c89af1SmrgCreateGetValuesCommand(node, info_ptr)
85933c89af1SmrgWNode * node;
86033c89af1SmrgXtPointer info_ptr;
86133c89af1Smrg{
86233c89af1Smrg    ApplyResourcesInfo * info = (ApplyResourcesInfo *) info_ptr;
86333c89af1Smrg    XrmNameList name_quarks;
86433c89af1Smrg    XrmClassList class_quarks;
86533c89af1Smrg    char ** names, **classes;
86633c89af1Smrg
86733c89af1Smrg    GetNamesAndClasses(node, &names, &classes);
86833c89af1Smrg    name_quarks = (XrmNameList) Quarkify(names, info->name);
86933c89af1Smrg    class_quarks = (XrmNameList) Quarkify(classes, info->class);
87033c89af1Smrg
87133c89af1Smrg    if (CheckDatabase(info->database, name_quarks, class_quarks)) {
87233c89af1Smrg	InsertWidgetFromNode(info->stream, node);
87333c89af1Smrg	info->count++;
87433c89af1Smrg    }
87533c89af1Smrg
87633c89af1Smrg    XtFree((char *)names);
87733c89af1Smrg    XtFree((char *)classes);
87833c89af1Smrg    XtFree((char *)name_quarks);
87933c89af1Smrg    XtFree((char *)class_quarks);
88033c89af1Smrg}
88133c89af1Smrg
88233c89af1Smrg*****/
88333c89af1Smrg
88433c89af1Smrg/*	Function Name: ActivateResourceWidgets
88533c89af1Smrg *	Description: Activates all widgets that match this resource.
88633c89af1Smrg *	Arguments: w - UNUSED.
88733c89af1Smrg *                 node_ptr - the node that owns this resource box.
88833c89af1Smrg *                 junk - UNUSED.
88933c89af1Smrg *	Returns: none.
89033c89af1Smrg */
89133c89af1Smrg
89233c89af1Smrg/* ARGSUSED */
89333c89af1Smrgvoid
89433c89af1SmrgActivateResourceWidgets(w, node_ptr, junk)
89533c89af1SmrgWidget w;
89633c89af1SmrgXtPointer node_ptr, junk;
89733c89af1Smrg{
89833c89af1Smrg    WNode * node = (WNode *) node_ptr;
89933c89af1Smrg    ApplyResourcesInfo info;
90033c89af1Smrg    char * line;
90133c89af1Smrg    Arg args[1];
90233c89af1Smrg
90333c89af1Smrg    info.name = GetResourceName(node->resources->res_box);
90433c89af1Smrg    info.class = "IGNORE_ME";	/* Not currently used.  */
90533c89af1Smrg
90633c89af1Smrg    /*
90733c89af1Smrg     * Unused fields.
90833c89af1Smrg     */
90933c89af1Smrg
91033c89af1Smrg    info.count = 0;
91133c89af1Smrg    info.stream = NULL;
91233c89af1Smrg
91333c89af1Smrg    XtSetArg(args[0], XtNlabel, &line);
91433c89af1Smrg    XtGetValues(node->resources->res_box->res_label, args, ONE);
91533c89af1Smrg
91633c89af1Smrg    info.database = NULL;
91733c89af1Smrg    XrmPutLineResource(&(info.database), line);
91833c89af1Smrg
91933c89af1Smrg
92033c89af1Smrg    ExecuteOverAllNodes(node->tree_info->top_node,
92133c89af1Smrg			SetOnlyMatchingWidgets, (XtPointer) &info);
92233c89af1Smrg
92333c89af1Smrg    XrmDestroyDatabase(info.database);
92433c89af1Smrg}
92533c89af1Smrg
92633c89af1Smrg/*	Function Name: SetOnlyMatchingWidgets
92733c89af1Smrg *	Description: Activates all widgets in the tree that match this
92833c89af1Smrg *                   resource specifiction.
92933c89af1Smrg *	Arguments: node - the current node.
93033c89af1Smrg *                 info_ptr - the pointer to the apply info.
93133c89af1Smrg *	Returns: none
93233c89af1Smrg */
93333c89af1Smrg
93433c89af1Smrgstatic void
93533c89af1SmrgSetOnlyMatchingWidgets(node, info_ptr)
93633c89af1SmrgWNode * node;
93733c89af1SmrgXtPointer info_ptr;
93833c89af1Smrg{
93933c89af1Smrg    ApplyResourcesInfo * info = (ApplyResourcesInfo *) info_ptr;
94033c89af1Smrg    XrmNameList name_quarks;
94133c89af1Smrg    XrmClassList class_quarks;
94233c89af1Smrg    char ** names, **classes;
94333c89af1Smrg    Boolean state;
94433c89af1Smrg    Arg args[1];
94533c89af1Smrg
94633c89af1Smrg    GetNamesAndClasses(node, &names, &classes);
94733c89af1Smrg    name_quarks = (XrmNameList) Quarkify(names, info->name);
94833c89af1Smrg    class_quarks = (XrmNameList) Quarkify(classes, info->class);
94933c89af1Smrg
95033c89af1Smrg    state = CheckDatabase(info->database, name_quarks, class_quarks);
95133c89af1Smrg
95233c89af1Smrg    XtSetArg(args[0], XtNstate, state);
95333c89af1Smrg    XtSetValues(node->widget, args, ONE);
95433c89af1Smrg    TreeToggle(node->widget, (XtPointer) node, (XtPointer)(long) state);
95533c89af1Smrg
95633c89af1Smrg    XtFree((char *)names);
95733c89af1Smrg    XtFree((char *)classes);
95833c89af1Smrg    XtFree((char *)name_quarks);
95933c89af1Smrg    XtFree((char *)class_quarks);
96033c89af1Smrg}
961