Enable silent-rules for compilation
[fsviewer.git] / src / FSMenu.c
blobdc1c33c96a60694bff40b2deab6b5091c8b0448b
1 #include <WINGs/WINGsP.h>
2 /* #include <WMaker.h> */
4 #include "files.h"
5 #include "FSFileButton.h"
6 #include "filebrowser.h"
7 #include "FSViewer.h"
8 #include "FSFileView.h"
9 #include "FSMenu.h"
10 #include "FSPanel.h"
11 #include "FSUtils.h"
12 #include "FSFinder.h"
15 static void fsSetViewerMode(FSViewer *fsViewer, FSFileViewType mode);
17 FileInfo *
18 fsGetFSViewerCurrentFileInfo(FSViewer *fsViewer)
20 FSFileView *fView;
22 fView = FSGetFSViewerCurrentView(fsViewer);
24 return FSGetFileViewFileInfo(fView);
27 void
28 FSQuitCB(WMWidget *w, void *data)
30 exit(0);
33 void
34 FSHideCB(FSViewer *fsViewer, int item, Time time)
36 WMHideApplication(FSGetFSViewerWMContext(fsViewer));
39 void
40 FSHideOthersCB(FSViewer *fsViewer, int item, Time time)
42 WMHideOthers(FSGetFSViewerWMContext(fsViewer));
45 void
46 FSInfoPanelCB(FSViewer *fsViewer, int item, Time time)
48 FSRunInfoPanel(fsViewer, "FSViewer", _("Info"));
51 void
52 FSLegalCB(FSViewer *fsViewer, int item, Time time)
54 FSRunLegalPanel(fsViewer, _("Legal"), _("License"));
57 void
58 FSPrefCB(FSViewer *fsViewer, int item, Time time)
60 FSRunPreferencesPanel(fsViewer, _("Preferences"));
63 void
64 FSWMPrefCB(FSViewer *fsViewer, int item, Time time)
66 FSRunPreferencesPanel(fsViewer, _("Preferences"));
69 void
70 FSRunCB(FSViewer *fsViewer, int item, Time time)
72 FSLaunchApp(fsViewer, AppExec);
75 void
76 FSViewCB(FSViewer *fsViewer, int item, Time time)
78 FSLaunchApp(fsViewer, AppView);
81 void
82 FSEditCB(FSViewer *fsViewer, int item, Time time)
84 FSLaunchApp(fsViewer, AppEdit);
87 void
88 FSInspectorCB(FSViewer *fsViewer, int item, Time time)
90 FileInfo *fileInfo;
92 fileInfo = fsGetFSViewerCurrentFileInfo(fsViewer);
93 FSShowInspectorWindow(FSGetFSViewerScreen(fsViewer), fileInfo);
96 void
97 FSBrowseCB(FSViewer *fsViewer, int item, Time time)
99 fsSetViewerMode(fsViewer, Browser);
102 void
103 FSIconCB(FSViewer *fsViewer, int item, Time time)
105 fsSetViewerMode(fsViewer, Icon);
108 void
109 FSListCB(FSViewer *fsViewer, int item, Time time)
111 fsSetViewerMode(fsViewer, List);
114 static void
115 fsSetViewerMode(FSViewer *fsViewer, FSFileViewType mode)
117 FSFileView *fView;
119 fView = FSGetFSViewerCurrentView(fsViewer);
121 FSSetFileViewMode(fView, mode);
124 void
125 FSSortOrderCB(FSViewer *fsViewer, int item, Time time)
127 FSToggleSort();
128 FSUpdateFileViewPath(FSGetFSViewerCurrentView(fsViewer),
129 FileSync, NULL, NULL);
132 void
133 FSNewViewCB(FSViewer *fsViewer, int item, Time time)
135 FSFileView *fView = FSGetFSViewerCurrentView(fsViewer);
137 if (!(FSCreateFileView(fsViewer, FSGetFileViewPath(fView), False)))
139 WMRunAlertPanel(FSGetFSViewerScreen(fsViewer), NULL,
140 _("New View"),
141 _("Error creating New FileViewer"),
142 _("OK"), NULL, NULL);
146 void
147 FSDotFilesCB(FSViewer *fsViewer, int item, Time time)
149 FSToggleDisplayHiddenFiles();
150 FSUpdateFileViewPath(FSGetFSViewerCurrentView(fsViewer),
151 FileSync, NULL, NULL);
154 void
155 FSCopyCB(FSViewer *fsViewer, int item, Time time)
157 FileInfo *fileInfo;
159 fileInfo = fsGetFSViewerCurrentFileInfo(fsViewer);
160 FSSetFSViewerClip(fsViewer, fileInfo);
161 FSSetFSViewerClipAction(fsViewer, ClipCopy);
164 void
165 FSCutCB(FSViewer *fsViewer, int item, Time time)
167 FileInfo *fileInfo;
169 fileInfo = fsGetFSViewerCurrentFileInfo(fsViewer);
170 FSSetFSViewerClip(fsViewer, fileInfo);
171 FSSetFSViewerClipAction(fsViewer, ClipCut);
174 void
175 FSPasteCB(FSViewer *fsViewer, int item, Time time)
177 ClipAction clipAction;
178 FileInfo *dest = NULL;
179 FileInfo *src = NULL;
181 dest = fsGetFSViewerCurrentFileInfo(fsViewer);
182 src = FSGetFSViewerClip(fsViewer);
184 if(src == NULL)
185 return;
187 clipAction = FSGetFSViewerClipAction(fsViewer);
189 if(clipAction == ClipCopy)
190 FSCopy(src, dest);
191 else if(clipAction == ClipCut)
192 FSMove(src, dest);
194 FSSetFSViewerClip(fsViewer, NULL);
197 void
198 FSLinkCB(FSViewer *fsViewer, int item, Time time)
200 char *new = NULL;
201 char *old = NULL;
202 FileInfo *src;
203 FileInfo *dest = FSCreateFileInfo();
205 src = fsGetFSViewerCurrentFileInfo(fsViewer);
206 old = GetPathnameFromPathName(src->path, src->name);
207 new = WMRunInputPanel(FSGetFSViewerScreen(fsViewer), NULL,
208 _("Link Name"), _("Link: Enter the link name"),
209 old, _("OK"), _("Cancel"));
211 if(new != NULL)
213 dest->path = GetPathFromPathname(new);
214 dest->name= GetNameFromPathname(new);
215 FSLink(src, dest);
218 if(new != NULL)
219 free(new);
220 if(old != NULL)
221 free(old);
224 void
225 FSRenameCB(FSViewer *fsViewer, int item, Time time)
227 char *new = NULL;
228 char *old = NULL;
229 FileInfo *src;
230 FileInfo *dest = FSCreateFileInfo();
232 src = fsGetFSViewerCurrentFileInfo(fsViewer);
233 old = GetPathnameFromPathName(src->path, src->name);
234 new = WMRunInputPanel(FSGetFSViewerScreen(fsViewer), NULL,
235 _("Rename File"), _("Rename: Enter the new file name"),
236 old, _("OK"), _("Cancel"));
238 if(new != NULL)
240 dest->path = GetPathFromPathname(new);
241 dest->name = GetNameFromPathname(new);
242 FSRename(src, dest);
245 if(new != NULL)
246 free(new);
247 if(old != NULL)
248 free(old);
252 void
253 FSDeleteCB(FSViewer *fsViewer, int item, Time time)
255 FileInfo *fileInfo;
257 fileInfo = fsGetFSViewerCurrentFileInfo(fsViewer);
259 FSDelete(fileInfo);
262 void
263 FSNewFileCB(FSViewer *fsViewer, int item, Time time)
265 char *new = NULL;
266 char *initPath = NULL;
267 FileInfo *fileInfo;
268 mode_t umask = FSGetUMask();
270 fileInfo = fsGetFSViewerCurrentFileInfo(fsViewer);
272 if(isDirectory(fileInfo->fileType))
274 initPath = GetPathnameFromPathName(fileInfo->path, fileInfo->name);
276 else
278 initPath = wstrdup(fileInfo->path);
281 new = WMRunInputPanel(FSGetFSViewerScreen(fsViewer), NULL,
282 _("Create a new file"),
283 _("New File: Enter the new file name"),
284 GetPathnameFromPathName(initPath, ""),
285 _("OK"), _("Cancel"));
287 if(new)
289 if(FSCreateNewFile(new, umask & 0777))
291 char s[0xff];
293 sprintf(s, _("Error creating file %s"), new);
294 FSErrorDialog(_("File Operation Error"), s);
296 else
298 FileInfo *src = FSCreateFileInfo();
299 FileInfo *dest = FSGetFileInfo(new);
301 FSUpdateFileView(FileCopy, src, dest);
302 if(src)
303 FSFreeFileInfo(src);
304 if(dest)
305 FSFreeFileInfo(dest);
309 if(new)
310 free(new);
311 if(initPath)
312 free(initPath);
316 void
317 FSNewDirCB(FSViewer *fsViewer, int item, Time time)
319 char *new = NULL;
320 char *initPath = NULL;
321 FileInfo *fileInfo;
322 mode_t umask = FSGetUMask();
324 fileInfo = fsGetFSViewerCurrentFileInfo(fsViewer);
326 if(isDirectory(fileInfo->fileType))
328 initPath = GetPathnameFromPathName(fileInfo->path, fileInfo->name);
330 else
332 initPath = wstrdup(fileInfo->path);
335 new = WMRunInputPanel(FSGetFSViewerScreen(fsViewer), NULL,
336 _("Create a new directory"),
337 _("New Dir: Enter the new directory name"),
338 GetPathnameFromPathName(initPath, ""),
339 _("OK"), _("Cancel"));
341 if(new)
343 if (FSCreateNewDirectory(new, umask & 0777))
345 char s[0xff];
347 sprintf(s, _("Error creating folder %s"), new);
348 FSErrorDialog(_("File Operation Error"), s);
350 else
352 FileInfo *src = FSCreateFileInfo();
353 FileInfo *dest = FSGetFileInfo(new);
355 src->name = dest->name;
356 dest->name = wstrdup("");
357 FSUpdateFileView(FileCopy, src, dest);
358 if(src)
359 FSFreeFileInfo(src);
360 if(dest)
361 FSFreeFileInfo(dest);
365 if(new)
366 free(new);
367 if(initPath)
368 free(initPath);
371 void
372 FSConsoleCB(FSViewer *fsViewer, int item, Time time)
374 FileInfo *fileInfo;
375 FileInfo *pathInfo;
377 fileInfo = FSCreateFileInfo();
379 fileInfo->name = (char *) wmalloc(8);
380 strcpy(fileInfo->name, "CONSOLE");
382 pathInfo = fsGetFSViewerCurrentFileInfo(fsViewer);
384 if(isDirectory(pathInfo->fileType))
386 fileInfo->path = GetPathnameFromPathName(pathInfo->path,
387 pathInfo->name);
389 else
391 fileInfo->path = pathInfo->path;
394 LaunchApp(fsViewer, fileInfo, AppExec);
396 if(pathInfo)
397 FSFreeFileInfo(pathInfo);
398 if(fileInfo)
399 FSFreeFileInfo(fileInfo);
403 void
404 FSFilterViewCB(FSViewer *fsViewer, int item, Time time)
406 char *filter = NULL;
407 char *init = NULL;
408 char *title = _("Filter Current FileView");
409 char *prompt = _("Enter Filter Value:");
410 FSFileView *fView = NULL;
412 fView = FSGetFSViewerCurrentView(fsViewer);
413 init = FSGetFileViewFilter(fView);
414 if((filter = WMRunInputPanel(FSGetFSViewerScreen(fsViewer),
415 FSGetFileViewWindow(fView),
416 title, prompt, init, _("OK"), _("Cancel"))) != NULL)
418 if(strcmp("", filter) == 0)
419 filter = NULL;
421 FSSetFileViewFilter(fView, filter);
423 if(filter)
424 free(filter);
428 void
429 FSSelectAllCB(FSViewer *fsViewer, int item, Time time)
431 WMRunAlertPanel(FSGetFSViewerScreen(fsViewer), NULL, _("Menu Error"),
432 _("This menu option has not yet been implemented"),
433 _("OK"), NULL, NULL);
436 void
437 FSDeselectAllCB(FSViewer *fsViewer, int item, Time time)
439 WMRunAlertPanel(FSGetFSViewerScreen(fsViewer), NULL, _("Menu Error"),
440 _("This menu option has not yet been implemented"),
441 _("OK"), NULL, NULL);
444 void
445 FSMountCB(Disk *disk, int item, Time time)
447 int noerror = 1;
448 char *execStr = NULL;
449 /* char *cmd = FSGetStringForNameKey("DISKS", "mount"); */
451 /* if(cmd) */
452 if(disk->mntCmd)
454 /* execStr = FSParseExecString(disk->point, cmd); */
455 execStr = FSParseExecString(disk->point, disk->mntCmd);
457 if(execStr)
459 noerror = execCommand(execStr);
460 free(execStr);
462 else
463 noerror = 0;
464 /* free(cmd); */
466 else
467 noerror = 0;
469 if(!noerror)
471 char s[0xff];
473 sprintf(s, "Unable to mount \"%s\"", disk->name);
474 WMRunAlertPanel(FSGetFSViewerScreen(disk->app), NULL, _("Exec Error"),
475 s, _("OK"), NULL, NULL);
479 void
480 FSUnmountCB(Disk *disk, int item, Time time)
482 int noerror = 1;
483 char *execStr = NULL;
484 /* char *cmd = FSGetStringForNameKey("DISKS", "umount"); */
486 /* if(cmd) */
487 if(disk->umntCmd)
489 /* execStr = FSParseExecString(disk->point, cmd); */
490 execStr = FSParseExecString(disk->point, disk->umntCmd);
492 if(execStr)
494 noerror = execCommand(execStr);
495 free(execStr);
497 else
498 noerror = 0;
499 /* free(cmd); */
501 else
502 noerror = 0;
504 if(!noerror)
506 char s[0xff];
508 sprintf(s, "Unable to unmount \"%s\"", disk->name);
509 WMRunAlertPanel(FSGetFSViewerScreen(disk->app), NULL, _("Exec Error"),
510 s, _("OK"), NULL, NULL);
514 void
515 FSEjectCB(Disk *disk, int item, Time time)
517 int noerror = 1;
518 char *execStr = NULL;
519 /* char *cmd = FSGetStringForNameKey("DISKS", "eject"); */
521 /* if(cmd) */
522 if(disk->ejectCmd)
524 /* execStr = FSParseExecString(disk->device, cmd); */
525 execStr = FSParseExecString(disk->device, disk->ejectCmd);
527 if(execStr)
529 noerror = execCommand(execStr);
530 free(execStr);
532 else
533 noerror = 0;
534 /* free(cmd); */
536 else
537 noerror = 0;
539 if(!noerror)
541 char s[0xff];
543 sprintf(s, "Unable to eject \"%s\"", disk->name);
544 WMRunAlertPanel(FSGetFSViewerScreen(disk->app), NULL, _("Exec Error"),
545 s, _("OK"), NULL, NULL);
549 void
550 FSCloseDiskCB(Disk *disk, int item, Time time)
552 int noerror = 1;
553 char *execStr = NULL;
554 /* char *cmd = FSGetStringForNameKey("DISKS", "eject"); */
556 /* if(cmd) */
557 if(disk->closeCmd)
559 /* execStr = FSParseExecString(disk->device, cmd); */
560 execStr = FSParseExecString(disk->point, disk->closeCmd);
562 if(execStr)
564 noerror = execCommand(execStr);
565 free(execStr);
567 else
568 noerror = 0;
569 /* free(cmd); */
571 else
572 noerror = 0;
574 if(!noerror)
576 char s[0xff];
578 sprintf(s, "Unable to close \"%s\"", disk->name);
579 WMRunAlertPanel(FSGetFSViewerScreen(disk->app), NULL, _("Exec Error"),
580 s, _("OK"), NULL, NULL);
584 void
585 FSFinderCB(FSViewer *fsViewer, int item, Time time)
587 if(!FSGetFSViewerFinder(fsViewer))
589 if(!FSCreateFinder(fsViewer))
590 wwarning(_("%s %d: Unable to create FSFinder"),
591 __FILE__, __LINE__);
593 else
596 * Should check if the window is minimized or covered
597 * and bring it into view.
603 void
604 FSMiniaturizeCB(FSViewer *fsViewer, int item, Time time)
606 WMRunAlertPanel(FSGetFSViewerScreen(fsViewer), NULL, _("Menu Info"),
607 _("This option is only available via the window manager."),
608 _("OK"), NULL, NULL);
611 void
612 FSOpenAsFolderCB(FSViewer *fsViewer, int item, Time time)
614 WMRunAlertPanel(FSGetFSViewerScreen(fsViewer), NULL, _("Menu Error"),
615 _("This menu option has not yet been implemented"),
616 _("OK"), NULL, NULL);
619 void
620 FSProcessCB(FSViewer *fsViewer, int item, Time time)
622 FileInfo *fileInfo;
623 FileInfo *pathInfo;
625 fileInfo = FSCreateFileInfo();
627 fileInfo->name = (char *) wmalloc(8);
628 strcpy(fileInfo->name, "PROCESS");
630 pathInfo = fsGetFSViewerCurrentFileInfo(fsViewer);
632 if(isDirectory(pathInfo->fileType))
634 fileInfo->path = GetPathnameFromPathName(pathInfo->path,
635 pathInfo->name);
637 else
639 fileInfo->path = pathInfo->path;
642 LaunchApp(fsViewer, fileInfo, AppExec);
644 if(pathInfo)
645 FSFreeFileInfo(pathInfo);
646 if(fileInfo)
647 FSFreeFileInfo(fileInfo);
651 void
652 FSHelpCB(FSViewer *fsViewer, int item, Time time)
654 WMRunAlertPanel(FSGetFSViewerScreen(fsViewer), NULL, _("Menu Error"),
655 _("This menu option has not yet been implemented"),
656 _("OK"), NULL, NULL);
659 void
660 FSCloseWindowCB(FSViewer *fsViewer, int item, Time time)
662 FSFileView *fView = NULL;
664 fView = FSGetFSViewerCurrentView(fsViewer);
665 if(!FSIsFileViewPrimary(fView))
666 WMCloseWindow(FSGetFileViewWindow(fView));
669 void
670 FSUpdateViewCB(FSViewer *fsViewer, int item, Time time)
672 FSFileView *fView = NULL;
674 fView = FSGetFSViewerCurrentView(fsViewer);
675 FSUpdateFileViewPath(fView, FileSync, NULL, NULL);
678 void
679 FSDuplicateCB(FSViewer *fsViewer, int item, Time time)
681 ClipAction clipAction;
682 FileInfo *dest = FSCreateFileInfo();
683 FileInfo *src = NULL;
685 src = fsGetFSViewerCurrentFileInfo(fsViewer);
686 FSCopyFileInfo(src, dest);
688 dest->name = (char *) wrealloc(dest->name, strlen(src->name)+7);
689 strcpy(dest->name, "copyof");
690 strcat(dest->name, src->name);
692 if(isDirectory(src->fileType))
694 char *new = NULL;
695 mode_t umask = FSGetUMask();
697 new = GetPathnameFromPathName(dest->path, dest->name);
698 if (new && FSCreateNewDirectory(new, umask & 0777))
700 char s[0xff];
702 sprintf(s, _("Error creating folder %s"), new);
703 FSErrorDialog(_("File Operation Error"), s);
705 if(new)
706 free(new);
709 FSCopy(src, dest);
712 void
713 FSCompressCB(FSViewer *fsViewer, int item, Time time)
715 int error = 0;
716 char *cmd = FSGetStringForNameKey("COMPRESS", "exec");
717 char *extn = FSGetStringForNameKey("COMPRESS", "extn");
719 if(!extn)
720 extn = wstrdup(".tar.gz");
722 if(cmd)
724 char *targz = NULL;
725 char *execStr = NULL;
726 char *pathname = NULL;
727 FileInfo *src = NULL;
729 src = fsGetFSViewerCurrentFileInfo(fsViewer);
730 pathname = GetPathnameFromPathName(src->path, src->name);
731 targz = (char *) wmalloc(strlen(src->name)+strlen(extn)+1);
733 strcpy(targz, src->name);
734 strcat(targz, extn);
736 execStr = (char *) wmalloc(strlen(cmd) + strlen(src->name) +
737 strlen(targz) + 1);
739 sprintf(execStr, cmd, targz, src->name);
741 if(execStr)
743 error = FSExecCommand(src->path, execStr);
744 free(execStr);
746 else
747 error = 1;
748 free(cmd);
750 else
751 error = 1;
753 if(error)
755 char s[0xff];
757 sprintf(s, _("Unable to compress selection."));
758 WMRunAlertPanel(FSGetFSViewerScreen(fsViewer), NULL, _("Exec Error"),
759 s, _("OK"), NULL, NULL);
762 if(extn)
763 free(extn);
766 void
767 FSEmptyRecyclerCB(FSViewer *fsViewer, int item, Time time)
769 WMRunAlertPanel(FSGetFSViewerScreen(fsViewer), NULL, _("Menu Error"),
770 _("This menu option has not yet been implemented"),
771 _("OK"), NULL, NULL);
774 static void
775 FSAddDisksMenu(FSViewer *fsViewer, WMMenu *menu)
777 WMMenu *submenu = NULL;
778 char *cmd = NULL;
779 WMPropList* devArray = NULL;
780 WMPropList* array = NULL;
782 /* devArray = FSGetArrayForNameKey("DISKS", "devices"); */
783 devArray = FSGetUDObjectForKey(defaultsDB, "DISCS");
785 if(devArray)
787 int i, numElem;
788 WMPropList* tmp;
790 numElem = WMGetPropListItemCount(devArray);
791 for(i = 0; i < numElem; i++)
793 array = WMGetFromPLArray(devArray, i);
794 if(array && WMIsPLArray(array))
796 Disk *disk = NULL;
798 disk = (Disk *) wmalloc(sizeof(Disk));
799 memset(disk, 0, sizeof(Disk));
801 disk->app = fsViewer;
802 tmp = WMGetFromPLArray(array, 0);
803 if(WMIsPLString(tmp))
804 disk->name = wstrdup(WMGetFromPLString(tmp));
806 tmp = WMGetFromPLArray(array, 1);
807 if(WMIsPLString(tmp))
808 disk->point = wstrdup(WMGetFromPLString(tmp));
810 tmp = WMGetFromPLArray(array, 2);
811 if(WMIsPLString(tmp))
812 disk->device = wstrdup(WMGetFromPLString(tmp));
814 tmp = WMGetFromPLArray(array, 3);
815 if(WMIsPLString(tmp))
816 disk->mntCmd = wstrdup(WMGetFromPLString(tmp));
818 tmp = WMGetFromPLArray(array, 4);
819 if(WMIsPLString(tmp))
820 disk->umntCmd = wstrdup(WMGetFromPLString(tmp));
822 tmp = WMGetFromPLArray(array, 5);
823 if(WMIsPLString(tmp))
824 disk->ejectCmd = wstrdup(WMGetFromPLString(tmp));
826 tmp = WMGetFromPLArray(array, 6);
827 if(WMIsPLString(tmp))
828 disk->closeCmd = wstrdup(WMGetFromPLString(tmp));
830 if(disk->name)
832 submenu = WMMenuCreate(fsViewer->wmContext, disk->name);
833 WMMenuAddSubmenu(menu, disk->name, submenu);
834 WMMenuAddItem(submenu, _("Mount"),
835 (WMMenuAction)FSMountCB, disk, NULL, NULL);
836 WMMenuAddItem(submenu, _("Unmount"),
837 (WMMenuAction)FSUnmountCB, disk, NULL, NULL);
838 WMMenuAddItem(submenu, _("Eject"),
839 (WMMenuAction)FSEjectCB, disk, NULL, NULL);
840 WMMenuAddItem(submenu, _("Close"),
841 (WMMenuAction)FSCloseDiskCB, disk, NULL, NULL);
848 void
849 FSCreateMenu(FSViewer *fsViewer)
851 int i;
852 WMMenu *submenu;
854 fsViewer->menu = WMMenuCreate(fsViewer->wmContext, "FSViewer");
856 /* Info Menu */
857 submenu = WMMenuCreate(fsViewer->wmContext, _("Info"));
858 WMMenuAddSubmenu(fsViewer->menu, _("Info"), submenu);
859 WMMenuAddItem(submenu, _("Info Panel..."),
860 (WMMenuAction)FSInfoPanelCB, fsViewer, NULL, NULL);
861 WMMenuAddItem(submenu, _("Legal..."),
862 (WMMenuAction)FSLegalCB, fsViewer, NULL, NULL);
863 WMMenuAddItem(submenu, _("Preferences..."),
864 (WMMenuAction)FSPrefCB, fsViewer, NULL, NULL);
865 /* WMMenuAddItem(submenu, _("WM Preferences..."), */
866 /* (WMMenuAction)FSWMPrefCB, fsViewer, NULL, NULL); */
867 i = WMMenuAddItem(submenu, _("Help..."),
868 (WMMenuAction)FSHelpCB, fsViewer, NULL, "?");
869 /* WMMenuSetEnabled(submenu, i, 0); */
871 /* File Menu */
872 submenu = WMMenuCreate(fsViewer->wmContext, _("File"));
873 WMMenuAddSubmenu(fsViewer->menu, _("File"), submenu);
874 i = WMMenuAddItem(submenu, _("Open"),
875 (WMMenuAction)FSViewCB, fsViewer, NULL, "o");
876 /* WMMenuSetEnabled(submenu, i, 0); */
877 i = WMMenuAddItem(submenu, _("Open as Folder"),
878 (WMMenuAction)FSOpenAsFolderCB, fsViewer, NULL, "O");
879 /* WMMenuSetEnabled(submenu, i, 0); */
880 WMMenuAddItem(submenu, _("New Folder"),
881 (WMMenuAction)FSNewDirCB, fsViewer, NULL, "n");
882 i = WMMenuAddItem(submenu, _("Duplicate"),
883 (WMMenuAction)FSDuplicateCB, fsViewer, NULL, "d");
884 /* WMMenuSetEnabled(submenu, i, 0); */
885 i = WMMenuAddItem(submenu, _("Compress"),
886 (WMMenuAction)FSCompressCB, fsViewer, NULL, NULL);
887 /* WMMenuSetEnabled(submenu, i, 0); */
888 i = WMMenuAddItem(submenu, _("UnCompress"),
889 (WMMenuAction)FSViewCB, fsViewer, NULL, NULL);
890 /* WMMenuSetEnabled(submenu, i, 0); */
891 i = WMMenuAddItem(submenu, _("Destroy"),
892 (WMMenuAction)FSDeleteCB, fsViewer, NULL, "r");
893 /* WMMenuSetEnabled(submenu, i, 0); */
894 i = WMMenuAddItem(submenu, _("Empty Recycler"),
895 (WMMenuAction)FSEmptyRecyclerCB, fsViewer, NULL, NULL);
896 /* WMMenuSetEnabled(submenu, i, 0); */
898 /* Edit Menu */
899 submenu = WMMenuCreate(fsViewer->wmContext, _("Edit"));
900 WMMenuAddSubmenu(fsViewer->menu, _("Edit"), submenu);
901 WMMenuAddItem(submenu, _("Cut"),
902 (WMMenuAction)FSCutCB, fsViewer, NULL, "x");
903 WMMenuAddItem(submenu, _("Copy"),
904 (WMMenuAction)FSCopyCB, fsViewer, NULL, "c");
905 WMMenuAddItem(submenu, _("Paste"),
906 (WMMenuAction)FSPasteCB, fsViewer, NULL, "v");
907 WMMenuAddItem(submenu, _("Delete"),
908 (WMMenuAction)FSDeleteCB, fsViewer, NULL, NULL);
909 i = WMMenuAddItem(submenu, _("Select All"),
910 (WMMenuAction)FSSelectAllCB, fsViewer, NULL, "a");
911 /* WMMenuSetEnabled(submenu, i, 0); */
912 i = WMMenuAddItem(submenu, _("DeSelect All"),
913 (WMMenuAction)FSDeselectAllCB, fsViewer, NULL, NULL);
914 /* WMMenuSetEnabled(submenu, i, 0); */
916 /* Disk Menu */
917 submenu = WMMenuCreate(fsViewer->wmContext, _("Disk"));
918 WMMenuAddSubmenu(fsViewer->menu, _("Disk"), submenu);
919 FSAddDisksMenu(fsViewer, submenu);
920 /* i = WMMenuAddItem(submenu, _("Eject"), */
921 /* NULL, fsViewer, NULL, "e"); */
922 /* WMMenuSetEnabled(submenu, i, 0); */
923 /* i = WMMenuAddItem(submenu, _("Initialize..."), */
924 /* NULL, fsViewer, NULL, NULL); */
925 /* WMMenuSetEnabled(submenu, i, 0); */
926 /* i = WMMenuAddItem(submenu, _("Check for Disks"), */
927 /* NULL, fsViewer, NULL, NULL); */
928 /* WMMenuSetEnabled(submenu, i, 0); */
930 /* View Menu */
931 submenu = WMMenuCreate(fsViewer->wmContext, _("View"));
932 WMMenuAddSubmenu(fsViewer->menu, _("View"), submenu);
933 WMMenuAddItem(submenu, _("Browse"),
934 (WMMenuAction)FSBrowseCB, fsViewer, NULL, "B");
935 /* Diabled Icon Menu, because it does nothing then being present */
936 i = WMMenuAddItem(submenu, _("Icon"),
937 (WMMenuAction)FSIconCB, fsViewer, NULL, "I");
938 /* WMMenuSetEnabled(submenu, i, 0); */
939 WMMenuAddItem(submenu, _("List"),
940 (WMMenuAction)FSListCB, fsViewer, NULL, "L");
941 WMMenuAddItem(submenu, _("Sort"),
942 (WMMenuAction)FSSortOrderCB, fsViewer, NULL, "s");
943 /* i = WMMenuAddItem(submenu, _("Clean Up Icons"), */
944 /* NULL, fsViewer, NULL, NULL); */
945 /* WMMenuSetEnabled(submenu, i, 0); */
946 WMMenuAddItem(submenu, _("Show .files"),
947 (WMMenuAction)FSDotFilesCB, fsViewer, NULL, "D");
948 WMMenuAddItem(submenu, _("Filter..."),
949 (WMMenuAction)FSFilterViewCB, fsViewer, NULL, "f");
950 WMMenuAddItem(submenu, _("New Viewer..."),
951 (WMMenuAction)FSNewViewCB, fsViewer, NULL, "N");
952 WMMenuAddItem(submenu, _("Update View"),
953 (WMMenuAction)FSUpdateViewCB, fsViewer, NULL, "u");
955 /* Tools Menu */
956 submenu = WMMenuCreate(fsViewer->wmContext, _("Tools"));
957 WMMenuAddSubmenu(fsViewer->menu, _("Tools"), submenu);
958 WMMenuAddItem(submenu, _("Inspector..."),
959 (WMMenuAction)FSInspectorCB, fsViewer, NULL, "i");
960 i = WMMenuAddItem(submenu, _("Finder"),
961 (WMMenuAction)FSFinderCB, fsViewer, NULL, "F");
962 /* WMMenuSetEnabled(submenu, i, 0); */
963 i = WMMenuAddItem(submenu, _("Processes..."),
964 (WMMenuAction)FSProcessCB, fsViewer, NULL, "P");
965 /* WMMenuSetEnabled(submenu, i, 0); */
966 WMMenuAddItem(submenu, _("Console..."),
967 (WMMenuAction)FSConsoleCB, fsViewer, NULL, "C");
969 /* Windows Menu */
970 submenu = WMMenuCreate(fsViewer->wmContext, _("Windows"));
971 WMMenuAddSubmenu(fsViewer->menu, _("Windows"), submenu);
972 /* i = WMMenuAddItem(submenu, _("Arrange in Front"), */
973 /* NULL, fsViewer, NULL, NULL); */
974 /* WMMenuSetEnabled(submenu, i, 0); */
976 * This should contain a list of the windows
977 * Problem would be how to foucs them if they are
978 * added to the submenu. Would setting the focus to
979 * a widget work?
982 * This is the standard key binding for miniaturizing windows
983 * under window maker. At this moment I can find a wmlib function
984 * to do this though I should put one together from the X functions
986 i = WMMenuAddItem(submenu, _("Miniaturize Window"),
987 (WMMenuAction)FSMiniaturizeCB, fsViewer, NULL, "m");
988 /* WMMenuSetEnabled(submenu, i, 0); */
989 i = WMMenuAddItem(submenu, _("Close Window"),
990 (WMMenuAction)FSCloseWindowCB, fsViewer, NULL, "w");
991 /* WMMenuSetEnabled(submenu, i, 0); */
993 /* Services Menu <- Custom stuff belongs here :) */
994 submenu = WMMenuCreate(fsViewer->wmContext, _("Services"));
995 WMMenuAddSubmenu(fsViewer->menu, _("Services"), submenu);
996 WMMenuAddItem(submenu, _("File Edit..."),
997 (WMMenuAction)FSEditCB, fsViewer, NULL, "E");
998 WMMenuAddItem(submenu, _("File Link..."),
999 (WMMenuAction)FSLinkCB, fsViewer, NULL, "l");
1000 WMMenuAddItem(submenu, _("File New..."),
1001 (WMMenuAction)FSNewFileCB, fsViewer, NULL, NULL);
1002 WMMenuAddItem(submenu, _("File Rename..."),
1003 (WMMenuAction)FSRenameCB, fsViewer, NULL, NULL);
1004 WMMenuAddItem(submenu, _("File Run..."),
1005 (WMMenuAction)FSRunCB, fsViewer, NULL, "R");
1006 WMMenuAddItem(submenu, _("Show Image"),
1007 (WMMenuAction)FSViewCB, fsViewer, NULL, "S");
1008 /* i = WMMenuAddItem(submenu, _("Show PDF"), */
1009 /* (WMMenuAction)FSViewCB, fsViewer, NULL, NULL); */
1010 /* WMMenuSetEnabled(submenu, i, 0); */
1012 /* Hide and Quit */
1013 WMMenuAddItem(fsViewer->menu, _("Hide"),
1014 (WMMenuAction)FSHideCB, fsViewer, NULL, "h");
1015 WMMenuAddItem(fsViewer->menu, _("Hide Others"),
1016 (WMMenuAction)FSHideOthersCB, fsViewer, NULL, NULL);
1017 WMMenuAddItem(fsViewer->menu, _("Quit"),
1018 (WMMenuAction)FSQuitCB, fsViewer, NULL, "q");
1020 WMAppSetMainMenu(fsViewer->wmContext, fsViewer->menu);
1021 WMRealizeMenus(fsViewer->wmContext);