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: Filter.c /main/8 1996/10/30 11:10:48 drk $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 * COMPONENT_NAME: Desktop File Manager (dtfile)
31 * Description: Source file for the file filter dialog.
33 * FUNCTIONS: ApplyCallback
51 * UpdateFilterAfterDBReread
55 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
56 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
57 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
58 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
60 ****************************************************************************
61 ************************************<+>*************************************/
70 #include <Xm/DialogS.h>
71 #include <Xm/DrawingA.h>
73 #include <Xm/LabelG.h>
75 #include <Xm/MessageB.h>
76 #include <Xm/PushBG.h>
77 #include <Xm/RowColumn.h>
79 #include <Xm/ToggleBG.h>
80 #include <Xm/ScrollBar.h>
81 #include <Xm/ScrolledW.h>
82 #include <Xm/SeparatoG.h>
83 #include <Xm/VendorSEP.h>
84 #include <Xm/MwmUtil.h>
85 #include <Xm/Protocols.h>
87 #include <Dt/TitleBox.h>
90 #include <Dt/IconFile.h>
92 #include <X11/ShellP.h>
93 #include <X11/Shell.h>
94 #include <X11/Xatom.h>
97 #include <Dt/DtNlUtils.h>
100 #include "SharedProcs.h"
109 char **DtDtsDataTypeNames(void);
111 static char * FILE_FILTER = "FileFilter";
114 static DialogResource resources[] =
116 { "matchFilter", XmRBoolean, sizeof(Boolean),
117 XtOffset(FilterDataPtr, match_flag),
118 (XtPointer) True, _DtBooleanToString },
120 { "name", XmRString, sizeof(String),
121 XtOffset(FilterDataPtr, filter),
122 (XtPointer) "", _DtStringToString },
124 { "showHidden", XmRBoolean, sizeof(Boolean),
125 XtOffset(FilterDataPtr, show_hidden),
126 (XtPointer) False, _DtBooleanToString },
128 { "filetypesFilteredCount", XmRInt, sizeof(int),
129 XtOffset(FilterDataPtr, filetypesFilteredCount),
130 (XtPointer) 3, _DtIntToString },
132 { "filetypesFiltered", XmRString, sizeof(String),
133 XtOffset(FilterDataPtr, filetypesFiltered),
134 (XtPointer) DEFAULT_FILTER, _DtStringToString },
138 #define FM_TYPE_LABEL "TYPE_LABEL"
141 /******** Static Function Declarations ********/
146 Widget *return_widget,
148 static void InstallChange(
149 FilterRec *filter_rec,
150 XtCallbackProc callback,
151 XtPointer client_data) ;
152 static void InstallClose(
153 FilterRec *filter_rec,
154 XtCallbackProc callback,
155 XtPointer client_data) ;
157 FilterRec *filter_rec) ;
158 static XtPointer GetValues(
159 FilterRec *filter_rec) ;
160 static XtPointer GetDefaultValues( void ) ;
161 static XtPointer GetResourceValues(
162 XrmDatabase data_base,
164 static void SetValues(
165 FilterRec *filter_rec,
166 FilterData *filter_data) ;
167 static void WriteResourceValues(
171 static void FreeValues(
172 FilterData *filter_data) ;
173 static void DefaultCallback(
175 XtPointer client_data,
176 XtPointer call_data) ;
177 static void CancelCallback(
179 XtPointer client_data,
180 XtPointer call_data) ;
181 static void OkCallback(
183 XtPointer client_data,
184 XtPointer call_data) ;
185 static void ApplyCallback(
187 XtPointer client_data,
188 XtPointer call_data) ;
189 static Boolean GetFilterValues(
190 FilterRec *filter_rec,
191 FilterData *filter_data) ;
192 static void filterTypeChanged(
194 XtPointer client_data,
195 XtPointer call_data ) ;
196 static int FileTypeAscending(
199 static void SelectAllFilter(
203 Cardinal *num_params );
204 static void DeselectAllFilter(
208 Cardinal *num_params );
209 /******** End Static Function Declarations ********/
214 static DialogClass filterClassRec =
219 (DialogInstallChangeProc) InstallChange,
220 (DialogInstallCloseProc) InstallClose,
221 (DialogDestroyProc) Destroy,
222 (DialogGetValuesProc) GetValues,
225 (DialogSetValuesProc) SetValues,
227 (DialogFreeValuesProc) FreeValues,
228 (DialogMapWindowProc) _DtGenericMapWindow,
232 DialogClass * filterClass = (DialogClass *) &filterClassRec;
234 static XtActionsRec FilterAction[] = {
235 { "SelectAllFilter", SelectAllFilter },
236 { "DeselectAllFilter", DeselectAllFilter }
239 static char FilterTranslationString[] = "\
240 Ctrl<Key>slash:SelectAllFilter(@)\n\
241 Ctrl<Key>backslash:DeselectAllFilter(@)";
243 /************************************************************************
247 ************************************************************************/
253 Widget *return_widget,
256 FilterRec * filter_rec;
257 Widget shell, form, fileNameFilter;
258 Widget tog_frame, tog_form, fileTypeScrollWin, file_window;
259 Widget labelPt2, hidden, separator, sel_form;
260 Widget ok, apply, reset, close, help;
261 Widget selectAll, unselectAll;
262 Widget hiddenPulldown;
263 XmString label_string;
264 XtTranslations filterTranslationTable;
269 char * tmpStr, * resolvedFilterTranslationString;
271 /* Allocate the file filter dialog instance record. */
272 filter_rec = (FilterRec *) XtMalloc (sizeof (FilterRec));
274 /* Create the shell and form used for the dialog. */
276 XtSetArg (args[n], XmNmwmFunctions, MWM_FUNC_MOVE |
277 MWM_FUNC_CLOSE); ++n;
278 XtSetArg (args[n], XmNmwmDecorations, MWM_DECOR_BORDER |
279 MWM_DECOR_TITLE); ++n;
280 XtSetArg (args[n], XmNallowShellResize, True); ++n;
281 shell = XmCreateDialogShell (parent, "filter_files", args, n);
283 /* Set the useAsyncGeo on the shell */
284 XtSetArg (args[0], XmNuseAsyncGeometry, True);
285 XtSetValues (XtParent(shell), args, 1);
288 XtSetArg (args[n], XmNmarginWidth, 1); n++;
289 XtSetArg (args[n], XmNmarginHeight, 1); n++;
290 XtSetArg (args[n], XmNshadowThickness, 1); n++;
291 XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
292 XtSetArg (args[n], XmNautoUnmanage, False); n++;
293 form = XmCreateForm (shell, "form", args, n);
294 XtAddCallback(form, XmNhelpCallback, HelpRequestCB,
295 HELP_FILTER_DIALOG_STR);
297 XtAppAddActions( XtWidgetToApplicationContext(form),
299 XtNumber(FilterAction));
300 resolvedFilterTranslationString = ResolveTranslationString(
301 FilterTranslationString,
302 (char *)filter_rec );
303 filterTranslationTable = XtParseTranslationTable(
304 resolvedFilterTranslationString );
305 XtFree( resolvedFilterTranslationString );
306 resolvedFilterTranslationString = NULL;
307 XtOverrideTranslations(form, filterTranslationTable);
309 hiddenPulldown = XmCreatePulldownMenu(form, "hiddenPD", args, 0);
311 label_string = XmStringCreateLocalized ((GETMESSAGE(13,27, "Shown")));
312 XtSetArg(args[0], XmNmarginHeight, 1);
313 XtSetArg(args[1], XmNmarginWidth, 1);
314 XtSetArg(args[2], XmNlabelString, label_string);
315 XtSetArg(args[3], XmNuserData, SHOWN);
316 filter_rec->hidArray[SHOWN] =
317 XmCreatePushButtonGadget(hiddenPulldown, "shown", args, 4);
318 XmStringFree(label_string);
319 XtAddCallback(filter_rec->hidArray[SHOWN], XmNactivateCallback,
320 filterTypeChanged, (XtPointer) filter_rec);
322 label_string = XmStringCreateLocalized ((GETMESSAGE(13,28, "Hidden")));
323 XtSetArg(args[2], XmNlabelString, label_string);
324 XtSetArg(args[3], XmNuserData, HIDDEN);
325 filter_rec->hidArray[HIDDEN] =
326 XmCreatePushButtonGadget(hiddenPulldown, "hidden", args, 4);
327 XmStringFree(label_string);
328 XtAddCallback(filter_rec->hidArray[HIDDEN], XmNactivateCallback,
329 filterTypeChanged, (XtPointer) filter_rec);
330 XtManageChildren(filter_rec->hidArray, 2);
332 /* create the Option Menu and attach it to the Pulldown MenuPane */
333 label_string = XmStringCreateLocalized ((GETMESSAGE(13,31,
334 "Select Datatypes to be:")));
336 XtSetArg (args[n], XmNlabelString, label_string); n++;
337 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
338 XtSetArg (args[n], XmNleftOffset, 5); n++;
339 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
340 XtSetArg (args[n], XmNtopOffset, 10); n++;
341 XtSetArg (args[n], XmNsubMenuId, hiddenPulldown); n++;
342 XtSetArg (args[n], XmNmenuHistory, filter_rec->hidArray[HIDDEN]); n++;
343 hidden = XmCreateOptionMenu(form, "file_name_label", args, n);
344 XtManageChild (hidden);
345 XmStringFree (label_string);
346 XtAddCallback(hidden, XmNhelpCallback, HelpRequestCB,
347 HELP_FILTER_DIALOG_STR);
349 /* Create the Scrolled Window For the filetype display area */
350 /* and set the scrollbars colors correctly */
352 XtSetArg (args[n], XmNspacing, 2); n++;
353 XtSetArg (args[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
354 XtSetArg (args[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++;
355 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
356 XtSetArg (args[n], XmNleftOffset, 10); n++;
357 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
358 XtSetArg (args[n], XmNrightOffset, 10); n++;
359 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
360 XtSetArg (args[n], XmNtopWidget, hidden); n++;
361 XtSetArg (args[n], XmNtopOffset, 5); n++;
362 fileTypeScrollWin = XmCreateScrolledWindow(form, "filetypeSWin", args, n);
363 XtManageChild (fileTypeScrollWin);
364 XtAddCallback(fileTypeScrollWin, XmNhelpCallback, HelpRequestCB,
365 HELP_FILTER_DIALOG_STR);
367 /* Create a drawing area as a child of the scrolled window */
370 XtSetArg (args[n], XmNmarginWidth, 4); n++;
371 XtSetArg (args[n], XmNmarginHeight, 4); n++;
372 XtSetArg (args[n], XmNresizePolicy, XmRESIZE_ANY); n++;
373 file_window = XmCreateDrawingArea (fileTypeScrollWin, "file_window",
375 XtManageChild (file_window);
378 XtSetArg (args[n], XmNmarginWidth, 1); n++;
379 XtSetArg (args[n], XmNmarginHeight, 1); n++;
380 XtSetArg (args[n], XmNshadowThickness, 0); n++;
381 XtSetArg (args[n], XmNautoUnmanage, False); n++;
382 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
383 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
384 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
385 XtSetArg (args[n], XmNtopWidget, fileTypeScrollWin); n++;
386 XtSetArg (args[n], XmNtopOffset, 10); n++;
387 sel_form = XmCreateForm (form, "sel_form", args, n);
388 XtManageChild(sel_form);
390 label_string = XmStringCreateLocalized ((GETMESSAGE(13,21, "Select All")));
392 XtSetArg (args[n], XmNlabelString, label_string); n++;
393 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
394 XtSetArg (args[n], XmNleftPosition, 15); n++;
395 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
396 XtSetArg (args[n], XmNtopOffset, 5); n++;
397 XtSetArg (args[n], XmNmarginHeight, 4); n++;
398 XtSetArg (args[n], XmNmarginWidth, 10); n++;
399 selectAll = XmCreatePushButtonGadget (sel_form, "selectAll", args, n);
400 XtManageChild (selectAll);
401 XtAddCallback (selectAll, XmNactivateCallback, SelectAllFileTypes,
402 (XtPointer) filter_rec);
403 XtAddCallback(selectAll, XmNhelpCallback, HelpRequestCB,
404 HELP_FILTER_DIALOG_STR);
405 XmStringFree (label_string);
406 XtSetArg (args[0], XmNdefaultButton, selectAll);
407 XtSetValues (sel_form, args, 1);
409 label_string = XmStringCreateLocalized ((GETMESSAGE(13,22, "Deselect All")));
411 XtSetArg (args[n], XmNlabelString, label_string); n++;
412 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
413 XtSetArg (args[n], XmNleftPosition, 55); n++;
414 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
415 XtSetArg (args[n], XmNtopOffset, 5); n++;
416 XtSetArg (args[n], XmNmarginHeight, 4); n++;
417 XtSetArg (args[n], XmNmarginWidth, 10); n++;
418 unselectAll = XmCreatePushButtonGadget (sel_form, "deselectAll", args, n);
419 XtManageChild (unselectAll);
420 XtAddCallback (unselectAll, XmNactivateCallback, UnselectAllFileTypes,
421 (XtPointer) filter_rec);
422 XtAddCallback(unselectAll, XmNhelpCallback, HelpRequestCB,
423 HELP_FILTER_DIALOG_STR);
424 XmStringFree (label_string);
426 /* Create the file name filter label and text fields. */
427 label_string = XmStringCreateLocalized (((char *)GETMESSAGE(13,26,
428 "Also hide (Optional): ")));
430 XtSetArg (args[n], XmNlabelString, label_string); n++;
431 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
432 XtSetArg (args[n], XmNleftOffset, 5); n++;
433 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
434 XtSetArg (args[n], XmNtopWidget, sel_form); n++;
435 XtSetArg (args[n], XmNtopOffset, 18); n++;
436 XtSetArg (args[n], XmNtraversalOn, False); n++;
437 labelPt2 = XmCreateLabelGadget (form, "file_name_label", args, n);
438 XtManageChild (labelPt2);
439 XmStringFree (label_string);
440 XtAddCallback(labelPt2, XmNhelpCallback, HelpRequestCB,
441 HELP_FILTER_DIALOG_STR);
445 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
446 XtSetArg (args[n], XmNleftWidget, labelPt2); n++;
447 XtSetArg (args[n], XmNleftOffset, 0); n++;
448 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
449 XtSetArg (args[n], XmNtopWidget, sel_form); n++;
450 XtSetArg (args[n], XmNtopOffset, 10); n++;
451 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
452 XtSetArg (args[n], XmNrightOffset, 10); n++;
453 fileNameFilter = XmCreateTextField (form, "file_name_text", args, n);
454 XtManageChild (fileNameFilter);
455 XtAddCallback(fileNameFilter, XmNhelpCallback, HelpRequestCB,
456 HELP_FILTER_DIALOG_STR);
458 /* Create a separator between the buttons */
461 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
462 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
463 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
464 XtSetArg (args[n], XmNtopWidget, fileNameFilter); n++;
465 XtSetArg (args[n], XmNtopOffset, 10); n++;
466 separator = XmCreateSeparatorGadget (form, "separator", args, n);
467 XtManageChild (separator);
470 /* Create the ok, apply, reset, cancel and help buttons */
473 XtSetArg (args[n], XmNlabelString, okXmString); n++;
474 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
475 XtSetArg (args[n], XmNleftPosition, 1); n++;
476 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
477 XtSetArg (args[n], XmNrightPosition, 19); n++;
478 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
479 XtSetArg (args[n], XmNtopWidget, separator); n++;
480 XtSetArg (args[n], XmNtopOffset, 5); n++;
481 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
482 XtSetArg (args[n], XmNbottomOffset, 5); n++;
483 XtSetArg (args[n], XmNmarginWidth, 4); n++;
484 XtSetArg (args[n], XmNmarginHeight, 4); n++;
485 XtSetArg (args[n], XmNmultiClick, XmMULTICLICK_DISCARD); n++;
486 XtSetArg (args[n], XmNuserData, flag); n++;
487 ok = XmCreatePushButtonGadget (form, "ok", args, n);
489 XtAddCallback(ok, XmNhelpCallback, HelpRequestCB,
490 HELP_FILTER_DIALOG_STR);
493 XtSetArg (args[n], XmNlabelString, applyXmString); n++;
494 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
495 XtSetArg (args[n], XmNleftPosition, 21); n++;
496 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
497 XtSetArg (args[n], XmNrightPosition, 39); n++;
498 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
499 XtSetArg (args[n], XmNtopWidget, separator); n++;
500 XtSetArg (args[n], XmNtopOffset, 5); n++;
501 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
502 XtSetArg (args[n], XmNbottomOffset, 5); n++;
503 XtSetArg (args[n], XmNmarginWidth, 4); n++;
504 XtSetArg (args[n], XmNmarginHeight, 4); n++;
505 apply = XmCreatePushButtonGadget (form, "apply", args, n);
506 XtManageChild (apply);
507 XtAddCallback(apply, XmNhelpCallback, HelpRequestCB,
508 HELP_FILTER_DIALOG_STR);
510 XtSetArg (args[0], XmNdefaultButton, apply);
511 XtSetValues (form, args, 1);
513 label_string = XmStringCreateLocalized (((char *)GETMESSAGE(13, 11, "Defaults")));
515 XtSetArg (args[n], XmNlabelString, label_string); n++;
516 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
517 XtSetArg (args[n], XmNleftPosition, 41); n++;
518 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
519 XtSetArg (args[n], XmNrightPosition, 59); n++;
520 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
521 XtSetArg (args[n], XmNtopWidget, separator); n++;
522 XtSetArg (args[n], XmNtopOffset, 5); n++;
523 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
524 XtSetArg (args[n], XmNbottomOffset, 5); n++;
525 XtSetArg (args[n], XmNmarginWidth, 4); n++;
526 XtSetArg (args[n], XmNmarginHeight, 4); n++;
527 reset = XmCreatePushButtonGadget (form, "reset", args, n);
528 XtManageChild (reset);
529 XtAddCallback (reset, XmNactivateCallback, DefaultCallback, (XtPointer) filter_rec);
530 XtAddCallback(reset, XmNhelpCallback, HelpRequestCB,
531 HELP_FILTER_DIALOG_STR);
532 XmStringFree (label_string);
536 XtSetArg (args[n], XmNlabelString, cancelXmString); n++;
537 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
538 XtSetArg (args[n], XmNleftPosition, 61); n++;
539 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
540 XtSetArg (args[n], XmNrightPosition, 79); n++;
541 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
542 XtSetArg (args[n], XmNtopWidget, separator); n++;
543 XtSetArg (args[n], XmNtopOffset, 5); n++;
544 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
545 XtSetArg (args[n], XmNbottomOffset, 5); n++;
546 XtSetArg (args[n], XmNmarginWidth, 4); n++;
547 XtSetArg (args[n], XmNmarginHeight, 4); n++;
548 XtSetArg (args[n], XmNmultiClick, XmMULTICLICK_DISCARD); n++;
549 XtSetArg (args[n], XmNuserData, flag ); n++;
550 close = XmCreatePushButtonGadget (form, "close", args, n);
551 XtAddCallback (close, XmNactivateCallback, CancelCallback, (XtPointer) filter_rec);
552 XtManageChild (close);
553 XtAddCallback(close, XmNhelpCallback, HelpRequestCB,
554 HELP_FILTER_DIALOG_STR);
558 XtSetArg (args[n], XmNlabelString, helpXmString); n++;
559 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
560 XtSetArg (args[n], XmNleftPosition, 81); n++;
561 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
562 XtSetArg (args[n], XmNrightPosition, 99); n++;
563 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
564 XtSetArg (args[n], XmNtopWidget, separator); n++;
565 XtSetArg (args[n], XmNtopOffset, 5); n++;
566 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
567 XtSetArg (args[n], XmNbottomOffset, 5); n++;
568 XtSetArg (args[n], XmNmarginWidth, 4); n++;
569 XtSetArg (args[n], XmNmarginHeight, 4); n++;
570 help = XmCreatePushButtonGadget (form, "help", args, n);
571 XtManageChild (help);
572 XtAddCallback(help, XmNactivateCallback, HelpRequestCB,
573 HELP_FILTER_DIALOG_STR);
574 XtAddCallback(help, XmNhelpCallback, HelpRequestCB,
575 HELP_FILTER_DIALOG_STR);
578 XtSetArg (args[0], XmNcancelButton, close);
579 XtSetValues (form, args, 1);
581 /* Fill in our instance structure */
583 filter_rec->shell = shell;
584 filter_rec->form = form;
585 filter_rec->fileNameFilter = fileNameFilter;
586 filter_rec->hidden = hidden;
587 filter_rec->scrolled_window = fileTypeScrollWin;
588 filter_rec->file_window = file_window;
589 filter_rec->select_all = selectAll;
590 filter_rec->unselect_all = unselectAll;
591 filter_rec->label = labelPt2;
592 filter_rec->cancel = 0x0;
593 filter_rec->previous_filter_data = NULL;
596 filter_rec->apply = apply;
597 filter_rec->reset = reset;
598 filter_rec->close = close;
599 filter_rec->help = help;
601 /* Set the return values for the dialog widget and dialog instance. */
603 *return_widget = form;
604 *dialog = (XtPointer) filter_rec;
610 /************************************************************************
614 ************************************************************************/
618 FilterRec *filter_rec,
619 XtCallbackProc callback,
620 XtPointer client_data )
622 FilterApply * apply_data;
625 /* Setup the callback data to be sent to the Ok callback. */
626 /* This contains the encapsulation callback to invoke upon */
627 /* the data within the dialog being changed. */
629 apply_data = (FilterApply *) XtMalloc (sizeof (FilterApply));
630 apply_data->callback = callback;
631 apply_data->client_data = client_data;
632 apply_data->filter_rec = (XtPointer) filter_rec;
633 filter_rec->apply_data = apply_data;
636 XtAddCallback (filter_rec->apply, XmNactivateCallback,
637 ApplyCallback, (XtPointer) apply_data);
639 XtAddCallback (filter_rec->ok, XmNactivateCallback,
640 OkCallback, (XtPointer) apply_data);
646 /************************************************************************
650 ************************************************************************/
654 FilterRec *filter_rec,
655 XtCallbackProc callback,
656 XtPointer client_data )
658 Atom delete_window_atom;
660 XtAddCallback(filter_rec->close, XmNactivateCallback, callback, client_data);
662 delete_window_atom = XmInternAtom (XtDisplay(filter_rec->shell), "WM_DELETE_WINDOW", True);
663 XmRemoveWMProtocols( filter_rec->shell, &delete_window_atom, 1 );
664 XmAddWMProtocolCallback( filter_rec->shell, delete_window_atom, callback,
665 (XtPointer) client_data );
671 /************************************************************************
675 ************************************************************************/
679 FilterRec *filter_rec )
681 XtDestroyWidget (filter_rec->shell);
682 XtFree ((char *) filter_rec->apply_data);
683 XtFree ((char *) filter_rec);
689 /************************************************************************
693 ************************************************************************/
697 FilterRec *filter_rec )
699 FilterData * filter_data;
701 if( filter_rec->cancel
702 && filter_rec->previous_filter_data )
705 filter_data = filter_rec->previous_filter_data;
706 filter_rec->previous_filter_data = NULL;
712 /* Allocate and initialize the file filter dialog data. */
714 filter_data = (FilterData *) XtMalloc (sizeof (FilterData));
716 filter_data->displayed = True;
718 XtSetArg (args[0], XmNx, &filter_data->x);
719 XtSetArg (args[1], XmNy, &filter_data->y);
720 XtSetArg (args[2], XmNwidth, &filter_data->width);
721 XtSetArg (args[3], XmNheight, &filter_data->height);
722 XtGetValues (filter_rec->shell, args, 4);
724 (void) GetFilterValues (filter_rec, filter_data);
727 filter_rec->cancel = 0x0;
729 return ((XtPointer) filter_data);
735 /************************************************************************
739 ************************************************************************/
742 GetDefaultValues( void )
744 FilterData * filter_data;
746 /* Allocate and initialize the default file filter dialog data. */
748 filter_data = (FilterData *) XtMalloc (sizeof (FilterData));
750 filter_data->displayed = False;
753 filter_data->height = 0;
754 filter_data->width = 0;
755 filter_data->match_flag = True;
756 filter_data->filter = XtNewString(".*");
757 filter_data->show_hidden = False;
758 filter_data->filetypesFilteredCount = 3;
759 filter_data->filetypesFiltered = XtNewString(DEFAULT_FILTER);
760 filter_data->user_data = NULL;
761 filter_data->count = ReadInFiletypes(filter_data);
763 return ((XtPointer) filter_data);
769 /************************************************************************
773 ************************************************************************/
777 XrmDatabase data_base,
780 FilterData * filter_data;
781 static Boolean convertersAdded = False;
784 /* Allocate and get the resources for file filter dialog data. */
786 filter_data = (FilterData *) XtMalloc (sizeof (FilterData));
787 filter_data->user_data = NULL;
789 _DtDialogGetResources (data_base, name_list, FILE_FILTER, (char *)filter_data,
790 resources, filterClass->resource_count);
793 /* Create new strings for any string value we read in from our
797 filter_data->filter = XtNewString(filter_data->filter);
798 filter_data->filetypesFiltered = XtNewString(filter_data->filetypesFiltered);
800 filter_data->count = ReadInFiletypes(filter_data);
802 return ((XtPointer) filter_data);
808 FilterData *filter_data )
810 FilterData * CopiedFilterData;
813 CopiedFilterData = (FilterData *) XtMalloc (sizeof (FilterData));
814 CopiedFilterData->displayed = filter_data->displayed;
815 CopiedFilterData->show_hidden = filter_data->show_hidden;
816 CopiedFilterData->match_flag = filter_data->match_flag;
817 CopiedFilterData->filter = XtNewString( filter_data->filter );
818 CopiedFilterData->filetypesFilteredCount = filter_data->filetypesFilteredCount;
819 CopiedFilterData->filetypesFiltered = XtNewString( filter_data->filetypesFiltered );
820 CopiedFilterData->count = filter_data->count;
821 CopiedFilterData->user_data = (FTData **) XtMalloc(sizeof(FTData *) *
823 for( i = 0; i < filter_data->count; ++i )
825 CopiedFilterData->user_data[i] = (FTData *)XtMalloc(sizeof(FTData));
826 CopiedFilterData->user_data[i]->filetype =
827 XtNewString( filter_data->user_data[i]->filetype );
828 CopiedFilterData->user_data[i]->index =
829 filter_data->user_data[i]->index;
830 CopiedFilterData->user_data[i]->selected =
831 filter_data->user_data[i]->selected;
833 return CopiedFilterData;
836 /************************************************************************
840 ************************************************************************/
844 FilterRec *filter_rec,
845 FilterData *filter_data )
849 XmManagerWidget mgr = (XmManagerWidget)filter_rec->file_window;
850 int num_children = mgr->composite.num_children;
851 Pixel background_color;
852 Pixel foreground_color;
853 Pixel pixmap_background;
854 Pixel pixmap_foreground;
860 XtWidgetGeometry desired, preferred;
862 PixmapData *pixmapData;
864 filter_rec->cancel = 0x0;
865 if( filter_rec->previous_filter_data )
866 FreeValues( filter_rec->previous_filter_data );
867 filter_rec->previous_filter_data = CopyFilterData( filter_data );
869 XmTextFieldSetString (filter_rec->fileNameFilter, filter_data->filter);
871 if(XmToggleButtonGadgetGetState (*showHiddenMenu))
872 filter_data->show_hidden = True;
874 filter_data->show_hidden = False;
876 if(filter_data->match_flag)
877 XtSetArg (args[0], XmNmenuHistory, filter_rec->hidArray[HIDDEN]);
879 XtSetArg (args[0], XmNmenuHistory, filter_rec->hidArray[SHOWN]);
880 XtSetValues(filter_rec->hidden, args, 1);
882 XtSetArg (args[0], XmNbackground, &background_color);
883 XtSetArg (args[1], XmNforeground, &foreground_color);
884 XtSetArg (args[2], XmNtopShadowColor, &pixmap_background);
885 XtSetArg (args[3], XmNbottomShadowColor, &pixmap_foreground);
886 XtGetValues((Widget)mgr, args, 4);
888 for (i = 0, x = 5, count = 0; i < filter_data->count; i++)
892 user_data = filter_data->user_data[i];
894 if (ptr = (char *)DtDtsDataTypeToAttributeValue(user_data->filetype,
898 icon_label = XmStringCreateLocalized(ptr);
899 DtDtsFreeAttributeValue(ptr);
903 icon_label = XmStringCreateLocalized(user_data->filetype);
906 pixmapData = _DtRetrievePixmapData(user_data->filetype,
909 filter_rec->file_window,
913 XtSetArg (args[n], XmNstring, icon_label); n++;
915 XtSetArg (args[n], XmNimageName, pixmapData->iconFileName);
917 XtSetArg (args[n], XmNimageName, NULL); n++;
918 XtSetArg (args[n], XmNunderline, False); n++;
920 XtSetArg (args[n], XmNpixmapPosition, XmPIXMAP_TOP); n++;
921 XtSetArg (args[n], XmNbehavior, XmICON_BUTTON); n++;
922 XtSetArg (args[n], XmNfillMode, XmFILL_PARENT); n++;
924 XtSetArg (args[n], XmNforeground, foreground_color); n++;
925 XtSetArg (args[n], XmNarmColor, white_pixel); n++;
926 if (background_color == white_pixel)
928 XtSetArg (args[n], XmNbackground, white_pixel); n++;
929 XtSetArg (args[n], XmNpixmapBackground, white_pixel); n++;
930 XtSetArg (args[n], XmNpixmapForeground, black_pixel); n++;
932 else if (background_color == black_pixel)
934 XtSetArg (args[n], XmNbackground, black_pixel); n++;
935 XtSetArg (args[n], XmNpixmapBackground, white_pixel); n++;
936 XtSetArg (args[n], XmNpixmapForeground, black_pixel); n++;
940 XtSetArg (args[n], XmNbackground, background_color); n++;
941 XtSetArg (args[n], XmNpixmapBackground, pixmap_background); n++;
942 XtSetArg (args[n], XmNpixmapForeground, pixmap_foreground); n++;
945 if (i - count < num_children)
947 icon_widget = mgr->composite.children[i - count];
948 XtSetArg (args[n], XmNx, x); n++;
949 XtSetArg (args[n], XmNy, 5); n++;
950 XtSetArg (args[n], XmNuserData, user_data); n++;
951 XtSetValues(icon_widget, args, n);
952 XtRemoveAllCallbacks (icon_widget, XmNcallback);
957 XtSetArg (args[n], XmNx, x); n++;
958 XtSetArg (args[n], XmNy, 5); n++;
959 XtSetArg (args[n], XmNshadowThickness, 2); n++;
960 XtSetArg (args[n], XmNfontList, user_font); n++;
961 if(keybdFocusPolicy == XmEXPLICIT)
963 XtSetArg (args[n], XmNtraversalOn, True); n++;
967 XtSetArg (args[n], XmNtraversalOn, False); n++;
968 XtSetArg (args[n], XmNhighlightThickness, 0); n++;
970 XtSetArg (args[n], XmNborderType, DtNON_RECTANGLE); n++;
971 if (mgr->composite.num_children == 0)
973 XtSetArg (args[n], XmNuserData, user_data); n++;
974 icon_widget= _DtCreateIcon ((Widget)mgr, "icon", args, n);
978 icon_widget = _DtDuplicateIcon((Widget)mgr,
979 mgr->composite.children[0],
980 (XmString)args[0].value, (String)args[1].value,
981 (XtPointer)user_data, (Boolean)args[2].value);
983 XtSetArg (args[n], XmNx, x); n++;
984 XtSetArg (args[n], XmNy, 5); n++;
985 XtSetValues(icon_widget, args, n);
987 XtAddCallback(icon_widget, XmNhelpCallback,
988 (XtCallbackProc)HelpRequestCB, NULL);
990 XtAddCallback (icon_widget, XmNcallback, NewFileTypeSelected,
991 (XtPointer)filter_rec);
993 _DtCheckAndFreePixmapData(user_data->filetype,
994 filter_rec->file_window,
995 (DtIconGadget) icon_widget,
998 XtManageChild(icon_widget);
999 x += 5 + icon_widget->core.width;
1000 if (icon_widget->core.height > max)
1001 max = icon_widget->core.height;
1003 XmStringFree(icon_label);
1006 for (i = 0, count = 0; i < filter_data->count; i++)
1009 user_data = filter_data->user_data[i];
1011 icon_widget = mgr->composite.children[i - count];
1013 if(filter_data->user_data[i]->selected == True)
1016 /* Draw the selected icon as selected */
1017 if (background_color == white_pixel)
1019 XtSetArg (args[n], XmNbackground, black_pixel); n++;
1020 XtSetArg (args[n], XmNforeground, white_pixel); n++;
1024 XtSetArg (args[n], XmNbackground, white_pixel); n++;
1025 XtSetArg (args[n], XmNforeground, black_pixel); n++;
1028 XtSetArg (args[n], XmNpixmapBackground, white_pixel); n++;
1029 XtSetArg (args[n], XmNpixmapForeground, black_pixel); n++;
1030 XtSetArg (args[n], XmNarmColor, white_pixel); n++;
1031 XtSetValues(icon_widget, args, n);
1036 /* Unmanage any icons left over */
1037 while (i < num_children)
1039 XtUnmanageChild(mgr->composite.children[i]);
1043 /* Line up the titles in all of the icons */
1044 num_children = mgr->composite.num_children;
1045 for (i = 0; i < num_children; i++)
1047 if (XtIsManaged(mgr->composite.children[i]))
1049 if (mgr->composite.children[i]->core.height != max)
1052 XtSetArg(args[n], XmNy,
1053 5 + (max - mgr->composite.children[i]->core.height)); n++;
1054 XtSetValues(mgr->composite.children[i], args, n);
1059 /* Set the height of the scrolled window */
1060 desired.x = filter_rec->scrolled_window->core.x;
1061 desired.y = filter_rec->scrolled_window->core.y;
1062 desired.width = filter_rec->scrolled_window->core.width;
1063 desired.request_mode = (CWWidth);
1064 XtQueryGeometry(filter_rec->scrolled_window, &desired, &preferred);
1066 if (preferred.request_mode & CWWidth)
1068 XtSetArg(args[n], XmNwidth, (XtArgVal) preferred.width);
1071 if (preferred.request_mode & CWHeight)
1073 XtSetArg(args[n], XmNheight, (XtArgVal) preferred.height);
1076 XtSetValues(filter_rec->scrolled_window, args, n);
1083 /************************************************************************
1085 * WriteResourceValues
1087 ************************************************************************/
1090 WriteResourceValues(
1095 FilterData * filter_data = (FilterData *) values->data;
1096 FilterRec * filter_rec;
1100 /* If the dialog is currently displayed, update the geometry */
1101 /* fields to their current values. */
1103 if (filter_data->displayed == True)
1105 _DtGenericUpdateWindowPosition(values);
1106 filter_rec = (FilterRec *) _DtGetDialogInstance (values);
1109 _DtDialogPutResources (fd, name_list, FILE_FILTER, values->data,
1110 resources, filterClass->resource_count);
1116 /************************************************************************
1120 ************************************************************************/
1124 FilterData *filter_data )
1128 for( i = 0; i < filter_data->count; i++)
1130 if(filter_data->user_data[i]->filetype)
1131 XtFree ((char *)filter_data->user_data[i]->filetype);
1132 XtFree ((char *)filter_data->user_data[i]);
1134 XtFree ((char *)filter_data->user_data);
1135 XtFree ((char *) filter_data->filter);
1136 XtFree ((char *) filter_data->filetypesFiltered);
1137 XtFree ((char *) filter_data);
1142 /************************************************************************
1146 ************************************************************************/
1151 XtPointer client_data,
1152 XtPointer call_data )
1154 FilterRec * filter_rec = (FilterRec *) client_data;
1155 DialogData * dialog_data;
1156 FilterData * filter_data;
1161 /* Get the instance and data for the dialog */
1163 dialog_data = _DtGetInstanceData ((XtPointer)filter_rec);
1164 filter_data = (FilterData *) dialog_data->data;
1166 filter_data->show_hidden = False;
1168 XtSetArg (args[0], XmNmenuHistory, filter_rec->hidArray[HIDDEN]);
1169 XtSetValues(filter_rec->hidden, args, 1);
1170 filter_data->match_flag = True;
1172 XmToggleButtonGadgetSetState(*showHiddenMenu, False, False);
1174 XtFree( filter_data->filter );
1175 filter_data->filter = XtNewString(".*");
1177 filter_data->filetypesFilteredCount = 3;
1178 XtFree( filter_data->filetypesFiltered );
1179 filter_data->filetypesFiltered = XtNewString( DEFAULT_FILTER );
1181 filter_data->count = ReadInFiletypes(filter_data);
1183 /* Display the new type */
1184 SetValues (filter_rec, filter_data);
1187 /************************************************************************
1191 ************************************************************************/
1196 XtPointer client_data,
1197 XtPointer call_data )
1199 FilterRec * filter_rec = (FilterRec *) client_data;
1201 filter_rec->cancel = 0x1;
1204 /************************************************************************
1207 * This is a callback function called when the (Ok) button
1208 * is pressed. It saves the new file filter data internally and
1209 * then calls the encapsulations callback function. It then closes
1212 ************************************************************************/
1217 XtPointer client_data,
1218 XtPointer call_data )
1220 FilterRec * filter_rec = (FilterRec *) ((FilterApply *)client_data)->filter_rec;
1221 DialogData * dialog_data;
1222 Widget close = filter_rec->close;
1224 if(RecheckFlag(NULL,w))
1226 else if(RecheckFlag(NULL,close))
1229 ApplyCallback(w, client_data, call_data);
1230 dialog_data = _DtGetInstanceData ((XtPointer)filter_rec);
1231 ResetFlag(NULL,close);
1232 XtCallCallbacks(filter_rec->close, XmNactivateCallback,
1233 (XtPointer)dialog_data);
1237 /************************************************************************
1240 * This is a callback function called when the (Apply) button
1241 * is pressed. It saves the new file filter data internally and
1242 * then calls the encapsulations callback function.
1244 ************************************************************************/
1249 XtPointer client_data,
1250 XtPointer call_data )
1252 FilterRec * filter_rec;
1253 DialogData * dialog_data;
1254 FilterData * filter_data;
1255 FilterData * new_filter_data;
1256 XmManagerWidget mgr;
1262 filter_rec = (FilterRec *) ((FilterApply *) client_data)->filter_rec;
1263 dialog_data = _DtGetInstanceData ((XtPointer)filter_rec);
1264 filter_data = (FilterData *) dialog_data->data;
1265 new_filter_data = (FilterData *) XtMalloc (sizeof (FilterData));
1266 mgr = (XmManagerWidget)filter_rec->file_window;
1267 num_children = mgr->composite.num_children;
1269 GetFilterValues (filter_rec, new_filter_data);
1270 FreeValues (filter_data);
1271 dialog_data->data = (XtPointer) new_filter_data;
1273 if( filter_rec->previous_filter_data )
1274 FreeValues( filter_rec->previous_filter_data );
1275 filter_rec->previous_filter_data = CopyFilterData( new_filter_data );
1277 /* Need to update 'userData' for each of the icons */
1278 for (i = 0, count = 0; i < num_children &&
1279 i + count < new_filter_data->count; i++)
1281 XtSetArg (args[0], XmNuserData, new_filter_data->user_data[i + count]);
1282 XtSetValues(mgr->composite.children[i], args, 1);
1284 (*(((FilterApply *)client_data)->callback)) (w, ((FilterApply *)client_data)->client_data, NULL);
1289 /************************************************************************
1292 * Update the current file filter values within the data structure
1293 * from the current toggle button values.
1295 ************************************************************************/
1299 FilterRec *filter_rec,
1300 FilterData *filter_data )
1305 DialogData * dialog_data;
1306 FilterData * old_filter_data;
1308 filter_data->displayed = True;
1310 filter_data->filter = XmTextFieldGetString (filter_rec->fileNameFilter);
1312 XmToggleButtonGadgetSetState(*showHiddenMenu, False, False);
1313 filter_data->show_hidden = False;
1315 XtSetArg (args[0], XmNmenuHistory, &menuHistory);
1316 XtGetValues (filter_rec->hidden, args, 1);
1318 if(menuHistory == filter_rec->hidArray[HIDDEN])
1319 filter_data->match_flag = True;
1321 filter_data->match_flag = False;
1323 filter_data->filetypesFiltered = NULL;
1324 filter_data->filetypesFilteredCount = 0;
1325 dialog_data = _DtGetInstanceData ((XtPointer)filter_rec);
1326 if(dialog_data != NULL)
1328 old_filter_data = (FilterData *) dialog_data->data;
1329 filter_data->count = old_filter_data->count;
1330 filter_data->user_data = (FTData **) XtMalloc(sizeof(FTData *) *
1331 filter_data->count);
1333 for( i = 0; i < filter_data->count; i++)
1335 /* Copy current value from the old dialog values */
1336 filter_data->user_data[i] = (FTData *)XtMalloc(sizeof(FTData));
1337 filter_data->user_data[i]->filetype =
1338 XtNewString(old_filter_data->user_data[i]->filetype);
1339 filter_data->user_data[i]->index =
1340 old_filter_data->user_data[i]->index;
1341 filter_data->user_data[i]->selected =
1342 old_filter_data->user_data[i]->selected;
1344 if((filter_data->user_data[i]->selected == True &&
1345 filter_data->match_flag) ||
1346 (filter_data->user_data[i]->selected == False &&
1347 !filter_data->match_flag))
1349 if(filter_data->filetypesFiltered == NULL)
1351 filter_data->filetypesFiltered =
1352 XtNewString(filter_data->user_data[i]->filetype);
1356 filter_data->filetypesFiltered = (char *)XtRealloc(
1357 (char *)filter_data->filetypesFiltered,
1358 strlen(filter_data->filetypesFiltered) +
1359 strlen(filter_data->user_data[i]->filetype) + 2);
1361 strcat(filter_data->filetypesFiltered, ",");
1362 strcat(filter_data->filetypesFiltered,
1363 filter_data->user_data[i]->filetype);
1365 filter_data->filetypesFilteredCount++;
1378 XtPointer client_data,
1382 FilterData *filter_data;
1383 FileMgrData *file_mgr_data;
1384 FileMgrRec *file_mgr_rec;
1385 FilterRec *filter_rec;
1386 DialogData *dialog_data;
1390 if ((int)client_data == FM_POPUP)
1393 mbar = (Widget)XmGetPostedFromWidget(XtParent(w));
1394 XmUpdateDisplay (w);
1396 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
1397 XtGetValues(mbar, args, 1);
1399 dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
1400 file_mgr_data = (FileMgrData *) dialog_data->data;
1402 filter_data = (FilterData *)(file_mgr_data->filter_active->data);
1403 if (file_mgr_data->show_hid_enabled)
1405 filter_data->show_hidden = False;
1406 file_mgr_data->show_hid_enabled = False;
1410 filter_data->show_hidden = True;
1411 file_mgr_data->show_hid_enabled = True;
1414 filter_rec = (FilterRec *)_DtGetDialogInstance( file_mgr_data->filter_edit );
1416 /* Refilter the contents of the current directory */
1418 FileMgrRedisplayFiles (file_mgr_rec, file_mgr_data, False);
1425 FilterData *filter_data)
1432 char *filtered_types, *file_type;
1435 if (filter_data->user_data)
1437 for(i=0; i<filter_data->count; i++)
1439 XtFree(filter_data->user_data[i]->filetype);
1440 XtFree((char *)filter_data->user_data[i]);
1442 XtFree((char *)filter_data->user_data);
1443 filter_data->user_data = NULL;
1444 filter_data->count = 0;
1447 file_types = (char **) DtDtsDataTypeNames();
1449 while(file_types[i])
1451 /* filter out invisible types and actions */
1452 if((_DtCheckForDataTypeProperty(file_types[i], "invisible")) ||
1453 (DtDtsDataTypeIsAction(file_types[i])))
1459 if (count == count_size)
1463 filter_data->user_data =
1464 (FTData **) XtRealloc ((char *)filter_data->user_data,
1465 sizeof (FTData *) * count_size);
1468 user_data = (FTData *)XtMalloc(sizeof(FTData));
1469 user_data->index = count;
1470 user_data->selected = False;
1471 user_data->filetype = XtNewString(file_types[i]);
1473 filter_data->user_data[count] = user_data;
1478 DtDtsFreeDataTypeNames(file_types);
1480 qsort( filter_data->user_data, count, sizeof( FTData *), (int (*)())FileTypeAscending );
1482 filtered_types = filter_data->filetypesFiltered;
1483 for(i = 0; i < filter_data->filetypesFilteredCount; i++)
1485 file_type = filtered_types;
1486 filtered_types = DtStrchr(filtered_types, ',');
1488 if(filter_data->filetypesFilteredCount - 1 != i)
1489 *filtered_types = '\0';
1491 for(j = 0; j < count; j++)
1493 if(strcmp(file_type, filter_data->user_data[j]->filetype) == 0)
1495 filter_data->user_data[j]->selected = True;
1500 if(filter_data->filetypesFilteredCount - 1 != i)
1502 *filtered_types = ',';
1506 if(!filter_data->match_flag)
1508 for(j = 0; j < count; j++)
1510 if(filter_data->user_data[j]->selected == True)
1511 filter_data->user_data[j]->selected = False;
1513 filter_data->user_data[j]->selected = True;
1522 * Whenever the database files are reread, we must update the filter
1523 * values, since the indices of the filetypes may have changed.
1527 UpdateFilterAfterDBReread (
1528 DialogData * dialog_data )
1533 XmManagerWidget mgr;
1535 FilterData * new_filter_data;
1536 FilterData * filter_data;
1537 FilterRec * filter_rec;
1540 filter_data = (FilterData *) dialog_data->data;
1541 new_filter_data = (FilterData *) XtMalloc (sizeof (FilterData));
1543 if (filter_rec = (FilterRec *) _DtGetDialogInstance(dialog_data))
1545 /* Dialog is posted */
1546 result = GetFilterValues (filter_rec, new_filter_data);
1549 XtFree(new_filter_data->filetypesFiltered);
1550 new_filter_data->filetypesFiltered =
1551 XtNewString(filter_data->filetypesFiltered);
1552 new_filter_data->filetypesFilteredCount =
1553 filter_data->filetypesFilteredCount;
1554 FreeValues (filter_data);
1555 dialog_data->data = (XtPointer) new_filter_data;
1556 filter_data = new_filter_data;
1560 /* Reload the filetype information */
1561 filter_data->count = ReadInFiletypes(filter_data);
1563 if (filter_rec && result)
1565 /* Need to update 'userData' for each of the icons */
1566 mgr = (XmManagerWidget)filter_rec->file_window;
1567 num_children = mgr->composite.num_children;
1568 for (i = 0, count = 0; i < num_children &&
1569 i + count < filter_data->count; i++)
1571 XtSetArg (args[0], XmNuserData, new_filter_data->user_data[i]);
1572 XtSetValues(mgr->composite.children[i], args, 1);
1574 /* Display the new type */
1575 SetValues (filter_rec, filter_data);
1582 XtPointer client_data,
1583 XtPointer call_data )
1586 FilterRec * filter_rec = (FilterRec *) client_data;
1587 DialogData * dialog_data;
1588 FilterData * filter_data;
1590 XmString label_string;
1592 /* Get the instance and data for the dialog */
1593 dialog_data = _DtGetInstanceData ((XtPointer)filter_rec);
1594 filter_data = (FilterData *) dialog_data->data;
1596 XtSetArg (args[0], XmNmenuHistory, &menuHistory);
1597 XtGetValues (filter_rec->hidden, args, 1);
1599 if(menuHistory == filter_rec->hidArray[HIDDEN])
1601 filter_data->match_flag = True;
1602 label_string = XmStringCreateLocalized (((char *)GETMESSAGE(13,26,
1603 "Also hide (Optional): ")));
1607 filter_data->match_flag = False;
1608 label_string = XmStringCreateLocalized (((char *)GETMESSAGE(13,29,
1609 "Also show (Optional): ")));
1611 XtSetArg (args[0], XmNlabelString, label_string);
1612 XtSetValues( filter_rec->label, args, 1 );
1614 XmStringFree( label_string );
1615 XmUpdateDisplay( filter_rec->label );
1623 return strcmp( (*t1)->filetype, (*t2)->filetype );
1631 Cardinal *num_params )
1633 FilterRec * filterRec;
1635 sscanf( params[0], "%p", &filterRec );
1636 SelectAllFileTypes( w, (XtPointer)filterRec, NULL );
1645 Cardinal *num_params )
1647 FilterRec * filterRec;
1649 sscanf( params[0], "%p", &filterRec );
1650 UnselectAllFileTypes( w, (XtPointer)filterRec, NULL );