Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ At run time, Gannet uses these:
| `bsdtar` (libarchive) and `bubblewrap` | Extracting archives and Compress to ZIP | Each says what's missing |
| `xdg-terminal-exec` | Open in terminal, in whichever terminal is set up | Open in terminal isn't offered |
| `libmpv` (part of `mpv` on many systems) and `bubblewrap` | Video and sound previews | Videos show a message saying what's needed |
| `udisks2` | Mounting, unlocking and ejecting drives | Only drives that are already mounted show |
| `udisks2` | Mounting, unlocking, ejecting and formatting drives | Only drives that are already mounted show |
| `exfatprogs`, `dosfstools`, `e2fsprogs` | Formatting a drive as exFAT, FAT32 or ext4 (udisks2 runs them) | That format is shown as unavailable, with the package it needs |
| `gvfs` | Network shares and connecting to servers: SFTP and FTP; SMB with `gvfs-smb` (which brings `smbclient`), NFS with `gvfs-nfs`, WebDAV with `gvfs-dnssd` | Connecting says GVfs isn't installed, and no shares show; an address for a missing backend says which package it needs |
| `shared-mime-info` | Saying what a file is, like "PDF document" | Previews name types like `application/pdf` |
| `poppler` (`pdfinfo`, `pdftoppm`) and `bubblewrap` | PDF previews | PDFs say what they are, or show a thumbnailer's picture |
Expand Down Expand Up @@ -483,6 +484,20 @@ This goes through udisks2, which most Linux desktops run. Polkit decides what's
asks for a password if the system says to. Before acting on a drive, Gannet checks it's still
the one you picked, as another stick put in can take the same place.

