libDtSearch: Remove optional code for NO_DBN which is not used on CDE
[oweals/cde.git] / cde / programs / dtsession / OWsync.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 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 /* $TOG: OWsync.c /main/4 1998/07/23 18:11:12 mgreess $ */
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
34 #include <stdio.h>
35 #include <X11/Xlib.h>
36 #include <Dt/DtP.h>
37
38 /*
39  * Include the appropriate header for the ColorSet structure
40  */
41 #if defined(dtsession)
42 #include "Srv.h"
43 #elif defined(dtstyle)
44 #include "ColorMain.h"
45 #endif
46
47 /*
48  * Sync OW Color resources with CDE color object values
49  */
50 void    
51 OWsyncColorResources(
52         Display *       display,
53         int             monitorType, 
54         ColorSet *      colors)
55 {
56         char            colorRes[512];
57         int             winChip, dataChip, wsChip;
58
59         switch (monitorType) {
60         case XmCO_HIGH_COLOR:
61                 winChip = 4; dataChip = 3; wsChip = 7;
62                 break;
63         case XmCO_MEDIUM_COLOR:
64                 winChip = 1; dataChip = 3; wsChip = 1;
65                 break;
66         case XmCO_LOW_COLOR:
67         case XmCO_BLACK_WHITE:
68                 winChip = 1; dataChip = 1; wsChip = 1;
69                 break;
70         default:
71                 return;
72         }
73
74         sprintf(colorRes,
75 "*background:\t#%04X%04X%04X\n\
76 *foreground:\t#%04X%04X%04X\n\
77 OpenWindows.WindowColor:\t#%04X%04X%04X\n\
78 OpenWindows.WindowForeground:\t#%04X%04X%04X\n\
79 OpenWindows.WorkspaceColor:\t#%04X%04X%04X\n\
80 OpenWindows.DataBackground:\t#%04X%04X%04X\n\
81 OpenWindows.DataForeground:\t#%04X%04X%04X\n\
82 Window.Color.Background:\t#%04X%04X%04X\n\
83 Window.Color.Foreground:\t#%04X%04X%04X\n",
84         colors[winChip].bg.red, 
85         colors[winChip].bg.green,
86         colors[winChip].bg.blue,
87         colors[winChip].fg.red,
88         colors[winChip].fg.green,
89         colors[winChip].fg.blue,
90         colors[winChip].bg.red, 
91         colors[winChip].bg.green,
92         colors[winChip].bg.blue,
93         colors[winChip].fg.red,
94         colors[winChip].fg.green,
95         colors[winChip].fg.blue,
96         colors[wsChip].bg.red,
97         colors[wsChip].bg.green,
98         colors[wsChip].bg.blue,
99         colors[dataChip].bg.red,
100         colors[dataChip].bg.green,
101         colors[dataChip].bg.blue,
102         colors[dataChip].fg.red,
103         colors[dataChip].fg.green,
104         colors[dataChip].fg.blue,
105         colors[dataChip].bg.red,
106         colors[dataChip].bg.green,
107         colors[dataChip].bg.blue,
108         colors[dataChip].fg.red,
109         colors[dataChip].fg.green,
110         colors[dataChip].fg.blue);
111
112 #ifdef DEBUG
113 fprintf(stderr,"OWsyncColorResource: setting\n%s\n",colorRes);
114 #endif
115
116         _DtAddToResource(display, colorRes);
117 }
118
119 /*
120  * Sync OW locale resources with CDE's use of the LANG environment variable
121  */
122 void
123 OWsyncLocaleResources(
124         Display *       display)
125 {
126         char    *localeRes;
127         char    *lang;
128
129         lang = getenv("LANG");
130         if (lang == NULL || *lang == 0)
131                 lang = "C";
132
133         localeRes = XtMalloc(BUFSIZ);
134
135         sprintf(localeRes,
136 "OpenWindows.BasicLocale:\t%s\n\
137 OpenWindows.InputLang:\t%s\n\
138 OpenWindows.DisplayLang:\t%s\n\
139 OpenWindows.TimeFormat:\t%s\n\
140 OpenWindows.NumericFormat:\t%s\n",
141                 lang, lang, lang, lang, lang);
142
143 #ifdef DEBUG
144 fprintf(stderr,"OWsyncLocaleResource: setting\n%s\n",localeRes);
145 #endif
146
147         _DtAddToResource(display, localeRes);
148
149         XtFree(localeRes);
150 }