JobBox.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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: JobBox.c /main/3 1996/08/12 18:41:59 cde-hp $ */
  24. /*
  25. * dtpdm/JobBox.c
  26. */
  27. /*
  28. * (c) Copyright 1996 Digital Equipment Corporation.
  29. * (c) Copyright 1996 Hewlett-Packard Company.
  30. * (c) Copyright 1996 International Business Machines Corp.
  31. * (c) Copyright 1996 Sun Microsystems, Inc.
  32. * (c) Copyright 1996 Novell, Inc.
  33. * (c) Copyright 1996 FUJITSU LIMITED.
  34. * (c) Copyright 1996 Hitachi.
  35. */
  36. #include <Dt/PrintDlgMgrP.h>
  37. #include "JobBox.h"
  38. /*
  39. * JobBox-specific data - PdmSetupBox.subclass_data
  40. */
  41. typedef struct
  42. {
  43. const char* job_options;
  44. const char* job_name;
  45. PdmOidNotify notification_profile;
  46. Boolean job_options_supported;
  47. Boolean job_name_supported;
  48. Boolean notification_profile_supported;
  49. Widget job_options_text;
  50. Widget job_name_text;
  51. Widget notify_toggle;
  52. } PdmJobBoxData;
  53. /*
  54. * JobBox-specific fallback resources
  55. */
  56. static String PdmJobBoxFallbackResources[] =
  57. {
  58. "*JobSetup.locationId: JobSetup",
  59. "*JobSetup.marginHeight: 5",
  60. "*JobSetup.marginWidth: 5",
  61. "*JobSetup.verticalSpacing: 5",
  62. "*JobTab.compoundString: Job",
  63. "*JobTab.labelString: Job"
  64. };
  65. /*
  66. * static function declarations
  67. */
  68. static void PdmJobBoxDelete(PdmSetupBox* me);
  69. static void PdmJobBoxCreate(PdmSetupBox* me, Widget parent);
  70. static PdmStatus PdmJobBoxVerifyAttr(PdmSetupBox* me, PdmXp* pdm_xp);
  71. static void PdmJobBoxGetAttr(PdmSetupBox* me, PdmXp* pdm_xp);
  72. static void PdmJobBoxSetAttr(PdmSetupBox* me, PdmXp* pdm_xp);
  73. /*
  74. * ------------------------------------------------------------------------
  75. * Name: PdmJobBoxNew
  76. *
  77. * Description:
  78. *
  79. * Creates a new PdmJobBox (PdmSetupBox) instance structure.
  80. *
  81. * Return value:
  82. *
  83. * The new PdmJobBox instance structure.
  84. *
  85. */
  86. PdmSetupBox*
  87. PdmJobBoxNew(void)
  88. {
  89. PdmSetupBox* me = (PdmSetupBox*)XtCalloc(1, sizeof(PdmSetupBox));
  90. me->delete_proc = PdmJobBoxDelete;
  91. me->create_proc = PdmJobBoxCreate;
  92. me->verify_attr_proc = PdmJobBoxVerifyAttr;
  93. me->get_attr_proc = PdmJobBoxGetAttr;
  94. me->set_attr_proc = PdmJobBoxSetAttr;
  95. me->fallback_resources = PdmJobBoxFallbackResources;
  96. me->fallback_resources_count = XtNumber(PdmJobBoxFallbackResources);
  97. me->tab_name = "JobTab";
  98. me->subclass_data = (XtPointer)XtCalloc(1, sizeof(PdmJobBoxData));
  99. return me;
  100. }
  101. /*
  102. * ------------------------------------------------------------------------
  103. * Name: PdmJobBoxDelete
  104. *
  105. * Description:
  106. *
  107. * Frees the passed PdmJobBox (PdmSetupBox) instance structure.
  108. *
  109. * Return value:
  110. *
  111. * None.
  112. *
  113. */
  114. static void
  115. PdmJobBoxDelete(PdmSetupBox* me)
  116. {
  117. PdmJobBoxData* data = (PdmJobBoxData*)me->subclass_data;
  118. XtFree((char*)data);
  119. XtFree((char*)me);
  120. }
  121. /*
  122. * ------------------------------------------------------------------------
  123. * Name: PdmJobBoxCreate
  124. *
  125. * Description:
  126. *
  127. * Creates a managed PDM Job options setup box widget.
  128. *
  129. * Return value:
  130. *
  131. * The passed PdmJobBox (PdmSetupBox) instance structure.
  132. *
  133. */
  134. static void
  135. PdmJobBoxCreate(PdmSetupBox* me, Widget parent)
  136. {
  137. PdmJobBoxData* data = (PdmJobBoxData*)me->subclass_data;
  138. me->widget = _DtCreatePDMJobSetup(parent);
  139. XtManageChild(me->widget);
  140. /*
  141. * get the control widget ids
  142. */
  143. data->notify_toggle = XtNameToWidget(me->widget, "*SendMail.button_0");
  144. data->job_name_text = XtNameToWidget(me->widget, "*Banner");
  145. data->job_options_text = XtNameToWidget(me->widget, "*Options");
  146. /*
  147. * initialize the banner field
  148. */
  149. if(data->job_name_supported)
  150. {
  151. XtVaSetValues(data->job_name_text, XmNvalue, data->job_name, NULL);
  152. }
  153. else
  154. {
  155. XtSetSensitive(data->job_name_text, False);
  156. XtSetSensitive(XtNameToWidget(me->widget, "*BannerLabel"), False);
  157. }
  158. /*
  159. * initialize the options field
  160. */
  161. if(data->job_options_supported)
  162. {
  163. XtVaSetValues(data->job_options_text,
  164. XmNvalue, data->job_options,
  165. NULL);
  166. }
  167. else
  168. {
  169. XtSetSensitive(data->job_options_text, False);
  170. XtSetSensitive(XtNameToWidget(me->widget, "*OptionsLabel"), False);
  171. }
  172. /*
  173. * initialize the send mail toggle
  174. */
  175. if(data->notification_profile_supported)
  176. {
  177. Boolean set;
  178. set = PDMOID_NOTIFY_EMAIL == data->notification_profile ? True : False;
  179. XmToggleButtonGadgetSetState(data->notify_toggle, set, False);
  180. }
  181. else
  182. {
  183. XtSetSensitive(data->notify_toggle, False);
  184. }
  185. }
  186. /*
  187. * ------------------------------------------------------------------------
  188. * Name: PdmJobBoxVerifyAttr
  189. *
  190. * Description:
  191. *
  192. *
  193. *
  194. * Return value:
  195. *
  196. * PDM_SUCCESS if all of the Printer options selected are OK.
  197. *
  198. * PDM_FAILURE if any of the Printer options are invalid.
  199. *
  200. */
  201. static PdmStatus
  202. PdmJobBoxVerifyAttr(PdmSetupBox* me, PdmXp* pdm_xp)
  203. {
  204. return PDM_SUCCESS;
  205. }
  206. /*
  207. * ------------------------------------------------------------------------
  208. * Name: PdmJobBoxGetAttr
  209. *
  210. * Description:
  211. *
  212. * Return value:
  213. *
  214. * None.
  215. *
  216. */
  217. static void
  218. PdmJobBoxGetAttr(PdmSetupBox* me, PdmXp* pdm_xp)
  219. {
  220. PdmJobBoxData* data = (PdmJobBoxData*)me->subclass_data;
  221. PdmOidList* job_attrs_supported = NULL;
  222. const char* strval = NULL;
  223. /*
  224. * job attributes supported
  225. */
  226. #if 0 && defined(PRINTING_SUPPORTED)
  227. strval = PdmXpGetStringValue(pdm_xp, XPPrinterAttr,
  228. pdmoid_att_job_attributes_supported);
  229. #endif /* PRINTING_SUPPORTED */
  230. job_attrs_supported = PdmOidListNew(strval);
  231. /*
  232. * job options
  233. */
  234. if(PdmOidListHasOid(job_attrs_supported,
  235. pdmoid_att_xp_spooler_command_options))
  236. {
  237. data->job_options_supported = True;
  238. #if 0 && defined(PRINTING_SUPPORTED)
  239. data->job_options =
  240. PdmXpGetStringValue(pdm_xp, XPJobAttr,
  241. pdmoid_att_xp_spooler_command_options);
  242. #endif /* PRINTING_SUPPORTED */
  243. }
  244. /*
  245. * job name (banner)
  246. */
  247. if(PdmOidListHasOid(job_attrs_supported, pdmoid_att_job_name))
  248. {
  249. data->job_name_supported = True;
  250. #if 0 && defined(PRINTING_SUPPORTED)
  251. data->job_name =
  252. PdmXpGetStringValue(pdm_xp, XPJobAttr, pdmoid_att_job_name);
  253. #endif /* PRINTING_SUPPORTED */
  254. }
  255. /*
  256. * notification profile (send mail)
  257. */
  258. if(PdmOidListHasOid(job_attrs_supported, pdmoid_att_notification_profile))
  259. {
  260. #if 0 && defined(PRINTING_SUPPORTED)
  261. strval = PdmXpGetStringValue(pdm_xp, XPJobAttr,
  262. pdmoid_att_notification_profile);
  263. #endif /* PRINTING_SUPPORTED */
  264. data->notification_profile = PdmOidNotifyParse(strval);
  265. if(data->notification_profile != PDMOID_NOTIFY_UNSUPPORTED)
  266. data->notification_profile_supported = True;
  267. }
  268. /*
  269. * clean up
  270. */
  271. PdmOidListDelete(job_attrs_supported);
  272. }
  273. /*
  274. * ------------------------------------------------------------------------
  275. * Name: PdmJobBoxSetAttr
  276. *
  277. * Description:
  278. *
  279. * Return value:
  280. *
  281. * None.
  282. *
  283. */
  284. static void
  285. PdmJobBoxSetAttr(PdmSetupBox* me, PdmXp* pdm_xp)
  286. {
  287. PdmJobBoxData* data = (PdmJobBoxData*)me->subclass_data;
  288. if(data->job_options_supported)
  289. {
  290. String value;
  291. XtVaGetValues(data->job_options_text, XmNvalue, &value, NULL);
  292. #if 0 && defined(PRINTING_SUPPORTED)
  293. PdmXpSetStringValue(pdm_xp, XPJobAttr,
  294. pdmoid_att_xp_spooler_command_options, value);
  295. #endif /* PRINTING_SUPPORTED */
  296. XtFree(value);
  297. }
  298. if(data->job_name_supported)
  299. {
  300. String value;
  301. XtVaGetValues(data->job_name_text, XmNvalue, &value, NULL);
  302. #if 0 && defined(PRINTING_SUPPORTED)
  303. PdmXpSetStringValue(pdm_xp, XPJobAttr, pdmoid_att_job_name, value);
  304. #endif /* PRINTING_SUPPORTED */
  305. XtFree(value);
  306. }
  307. if(data->notification_profile_supported)
  308. {
  309. Boolean set;
  310. set = XmToggleButtonGadgetGetState(data->notify_toggle);
  311. #if 0 && defined(PRINTING_SUPPORTED)
  312. PdmXpSetStringValue(pdm_xp, XPJobAttr,
  313. pdmoid_att_notification_profile,
  314. PdmOidNotifyString(set
  315. ? PDMOID_NOTIFY_EMAIL
  316. : PDMOID_NOTIFY_NONE));
  317. #endif /* PRINTING_SUPPORTED */
  318. }
  319. }