18108eb18Smrg/* $Xorg: info.c,v 1.5 2001/02/09 02:05:59 xorgcvs Exp $ */
28108eb18Smrg/******************************************************************************
38108eb18Smrg
48108eb18SmrgCopyright 1993, 1998  The Open Group
58108eb18Smrg
68108eb18SmrgPermission to use, copy, modify, distribute, and sell this software and its
78108eb18Smrgdocumentation for any purpose is hereby granted without fee, provided that
88108eb18Smrgthe above copyright notice appear in all copies and that both that
98108eb18Smrgcopyright notice and this permission notice appear in supporting
108108eb18Smrgdocumentation.
118108eb18Smrg
128108eb18SmrgThe above copyright notice and this permission notice shall be included in
138108eb18Smrgall copies or substantial portions of the Software.
148108eb18Smrg
158108eb18SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168108eb18SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178108eb18SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
188108eb18SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
198108eb18SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
208108eb18SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
218108eb18Smrg
228108eb18SmrgExcept as contained in this notice, the name of The Open Group shall not be
238108eb18Smrgused in advertising or otherwise to promote the sale, use or other dealings
248108eb18Smrgin this Software without prior written authorization from The Open Group.
258108eb18Smrg******************************************************************************/
268108eb18Smrg/* $XFree86: xc/programs/xsm/info.c,v 1.5 2001/01/17 23:46:28 dawes Exp $ */
278108eb18Smrg
288108eb18Smrg#include "xsm.h"
298108eb18Smrg#include "restart.h"
308108eb18Smrg#include "popup.h"
318108eb18Smrg#include "info.h"
328108eb18Smrg#include "prop.h"
338108eb18Smrg
348108eb18Smrg#include <X11/Shell.h>
358108eb18Smrg#include <X11/Xaw/Form.h>
368108eb18Smrg#include <X11/Xaw/List.h>
378108eb18Smrg#include <X11/Xaw/Command.h>
388108eb18Smrg#include <X11/Xaw/SimpleMenu.h>
398108eb18Smrg#include <X11/Xaw/MenuButton.h>
408108eb18Smrg#include <X11/Xaw/SmeBSB.h>
418108eb18Smrg#include <X11/Xaw/AsciiText.h>
428108eb18Smrg
438108eb18Smrgstatic Pixmap checkBitmap;
448108eb18Smrg
458108eb18SmrgWidget clientInfoPopup;
461a650d1eSmrgstatic Widget   clientInfoForm;
471a650d1eSmrgstatic Widget     viewPropButton;
481a650d1eSmrgstatic Widget	   cloneButton;
491a650d1eSmrgstatic Widget	   killClientButton;
501a650d1eSmrgstatic Widget	   clientInfoDoneButton;
511a650d1eSmrgstatic Widget	   restartHintButton;
521a650d1eSmrgstatic Widget	     restartHintMenu;
531a650d1eSmrgstatic Widget		restartIfRunning;
541a650d1eSmrgstatic Widget		restartAnyway;
551a650d1eSmrgstatic Widget		restartImmediately;
561a650d1eSmrgstatic Widget		restartNever;
571a650d1eSmrgWidget clientListWidget;
581a650d1eSmrgstatic Widget noClientsLabel;
591a650d1eSmrgWidget manualRestartLabel;
601a650d1eSmrgWidget manualRestartCommands;
618108eb18Smrg
628108eb18SmrgWidget clientPropPopup;
631a650d1eSmrgstatic Widget clientPropForm;
641a650d1eSmrgstatic Widget clientPropDoneButton;
651a650d1eSmrgstatic Widget clientPropTextWidget;
668108eb18Smrg
678108eb18Smrg
688108eb18Smrg
698108eb18Smrgvoid
708108eb18SmrgShowHint(ClientRec *client)
718108eb18Smrg{
728108eb18Smrg    static Widget active = NULL;
738108eb18Smrg    int hint = client->restartHint;
748108eb18Smrg
758108eb18Smrg    if (active)
768108eb18Smrg	XtVaSetValues (active, XtNleftBitmap, None, NULL);
778108eb18Smrg
788108eb18Smrg    if (hint == SmRestartIfRunning)
798108eb18Smrg	active = restartIfRunning;
808108eb18Smrg    else if (hint == SmRestartAnyway)
818108eb18Smrg	active = restartAnyway;
828108eb18Smrg    else if (hint == SmRestartImmediately)
838108eb18Smrg	active = restartImmediately;
848108eb18Smrg    else if (hint == SmRestartNever)
858108eb18Smrg	active = restartNever;
868108eb18Smrg
878108eb18Smrg    XtVaSetValues (active, XtNleftBitmap, checkBitmap, NULL);
888108eb18Smrg}
898108eb18Smrg
908108eb18Smrg
918108eb18Smrg
928108eb18Smrgtypedef struct {
938108eb18Smrg    char *bufStart;
948108eb18Smrg    char *bufPtr;
958108eb18Smrg    int bufSize;
968108eb18Smrg    int bytesLeft;
978108eb18Smrg} Buffer;
988108eb18Smrg
998108eb18Smrg#define BUF_START_SIZE 1024
1008108eb18Smrg#define BUF_GROW_SIZE 256
1018108eb18Smrg
1028108eb18Smrg
1038108eb18Smrgstatic void
1045977a007SmrgAppendStr(Buffer *buffer, const char *str)
1058108eb18Smrg{
1068108eb18Smrg    int len = strlen (str);
1078108eb18Smrg
1088108eb18Smrg    if ((buffer->bytesLeft - 1) < len)
1098108eb18Smrg    {
1108108eb18Smrg	int newBufSize = buffer->bufSize + len + BUF_GROW_SIZE;
1118108eb18Smrg	int bytesUsed = buffer->bufPtr - buffer->bufStart;
1121a650d1eSmrg	char *newbuf = realloc (buffer->bufStart, newBufSize);
1131a650d1eSmrg	if (newbuf != NULL) {
1141a650d1eSmrg	    newbuf[bytesUsed] = '\0';
1151a650d1eSmrg	    buffer->bufStart = newbuf;
1161a650d1eSmrg	    buffer->bufPtr = newbuf + bytesUsed;
1171a650d1eSmrg	    buffer->bufSize = newBufSize;
1181a650d1eSmrg	    buffer->bytesLeft = newBufSize - bytesUsed;
1191a650d1eSmrg	} else {
1201a650d1eSmrg	    perror("realloc failed, aborting");
1211a650d1eSmrg	    exit(1);
1221a650d1eSmrg	}
1238108eb18Smrg    }
1248108eb18Smrg
1258108eb18Smrg    strcat (buffer->bufPtr, str);
1268108eb18Smrg    buffer->bufPtr += len;
1278108eb18Smrg    buffer->bytesLeft -= len;
1288108eb18Smrg}
1298108eb18Smrg
1308108eb18Smrg
1318108eb18Smrgvoid
1328108eb18SmrgDisplayProps(ClientRec *client)
1338108eb18Smrg{
1348108eb18Smrg    int index;
1358108eb18Smrg    List *pl, *pj, *vl;
1368108eb18Smrg    PropValue *pval;
1378108eb18Smrg    Buffer buffer;
1388108eb18Smrg    static int first_time = 1;
1398108eb18Smrg
1408108eb18Smrg    for (index = 0; index < numClientListNames; index++)
1418108eb18Smrg	if (clientListRecs[index] == client)
1428108eb18Smrg	    break;
1438108eb18Smrg
1448108eb18Smrg    if (index >= numClientListNames)
1458108eb18Smrg	return;
1468108eb18Smrg
1478108eb18Smrg    buffer.bufStart = buffer.bufPtr = (char *) malloc (BUF_START_SIZE);
1488108eb18Smrg    buffer.bufSize = buffer.bytesLeft = BUF_START_SIZE;
1498108eb18Smrg    buffer.bufStart[0] = '\0';
1508108eb18Smrg
1518108eb18Smrg    if (ListCount (client->props) > 0)
1528108eb18Smrg    {
15399c4c48aSmrg	char number[16];
1548108eb18Smrg	char *ptr;
1558108eb18Smrg
1568108eb18Smrg	AppendStr (&buffer, "*** ID = ");
1578108eb18Smrg	AppendStr (&buffer, client->clientId);
1588108eb18Smrg	AppendStr (&buffer, " ***\n\n");
1598108eb18Smrg
1608108eb18Smrg	for (pl = ListFirst (client->props); pl; pl = ListNext (pl))
1618108eb18Smrg	{
1628108eb18Smrg	    Prop *pprop = (Prop *) pl->thing;
1638108eb18Smrg
1648108eb18Smrg	    AppendStr (&buffer, "Name:		");
1658108eb18Smrg	    AppendStr (&buffer, pprop->name);
1668108eb18Smrg	    AppendStr (&buffer, "\n");
1678108eb18Smrg	    AppendStr (&buffer, "Type:		");
1688108eb18Smrg	    AppendStr (&buffer, pprop->type);
1698108eb18Smrg	    AppendStr (&buffer, "\n");
1708108eb18Smrg	    AppendStr (&buffer, "Num values:	");
1711a650d1eSmrg	    snprintf (number, sizeof(number), "%d", ListCount (pprop->values));
1728108eb18Smrg	    AppendStr (&buffer, number);
1738108eb18Smrg	    AppendStr (&buffer, "\n");
1748108eb18Smrg
1758108eb18Smrg	    if (strcmp (pprop->type, SmCARD8) == 0)
1768108eb18Smrg	    {
1778108eb18Smrg		char *card8;
1788108eb18Smrg		int value;
1798108eb18Smrg
1808108eb18Smrg		vl = ListFirst (pprop->values);
1818108eb18Smrg		pval = (PropValue *) vl->thing;
1828108eb18Smrg
1838108eb18Smrg		card8 = pval->value;
1848108eb18Smrg		value = *card8;
1858108eb18Smrg
1868108eb18Smrg		AppendStr (&buffer, "Value 1:	");
1871a650d1eSmrg		snprintf (number, sizeof(number), "%d", value);
1888108eb18Smrg		AppendStr (&buffer, number);
1898108eb18Smrg
1908108eb18Smrg		if (strcmp (pprop->name, SmRestartStyleHint) == 0)
1918108eb18Smrg		{
1928108eb18Smrg		    if (value == SmRestartAnyway)
1938108eb18Smrg			AppendStr (&buffer, " (Restart Anyway)");
1948108eb18Smrg		    else if (value == SmRestartImmediately)
1958108eb18Smrg			AppendStr (&buffer, " (Restart Immediately)");
1968108eb18Smrg		    else if (value == SmRestartNever)
1978108eb18Smrg			AppendStr (&buffer, " (Restart Never)");
1988108eb18Smrg		    else
1998108eb18Smrg			AppendStr (&buffer, " (Restart If Running)");
2008108eb18Smrg		}
2018108eb18Smrg
2028108eb18Smrg		AppendStr (&buffer, "\n");
2038108eb18Smrg	    }
2048108eb18Smrg	    else
2058108eb18Smrg	    {
2068108eb18Smrg		int propnum = 0;
2078108eb18Smrg
2088108eb18Smrg		for (pj = ListFirst (pprop->values); pj; pj = ListNext (pj))
2098108eb18Smrg		{
2108108eb18Smrg		    propnum++;
2118108eb18Smrg
2128108eb18Smrg		    pval = (PropValue *) pj->thing;
2138108eb18Smrg		    AppendStr (&buffer, "Value ");
2141a650d1eSmrg		    snprintf (number, sizeof(number), "%d", propnum);
2158108eb18Smrg		    AppendStr (&buffer, number);
2168108eb18Smrg		    AppendStr (&buffer, ":	");
2178108eb18Smrg		    AppendStr (&buffer, (char *) pval->value);
2188108eb18Smrg		    AppendStr (&buffer, "\n");
2198108eb18Smrg		}
2208108eb18Smrg	    }
2218108eb18Smrg
2228108eb18Smrg	    AppendStr (&buffer, "\n");
2238108eb18Smrg	}
2248108eb18Smrg
2258108eb18Smrg	XtVaSetValues (clientPropTextWidget,
2268108eb18Smrg	    XtNstring, buffer.bufStart,
2278108eb18Smrg	    NULL);
2288108eb18Smrg
2295977a007Smrg	snprintf (buffer.bufStart, buffer.bufSize,
2308108eb18Smrg	    "SM Properties : %s", clientListNames[index]);
2318108eb18Smrg
2328108eb18Smrg	ptr = Strstr (buffer.bufStart, ")   Restart");
2338108eb18Smrg	if (ptr) *(ptr + 1) = '\0';
2348108eb18Smrg
2358108eb18Smrg	XtVaSetValues (clientPropPopup,
2368108eb18Smrg	    XtNtitle, buffer.bufStart,
2378108eb18Smrg	    XtNiconName, buffer.bufStart,
2388108eb18Smrg	    NULL);
2398108eb18Smrg
2408108eb18Smrg	if (client_prop_visible)
2418108eb18Smrg	{
2428108eb18Smrg	    /* Make sure it is visible */
2438108eb18Smrg
2448108eb18Smrg	    XMapRaised (XtDisplay (topLevel), XtWindow (clientPropPopup));
2458108eb18Smrg	}
2468108eb18Smrg	else
2478108eb18Smrg	{
2488108eb18Smrg	    PopupPopup (mainWindow, clientPropPopup,
2498108eb18Smrg		False, first_time, 50, 150, "DelPropWinAction()");
2508108eb18Smrg
2518108eb18Smrg	    client_prop_visible = 1;
2528108eb18Smrg
2538108eb18Smrg	    if (first_time)
2548108eb18Smrg		first_time = 0;
2558108eb18Smrg	}
2568108eb18Smrg    }
2578108eb18Smrg
2588108eb18Smrg    free (buffer.bufStart);
2598108eb18Smrg}
2608108eb18Smrg
2618108eb18Smrg
2628108eb18Smrg
2638108eb18Smrgstatic void
2648108eb18SmrgClientListXtProc(Widget w, XtPointer client_data, XtPointer callData)
2658108eb18Smrg{
2668108eb18Smrg    XawListReturnStruct *current = (XawListReturnStruct *) callData;
2678108eb18Smrg    ClientRec *client;
2688108eb18Smrg
2698108eb18Smrg    if (!current || current->list_index < 0)
2708108eb18Smrg	return;
2718108eb18Smrg
2728108eb18Smrg    client = clientListRecs[current->list_index];
2738108eb18Smrg    ShowHint (client);
2748108eb18Smrg    current_client_selected = current->list_index;
2758108eb18Smrg    if (client_prop_visible)
2768108eb18Smrg	DisplayProps (client);
2778108eb18Smrg}
2788108eb18Smrg
2798108eb18Smrg
2808108eb18Smrg
2818108eb18Smrg
2828108eb18Smrgstatic void
2838108eb18SmrgViewPropXtProc(Widget w, XtPointer client_data, XtPointer callData)
2848108eb18Smrg{
2858108eb18Smrg    ClientRec *client;
2868108eb18Smrg    XawListReturnStruct *current;
2878108eb18Smrg
2888108eb18Smrg    current = XawListShowCurrent (clientListWidget);
2898108eb18Smrg
2908108eb18Smrg    if (!current || current->list_index < 0)
2918108eb18Smrg    {
2928108eb18Smrg	if (current)
2938108eb18Smrg	    XtFree ((char *) current);
2948108eb18Smrg	return;
2958108eb18Smrg    }
2968108eb18Smrg
2978108eb18Smrg    client = clientListRecs[current->list_index];
2988108eb18Smrg    DisplayProps (client);
2998108eb18Smrg    XtFree ((char *) current);
3008108eb18Smrg}
3018108eb18Smrg
3028108eb18Smrg
3038108eb18Smrg
3048108eb18Smrgstatic void
3058108eb18SmrgCloneXtProc(Widget w, XtPointer client_data, XtPointer callData)
3068108eb18Smrg{
3078108eb18Smrg    ClientRec *client;
3088108eb18Smrg    XawListReturnStruct *current;
3098108eb18Smrg
3108108eb18Smrg    current = XawListShowCurrent (clientListWidget);
3118108eb18Smrg
3128108eb18Smrg    if (!current || current->list_index < 0)
3138108eb18Smrg    {
3148108eb18Smrg	if (current)
3158108eb18Smrg	    XtFree ((char *) current);
3168108eb18Smrg	return;
3178108eb18Smrg    }
3188108eb18Smrg
3198108eb18Smrg    client = clientListRecs[current->list_index];
3208108eb18Smrg
3218108eb18Smrg    if (client)
3228108eb18Smrg	Clone (client, False /* don't use saved state */);
3238108eb18Smrg
3248108eb18Smrg    XtFree ((char *) current);
3258108eb18Smrg}
3268108eb18Smrg
3278108eb18Smrg
3288108eb18Smrg
3298108eb18Smrgstatic void
3308108eb18SmrgKillClientXtProc(Widget w, XtPointer client_data, XtPointer callData)
3318108eb18Smrg{
3328108eb18Smrg    ClientRec *client;
3338108eb18Smrg    XawListReturnStruct *current;
3348108eb18Smrg
3358108eb18Smrg    current = XawListShowCurrent (clientListWidget);
3368108eb18Smrg
3378108eb18Smrg    if (!current || current->list_index < 0)
3388108eb18Smrg    {
3398108eb18Smrg	if (current)
3408108eb18Smrg	    XtFree ((char *) current);
3418108eb18Smrg	return;
3428108eb18Smrg    }
3438108eb18Smrg
3448108eb18Smrg    client = clientListRecs[current->list_index];
3458108eb18Smrg
3468108eb18Smrg    SmsDie (client->smsConn);
3478108eb18Smrg
3488108eb18Smrg    XtFree ((char *) current);
3498108eb18Smrg}
3508108eb18Smrg
3518108eb18Smrg
3528108eb18Smrg
3538108eb18Smrgstatic void
3548108eb18SmrglistDoneXtProc(Widget w, XtPointer client_data, XtPointer callData)
3558108eb18Smrg{
3568108eb18Smrg    XtPopdown (clientInfoPopup);
3578108eb18Smrg    client_info_visible = 0;
3588108eb18Smrg}
3598108eb18Smrg
3608108eb18Smrg
3618108eb18Smrg
3628108eb18Smrgchar *
3638108eb18SmrgGetProgramName(char *fullname)
3648108eb18Smrg{
3658108eb18Smrg    char *lastSlash = NULL;
3668108eb18Smrg    int i;
3678108eb18Smrg
3688108eb18Smrg    for (i = 0; i < (int) strlen (fullname); i++)
3698108eb18Smrg	if (fullname[i] == '/')
3708108eb18Smrg	    lastSlash = &fullname[i];
3718108eb18Smrg
3728108eb18Smrg    if (lastSlash)
3738108eb18Smrg	return (lastSlash + 1);
3748108eb18Smrg    else
3758108eb18Smrg	return (fullname);
3768108eb18Smrg}
3778108eb18Smrg
3788108eb18Smrg
3798108eb18Smrg
3808108eb18Smrgvoid
3818108eb18SmrgUpdateClientList(void)
3828108eb18Smrg{
3838108eb18Smrg    ClientRec *client;
3848108eb18Smrg    char *progName, *hostname, *tmp1, *tmp2;
38599c4c48aSmrg    char *clientInfo;
3868108eb18Smrg    int maxlen1, maxlen2;
3878108eb18Smrg    char extraBuf1[80], extraBuf2[80];
3888108eb18Smrg    char *restart_service_prop;
3898108eb18Smrg    List *cl, *pl;
3908108eb18Smrg    int i, k;
3918108eb18Smrg    static int reenable_asap = 0;
3928108eb18Smrg
3938108eb18Smrg    if (clientListNames)
3948108eb18Smrg    {
3958108eb18Smrg	/*
3968108eb18Smrg	 * Free the previous list of names.  Xaw doesn't make a copy of
3978108eb18Smrg	 * our list, so we need to keep it around.
3988108eb18Smrg	 */
3998108eb18Smrg
4008108eb18Smrg	for (i = 0; i < numClientListNames; i++)
40199c4c48aSmrg	    XtFree ((char *) clientListNames[i]);
4028108eb18Smrg
4038108eb18Smrg	XtFree ((char *) clientListNames);
4048108eb18Smrg
4058108eb18Smrg	clientListNames = NULL;
4068108eb18Smrg    }
4078108eb18Smrg
4088108eb18Smrg    if (clientListRecs)
4098108eb18Smrg    {
4108108eb18Smrg	/*
4118108eb18Smrg	 * Free the mapping of client names to client records
4128108eb18Smrg	 */
4138108eb18Smrg
4148108eb18Smrg	XtFree ((char *) clientListRecs);
4158108eb18Smrg	clientListRecs = NULL;
4168108eb18Smrg    }
4178108eb18Smrg
4188108eb18Smrg    maxlen1 = maxlen2 = 0;
4198108eb18Smrg    numClientListNames = 0;
4208108eb18Smrg
4218108eb18Smrg    for (cl = ListFirst (RunningList); cl; cl = ListNext (cl))
4228108eb18Smrg    {
4238108eb18Smrg	client = (ClientRec *) cl->thing;
4248108eb18Smrg
4258108eb18Smrg	progName = NULL;
4268108eb18Smrg	restart_service_prop = NULL;
4278108eb18Smrg
4288108eb18Smrg	for (pl = ListFirst (client->props); pl; pl = ListNext (pl))
4298108eb18Smrg	{
4308108eb18Smrg	    Prop *pprop = (Prop *) pl->thing;
4318108eb18Smrg	    List *vl = ListFirst (pprop->values);
4328108eb18Smrg	    if (vl != NULL)
4338108eb18Smrg	    {
4348108eb18Smrg	    	PropValue *pval = (PropValue *) vl->thing;
4358108eb18Smrg
4368108eb18Smrg	    	if (strcmp (pprop->name, SmProgram) == 0)
4378108eb18Smrg	    	{
4388108eb18Smrg			progName = GetProgramName ((char *) pval->value);
4398108eb18Smrg
4408108eb18Smrg			if ((int) strlen (progName) > maxlen1)
4418108eb18Smrg			    maxlen1 = strlen (progName);
4428108eb18Smrg	    	}
4438108eb18Smrg	    	else if (strcmp (pprop->name, "_XC_RestartService") == 0)
4448108eb18Smrg	    	{
4458108eb18Smrg			restart_service_prop = (char *) pval->value;
4468108eb18Smrg	    	}
4478108eb18Smrg	    }
4488108eb18Smrg	}
4498108eb18Smrg
4508108eb18Smrg	if (!progName)
4518108eb18Smrg	    continue;
4528108eb18Smrg
4538108eb18Smrg	if (restart_service_prop)
4548108eb18Smrg	    tmp1 = restart_service_prop;
4558108eb18Smrg	else if (client->clientHostname)
4568108eb18Smrg	    tmp1 = client->clientHostname;
4578108eb18Smrg	else
4588108eb18Smrg	    continue;
4598108eb18Smrg
4608108eb18Smrg	if ((tmp2 = (char *) strchr (tmp1, '/')) == NULL)
4618108eb18Smrg	    hostname = tmp1;
4628108eb18Smrg	else
4638108eb18Smrg	    hostname = tmp2 + 1;
4648108eb18Smrg
4658108eb18Smrg	if ((int) strlen (hostname) > maxlen2)
4668108eb18Smrg	    maxlen2 = strlen (hostname);
4678108eb18Smrg
4688108eb18Smrg	numClientListNames++;
4698108eb18Smrg    }
4708108eb18Smrg
4718108eb18Smrg    if (numClientListNames == 0)
4728108eb18Smrg    {
4738108eb18Smrg	XtSetSensitive (viewPropButton, 0);
4748108eb18Smrg	XtSetSensitive (cloneButton, 0);
4758108eb18Smrg	XtSetSensitive (killClientButton, 0);
4768108eb18Smrg	XtSetSensitive (restartHintButton, 0);
4778108eb18Smrg
4788108eb18Smrg	XtUnmanageChild (clientListWidget);
4798108eb18Smrg	XtManageChild (noClientsLabel);
4808108eb18Smrg
4818108eb18Smrg	reenable_asap = 1;
4828108eb18Smrg
4838108eb18Smrg	return;
4848108eb18Smrg    }
4858108eb18Smrg
4868108eb18Smrg    if (reenable_asap)
4878108eb18Smrg    {
4888108eb18Smrg	XtSetSensitive (viewPropButton, 1);
4898108eb18Smrg	XtSetSensitive (cloneButton, 1);
4908108eb18Smrg	XtSetSensitive (killClientButton, 1);
4918108eb18Smrg	XtSetSensitive (restartHintButton, 1);
4928108eb18Smrg
4938108eb18Smrg	XtUnmanageChild (noClientsLabel);
4948108eb18Smrg	XtManageChild (clientListWidget);
4958108eb18Smrg
4968108eb18Smrg	reenable_asap = 0;
4978108eb18Smrg    }
4988108eb18Smrg
4998108eb18Smrg    clientListNames = (String *) XtMalloc (
5008108eb18Smrg	numClientListNames * sizeof (String));
5018108eb18Smrg    clientListRecs = (ClientRec **) XtMalloc (
5028108eb18Smrg	numClientListNames * sizeof (ClientRec *));
5038108eb18Smrg
5048108eb18Smrg    i = 0;
5058108eb18Smrg    for (cl = ListFirst (RunningList); cl; cl = ListNext (cl))
5068108eb18Smrg    {
5078108eb18Smrg	ClientRec *client = (ClientRec *) cl->thing;
5088108eb18Smrg	int extra1, extra2;
5095977a007Smrg	const char *hint;
5108108eb18Smrg
5118108eb18Smrg	progName = NULL;
5128108eb18Smrg	restart_service_prop = NULL;
5138108eb18Smrg
5148108eb18Smrg	for (pl = ListFirst (client->props); pl; pl = ListNext (pl))
5158108eb18Smrg	{
5168108eb18Smrg	    Prop *pprop = (Prop *) pl->thing;
5178108eb18Smrg	    List *vl = ListFirst (pprop->values);
5188108eb18Smrg
5198108eb18Smrg	    if (vl != NULL)
5208108eb18Smrg	    {
5218108eb18Smrg	    	PropValue *pval = (PropValue *) vl->thing;
5228108eb18Smrg	    	if (strcmp (pprop->name, SmProgram) == 0)
5238108eb18Smrg	    	{
5248108eb18Smrg			progName = GetProgramName ((char *) pval->value);
5258108eb18Smrg	    	}
5268108eb18Smrg	    	else if (strcmp (pprop->name, "_XC_RestartService") == 0)
5278108eb18Smrg	    	{
5288108eb18Smrg			restart_service_prop = (char *) pval->value;
5298108eb18Smrg	    	}
5308108eb18Smrg	    }
5318108eb18Smrg	}
5328108eb18Smrg
5338108eb18Smrg	if (!progName)
5348108eb18Smrg	    continue;
5358108eb18Smrg
5368108eb18Smrg	if (restart_service_prop)
5378108eb18Smrg	    tmp1 = restart_service_prop;
5388108eb18Smrg	else if (client->clientHostname)
5398108eb18Smrg	    tmp1 = client->clientHostname;
5408108eb18Smrg	else
5418108eb18Smrg	    continue;
5428108eb18Smrg
5438108eb18Smrg	if ((tmp2 = (char *) strchr (tmp1, '/')) == NULL)
5448108eb18Smrg	    hostname = tmp1;
5458108eb18Smrg	else
5468108eb18Smrg	    hostname = tmp2 + 1;
5478108eb18Smrg
5488108eb18Smrg	extra1 = maxlen1 - strlen (progName) + 5;
5498108eb18Smrg	extra2 = maxlen2 - strlen (hostname);
5508108eb18Smrg
5518108eb18Smrg	if (client->restartHint == SmRestartIfRunning)
5528108eb18Smrg	    hint = "Restart If Running";
5538108eb18Smrg	else if (client->restartHint == SmRestartAnyway)
5548108eb18Smrg	    hint = "Restart Anyway";
5558108eb18Smrg	else if (client->restartHint == SmRestartImmediately)
5568108eb18Smrg	    hint = "Restart Immediately";
5578108eb18Smrg	else if (client->restartHint == SmRestartNever)
5588108eb18Smrg	    hint = "Restart Never";
5598108eb18Smrg	else
5608108eb18Smrg	    hint = "";
5618108eb18Smrg
5628108eb18Smrg	for (k = 0; k < extra1; k++)
5638108eb18Smrg	    extraBuf1[k] = ' ';
5648108eb18Smrg	extraBuf1[extra1] = '\0';
5658108eb18Smrg
5668108eb18Smrg	for (k = 0; k < extra2; k++)
5678108eb18Smrg	    extraBuf2[k] = ' ';
5688108eb18Smrg	extraBuf2[extra2] = '\0';
5698108eb18Smrg
5705977a007Smrg	XtAsprintf (&clientInfo, "%s%s (%s%s)   %s", progName, extraBuf1,
5718108eb18Smrg	    hostname, extraBuf2, hint);
5728108eb18Smrg
5738108eb18Smrg	clientListRecs[i] = client;
5748108eb18Smrg	clientListNames[i++] = clientInfo;
5758108eb18Smrg    }
5768108eb18Smrg
5778108eb18Smrg    XawListChange (clientListWidget,
5788108eb18Smrg	clientListNames, numClientListNames, 0, True);
5798108eb18Smrg}
5808108eb18Smrg
5818108eb18Smrg
5828108eb18Smrg
5838108eb18Smrgstatic void
5848108eb18SmrgRestartHintXtProc(Widget w, XtPointer client_data, XtPointer callData)
5858108eb18Smrg{
5868108eb18Smrg    XawListReturnStruct *current;
5878108eb18Smrg    ClientRec *client;
5888108eb18Smrg    Widget active;
5898108eb18Smrg    int found = 0;
5908108eb18Smrg    List *pl;
5918108eb18Smrg    char hint;
5928108eb18Smrg
5938108eb18Smrg    current = XawListShowCurrent (clientListWidget);
5948108eb18Smrg
5958108eb18Smrg    if (!current || current->list_index < 0)
5968108eb18Smrg    {
5978108eb18Smrg	if (current)
5988108eb18Smrg	    XtFree ((char *) current);
5998108eb18Smrg	return;
6008108eb18Smrg    }
6018108eb18Smrg
6028108eb18Smrg    client = clientListRecs[current->list_index];
6038108eb18Smrg
6048108eb18Smrg    active = XawSimpleMenuGetActiveEntry (restartHintMenu);
6058108eb18Smrg
6068108eb18Smrg    if (active == restartIfRunning)
6078108eb18Smrg	hint = SmRestartIfRunning;
6088108eb18Smrg    else if (active == restartAnyway)
6098108eb18Smrg	hint = SmRestartAnyway;
6108108eb18Smrg    else if (active == restartImmediately)
6118108eb18Smrg	hint = SmRestartImmediately;
6128108eb18Smrg    else if (active == restartNever)
6138108eb18Smrg	hint = SmRestartNever;
6148108eb18Smrg    else
6158108eb18Smrg    {
6168108eb18Smrg	XtFree ((char *) current);
6178108eb18Smrg	return;
6188108eb18Smrg    }
6198108eb18Smrg
6208108eb18Smrg    client->restartHint = hint;
6218108eb18Smrg
6228108eb18Smrg    for (pl = ListFirst (client->props); pl; pl = ListNext (pl))
6238108eb18Smrg    {
6248108eb18Smrg	Prop *pprop = (Prop *) pl->thing;
6258108eb18Smrg
6268108eb18Smrg	if (strcmp (SmRestartStyleHint, pprop->name) == 0)
6278108eb18Smrg	{
6288108eb18Smrg	    List *vl = ListFirst (pprop->values);
6298108eb18Smrg
6308108eb18Smrg	    PropValue *pval = (PropValue *) vl->thing;
6318108eb18Smrg
6328108eb18Smrg	    *((char *) (pval->value)) = hint;
6338108eb18Smrg	    found = 1;
6348108eb18Smrg	    break;
6358108eb18Smrg	}
6368108eb18Smrg    }
6378108eb18Smrg
6388108eb18Smrg    if (!found)
6398108eb18Smrg    {
6408108eb18Smrg	SmProp prop;
6418108eb18Smrg	SmPropValue propval;
6428108eb18Smrg
6438108eb18Smrg	prop.name = SmRestartStyleHint;
6448108eb18Smrg	prop.type = SmCARD8;
6458108eb18Smrg	prop.num_vals = 1;
6468108eb18Smrg	prop.vals = &propval;
6478108eb18Smrg	propval.value = (SmPointer) &hint;
6488108eb18Smrg	propval.length = 1;
6498108eb18Smrg
6508108eb18Smrg	SetProperty (client, &prop, False /* don't free it */);
6518108eb18Smrg    }
6528108eb18Smrg
6538108eb18Smrg    UpdateClientList ();
6548108eb18Smrg    XawListHighlight (clientListWidget, current_client_selected);
6558108eb18Smrg    ShowHint (client);
6568108eb18Smrg
6578108eb18Smrg    if (client_prop_visible && clientListRecs &&
6588108eb18Smrg	clientListRecs[current_client_selected] == client)
6598108eb18Smrg    {
6608108eb18Smrg	DisplayProps (client);
6618108eb18Smrg    }
6628108eb18Smrg
6638108eb18Smrg    XtFree ((char *) current);
6648108eb18Smrg}
6658108eb18Smrg
6668108eb18Smrg
6678108eb18Smrg
6688108eb18Smrgstatic void
6698108eb18SmrgclientPropDoneXtProc(Widget w, XtPointer client_data, XtPointer callData)
6708108eb18Smrg{
6718108eb18Smrg    XtPopdown (clientPropPopup);
6728108eb18Smrg    client_prop_visible = 0;
6738108eb18Smrg}
6748108eb18Smrg
6758108eb18Smrg
6768108eb18Smrg
6778108eb18Smrgvoid
6788108eb18SmrgClientInfoStructureNotifyXtHandler(Widget w, XtPointer closure,
6798108eb18Smrg				   XEvent *event,
6808108eb18Smrg				   Boolean *continue_to_dispatch)
6818108eb18Smrg{
6828108eb18Smrg    if (event->type == MapNotify)
6838108eb18Smrg    {
6848108eb18Smrg	UpdateClientList ();
6858108eb18Smrg
6868108eb18Smrg	if (current_client_selected >= 0)
6878108eb18Smrg	    XawListHighlight (clientListWidget, current_client_selected);
6888108eb18Smrg
6898108eb18Smrg	XtRemoveEventHandler (clientInfoPopup, StructureNotifyMask, False,
6908108eb18Smrg	    ClientInfoStructureNotifyXtHandler, NULL);
6918108eb18Smrg    }
6928108eb18Smrg}
6938108eb18Smrg
6948108eb18Smrg
6958108eb18Smrg
6968108eb18Smrgvoid
6978108eb18SmrgClientInfoXtProc(Widget w, XtPointer client_data, XtPointer callData)
6988108eb18Smrg{
6998108eb18Smrg    static int first_time = 1;
7008108eb18Smrg
7018108eb18Smrg    if (client_info_visible)
7028108eb18Smrg    {
7038108eb18Smrg	/* Make sure it is visible */
7048108eb18Smrg
7058108eb18Smrg	XMapRaised (XtDisplay (topLevel), XtWindow (clientInfoPopup));
7068108eb18Smrg    }
7078108eb18Smrg    else
7088108eb18Smrg    {
7098108eb18Smrg	UpdateClientList ();
7108108eb18Smrg
7118108eb18Smrg	if (clientListRecs && clientListRecs[0])
7128108eb18Smrg	{
7138108eb18Smrg	    current_client_selected = 0;
7148108eb18Smrg	    XawListHighlight (clientListWidget, 0);
7158108eb18Smrg	    ShowHint (clientListRecs[0]);
7168108eb18Smrg	    if (client_prop_visible)
7178108eb18Smrg		DisplayProps (clientListRecs[0]);
7188108eb18Smrg	}
7198108eb18Smrg	else
7208108eb18Smrg	    current_client_selected = -1;
7218108eb18Smrg
7228108eb18Smrg	if (first_time && num_clients_in_last_session > 0 &&
7238108eb18Smrg	    num_clients_in_last_session != numClientListNames)
7248108eb18Smrg	{
7258108eb18Smrg	    XtAddEventHandler (clientInfoPopup, StructureNotifyMask, False,
7268108eb18Smrg	        ClientInfoStructureNotifyXtHandler, NULL);
7278108eb18Smrg	}
7288108eb18Smrg
7298108eb18Smrg	PopupPopup (mainWindow, clientInfoPopup,
7308108eb18Smrg	    False, first_time, 100, 50, "DelClientInfoWinAction()");
7318108eb18Smrg
7328108eb18Smrg	client_info_visible = 1;
7338108eb18Smrg
7348108eb18Smrg	if (first_time)
7358108eb18Smrg	    first_time = 0;
7368108eb18Smrg    }
7378108eb18Smrg}
7388108eb18Smrg
7398108eb18Smrg
7408108eb18Smrg#define CHECK_WIDTH 9
7418108eb18Smrg#define CHECK_HEIGHT 8
7428108eb18Smrg
7438108eb18Smrgstatic unsigned char check_bits[] = {
7448108eb18Smrg   0x00, 0x01, 0x80, 0x01, 0xc0, 0x00, 0x60, 0x00,
7458108eb18Smrg   0x31, 0x00, 0x1b, 0x00, 0x0e, 0x00, 0x04, 0x00
7468108eb18Smrg};
7478108eb18Smrg
7488108eb18Smrg
7498108eb18Smrg
7508108eb18Smrgstatic void
7518108eb18SmrgDelClientInfoWinAction(Widget w, XEvent *event, String *params,
7528108eb18Smrg		       Cardinal *num_params)
7538108eb18Smrg{
7548108eb18Smrg    XtCallCallbacks (clientInfoDoneButton, XtNcallback, NULL);
7558108eb18Smrg}
7568108eb18Smrg
7578108eb18Smrg
7588108eb18Smrg
7598108eb18Smrgstatic void
7608108eb18SmrgDelPropWinAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
7618108eb18Smrg{
7628108eb18Smrg    XtCallCallbacks (clientPropDoneButton, XtNcallback, NULL);
7638108eb18Smrg}
7648108eb18Smrg
7658108eb18Smrg
7668108eb18Smrg
7678108eb18Smrgvoid
7688108eb18Smrgcreate_client_info_popup(void)
7698108eb18Smrg
7708108eb18Smrg{
7718108eb18Smrg    /*
7728108eb18Smrg     * Install actions for WM_DELETE_WINDOW
7738108eb18Smrg     */
7748108eb18Smrg
7758108eb18Smrg    static XtActionsRec actions[] = {
7768108eb18Smrg        {"DelClientInfoWinAction", DelClientInfoWinAction},
7778108eb18Smrg        {"DelPropWinAction", DelPropWinAction}
7788108eb18Smrg    };
7798108eb18Smrg
7808108eb18Smrg    XtAppAddActions (appContext, actions, XtNumber (actions));
7818108eb18Smrg
7828108eb18Smrg
7838108eb18Smrg    /*
7848108eb18Smrg     * Make checkmark bitmap
7858108eb18Smrg     */
7868108eb18Smrg
7878108eb18Smrg    checkBitmap = XCreateBitmapFromData (
7888108eb18Smrg	XtDisplay (topLevel), RootWindowOfScreen (XtScreen (topLevel)),
7898108eb18Smrg	(char *) check_bits, CHECK_WIDTH, CHECK_HEIGHT);
7908108eb18Smrg
7918108eb18Smrg
7928108eb18Smrg    /*
7938108eb18Smrg     * Pop up for List Clients button.
7948108eb18Smrg     */
7958108eb18Smrg
7968108eb18Smrg    clientInfoPopup = XtVaCreatePopupShell (
7978108eb18Smrg	"clientInfoPopup", topLevelShellWidgetClass, topLevel,
7988108eb18Smrg	XtNallowShellResize, True,
7998108eb18Smrg	NULL);
8008108eb18Smrg
8018108eb18Smrg
8028108eb18Smrg    clientInfoForm = XtVaCreateManagedWidget (
8038108eb18Smrg	"clientInfoForm", formWidgetClass, clientInfoPopup,
8048108eb18Smrg	NULL);
8058108eb18Smrg
8068108eb18Smrg    viewPropButton = XtVaCreateManagedWidget (
8078108eb18Smrg	"viewPropButton", commandWidgetClass, clientInfoForm,
8088108eb18Smrg        XtNfromHoriz, NULL,
8098108eb18Smrg        XtNfromVert, NULL,
8108108eb18Smrg	XtNtop, XawChainTop,
8118108eb18Smrg	XtNbottom, XawChainTop,
8128108eb18Smrg	XtNleft, XawChainLeft,
8138108eb18Smrg	XtNright, XawChainLeft,
8148108eb18Smrg        NULL);
8151a650d1eSmrg
8161a650d1eSmrg    XtAddCallback (viewPropButton, XtNcallback, ViewPropXtProc, NULL);
8178108eb18Smrg
8188108eb18Smrg
8198108eb18Smrg    cloneButton = XtVaCreateManagedWidget (
8208108eb18Smrg	"cloneButton", commandWidgetClass, clientInfoForm,
8218108eb18Smrg        XtNfromHoriz, viewPropButton,
8228108eb18Smrg        XtNfromVert, NULL,
8238108eb18Smrg	XtNtop, XawChainTop,
8248108eb18Smrg	XtNbottom, XawChainTop,
8258108eb18Smrg	XtNleft, XawChainLeft,
8268108eb18Smrg	XtNright, XawChainLeft,
8278108eb18Smrg        NULL);
8281a650d1eSmrg
8291a650d1eSmrg    XtAddCallback (cloneButton, XtNcallback, CloneXtProc, NULL);
8308108eb18Smrg
8318108eb18Smrg
8328108eb18Smrg    killClientButton = XtVaCreateManagedWidget (
8338108eb18Smrg	"killClientButton", commandWidgetClass, clientInfoForm,
8348108eb18Smrg        XtNfromHoriz, cloneButton,
8358108eb18Smrg        XtNfromVert, NULL,
8368108eb18Smrg	XtNtop, XawChainTop,
8378108eb18Smrg	XtNbottom, XawChainTop,
8388108eb18Smrg	XtNleft, XawChainLeft,
8398108eb18Smrg	XtNright, XawChainLeft,
8408108eb18Smrg        NULL);
8411a650d1eSmrg
8421a650d1eSmrg    XtAddCallback (killClientButton, XtNcallback, KillClientXtProc, NULL);
8438108eb18Smrg
8448108eb18Smrg
8458108eb18Smrg    restartHintButton = XtVaCreateManagedWidget (
8468108eb18Smrg	"restartHintButton", menuButtonWidgetClass, clientInfoForm,
8478108eb18Smrg	XtNmenuName, "restartHintMenu",
8488108eb18Smrg        XtNfromHoriz, killClientButton,
8498108eb18Smrg        XtNfromVert, NULL,
8508108eb18Smrg	XtNtop, XawChainTop,
8518108eb18Smrg	XtNbottom, XawChainTop,
8528108eb18Smrg	XtNleft, XawChainLeft,
8538108eb18Smrg	XtNright, XawChainLeft,
8548108eb18Smrg	NULL);
8558108eb18Smrg
8568108eb18Smrg    restartHintMenu = XtVaCreatePopupShell (
8578108eb18Smrg	"restartHintMenu", simpleMenuWidgetClass, clientInfoForm,
8588108eb18Smrg	NULL);
8598108eb18Smrg
8608108eb18Smrg    restartIfRunning = XtVaCreateManagedWidget (
8618108eb18Smrg	"restartIfRunning", smeBSBObjectClass, restartHintMenu,
8628108eb18Smrg	XtNleftMargin, 18,
8638108eb18Smrg	NULL);
8648108eb18Smrg
8658108eb18Smrg    restartAnyway = XtVaCreateManagedWidget (
8668108eb18Smrg	"restartAnyway", smeBSBObjectClass, restartHintMenu,
8678108eb18Smrg	XtNleftMargin, 18,
8688108eb18Smrg	NULL);
8698108eb18Smrg
8708108eb18Smrg    restartImmediately = XtVaCreateManagedWidget (
8718108eb18Smrg	"restartImmediately", smeBSBObjectClass, restartHintMenu,
8728108eb18Smrg	XtNleftMargin, 18,
8738108eb18Smrg	NULL);
8748108eb18Smrg
8758108eb18Smrg    restartNever = XtVaCreateManagedWidget (
8768108eb18Smrg	"restartNever", smeBSBObjectClass, restartHintMenu,
8778108eb18Smrg	XtNleftMargin, 18,
8788108eb18Smrg	NULL);
8798108eb18Smrg
8801a650d1eSmrg    XtAddCallback (restartIfRunning, XtNcallback, RestartHintXtProc, NULL);
8811a650d1eSmrg    XtAddCallback (restartAnyway, XtNcallback, RestartHintXtProc, NULL);
8821a650d1eSmrg    XtAddCallback (restartImmediately, XtNcallback, RestartHintXtProc, NULL);
8831a650d1eSmrg    XtAddCallback (restartNever, XtNcallback, RestartHintXtProc, NULL);
8848108eb18Smrg
8858108eb18Smrg
8868108eb18Smrg    clientInfoDoneButton = XtVaCreateManagedWidget (
8878108eb18Smrg	"clientInfoDoneButton", commandWidgetClass, clientInfoForm,
8888108eb18Smrg        XtNfromHoriz, restartHintButton,
8898108eb18Smrg        XtNfromVert, NULL,
8908108eb18Smrg	XtNtop, XawChainTop,
8918108eb18Smrg	XtNbottom, XawChainTop,
8928108eb18Smrg	XtNleft, XawChainLeft,
8938108eb18Smrg	XtNright, XawChainLeft,
8948108eb18Smrg        NULL);
8958108eb18Smrg
8961a650d1eSmrg    XtAddCallback (clientInfoDoneButton, XtNcallback, listDoneXtProc, NULL);
8978108eb18Smrg
8988108eb18Smrg
8998108eb18Smrg    clientListWidget = XtVaCreateManagedWidget (
9008108eb18Smrg	"clientListWidget", listWidgetClass, clientInfoForm,
9018108eb18Smrg        XtNdefaultColumns, 1,
9028108eb18Smrg	XtNforceColumns, True,
9038108eb18Smrg        XtNfromHoriz, NULL,
9048108eb18Smrg        XtNfromVert, viewPropButton,
9058108eb18Smrg	XtNresizable, True,
9068108eb18Smrg	XtNtop, XawChainTop,
9078108eb18Smrg	XtNbottom, XawChainTop,
9088108eb18Smrg	NULL);
9098108eb18Smrg
9101a650d1eSmrg    XtAddCallback (clientListWidget, XtNcallback, ClientListXtProc, NULL);
9118108eb18Smrg
9128108eb18Smrg    noClientsLabel = XtVaCreateWidget (
9138108eb18Smrg	"noClientsLabel", labelWidgetClass, clientInfoForm,
9148108eb18Smrg        XtNfromHoriz, NULL,
9158108eb18Smrg        XtNfromVert, viewPropButton,
9168108eb18Smrg        XtNborderWidth, 0,
9178108eb18Smrg	XtNtop, XawChainTop,
9188108eb18Smrg	XtNbottom, XawChainTop,
9198108eb18Smrg	NULL);
9208108eb18Smrg
9218108eb18Smrg    manualRestartLabel = XtVaCreateManagedWidget (
9228108eb18Smrg	"manualRestartLabel", labelWidgetClass, clientInfoForm,
9238108eb18Smrg        XtNfromHoriz, NULL,
9248108eb18Smrg        XtNfromVert, clientListWidget,
9258108eb18Smrg        XtNborderWidth, 0,
9268108eb18Smrg        XtNvertDistance, 20,
9278108eb18Smrg	XtNtop, XawChainBottom,
9288108eb18Smrg	XtNbottom, XawChainBottom,
9298108eb18Smrg	XtNleft, XawChainLeft,
9308108eb18Smrg	XtNright, XawChainLeft,
9318108eb18Smrg	NULL);
9328108eb18Smrg
9338108eb18Smrg    manualRestartCommands = XtVaCreateManagedWidget (
9348108eb18Smrg	"manualRestartCommands", asciiTextWidgetClass, clientInfoForm,
9358108eb18Smrg        XtNfromHoriz, NULL,
9368108eb18Smrg        XtNfromVert, manualRestartLabel,
9378108eb18Smrg	XtNeditType, XawtextEdit,
9388108eb18Smrg	XtNresizable, True,
9398108eb18Smrg	XtNresize, XawtextResizeWidth,
9408108eb18Smrg	XtNscrollVertical, XawtextScrollAlways,
9418108eb18Smrg	XtNwidth, 350,
9428108eb18Smrg	XtNheight, 100,
9438108eb18Smrg	XtNtop, XawChainBottom,
9448108eb18Smrg	XtNbottom, XawChainBottom,
9458108eb18Smrg	NULL);
9468108eb18Smrg
9478108eb18Smrg    /*
9488108eb18Smrg     * Pop up for viewing client properties
9498108eb18Smrg     */
9508108eb18Smrg
9518108eb18Smrg    clientPropPopup = XtVaCreatePopupShell (
9528108eb18Smrg	"clientPropPopup", topLevelShellWidgetClass, topLevel,
9538108eb18Smrg	XtNallowShellResize, True,
9548108eb18Smrg	NULL);
9558108eb18Smrg
9568108eb18Smrg
9578108eb18Smrg    clientPropForm = XtVaCreateManagedWidget (
9588108eb18Smrg	"clientPropForm", formWidgetClass, clientPropPopup,
9598108eb18Smrg	NULL);
9608108eb18Smrg
9618108eb18Smrg    clientPropDoneButton = XtVaCreateManagedWidget (
9628108eb18Smrg	"clientPropDoneButton", commandWidgetClass, clientPropForm,
9638108eb18Smrg        XtNfromHoriz, NULL,
9648108eb18Smrg        XtNfromVert, NULL,
9658108eb18Smrg	XtNtop, XawChainTop,
9668108eb18Smrg	XtNbottom, XawChainTop,
9678108eb18Smrg	XtNleft, XawChainLeft,
9688108eb18Smrg	XtNright, XawChainLeft,
9698108eb18Smrg        NULL);
9708108eb18Smrg
9711a650d1eSmrg    XtAddCallback (clientPropDoneButton, XtNcallback, clientPropDoneXtProc, NULL);
9728108eb18Smrg
9738108eb18Smrg
9748108eb18Smrg    clientPropTextWidget = XtVaCreateManagedWidget (
9758108eb18Smrg	"clientPropTextWidget", asciiTextWidgetClass, clientPropForm,
9768108eb18Smrg        XtNfromHoriz, NULL,
9778108eb18Smrg        XtNfromVert, clientPropDoneButton,
9788108eb18Smrg	XtNeditType, XawtextRead,
9798108eb18Smrg        XtNdisplayCaret, False,
9808108eb18Smrg	XtNscrollVertical, XawtextScrollWhenNeeded,
9818108eb18Smrg	XtNscrollHorizontal, XawtextScrollWhenNeeded,
9828108eb18Smrg	XtNresizable, True,
9838108eb18Smrg	XtNtop, XawChainTop,
9848108eb18Smrg	XtNbottom, XawChainBottom,
9858108eb18Smrg	NULL);
9868108eb18Smrg}
987