1 /* $XConsortium: FindP.c /main/5 1996/10/15 10:07:22 mustafa $ */
2 /************************************<+>*************************************
3 ****************************************************************************
7 * COMPONENT_NAME: Desktop File Manager (dtfile)
9 * Description: Processing functions for the find file dialog.
11 * FUNCTIONS: FindClose
14 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
15 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
16 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
17 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
19 ****************************************************************************
20 ************************************<+>*************************************/
25 #include <Xm/RowColumn.h>
29 #include "SharedProcs.h"
36 #include "SharedMsgs.h"
40 /******** Static Function Declarations ********/
42 static void FindClose( XtPointer client_data,
43 DialogData *old_dialog_data,
44 DialogData *new_dialog_data) ;
46 /******** End Static Function Declarations ********/
51 /************************************************************************
54 * Callback functions invoked from the Find File ... menu
55 * item. This function displays the find file dialog.
57 ************************************************************************/
62 XtPointer client_data,
65 FileMgrRec * file_mgr_rec;
66 DialogData * dialog_data;
67 FileMgrData * file_mgr_data;
73 XmString label_string;
74 char *tempStr, *tmpStr;
76 /* Set the menu item to insensitive to prevent multiple */
77 /* dialogs from being posted and get the area under the */
78 /* menu pane redrawn. */
82 if ( (int) client_data == FM_POPUP )
85 mbar = XmGetPostedFromWidget(XtParent(w));
88 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
89 XtGetValues(mbar, args, 1);
91 /* Ignore accelerators when we're insensitive */
92 if ((file_mgr_rec->menuStates & FIND) == 0)
94 XSetInputFocus(XtDisplay(w),
95 XtWindow(file_mgr_rec->findBtn_child),
96 RevertToParent, CurrentTime);
102 /* Done only when restoring a session */
103 file_mgr_rec = (FileMgrRec *)client_data;
107 /* Ignore accelerators received after we're unposted */
108 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
111 file_mgr_data = (FileMgrData *) dialog_data->data;
113 file_mgr_rec->menuStates &= ~FIND;
115 dialog_data = (DialogData *)file_mgr_data->find;
116 find_data = (FindData *)dialog_data->data;
117 find_data->file_mgr_data = file_mgr_data;
119 if(find_data->content != NULL && w != NULL)
121 if(strcmp(find_data->content, "") != 0)
122 XtFree(find_data->content);
123 find_data->content = NULL;
126 if(find_data->filter != NULL && w != NULL)
128 XtFree(find_data->filter);
129 find_data->filter = NULL;
132 if(find_data->directories != NULL && w != NULL)
134 XtFree(find_data->directories);
135 find_data->directories = NULL;
140 for (i = 0; i < find_data->num_matches; i++)
141 XtFree (find_data->matches[i]);
143 XtFree ((char *) find_data->matches);
145 find_data->matches = NULL;
146 find_data->num_matches = 0;
147 find_data->selected_item = -1;
150 _DtShowDialog (file_mgr_rec->shell, NULL,
151 (XtPointer)file_mgr_rec, file_mgr_data->find,
152 NULL, (XtPointer)file_mgr_rec,
153 FindClose, (XtPointer)file_mgr_rec, NULL, False,
156 /* Save a ptr to file_mgr_rec in the find dialogs structure */
157 find_rec = (FindRec *)_DtGetDialogInstance(file_mgr_data->find);
158 find_rec->fileMgrRec = file_mgr_rec;
160 if(file_mgr_data->title != NULL &&
161 strcmp(file_mgr_data->helpVol, DTFILE_HELP_NAME) != 0)
163 tmpStr = (GETMESSAGE(15,46, "Find"));
164 tempStr = (char *)XtMalloc(strlen(tmpStr) +
165 strlen(file_mgr_data->title) + 5);
166 sprintf(tempStr, "%s - %s", file_mgr_data->title, tmpStr);
170 tmpStr = (GETMESSAGE(15,49, "File Manager - Find"));
171 tempStr = XtNewString(tmpStr);
173 XtSetArg (args[0], XmNtitle, tempStr);
174 XtSetValues (find_rec->shell, args, 1);
176 file_mgr_rec->findBtn_child=find_rec->shell;
178 #if defined(__hpux) || defined(sun)
179 if(file_mgr_data->toolbox)
181 XtSetArg (args[0], XmNmenuHistory, find_rec->widgArry[ON]);
182 XtSetValues(find_rec->followLink, args, 1);
186 label_string = XmStringCreateLocalized (GetSharedMessage(FILES_FOUND_LABEL));
187 XtSetArg (args[0], XmNlabelString, label_string);
188 XtSetValues (find_rec->listLabel, args, 1);
189 XmStringFree (label_string);
195 /************************************************************************
198 * Callback function invoked from the find file dialog's close
199 * button. This function resensitizes the menu item, and saves the
200 * interim dialog values.
202 ************************************************************************/
206 XtPointer client_data,
207 DialogData *old_dialog_data,
208 DialogData *new_dialog_data )
210 FileMgrRec * file_mgr_rec = (FileMgrRec *) client_data;
214 /* Free up the old interim values, and save the new ones */
215 save_data = old_dialog_data->data;
216 old_dialog_data->data = new_dialog_data->data;
217 new_dialog_data->data = save_data;
218 _DtFreeDialogData (new_dialog_data);
221 /* Resensitize the associated menubutton */
222 file_mgr_rec->menuStates |= FIND;