2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $TOG: DtUtil.c /main/10 1998/07/30 12:13:08 mgreess $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
30 /******************************************************************************
34 * Contains the DT functions used by an application to connect to the
35 * underlying communications mechanism.
37 *****************************************************************************/
38 #include <sys/param.h>
39 #include <sys/types.h>
43 #include <X11/Intrinsic.h>
44 #include <X11/StringDefs.h>
47 #include <Dt/UserMsg.h>
48 #include <Dt/DtNlUtils.h>
49 #include <Dt/EnvControlP.h>
50 #include "DtSvcLock.h"
52 /*****************************************
54 * External functions not defined in header files.
56 *****************************************/
58 /******** End Public Function Declarations ********/
60 /******** Static Function Declarations ********/
62 static Boolean DtBigInitialize(
67 XtAppContext app_context) ;
68 static void InitButtonLabels( void ) ;
69 static void DtGlobalsInitialize(
74 /******** End Static Function Declarations ********/
77 /*****************************************
81 *****************************************/
83 XrmDatabase _DtResourceDatabase = NULL; /* This Dt global indicates which
84 Xrm database should be read for
87 XtAppContext _DtAppContext = NULL; /* This Dt global keeps track of the
88 app-context, if one has been
89 specified. Note that libXv does
90 not yet support multiple app-
92 XtAppContext *_DtInitAppContextp = NULL;
93 Widget _DtInitTtContextWidget = NULL;
95 Display *_DtDisplay = NULL; /* This global variable is saved
96 when a client invokes "DtInitialize"
97 It is used later to get resources
98 when the DT databases are loaded.*/
99 char *_DtApplicationName = NULL; /* This global variable is the
100 client's "ApplicationName". */
101 char *_DtApplicationClass = NULL; /* This global variable is the
102 client's "ApplicationClass". */
103 char *_DtToolClass = NULL; /* Tool class passed to _DtInit...() */
106 /* Localizable button labels */
107 const char * _DtOkString = NULL;
108 const char * _DtCancelString = NULL;
109 const char * _DtHelpString = NULL;
110 const char * _DtApplyString = NULL;
111 const char * _DtCloseString = NULL;
114 /*********************************************
116 * Initialization Functions
118 *********************************************/
122 XtAppContext app_context,
130 _DtSvcAppLock(app_context);
131 result = DtBigInitialize (display, widget, name, toolClass, app_context);
132 _DtSvcAppUnlock(app_context);
144 _DtSvcDisplayToAppContext(display);
147 result = DtBigInitialize (display, widget, name, toolClass, NULL);
148 _DtSvcAppUnlock(app);
158 XtAppContext app_context )
161 static Boolean initialized = False;
163 /* Initialization can only be performed once. */
166 _DtSvcProcessUnlock();
170 /* Preserve the pre-Dt environ and add Dt-specifics to environ */
171 (void) _DtEnvControl (DT_ENV_SET);
173 /* Initialize a bunch of miscellaneous things. */
176 DtGlobalsInitialize (display, name, toolClass);
178 if ( XmIsGadget(widget) )
179 _DtInitTtContextWidget = XtParent(widget);
181 _DtInitTtContextWidget = widget;
184 _DtAppContext = app_context;
186 _DtAppContext = XtWidgetToApplicationContext(_DtInitTtContextWidget);
187 _DtInitAppContextp = &_DtAppContext;
190 _DtSvcProcessUnlock();
191 return (initialized);
195 /* Initialize the global button labels */
198 InitButtonLabels( void )
201 _DtOkString = XtNewString(Dt11GETMESSAGE(28, 1, "OK"));
202 _DtCancelString = XtNewString(Dt11GETMESSAGE(28, 2, "Cancel"));
203 _DtHelpString = XtNewString(Dt11GETMESSAGE(28, 3, "Help"));
204 _DtApplyString = XtNewString(Dt11GETMESSAGE(28, 4, "Apply"));
205 _DtCloseString = XtNewString(Dt11GETMESSAGE(28, 5, "Close"));
214 _DtResourceDatabase = XtDatabase (display);
216 _DtToolClass = XtNewString(toolClass);
218 XeToolClass = XtNewString (toolClass);
221 * Save the application name and application class.
223 _DtDisplay = display;
224 XtGetApplicationNameAndClass (display,
226 &_DtApplicationClass);