LJ Archive

Listing 2. Ttchmodd: command widget

#include <stdio.h>
#include <Xm/Command.h>
#include <stdio.h>
#include <Tt/tt_c.h>
Widget        topLevel;
XtAppContext  appContext;
Display       *display;
void CmdCB         (Widget, XtPointer, XtPointer);
int  Register      ();
void ToolTalkCB    (Widget, XtPointer, XtPointer);
int  ToolTalkAbort (char *, Tt_status);
void main (argc, argv)
   int     argc;
   char    *argv[];
{
   Widget  cmd;
   int     ttfd;
   topLevel = XtVaAppInitialize(&appContext,
      "TtChmodd", NULL, 0,
      &argc, argv, NULL, NULL);
   cmd = XtVaCreateManagedWidget(
      "command",
      xmCommandWidgetClass,
      topLevel, NULL);
   XtAddCallback(cmd,
      XmNcommandEnteredCallback,
      CmdCB, NULL);
   ttfd = Register();
   XtAppAddInput(appContext, ttfd,
      (XtPointer)XtInputReadMask,
      ToolTalkCB, cmd);
   XtRealizeWidget(topLevel);
   XtAppMainLoop(appContext);
   tt_close();
}
void CmdCB (w, clientData, callData)
/*  widget id  */
Widget     w;
/*  data from application   */
XtPointer       clientData;
/*  data from widget class  */
XtPointer       callData;
{
   XmCommandCallbackStruct *cbs =
      (XmCommandCallbackStruct *) callData;
   char *cmd;
   XmStringGetLtoR(cbs->value,
      XmSTRING_DEFAULT_CHARSET, &cmd);
   printf("CmdCB(): %s\n", cmd);
}
LJ Archive