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 /* $XConsortium: OpenFile.c /main/6 1996/10/17 14:06:40 rswiston $ */
24 /*******************************************************************************
27 Associated Header file: OpenFile.h
28 *******************************************************************************/
32 #include <Xm/MwmUtil.h>
33 #include <Xm/DialogS.h>
34 #include <Xm/MenuShell.h>
35 #include <Xm/FileSB.h>
43 #define CONTEXT_MACRO_ACCESS 1
45 #undef CONTEXT_MACRO_ACCESS
48 _XmStringUngenerate(XmString, XmStringTag, XmTextType, XmTextType);
50 /*******************************************************************************
51 The following are callback functions.
52 *******************************************************************************/
54 static void cancelCB_OpenFile( Widget UxWidget,
55 XtPointer UxClientData,
56 XtPointer UxCallbackArg )
59 _UxCOpenFile *UxSaveCtx, *UxContext;
61 UxSaveCtx = UxOpenFileContext;
62 UxOpenFileContext = UxContext =
63 (_UxCOpenFile *) UxGetContext( UxWidget );
66 UxPopdownInterface(UxWidget);
68 UxOpenFileContext = UxSaveCtx;
71 static void okCallback_OpenFile( Widget UxWidget,
72 XtPointer UxClientData,
73 XtPointer UxCallbackArg )
76 _UxCOpenFile *UxSaveCtx, *UxContext;
77 XmFileSelectionBoxCallbackStruct *cbs;
82 UxSaveCtx = UxOpenFileContext;
83 UxOpenFileContext = UxContext =
84 (_UxCOpenFile *) UxGetContext( UxWidget );
87 /********************************************************************/
88 /* Call file parsing code here! */
89 /********************************************************************/
90 cbs = (XmFileSelectionBoxCallbackStruct *)UxCallbackArg;
92 XtFree(pszFileToEdit);
95 _XmStringUngenerate(cbs->value, NULL,
96 XmCHARSET_TEXT, XmCHARSET_TEXT);
97 if (pszFileToEdit != (char *)NULL) {
98 memset(&ADTmp, 0, sizeof(ActionData));
99 rc = OpenDefinitionFile(pszFileToEdit, &ADTmp);
101 /*****************************************************************/
102 /* If everything ok, then clear out data from action structure */
103 /* and store new data. */
104 /*****************************************************************/
107 memcpy(&AD, &ADTmp, sizeof(ActionData));
110 UxPopdownInterface (UxWidget);
112 /********************************************************************/
113 /* If successfully opened and parsed file, then init the fields of */
114 /* the main window. */
115 /********************************************************************/
117 clear_CreateActionAppShell_fields();
121 UxOpenFileContext = UxSaveCtx;
124 static void helpCallback_OpenFile( Widget UxWidget,
125 XtPointer UxClientData,
126 XtPointer UxCallbackArg )
129 _UxCOpenFile *UxSaveCtx, *UxContext;
131 UxSaveCtx = UxOpenFileContext;
132 UxOpenFileContext = UxContext =
133 (_UxCOpenFile *) UxGetContext( UxWidget );
135 DisplayHelpDialog(UxWidget, HELP_OPENFILE, UxCallbackArg);
137 UxOpenFileContext = UxSaveCtx;
140 /*******************************************************************************
141 The 'build_' function creates all the widgets
142 using the resource values specified in the Property Editor.
143 *******************************************************************************/
145 static Widget _Uxbuild_OpenFile(void)
149 /* Creation of OpenFile */
150 _UxParent = XtVaCreatePopupShell( "OpenFile_shell",
151 xmDialogShellWidgetClass, UxTopLevel,
156 XmNallowShellResize, TRUE,
157 XmNshellUnitType, XmPIXELS,
158 XmNtitle, GETMESSAGE(12, 25, "Create Action - Open"),
161 OpenFile = XtVaCreateWidget( "OpenFile",
162 xmFileSelectionBoxWidgetClass,
164 XmNresizePolicy, XmRESIZE_GROW,
165 XmNunitType, XmPIXELS,
168 RES_CONVERT( XmNdialogTitle, GETMESSAGE(12, 25, "Create Action - Open")),
169 RES_CONVERT( XmNdirectory, "" ),
170 RES_CONVERT( XmNtextString, "" ),
171 RES_CONVERT( XmNdirSpec, "" ),
172 XmNdialogType, XmDIALOG_FILE_SELECTION,
174 XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
175 XmNallowOverlap, FALSE,
176 RES_CONVERT( XmNchildPlacement, "place_below_selection" ),
177 XmNdefaultPosition, FALSE,
178 RES_CONVERT( XmNdirMask, "" ),
179 RES_CONVERT( XmNpattern, "" ),
181 XtAddCallback( OpenFile, XmNcancelCallback,
182 (XtCallbackProc) cancelCB_OpenFile,
183 (XtPointer) UxOpenFileContext );
184 XtAddCallback( OpenFile, XmNokCallback,
185 (XtCallbackProc) okCallback_OpenFile,
186 (XtPointer) UxOpenFileContext );
187 XtAddCallback( OpenFile, XmNhelpCallback,
188 (XtCallbackProc) helpCallback_OpenFile,
189 (XtPointer) UxOpenFileContext );
190 XtVaSetValues(OpenFile, XmNuserData, OpenFile, NULL);
192 UxPutContext( OpenFile, (char *) UxOpenFileContext );
194 XtAddCallback( OpenFile, XmNdestroyCallback,
195 (XtCallbackProc) UxDestroyContextCB,
196 (XtPointer) UxOpenFileContext);
201 /*******************************************************************************
202 The following is the 'Interface function' which is the
203 external entry point for creating this interface.
204 This function should be called from your application or from
206 *******************************************************************************/
208 Widget create_OpenFile(void)
211 _UxCOpenFile *UxContext;
213 UxOpenFileContext = UxContext =
214 (_UxCOpenFile *) UxNewContext( sizeof(_UxCOpenFile), False );
217 rtrn = _Uxbuild_OpenFile();
222 /*******************************************************************************
224 *******************************************************************************/