Files
mcde/programs/dtchat/ui_request.h
T
lotherk 64979ecebd dtchat: add the request, error and QR dialogs (T2.5)
ui_request.c turns one adapter request object into a Motif dialog: code, password (masked via modifyVerify, the real value kept out of the widget), notice, confirm and qr. The QR bitmap is base64 (one byte per module), drawn into a depth-1 pixmap and shown as XmNlabelPixmap; no QR library. The answer is delivered exactly once from OK/Yes/No, Cancel, the timeout or the window-manager close, and the dialog frees itself before the callback runs. dtchat_error_dialog is the one-button error/notice window. The smoke test exercises all five kinds plus the timeout; --demo-request qr|code|password|error shows one for screenshots. Standalone smoke PASS; QR and masked password verified on Xvfb (build/mcde-shots/dtchat-t25.png). make mcde-host still blocked by the foreign release build holding build/.build.lock (pid 175328).
2026-11-16 18:46:56 +00:00

39 lines
1.4 KiB
C

/*
* ui_request.h -- the request, error and QR dialogs of dtchat
*
* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
*/
#ifndef _Dtchat_ui_request_h
#define _Dtchat_ui_request_h
#include <X11/Intrinsic.h>
#include "dc_internal.h"
typedef struct DtRequestDialog DtRequestDialog;
/*
* Called exactly once: with the answer text, or with NULL for cancel,
* timeout and window-manager close. The dialog destroys itself before the
* callback returns, so the callback may open the next dialog.
*/
typedef void (*DtRequestAnswerFn)(const char *value, void *arg);
/*
* Build the dialog for one adapter "request" object of the v1 protocol
* (kind code/password/notice/confirm/qr). TIMEOUT_MS <= 0 means no
* timeout. Returns NULL for an unknown kind or an allocation failure.
*/
DtRequestDialog *dtchat_request_dialog_create(Widget parent,
const DcJson *request, int timeout_ms, DtRequestAnswerFn answer, void *arg);
void dtchat_request_dialog_destroy(DtRequestDialog *dialog);
Widget dtchat_request_dialog_shell(const DtRequestDialog *dialog);
/* Same path as the buttons: answers VALUE (NULL = cancel) once. */
void dtchat_request_dialog_answer(DtRequestDialog *dialog, const char *value);
/* An error/notice window with one Dismiss button; it frees itself. */
void dtchat_error_dialog(Widget parent, const char *title, const char *text);
#endif /* _Dtchat_ui_request_h */