To reuse a stick or card, right-click it and choose **Format…**. Give it a name, and pick exFAT
(the default, for Windows, macOS and Linux, and files of any size), FAT32 (for older devices,
files up to 4 GB) or ext4 (Linux only). The dialog says what will be erased: the drive by make
and size, and each partition on it with how much it holds. The keyboard starts on Cancel, and
Enter never erases: choose Erase and Format with the pointer, or Tab to it and press Space.
The system then asks for your password. The whole drive gets a new partition table and one
partition, which is mounted when it's done. Cancelling at the password prompt, or stopping the
job before the erasing starts, leaves everything as it was and mounts again what was mounted;
an unlocked encrypted partition stays locked, and Gannet says so. Format is only offered for
drives that can come out, never for one udisks2 marks as the system's, one the system is
mounted from or swaps to, or the stick a live or installer system is running from (including
one, like Ventoy's, that it maps without mounting). If erasing fails partway, as when the drive
is pulled out, Gannet says it may have been erased.

## Network shares

To connect to a server, type its address in the path bar (Ctrl+L), like
Expand Down
48 changes: 42 additions & 6 deletions crates/app/src/a11y.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ pub const SERVER_USER: u64 = 37;
pub const SERVER_DOMAIN: u64 = 38;
/// The recent servers offered under the path bar, and each by its place among them.
pub const SUGGESTIONS: u64 = 39;
/// The format dialog's name, its group of formats, and each format by its place in
/// `FsKind::ALL`.
pub const FORMAT_NAME: u64 = 40;
pub const FORMAT_KINDS: u64 = 41;
pub const FORMAT_KIND0: u64 = 42;
pub const SUGGESTION0: u64 = 1 << 21;
pub const MENU_ITEM0: u64 = 1 << 17;
pub const DIALOG_BUTTON0: u64 = 1 << 18;
Expand Down Expand Up @@ -136,6 +141,8 @@ pub enum Role {
PasswordText,
Menu,
MenuItem,
/// One of a group of choices, of which one is picked: its `checked`.
RadioButton,
}

/// A thing a part does when a screen reader asks: its name and description, as AT-SPI has
Expand Down Expand Up @@ -1058,13 +1065,14 @@ fn dialog(app: &mut App) -> Option<(Vec<Node>, Modal, u64)> {
let r = app.dialog_rect_for(&d);
let (title, message) = app.dialog_text(&d);
let rects = app.dialog_button_rects(&d);
let default = DIALOG_BUTTON0 + App::dialog_default(&d) as u64;
// The format dialog has no default while the keyboard isn't on Cancel.
let default = Some(App::dialog_default(&d)).filter(|&i| i < App::dialog_buttons(&d).len()).map(|i| DIALOG_BUTTON0 + i as u64);
// A question a job just asked, as a clash, takes no answer for a moment, as with the
// keyboard and the pointer, but its buttons aren't drawn as unavailable meanwhile, and aren't
// said to be: a screen reader would read "grayed" as the dialog opens, and never hear that
// it's over. The server refuses a press meanwhile, as the app would drop it.
let mut parts = Vec::new();
let mut has = default;
let mut has = default.unwrap_or(DIALOG);
match &d {
Dialog::Conflict { apply_to_all, .. } => {
let mut check = Node::new(DIALOG_CHECK, Role::CheckBox, "Do the same for the rest", app.dialog_check_rect(), DIALOG).doing(Action::new("toggle", "Answer the rest the same way", "a"));
Expand Down Expand Up @@ -1110,6 +1118,32 @@ fn dialog(app: &mut App) -> Option<(Vec<Node>, Modal, u64)> {
Stop::Button(i) => DIALOG_BUTTON0 + i as u64,
};
}
Dialog::Format(a) => {
use crate::format_drive::Stop;
let l = app.format_layout(a);
// The name, described by why it can't be used or by the format's rule for names, so
// the error is heard with the field it's about.
let mut name = Node::new(FORMAT_NAME, Role::Entry, "Name", l.name, DIALOG).described(a.name_line());
name.field = Some(a.name.clone());
let kinds: Vec<Node> = gannet_core::disks::FsKind::ALL
.into_iter()
.zip(&l.kinds)
.enumerate()
.map(|(i, (kind, rect))| {
let mut n = Node::new(FORMAT_KIND0 + i as u64, Role::RadioButton, kind.name(), *rect, FORMAT_KINDS).described(a.note(kind)).enabled(a.missing(kind).is_none()).doing(click("Choose it", ""));
n.checked = Some(a.kind == kind);
n
})
.collect();
let group = Rect::new(l.kinds_label.x, l.kinds_label.y, l.name.right() - l.kinds_label.x, l.kinds.iter().map(|r| r.h).sum());
parts.extend([name, Node::new(FORMAT_KINDS, Role::Panel, "Format", group, DIALOG).with_children(kinds.iter().map(|n| n.id).collect())]);
parts.extend(kinds);
has = match a.focus {
Stop::Name => FORMAT_NAME,
Stop::Kind => FORMAT_KIND0 + gannet_core::disks::FsKind::ALL.iter().position(|k| *k == a.kind).unwrap_or(0) as u64,
Stop::Button(i) => DIALOG_BUTTON0 + i as u64,
};
}
Dialog::RenameMany(rm) => {
let l = app.rename_layout(rm.names.len());
let mut find = Node::new(RENAME_FIND, Role::Entry, "Find", l.find, DIALOG);
Expand All @@ -1135,19 +1169,21 @@ fn dialog(app: &mut App) -> Option<(Vec<Node>, Modal, u64)> {
_ => {}
}
for (i, (b, rect)) in App::dialog_buttons(&d).iter().zip(rects).enumerate() {
// The rename dialog's Rename waits until something changes and nothing clashes.
let can = !matches!(&d, Dialog::RenameMany(rm) if i == 0 && !rm.can_rename());
// The rename dialog's Rename waits until something changes and nothing clashes, and the
// format dialog's Erase and Format until the name fits the format.
let can = !matches!(&d, Dialog::RenameMany(rm) if i == 0 && !rm.can_rename()) && !matches!(&d, Dialog::Format(a) if i == 0 && a.ready().is_none());
let keys = if b.key == "Esc" { "Escape" } else { b.key };
parts.push(Node::new(DIALOG_BUTTON0 + i as u64, Role::PushButton, b.label.as_ref(), rect, DIALOG).enabled(can).doing(click("Press it", keys)));
}
// A login is a form to fill in; a question that has to be answered first is an alert.
// Formatting a drive asks before erasing it, so it's an alert, and its warning is heard.
let role = if matches!(&d, Dialog::Unlock { .. } | Dialog::RenameMany(_)) || matches!(&d, Dialog::Server(a) if a.is_login()) { Role::Dialog } else { Role::Alert };
let kids = parts.iter().filter(|n| n.parent == DIALOG).map(|n| n.id).collect();
// Lines drawn one under another are heard as one.
parts.insert(0, Node::new(DIALOG, role, title, r, FRAME).described(message.replace('\n', " ")).with_children(kids));
let asked = matches!(d, Dialog::Conflict { .. } | Dialog::Expands { .. } | Dialog::Server(_)).then(|| app.dialog_asked()).flatten();
app.dialog = Some(d);
Some((parts, Modal { id: DIALOG, default: Some(default), asked }, has))
Some((parts, Modal { id: DIALOG, default, asked }, has))
}

/// The list's columns, placed as `paint_header` draws them. Recent, the Trash and search
Expand Down Expand Up @@ -1221,7 +1257,7 @@ fn sidebar(app: &App, l: &Layout, mut places: Vec<Node>) -> (Vec<u64>, Vec<Node>
let Some(r) = app.eject_rect(i) else { continue };
let id = EJECT0 + i as u64;
let button = if let Some(v) = app.places.get(i).and_then(|p| p.volume.as_ref()) {
Node::new(id, Role::PushButton, format!("Eject {}", n.name), r, n.id).enabled(!app.drives_busy.contains(&v.block)).doing(click("Eject the drive", ""))
Node::new(id, Role::PushButton, format!("Eject {}", n.name), r, n.id).enabled(!app.drive_busy(v)).doing(click("Eject the drive", ""))
} else if let Some(share) = app.share_at(i) {
Node::new(id, Role::PushButton, format!("Disconnect {}", n.name), r, n.id).enabled(!app.shares_busy.contains(&share.path)).doing(click("Disconnect the share", ""))
} else {
Expand Down
5 changes: 3 additions & 2 deletions crates/app/src/a11y_atspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ fn role_of(r: Role) -> (u32, &'static str) {
Role::PasswordText => (40, "password text"),
Role::Menu => (33, "menu"),
Role::MenuItem => (35, "menu item"),
Role::RadioButton => (44, "radio button"),
}
}

Expand Down Expand Up @@ -600,7 +601,7 @@ impl Ctx {
Role::ListItem => on.extend([STATE_SELECTABLE, STATE_FOCUSABLE]),
Role::Menu => on.push(STATE_FOCUSABLE),
Role::PushButton => on.push(STATE_FOCUSABLE),
Role::CheckBox => on.extend([STATE_FOCUSABLE, STATE_CHECKABLE]),
Role::CheckBox | Role::RadioButton => on.extend([STATE_FOCUSABLE, STATE_CHECKABLE]),
Role::Entry => on.extend([STATE_FOCUSABLE, STATE_EDITABLE, STATE_SINGLE_LINE, STATE_SELECTABLE_TEXT]),
Role::PasswordText => on.extend([STATE_FOCUSABLE, STATE_EDITABLE, STATE_SINGLE_LINE]),
Role::MenuItem => on.extend([STATE_SELECTABLE, STATE_FOCUSABLE]),
Expand Down Expand Up @@ -820,7 +821,7 @@ impl Ctx {
Target::Fixed(n) if Self::is_place(n) => self.show_place(n, snap),
// A part of the menu or dialog that's open, which moving to picks, as the
// keyboard or pointer does.
Target::Fixed(n) if snap.modal.is_some() && n.enabled && matches!(n.role, Role::MenuItem | Role::PushButton | Role::Entry) => {
Target::Fixed(n) if snap.modal.is_some() && n.enabled && matches!(n.role, Role::MenuItem | Role::PushButton | Role::Entry | Role::RadioButton) => {
self.hub.send(Msg::A11y(Act::Focus(n.id)));
true
}
Expand Down
Loading
Loading