Resource.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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: Resource.c /main/6 1996/07/19 10:21:08 pascale $ */
  24. /************************************<+>*************************************
  25. ****************************************************************************
  26. **
  27. ** File: Resource.c
  28. **
  29. ** Project: DT 3.0
  30. **
  31. ** Description: Controls the Dtstyle resources
  32. **
  33. **
  34. ****************************************************************************
  35. ************************************<+>*************************************/
  36. /*
  37. * (c) Copyright 1996 Digital Equipment Corporation.
  38. * (c) Copyright 1990, 1996 Hewlett-Packard Company.
  39. * (c) Copyright 1996 International Business Machines Corp.
  40. * (c) Copyright 1996 Sun Microsystems, Inc.
  41. * (c) Copyright 1996 Novell, Inc.
  42. * (c) Copyright 1996 FUJITSU LIMITED.
  43. * (c) Copyright 1996 Hitachi.
  44. */
  45. /*+++++++++++++++++++++++++++++++++++++++*/
  46. /* include files */
  47. /*+++++++++++++++++++++++++++++++++++++++*/
  48. #include <Xm/Xm.h>
  49. #include <Xm/XmP.h>
  50. #include "Main.h"
  51. /*+++++++++++++++++++++++++++++++++++++++*/
  52. /* include extern functions */
  53. /*+++++++++++++++++++++++++++++++++++++++*/
  54. #include "Resource.h"
  55. /*+++++++++++++++++++++++++++++++++++++++*/
  56. /* Local #defines */
  57. /*+++++++++++++++++++++++++++++++++++++++*/
  58. #define DEF_FONT "Fixed"
  59. #ifndef CDE_INSTALLATION_TOP
  60. #define CDE_INSTALLATION_TOP "/opt/dt"
  61. #endif
  62. /*+++++++++++++++++++++++++++++++++++++++*/
  63. /* Internal Functions */
  64. /*+++++++++++++++++++++++++++++++++++++++*/
  65. /*+++++++++++++++++++++++++++++++++++++++*/
  66. /* Internal Variables */
  67. /*+++++++++++++++++++++++++++++++++++++++*/
  68. /*++++++++++++++++++++++++++++++++++++++*/
  69. /* Application Resources */
  70. /*++++++++++++++++++++++++++++++++++++++*/
  71. XtResource sysFont_resources[] = {
  72. {"systemFont1", "SystemFont1", XmRFontList, sizeof (XmFontList),
  73. XtOffset(ApplicationDataPtr, fontChoice[0].sysFont), XmRString,
  74. "-adobe-helvetica-medium-r-normal--10-*-iso8859-1"
  75. },
  76. {"systemFont2", "SystemFont2", XmRFontList, sizeof (XmFontList),
  77. XtOffset(ApplicationDataPtr, fontChoice[1].sysFont), XmRString,
  78. "-adobe-helvetica-medium-r-normal--12-*-iso8859-1"
  79. },
  80. {"systemFont3", "SystemFont3", XmRFontList, sizeof (XmFontList),
  81. XtOffset(ApplicationDataPtr, fontChoice[2].sysFont), XmRString,
  82. "-adobe-helvetica-medium-r-normal--14-*-iso8859-1"
  83. },
  84. {"systemFont4", "SystemFont4", XmRFontList, sizeof (XmFontList),
  85. XtOffset(ApplicationDataPtr, fontChoice[3].sysFont), XmRString,
  86. "-adobe-helvetica-medium-r-normal--17-*-iso8859-1"
  87. },
  88. {"systemFont5", "SystemFont5", XmRFontList, sizeof (XmFontList),
  89. XtOffset(ApplicationDataPtr, fontChoice[4].sysFont), XmRString,
  90. "-adobe-helvetica-medium-r-normal--18-*-iso8859-1"
  91. },
  92. {"systemFont6", "SystemFont6", XmRFontList, sizeof (XmFontList),
  93. XtOffset(ApplicationDataPtr, fontChoice[5].sysFont), XmRString,
  94. "-adobe-helvetica-medium-r-normal--20-*-iso8859-1"
  95. },
  96. {"systemFont7", "SystemFont7", XmRFontList, sizeof (XmFontList),
  97. XtOffset(ApplicationDataPtr, fontChoice[6].sysFont), XmRString,
  98. "-adobe-helvetica-medium-r-normal--24-*-iso8859-1"
  99. },
  100. };
  101. XtResource userFont_resources[] = {
  102. {"userFont1", "UserFont1", XmRFontList, sizeof (XmFontList),
  103. XtOffset(ApplicationDataPtr, fontChoice[0].userFont), XmRString,
  104. "-adobe-courier-medium-r-normal--10-*-iso8859-1"
  105. },
  106. {"userFont2", "UserFont2", XmRFontList, sizeof (XmFontList),
  107. XtOffset(ApplicationDataPtr, fontChoice[1].userFont), XmRString,
  108. "-adobe-courier-medium-r-normal--12-*-iso8859-1"
  109. },
  110. {"userFont3", "UserFont3", XmRFontList, sizeof (XmFontList),
  111. XtOffset(ApplicationDataPtr, fontChoice[2].userFont), XmRString,
  112. "-adobe-courier-medium-r-normal--14-*-iso8859-1"
  113. },
  114. {"userFont4", "UserFont4", XmRFontList, sizeof (XmFontList),
  115. XtOffset(ApplicationDataPtr, fontChoice[3].userFont), XmRString,
  116. "-adobe-courier-medium-r-normal--17-*-iso8859-1"
  117. },
  118. {"userFont5", "UserFont5", XmRFontList, sizeof (XmFontList),
  119. XtOffset(ApplicationDataPtr, fontChoice[4].userFont), XmRString,
  120. "-adobe-courier-medium-r-normal--18-*-iso8859-1"
  121. },
  122. {"userFont6", "UserFont6", XmRFontList, sizeof (XmFontList),
  123. XtOffset(ApplicationDataPtr, fontChoice[5].userFont), XmRString,
  124. "-adobe-courier-medium-r-normal--20-*-iso8859-1"
  125. },
  126. {"userFont7", "UserFont7", XmRFontList, sizeof (XmFontList),
  127. XtOffset(ApplicationDataPtr, fontChoice[6].userFont), XmRString,
  128. "-adobe-courier-medium-r-normal--24-*-iso8859-1"
  129. },
  130. };
  131. XtResource sysStr_resources[] = {
  132. {"systemFont1", "SystemFont1", XmRString, sizeof (XmString),
  133. XtOffset(ApplicationDataPtr, fontChoice[0].sysStr), XmRString,
  134. "-adobe-helvetica-medium-r-normal--10-*-iso8859-1"
  135. },
  136. {"systemFont2", "SystemFont2", XmRString, sizeof (XmString),
  137. XtOffset(ApplicationDataPtr, fontChoice[1].sysStr), XmRString,
  138. "-adobe-helvetica-medium-r-normal--12-*-iso8859-1"
  139. },
  140. {"systemFont3", "SystemFont3", XmRString, sizeof (XmString),
  141. XtOffset(ApplicationDataPtr, fontChoice[2].sysStr), XmRString,
  142. "-adobe-helvetica-medium-r-normal--14-*-iso8859-1"
  143. },
  144. {"systemFont4", "SystemFont4", XmRString, sizeof (XmString),
  145. XtOffset(ApplicationDataPtr, fontChoice[3].sysStr), XmRString,
  146. "-adobe-helvetica-medium-r-normal--17-*-iso8859-1"
  147. },
  148. {"systemFont5", "SystemFont5", XmRString, sizeof (XmString),
  149. XtOffset(ApplicationDataPtr, fontChoice[4].sysStr), XmRString,
  150. "-adobe-helvetica-medium-r-normal--18-*-iso8859-1"
  151. },
  152. {"systemFont6", "SystemFont6", XmRString, sizeof (XmString),
  153. XtOffset(ApplicationDataPtr, fontChoice[5].sysStr), XmRString,
  154. "-adobe-helvetica-medium-r-normal--20-*-iso8859-1"
  155. },
  156. {"systemFont7", "SystemFont7", XmRString, sizeof (XmString),
  157. XtOffset(ApplicationDataPtr, fontChoice[6].sysStr), XmRString,
  158. "-adobe-helvetica-medium-r-normal--24-*-iso8859-1"
  159. },
  160. };
  161. XtResource userStr_resources[] = {
  162. {"userFont1", "UserFont1", XmRString, sizeof (XmString),
  163. XtOffset(ApplicationDataPtr, fontChoice[0].userStr), XmRString,
  164. "-adobe-courier-medium-r-normal--10-*-iso8859-1"
  165. },
  166. {"userFont2", "UserFont2", XmRString, sizeof (XmString),
  167. XtOffset(ApplicationDataPtr, fontChoice[1].userStr), XmRString,
  168. "-adobe-courier-medium-r-normal--12-*-iso8859-1"
  169. },
  170. {"userFont3", "UserFont3", XmRString, sizeof (XmString),
  171. XtOffset(ApplicationDataPtr, fontChoice[2].userStr), XmRString,
  172. "-adobe-courier-medium-r-normal--14-*-iso8859-1"
  173. },
  174. {"userFont4", "UserFont4", XmRString, sizeof (XmString),
  175. XtOffset(ApplicationDataPtr, fontChoice[3].userStr), XmRString,
  176. "-adobe-courier-medium-r-normal--17-*-iso8859-1"
  177. },
  178. {"userFont5", "UserFont5", XmRString, sizeof (XmString),
  179. XtOffset(ApplicationDataPtr, fontChoice[4].userStr), XmRString,
  180. "-adobe-courier-medium-r-normal--18-*-iso8859-1"
  181. },
  182. {"userFont6", "UserFont6", XmRString, sizeof (XmString),
  183. XtOffset(ApplicationDataPtr, fontChoice[5].userStr), XmRString,
  184. "-adobe-courier-medium-r-normal--20-*-iso8859-1"
  185. },
  186. {"userFont7", "UserFont7", XmRString, sizeof (XmString),
  187. XtOffset(ApplicationDataPtr, fontChoice[6].userStr), XmRString,
  188. "-adobe-courier-medium-r-normal--24-*-iso8859-1"
  189. },
  190. };
  191. XtResource resources[] = {
  192. {"numFonts", "NumFonts", XmRInt, sizeof (int),
  193. XtOffset(ApplicationDataPtr, numFonts), XmRImmediate, (caddr_t) 7
  194. },
  195. {"systemFont", "SystemFont", XmRFontList, sizeof (XmFontList),
  196. XtOffset(ApplicationDataPtr, systemFont), XmRString, "Fixed"
  197. },
  198. {"userFont", "UserFont", XmRFontList, sizeof (XmFontList),
  199. XtOffset(ApplicationDataPtr, userFont), XmRString, "Fixed"
  200. },
  201. {"systemFont", "SystemFont", XmRString, sizeof (XmString),
  202. XtOffset(ApplicationDataPtr, systemFontStr), XmRString, DEF_FONT
  203. },
  204. {"userFont", "UserFont", XmRString, sizeof (XmString),
  205. XtOffset(ApplicationDataPtr, userFontStr), XmRString, DEF_FONT
  206. },
  207. {"session", "Session", XmRString, sizeof (char *),
  208. XtOffset (ApplicationDataPtr, session), XmRImmediate, (XtPointer)NULL,
  209. },
  210. {"backdropDirectories", "BackdropDirectories", XmRString, sizeof(char *),
  211. XtOffset(ApplicationDataPtr, backdropDir), XmRString, NULL
  212. },
  213. {"paletteDirectories", "PaletteDirectories", XmRString, sizeof(char *),
  214. XtOffset(ApplicationDataPtr, paletteDir), XmRString, NULL
  215. },
  216. {"timeoutScale", "TimeoutScale", XmRString, sizeof (String),
  217. XtOffset(ApplicationDataPtr, timeoutScale), XmRString, "10"
  218. },
  219. {"lockoutScale", "LockoutScale", XmRString, sizeof (String),
  220. XtOffset(ApplicationDataPtr, lockoutScale), XmRString, "30"
  221. },
  222. {"writeXrdbImmediate", "WriteXrdbImmediate", XmRBoolean, sizeof(Boolean) ,
  223. XtOffset(ApplicationDataPtr, writeXrdbImmediate), XmRImmediate, (XtPointer)True
  224. },
  225. {"writeXrdbColors", "WriteXrdbColors", XmRBoolean, sizeof(Boolean) ,
  226. XtOffset(ApplicationDataPtr, writeXrdbColors), XmRImmediate, (XtPointer)True
  227. },
  228. {"componentList", "ComponentList", XtRString, sizeof(String) ,
  229. XtOffset(ApplicationDataPtr, componentList), XmRImmediate,
  230. "Color Font Backdrop Keyboard Mouse Audio Screen Dtwm Startup"
  231. },
  232. {"imServerHosts", "ImServerHosts", XmRXmStringTable, sizeof(XmStringTable) ,
  233. XtOffset(ApplicationDataPtr, imServerHosts), XmRImmediate,
  234. NULL
  235. },
  236. {"preeditType", "PreeditType", XmRXmStringTable, sizeof(XmStringTable) ,
  237. XtOffset(ApplicationDataPtr, preeditType), XmRString,
  238. "OnTheSpot,OverTheSpot,OffTheSpot,Root"
  239. },
  240. {"pipeTimeOut", "PipeTimeOut", XmRInt, sizeof (int),
  241. XtOffset(ApplicationDataPtr, pipeTimeOut), XmRImmediate, (caddr_t) 100
  242. },
  243. };
  244. /************************************************************************
  245. * GetSysFontResources
  246. *
  247. * Description:
  248. * -----------
  249. * This function is used to retrieve the Dtstyle System Font resources
  250. ************************************************************************/
  251. void
  252. GetSysFontResource(int i)
  253. {
  254. XtGetApplicationResources(style.shell, &style.xrdb,
  255. &sysFont_resources[i],
  256. 1, NULL, 0);
  257. }
  258. /************************************************************************
  259. * GetUserFontResources
  260. *
  261. * Description:
  262. * -----------
  263. * This function is used to retrieve the Dtstyle User Font resources
  264. ************************************************************************/
  265. void
  266. GetUserFontResource(int i)
  267. {
  268. XtGetApplicationResources(style.shell, &style.xrdb,
  269. &userFont_resources[i],
  270. 1, NULL, 0);
  271. }
  272. /************************************************************************
  273. * GetFontStrResources
  274. *
  275. * Description:
  276. * -----------
  277. ************************************************************************/
  278. static void
  279. GetFontStrResources( void )
  280. {
  281. int i;
  282. XtGetApplicationResources(style.shell, &style.xrdb, sysStr_resources,
  283. XtNumber(sysStr_resources), NULL, 0);
  284. XtGetApplicationResources(style.shell, &style.xrdb, userStr_resources,
  285. XtNumber(userStr_resources), NULL, 0);
  286. for (i=0; i<style.xrdb.numFonts; i++) {
  287. style.xrdb.fontChoice[i].userFont = NULL;
  288. style.xrdb.fontChoice[i].sysFont = NULL;
  289. }
  290. }
  291. /************************************************************************
  292. * GetApplicationResources
  293. *
  294. * Description:
  295. * -----------
  296. * This function is used to retrieve Dtstyle resources that are
  297. * not component-specific.
  298. ************************************************************************/
  299. void
  300. GetApplicationResources( void )
  301. {
  302. XtGetApplicationResources(style.shell, &style.xrdb, resources,
  303. XtNumber(resources), NULL, 0);
  304. GetFontStrResources();
  305. }