OWsync.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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: OWsync.c /main/3 1996/05/08 20:12:08 drk $ */
  24. /*******************************************************************************
  25. **
  26. ** OWsync.c
  27. **
  28. ** Implements functions to synchronize CDE and OpenWindows resources.
  29. **
  30. ** Copyright 1995 Sun Microsystems, Inc. All rights reserved.
  31. **
  32. *******************************************************************************/
  33. #include <stdio.h>
  34. #include <X11/Xlib.h>
  35. #include <Dt/DtP.h>
  36. /*
  37. * Include the appropriate header for the ColorSet structure
  38. */
  39. #if defined(dtsession)
  40. #include "Srv.h"
  41. #elif defined(dtstyle)
  42. #include "ColorMain.h"
  43. #endif
  44. /*
  45. * Sync OW Color resources with CDE color object values
  46. */
  47. void
  48. OWsyncColorResources(
  49. Display * display,
  50. int monitorType,
  51. ColorSet * colors)
  52. {
  53. char colorRes[512];
  54. int winChip, dataChip, wsChip;
  55. switch (monitorType) {
  56. case XmCO_HIGH_COLOR:
  57. winChip = 4; dataChip = 3; wsChip = 7;
  58. break;
  59. case XmCO_MEDIUM_COLOR:
  60. winChip = 1; dataChip = 3; wsChip = 1;
  61. break;
  62. case XmCO_LOW_COLOR:
  63. case XmCO_BLACK_WHITE:
  64. winChip = 1; dataChip = 1; wsChip = 1;
  65. break;
  66. default:
  67. return;
  68. }
  69. sprintf(colorRes,
  70. "*background:\t#%04X%04X%04X\n\
  71. *foreground:\t#%04X%04X%04X\n\
  72. OpenWindows.WindowColor:\t#%04X%04X%04X\n\
  73. OpenWindows.WindowForeground:\t#%04X%04X%04X\n\
  74. OpenWindows.WorkspaceColor:\t#%04X%04X%04X\n\
  75. OpenWindows.DataBackground:\t#%04X%04X%04X\n\
  76. OpenWindows.DataForeground:\t#%04X%04X%04X\n\
  77. Window.Color.Background:\t#%04X%04X%04X\n\
  78. Window.Color.Foreground:\t#%04X%04X%04X\n",
  79. colors[winChip].bg.red,
  80. colors[winChip].bg.green,
  81. colors[winChip].bg.blue,
  82. colors[winChip].fg.red,
  83. colors[winChip].fg.green,
  84. colors[winChip].fg.blue,
  85. colors[winChip].bg.red,
  86. colors[winChip].bg.green,
  87. colors[winChip].bg.blue,
  88. colors[winChip].fg.red,
  89. colors[winChip].fg.green,
  90. colors[winChip].fg.blue,
  91. colors[wsChip].bg.red,
  92. colors[wsChip].bg.green,
  93. colors[wsChip].bg.blue,
  94. colors[dataChip].bg.red,
  95. colors[dataChip].bg.green,
  96. colors[dataChip].bg.blue,
  97. colors[dataChip].fg.red,
  98. colors[dataChip].fg.green,
  99. colors[dataChip].fg.blue,
  100. colors[dataChip].bg.red,
  101. colors[dataChip].bg.green,
  102. colors[dataChip].bg.blue,
  103. colors[dataChip].fg.red,
  104. colors[dataChip].fg.green,
  105. colors[dataChip].fg.blue);
  106. #ifdef DEBUG
  107. fprintf(stderr,"OWsyncColorResource: setting\n%s\n",colorRes);
  108. #endif
  109. _DtAddToResource(display, colorRes);
  110. }
  111. /*
  112. * Sync OW locale resources with CDE's use of the LANG environment variable
  113. */
  114. void
  115. OWsyncLocaleResources(
  116. Display * display)
  117. {
  118. char localeRes[512];
  119. char * lang;
  120. lang = getenv("LANG");
  121. if (lang == NULL || *lang == 0)
  122. lang = "C";
  123. sprintf(localeRes,
  124. "OpenWindows.BasicLocale:\t%s\n\
  125. OpenWindows.InputLang:\t%s\n\
  126. OpenWindows.DisplayLang:\t%s\n\
  127. OpenWindows.TimeFormat:\t%s\n\
  128. OpenWindows.NumericFormat:\t%s\n",
  129. lang, lang, lang, lang, lang);
  130. #ifdef DEBUG
  131. fprintf(stderr,"OWsyncLocaleResource: setting\n%s\n",localeRes);
  132. #endif
  133. _DtAddToResource(display, localeRes);
  134. }