diff --git a/programs/dtfile/Desktop.c b/programs/dtfile/Desktop.c index 68bc6e16..c6b2b0fb 100644 --- a/programs/dtfile/Desktop.c +++ b/programs/dtfile/Desktop.c @@ -1769,9 +1769,9 @@ OpenFolder ( /* Initially, all menubuttons are sensitive */ file_mgr_rec->menuStates = (RENAME | MOVE | DUPLICATE | LINK | TRASH | - MODIFY | CHANGEDIR | PREFERENCES | FILTER | - FIND | CREATE_DIR | CREATE_FILE | SETTINGS | - CLEAN_UP | MOVE_UP | + EJECT | MODIFY | CHANGEDIR | PREFERENCES | + FILTER | FIND | CREATE_DIR | CREATE_FILE | + SETTINGS | CLEAN_UP | MOVE_UP | HOME | CHANGE_DIR | TERMINAL); if (file_mgr_data->selected_file_count == 0) diff --git a/programs/dtfile/FileMgr.c b/programs/dtfile/FileMgr.c index e96db5ad..d8f16f8c 100644 --- a/programs/dtfile/FileMgr.c +++ b/programs/dtfile/FileMgr.c @@ -511,6 +511,7 @@ Shift Mod4d:McdeKey(@,desktop)\n\ Shift Mod4a:McdeKey(@,applications)\n\ Shift Mod4k:McdeKey(@,network)\n\ Mod4k:McdeKey(@,connect)\n\ +Mod4e:McdeKey(@,eject)\n\ :ManagerGadgetButtonMotion()\n\ :DrawingAreaInput() ManagerGadgetArm()\n\ ,:DrawingAreaInput() ManagerGadgetActivate()\n\ @@ -722,9 +723,9 @@ Create( else { file_mgr_rec->menuStates = (RENAME | MOVE | DUPLICATE | LINK | TRASH | - MODIFY | CHANGEDIR | PREFERENCES | FILTER | - FIND | CREATE_DIR | CREATE_FILE | SETTINGS | - CLEAN_UP | MOVE_UP | + EJECT | MODIFY | CHANGEDIR | PREFERENCES | + FILTER | FIND | CREATE_DIR | CREATE_FILE | + SETTINGS | CLEAN_UP | MOVE_UP | HOME | CHANGE_DIR | TERMINAL); file_mgr_rec->menu = menu = CreateMenu (mainWidget, file_mgr_rec); @@ -1942,9 +1943,9 @@ SetValues( /* Initially, all menubuttons are sensitive */ file_mgr_rec->menuStates = (RENAME | MOVE | DUPLICATE | LINK | TRASH | - MODIFY | CHANGEDIR | PREFERENCES | FILTER | - FIND | CREATE_DIR | CREATE_FILE | SETTINGS | - CLEAN_UP | MOVE_UP | + EJECT | MODIFY | CHANGEDIR | PREFERENCES | + FILTER | FIND | CREATE_DIR | CREATE_FILE | + SETTINGS | CLEAN_UP | MOVE_UP | HOME | CHANGE_DIR | TERMINAL); if(file_mgr_data != trashFileMgrData @@ -2417,6 +2418,8 @@ McdeKey( sscanf( params[0], "%p", (void **) &fileMgrRec ); if( strcmp( params[1], "connect" ) == 0 ) _McdeNetConnect( fileMgrRec ); + else if( strcmp( params[1], "eject" ) == 0 ) + McdeEjectSelection( fileMgrRec ); else if( strcmp( params[1], "info" ) == 0 ) _InfoShow( fileMgrRec ); else if( strcmp( params[1], "peek" ) == 0 ) diff --git a/programs/dtfile/FileMgr.h b/programs/dtfile/FileMgr.h index c5ca6d64..1cbf1f42 100644 --- a/programs/dtfile/FileMgr.h +++ b/programs/dtfile/FileMgr.h @@ -83,6 +83,8 @@ is being reread) not to reload icon positions from the .!dt file. */ #define CLEAN_UP_OP (1 << 21) +/* MCDE: Eject in the Selected menu (t0093) */ +#define EJECT (1 << 22) #define NOT_DESKTOP 0 diff --git a/programs/dtfile/Main.h b/programs/dtfile/Main.h index 07ca2b97..0d42ea40 100644 --- a/programs/dtfile/Main.h +++ b/programs/dtfile/Main.h @@ -1171,6 +1171,12 @@ extern void TrashFiles( Widget w, XtPointer client_data, XtPointer call_data) ; +extern void EjectFiles( + Widget w, + XtPointer client_data, + XtPointer call_data) ; +extern void McdeEjectSelection( + FileMgrRec *file_mgr_rec) ; extern void ChangeToHome( Widget w, XtPointer client_data, diff --git a/programs/dtfile/Menu.c b/programs/dtfile/Menu.c index 2a23f6f8..e7bcc621 100644 --- a/programs/dtfile/Menu.c +++ b/programs/dtfile/Menu.c @@ -86,6 +86,8 @@ #include
#include
+#include + #include "Encaps.h" #include "SharedProcs.h" #include "MultiView.h" @@ -109,9 +111,9 @@ #endif #if defined(ADD_SHOW_TRASH) -static int menuItemCount = 68; +static int menuItemCount = 69; /* 68 and MCDE's Eject (t0093) */ #else -static int menuItemCount = 51; +static int menuItemCount = 52; #endif static MenuDesc * mainMenu = NULL; static Widget * actionsPaneId = NULL; @@ -418,6 +420,18 @@ CreateMenu( mainMenu[j].name = "putInTrash"; mainMenu[j++].activateCallback = TrashFiles; + /* MCDE: Eject the mounted volume of the selection (t0093); the + * desktop's removal warning sends the person here */ + mainMenu[j].type = MENU_BUTTON; + mainMenu[j].maskBit = EJECT; + mainMenu[j].label = GETMESSAGE(20,173, "Eject"); + mainMenu[j].label = XtNewString(mainMenu[j].label); + mainMenu[j].mnemonic = GETMESSAGE(20,174, "E"); + mainMenu[j].mnemonic = XtNewString(mainMenu[j].mnemonic); + mainMenu[j].helpData = HELP_SELECTED_MENU_STR; + mainMenu[j].name = "eject"; + mainMenu[j++].activateCallback = EjectFiles; + renameBtn = &(mainMenu[j].widget); mainMenu[j].type = MENU_BUTTON; mainMenu[j].maskBit = RENAME; @@ -1342,6 +1356,108 @@ TrashFiles( +/************************************************************************ + * + * McdeEjectSelection + * Unmount the volume of the selected folder (MCDE, t0093). A volume + * is a mountpoint from mcde_sys_disks; the system's own volumes are + * refused by McdeSys. The desktop's device events rebuild the icons. + * + ************************************************************************/ + +static const McdeSysDisk * +DiskAtPath(const McdeSysDisk *d, int n, const char *path) +{ + int i; + + for (i = 0; i < n; i++) + if (d[i].mountpoint[0] != '\0' && + strcmp(d[i].mountpoint, path) == 0) + return &d[i]; + return NULL; +} + +void +McdeEjectSelection(FileMgrRec *file_mgr_rec) +{ + DialogData *dialog_data; + FileMgrData *file_mgr_data; + McdeSysDisk disks[64]; + char error[512], *title; + int nd, i, ejected = 0; + + if (file_mgr_rec == NULL) + return; + if ((dialog_data = _DtGetInstanceData((XtPointer) file_mgr_rec)) == NULL) + return; + file_mgr_data = (FileMgrData *) dialog_data->data; + title = GETMESSAGE(20,173, "Eject"); + error[0] = '\0'; + if (file_mgr_data->selected_file_count <= 0 || + file_mgr_data->selection_list == NULL) + { + _DtMessage(file_mgr_rec->shell, title, + GETMESSAGE(20,175, "Select a mounted volume to eject."), + NULL, NULL); + return; + } + nd = mcde_sys_disks(disks, 64); + for (i = 0; i < file_mgr_data->selected_file_count; i++) + { + char *path; + const McdeSysDisk *d; + + path = _DtGetSelectedFilePath(file_mgr_data->selection_list[i]); + d = path != NULL ? DiskAtPath(disks, nd, path) : NULL; + if (d != NULL) + { + if (mcde_sys_disk_unmount(d->name) == MCDE_SYS_OK) + ejected++; + else + snprintf(error, sizeof error, "%s", mcde_sys_error()); + } + if (path != NULL) + XtFree(path); + } + if (ejected > 0) + return; + if (error[0] != '\0') + _DtMessage(file_mgr_rec->shell, title, error, NULL, NULL); + else + _DtMessage(file_mgr_rec->shell, title, + GETMESSAGE(20,176, + "The selected item is not a mounted volume."), + NULL, NULL); +} + +void +EjectFiles( + Widget w, + XtPointer client_data, + XtPointer call_data ) +{ + FileMgrRec *file_mgr_rec; + Arg args[1]; + Widget mbar; + + (void) call_data; + if (client_data == 0) + mbar = XmGetPostedFromWidget(XtParent(w)); + else + mbar = XtParent(w); + if (mbar == NULL) + return; + XtSetArg(args[0], XmNuserData, &file_mgr_rec); + XtGetValues(mbar, args, 1); + /* Ignore accelerators when we're insensitive */ + if (client_data == NULL && (file_mgr_rec->menuStates & EJECT) == 0) + return; + McdeEjectSelection(file_mgr_rec); +} + + + + /************************************************************************ * * NewView diff --git a/programs/dtfile/dtfile.msg b/programs/dtfile/dtfile.msg index 159c0f44..abd62d32 100644 --- a/programs/dtfile/dtfile.msg +++ b/programs/dtfile/dtfile.msg @@ -1206,7 +1206,11 @@ $ Messages 162-172 are the Go menu of the file manager 171 Applications 172 Connect to Server... - +$ MCDE: the Selected menu's Eject (t0093), its mnemonic and the two answers +173 Eject +174 E +175 Select a mounted volume to eject. +176 The selected item is not a mounted volume. $set 21 $ ****** Module: ModAttr.c ****(developer comment only)******** diff --git a/programs/dtwm/WmMcdeDesktop.c b/programs/dtwm/WmMcdeDesktop.c index 5ca3519b..2a3a9728 100644 --- a/programs/dtwm/WmMcdeDesktop.c +++ b/programs/dtwm/WmMcdeDesktop.c @@ -1802,8 +1802,8 @@ DiskRemovedDialog(const char *device, const char *mountpoint) "The device \"%s\" was removed while it was still\n" "mounted at \"%s\".\n\n" "Data might have been lost or damaged. Before you\n" - "unplug a device, unmount it first (Disk Utility,\n" - "Unmount).", + "unplug a device, unmount it first -- Eject in the file\n" + "manager (Command+E) or Unmount in the Disk Utility.", device, mountpoint); m = XmStringCreateLocalized(text); t = XmStringCreateLocalized("Disk Not Ejected"); diff --git a/programs/localized/de_DE.UTF-8/msg/dtfile.msg b/programs/localized/de_DE.UTF-8/msg/dtfile.msg index 0b55d263..cabcb95f 100644 --- a/programs/localized/de_DE.UTF-8/msg/dtfile.msg +++ b/programs/localized/de_DE.UTF-8/msg/dtfile.msg @@ -1482,6 +1482,12 @@ $ NOTE: Message 94 is the mnemonic for the "Up" menu item 157 "Informationen zu Anwendungsmanager" +$ MCDE: Eject im Selected-Menue (t0093), die Mnemonik und die zwei Antworten +173 "Auswerfen" +174 "E" +175 "Bitte ein eingehängtes Volume auswählen." +176 "Das ausgewählte Objekt ist kein eingehängtes Volume." + $set 21 Redefine set# $ ****** Module: ModAttr.c ****(developer comment only)********