printSetup.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  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)
  10. * any later version.
  11. *
  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
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: printSetup.c /main/14 1996/10/25 13:37:55 mgreess $ */
  24. /**********************************<+>*************************************
  25. ***************************************************************************
  26. **
  27. ** File: printSetup.c
  28. **
  29. ** Project: HP DT dtpad, a memo maker type editor based on the
  30. ** Dt Editor widget.
  31. **
  32. ** Description: Routines which manipulate the print setup dialog
  33. **
  34. **************************************************************************
  35. **********************************<+>*************************************/
  36. /*
  37. * Common Desktop Environment
  38. *
  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.
  46. *
  47. *
  48. * RESTRICTED RIGHTS LEGEND
  49. *
  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).
  55. *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
  56. *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
  57. *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
  58. *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
  59. *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
  60. *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
  61. *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
  62. */
  63. #define REUSE_PRINT_SETUP_DIALOGS
  64. #include <stdio.h>
  65. #include <sys/param.h>
  66. #include <X11/Intrinsic.h>
  67. #include <Xm/DialogS.h>
  68. #include <Xm/Form.h>
  69. #include <Xm/MwmUtil.h>
  70. #include <Xm/ToggleB.h>
  71. #include <Dt/DtPStrings.h>
  72. #include <Dt/HelpDialog.h>
  73. #include <Dt/Print.h>
  74. #include <Dt/Session.h>
  75. #include "dtpad.h"
  76. static char *_psGetResourceFileName(
  77. PrintSetup *pSetup);
  78. static void _psSetupToSource(
  79. PrintSetup *pSetup);
  80. static void _psSourceToSetup(
  81. PrintSetup *pSetup,
  82. Boolean wordWrap);
  83. static void _psSetupToUi(
  84. PrintSetup *pSetup);
  85. static void _psUiToSetup(
  86. PrintSetup *pSetup);
  87. static Boolean _psUiSpecsAreValid(
  88. PrintSetup *pSetup);
  89. static void _psAttachPrintSetupDialog(
  90. PrintSetup *pSetup,
  91. Editor *pPad);
  92. static Widget _psCreatePrintSetupDialog(
  93. Widget parent,
  94. Editor *pPad);
  95. static void _psPrintSetupCancelCB(
  96. Widget dtprintSetup,
  97. XtPointer client_data,
  98. XtPointer call_data);
  99. static void _psPrintSetupDestroyCB(
  100. Widget dtprintSetup,
  101. XtPointer client_data,
  102. XtPointer call_data);
  103. static void _psPrintSetupPrintCB(
  104. Widget dtprintSetup,
  105. XtPointer client_data,
  106. XtPointer call_data);
  107. static void _psReleasePrintSetupDialog(
  108. PrintSetup *pSetup);
  109. #define PS_ARRAY_SIZE(ary) (sizeof((ary))/sizeof((ary)[0]))
  110. #define PS_HOME_ENV_VARIABLE "HOME"
  111. #define PS_DEFAULT_RESOURCE_FILE "dtpadrc"
  112. #define PS_RESOURCE_HDRFTR_FORMAT_STRING "Dtpad.%s: %d\n"
  113. #define PS_RESOURCE_MARGIN_FORMAT_STRING "Dtpad.%s: %s\n"
  114. #define PS_RESOURCE_NAME_HEADER_LEFT "headerLeftEnum"
  115. #define PS_RESOURCE_NAME_HEADER_RIGHT "headerRightEnum"
  116. #define PS_RESOURCE_NAME_FOOTER_LEFT "footerLeftEnum"
  117. #define PS_RESOURCE_NAME_FOOTER_RIGHT "footerRightEnum"
  118. #define PS_RESOURCE_NAME_MARGIN_TOP "marginTopSpec"
  119. #define PS_RESOURCE_NAME_MARGIN_RIGHT "marginRightSpec"
  120. #define PS_RESOURCE_NAME_MARGIN_BOTTOM "marginBottomSpec"
  121. #define PS_RESOURCE_NAME_MARGIN_LEFT "marginLeftSpec"
  122. #define PS_RESOURCE_VALUE_NONE "Empty"
  123. #define PS_RESOURCE_VALUE_DATE "Date"
  124. #define PS_RESOURCE_VALUE_DOCNAME "DocName"
  125. #define PS_RESOURCE_VALUE_PAGE_NUMBER "PageNumber"
  126. #define PS_RESOURCE_VALUE_USER_NAME "UserName"
  127. #define PS_RESOURCE_VALUE_DFLT_MARGIN "1.0 in"
  128. typedef struct resource_value
  129. {
  130. PrintStringTypeEnum which;
  131. char *resource_string;
  132. int set_id;
  133. int msg_id;
  134. char *dflt_string;
  135. } ResourceValue;
  136. static ResourceValue _psHdrFtrValues[] =
  137. {
  138. { PRINT_NONE_STRING_TYPE_ENUM,
  139. PS_RESOURCE_VALUE_NONE,
  140. 15, 1, "None"
  141. },
  142. { PRINT_DATE_STRING_TYPE_ENUM,
  143. PS_RESOURCE_VALUE_DATE,
  144. 15, 2, "Date"
  145. },
  146. { PRINT_DOCNAME_STRING_TYPE_ENUM,
  147. PS_RESOURCE_VALUE_DOCNAME,
  148. 15, 3, "Document Name"
  149. },
  150. { PRINT_PAGE_NUMBER_STRING_TYPE_ENUM,
  151. PS_RESOURCE_VALUE_PAGE_NUMBER,
  152. 15, 4, "Page Number"
  153. },
  154. { PRINT_USER_NAME_STRING_TYPE_ENUM,
  155. PS_RESOURCE_VALUE_USER_NAME,
  156. 15, 5, "User Name"
  157. }
  158. };
  159. static Widget _psDefaultPrintSetupDialog = (Widget) NULL;
  160. static char *_psDefaultMargin = PS_RESOURCE_VALUE_DFLT_MARGIN;
  161. static XtResource _psResources[] = {
  162. {PS_RESOURCE_NAME_FOOTER_LEFT, "FooterLeftEnum", XmRInt, sizeof(int),
  163. XtOffset(PrintOptions*, footerLeft),
  164. XmRImmediate, (XtPointer) PRINT_NONE_STRING_TYPE_ENUM,
  165. },
  166. {PS_RESOURCE_NAME_FOOTER_RIGHT, "FooterRightEnum", XmRInt, sizeof(int),
  167. XtOffset(PrintOptions*, footerRight),
  168. XmRImmediate, (XtPointer) PRINT_PAGE_NUMBER_STRING_TYPE_ENUM,
  169. },
  170. {PS_RESOURCE_NAME_HEADER_LEFT, "HeaderLeftEnum", XmRInt, sizeof(int),
  171. XtOffset(PrintOptions*, headerLeft),
  172. XmRImmediate, (XtPointer) PRINT_NONE_STRING_TYPE_ENUM,
  173. },
  174. {PS_RESOURCE_NAME_HEADER_RIGHT, "HeaderRightEnum", XmRInt, sizeof(int),
  175. XtOffset(PrintOptions*, headerRight),
  176. XmRImmediate, (XtPointer) PRINT_DOCNAME_STRING_TYPE_ENUM,
  177. },
  178. {PS_RESOURCE_NAME_MARGIN_BOTTOM, "MarginBottomSpec", XmRString, sizeof(String),
  179. XtOffset(PrintOptions*, marginBottom),
  180. XmRString, (XtPointer) PS_RESOURCE_VALUE_DFLT_MARGIN,
  181. },
  182. {PS_RESOURCE_NAME_MARGIN_LEFT, "MarginLeftSpec", XmRString, sizeof(String),
  183. XtOffset(PrintOptions*, marginLeft),
  184. XmRString, (XtPointer) PS_RESOURCE_VALUE_DFLT_MARGIN,
  185. },
  186. {PS_RESOURCE_NAME_MARGIN_RIGHT, "MarginRightSpec", XmRString, sizeof(String),
  187. XtOffset(PrintOptions*, marginRight),
  188. XmRString, (XtPointer) PS_RESOURCE_VALUE_DFLT_MARGIN,
  189. },
  190. {PS_RESOURCE_NAME_MARGIN_TOP, "MarginTopSpec", XmRString, sizeof(String),
  191. XtOffset(PrintOptions*, marginTop),
  192. XmRString, (XtPointer) PS_RESOURCE_VALUE_DFLT_MARGIN,
  193. }
  194. };
  195. /************************************************************************
  196. * PrintSetupCreate
  197. * Class constructor.
  198. * Adds dtpad specific items to the passed print setup box.
  199. * The document file name is presented in the bottom work area.
  200. ************************************************************************/
  201. PrintSetup *
  202. PrintSetupCreate(
  203. Widget parent,
  204. char *docName,
  205. Boolean wordWrap,
  206. Editor *pPad,
  207. XtCallbackProc cancelCB, XtPointer cancelClosure,
  208. XtCallbackProc closeDisplayCB, XtPointer closeDisplayClosure,
  209. XtCallbackProc printCB, XtPointer printClosure,
  210. XtCallbackProc setupCB, XtPointer setupClosure
  211. )
  212. {
  213. Widget w;
  214. XmString xms;
  215. unsigned char is_set;
  216. PrintSetup *pSetup;
  217. Widget *menu_buttons;
  218. int nitems;
  219. char **strings;
  220. void **data;
  221. int i;
  222. pSetup = (PrintSetup *) XtMalloc( sizeof(PrintSetup) );
  223. pSetup->parent = parent;
  224. pSetup->docName = strdup(docName);
  225. pSetup->cancelCB = cancelCB;
  226. pSetup->closeDisplayCB = closeDisplayCB;
  227. pSetup->printCB = printCB;
  228. pSetup->setupCB = setupCB;
  229. pSetup->cancelClosure = cancelClosure;
  230. pSetup->closeDisplayClosure = closeDisplayClosure;
  231. pSetup->printClosure = printClosure;
  232. pSetup->setupClosure = setupClosure;
  233. pSetup->pPad = pPad;
  234. pSetup->dtprintSetup = (Widget) NULL;
  235. pSetup->widgets = (psWidgets *) NULL;
  236. /*
  237. * Get the current default values for the app-specific printing options.
  238. */
  239. _psSourceToSetup(pSetup, wordWrap);
  240. /*
  241. * Get a print setup dialog.
  242. */
  243. _psAttachPrintSetupDialog(pSetup, pPad);
  244. return pSetup;
  245. }
  246. /************************************************************************
  247. * PrintSetupDestroy
  248. * Class destructor.
  249. ************************************************************************/
  250. void
  251. PrintSetupDestroy(PrintSetup *pSetup)
  252. {
  253. if (pSetup == NULL) return;
  254. if (pSetup->docName)
  255. free(pSetup->docName);
  256. if (pSetup->dtprintSetup)
  257. _psReleasePrintSetupDialog(pSetup);
  258. XtFree((char*) pSetup);
  259. }
  260. /************************************************************************
  261. * PrintSetupDisplay
  262. * Displays the specified print setup GUI.
  263. ************************************************************************/
  264. void
  265. PrintSetupDisplay(PrintSetup *pSetup)
  266. {
  267. if (pSetup == NULL) return;
  268. /*
  269. * Initialize the print setup Ui.
  270. */
  271. _psSetupToUi(pSetup);
  272. XtManageChild(pSetup->dtprintSetup);
  273. XtMapWidget(pSetup->dtprintSetup);
  274. }
  275. /************************************************************************
  276. * PrintSetupHide
  277. * Hides the specified print setup GUI.
  278. ************************************************************************/
  279. void
  280. PrintSetupHide(PrintSetup *pSetup)
  281. {
  282. if (pSetup == NULL) return;
  283. if (pSetup->dtprintSetup == NULL) return;
  284. XtUnmanageChild(pSetup->dtprintSetup);
  285. XtUnmapWidget(pSetup->dtprintSetup);
  286. }
  287. /************************************************************************
  288. * PrintSetupGetHdrFtrSpec
  289. * Returns the current value of the specified header/footer print option.
  290. ************************************************************************/
  291. PrintStringTypeEnum
  292. PrintSetupGetHdrFtrSpec(PrintSetup *pSetup, _DtPrintHdrFtrEnum which)
  293. {
  294. PrintStringTypeEnum rtn;
  295. if (pSetup == NULL) return PRINT_NONE_STRING_TYPE_ENUM;
  296. switch (which)
  297. {
  298. case DTPRINT_OPTION_HEADER_LEFT:
  299. rtn = pSetup->options.headerLeft;
  300. break;
  301. case DTPRINT_OPTION_HEADER_RIGHT:
  302. rtn = pSetup->options.headerRight;
  303. break;
  304. case DTPRINT_OPTION_FOOTER_LEFT:
  305. rtn = pSetup->options.footerLeft;
  306. break;
  307. case DTPRINT_OPTION_FOOTER_RIGHT:
  308. default:
  309. rtn = pSetup->options.footerRight;
  310. break;
  311. }
  312. return rtn;
  313. }
  314. /************************************************************************
  315. * PrintSetupGetMarginSpec
  316. * Returns the current value of the specified margin print option.
  317. ************************************************************************/
  318. char *
  319. PrintSetupGetMarginSpec(PrintSetup *pSetup, _DtPrintMarginEnum which)
  320. {
  321. char *rtn;
  322. if (pSetup == NULL) return _psDefaultMargin;
  323. switch (which)
  324. {
  325. case DTPRINT_OPTION_MARGIN_TOP:
  326. rtn = pSetup->options.marginTop;
  327. break;
  328. case DTPRINT_OPTION_MARGIN_RIGHT:
  329. rtn = pSetup->options.marginRight;
  330. break;
  331. case DTPRINT_OPTION_MARGIN_BOTTOM:
  332. rtn = pSetup->options.marginBottom;
  333. break;
  334. case DTPRINT_OPTION_MARGIN_LEFT:
  335. default:
  336. rtn = pSetup->options.marginLeft;
  337. break;
  338. }
  339. return rtn;
  340. }
  341. /************************************************************************
  342. * PrintSetupGetDefaultPrintData
  343. * Returns the current value of the print data in the pData variable.
  344. ************************************************************************/
  345. Boolean
  346. PrintSetupGetDefaultPrintData(PrintSetup *pSetup, DtPrintSetupData *pData)
  347. {
  348. if (pSetup == NULL || pData == NULL) return FALSE;
  349. return (DtPRINT_SUCCESS == DtPrintFillSetupData(
  350. pSetup->dtprintSetup,
  351. pData));
  352. }
  353. /************************************************************************
  354. * PrintSetupUseWordWrap
  355. * Returns the current value of word wrap print option.
  356. ************************************************************************/
  357. Boolean
  358. PrintSetupUseWordWrap(PrintSetup *pSetup)
  359. {
  360. if (pSetup == NULL) return TRUE;
  361. return pSetup->options.wordWrap;
  362. }
  363. /*******************************************************************************
  364. *******************************************************************************
  365. *
  366. * Static Functions
  367. *
  368. *******************************************************************************
  369. ******************************************************************************/
  370. /************************************************************************
  371. * _psGetResourceFileName
  372. ************************************************************************/
  373. static char*
  374. _psGetResourceFileName(PrintSetup *pSetup)
  375. {
  376. #define BUFFER_SIZE 256
  377. extern Widget topLevelWithWmCommand;
  378. static char buffer[BUFFER_SIZE];
  379. static char *dtpadrc = NULL;
  380. char *savePath, *saveFile;
  381. if (dtpadrc != NULL) return XtNewString(dtpadrc);
  382. savePath = NULL;
  383. saveFile = PS_DEFAULT_RESOURCE_FILE;
  384. if (! DtSessionSavePath(topLevelWithWmCommand, &savePath, &saveFile))
  385. {
  386. snprintf(
  387. buffer, sizeof(buffer), "%s/%s/%s",
  388. getenv(PS_HOME_ENV_VARIABLE),
  389. DtPERSONAL_TMP_DIRECTORY,
  390. PS_DEFAULT_RESOURCE_FILE);
  391. savePath = buffer;
  392. }
  393. dtpadrc = XtNewString(savePath);
  394. return XtNewString(dtpadrc);
  395. }
  396. /************************************************************************
  397. * _psSourceToSetup
  398. ************************************************************************/
  399. static void
  400. _psSourceToSetup(PrintSetup *pSetup, Boolean wordWrap)
  401. {
  402. XrmDatabase database;
  403. char *dtpadrc;
  404. PrintOptions pOption;
  405. if (pSetup == NULL) return;
  406. dtpadrc = _psGetResourceFileName(pSetup);
  407. database = XtDatabase(XtDisplay(pSetup->parent));
  408. XrmCombineFileDatabase(dtpadrc, &database, TRUE);
  409. XtFree(dtpadrc);
  410. /* Get the application resources */
  411. XtGetApplicationResources(
  412. pSetup->parent, &pOption,
  413. _psResources, XtNumber(_psResources),
  414. NULL, 0);
  415. pSetup->options.footerLeft = pOption.footerLeft;
  416. pSetup->options.footerRight = pOption.footerRight;
  417. pSetup->options.headerLeft = pOption.headerLeft;
  418. pSetup->options.headerRight = pOption.headerRight;
  419. pSetup->options.marginBottom = XtNewString(pOption.marginBottom);
  420. pSetup->options.marginLeft = XtNewString(pOption.marginLeft);
  421. pSetup->options.marginRight = XtNewString(pOption.marginRight);
  422. pSetup->options.marginTop = XtNewString(pOption.marginTop);
  423. pSetup->options.wordWrap = wordWrap;
  424. }
  425. /************************************************************************
  426. * _psSetupToSource
  427. ************************************************************************/
  428. static void
  429. _psSetupToSource(PrintSetup *pSetup)
  430. {
  431. PrintOptions *pOption;
  432. FILE *fp;
  433. char *dtpadrc;
  434. if (pSetup == NULL) return;
  435. pOption = &pSetup->options;
  436. dtpadrc = _psGetResourceFileName(pSetup);
  437. fp = fopen(dtpadrc, "wb");
  438. if (fp == NULL)
  439. {
  440. /* TBD: Error message. */
  441. fprintf(
  442. stderr,
  443. "_psSetupToSource: Cannot open resource file '%s'\n",
  444. dtpadrc);
  445. return;
  446. }
  447. XtFree(dtpadrc);
  448. fprintf(
  449. fp,
  450. PS_RESOURCE_HDRFTR_FORMAT_STRING,
  451. PS_RESOURCE_NAME_HEADER_LEFT,
  452. pOption->headerLeft
  453. );
  454. fprintf(
  455. fp,
  456. PS_RESOURCE_HDRFTR_FORMAT_STRING,
  457. PS_RESOURCE_NAME_HEADER_RIGHT,
  458. pOption->headerRight
  459. );
  460. fprintf(
  461. fp,
  462. PS_RESOURCE_HDRFTR_FORMAT_STRING,
  463. PS_RESOURCE_NAME_FOOTER_LEFT,
  464. pOption->footerLeft
  465. );
  466. fprintf(
  467. fp,
  468. PS_RESOURCE_HDRFTR_FORMAT_STRING,
  469. PS_RESOURCE_NAME_FOOTER_RIGHT,
  470. pOption->footerRight
  471. );
  472. fprintf(
  473. fp,
  474. PS_RESOURCE_MARGIN_FORMAT_STRING,
  475. PS_RESOURCE_NAME_MARGIN_TOP,
  476. pOption->marginTop
  477. );
  478. fprintf(
  479. fp,
  480. PS_RESOURCE_MARGIN_FORMAT_STRING,
  481. PS_RESOURCE_NAME_MARGIN_RIGHT,
  482. pOption->marginRight
  483. );
  484. fprintf(
  485. fp,
  486. PS_RESOURCE_MARGIN_FORMAT_STRING,
  487. PS_RESOURCE_NAME_MARGIN_BOTTOM,
  488. pOption->marginBottom
  489. );
  490. fprintf(
  491. fp,
  492. PS_RESOURCE_MARGIN_FORMAT_STRING,
  493. PS_RESOURCE_NAME_MARGIN_LEFT,
  494. pOption->marginLeft
  495. );
  496. fclose(fp);
  497. }
  498. /************************************************************************
  499. * _psSetupToUi
  500. ************************************************************************/
  501. static void
  502. _psSetupToUi(PrintSetup *pSetup)
  503. {
  504. unsigned char isSet;
  505. Widget frame, w;
  506. PrintOptions *pOption;
  507. if (pSetup == NULL ||
  508. pSetup->dtprintSetup == NULL ||
  509. pSetup->widgets == NULL)
  510. return;
  511. pOption = &pSetup->options;
  512. isSet = (pOption->wordWrap) ? XmSET : XmUNSET;
  513. XtVaSetValues(pSetup->widgets->wordWrapTB, XmNset, isSet, NULL);
  514. frame = pSetup->widgets->hdrftrFrame;
  515. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_HEADER_LEFT);
  516. _DtPrintSetHdrFtrByData(w, (void*) pOption->headerLeft);
  517. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_HEADER_RIGHT);
  518. _DtPrintSetHdrFtrByData(w, (void*) pOption->headerRight);
  519. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_FOOTER_LEFT);
  520. _DtPrintSetHdrFtrByData(w, (void*) pOption->footerLeft);
  521. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_FOOTER_RIGHT);
  522. _DtPrintSetHdrFtrByData(w, (void*) pOption->footerRight);
  523. frame = pSetup->widgets->marginFrame;
  524. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_TOP);
  525. _DtPrintSetMarginSpec(w, pOption->marginTop);
  526. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_RIGHT);
  527. _DtPrintSetMarginSpec(w, pOption->marginRight);
  528. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_BOTTOM);
  529. _DtPrintSetMarginSpec(w, pOption->marginBottom);
  530. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_LEFT);
  531. _DtPrintSetMarginSpec(w, pOption->marginLeft);
  532. }
  533. /************************************************************************
  534. * _psUiToSetup
  535. ************************************************************************/
  536. static void
  537. _psUiToSetup(PrintSetup *pSetup)
  538. {
  539. XtArgVal isSet;
  540. Widget frame, w;
  541. PrintOptions *pOption;
  542. char *marginSpec;
  543. Boolean error = FALSE;
  544. if (pSetup == NULL ||
  545. pSetup->dtprintSetup == NULL ||
  546. pSetup->widgets == NULL)
  547. return;
  548. pOption = &pSetup->options;
  549. XtVaGetValues(pSetup->widgets->wordWrapTB, XmNset, &isSet, NULL);
  550. pOption->wordWrap = (isSet == XmUNSET) ? FALSE : TRUE;
  551. frame = pSetup->widgets->hdrftrFrame;
  552. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_HEADER_LEFT);
  553. pOption->headerLeft = (PrintStringTypeEnum) _DtPrintGetHdrFtrData(w);
  554. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_HEADER_RIGHT);
  555. pOption->headerRight = (PrintStringTypeEnum) _DtPrintGetHdrFtrData(w);
  556. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_FOOTER_LEFT);
  557. pOption->footerLeft = (PrintStringTypeEnum) _DtPrintGetHdrFtrData(w);
  558. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_FOOTER_RIGHT);
  559. pOption->footerRight = (PrintStringTypeEnum) _DtPrintGetHdrFtrData(w);
  560. frame = pSetup->widgets->marginFrame;
  561. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_TOP);
  562. marginSpec = _DtPrintGetMarginSpec(w);
  563. if (pOption->marginTop != NULL)
  564. XtFree(pOption->marginTop);
  565. if (marginSpec == NULL || strcmp("", marginSpec) == 0)
  566. pOption->marginTop = XtNewString(_psDefaultMargin);
  567. else
  568. pOption->marginTop = marginSpec;
  569. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_RIGHT);
  570. marginSpec = _DtPrintGetMarginSpec(w);
  571. if (pOption->marginRight != NULL)
  572. XtFree(pOption->marginRight);
  573. if (marginSpec == NULL || strcmp("", marginSpec) == 0)
  574. pOption->marginRight = XtNewString(_psDefaultMargin);
  575. else
  576. pOption->marginRight = marginSpec;
  577. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_BOTTOM);
  578. marginSpec = _DtPrintGetMarginSpec(w);
  579. if (pOption->marginBottom != NULL)
  580. XtFree(pOption->marginBottom);
  581. if (marginSpec == NULL || strcmp("", marginSpec) == 0)
  582. pOption->marginBottom = XtNewString(_psDefaultMargin);
  583. else
  584. pOption->marginBottom = marginSpec;
  585. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_LEFT);
  586. marginSpec = _DtPrintGetMarginSpec(w);
  587. if (pOption->marginLeft != NULL)
  588. XtFree(pOption->marginLeft);
  589. if (marginSpec == NULL || strcmp("", marginSpec) == 0)
  590. pOption->marginLeft = XtNewString(_psDefaultMargin);
  591. else
  592. pOption->marginLeft = marginSpec;
  593. }
  594. /************************************************************************
  595. * _psUiSpecsAreValid
  596. ************************************************************************/
  597. static Boolean
  598. _psUiSpecsAreValid(PrintSetup *pSetup)
  599. {
  600. unsigned char isSet;
  601. Widget frame, w;
  602. PrintOptions *pOption;
  603. char *marginSpec;
  604. if (pSetup == NULL ||
  605. pSetup->dtprintSetup == NULL ||
  606. pSetup->widgets == NULL)
  607. return 0;
  608. pOption = &pSetup->options;
  609. frame = pSetup->widgets->marginFrame;
  610. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_TOP);
  611. marginSpec = _DtPrintGetMarginSpec(w);
  612. if (marginSpec != NULL && strcmp("", marginSpec) != 0)
  613. {
  614. XtEnum parseError = FALSE;
  615. (void) XmConvertStringToUnits(
  616. XtScreenOfObject(pSetup->parent),
  617. marginSpec,
  618. XmVERTICAL,
  619. XmPIXELS,
  620. &parseError);
  621. if (parseError)
  622. {
  623. char *i18nMsg;
  624. char *errMsg;
  625. i18nMsg = GETMESSAGE(15, 6, "Top Margin specifier is invalid: ");
  626. errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
  627. sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
  628. Warning(pSetup->pPad, (char *) errMsg, XmDIALOG_WARNING);
  629. XtFree(errMsg);
  630. return FALSE;
  631. }
  632. }
  633. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_RIGHT);
  634. marginSpec = _DtPrintGetMarginSpec(w);
  635. if (marginSpec != NULL && strcmp("", marginSpec) != 0)
  636. {
  637. XtEnum parseError = FALSE;
  638. (void) XmConvertStringToUnits(
  639. XtScreenOfObject(pSetup->parent),
  640. marginSpec,
  641. XmHORIZONTAL,
  642. XmPIXELS,
  643. &parseError);
  644. if (parseError)
  645. {
  646. char *i18nMsg;
  647. char *errMsg;
  648. i18nMsg =
  649. GETMESSAGE(15, 7, "Right Margin specifier is invalid: ");
  650. errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
  651. sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
  652. Warning(pSetup->pPad, (char *) errMsg, XmDIALOG_WARNING);
  653. XtFree(errMsg);
  654. return FALSE;
  655. }
  656. }
  657. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_BOTTOM);
  658. marginSpec = _DtPrintGetMarginSpec(w);
  659. if (marginSpec != NULL && strcmp("", marginSpec) != 0)
  660. {
  661. XtEnum parseError = FALSE;
  662. (void) XmConvertStringToUnits(
  663. XtScreenOfObject(pSetup->parent),
  664. marginSpec,
  665. XmVERTICAL,
  666. XmPIXELS,
  667. &parseError);
  668. if (parseError)
  669. {
  670. char *i18nMsg;
  671. char *errMsg;
  672. i18nMsg =
  673. GETMESSAGE(15, 8, "Bottom Margin specifier is invalid: ");
  674. errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
  675. sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
  676. Warning(pSetup->pPad, (char *) errMsg, XmDIALOG_WARNING);
  677. XtFree(errMsg);
  678. return FALSE;
  679. }
  680. }
  681. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_LEFT);
  682. marginSpec = _DtPrintGetMarginSpec(w);
  683. if (marginSpec != NULL && strcmp("", marginSpec) != 0)
  684. {
  685. XtEnum parseError = FALSE;
  686. (void) XmConvertStringToUnits(
  687. XtScreenOfObject(pSetup->parent),
  688. marginSpec,
  689. XmHORIZONTAL,
  690. XmPIXELS,
  691. &parseError);
  692. if (parseError)
  693. {
  694. char *i18nMsg;
  695. char *errMsg;
  696. i18nMsg = GETMESSAGE(15, 9, "Left Margin specifier is invalid: ");
  697. errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
  698. sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
  699. Warning(pSetup->pPad, (char *) errMsg, XmDIALOG_WARNING);
  700. XtFree(errMsg);
  701. return FALSE;
  702. }
  703. }
  704. return TRUE;
  705. }
  706. /*
  707. * _psAttachPrintSetupDialog
  708. * Creates the widgets for the Setup Dialog.
  709. */
  710. static void
  711. _psAttachPrintSetupDialog(PrintSetup *pSetup, Editor *pPad)
  712. {
  713. char *title, *titlePrefix, *titleParent;
  714. XmString xms;
  715. Widget dialog;
  716. unsigned char is_set;
  717. #ifdef REUSE_PRINT_SETUP_DIALOGS
  718. if (_psDefaultPrintSetupDialog != NULL)
  719. {
  720. /*
  721. * Attempt to reuse the last print setup and print display connection.
  722. */
  723. pSetup->dtprintSetup = _psDefaultPrintSetupDialog;
  724. _psDefaultPrintSetupDialog = NULL;
  725. }
  726. else
  727. #endif
  728. {
  729. char *dirname;
  730. pSetup->dtprintSetup = _psCreatePrintSetupDialog(pSetup->parent, pPad);
  731. dirname = getenv("HOME");
  732. if (dirname)
  733. {
  734. char path[MAXPATHLEN+1];
  735. char *filename;
  736. filename = strrchr(pSetup->docName, '/');
  737. if (NULL == filename)
  738. filename = pSetup->docName;
  739. else
  740. filename++;
  741. snprintf(path, sizeof(path), "%s/%s.ps", dirname, filename);
  742. XtVaSetValues(pSetup->dtprintSetup, DtNfileName, path, NULL);
  743. }
  744. }
  745. /*
  746. * Copy the information about the widgets into the setup.
  747. */
  748. XtVaGetValues(pSetup->dtprintSetup, XmNuserData, &pSetup->widgets, NULL);
  749. /*
  750. * Add the setup-specific callbacks.
  751. */
  752. XtAddCallback(
  753. pSetup->dtprintSetup,
  754. DtNcancelCallback,
  755. _psPrintSetupCancelCB,
  756. (XtPointer) pSetup);
  757. XtAddCallback(
  758. pSetup->dtprintSetup,
  759. DtNclosePrintDisplayCallback,
  760. pSetup->closeDisplayCB,
  761. (XtPointer) pSetup->closeDisplayClosure);
  762. XtAddCallback(
  763. pSetup->dtprintSetup,
  764. DtNprintCallback,
  765. _psPrintSetupPrintCB,
  766. (XtPointer) pSetup);
  767. XtAddCallback(
  768. pSetup->dtprintSetup,
  769. DtNsetupCallback,
  770. pSetup->setupCB,
  771. (XtPointer) pSetup->setupClosure);
  772. xms = XmStringCreateLocalized(pSetup->docName);
  773. XtVaSetValues(pSetup->widgets->docNameLabel, XmNlabelString, xms, NULL);
  774. XmStringFree(xms);
  775. dialog = XtParent(pSetup->widgets->dtprintSetup);
  776. if (NULL != dialog && XtIsShell(dialog))
  777. {
  778. titleParent = (char*) GETMESSAGE(7, 2, "Text Editor - ");
  779. titlePrefix = (char*) GETMESSAGE(14, 23, "Print Setup - ");
  780. title =
  781. (char*) XtMalloc(strlen(titleParent) + strlen(titlePrefix) + strlen(pSetup->docName) + 1);
  782. sprintf(title, "%s%s%s", titleParent, titlePrefix, pSetup->docName);
  783. XtVaSetValues(dialog, XmNtitle, title, NULL);
  784. XtFree(title);
  785. }
  786. else
  787. {
  788. fprintf(stderr, "Print Setup box is not parented to a shell\n");
  789. }
  790. is_set = (pSetup->options.wordWrap) ? XmSET : XmUNSET;
  791. XtVaSetValues(pSetup->widgets->wordWrapTB, XmNset, is_set, NULL);
  792. }
  793. /*
  794. * _psCreatePrintSetupDialog
  795. * Creates the widgets for the Setup Dialog.
  796. */
  797. static Widget
  798. _psCreatePrintSetupDialog(Widget parent, Editor *pPad)
  799. {
  800. Arg args[2];
  801. int nargs;
  802. psWidgets *widgets;
  803. Widget w;
  804. XmString xms;
  805. unsigned char is_set;
  806. int nitems;
  807. char **strings;
  808. void **data;
  809. int i;
  810. /*
  811. * Create the widgets for the Setup Dialog.
  812. */
  813. widgets = (psWidgets *) XtMalloc(sizeof(psWidgets));
  814. /*
  815. * Create the DtPrintSetupDialog and specify that the application
  816. * specific area be located below the generic area.
  817. */
  818. nargs=0;
  819. XtSetArg(args[nargs], XmNautoUnmanage, FALSE); nargs++;
  820. widgets->dtprintSetup =
  821. DtCreatePrintSetupDialog(parent, "DtPrintSetup", args, nargs);
  822. XtVaSetValues(
  823. widgets->dtprintSetup,
  824. DtNworkAreaLocation, DtWORK_AREA_BOTTOM,
  825. XmNuserData, widgets,
  826. NULL);
  827. XtAddCallback(
  828. widgets->dtprintSetup,
  829. XmNhelpCallback,
  830. HelpPrintSetupDialogCB,
  831. (XtPointer) pPad);
  832. XtAddCallback(
  833. widgets->dtprintSetup,
  834. XmNdestroyCallback,
  835. _psPrintSetupDestroyCB,
  836. (XtPointer) widgets);
  837. /*
  838. * Create the dtpad-specific setup dialog in the bottom work area
  839. */
  840. widgets->form = XtVaCreateManagedWidget(
  841. "SetupForm",
  842. xmFormWidgetClass,
  843. widgets->dtprintSetup,
  844. NULL);
  845. XtAddCallback(
  846. widgets->form,
  847. XmNhelpCallback,
  848. HelpPrintSetupAppSpecificCB,
  849. (XtPointer) pPad);
  850. /*
  851. * Create the document name title label
  852. */
  853. xms = XmStringCreateLocalized( GETMESSAGE(14, 12, "Document Name: ") );
  854. widgets->docLabel = XtVaCreateManagedWidget(
  855. "DocumentLable",
  856. xmLabelGadgetClass,
  857. widgets->form,
  858. XmNleftAttachment, XmATTACH_FORM,
  859. XmNtopAttachment, XmATTACH_FORM,
  860. XmNlabelString, xms,
  861. NULL);
  862. XmStringFree(xms);
  863. /*
  864. * Create the document name label
  865. */
  866. widgets->docNameLabel = XtVaCreateManagedWidget(
  867. "DocumentName",
  868. xmLabelGadgetClass,
  869. widgets->form,
  870. XmNleftAttachment, XmATTACH_WIDGET,
  871. XmNleftWidget, widgets->docLabel,
  872. #if 0
  873. XmNrightAttachment, XmATTACH_FORM,
  874. #endif
  875. XmNtopAttachment, XmATTACH_FORM,
  876. NULL);
  877. xms = XmStringCreateLocalized(GETMESSAGE(14, 13, "Wrap To Fit"));
  878. widgets->wordWrapTB = XtVaCreateManagedWidget(
  879. "WrapToFit",
  880. xmToggleButtonWidgetClass,
  881. widgets->form,
  882. XmNalignment, XmALIGNMENT_BEGINNING,
  883. XmNlabelString, xms,
  884. XmNleftAttachment, XmATTACH_FORM,
  885. XmNrightAttachment, XmATTACH_FORM,
  886. XmNtopAttachment, XmATTACH_WIDGET,
  887. XmNtopWidget, widgets->docLabel,
  888. NULL);
  889. XmStringFree(xms);
  890. /*
  891. * Create GUI for the Header/Footer options
  892. */
  893. nitems = PS_ARRAY_SIZE(_psHdrFtrValues);
  894. strings = (char **) XtMalloc( nitems * sizeof(char*) );
  895. data = (void **) XtMalloc( nitems * sizeof(void*) );
  896. for (i=0; i<nitems; i++)
  897. {
  898. data[i] = (void*) _psHdrFtrValues[i].which;
  899. strings[i] = GETMESSAGE(
  900. _psHdrFtrValues[i].set_id,
  901. _psHdrFtrValues[i].msg_id,
  902. _psHdrFtrValues[i].dflt_string
  903. );
  904. }
  905. #if 0
  906. /*
  907. * Create GUI for the Header/Footer options
  908. */
  909. widgets->hdrftrFrame =
  910. _DtPrintCreateHdrFtrFrame(widgets->form, nitems, strings, data);
  911. XtVaSetValues(
  912. widgets->hdrftrFrame,
  913. XmNtopAttachment, XmATTACH_WIDGET,
  914. XmNtopWidget, widgets->wordWrapTB,
  915. XmNleftAttachment, XmATTACH_FORM,
  916. NULL);
  917. XtManageChild(widgets->hdrftrFrame);
  918. /*
  919. * Create GUI for the Margin options
  920. */
  921. widgets->marginFrame = _DtPrintCreateMarginFrame(widgets->form);
  922. XtVaSetValues(
  923. widgets->marginFrame,
  924. XmNtopAttachment, XmATTACH_WIDGET,
  925. XmNtopWidget, widgets->hdrftrFrame,
  926. XmNleftAttachment, XmATTACH_FORM,
  927. NULL);
  928. XtManageChild(widgets->marginFrame);
  929. #else
  930. /*
  931. * Create GUI for the Margin options
  932. */
  933. widgets->marginFrame = _DtPrintCreateMarginFrame(widgets->form);
  934. XtVaSetValues(
  935. widgets->marginFrame,
  936. XmNtopAttachment, XmATTACH_WIDGET,
  937. XmNtopWidget, widgets->wordWrapTB,
  938. XmNleftAttachment, XmATTACH_FORM,
  939. NULL);
  940. XtManageChild(widgets->marginFrame);
  941. /*
  942. * Create GUI for the Header/Footer options
  943. */
  944. widgets->hdrftrFrame =
  945. _DtPrintCreateHdrFtrFrame(widgets->form, nitems, strings, data);
  946. XtVaSetValues(
  947. widgets->hdrftrFrame,
  948. XmNtopAttachment, XmATTACH_WIDGET,
  949. XmNtopWidget, widgets->wordWrapTB,
  950. XmNtopWidget, widgets->marginFrame,
  951. XmNleftAttachment, XmATTACH_FORM,
  952. NULL);
  953. XtManageChild(widgets->hdrftrFrame);
  954. #endif
  955. XtAddCallback(
  956. widgets->hdrftrFrame,
  957. XmNhelpCallback,
  958. HelpPrintSetupPageHeadersFootersCB,
  959. (XtPointer) pPad);
  960. XtAddCallback(
  961. widgets->marginFrame,
  962. XmNhelpCallback,
  963. HelpPrintSetupPageMargins,
  964. (XtPointer) pPad);
  965. XtRealizeWidget(widgets->dtprintSetup);
  966. return widgets->dtprintSetup;
  967. }
  968. /*
  969. * _psReleasePrintSetupDialog
  970. * Removes setup-specific callbacks.
  971. */
  972. static void
  973. _psReleasePrintSetupDialog(PrintSetup *pSetup)
  974. {
  975. /*
  976. * Remove the setup-specific callbacks.
  977. */
  978. XtRemoveCallback(
  979. pSetup->dtprintSetup,
  980. DtNcancelCallback,
  981. _psPrintSetupCancelCB,
  982. (XtPointer) pSetup);
  983. XtRemoveCallback(
  984. pSetup->dtprintSetup,
  985. DtNclosePrintDisplayCallback,
  986. pSetup->closeDisplayCB,
  987. (XtPointer) pSetup->closeDisplayClosure);
  988. XtRemoveCallback(
  989. pSetup->dtprintSetup,
  990. DtNprintCallback,
  991. _psPrintSetupPrintCB,
  992. (XtPointer) pSetup);
  993. XtRemoveCallback(
  994. pSetup->dtprintSetup,
  995. DtNsetupCallback,
  996. pSetup->setupCB,
  997. (XtPointer) pSetup->setupClosure);
  998. #ifdef REUSE_PRINT_SETUP_DIALOGS
  999. if (_psDefaultPrintSetupDialog != NULL)
  1000. {
  1001. /*
  1002. * Attempt to reuse the last print setup and print display connection.
  1003. */
  1004. XtDestroyWidget(_psDefaultPrintSetupDialog);
  1005. _psDefaultPrintSetupDialog = NULL;
  1006. }
  1007. _psDefaultPrintSetupDialog = pSetup->dtprintSetup;
  1008. #else
  1009. XtDestroyWidget(pSetup->dtprintSetup);
  1010. #endif
  1011. }
  1012. /*
  1013. * _psPrintSetupCancelCB
  1014. */
  1015. static void
  1016. _psPrintSetupCancelCB(
  1017. Widget dtprintSetup,
  1018. XtPointer client_data,
  1019. XtPointer call_data)
  1020. {
  1021. PrintSetup *pSetup = (PrintSetup*) client_data;
  1022. PrintSetupHide(pSetup);
  1023. pSetup->cancelCB(dtprintSetup, pSetup->cancelClosure, call_data);
  1024. }
  1025. /*
  1026. * _psPrintSetupDestroyCB
  1027. */
  1028. static void
  1029. _psPrintSetupDestroyCB(
  1030. Widget dtprintSetup,
  1031. XtPointer client_data,
  1032. XtPointer call_data)
  1033. {
  1034. psWidgets *widgets;
  1035. XtVaGetValues(dtprintSetup, XmNuserData, &widgets, NULL);
  1036. XtFree((XtPointer) widgets);
  1037. }
  1038. /*
  1039. * _psPrintSetupPrintCB
  1040. */
  1041. static void
  1042. _psPrintSetupPrintCB(
  1043. Widget dtprintSetup,
  1044. XtPointer client_data,
  1045. XtPointer call_data)
  1046. {
  1047. PrintSetup *pSetup = (PrintSetup*) client_data;
  1048. Boolean error = FALSE;
  1049. if (! _psUiSpecsAreValid(pSetup)) return;
  1050. PrintSetupHide(pSetup);
  1051. _psUiToSetup(pSetup);
  1052. _psSetupToSource(pSetup);
  1053. pSetup->printCB(dtprintSetup, pSetup->printClosure, call_data);
  1054. }