LICENSE at the root; the 103 files new in ext/src/mcde (none was in the CDE import) carry the CNCL line instead of the LGPL notice. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
73 lines
2.1 KiB
C
73 lines
2.1 KiB
C
/*
|
|
* dterror.ds -- an error dialog with a message.
|
|
*
|
|
* usage: dterror.ds MESSAGE [TITLE [OK-LABEL]]
|
|
*
|
|
* For the places that have to tell the user something when the program that
|
|
* should do it cannot: an action whose command is missing, an exec that failed
|
|
* in a child, an error before an application's window exists (the data types
|
|
* of the desktop, dtopen, dtfile). It was a dtksh script (dterror.src,
|
|
* dtfile_error.cpp, types/error.ds.src); Konrad, 2026-11-14: dtksh is out of
|
|
* MCDE, this is a Motif program like the rest, in C.
|
|
*
|
|
* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <X11/Intrinsic.h>
|
|
#include <X11/Shell.h>
|
|
#include <Xm/Xm.h>
|
|
#include <Xm/MessageB.h>
|
|
|
|
static void
|
|
Quit(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) w;
|
|
(void) data;
|
|
(void) call;
|
|
exit(0);
|
|
}
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
XtAppContext app;
|
|
Widget top, dialog;
|
|
Arg args[4];
|
|
XmString message, title, ok = NULL;
|
|
int n = 0;
|
|
|
|
top = XtVaOpenApplication(&app, "DtError", NULL, 0, &argc, argv, NULL,
|
|
applicationShellWidgetClass, NULL);
|
|
if (argc < 2) {
|
|
fprintf(stderr, "usage: dterror.ds MESSAGE [TITLE [OK-LABEL]]\n");
|
|
return 2;
|
|
}
|
|
|
|
/* LtoR: the message may have line ends */
|
|
message = XmStringCreateLtoR(argv[1], XmFONTLIST_DEFAULT_TAG);
|
|
title = XmStringCreateLocalized(argc > 2 ? argv[2] : "dt Error");
|
|
XtSetArg(args[n], XmNmessageString, message); n++;
|
|
XtSetArg(args[n], XmNdialogTitle, title); n++;
|
|
if (argc > 3) {
|
|
ok = XmStringCreateLocalized(argv[3]);
|
|
XtSetArg(args[n], XmNokLabelString, ok); n++;
|
|
}
|
|
dialog = XmCreateErrorDialog(top, "error", args, n);
|
|
XmStringFree(message);
|
|
XmStringFree(title);
|
|
if (ok != NULL)
|
|
XmStringFree(ok);
|
|
|
|
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
|
|
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
|
|
XtAddCallback(dialog, XmNokCallback, Quit, NULL);
|
|
/* closed by the window manager: nothing keeps the process alive */
|
|
XtAddCallback(dialog, XmNunmapCallback, Quit, NULL);
|
|
XtManageChild(dialog);
|
|
XtAppMainLoop(app);
|
|
return 0;
|
|
}
|