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