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: FilterP.c /main/4 1995/11/02 14:39:12 rswiston $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 * COMPONENT_NAME: Desktop File Manager (dtfile)
31 * Description: Processing functions for the file filter dialog
33 * FUNCTIONS: FilterChange
38 * UnselectAllFileTypes
40 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
41 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
42 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
43 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
45 ****************************************************************************
46 ************************************<+>*************************************/
50 #include <Xm/RowColumn.h>
54 #include <Dt/HourGlass.h>
57 #include "SharedProcs.h"
66 /******** Static Function Declarations ********/
68 static void FilterChange(
69 XtPointer client_data,
70 DialogData *old_dialog_data,
71 DialogData *new_dialog_data,
72 XtPointer call_data) ;
73 static void FilterClose(
74 XtPointer client_data,
75 DialogData *old_dialog_data,
76 DialogData *new_dialog_data) ;
78 /******** End Static Function Declarations ********/
82 /************************************************************************
85 * Callback functions invoked from the File Filter ... menu
86 * item. This function displays the file filter dialog.
88 ************************************************************************/
93 XtPointer client_data,
96 FileMgrRec * file_mgr_rec;
97 DialogData * dialog_data;
98 FileMgrData * file_mgr_data;
99 FilterRec * filter_rec;
102 char *tmpStr, *tempStr;
105 /* Set the menu item to insensitive to prevent multiple */
106 /* dialogs from being posted and get the area under the */
107 /* menu pane redrawn. */
111 mbar = XmGetPostedFromWidget(XtParent(w));
113 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
114 XtGetValues(mbar, args, 1);
116 /* Ignore accelerators when we're insensitive */
117 if ((file_mgr_rec->menuStates & FILTER) == 0)
119 XSetInputFocus(XtDisplay(w),
120 XtWindow(file_mgr_rec->filterBtn_child),
121 RevertToParent, CurrentTime);
127 /* Done only during a restore session */
128 file_mgr_rec = (FileMgrRec *)client_data;
132 /* Ignore accelerators received after we're unposted */
133 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
135 file_mgr_data = (FileMgrData *) dialog_data->data;
137 file_mgr_rec->menuStates &= ~FILTER;
139 _DtTurnOnHourGlass (file_mgr_rec->shell);
141 _DtShowDialog (file_mgr_rec->shell, NULL, (XtPointer)file_mgr_rec,
142 file_mgr_data->filter_edit, FilterChange,
143 (XtPointer)file_mgr_rec, FilterClose, (XtPointer)file_mgr_rec,
144 NULL, False, False, NULL, NULL);
146 filter_rec = (FilterRec *)_DtGetDialogInstance(file_mgr_data->filter_edit);
148 if(file_mgr_data->title != NULL &&
149 strcmp(file_mgr_data->helpVol, DTFILE_HELP_NAME) != 0)
151 tmpStr = (GETMESSAGE(13,19, "Set Filter Options"));
152 tempStr = (char *)XtMalloc(strlen(tmpStr) +
153 strlen(file_mgr_data->title) + 5);
154 sprintf(tempStr, "%s - %s", file_mgr_data->title, tmpStr);
158 tmpStr = (GETMESSAGE(13,24, "File Manager - Set Filter Options"));
159 tempStr = XtNewString(tmpStr);
161 XtSetArg (args[0], XmNtitle, tempStr);
162 XtSetValues (filter_rec->shell, args, 1);
165 file_mgr_rec->filterBtn_child=filter_rec->shell;
166 _DtTurnOffHourGlass (file_mgr_rec->shell);
171 if( XtIsRealized( filter_rec->shell ) )
173 /* In order for the set increment to work,
174 the top level shell has to be realized.
175 This seemed to be a good place for it.
177 XtSetArg( args[0], XmNhorizontalScrollBar, &hb );
178 XtGetValues( filter_rec->scrolled_window, args, 1 );
181 XtSetArg( args[0], XmNincrement, 40 );
182 XtSetValues( hb, args, 1 );
191 /************************************************************************
194 * Callback functions invoked from the file filter dialog's
195 * apply button being pressed. This function updates and redisplays
196 * the current set of objects being viewed.
198 ************************************************************************/
202 XtPointer client_data,
203 DialogData *old_dialog_data,
204 DialogData *new_dialog_data,
205 XtPointer call_data )
207 FileMgrRec * file_mgr_rec = (FileMgrRec *) client_data;
208 DialogData * dialog_data;
209 FileMgrData * file_mgr_data;
210 FilterData * filter_data;
214 dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
215 file_mgr_data = (FileMgrData *) dialog_data->data;
218 * Replace the active values with those just applied in the dialog,
219 * and then free up the old active values.
222 save_data = file_mgr_data->filter_active->data;
223 file_mgr_data->filter_active->data = new_dialog_data->data;
224 new_dialog_data->data = save_data;
225 _DtFreeDialogData (new_dialog_data);
227 filter_data = (FilterData *) file_mgr_data->filter_active->data;
228 filter_data->displayed = False;
231 /* Refilter the contents of the current directory */
233 FileMgrRedisplayFiles (file_mgr_rec, file_mgr_data, False);
239 /************************************************************************
242 * Callback function invoked from the file filter dialog's close
243 * button. This function resensitizes the menu item, and saves the
244 * interim dialog values.
246 ************************************************************************/
250 XtPointer client_data,
251 DialogData *old_dialog_data,
252 DialogData *new_dialog_data )
254 FileMgrRec * file_mgr_rec = (FileMgrRec *) client_data;
258 /* Free up the old interim values, and save the new ones */
260 save_data = old_dialog_data->data;
261 old_dialog_data->data = new_dialog_data->data;
262 new_dialog_data->data = save_data;
263 _DtFreeDialogData (new_dialog_data);
266 /* Resensitize the associated menubutton */
267 file_mgr_rec->menuStates |= FILTER;
271 NewFileTypeSelected (
273 XtPointer client_data,
276 XmAnyCallbackStruct * callback_data = (XmAnyCallbackStruct *) callback;
278 Pixel background_color;
279 Pixel foreground_color;
280 Pixel pixmap_background;
281 FilterRec *filter_rec;
285 filter_rec = (FilterRec *)client_data;
286 mgr = (XmManagerWidget)filter_rec->file_window;
288 if (callback_data->reason == XmCR_ACTIVATE)
290 XtSetArg (args[0], XmNbackground, &background_color);
291 XtSetArg (args[1], XmNforeground, &foreground_color);
292 XtSetArg (args[2], XmNtopShadowColor, &pixmap_background);
293 XtGetValues ((Widget)mgr, args, 3);
295 XtSetArg(args[0], XmNuserData, &user_data);
296 XtGetValues(w, args, 1);
298 if(user_data->selected)
300 /* Draw the old selected icon in normal state */
301 XtSetArg (args[0], XmNpixmapForeground, black_pixel);
302 XtSetArg (args[1], XmNforeground, foreground_color);
303 XtSetArg (args[2], XmNarmColor, white_pixel);
305 if (background_color == white_pixel)
307 XtSetArg (args[3], XmNbackground, white_pixel);
308 XtSetArg (args[4], XmNpixmapBackground, white_pixel);
310 else if (background_color == black_pixel)
312 XtSetArg (args[3], XmNbackground, black_pixel);
313 XtSetArg (args[4], XmNpixmapBackground, white_pixel);
317 XtSetArg (args[3], XmNbackground, background_color);
318 XtSetArg (args[4], XmNpixmapBackground, pixmap_background);
320 XtSetValues(w, args, 5);
321 user_data->selected = False;
327 /* Draw the selected icon as selected */
328 if (background_color == white_pixel)
330 XtSetArg(args[0], XmNbackground, black_pixel);
331 XtSetArg(args[1], XmNforeground, white_pixel);
333 else if (background_color == black_pixel)
335 XtSetArg(args[0], XmNbackground, white_pixel);
336 XtSetArg(args[1], XmNforeground, black_pixel);
340 XtSetArg(args[0], XmNbackground, white_pixel);
341 XtSetArg(args[1], XmNforeground, black_pixel);
344 XtSetArg(args[2], XmNpixmapBackground, white_pixel);
345 XtSetArg(args[3], XmNpixmapForeground, black_pixel);
346 XtSetArg(args[4], XmNarmColor, white_pixel);
347 XtSetValues(w, args, 5);
348 user_data->selected = True;
352 else if (callback_data->reason == XmCR_HIGHLIGHT)
353 DrawHighlight(w, NULL, NULL, NOT_DESKTOP);
354 else if (callback_data->reason == XmCR_UNHIGHLIGHT)
355 DrawUnhighlight(w, NOT_DESKTOP);
356 else if (callback_data->reason == XmCR_SHADOW)
357 DrawShadowTh(w, NULL, NOT_DESKTOP);
364 XtPointer client_data,
368 FilterRec *filter_rec;
369 Pixel background_color;
372 int num_of_filetypes, i;
374 filter_rec = (FilterRec *)client_data;
375 mgr = (XmManagerWidget)filter_rec->file_window;
376 num_of_filetypes = mgr->composite.num_children;
378 XtSetArg (args[0], XmNbackground, &background_color);
379 XtGetValues ((Widget)mgr, args, 1);
381 for(i = 0; i < num_of_filetypes; i++)
383 XtSetArg(args[0], XmNuserData, &user_data);
384 XtGetValues(mgr->composite.children[i], args, 1);
386 if(!user_data->selected)
388 /* Draw the selected icon as selected */
389 if (background_color == white_pixel)
391 XtSetArg(args[0], XmNbackground, black_pixel);
392 XtSetArg(args[1], XmNforeground, white_pixel);
394 else if (background_color == black_pixel)
396 XtSetArg(args[0], XmNbackground, white_pixel);
397 XtSetArg(args[1], XmNforeground, black_pixel);
401 XtSetArg(args[0], XmNbackground, white_pixel);
402 XtSetArg(args[1], XmNforeground, black_pixel);
405 XtSetArg(args[2], XmNpixmapBackground, white_pixel);
406 XtSetArg(args[3], XmNpixmapForeground, black_pixel);
407 XtSetArg(args[4], XmNarmColor, white_pixel);
408 XtSetValues(mgr->composite.children[i], args, 5);
410 user_data->selected = True;
417 UnselectAllFileTypes (
419 XtPointer client_data,
423 FilterRec *filter_rec;
424 Pixel background_color;
425 Pixel foreground_color;
426 Pixel pixmap_background;
429 int num_of_filetypes, i;
431 filter_rec = (FilterRec *)client_data;
432 mgr = (XmManagerWidget)filter_rec->file_window;
433 num_of_filetypes = mgr->composite.num_children;
435 XtSetArg (args[0], XmNbackground, &background_color);
436 XtSetArg (args[1], XmNforeground, &foreground_color);
437 XtSetArg (args[2], XmNtopShadowColor, &pixmap_background);
438 XtGetValues ((Widget)mgr, args, 3);
440 for(i = 0; i < num_of_filetypes; i++)
442 XtSetArg(args[0], XmNuserData, &user_data);
443 XtGetValues(mgr->composite.children[i], args, 1);
445 if(user_data->selected)
447 /* Draw the old selected icon in normal state */
448 XtSetArg (args[0], XmNpixmapForeground, black_pixel);
449 XtSetArg (args[1], XmNforeground, foreground_color);
450 XtSetArg (args[2], XmNarmColor, white_pixel);
452 if (background_color == white_pixel)
454 XtSetArg (args[3], XmNbackground, white_pixel);
455 XtSetArg (args[4], XmNpixmapBackground, white_pixel);
457 else if (background_color == black_pixel)
459 XtSetArg (args[3], XmNbackground, black_pixel);
460 XtSetArg (args[4], XmNpixmapBackground, white_pixel);
464 XtSetArg (args[3], XmNbackground, background_color);
465 XtSetArg (args[4], XmNpixmapBackground, pixmap_background);
467 XtSetValues(mgr->composite.children[i], args, 5);
469 user_data->selected = False;