dtfile: Eject in the Selected menu and Command+E (t0093)

The network view's warning names Eject; now dtfile has it.  The Selected
menu carries "Eject" (mnemonic E) after "Put in Trash", and Command+E is
bound in the drawing area's translation block (Mod4<Key>e:McdeKey(@,eject)).
Both call McdeEjectSelection(): it takes the selected folders, asks
mcde_sys_disks for the mounted volume whose mountpoint is one of them, and
unmounts it through mcde_sys_disk_unmount -- never a shell, and McdeSys
refuses what the computer runs from.  No selection or no mounted volume gets
a sentence instead; a refused unmount shows mcde_sys_error() (as a user,
udisksctl asks polkit and fails without an agent -- measured).

The menu table is a fixed XtCalloc(menuItemCount): the new item made it 69
entries, so menuItemCount goes from 68 to 69 (51 to 52 without the Trash
menu).  Without that, opening the Selected menu crashed the window (the
overflow was found by the menu click, not by the build).

Catalog: set 20 messages 173 "Eject", 174 "E", 175/176 the two answers, in
dtfile.msg and the German copy.  The desktop's warning now says "Eject in
the file manager (Command+E) or Unmount in the Disk Utility"; its screenshot
docs/screenshots/leopard/Device-Removal-mcde.png is renewed.

Measured (Xvfb, a 32 MB image with one ext4 partition on /dev/loop0p1):
- as the user on :82: the Selected menu shows "Eject" and the window
  survives (0x60002d, 213x218); Command+E opens the Eject message
  "/usr/bin/udisksctl did not succeed (status 1)." -- the key reaches the
  call, polkit refuses a user.
- as root under a root ttsession on :83 (ttsession -c dtfile): selecting the
  mounted folder and Selected > Eject unmounts; findmnt then prints
  "UNMOUNTED" for /tmp/opencode/ejecttest/mnt.
- after that Eject, a simulated removal of loop0p1 in dtwm
  (MCDE_DESK_TEST_DEVICE) logs only "desktop: loop0p1 (remove)" and opens
  0 dialogs -- a volume that was put away stays quiet.
- make mcde-linux MCDE_DIRS="install programs/dtfile" and "install
  programs/localized/C/msg" exit=0; gencat reads both catalogs;
  MCDE_DIRS=plist "mcde-plist-check: ok".
This commit is contained in:
lotherk committed 2026-11-16 14:24:00 +00:00
1 parent 8b94ab17c9
commit 12fe1a192b
8 files changed
+151 -14

No files matched your search

+3 -3
View File
@@ -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)
+9 -6
View File
@@ -511,6 +511,7 @@ Shift Mod4<Key>d:McdeKey(@,desktop)\n\
Shift Mod4<Key>a:McdeKey(@,applications)\n\
Shift Mod4<Key>k:McdeKey(@,network)\n\
Mod4<Key>k:McdeKey(@,connect)\n\
Mod4<Key>e:McdeKey(@,eject)\n\
<BtnMotion>:ManagerGadgetButtonMotion()\n\
<Btn1Down>:DrawingAreaInput() ManagerGadgetArm()\n\
<Btn1Down>,<Btn1Up>: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 )
+2
View File
@@ -83,6 +83,8 @@
is being reread) not to reload icon positions from the .!dt<userid> file.
*/
#define CLEAN_UP_OP (1 << 21)
/* MCDE: Eject in the Selected menu (t0093) */
#define EJECT (1 << 22)
#define NOT_DESKTOP 0
+6
View File
@@ -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,
+118 -2
View File
@@ -86,6 +86,8 @@
#include <Dt/FileM.h>
#include <Dt/SharedProcs.h>
#include <Mcde/McdeSys.h>
#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
+5 -1
View File
@@ -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)********
+2 -2
View File
@@ -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");
@@ -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)********