DTACTIONCALLBACKPROC(3)
π NAME π
okay bestie, welcome to DtActionCallbackProc β sheβs a library call β and her whole job is to notify the application that the status of an application has changed. itβs giving βyour action has updatesβ energy, and weβre obsessed. π
β¨ SYNOPSIS β¨
#include &<Dt/Action.h>
π¦ DESCRIPTION π¦
the Dt/Action.h header defines the DtActionCallbackProc callback prototype like this, bestie:
typedef void (*DtActionCallbackProc)(DtActionInvocationID id,
XtPointer client_data,
DtActionArg *args,
int argCount,
DtActionStatus status);
if you registered one when invoking an action with DtActionInvoke(3), a DtActionCallbackProc procedure gets called whenever an action has a status update β such as action termination. depending on status, modified action arguments may be returned using args. π
the id argument specifies an invocation ID as returned by DtActionInvoke(3).
the client_data argument specifies the client data that was registered with DtActionInvoke(3).
the args argument is an array of updated action argument structures, if there are any. individual arguments have their argClass set to one of the standard argument classes, or DtACTION_NULLARG, to indicate that the current status update is not providing an update for the given argument. if the object has been removed (for example, dropped on the trash), the return argClass is set to DtACTION_NULLARG to indicate that it no longer exists. ποΈ
the args array has been allocated by XtMalloc(3), as have any of the char* or void* elements contained in each of the args.
bestie, memory management is literally your job here: the application is responsible for callingXtFree(3)on all elements contained in each of theargs, and then callingXtFree(3)onargs. no cap. π«Ά
the argCount argument specifies the total number of arguments in args. this number equals the number of arguments originally provided to DtActionInvoke(3).
the *n*th argument in the original action argument array corresponds to the *n*th argument in an updated action argument array.
the status argument specifies the purpose of the status update. the status codes listed here and in Dt/Action.h - DtAction(5) may be returned in a DtActionCallbackProc:
DtACTION_INVOKEDβ the correspondingDtActionInvoke(3), which is asynchronous and does not block when starting actions, has finished starting the requested actions. for allDtActionInvoke(3)calls that include aDtactionCallbackProc, this status code is guaranteed to be returned. when returned, no additional prompts for data will appear from the action service. β¨DtACTION_DONEβ the actions that were the result of the originalDtActionInvoke(3)call have terminated normally. once this status value is returned, all registered callbacks are invalidated, andidcan no longer be used in subsequent action service calls. returnedargsdata may accompany theDtACTION_DONEstatus code. for allDtActionInvoke(3)calls that include aDtActionCallbackProc, this status code or an equivalent status code (for example,DtACTION_CANCELEDorDtACTION_FAILED) is guaranteed to be returned. πDtACTION_CANCELEDβ the actions that were the result of the originalDtActionInvoke(3)call were canceled and have terminated normally. once this status value is returned, all registered callbacks are invalidated, andidcan no longer be used in subsequent action service calls. noargsdata will accompany theDtACTION_CANCELEDstatus code. πDtACTION_FAILEDβ an error occurred and a normal termination is no longer possible. the action service may have failed to start the action or lost contact with and abandoned the action. once this status value is returned, an error dialog may be posted by the action service, all registered callbacks are invalidated, andidcan no longer be used in subsequent action service calls. noargsdata will accompany theDtACTION_FAILEDstatus code. πDtACTION_STATUS_UPDATEβ the actions associated withidhave generated a status update, such as returning modifiedargs. updates occur in several ways. π- if several actions were started from a single
DtActionInvoke(3), then as each individual action terminates, aDtACTION_STATUS_UPDATEwith returnargsis returned, and when the final action terminates, aDtACTION_DONEor equivalent status code is returned, possibly with return arguments. - other actions may have the capability to generate updates (for example, Tooltalk-based actions doing a Media Exchange Deposit (Request)).
- in most cases, a
DtActionArgargument array accompanying aDtACTION_STATUS_UPDATEonly has updated data for a few of the arguments; the remaining arguments are set toDtACTION_NULLARG.
- if several actions were started from a single
πΈ EXAMPLES πΈ
the following shows how a DtActionCallbackProc might be coded. copy it exactly, bestie β feral ampersands and all β because thatβs what the page says. π
DtActionCallbackProc myCallback(
DtActionInvocationID id,
XtPointer client_data,
DtActionArg *actionArgPtr,
int actionArgCount,
DtActionStatus status);
{
extern DtActionArg *myUpdatedArgs; /* global hook for new data */
extern int myDoneFlag; /* global done flag */
switch (status) {
case DtACTION_INVOKED:
/*
* All the arguments to the original DtActionInvoke
* have been consumed by actions, and the actions have
* been started. Among other things, we will not see
* any more prompts for user input.
*/
break;
case DtACTION_DONE:
myUpdatedArgs = (DtActionArg *) actionArgPtr;
myDoneFlag = TRUE;
break;
case DtACTION_CANCELED:
case DtACTION_FAILED:
if ((actionArgCount != 0) &&&& actionArgPtr) {
/*
* If not a normal shutdown, throw away returned
* information.
*/
for (i=0; i &< actionArgCount; i++) {
if (actionArgPtr[i].argClass == DtACTION_FILE) {
XtFree(actionArgPtr[i].u.file.name);
} else if (actionArgPtr[i].argClass ==
DtACTION_BUFFER) {
XtFree(actionArgPtr[i].u.buffer.bp);
XtFree(actionArgPtr[i].u.buffer.type);
XtFree(actionArgPtr[i].u.buffer.name);
}
}
XtFree(actionArgPtr);
}
myUpdatedArgs = (DtActionArg *) NULL;
myDoneFlag = FALSE;
break;
case DtACTION_STATUS_UPDATE:
myUpdatedArgs = (DtActionArg *) actionArgPtr;
myDoneFlag = FALSE;
break;
default:
/* ignore */
break;
}
}
π SEE ALSO π
go read these too, iykyk:
Dt/Action.h - DtAction(5)DtDbLoad(3)DtActionLabel(3)DtActionDescription(3)DtActionExists(3)DtActionInvoke(3)XtMalloc(3)XtFree(3)dtdtfile(4)
mwah π β source/version vibe: library call; date: not printed on this page, bestie. thatβs the whole DtActionCallbackProc moment. π
π¦ where this page comes from
- nixos 26.05: cde 2.5.3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms