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: FindP.c /main/5 1996/10/15 10:07:22 mustafa $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 * COMPONENT_NAME: Desktop File Manager (dtfile)
31 * Description: Processing functions for the find file dialog.
33 * FUNCTIONS: FindClose
36 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
37 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
38 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
39 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
41 ****************************************************************************
42 ************************************<+>*************************************/
47 #include <Xm/RowColumn.h>
51 #include "SharedProcs.h"
58 #include "SharedMsgs.h"
62 /******** Static Function Declarations ********/
64 static void FindClose( XtPointer client_data,
65 DialogData *old_dialog_data,
66 DialogData *new_dialog_data) ;
68 /******** End Static Function Declarations ********/
73 /************************************************************************
76 * Callback functions invoked from the Find File ... menu
77 * item. This function displays the find file dialog.
79 ************************************************************************/
84 XtPointer client_data,
87 FileMgrRec * file_mgr_rec;
88 DialogData * dialog_data;
89 FileMgrData * file_mgr_data;
95 XmString label_string;
96 char *tempStr, *tmpStr;
98 /* Set the menu item to insensitive to prevent multiple */
99 /* dialogs from being posted and get the area under the */
100 /* menu pane redrawn. */
104 if ( (int) client_data == FM_POPUP )
107 mbar = XmGetPostedFromWidget(XtParent(w));
110 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
111 XtGetValues(mbar, args, 1);
113 /* Ignore accelerators when we're insensitive */
114 if ((file_mgr_rec->menuStates & FIND) == 0)
116 XSetInputFocus(XtDisplay(w),
117 XtWindow(file_mgr_rec->findBtn_child),
118 RevertToParent, CurrentTime);
124 /* Done only when restoring a session */
125 file_mgr_rec = (FileMgrRec *)client_data;
129 /* Ignore accelerators received after we're unposted */
130 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
133 file_mgr_data = (FileMgrData *) dialog_data->data;
135 file_mgr_rec->menuStates &= ~FIND;
137 dialog_data = (DialogData *)file_mgr_data->find;
138 find_data = (FindData *)dialog_data->data;
139 find_data->file_mgr_data = file_mgr_data;
141 if(find_data->content != NULL && w != NULL)
143 if(strcmp(find_data->content, "") != 0)
144 XtFree(find_data->content);
145 find_data->content = NULL;
148 if(find_data->filter != NULL && w != NULL)
150 XtFree(find_data->filter);
151 find_data->filter = NULL;
154 if(find_data->directories != NULL && w != NULL)
156 XtFree(find_data->directories);
157 find_data->directories = NULL;
162 for (i = 0; i < find_data->num_matches; i++)
163 XtFree (find_data->matches[i]);
165 XtFree ((char *) find_data->matches);
167 find_data->matches = NULL;
168 find_data->num_matches = 0;
169 find_data->selected_item = -1;
172 _DtShowDialog (file_mgr_rec->shell, NULL,
173 (XtPointer)file_mgr_rec, file_mgr_data->find,
174 NULL, (XtPointer)file_mgr_rec,
175 FindClose, (XtPointer)file_mgr_rec, NULL, False,
178 /* Save a ptr to file_mgr_rec in the find dialogs structure */
179 find_rec = (FindRec *)_DtGetDialogInstance(file_mgr_data->find);
180 find_rec->fileMgrRec = file_mgr_rec;
182 if(file_mgr_data->title != NULL &&
183 strcmp(file_mgr_data->helpVol, DTFILE_HELP_NAME) != 0)
185 tmpStr = (GETMESSAGE(15,46, "Find"));
186 tempStr = (char *)XtMalloc(strlen(tmpStr) +
187 strlen(file_mgr_data->title) + 5);
188 sprintf(tempStr, "%s - %s", file_mgr_data->title, tmpStr);
192 tmpStr = (GETMESSAGE(15,49, "File Manager - Find"));
193 tempStr = XtNewString(tmpStr);
195 XtSetArg (args[0], XmNtitle, tempStr);
196 XtSetValues (find_rec->shell, args, 1);
198 file_mgr_rec->findBtn_child=find_rec->shell;
200 #if defined(__hpux) || defined(sun)
201 if(file_mgr_data->toolbox)
203 XtSetArg (args[0], XmNmenuHistory, find_rec->widgArry[ON]);
204 XtSetValues(find_rec->followLink, args, 1);
208 label_string = XmStringCreateLocalized (GetSharedMessage(FILES_FOUND_LABEL));
209 XtSetArg (args[0], XmNlabelString, label_string);
210 XtSetValues (find_rec->listLabel, args, 1);
211 XmStringFree (label_string);
217 /************************************************************************
220 * Callback function invoked from the find file dialog's close
221 * button. This function resensitizes the menu item, and saves the
222 * interim dialog values.
224 ************************************************************************/
228 XtPointer client_data,
229 DialogData *old_dialog_data,
230 DialogData *new_dialog_data )
232 FileMgrRec * file_mgr_rec = (FileMgrRec *) client_data;
236 /* Free up the old interim values, and save the new ones */
237 save_data = old_dialog_data->data;
238 old_dialog_data->data = new_dialog_data->data;
239 new_dialog_data->data = save_data;
240 _DtFreeDialogData (new_dialog_data);
243 /* Resensitize the associated menubutton */
244 file_mgr_rec->menuStates |= FIND;