🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #37484

`Working dialogs' in Motif

#37484
From: Paul Vianna
Date: Wed, 28 Feb 1990 16:47
83 lines
2964 bytes
The C code below uses the Motif X Toolkit to pop up a button that can be
used to trigger the execution of some application code (simply reads
a string entered by the user in this example). Assuming that the
application code will take some time, a status window is popped up to
tell the user that we are "Working...". Unfortunately, due to the order
that things are done by the X toolkit, a blank status window is displayed
while the application code runs. If the XtUnmanageChild() call is commented
out, then the "Working..." text is displayed, but only *after* the
application code is finished.

Does anyone know how such a status window can be completely displayed
*before* the application code begins? Thanks!

--
Paul Vianna
pvianna@Citicorp.COM
uunet!ccorp!pvianna

/* dialog.c - Test of a simple button-activated dialog. */

#include <stdio.h>
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <Xm/Xm.h>
#include <Xm/PushB.h>
#include <Xm/Text.h>
#include <Xm/MessageB.h>

static void buttonPressCallback(button, clientData, callData)
     Widget button;
     caddr_t clientData, callData;
{
    char line[80];
    static Widget box = NULL;
    
    if (!box) {
	XmString title = XmStringCreateLtoR(" Waiting... ", 
					    XmSTRING_DEFAULT_CHARSET);
	XmString msg = XmStringCreateLtoR("Waiting for a string...", 
					  XmSTRING_DEFAULT_CHARSET);
	Arg args[10];
	int n = 0;
	
	XtSetArg(args[n], XmNmessageString,  msg);                         n++;
	XtSetArg(args[n], XmNdialogTitle,    title);                       n++;
	XtSetArg(args[n], XmNdialogStyle,    XmDIALOG_APPLICATION_MODAL);  n++;
	box = XmCreateWorkingDialog(button, "WorkingBox", args, n);
	}

    XtManageChild(box);
    XSync(XtDisplay(box), False);

    fprintf(stderr, "Enter a string: ");
    gets(line);
    fprintf(stderr, "You typed: `%s'\n", line);
    XtUnmanageChild(box);
    }

main(ac, av)
     int ac;
     char **av;
{
    Widget topLevel, button, dialog;
    Arg args[10];
    int n = 0;

    topLevel = XtInitialize(av[0], "Dialog", NULL, 0, &ac, av);

    XtSetArg(args[n], XmNwidth,  150); n++;
    XtSetArg(args[n], XmNheight, 150); n++;
    button = XtCreateManagedWidget("button", xmPushButtonWidgetClass, topLevel,
				   args, n);
    XtAddCallback(button, XmNactivateCallback, buttonPressCallback, NULL);

    XtRealizeWidget(topLevel);
    XtMainLoop();
    }
-- 
Dominick Samperi
Citicorp, NAIB
uunet!naib!samperi
Technical Details
Message-ID: <1990Feb28.164742.1177@Citicorp.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!marob!ccorp!pvianna

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!marob!ccorp!pvianna
From: pvianna@Citicorp.COM (Paul Vianna)
Newsgroups: comp.windows.x
Subject: `Working dialogs' in Motif
Keywords: Motif, dialogs, synchronous window display
Message-ID: <1990Feb28.164742.1177@Citicorp.COM>
Date: 28 Feb 90 16:47:42 GMT
Organization: Citicorp, New York City
Lines: 83