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: Menu.c /main/4 1995/11/02 14:41:53 rswiston $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 * COMPONENT_NAME: Desktop File Manager (dtfile)
31 * Description: Contains the menu creation code for the file manager
32 * main window, and the simpler callback functions.
34 * FUNCTIONS: ActivateMultipleSelect
36 * ActivateSingleSelect
44 * RestoreMenuSensitivity
50 * UnmanageAllActionItems
53 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
54 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
55 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
56 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
58 ****************************************************************************
59 ************************************<+>*************************************/
67 #include <Xm/CascadeBG.h>
68 #include <Xm/PushBG.h>
69 #include <Xm/RowColumn.h>
70 #include <Xm/SeparatoG.h>
71 #include <Xm/ToggleBG.h>
72 #include <Xm/MessageB.h>
73 #include <Xm/MenuShellP.h>
75 #include <X11/ShellP.h>
78 #include <Dt/DtNlUtils.h>
79 #include <Dt/Action.h>
80 #include <Dt/ActionP.h>
81 #include <Dt/Connect.h>
82 #include <Dt/Indicator.h>
86 #include "SharedProcs.h"
87 #include "MultiView.h"
93 #include "SharedMsgs.h"
96 #define INDICATOR_TIME 12
98 #if defined(ADD_SHOW_TRASH)
99 static int menuItemCount = 52;
101 static int menuItemCount = 51;
103 static MenuDesc * mainMenu = NULL;
104 static Widget * actionsPaneId = NULL;
105 static char * homeDir = NULL;
107 /******** Static Function Declarations ********/
108 static void GetMainMenuData (
110 XtPointer * mainRecordPtr,
111 MenuDesc ** menuDescPtr,
112 int * menuItemCountPtr,
113 unsigned int ** globalMenuStatesPtr,
114 unsigned int ** viewMenuStatesPtr) ;
115 static void RereadDirectoryMenu(
117 XtPointer client_data,
118 XtPointer call_data) ;
119 static void ShowTrash(
121 XtPointer client_data,
122 XtPointer call_data) ;
125 XtPointer client_data,
126 XtPointer call_data) ;
127 static void SetMenuSensitivity(
129 XtPointer client_data,
130 XtPointer call_data) ;
131 static void RestoreMenuSensitivity(
133 XtPointer client_data,
134 XtPointer call_data) ;
135 static void TerminalCWD (
137 XtPointer client_data,
138 XtPointer call_data) ;
140 /******** End Static Function Declarations ********/
143 /************************************************************************
146 * Create the pull down menuing system for the program.
148 ************************************************************************/
153 FileMgrRec *file_mgr_rec )
155 static Boolean createSharedComponents = True;
156 static Widget * actionsId;
157 static Widget * directoryBarBtn;
162 if (createSharedComponents)
164 mainMenu = (MenuDesc *)XtCalloc(sizeof(MenuDesc) * menuItemCount, 1);
167 for (i = 0; i < menuItemCount; i++)
169 mainMenu[i].helpCallback = HelpRequestCB;
170 mainMenu[i].helpData = NULL;
171 mainMenu[i].activateCallback = NULL;
172 mainMenu[i].activateData = NULL;
173 mainMenu[i].maskBit = 0;
174 mainMenu[i].isHelpBtn = False;
175 mainMenu[i].label = NULL;
176 mainMenu[i].mnemonic = NULL;
180 /*************************************/
181 /* Create the 'File' menu components */
182 /*************************************/
184 mainMenu[j].type = MENU_PULLDOWN_BUTTON;
185 mainMenu[j].label = GETMESSAGE(20, 1, "File");
186 mainMenu[j].label = XtNewString(mainMenu[j].label);
187 mainMenu[j].mnemonic = GETMESSAGE(20, 2, "F");
188 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
189 mainMenu[j].name = "file";
190 mainMenu[j++].helpData = HELP_FILE_MENU_STR;
192 mainMenu[j].type = SHARED_MENU_PANE;
193 mainMenu[j].name = "fileMenu";
194 mainMenu[j++].helpData = HELP_FILE_MENU_STR;
196 create_directoryBtn = &(mainMenu[j].widget);
197 mainMenu[j].type = MENU_BUTTON;
198 mainMenu[j].maskBit = CREATE_DIR;
199 mainMenu[j].label = GETMESSAGE(20, 130, "New Folder...");
200 mainMenu[j].label = XtNewString(mainMenu[j].label);
201 mainMenu[j].mnemonic = GETMESSAGE(20, 131, "N");
202 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
203 mainMenu[j].helpData = HELP_FILE_MENU_STR;
204 mainMenu[j].name = "newFolder";
205 mainMenu[j++].activateCallback = ShowMakeFileDialog;
207 create_dataBtn = &(mainMenu[j].widget);
208 mainMenu[j].maskBit = CREATE_FILE;
209 mainMenu[j].type = MENU_BUTTON;
210 mainMenu[j].label = GETMESSAGE(20, 132, "New File...");
211 mainMenu[j].label = XtNewString(mainMenu[j].label);
212 mainMenu[j].mnemonic = GETMESSAGE(20, 133, "w");
213 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
214 mainMenu[j].helpData = HELP_FILE_MENU_STR;
215 mainMenu[j].name = "newFile";
216 mainMenu[j++].activateCallback = ShowMakeFileDialog;
218 mainMenu[j].type = MENU_SEPARATOR;
219 mainMenu[j].name = "separator";
220 mainMenu[j++].helpCallback = NULL;
222 homeBarBtn = &(mainMenu[j].widget);
223 mainMenu[j].type = MENU_BUTTON;
224 mainMenu[j].label = GETMESSAGE(20, 38, "Go Home");
225 mainMenu[j].label = XtNewString(mainMenu[j].label);
226 mainMenu[j].mnemonic = GETMESSAGE(20, 41, "H");
227 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
228 mainMenu[j].helpData = HELP_FILE_MENU_STR;
229 mainMenu[j].name = "goHome";
230 mainMenu[j++].activateCallback = ChangeToHome;
232 upBarBtn = &(mainMenu[j].widget);
233 mainMenu[j].type = MENU_BUTTON;
234 mainMenu[j].maskBit = MOVE_UP;
235 mainMenu[j].label = GETMESSAGE(20, 155, "Go Up");
236 mainMenu[j].label = XtNewString(mainMenu[j].label);
237 mainMenu[j].mnemonic = GETMESSAGE(20,94, "U");
238 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
239 mainMenu[j].helpData = HELP_FILE_MENU_STR;
240 mainMenu[j].name = "goUp";
241 mainMenu[j++].activateCallback = ChangeToParent;
243 change_directoryBtn = &(mainMenu[j].widget);
244 mainMenu[j].maskBit = CHANGEDIR;
245 mainMenu[j].type = MENU_BUTTON;
246 mainMenu[j].label = GETMESSAGE(20, 134, "Go To...");
247 mainMenu[j].label = XtNewString(mainMenu[j].label);
248 mainMenu[j].mnemonic = GETMESSAGE(20, 135, "G");
249 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
250 mainMenu[j].helpData = HELP_FILE_MENU_STR;
251 mainMenu[j].name = "changeTo";
252 mainMenu[j++].activateCallback = ShowChangeDirDialog;
254 findBtn = &(mainMenu[j].widget);
255 mainMenu[j].type = MENU_BUTTON;
256 mainMenu[j].maskBit = FIND;
257 mainMenu[j].label = GETMESSAGE(20, 18, "Find...");
258 mainMenu[j].label = XtNewString(mainMenu[j].label);
259 mainMenu[j].mnemonic = GETMESSAGE(20, 19, "F");
260 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
261 mainMenu[j].helpData = HELP_FILE_MENU_STR;
262 mainMenu[j].name = "find";
263 mainMenu[j++].activateCallback = ShowFindDialog;
265 mainMenu[j].type = MENU_SEPARATOR;
266 mainMenu[j].name = "separator";
267 mainMenu[j++].helpCallback = NULL;
269 #if defined(ADD_SHOW_TRASH)
270 mainMenu[j].type = MENU_BUTTON;
271 mainMenu[j].label = GETMESSAGE(20, 136, "Open Trash");
272 mainMenu[j].label = XtNewString(mainMenu[j].label);
273 mainMenu[j].mnemonic = GETMESSAGE(20, 112, "O");
274 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
275 mainMenu[j].helpData = HELP_FILE_MENU_STR;
276 mainMenu[j].name = "openTrash";
277 mainMenu[j++].activateCallback = ShowTrash;
281 terminalBtn = &(mainMenu[j].widget);
282 mainMenu[j].type = MENU_BUTTON;
283 mainMenu[j].label = GETMESSAGE(20,146, "Open Terminal");
284 mainMenu[j].label = XtNewString(mainMenu[j].label);
285 mainMenu[j].mnemonic = GETMESSAGE(20,147, "O");
286 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
287 mainMenu[j].helpData = HELP_FILE_MENU_STR;
288 mainMenu[j].name = "openTerminal";
289 mainMenu[j++].activateCallback = TerminalCWD;
294 mainMenu[j].type = MENU_SEPARATOR;
295 mainMenu[j].name = "separator";
296 mainMenu[j++].helpCallback = NULL;
298 mainMenu[j].type = MENU_BUTTON;
299 mainMenu[j].label = GETMESSAGE(20, 117, "Close");
300 mainMenu[j].label = XtNewString(mainMenu[j].label);
301 mainMenu[j].mnemonic = GETMESSAGE(20, 118, "C");
302 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
303 mainMenu[j].helpData = HELP_FILE_MENU_STR;
304 mainMenu[j].name = "close";
305 mainMenu[j++].activateCallback = Close;
307 /***************************************/
308 /* Create the 'Action' menu components */
309 /***************************************/
311 actionsId = &(mainMenu[j].widget);
312 mainMenu[j].type = MENU_PULLDOWN_BUTTON;
313 mainMenu[j].label = GETMESSAGE(20, 7, "Selected");
314 mainMenu[j].label = XtNewString(mainMenu[j].label);
315 mainMenu[j].mnemonic = GETMESSAGE(20, 8, "S");
316 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
317 mainMenu[j].name = "actions";
318 mainMenu[j++].helpData = HELP_SELECTED_MENU_STR;
320 actionsPaneId = &(mainMenu[j].widget);
321 mainMenu[j].type = SHARED_MENU_PANE;
322 mainMenu[j].name = "actionMenu";
323 mainMenu[j++].helpData = HELP_SELECTED_MENU_STR;
325 moveBtn = &(mainMenu[j].widget);
326 mainMenu[j].type = MENU_BUTTON;
327 mainMenu[j].maskBit = MOVE;
328 mainMenu[j].label = GETMESSAGE(20, 152, "Move to...");
329 mainMenu[j].label = XtNewString(mainMenu[j].label);
330 mainMenu[j].mnemonic = GETMESSAGE(20, 125, "M");
331 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
332 mainMenu[j].helpData = HELP_MOVE_AS_COMMAND_STR;
333 mainMenu[j].name = "move";
334 mainMenu[j++].activateCallback = ShowMoveFileDialog;
336 duplicateBtn = &(mainMenu[j].widget);
337 mainMenu[j].type = MENU_BUTTON;
338 mainMenu[j].maskBit = DUPLICATE;
339 mainMenu[j].label = GETMESSAGE(20, 153, "Copy to...");
340 mainMenu[j].label = XtNewString(mainMenu[j].label);
341 mainMenu[j].mnemonic = GETMESSAGE(20, 145, "C");
342 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
343 mainMenu[j].helpData = HELP_COPY_AS_COMMAND_STR;
344 mainMenu[j].name = "copy";
345 mainMenu[j++].activateCallback = ShowCopyFileDialog;
347 linkBtn = &(mainMenu[j].widget);
348 mainMenu[j].type = MENU_BUTTON;
349 mainMenu[j].maskBit = LINK;
350 mainMenu[j].label = GETMESSAGE(20, 154, "Copy As Link...");
351 mainMenu[j].label = XtNewString(mainMenu[j].label);
352 mainMenu[j].mnemonic = GETMESSAGE(20, 127, "L");
353 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
354 mainMenu[j].helpData = HELP_LINK_AS_COMMAND_STR;
355 mainMenu[j].name = "link";
356 mainMenu[j++].activateCallback = ShowLinkFileDialog;
358 mainMenu[j].type = MENU_SEPARATOR;
359 mainMenu[j].name = "separator";
360 mainMenu[j++].helpCallback = NULL;
362 mainMenu[j].maskBit = PUT_ON_DESKTOP;
363 mainMenu[j].type = MENU_BUTTON;
364 mainMenu[j].label = GETMESSAGE(20,84, "Put in Workspace");
365 mainMenu[j].label = XtNewString(mainMenu[j].label);
366 mainMenu[j].mnemonic = GETMESSAGE(20,85, "W");
367 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
368 mainMenu[j].helpData = HELP_PUT_ON_DT_COMMAND_STR;
369 mainMenu[j].name = "putInWorkspace";
370 mainMenu[j++].activateCallback = PutOnDTCB;
372 mainMenu[j].type = MENU_BUTTON;
373 mainMenu[j].maskBit = TRASH;
374 mainMenu[j].label = GETMESSAGE(20,151, "Put in Trash");
375 mainMenu[j].label = XtNewString(mainMenu[j].label);
376 mainMenu[j].mnemonic = GETMESSAGE(20, 91, "T");
377 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
378 mainMenu[j].helpData = HELP_TRASH_FILES_COMMAND_STR;
379 mainMenu[j].name = "putInTrash";
380 mainMenu[j++].activateCallback = TrashFiles;
382 renameBtn = &(mainMenu[j].widget);
383 mainMenu[j].type = MENU_BUTTON;
384 mainMenu[j].maskBit = RENAME;
385 mainMenu[j].label = GETMESSAGE(20, 137, "Rename...");
386 mainMenu[j].label = XtNewString(mainMenu[j].label);
387 mainMenu[j].mnemonic = GETMESSAGE(20, 110, "R");
388 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
389 mainMenu[j].helpData = HELP_RENAME_COMMAND_STR;
390 mainMenu[j].name = "rename";
391 mainMenu[j++].activateCallback = ShowRenameFileDialog;
393 mainMenu[j].type = MENU_BUTTON;
394 mainMenu[j].maskBit = MODIFY;
395 mainMenu[j].label = GETMESSAGE(20, 150, "Change Permissions...");
396 mainMenu[j].label = XtNewString(mainMenu[j].label);
397 mainMenu[j].mnemonic = GETMESSAGE(20, 17, "P");
398 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
399 mainMenu[j].helpData = HELP_PROPERTIES_COMMAND_STR;
400 mainMenu[j].name = "permissions";
401 mainMenu[j++].activateCallback = ShowModAttrDialog;
403 mainMenu[j].type = MENU_SEPARATOR;
404 mainMenu[j].name = "separator";
405 mainMenu[j++].helpCallback = NULL;
407 mainMenu[j].type = MENU_BUTTON;
408 mainMenu[j].label = GETMESSAGE(20, 48, "Select All");
409 mainMenu[j].label = XtNewString(mainMenu[j].label);
410 mainMenu[j].mnemonic = GETMESSAGE(20, 51, "S");
411 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
412 mainMenu[j].helpData = HELP_SELECT_ALL_COMMAND_STR;
413 mainMenu[j].name = "selectAll";
414 mainMenu[j++].activateCallback = SelectAll;
416 mainMenu[j].type = MENU_BUTTON;
417 mainMenu[j].label = GETMESSAGE(20, 52, "Deselect All");
418 mainMenu[j].label = XtNewString(mainMenu[j].label);
419 mainMenu[j].mnemonic = GETMESSAGE(20, 55, "D");
420 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
421 mainMenu[j].helpData = HELP_UNSELECT_ALL_COMMAND_STR;
422 mainMenu[j].name = "deselectAll";
423 mainMenu[j++].activateCallback = UnselectAll;
425 mainMenu[j].type = MENU_SEPARATOR;
426 mainMenu[j].name = "separator";
427 mainMenu[j++].helpCallback = NULL;
429 /*************************************/
430 /* Create the 'View' menu components */
431 /*************************************/
433 directoryBarBtn = &(mainMenu[j].widget);
434 mainMenu[j].type = MENU_PULLDOWN_BUTTON;
435 mainMenu[j].label = GETMESSAGE(20, 5, "View");
436 mainMenu[j].label = XtNewString(mainMenu[j].label);
437 mainMenu[j].mnemonic = GETMESSAGE(20, 6, "V");
438 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
439 mainMenu[j].name = "view";
440 mainMenu[j++].helpData = HELP_VIEW_MENU_STR;
442 mainMenu[j].type = SHARED_MENU_PANE;
443 mainMenu[j].name = "viewMenu";
444 mainMenu[j++].helpData = HELP_VIEW_MENU_STR;
446 if(openDirType == CURRENT)
448 newViewBtn = &(mainMenu[j].widget);
449 mainMenu[j].type = MENU_BUTTON;
450 mainMenu[j].label = GETMESSAGE(20, 138, "Open New View");
451 mainMenu[j].label = XtNewString(mainMenu[j].label);
452 mainMenu[j].mnemonic = GETMESSAGE(20, 139, "O");
453 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
454 mainMenu[j].helpData = HELP_NEW_VIEW_COMMAND_STR;
455 mainMenu[j].name = "new";
456 mainMenu[j++].activateCallback = NewView;
461 mainMenu[j].type = MENU_SEPARATOR;
462 mainMenu[j].name = "separator";
463 mainMenu[j++].helpCallback = NULL;
465 preferencesBtn = &(mainMenu[j].widget);
466 mainMenu[j].type = MENU_BUTTON;
467 mainMenu[j].maskBit = PREFERENCES;
468 mainMenu[j].label = GETMESSAGE(20, 141, "Set View Options...");
469 mainMenu[j].label = XtNewString(mainMenu[j].label);
470 mainMenu[j].mnemonic = GETMESSAGE(20, 6, "V");
471 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
472 mainMenu[j].helpData = HELP_PREFERENCES_COMMAND_STR;
473 mainMenu[j].name = "setViewOptions";
474 mainMenu[j++].activateCallback = ShowPreferencesDialog;
476 defaultEnvBtn = &(mainMenu[j].widget);
477 mainMenu[j].type = MENU_BUTTON;
478 mainMenu[j].maskBit = SETTINGS;
479 mainMenu[j].label = GETMESSAGE(20, 142, "Save As Default Options...");
480 mainMenu[j].label = XtNewString(mainMenu[j].label);
481 mainMenu[j].mnemonic = GETMESSAGE(20, 143, "S");
482 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
483 mainMenu[j].helpData = HELP_SAVE_SETTINGS_COMMAND_STR;
484 mainMenu[j].name = "saveViewOptions";
485 mainMenu[j++].activateCallback = SaveSettingsCB;
487 showHiddenMenu = &(mainMenu[j].widget);
488 mainMenu[j].type = MENU_TOGGLE_BUTTON;
489 mainMenu[j].label = GETMESSAGE(20,156, "Show Hidden Objects");
490 mainMenu[j].label = XtNewString(mainMenu[j].label);
491 mainMenu[j].mnemonic = GETMESSAGE(20,102, "H");
492 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
493 mainMenu[j].helpData = HELP_SHOW_HIDDEN_COMMAND_STR;
494 mainMenu[j].name = "showHiddenObjects";
495 mainMenu[j++].activateCallback = ShowHiddenFiles;
497 filterBtn = &(mainMenu[j].widget);
498 mainMenu[j].type = MENU_BUTTON;
499 mainMenu[j].maskBit = FILTER;
500 mainMenu[j].label = GETMESSAGE(20,144, "Set Filter Options...");
501 mainMenu[j].label = XtNewString(mainMenu[j].label);
502 mainMenu[j].mnemonic = GETMESSAGE(20, 104, "F");
503 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
504 mainMenu[j].helpData = HELP_FILTER_COMMAND_STR;
505 mainMenu[j].name = "setFilterOptions";
506 mainMenu[j++].activateCallback = ShowFilterDialog;
508 mainMenu[j].type = MENU_SEPARATOR;
509 mainMenu[j].name = "separator";
510 mainMenu[j++].helpCallback = NULL;
512 cleanUpBtn = &(mainMenu[j].widget);
513 mainMenu[j].type = MENU_BUTTON;
514 mainMenu[j].maskBit = CLEAN_UP;
515 mainMenu[j].label = GETMESSAGE(20,99, "Clean Up");
516 mainMenu[j].label = XtNewString(mainMenu[j].label);
517 mainMenu[j].mnemonic = GETMESSAGE(20,100, "C");
518 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
519 mainMenu[j].helpData = HELP_CLEAN_UP_COMMAND_STR;
520 mainMenu[j].name = "cleanUp";
521 mainMenu[j++].activateCallback = CleanUp;
523 mainMenu[j].type = MENU_BUTTON;
524 mainMenu[j].label = GETMESSAGE(20, 30, "Update");
525 mainMenu[j].label = XtNewString(mainMenu[j].label);
526 mainMenu[j].mnemonic = GETMESSAGE(20, 33, "U");
527 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
528 mainMenu[j].helpData = HELP_REREAD_COMMAND_STR;
529 mainMenu[j].name = "refresh";
530 mainMenu[j++].activateCallback = RereadDirectoryMenu;
532 /*************************************/
533 /* Create the 'Help' menu components */
534 /*************************************/
536 mainMenu[j].type = MENU_PULLDOWN_BUTTON;
537 mainMenu[j].isHelpBtn = True;
538 mainMenu[j].label = GETMESSAGE(20, 123, "Help");
539 mainMenu[j].label = XtNewString(mainMenu[j].label);
540 mainMenu[j].mnemonic = GETMESSAGE(20, 9, "H");
541 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
542 mainMenu[j].name = "help";
543 mainMenu[j++].helpData = HELP_HELP_MENU_STR;
545 mainMenu[j].type = SHARED_MENU_PANE;
546 mainMenu[j].name = "helpMenu";
547 mainMenu[j++].helpData = HELP_HELP_MENU_STR;
549 mainMenu[j].type = MENU_BUTTON;
550 mainMenu[j].label = GETMESSAGE(20, 105, "Overview");
551 mainMenu[j].label = XtNewString(mainMenu[j].label);
552 mainMenu[j].mnemonic = GETMESSAGE(20, 106, "v");
553 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
554 mainMenu[j].helpData = HELP_HELP_MENU_STR;
555 mainMenu[j].activateCallback = HelpRequestCB;
556 mainMenu[j].name = "introduction";
557 mainMenu[j++].activateData = HELP_HOME_TOPIC;
559 mainMenu[j].type = MENU_SEPARATOR;
560 mainMenu[j].name = "separator";
561 mainMenu[j++].helpCallback = NULL;
563 mainMenu[j].type = MENU_BUTTON;
564 mainMenu[j].label = GETMESSAGE(20, 148, "Table Of Contents");
565 mainMenu[j].label = XtNewString(mainMenu[j].label);
566 mainMenu[j].mnemonic = GETMESSAGE(20, 149, "C");
567 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
568 mainMenu[j].helpData = HELP_HELP_MENU_STR;
569 mainMenu[j].activateCallback = HelpRequestCB;
570 mainMenu[j].name = "toc";
571 mainMenu[j++].activateData = HELP_TOC_STR;
573 mainMenu[j].type = MENU_BUTTON;
574 mainMenu[j].label = GETMESSAGE(20, 107, "Tasks");
575 mainMenu[j].label = XtNewString(mainMenu[j].label);
576 mainMenu[j].mnemonic = GETMESSAGE(20, 108, "T");
577 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
578 mainMenu[j].helpData = HELP_HELP_MENU_STR;
579 mainMenu[j].activateCallback = HelpRequestCB;
580 mainMenu[j].name = "tasks";
581 mainMenu[j++].activateData = HELP_TASKS_STR;
583 mainMenu[j].type = MENU_BUTTON;
584 mainMenu[j].label = GETMESSAGE(20,109, "Reference");
585 mainMenu[j].label = XtNewString(mainMenu[j].label);
586 mainMenu[j].mnemonic = GETMESSAGE(20,110, "R");
587 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
588 mainMenu[j].helpData = HELP_HELP_MENU_STR;
589 mainMenu[j].activateCallback = HelpRequestCB;
590 mainMenu[j].name = "reference";
591 mainMenu[j++].activateData = HELP_REFERENCE_STR;
593 mainMenu[j].type = MENU_BUTTON;
594 mainMenu[j].label = GETMESSAGE(20,111, "On Item");
595 mainMenu[j].label = XtNewString(mainMenu[j].label);
596 mainMenu[j].mnemonic = GETMESSAGE(20,112, "O");
597 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
598 mainMenu[j].helpData = HELP_HELP_MENU_STR;
599 mainMenu[j].activateCallback = HelpRequestCB;
600 mainMenu[j].name = "onItem";
601 mainMenu[j++].activateData = HELP_HELP_MODE_STR;
603 mainMenu[j].type = MENU_SEPARATOR;
604 mainMenu[j].name = "separator";
605 mainMenu[j++].helpCallback = NULL;
607 usingHelp = &(mainMenu[j].widget);
608 mainMenu[j].type = MENU_BUTTON;
609 mainMenu[j].label = GETMESSAGE(20,113, "Using Help");
610 mainMenu[j].label = XtNewString(mainMenu[j].label);
611 mainMenu[j].mnemonic = GETMESSAGE(20,114, "U");
612 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
613 mainMenu[j].helpData = HELP_HELP_MENU_STR;
614 mainMenu[j].activateCallback = HelpRequestCB;
615 mainMenu[j].name = "usingHelp";
616 mainMenu[j++].activateData = HELP_HOME_TOPIC;
618 mainMenu[j].type = MENU_SEPARATOR;
619 mainMenu[j].name = "separator";
620 mainMenu[j++].helpCallback = NULL;
622 fileManagerHelp = &(mainMenu[j].widget);
623 mainMenu[j].type = MENU_BUTTON;
624 mainMenu[j].label = GETMESSAGE(20,115, "About File Manager");
625 mainMenu[j].label = XtNewString(mainMenu[j].label);
626 mainMenu[j].mnemonic = GETMESSAGE(20,116, "A");
627 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
628 mainMenu[j].helpData = HELP_HELP_MENU_STR;
629 mainMenu[j].activateCallback = HelpRequestCB;
630 mainMenu[j].name = "version";
631 mainMenu[j++].activateData = HELP_ABOUT_STR;
633 applicationManagerHelp = &(mainMenu[j].widget);
634 mainMenu[j].type = MENU_BUTTON;
635 mainMenu[j].label = GETMESSAGE(20,157, "About Application Manager");
636 mainMenu[j].label = XtNewString(mainMenu[j].label);
637 mainMenu[j].mnemonic = GETMESSAGE(20,116, "A");
638 mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic);
639 mainMenu[j].helpData = HELP_HELP_MENU_STR;
640 mainMenu[j].activateCallback = HelpRequestCB;
641 mainMenu[j].name = "version";
642 mainMenu[j++].activateData = HELP_ABOUT_STR;
645 menu_bar = _DtCreateMenuSystem(main, "mainMenu", HelpRequestCB,
646 HELP_HELP_MENU_STR, createSharedComponents,
647 mainMenu, menuItemCount, GetMainMenuData,
648 SetMenuSensitivity, RestoreMenuSensitivity);
650 /* Fine tune the menubar */
651 XtSetArg(args[0], XmNmarginWidth, 2);
652 XtSetArg(args[1], XmNmarginHeight, 2);
653 XtSetValues(menu_bar, args, 2);
655 file_mgr_rec->actions = *actionsId;
656 file_mgr_rec->action_pane = *actionsPaneId;
657 file_mgr_rec->directoryBarBtn = *directoryBarBtn;
659 file_mgr_rec->create_directoryBtn_child= NULL;
660 file_mgr_rec->create_dataBtn_child= NULL;
662 ActivateNoSelect (file_mgr_rec);
664 createSharedComponents = False;
673 XtPointer * mainRecordPtr,
674 MenuDesc ** menuDescPtr,
675 int * menuItemCountPtr,
676 unsigned int ** globalMenuStatesPtr,
677 unsigned int ** viewMenuStatesPtr )
681 FileMgrRec * fileMgrRec;
683 XtSetArg(args[0], XmNuserData, &fileMgrRec);
684 XtGetValues(mbar, args, 1);
685 *mainRecordPtr = (XtPointer) fileMgrRec;
686 *menuDescPtr = mainMenu;
687 *menuItemCountPtr = menuItemCount;
688 *globalMenuStatesPtr = ¤tMenuStates;
689 *viewMenuStatesPtr = &fileMgrRec->menuStates;
690 *actionsPaneId = fileMgrRec->action_pane;
697 struct passwd * pwInfo;
699 if( homeDir == NULL )
701 if ((homeDir = getenv("HOME_CLIENT")) == NULL)
703 if ((homeDir = getenv("HOME")) == NULL)
705 pwInfo = getpwuid (getuid());
706 homeDir = pwInfo->pw_dir;
713 /************************************************************************
715 * ActivateSingleSelect
716 * Activate the menu items that are to be active upon a
719 ************************************************************************/
722 ActivateSingleSelect(
723 FileMgrRec *file_mgr_rec,
726 DialogData * dialog_data;
727 FileMgrData * file_mgr_data;
729 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
731 file_mgr_data = (FileMgrData *) dialog_data->data;
733 if ((strcmp(file_mgr_data->selection_list[0]->file_data->file_name, ".." ) == 0 )
734 || (strcmp(file_mgr_data->selection_list[0]->file_data->file_name, "." ) == 0 ) )
736 file_mgr_rec->menuStates |= TRASH | MODIFY | PUT_ON_DESKTOP;
737 file_mgr_rec->menuStates &= (~RENAME);
740 file_mgr_rec->menuStates |= RENAME | TRASH | MODIFY | PUT_ON_DESKTOP;
742 if ((strcmp(file_type, LT_BROKEN_LINK) != 0)
743 && (strcmp(file_type, LT_RECURSIVE_LINK) != 0)
745 && (file_mgr_data->selection_list[0]->file_data->physical_type !=
750 file_mgr_rec->menuStates |= MOVE | DUPLICATE | LINK;
753 file_mgr_rec->menuStates &= ~(MOVE | DUPLICATE | LINK);
755 /* Update the action menu pane defined for the file type */
756 /* of the selected file. */
758 UpdateActionMenuPane ((XtPointer)file_mgr_data, file_mgr_rec, file_type,
759 NOT_DESKTOP, 0, (Widget)NULL,
760 file_mgr_data->selection_list[0]->file_data->physical_type);
766 UnmanageAllActionItems(
767 FileMgrRec *file_mgr_rec )
769 register int i, children;
770 XmManagerWidget action_pane;
772 action_pane = (XmManagerWidget) file_mgr_rec->action_pane;
774 for (i = SELECTED_MENU_MAX; i < action_pane->composite.num_children; ++i)
776 XtUnmanageChild (action_pane->composite.children[i]);
780 /************************************************************************
782 * ActivateMultipleSelect
783 * Activate (deactivate) the appropriate menu items when multiple
784 * files are selected.
787 ************************************************************************/
790 ActivateMultipleSelect(
791 FileMgrRec *file_mgr_rec )
793 file_mgr_rec->menuStates |= TRASH | PUT_ON_DESKTOP;
794 file_mgr_rec->menuStates &= ~(RENAME | MOVE | DUPLICATE | LINK |
797 UnmanageAllActionItems (file_mgr_rec);
803 /************************************************************************
806 * Activate (deactivate) the appropriate menu items when no
807 * files are selected.
809 ************************************************************************/
813 FileMgrRec *file_mgr_rec )
815 file_mgr_rec->menuStates &= ~(RENAME | MOVE | DUPLICATE | LINK | TRASH |
816 MODIFY | PUT_ON_DESKTOP);
818 UnmanageAllActionItems (file_mgr_rec);
823 /************************************************************************
826 * Unselect all of the selected files.
828 ************************************************************************/
833 XtPointer client_data,
834 XtPointer call_data )
836 FileMgrRec * file_mgr_rec;
837 DialogData * dialog_data;
838 FileMgrData * file_mgr_data;
842 if ((int)client_data == FM_POPUP)
845 mbar = XmGetPostedFromWidget(XtParent(w));
848 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
849 XtGetValues(mbar, args, 1);
851 /* Ignore accelerators received after we're unposted */
852 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
854 file_mgr_data = (FileMgrData *) dialog_data->data;
856 DeselectAllFiles (file_mgr_data);
857 ActivateNoSelect (file_mgr_rec);
859 if( file_mgr_data == trashFileMgrData )
860 SensitizeTrashBtns();
866 /************************************************************************
869 * Select all of file displayed.
871 ************************************************************************/
876 XtPointer client_data,
877 XtPointer call_data )
879 FileMgrRec * file_mgr_rec;
880 DialogData * dialog_data;
881 FileMgrData * file_mgr_data;
885 if ((int)client_data == FM_POPUP)
888 mbar = XmGetPostedFromWidget(XtParent(w));
891 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
892 XtGetValues(mbar, args, 1);
894 /* Ignore accelerators received after we're unposted */
895 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
897 file_mgr_data = (FileMgrData *) dialog_data->data;
899 SelectAllFiles (file_mgr_data);
901 if( file_mgr_data == trashFileMgrData )
902 SensitizeTrashBtns();
908 /************************************************************************
910 * RereadDirectoryMenu
911 * Callback function invoked from the Reread Directory
912 * menu item. This function calls the file manager functions
913 * which rereads and processes the directory.
915 ************************************************************************/
920 XtPointer client_data,
921 XtPointer call_data )
924 Widget mbar = XmGetPostedFromWidget(XtParent(w));
925 FileMgrRec * file_mgr_rec;
926 DialogData * dialog_data;
930 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
931 XtGetValues(mbar, args, 1);
933 /* Ignore accelerators received after we're unposted */
934 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
937 UnpostTextPath( (FileMgrData *) dialog_data->data );
939 /* force this directory to be updated */
940 FileMgrReread (file_mgr_rec);
944 /************************************************************************
947 * Display the Trash can.
949 ************************************************************************/
950 #if defined(ADD_SHOW_TRASH)
955 XtPointer client_data,
956 XtPointer call_data )
960 TrashDisplayHandler (NULL, NULL, NULL, NULL, 0);
965 /************************************************************************
968 * Send the selected set of files to the trash.
970 ************************************************************************/
975 XtPointer client_data,
976 XtPointer call_data )
978 FileMgrRec * file_mgr_rec;
979 DialogData * dialog_data;
980 FileMgrData * file_mgr_data;
981 FileViewData * file_view_data;
984 DtActionArg * action_args;
988 if (!TrashIsInitialized())
992 title = XtNewString(GetSharedMessage(TRASH_ERROR_TITLE));
994 msg = XtMalloc( strlen( GETMESSAGE(27,95, "Unable to access the Trash directory:\n %s\n All trash operations will not be performed.\n The most common causes are:\n - Network authentication.\n - Insufficient disk space.\n - Wrong permissions.") )
995 + strlen( trash_dir )
998 sprintf( msg, GETMESSAGE(27, 95, "Unable to access the Trash directory:\n %s\n All trash operations will not be performed.\n The most common causes are:\n - Network authentication.\n - Insufficient disk space.\n - Wrong permissions."), trash_dir );
1000 _DtMessage(toplevel, title, msg, NULL, HelpRequestCB);
1006 XmUpdateDisplay (w);
1008 if((int)client_data == 0)
1009 mbar = XmGetPostedFromWidget(XtParent(w));
1013 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
1014 XtGetValues(mbar, args, 1);
1016 /* Ignore accelerators when we're insensitive */
1017 if(client_data == NULL)
1018 if ((file_mgr_rec->menuStates & TRASH) == 0)
1021 /* Ignore accelerators received after we're unposted */
1022 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
1024 file_mgr_data = (FileMgrData *) dialog_data->data;
1026 /* 'widget_dragged' is set in InitiateIconDrag() and
1027 is never set to NULL. Because of this, after doing a desktop drag
1028 if you do a 'PutInTrash' on the File Manager window object, in
1029 TrashRemoveHandler() in Trash.c, it displays an incorrect message,
1030 So set it to NULL here. */
1032 widget_dragged = NULL;
1034 /* get the file_view_data object from which the menu was invoked */
1035 if (client_data == NULL)
1036 file_view_data = NULL;
1039 file_view_data = file_mgr_data->popup_menu_icon;
1040 /* The following test makes sure that the it is not the case of
1041 multiple selected files */
1042 if (!file_mgr_data->selected_file_count && file_view_data == NULL)
1043 /* the object has gone away (probably deleted) */
1046 file_mgr_data->popup_menu_icon = NULL;
1050 for(i = 0; i < file_mgr_data->selected_file_count; i++)
1052 if(file_mgr_data->selection_list[i] == file_view_data)
1054 file_view_data = NULL;
1062 _DtBuildActionArgsWithSelectedFiles(&file_view_data, 1,
1063 &action_args, &arg_count);
1065 _DtBuildActionArgsWithSelectedFiles(file_mgr_data->selection_list,
1066 file_mgr_data->selected_file_count,
1067 &action_args, &arg_count);
1069 DtActionInvoke(file_mgr_rec->shell, TRASH_ACTION,
1070 action_args, arg_count, NULL, NULL,
1071 trash_dir, True, NULL, NULL);
1073 _DtFreeActionArgs(action_args, arg_count);
1079 /************************************************************************
1082 * Create a new view of the currently display directory
1084 ************************************************************************/
1089 XtPointer client_data,
1090 XtPointer call_data )
1092 FileMgrRec * file_mgr_rec;
1093 DialogData * dialog_data;
1094 FileMgrData * file_mgr_data;
1096 Widget mbar = XmGetPostedFromWidget(XtParent(w));
1099 XmUpdateDisplay (w);
1100 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
1101 XtGetValues(mbar, args, 1);
1103 /* Ignore accelerators received after we're unposted */
1104 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
1106 file_mgr_data = (FileMgrData *) dialog_data->data;
1108 initiating_view = (XtPointer) file_mgr_data;
1109 if(file_mgr_data->restricted_directory != NULL)
1111 special_view = True;
1112 special_treeType = file_mgr_data->show_type;
1113 special_viewType = file_mgr_data->view;
1114 special_orderType = file_mgr_data->order;
1115 special_directionType = file_mgr_data->direction;
1116 special_randomType = file_mgr_data->positionEnabled;
1117 special_restricted = XtNewString(file_mgr_data->restricted_directory);
1118 if(file_mgr_data->title == NULL)
1119 special_title = NULL;
1121 special_title = XtNewString(file_mgr_data->title);
1122 special_helpVol = XtNewString(file_mgr_data->helpVol);
1124 if(file_mgr_data->toolbox)
1125 GetNewView (file_mgr_data->host, file_mgr_data->current_directory,
1126 file_mgr_data->restricted_directory, NULL, 0);
1128 GetNewView (file_mgr_data->host, file_mgr_data->current_directory,
1132 GetNewView (file_mgr_data->host, file_mgr_data->current_directory, NULL,
1134 initiating_view = (XtPointer) NULL;
1140 /************************************************************************
1143 * Update the current view to show the home directory.
1145 ************************************************************************/
1150 XtPointer client_data,
1151 XtPointer call_data )
1153 FileMgrRec * file_mgr_rec;
1154 DialogData * dialog_data;
1155 FileMgrData * file_mgr_data;
1159 Widget mbar = XmGetPostedFromWidget(XtParent(w));
1162 XmUpdateDisplay (w);
1163 if((int)client_data == FM_POPUP)
1166 mbar = XmGetPostedFromWidget(XtParent(w));
1168 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
1169 XtGetValues(mbar, args, 1);
1171 /* Ignore accelerators when we're insensitive */
1172 if ((file_mgr_rec->menuStates & HOME) == 0)
1175 /* Ignore accelerators received after we're unposted */
1176 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
1178 file_mgr_data = (FileMgrData *) dialog_data->data;
1182 if( homeDir == NULL )
1185 if((ptr = DtStrchr(homeDir, ':')) != NULL)
1187 ptr1 = DtStrchr(homeDir, '/');
1188 if(strlen(ptr) > strlen(ptr1))
1191 host = XtNewString(homeDir);
1199 host = home_host_name;
1202 host = home_host_name;
1204 if (file_mgr_data->cd_select != NULL)
1206 XtFree (file_mgr_data->cd_select);
1207 file_mgr_data->cd_select = NULL;
1210 ShowNewDirectory( file_mgr_data, host, homeDir );
1219 /************************************************************************
1222 * Update the current view to show the parent directory.
1224 ************************************************************************/
1229 XtPointer client_data,
1230 XtPointer call_data )
1232 FileMgrRec * file_mgr_rec;
1233 DialogData * dialog_data;
1234 FileMgrData * file_mgr_data;
1236 Widget mbar = XmGetPostedFromWidget(XtParent(w));
1237 char host_name[MAX_PATH];
1238 Widget focus_widget;
1240 XmUpdateDisplay (w);
1241 if((int)client_data == FM_POPUP)
1244 mbar = XmGetPostedFromWidget(XtParent(w));
1246 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
1247 XtGetValues(mbar, args, 1);
1249 /* Ignore accelerators when we're insensitive */
1250 if ((file_mgr_rec->menuStates & MOVE_UP) == 0)
1253 /* Ignore accelerators received after we're unposted */
1254 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
1257 focus_widget = XmGetFocusWidget(file_mgr_rec->file_window);
1260 if (focus_widget == file_mgr_rec->current_directory_text)
1262 XmTextFieldReplace(focus_widget,
1264 XmTextFieldGetInsertionPosition(focus_widget),
1268 else if (strcmp(focus_widget->core.name, "nameChangeT") == 0)
1270 XmTextReplace(focus_widget,
1272 XmTextFieldGetInsertionPosition(focus_widget),
1278 file_mgr_data = (FileMgrData *) dialog_data->data;
1280 if (strcmp (file_mgr_data->current_directory, "/") == 0)
1283 strcpy(host_name, file_mgr_data->host);
1285 if (file_mgr_data->cd_select != NULL)
1287 XtFree (file_mgr_data->cd_select);
1288 file_mgr_data->cd_select = NULL;
1291 ShowNewDirectory (file_mgr_data, host_name,
1292 _DtPName (file_mgr_data->current_directory));
1294 if(strcmp(file_mgr_data->current_directory,
1295 file_mgr_data->restricted_directory) == 0)
1297 _DtGlobalUpdateMenuItemState(*upBarBtn, MOVE_UP, False, ¤tMenuStates);
1298 file_mgr_rec->menuStates &= ~(MOVE_UP);
1302 file_mgr_rec->menuStates |= MOVE_UP;
1303 _DtGlobalUpdateMenuItemState(*upBarBtn, MOVE_UP, True, ¤tMenuStates);
1310 /************************************************************************
1312 * SetMenuSensitivity
1313 * Called before each menupane is posted; it will correctly set
1314 * the menu button sensitivity for the view from which the menu
1315 * is being posted; this is necessary because the menupanes are
1316 * shared. Only those buttons whose state is different than that
1317 * of the current menu will be changed.
1319 ************************************************************************/
1324 XtPointer client_data,
1325 XtPointer call_data )
1329 FileMgrRec * file_mgr_rec;
1330 XmMenuShellWidget mshell = (XmMenuShellWidget) w;
1331 DialogData * dialog_data;
1332 FileMgrData * file_mgr_data;
1334 _XmGetActiveTopLevelMenu(mshell->composite.children[0], &mbar);
1335 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
1336 XtGetValues(mbar, args, 1);
1338 /* Enable the appropriate menu widgets based on the view type */
1339 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) != NULL)
1341 struct stat file_info;
1343 file_mgr_data = (FileMgrData *) dialog_data->data;
1345 if( stat( file_mgr_data->current_directory, &file_info ) == 0 )
1347 if( ! (file_info.st_mode & S_IXUSR)
1348 || ! (file_info.st_mode & S_IWUSR) )
1350 file_mgr_rec->menuStates &= ~(CREATE_DIR) & ~(CREATE_FILE);
1351 _DtGlobalUpdateMenuItemState(*create_dataBtn, CREATE_FILE, False, ¤tMenuStates);
1352 _DtGlobalUpdateMenuItemState(*create_directoryBtn, CREATE_DIR, False, ¤tMenuStates);
1354 else if( ! ( file_mgr_data->toolbox ) ||
1355 ( file_mgr_data->toolbox && geteuid() == root_user ) )
1357 file_mgr_rec->menuStates |= CREATE_DIR | CREATE_FILE;
1358 _DtGlobalUpdateMenuItemState(*create_dataBtn, CREATE_FILE, True, ¤tMenuStates);
1359 _DtGlobalUpdateMenuItemState(*create_directoryBtn, CREATE_DIR, True, ¤tMenuStates);
1363 if (!PositioningEnabledInView(file_mgr_data))
1364 file_mgr_rec->menuStates &= ~(CLEAN_UP);
1366 file_mgr_rec->menuStates |= CLEAN_UP;
1368 XtManageChild(*defaultEnvBtn);
1369 if(file_mgr_data->restricted_directory == NULL)
1371 if(strcmp(file_mgr_data->current_directory, "/") == 0)
1373 file_mgr_rec->menuStates &= ~(MOVE_UP);
1374 _DtGlobalUpdateMenuItemState( *upBarBtn, MOVE_UP,
1375 False,¤tMenuStates);
1379 file_mgr_rec->menuStates |= MOVE_UP;
1380 _DtGlobalUpdateMenuItemState(*upBarBtn, MOVE_UP, True,¤tMenuStates);
1383 if( homeDir == NULL )
1387 && strcmp( homeDir, file_mgr_data->current_directory ) != 0 )
1389 file_mgr_rec->menuStates |= HOME;
1390 _DtGlobalUpdateMenuItemState(*homeBarBtn, HOME, True,
1391 ¤tMenuStates);
1395 file_mgr_rec->menuStates &= ~(HOME);
1396 _DtGlobalUpdateMenuItemState(*homeBarBtn, HOME, False,
1397 ¤tMenuStates);
1400 file_mgr_rec->menuStates |= CHANGE_DIR;
1401 _DtGlobalUpdateMenuItemState(*change_directoryBtn, CHANGE_DIR, True,
1402 ¤tMenuStates);
1403 XtManageChild(*change_directoryBtn);
1407 if(strcmp(file_mgr_data->current_directory,
1408 file_mgr_data->restricted_directory) == 0)
1410 _DtGlobalUpdateMenuItemState(*upBarBtn, MOVE_UP, False,
1411 ¤tMenuStates);
1412 file_mgr_rec->menuStates &= ~(MOVE_UP);
1416 file_mgr_rec->menuStates |= MOVE_UP;
1417 _DtGlobalUpdateMenuItemState(*upBarBtn, MOVE_UP, True,
1418 ¤tMenuStates);
1420 _DtGlobalUpdateMenuItemState(*homeBarBtn, HOME, False,¤tMenuStates);
1421 file_mgr_rec->menuStates &= ~(HOME);
1422 _DtGlobalUpdateMenuItemState(*change_directoryBtn, CHANGE_DIR, False,
1423 ¤tMenuStates);
1424 file_mgr_rec->menuStates &= ~(CHANGE_DIR);
1430 if(file_mgr_data->restricted_directory == NULL)
1433 _DtGlobalUpdateMenuItemState(*terminalBtn, TERMINAL, True,
1434 ¤tMenuStates);
1435 file_mgr_rec->menuStates |= TERMINAL;
1440 _DtGlobalUpdateMenuItemState(*terminalBtn, TERMINAL, False,
1441 ¤tMenuStates);
1442 file_mgr_rec->menuStates &= ~(TERMINAL);
1445 XtManageChild(*terminalBtn);
1448 XtManageChild(*preferencesBtn);
1449 XtManageChild(*filterBtn);
1450 if(openDirType == CURRENT)
1451 XtManageChild(*newViewBtn);
1452 XtManageChild(*showHiddenMenu);
1459 ptr = strrchr(users_home_dir, '/');
1461 if(strcmp(file_mgr_data->current_directory, users_home_dir) == 0)
1462 file_mgr_rec->menuStates &= ~(MOVE_UP);
1464 file_mgr_rec->menuStates |= MOVE_UP;
1469 XtManageChild(*findBtn);
1471 /* The problem is when users have 2 views
1472 and selected one file on one view and popup the
1473 'Selected' menu on the other view.
1474 The 'Selected' menu still show the other view action items.
1476 if( file_mgr_data->selected_file_count == 0 )
1477 ActivateNoSelect( file_mgr_rec );
1478 else if( file_mgr_data->selected_file_count == 1 )
1479 ActivateSingleSelect( file_mgr_rec,
1480 file_mgr_data->selection_list[0]->file_data->logical_type );
1482 ActivateMultipleSelect( file_mgr_rec );
1484 if( file_mgr_data->toolbox )
1486 if( geteuid() == root_user || access(file_mgr_data->current_directory,
1489 file_mgr_rec->menuStates |= CREATE_DIR
1491 _DtGlobalUpdateMenuItemState(*create_dataBtn, CREATE_FILE, True,
1492 ¤tMenuStates);
1493 _DtGlobalUpdateMenuItemState(*create_directoryBtn, CREATE_DIR, True,
1494 ¤tMenuStates);
1498 file_mgr_rec->menuStates &= ~(CREATE_DIR
1504 _DtGlobalUpdateMenuItemState(*create_dataBtn, CREATE_FILE, False,
1505 ¤tMenuStates);
1506 _DtGlobalUpdateMenuItemState(*create_directoryBtn, CREATE_DIR, False,
1507 ¤tMenuStates);
1508 _DtGlobalUpdateMenuItemState(*moveBtn, MOVE, False,
1509 ¤tMenuStates);
1510 _DtGlobalUpdateMenuItemState(*linkBtn, LINK, False,
1511 ¤tMenuStates);
1512 _DtGlobalUpdateMenuItemState(*renameBtn, RENAME, False,
1513 ¤tMenuStates);
1520 if (file_mgr_data->show_hid_enabled)
1521 XmToggleButtonGadgetSetState(*showHiddenMenu, True, False);
1523 XmToggleButtonGadgetSetState(*showHiddenMenu, False, False);
1526 if( file_mgr_data->toolbox )
1528 if( ! XtIsManaged( *applicationManagerHelp ) )
1529 XtManageChild( *applicationManagerHelp );
1530 if( XtIsManaged( *fileManagerHelp ) )
1531 XtUnmanageChild( *fileManagerHelp );
1535 if( ! XtIsManaged( *fileManagerHelp ) )
1536 XtManageChild( *fileManagerHelp );
1537 if( XtIsManaged( *applicationManagerHelp ) )
1538 XtUnmanageChild( *applicationManagerHelp );
1541 _DtGlobalSetMenuSensitivity(w, client_data, call_data);
1547 /************************************************************************
1549 * RestoreMenuSensitivity
1550 * Called after each menupane is unposted; it will restore the
1551 * sensitivity state of each menubutton to 'TRUE'; this is so that
1552 * accelerators will work correctly.
1554 ************************************************************************/
1557 RestoreMenuSensitivity(
1559 XtPointer client_data,
1560 XtPointer call_data )
1564 FileMgrRec * file_mgr_rec;
1565 XmMenuShellWidget mshell = (XmMenuShellWidget) w;
1566 DialogData * dialog_data;
1567 FileMgrData * file_mgr_data;
1570 _XmGetActiveTopLevelMenu(mshell->composite.children[0], &mbar);
1571 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
1572 XtGetValues(mbar, args, 1);
1574 /* Enable the appropriate menu widgets based on the view type */
1575 dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
1576 file_mgr_data = (FileMgrData *) dialog_data->data;
1578 _DtGlobalRestoreMenuSensitivity(w, client_data, call_data);
1584 ptr = strrchr(users_home_dir, '/');
1586 if(strcmp(file_mgr_data->current_directory, users_home_dir) == 0)
1588 _DtGlobalUpdateMenuItemState(*upBarBtn, MOVE_UP, False,
1589 ¤tMenuStates);
1593 _DtGlobalUpdateMenuItemState(*upBarBtn, MOVE_UP, True,
1594 ¤tMenuStates);
1599 if ((currentMenuStates & MOVE_UP) == 0)
1600 _DtGlobalUpdateMenuItemState(*upBarBtn, MOVE_UP, True,¤tMenuStates);
1602 if ((currentMenuStates & CLEAN_UP) == 0)
1603 _DtGlobalUpdateMenuItemState(*cleanUpBtn, CLEAN_UP, True,¤tMenuStates);
1609 /************************************************************************
1612 * Bring up a terminal with the current working directory the directory
1613 * of the dtfile view.
1615 ************************************************************************/
1620 XtPointer client_data,
1621 XtPointer call_data)
1623 FileMgrRec * file_mgr_rec;
1624 DialogData * dialog_data;
1625 FileMgrData * file_mgr_data;
1627 Widget mbar = XmGetPostedFromWidget(XtParent(w));
1628 char * pwd_host = NULL;
1629 char * pwd_dir = NULL;
1631 XmUpdateDisplay (w);
1632 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
1633 XtGetValues(mbar, args, 1);
1635 /* Ignore accelerators received after we're unposted */
1636 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
1638 file_mgr_data = (FileMgrData *) dialog_data->data;
1640 pwd_host = XtNewString(file_mgr_data->host);
1641 pwd_dir = XtNewString(file_mgr_data->current_directory);
1643 DtActionInvoke(file_mgr_rec->shell, "Terminal", NULL, 0, NULL,
1644 NULL, pwd_dir, True, NULL, NULL);