2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: printJob.c /main/29 1997/08/01 14:32:04 samborn $ */
24 /**********************************<+>*************************************
25 ***************************************************************************
29 ** Project: HP DT dtpad, a memo maker type editor based on the
32 ** Description: Routines which manipulate the print setup dialog
34 **************************************************************************
35 **********************************<+>*************************************/
37 * Common Desktop Environment
39 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
40 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
41 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
42 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
43 * (c) Copyright 1995 Digital Equipment Corp.
44 * (c) Copyright 1995 Fujitsu Limited
45 * (c) Copyright 1995 Hitachi, Ltd.
48 * RESTRICTED RIGHTS LEGEND
50 *Use, duplication, or disclosure by the U.S. Government is subject to
51 *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
52 *Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
53 *for non-DOD U.S. Government Departments and Agencies are as set forth in
54 *FAR 52.227-19(c)(1,2).
56 *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
57 *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
58 *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
59 *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
60 *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
61 *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
62 *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
70 #include <sys/types.h>
73 #include <X11/Intrinsic.h>
74 #include <X11/Shell.h>
76 #include <Xm/DialogS.h>
79 #if 0 && defined(PRINTING_SUPPORTED)
81 #endif /* PRINTING_SUPPORTED */
82 #include <Dt/Editor.h>
87 static void _pjCreatePrintShell(PrintJob *pJob);
88 static void _pjCreateOutputWidgets(PrintJob *pJob);
89 static void _pjDoPrint(PrintJob*);
90 static void _pjUpdatePageHeaders(
96 #if 0 && defined(PRINTING_SUPPORTED)
97 static void _pjFinishedPrintToFile(
102 #endif /* PRINTING_SUPPORTED */
103 static char * _pjGetPageHeaderString(PrintJob*, PrintStringTypeEnum);
105 static void _pjCancelCB (Widget, XtPointer client_data, XtPointer);
106 static void _pjCloseDisplayCB (Widget, XtPointer client_data, XtPointer);
107 static void _pjPdmSetupCB (Widget, XtPointer client_data, XtPointer);
108 static void _pjPdmNotificationCB (Widget, XtPointer client_data, XtPointer);
109 static void _pjPrintCB (Widget, XtPointer client_data, XtPointer);
110 static void _pjPrintOnePageCB(Widget, XtPointer, XtPointer);
112 static void _pjRegisterActivePrintDisplay(Display*);
113 static void _pjUnregisterActivePrintDisplay(Display*);
115 static Display *_pjErrorPrintDisplay = NULL;
116 static Display **_pjActivePrintDisplay = NULL;
117 static int _pjMaxActivePrintDisplay = 0;
119 /************************************************************************
121 * Creates a new print job for the specified document file.
122 ************************************************************************/
133 pJob = (PrintJob *) XtMalloc( sizeof(PrintJob) );
134 memset(pJob, 0, sizeof(PrintJob));
137 pJob->parentShell = pPad->app_shell;
138 pJob->documentName = strdup(documentName);
139 pJob->tempFileName = strdup(tempFileName);
140 pJob->silent = silent;
142 pJob->pOutput = NULL;
145 pJob->printData = (DtPrintSetupData*) XtMalloc(sizeof(DtPrintSetupData));
146 memset(pJob->printData, 0, sizeof(DtPrintSetupData));
148 pJob->npagesDone = 0;
149 pJob->npagesTotal = 0;
151 pJob->nextpageShell = NULL;
152 pJob->nextpageButton = NULL;
157 /************************************************************************
159 * Destroys the specified PrintJob.
160 ************************************************************************/
162 PrintJobDestroy(PrintJob *pJob)
169 pJob->pPad->numPendingTasks--;
170 ClearStatusMessage(pJob->pPad);
171 XtSetSensitive(pJob->pPad->fileStuff.fileWidgets.printBtn, True);
173 XtSetSensitive(pJob->pPad->fileStuff.fileWidgets.silentPrintBtn, True);
176 if (pJob->documentName != NULL)
178 free((char*) pJob->documentName);
179 pJob->documentName = NULL;
181 if (pJob->tempFileName != NULL)
183 free((char*) pJob->tempFileName);
184 pJob->tempFileName = NULL;
186 if (pJob->pOutput != NULL)
188 PrintOutputDestroy(pJob->pOutput);
189 pJob->pOutput = NULL;
191 if (pJob->pShell != NULL)
193 _pjRegisterActivePrintDisplay(XtDisplay(pJob->pShell));
194 if (XtDisplay(pJob->pShell) == PrintJobGetErrorPrintDisplay())
199 * Need to display an error dialog;
204 "The X Print Server is temporarily out of resources.");
206 Warning(pJob->pPad, (char *) errMsg, XmDIALOG_ERROR);
207 PrintJobSetErrorPrintDisplay(NULL);
210 XtDestroyWidget(pJob->pShell);
213 if (pJob->pSetup != NULL)
215 PrintSetupDestroy(pJob->pSetup);
220 DtPrintFreeSetupData(pJob->printData);
221 XtFree((XtPointer) pJob->printData);
222 pJob->printData = NULL;
224 if (pJob->nextpageShell)
226 XtDestroyWidget(pJob->nextpageShell);
227 pJob->nextpageShell = NULL;
230 XtFree((char *) pJob);
233 /************************************************************************
235 * Executes the specified PrintJob
236 ************************************************************************/
238 PrintJobExecute(PrintJob *pJob)
240 if (pJob == NULL) return;
242 pJob->pSetup = PrintSetupCreate(
245 pJob->pPad->xrdb.wordWrap,
247 (XtCallbackProc) _pjCancelCB, pJob,
248 (XtCallbackProc) _pjCloseDisplayCB, pJob,
249 (XtCallbackProc) _pjPrintCB, pJob,
250 (XtCallbackProc) _pjPdmSetupCB, pJob);
254 * The DtPrintSetupDialog will display itself automatically
255 * along with an error message in the event of an error.
257 if (FALSE == PrintSetupGetDefaultPrintData(
262 _pjCreatePrintShell(pJob);
266 PrintSetupDisplay(pJob->pSetup);
269 /************************************************************************
271 * Cancels and deletes the specified print job.
272 ************************************************************************/
274 PrintJobCancel(PrintJob *pJob)
276 PrintJobDestroy(pJob);
280 /************************************************************************
281 * PrintJobGetErrorPrintDisplay
282 * Returns the last print display on which an error occured.
283 ************************************************************************/
285 PrintJobGetErrorPrintDisplay()
287 return _pjErrorPrintDisplay;
290 /************************************************************************
291 * PrintJobSetErrorPrintDisplay
292 * Save a pointer to the print display on which an error occured.
293 ************************************************************************/
295 PrintJobSetErrorPrintDisplay(Display *display)
297 _pjErrorPrintDisplay = display;
300 /************************************************************************
301 * PrintJobIsActivePrintDisplay
302 * Save a pointer to the print display on which an error occured.
303 ************************************************************************/
305 PrintJobIsActivePrintDisplay(Display *display)
309 for (i = 0; i < _pjMaxActivePrintDisplay; i++)
310 if (display == _pjActivePrintDisplay[i])
316 /************************************************************************
317 * _pjRegisterActivePrintDisplay
318 * Save the Display pointer for an active print display connection
319 ************************************************************************/
321 _pjRegisterActivePrintDisplay(Display *display)
326 if (0 == _pjMaxActivePrintDisplay)
328 _pjMaxActivePrintDisplay = 10;
329 size = _pjMaxActivePrintDisplay * sizeof(Display*);
330 _pjActivePrintDisplay = (Display**) malloc(size);
331 memset((char*) _pjActivePrintDisplay, 0, size);
334 for (i = 0; i < _pjMaxActivePrintDisplay; i++)
336 if (NULL == _pjActivePrintDisplay[i])
338 _pjActivePrintDisplay[i] = display;
343 size = _pjMaxActivePrintDisplay * sizeof(Display*);
344 _pjActivePrintDisplay =
345 (Display**) realloc((void*) _pjActivePrintDisplay, 2*size);
346 memset((char*) (_pjActivePrintDisplay + size), 0, size);
347 _pjActivePrintDisplay[_pjMaxActivePrintDisplay] = display;
348 _pjMaxActivePrintDisplay *= 2;
351 /************************************************************************
352 * _pjUnregisterActivePrintDisplay
353 * Delete the Display pointer for an active print display connection
354 ************************************************************************/
356 _pjUnregisterActivePrintDisplay(Display *display)
360 for (i = 0; i < _pjMaxActivePrintDisplay; i++)
361 if (display == _pjActivePrintDisplay[i])
362 _pjActivePrintDisplay[i] = NULL;
366 /************************************************************************
367 * _pjCreatePrintShell
368 * Creates the print shell (XmPrintShell or XmDialogShell) to control
370 ************************************************************************/
372 _pjCreatePrintShell(PrintJob *pJob)
374 DtPrintSetupData *psd = NULL;
377 pJob->pShell != NULL ||
378 pJob->parentShell == NULL ||
379 pJob->pSetup == NULL) return;
381 #if 0 && defined(PRINTING_SUPPORTED)
384 * Create the print shell and
385 * the print output widgets
387 #ifdef PRINT_TO_VIDEO
389 * Create a dialog shell widget on the video display.
391 pJob->pShell = XmCreateDialogShell(
398 pJob->nextpageShell = XmCreateDialogShell(
403 xms = XmStringCreateLocalized("Push for Next Page");
404 pJob->nextpageButton = XtVaCreateManagedWidget(
406 xmPushButtonWidgetClass,
415 pJob->nextpageButton,
420 XtManageChild(pJob->nextpageShell);
421 XtRealizeWidget(pJob->nextpageShell);
426 * Create an XmPrintShell widget on the print display.
428 psd = pJob->printData;
430 pJob->pShell = XmPrintSetup(
432 XpGetScreenOfContext(psd->print_display, psd->print_context),
438 XmNpageSetupCallback,
443 XmNpdmNotificationCallback,
444 _pjPdmNotificationCB,
448 if (pJob->pShell == NULL) return;
449 #endif /* PRINTING_SUPPORTED */
455 /************************************************************************
456 * _pjCreateOutputWidgets
457 * Actually run the specified PrintJob.
458 * Creates the PrintOutput object to be used for printing.
459 * Initializes the mailbox to iterate through the messages.
460 * Calls spoolOne to send a print job to the Xp server.
461 ************************************************************************/
463 _pjCreateOutputWidgets(PrintJob *pJob)
465 DtEditorErrorCode errorCode;
467 DtPrintSetupData *psd = NULL;
471 * Notify the user that we're printing
473 /* TBD: Is there a status bar on pPad? */
475 if (pJob->pShell == NULL)
477 {/* TBD error dialog */}
478 PrintJobDestroy(pJob);
482 pJob->pOutput = PrintOutputCreate(pJob->pShell);
483 PrintOutputSetWordWrap(pJob->pOutput, PrintSetupUseWordWrap(pJob->pSetup));
484 PrintOutputSetPageMargins(
486 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_TOP),
487 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_RIGHT),
488 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_BOTTOM),
489 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_LEFT),
495 * Display an error dialog.
496 DtMailGenDialog *genDialog = new DtMailGenDialog(
498 _parent->baseWidget());
503 i18nMsg = GETMESSAGE(
505 "One of the following margin specifiers \n has incorrect syntax: \n %s \n %s \n %s \n %s \nContinue using default margins?"
508 errMsg = (char *) XtMalloc(1024);
512 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_TOP),
513 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_RIGHT),
514 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_BOTTOM),
515 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_LEFT)
518 Warning(pJob->pPad, (char *) errMsg, XmDIALOG_WARNING);
525 errorCode = PrintOutputLoadFile(pJob->pOutput, pJob->tempFileName);
528 case DtEDITOR_NO_ERRORS:
529 case DtEDITOR_READ_ONLY_FILE:
531 case DtEDITOR_NONEXISTENT_FILE:
534 (char *) GETMESSAGE(14, 2, "File does not exist."),
537 case DtEDITOR_DIRECTORY:
540 (char *) GETMESSAGE(14, 3, "Specified file is a directory."),
543 case DtEDITOR_CHAR_SPECIAL_FILE:
544 case DtEDITOR_BLOCK_MODE_FILE:
547 (char *) GETMESSAGE(14, 4, "File type error."),
550 case DtEDITOR_NULLS_REMOVED:
553 (char *) GETMESSAGE(14, 5, "File contains NULL characters."),
556 case DtEDITOR_INSUFFICIENT_MEMORY:
560 GETMESSAGE(14, 6, "Unable to load file (insufficient memory)."),
563 case DtEDITOR_NO_FILE_ACCESS:
564 case DtEDITOR_UNREADABLE_FILE:
569 GETMESSAGE(14, 7, "File does not have read permissions"),
574 XtRealizeWidget( pJob->pShell );
576 PrintOutputFirstPage(pJob->pOutput);
577 pJob->npagesTotal = PrintOutputGetNumLines(pJob->pOutput) +
578 PrintOutputGetLinesPerPage(pJob->pOutput) - 1;
579 pJob->npagesTotal /= PrintOutputGetLinesPerPage(pJob->pOutput);
580 pJob->npagesDone = 0;
586 /************************************************************************
588 * Actually run the specified PrintJob.
589 * Creates the PrintOutput object to be used for printing.
590 * Initializes the mailbox to iterate through the messages.
591 * Calls spoolOne to send a print job to the Xp server.
592 ************************************************************************/
594 _pjDoPrint(PrintJob *pJob)
596 #if 0 && defined(PRINTING_SUPPORTED)
598 static char buf[1024];
600 DtPrintSetupData *psd = NULL;
604 * Notify the user that we're printing
606 if (pJob->pPad != NULL) {
607 pJob->pPad->numPendingTasks++;
608 format = GETMESSAGE(14, 21, "Printing %s ...");
609 sprintf(buf, format, pJob->documentName);
610 SetStatusMessage(pJob->pPad, buf);
611 XtSetSensitive(pJob->pPad->fileStuff.fileWidgets.printBtn, False);
614 #ifndef PRINT_TO_VIDEO
615 psd = pJob->printData;
617 if (psd->destination == DtPRINT_TO_FILE)
620 _pjRegisterActivePrintDisplay(XtDisplay(pJob->pShell));
621 XpStartJob(XtDisplay(pJob->pShell), dest);
622 XFlush(XtDisplay(pJob->pShell));
624 if (psd->destination == DtPRINT_TO_FILE)
626 if (FALSE == XmPrintToFile(
627 XtDisplay(pJob->pShell),
629 _pjFinishedPrintToFile,
632 char *fmt = "%s\n%s: %s";
634 char *appmessage = NULL;
635 char *sysmessage = strerror(errno);
637 appmessage = (char *) GETMESSAGE(
639 "'Print to File' was unsuccessful.");
641 if (NULL == sysmessage)
643 message = XtMalloc(strlen(appmessage) + 1);
644 sprintf(message, "%s", appmessage);
651 strlen(psd->dest_info) +
653 sprintf(message, fmt, appmessage, psd->dest_info, sysmessage);
656 Warning(pJob->pPad, message, XmDIALOG_WARNING);
659 XpCancelJob(XtDisplay(pJob->pShell), False);
660 PrintJobDestroy(pJob);
664 #endif /* PRINTING_SUPPORTED */
669 /************************************************************************
670 * _pjUpdatePageHeaders
671 * Configures the header and footer string in the PrintOutput.
672 ************************************************************************/
674 _pjUpdatePageHeaders(
676 PrintStringTypeEnum hl_type,
677 PrintStringTypeEnum hr_type,
678 PrintStringTypeEnum fl_type,
679 PrintStringTypeEnum fr_type
687 if (pJob == (PrintJob *) NULL) return;
689 hl_string = _pjGetPageHeaderString(pJob, hl_type);
690 hr_string = _pjGetPageHeaderString(pJob, hr_type);
691 fl_string = _pjGetPageHeaderString(pJob, fl_type);
692 fr_string = _pjGetPageHeaderString(pJob, fr_type);
694 if (PRINT_NONE_STRING_TYPE_ENUM == hl_type &&
695 PRINT_NONE_STRING_TYPE_ENUM == hr_type)
696 PrintOutputHideHeaders(pJob->pOutput);
698 PrintOutputShowHeaders(pJob->pOutput);
700 if (PRINT_NONE_STRING_TYPE_ENUM == fl_type &&
701 PRINT_NONE_STRING_TYPE_ENUM == fr_type)
702 PrintOutputHideFooters(pJob->pOutput);
704 PrintOutputShowFooters(pJob->pOutput);
707 PrintOutputSetHdrFtrStrings(
720 /************************************************************************
721 * _pjGetPageHeaderString
722 * Returns a header and footer string of the specified type.
723 ************************************************************************/
725 _pjGetPageHeaderString(PrintJob *pJob, PrintStringTypeEnum type)
728 *buf = (char *) NULL;
732 case PRINT_NONE_STRING_TYPE_ENUM:
735 case PRINT_DATE_STRING_TYPE_ENUM:
740 clock = time((time_t*) NULL);
741 date = ctime(&clock);
742 /* Strip off the trailing newline. */
743 date[strlen(date)-1] = '\0';
744 format = GETMESSAGE(14, 8, "Date: %s");
745 buf = (char *) malloc(strlen(format) + strlen(date) + 1);
746 if (buf != (char *) NULL)
747 sprintf(buf, format, date);
750 case PRINT_DOCNAME_STRING_TYPE_ENUM:
754 format = GETMESSAGE(14, 9, "Document: %s");
755 buflen = strlen(format) + strlen(pJob->documentName) + 1;
756 buf = (char *) malloc(buflen);
757 if (buf != (char *) NULL)
758 sprintf(buf, format, pJob->documentName);
761 case PRINT_PAGE_NUMBER_STRING_TYPE_ENUM:
763 * Allocate space for the format and the translated page number.
766 format = GETMESSAGE(14, 10, "Page %d of %d");
767 buf = (char *) malloc(strlen(format) + 16);
768 if (buf != (char *) NULL)
769 sprintf(buf, format, pJob->npagesDone, pJob->npagesTotal);
772 case PRINT_USER_NAME_STRING_TYPE_ENUM:
774 * Allocate space for the format and the username.
779 format = GETMESSAGE(14, 11, "Document For: %s");
780 pw = getpwuid(getuid());
781 buf = (char *) malloc(strlen(format) + strlen(pw->pw_name) + 1);
782 if (buf != (char *) NULL)
783 sprintf(buf, format, pw->pw_name);
787 buf = strdup("DEFAULT not impld");
796 * Name: _pjFinishedPrintToFile
800 * App-specific print data holder allocate function.
803 #if 0 && defined(PRINTING_SUPPORTED)
804 static void _pjFinishedPrintToFile(
807 XPGetDocStatus status,
808 XPointer client_data)
810 char *message = NULL;
811 PrintJob *pJob = (PrintJob *) client_data;
812 Editor *pPad = pJob->pPad;
814 if (status != XPGetDocFinished)
817 message = (char *) GETMESSAGE(
819 "'Print to File' was unsuccessful.");
820 Warning(pPad, message, XmDIALOG_WARNING);
822 else if (display != PrintJobGetErrorPrintDisplay())
825 message = (char *) GETMESSAGE(
827 "'Print to File' completed successfully.");
828 Warning(pPad, message, XmDIALOG_INFORMATION);
830 PrintJobDestroy(pJob);
832 #endif /* PRINTING_SUPPORTED */
838 * An XtCallbackProc which can be added to the callback list of
839 * a widget to cancel the print job passed back as client_data.
842 _pjCancelCB (Widget widget, XtPointer client_data, XtPointer call_data)
844 PrintJob *pJob = (PrintJob *) client_data;
846 PrintJobDestroy(pJob);
850 * Name: _pjCloseDisplayCB
852 * An XtCallbackProc which can be added to the callback list of
853 * a widget to cancel the print job passed back as client_data.
856 _pjCloseDisplayCB (Widget widget, XtPointer client_data, XtPointer call_data)
858 PrintJob *pJob = (PrintJob *) client_data;
859 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
861 if (pJob->pShell != NULL)
863 XtDestroyWidget(pJob->pShell);
866 DtPrintFreeSetupData(pJob->printData);
872 * An XtCallbackProc which can be added to the callback list of
873 * a widget to execute the print job passed back as client_data.
876 _pjPrintCB (Widget widget, XtPointer client_data, XtPointer call_data)
878 PrintJob *pJob = (PrintJob *) client_data;
879 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
881 DtPrintCopySetupData(pJob->printData, pbs->print_data);
882 _pjCreatePrintShell(pJob);
888 * Name: _pjPdmSetupCB
890 * An XtCallbackProc which can be added to the callback list of
891 * a widget to popup the PDM for the print job.
894 _pjPdmSetupCB(Widget print_setup, XtPointer client_data, XtPointer call_data)
896 #if 0 && defined(PRINTING_SUPPORTED)
897 char *pname = "_pjPdmSetupCB";
898 PrintJob *pJob = (PrintJob *) client_data;
899 DtPrintSetupCallbackStruct
900 *pbs = (DtPrintSetupCallbackStruct *) call_data;
902 DtPrintCopySetupData(pJob->printData, pbs->print_data);
903 _pjCreatePrintShell(pJob);
908 Widget shell = print_setup;
910 while (! (shell == NULL || XtIsShell(shell)) )
911 shell = XtParent(shell);
914 XmPrintPopupPDM(pJob->pShell, shell);
916 fprintf(stderr, "Internal Error %s: Missing XmPrintShell.", pname);
918 #endif /* PRINTING_SUPPORTED */
922 /************************************************************************
923 * _pjPdmNotificationCB
924 * XmNpdmNotificationCallback for the XmPrintShell
925 ************************************************************************/
927 _pjPdmNotificationCB (Widget widget, XtPointer client_data, XtPointer call_data)
929 #if 0 && defined(PRINTING_SUPPORTED)
930 PrintJob *pJob = (PrintJob*) client_data;
931 XmPrintShellCallbackStruct *pscbs = (XmPrintShellCallbackStruct*)call_data;
932 char *message = NULL;
934 switch (pscbs->reason)
938 case XmCR_PDM_START_ERROR:
939 case XmCR_PDM_START_VXAUTH:
940 case XmCR_PDM_START_PXAUTH:
941 message = (char *) GETMESSAGE(
943 "Print Dialog Manager error - setup failed.");
951 Warning( pJob->pPad, message, XmDIALOG_WARNING);
952 #endif /* PRINTING_SUPPORTED */
957 /************************************************************************
959 * XmNpageSetupCallback for the XmPrintShell
960 ************************************************************************/
964 XtPointer client_data,
968 #if 0 && defined(PRINTING_SUPPORTED)
969 PrintJob *pJob = (PrintJob *) client_data;
971 XmPrintShellCallbackStruct *pscbs = (XmPrintShellCallbackStruct*)call_data;
974 if (pJob->pOutput == NULL)
976 XtArgVal width0, height0;
977 Dimension width, height;
985 width = (Dimension)width0;
986 height = (Dimension)height0;
988 #if defined(PRINT_TO_VIDEO)
989 printf("PrintShell in _pjPrintOnePageCB: <W %d - H %d>\n",width,height);
992 if (width < 100 || height < 100)
994 width = 2550; height=3250;
1000 width = 0; height=0;
1006 #if defined(PRINT_TO_VIDEO)
1008 "PrintShell in _pjPrintOnePageCB: <W %d - H %d>\n",width,height);
1011 _pjCreateOutputWidgets(pJob);
1014 #ifdef PRINT_TO_VIDEO
1015 if (pJob->npagesDone > 0 && pJob->npagesDone == pJob->npagesTotal)
1017 if (pscbs->last_page)
1020 DtPrintSetupData *psd = pJob->printData;
1023 * This spool job is done. Clean up.
1024 * If this is a print to file job,
1025 * clean up in the job finished callback.
1027 if (psd->destination != DtPRINT_TO_FILE)
1028 PrintJobDestroy(pJob);
1032 if (pJob->npagesDone > 0 && PrintOutputPageDown(pJob->pOutput) == FALSE)
1034 #ifndef PRINT_TO_VIDEO
1035 pscbs->last_page = TRUE;
1041 * Update header and footer strings.
1044 _pjUpdatePageHeaders(
1046 PrintSetupGetHdrFtrSpec(pJob->pSetup, DTPRINT_OPTION_HEADER_LEFT),
1047 PrintSetupGetHdrFtrSpec(pJob->pSetup, DTPRINT_OPTION_HEADER_RIGHT),
1048 PrintSetupGetHdrFtrSpec(pJob->pSetup, DTPRINT_OPTION_FOOTER_LEFT),
1049 PrintSetupGetHdrFtrSpec(pJob->pSetup, DTPRINT_OPTION_FOOTER_RIGHT)
1053 * Notify the user that we're printing
1055 if (pJob->pPad != NULL)
1057 static char buf[1024];
1060 format = GETMESSAGE(14, 22, "Printing %s: page %d of %d ...");
1061 sprintf(buf, format,
1065 SetStatusMessage(pJob->pPad, buf);
1068 #ifndef PRINT_TO_VIDEO
1069 if (pJob->npagesDone >= pJob->npagesTotal)
1070 pscbs->last_page = TRUE;
1073 #endif /* PRINTING_SUPPORTED */