Compare commits
15 commits
d6e1572611
...
f2ca1d37a6
| Author | SHA1 | Date | |
|---|---|---|---|
| f2ca1d37a6 | |||
| 50e0f5a19c | |||
|
|
f4546017a9 | ||
|
|
55a6f46f73 | ||
|
|
a84524ef70 | ||
|
|
2480d5cb0d | ||
|
|
98778333f4 | ||
|
|
0331bf550c | ||
| dcd936f7dd | |||
| 9dbe3a378d | |||
| 36ade6cf65 | |||
| d6c245d809 | |||
| 17490bfbca | |||
| 54862ba701 | |||
|
|
f1b1f8d799 |
34 changed files with 977 additions and 453 deletions
433
Cargo.lock
generated
433
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
37
Cargo.toml
37
Cargo.toml
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "cosmic-files"
|
||||
version = "1.0.13"
|
||||
version = "1.0.14"
|
||||
authors = ["Jeremy Soller <jeremy@system76.com>"]
|
||||
edition = "2024"
|
||||
license = "GPL-3.0-only"
|
||||
|
|
@ -11,7 +11,7 @@ anyhow = "1"
|
|||
jiff = "0.2"
|
||||
jiff-icu = "0.2"
|
||||
icu = { version = "2.2.0", features = ["compiled_data"] }
|
||||
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "160b086", optional = true }
|
||||
cctk = { path = "../cosmic-protocols/client-toolkit", package = "cosmic-client-toolkit", optional = true }
|
||||
cosmic-mime-apps = { git = "https://github.com/pop-os/cosmic-mime-apps.git", optional = true }
|
||||
dirs = "6.0.0"
|
||||
gio = { version = "0.21", optional = true }
|
||||
|
|
@ -73,8 +73,9 @@ version = "0.18"
|
|||
default-features = false
|
||||
features = ["fs", "io", "macros", "polling", "runtime"]
|
||||
|
||||
[dependencies.libcosmic]
|
||||
git = "https://github.com/pop-os/libcosmic.git"
|
||||
# Yoda fork — depend on libcosmic-yoda directly by path (no git/no patch).
|
||||
[dependencies.libcosmic-yoda]
|
||||
path = "../libcosmic"
|
||||
default-features = false
|
||||
#TODO: a11y feature crashes
|
||||
features = [
|
||||
|
|
@ -83,7 +84,7 @@ features = [
|
|||
"autosize",
|
||||
"multi-window",
|
||||
"tokio",
|
||||
"winit",
|
||||
"wayland",
|
||||
"surface-message",
|
||||
]
|
||||
|
||||
|
|
@ -111,15 +112,15 @@ default = [
|
|||
"wayland",
|
||||
"wgpu",
|
||||
]
|
||||
dbus-config = ["libcosmic/dbus-config"]
|
||||
desktop = ["libcosmic/desktop", "dep:cosmic-mime-apps", "dep:xdg"]
|
||||
dbus-config = ["libcosmic-yoda/dbus-config"]
|
||||
desktop = ["libcosmic-yoda/desktop", "dep:cosmic-mime-apps", "dep:xdg"]
|
||||
desktop-applet = []
|
||||
gvfs = ["dep:gio", "dep:glib"]
|
||||
io-uring = ["compio/io-uring"]
|
||||
jemalloc = ["dep:tikv-jemallocator"]
|
||||
notify = ["dep:notify-rust"]
|
||||
wayland = ["libcosmic/wayland", "dep:cctk", "dep:wayland-client"]
|
||||
wgpu = ["libcosmic/wgpu"]
|
||||
wayland = ["libcosmic-yoda/wayland", "dep:cctk", "dep:wayland-client"]
|
||||
wgpu = ["libcosmic-yoda/wgpu"]
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
|
|
@ -145,20 +146,12 @@ fastrand = "2"
|
|||
test-log = "0.2"
|
||||
tokio = { version = "1", features = ["rt", "macros"] }
|
||||
|
||||
# [patch.'https://github.com/pop-os/cosmic-text']
|
||||
# cosmic-text = { path = "../cosmic-text" }
|
||||
# Yoda fork — libcosmic dep is now a direct path dep (libcosmic-yoda above),
|
||||
# no [patch] block needed anymore. Keeping the block below would be a no-op
|
||||
# since nothing in the dep graph still asks for pop-os/libcosmic.git.
|
||||
|
||||
# [patch.'https://github.com/pop-os/libcosmic']
|
||||
# libcosmic = { path = "../libcosmic" }
|
||||
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
||||
# cosmic-theme = { path = "../libcosmic/cosmic-theme" }
|
||||
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "iced-rebase" }
|
||||
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "iced-rebase" }
|
||||
# cosmic-theme = { git = "https://github.com/pop-os/libcosmic//", branch = "iced-rebase" }
|
||||
|
||||
|
||||
# [patch.'https://github.com/pop-os/smithay-clipboard']
|
||||
# smithay-clipboard = { path = "../smithay-clipboard" }
|
||||
[patch.'https://github.com/pop-os/cosmic-text.git']
|
||||
cosmic-text = { path = "../cosmic-text" }
|
||||
|
||||
[workspace]
|
||||
members = ["cosmic-files-applet"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "cosmic-files-applet"
|
||||
version = "1.0.13"
|
||||
version = "1.0.14"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
|||
6
debian/changelog
vendored
6
debian/changelog
vendored
|
|
@ -1,3 +1,9 @@
|
|||
cosmic-files (1.0.14) noble; urgency=medium
|
||||
|
||||
* Epoch 1.0.14 version update
|
||||
|
||||
-- Jeremy Soller <jeremy@system76.com> Tue, 26 May 2026 08:30:59 -0600
|
||||
|
||||
cosmic-files (1.0.13) noble; urgency=medium
|
||||
|
||||
* Epoch 1.0.13 version update
|
||||
|
|
|
|||
78
docs/local-performance-and-portal-notes.md
Normal file
78
docs/local-performance-and-portal-notes.md
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# Local performance and portal notes
|
||||
|
||||
Date: 2026-05-05
|
||||
|
||||
This repository carries a local patch aimed at improving initial directory
|
||||
display latency in large folders, plus a system-level workaround for a COSMIC
|
||||
portal FileChooser crash observed with Firefox and Chromium.
|
||||
|
||||
## Directory listing latency
|
||||
|
||||
The slow path was the initial construction of `Item` values in `src/tab.rs`.
|
||||
On a test folder with about 2000 entries, raw filesystem enumeration and stat
|
||||
calls completed in a few milliseconds, while COSMIC Files took multiple seconds
|
||||
before showing the directory.
|
||||
|
||||
The local patch keeps initial item construction cheap:
|
||||
|
||||
- directory child counts are no longer computed synchronously in
|
||||
`item_from_entry` and `item_from_gvfs_info`;
|
||||
- initial MIME detection uses extension-based `mime_guess`;
|
||||
- regular files use a generic file icon during the initial scan instead of
|
||||
resolving the full MIME icon immediately.
|
||||
|
||||
This keeps folders and `.desktop` files special-cased, while avoiding expensive
|
||||
per-file work for ordinary files during first paint.
|
||||
|
||||
Measured locally during investigation:
|
||||
|
||||
- before the MIME/icon changes: about 3.1 seconds for `~/Téléchargements`;
|
||||
- after avoiding full MIME icon resolution during scan: below the temporary
|
||||
100 ms perf-log threshold for the same folder.
|
||||
|
||||
## File chooser portal workaround
|
||||
|
||||
Firefox and Chromium were failing to open `Save As` on the first attempt because
|
||||
`xdg-desktop-portal-cosmic` crashed while handling `FileChooser`.
|
||||
|
||||
Logs showed:
|
||||
|
||||
```text
|
||||
Backend call failed: Remote peer disconnected
|
||||
xdg-desktop-portal-cosmic ... status=11/SEGV
|
||||
```
|
||||
|
||||
The working local system workaround is to remove
|
||||
`org.freedesktop.impl.portal.FileChooser` from:
|
||||
|
||||
```text
|
||||
/usr/share/xdg-desktop-portal/portals/cosmic.portal
|
||||
```
|
||||
|
||||
so the file chooser falls back to GTK. The resulting local `cosmic.portal`
|
||||
keeps COSMIC for the other interfaces:
|
||||
|
||||
```ini
|
||||
[portal]
|
||||
DBusName=org.freedesktop.impl.portal.desktop.cosmic
|
||||
Interfaces=org.freedesktop.impl.portal.Access;org.freedesktop.impl.portal.Screenshot;org.freedesktop.impl.portal.Settings;org.freedesktop.impl.portal.ScreenCast
|
||||
UseIn=COSMIC
|
||||
```
|
||||
|
||||
Backups created locally:
|
||||
|
||||
```text
|
||||
/usr/share/xdg-desktop-portal/portals/cosmic.portal.bak-codex-20260505-filechooser
|
||||
/usr/share/xdg-desktop-portal/cosmic-portals.conf.bak-codex-20260505
|
||||
/usr/share/xdg-desktop-portal/cosmic-portals.conf.bak-codex-20260505-2
|
||||
```
|
||||
|
||||
After editing portal files, restart:
|
||||
|
||||
```sh
|
||||
systemctl --user restart xdg-desktop-portal.service xdg-desktop-portal-gtk.service
|
||||
```
|
||||
|
||||
Package updates may overwrite `/usr/share/xdg-desktop-portal/portals/cosmic.portal`.
|
||||
If `Save As` starts needing two attempts again, re-check that `FileChooser` has
|
||||
not been reintroduced in `cosmic.portal`.
|
||||
|
|
@ -427,3 +427,4 @@ context-action-confirm-warning =
|
|||
*[other] položek
|
||||
}.
|
||||
run = Spustit
|
||||
rename-confirm = Přejmenovat
|
||||
|
|
|
|||
|
|
@ -437,3 +437,4 @@ context-action-confirm-warning =
|
|||
*[other] Elementen
|
||||
}.
|
||||
run = Ausführen
|
||||
rename-confirm = Umbenennen
|
||||
|
|
|
|||
|
|
@ -327,3 +327,4 @@ context-action-confirm-warning =
|
|||
[one] στοιχείο
|
||||
*[other] στοιχεία
|
||||
}.
|
||||
rename-confirm = Μετονομασία
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ save-file = Save file
|
|||
|
||||
## Open With Dialog
|
||||
open-with-title = How do you want to open "{$name}"?
|
||||
open-with-set-default = Always use this app for this file type
|
||||
browse-store = Browse {$store}
|
||||
other-apps = Other applications
|
||||
related-apps = Related applications
|
||||
|
|
@ -139,6 +140,11 @@ open-with = Open with
|
|||
owner = Owner
|
||||
group = Group
|
||||
other = Other
|
||||
toolbar = Toolbar
|
||||
toolbar-available = Available
|
||||
toolbar-empty-hint = No buttons. Drag or add from below.
|
||||
toolbar-reset = Reset to defaults
|
||||
parent-directory = Parent directory
|
||||
mixed = Mixed
|
||||
### Mode 0
|
||||
none = None
|
||||
|
|
|
|||
|
|
@ -414,3 +414,4 @@ context-action-confirm-warning =
|
|||
*[other] kohdetta
|
||||
}.
|
||||
run = Suorita
|
||||
rename-confirm = Nimeä uudelleen
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ save-file = Enregistrer fichier
|
|||
## Open With Dialog
|
||||
|
||||
open-with-title = Comment souhaitez-vous ouvrir "{ $name }" ?
|
||||
open-with-set-default = Toujours utiliser cette application pour ce type de fichier
|
||||
browse-store = Parcourir { $store }
|
||||
|
||||
## Permanently delete Dialog
|
||||
|
|
@ -130,6 +131,11 @@ open-with = Ouvrir avec
|
|||
owner = Propriétaire
|
||||
group = Groupe
|
||||
other = Autre
|
||||
toolbar = Barre d'outils
|
||||
toolbar-available = Disponibles
|
||||
toolbar-empty-hint = Aucun bouton. Glisser-déposer ou ajouter depuis la liste ci-dessous.
|
||||
toolbar-reset = Rétablir par défaut
|
||||
parent-directory = Dossier parent
|
||||
|
||||
### Mode 0
|
||||
|
||||
|
|
@ -445,3 +451,4 @@ context-action-confirm-warning =
|
|||
}.
|
||||
run = Exécuter
|
||||
context-action = Action contextuelle
|
||||
rename-confirm = Renommer
|
||||
|
|
|
|||
|
|
@ -442,3 +442,4 @@ context-action-confirm-warning =
|
|||
*[other] míreanna
|
||||
}.
|
||||
run = Rith
|
||||
rename-confirm = Athainmnigh
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ cosmic-files = COSMIC Fájlok
|
|||
comment = Fájlkezelő a COSMIC asztali környezethez
|
||||
keywords = mappa;fájl;kezelő;
|
||||
empty-folder = Üres mappa
|
||||
empty-folder-hidden = Üres mappa (Rejtett elemeket tartalmaz)
|
||||
empty-folder-hidden = Üres mappa (rejtett elemeket tartalmaz)
|
||||
no-results = Nincs találat
|
||||
filesystem = Fájlrendszer
|
||||
home = Saját mappa
|
||||
|
|
@ -47,13 +47,13 @@ resume = Folytatás
|
|||
|
||||
## Compress Dialog
|
||||
|
||||
create-archive = Tömörített fájl létrehozása
|
||||
create-archive = Archívum létrehozása
|
||||
|
||||
## Extract Dialog
|
||||
|
||||
extract-password-required = Jelszó szükséges
|
||||
extract-to = Kibontás ide…
|
||||
extract-to-title = Kibontás mappába
|
||||
extract-to-title = Kibontási cél kiválasztása
|
||||
|
||||
## Empty Trash Dialog
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ save-file = Fájl mentése
|
|||
|
||||
## Open With Dialog
|
||||
|
||||
open-with-title = Hogyan szeretnéd megnyitni a következőt: „{ $name }”?
|
||||
open-with-title = Hogyan szeretnéd megnyitni a(z) „{ $name }” fájlt?
|
||||
browse-store = { $store } böngészése
|
||||
other-apps = Egyéb alkalmazások
|
||||
related-apps = Hasonló alkalmazások
|
||||
|
|
@ -113,7 +113,7 @@ rename-folder = Mappa átnevezése
|
|||
## Replace Dialog
|
||||
|
||||
replace = Csere
|
||||
replace-title = „{ $filename }” már létezik
|
||||
replace-title = „{ $filename }” már létezik ezen a helyen
|
||||
replace-warning = Szeretnéd lecserélni a meglévő fájlt a mentendő fájllal? A cserével felülírod annak tartalmát.
|
||||
replace-warning-operation = Szeretnéd lecserélni? A csere felülírja annak tartalmát.
|
||||
original-file = Eredeti fájl
|
||||
|
|
@ -133,7 +133,7 @@ set-and-launch = Beállítás és indítás
|
|||
open-with = Megnyitás ezzel
|
||||
owner = Tulajdonos
|
||||
group = Csoport
|
||||
other = Többi
|
||||
other = Mások
|
||||
|
||||
### Mode 0
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ read-write-execute = Olvasás, írás és végrehajtás
|
|||
favorite-path-error = Hiba a könyvtár megnyitásakor
|
||||
favorite-path-error-description =
|
||||
Nem sikerült megnyitni ezt: „{ $path }”
|
||||
„{ $path }” lehet nem létezik, vagy nincs jogosultságod a megnyitásához
|
||||
A(z) „{ $path }” útvonal lehet, hogy nem létezik, vagy nincs jogosultságod a megnyitásához
|
||||
|
||||
Szeretnéd eltávolítani az oldalsávról?
|
||||
remove = Eltávolítás
|
||||
|
|
@ -187,9 +187,9 @@ keep = Megtartás
|
|||
## Add Network Drive
|
||||
|
||||
add-network-drive = Hálózati meghajtó hozzáadása
|
||||
connect = Csatlakozás
|
||||
connect-anonymously = Csatlakozás névtelenül
|
||||
connecting = Csatlakozás…
|
||||
connect = Kapcsolódás
|
||||
connect-anonymously = Kapcsolódás névtelenül
|
||||
connecting = Kapcsolódás…
|
||||
domain = Tartomány
|
||||
enter-server-address = Add meg a kiszolgáló címét
|
||||
network-drive-description =
|
||||
|
|
@ -209,7 +209,7 @@ network-drive-schemes =
|
|||
network-drive-error = Nem érhető el a hálózati meghajtó
|
||||
password = Jelszó
|
||||
remember-password = Jelszó megjegyzése
|
||||
try-again = Újra
|
||||
try-again = Próbáld újra
|
||||
username = Felhasználónév
|
||||
|
||||
## Operations
|
||||
|
|
@ -217,7 +217,7 @@ username = Felhasználónév
|
|||
cancelled = Megszakítva
|
||||
edit-history = Fájlműveleti előzmények
|
||||
history = Előzmények
|
||||
no-history = Nem találhatók elemek az előzményekben
|
||||
no-history = Nem találhatók elemek az előzményekben.
|
||||
pending = Függőben
|
||||
progress = { $percent }%
|
||||
progress-cancelled = { $percent }%, megszakítva
|
||||
|
|
@ -330,7 +330,7 @@ items = Elemek: { $items }
|
|||
item-size = Méret: { $size }
|
||||
item-created = Létrehozva: { $created }
|
||||
item-modified = Módosítva: { $modified }
|
||||
item-accessed = Hozzáférve: { $accessed }
|
||||
item-accessed = Utolsó hozzáférés: { $accessed }
|
||||
calculating = Számítás…
|
||||
|
||||
## Settings
|
||||
|
|
@ -350,7 +350,7 @@ light = Világos
|
|||
|
||||
type-to-search = Gépeléssel keresés
|
||||
type-to-search-recursive = Keresés a jelenlegi mappában és almappákban
|
||||
type-to-search-enter-path = Elérési út megadása
|
||||
type-to-search-enter-path = Elérési út megnyitása
|
||||
# Context menu
|
||||
add-to-sidebar = Hozzáadás az oldalsávhoz
|
||||
compress = Tömörítés…
|
||||
|
|
@ -373,7 +373,7 @@ remove-from-recents = Eltávolítás a legutóbbiak közül
|
|||
|
||||
change-wallpaper = Háttérkép cseréje…
|
||||
desktop-appearance = Asztali megjelenés…
|
||||
display-settings = Képernyő-beállítások…
|
||||
display-settings = Kijelzőbeállítások…
|
||||
|
||||
# Menu
|
||||
|
||||
|
|
@ -406,7 +406,7 @@ grid-view = Rácsnézet
|
|||
list-view = Listanézet
|
||||
show-hidden-files = Rejtett fájlok megjelenítése
|
||||
list-directories-first = Könyvtárak listázása először
|
||||
gallery-preview = Galéria előnézet
|
||||
gallery-preview = Galéria-előnézet
|
||||
menu-settings = Beállítások…
|
||||
menu-about = A COSMIC Fájlok névjegye…
|
||||
|
||||
|
|
@ -415,8 +415,8 @@ menu-about = A COSMIC Fájlok névjegye…
|
|||
sort = Rendezés
|
||||
sort-a-z = A-Z
|
||||
sort-z-a = Z-A
|
||||
sort-newest-first = Legújabb előre
|
||||
sort-oldest-first = Legrégibb előre
|
||||
sort-newest-first = Legújabb elöl
|
||||
sort-oldest-first = Legrégibb elöl
|
||||
sort-smallest-to-largest = Legkisebbtől a legnagyobbig
|
||||
sort-largest-to-smallest = Legnagyobbtól a legkisebbig
|
||||
repository = Tároló
|
||||
|
|
@ -445,3 +445,4 @@ context-action-confirm-warning =
|
|||
*[other] elemen
|
||||
} fog lefutni.
|
||||
run = Futtatás
|
||||
rename-confirm = Átnevezés
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ permanently-delete-question = Slett permanent
|
|||
permanently-delete-warning = Er du sukker på om du vil permanent slette { $target }? Dette kan ikke angres.
|
||||
rename-file = Endre filnavn
|
||||
rename-folder = Endre mappenavn
|
||||
replace-title = "{ $filename }" finnes allerede på denne plasseringen.
|
||||
replace-title = «{ $filename }» finnes allerede på denne plasseringen
|
||||
replace-warning = Vil du bytte den ut med filen du lagrer? Dette vil overskrive innholdet.
|
||||
replace-warning-operation = Vil du erstatte den? Dette vil overskrive innholdet.
|
||||
original-file = Orginalfil
|
||||
|
|
@ -122,8 +122,8 @@ read-write = Kun skrive- og lesbar
|
|||
read-write-execute = Lesbar, skrivbar og kjørbar
|
||||
favorite-path-error = Feil ved åpning av mappen
|
||||
favorite-path-error-description =
|
||||
Kunne ikke åpne "{ $path }".
|
||||
Den kan ikke eksistere eller så har du ikke tilgang til å åpne den.
|
||||
Klarte ikke åpne «{ $path }».
|
||||
«{ $path }» finnes ikke eller så har du ikke tilgang til å åpne den.
|
||||
|
||||
Vil du fjerne den fra sidepanelet?
|
||||
keep = Behold
|
||||
|
|
@ -140,7 +140,7 @@ zoom-out = Zoom ut
|
|||
cut = Klipp ut
|
||||
set-and-launch = Still inn og start
|
||||
domain = Domene
|
||||
enter-server-address = Angi serveradresse
|
||||
enter-server-address = Angi tjeneradresse
|
||||
network-drive-description =
|
||||
Serveradresser inkluderer ett protokollprefiks og en addresse.
|
||||
Examples: ssh://192.168.0.1, ftp://[2001:db8::1]
|
||||
|
|
|
|||
|
|
@ -446,3 +446,4 @@ context-action-confirm-warning =
|
|||
*[other] elementów
|
||||
}.
|
||||
run = Uruchom
|
||||
rename-confirm = Zmień nazwę
|
||||
|
|
|
|||
|
|
@ -445,3 +445,4 @@ context-action-confirm-warning =
|
|||
*[other] itens
|
||||
}.
|
||||
run = Executar
|
||||
rename-confirm = Renomear
|
||||
|
|
|
|||
|
|
@ -354,3 +354,4 @@ sort-smallest-to-largest = Do menor para o maior
|
|||
sort-largest-to-smallest = Do maior para o menor
|
||||
context-action-confirm-title = Executar "{ $name }"?
|
||||
run = Executar
|
||||
rename-confirm = Renomear
|
||||
|
|
|
|||
|
|
@ -389,3 +389,4 @@ context-action-confirm-warning =
|
|||
*[other] элем.
|
||||
}.
|
||||
run = Выполнить
|
||||
rename-confirm = Переименовать
|
||||
|
|
|
|||
|
|
@ -418,3 +418,4 @@ context-action-confirm-warning =
|
|||
*[other] objekt
|
||||
}.
|
||||
run = Kör
|
||||
rename-confirm = Byt namn
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ copying =
|
|||
Копіювання { $items } { $items ->
|
||||
[one] елемента
|
||||
*[other] елементів
|
||||
} з «{ $from }» в «{ $to }» ({ $progress })...
|
||||
} з «{ $from }» до «{ $to }» ({ $progress })...
|
||||
copied =
|
||||
Скопійовано { $items } { $items ->
|
||||
[one] елемент
|
||||
|
|
@ -95,7 +95,7 @@ moving =
|
|||
Переміщення { $items } { $items ->
|
||||
[one] елемента
|
||||
*[other] елементів
|
||||
} з «{ $from }» в «{ $to }» ({ $progress })...
|
||||
} з «{ $from }» до «{ $to }» ({ $progress })...
|
||||
moved =
|
||||
Переміщено { $items } { $items ->
|
||||
[one] елемент
|
||||
|
|
@ -299,7 +299,7 @@ extracting =
|
|||
Видобування { $items } { $items ->
|
||||
[one] елемента
|
||||
*[other] елементів
|
||||
} з «{ $from }» в «{ $to }» ({ $progress })...
|
||||
} з «{ $from }» до «{ $to }» ({ $progress })...
|
||||
extracted =
|
||||
Видобуто { $items } { $items ->
|
||||
[one] елемент
|
||||
|
|
@ -364,10 +364,10 @@ removed-from-recents =
|
|||
*[other] елементів
|
||||
} з { recents }
|
||||
empty-trash-title = Спорожити смітник?
|
||||
type-to-search-select = Вибирає перший відповідний файл або папку
|
||||
type-to-search-select = Вибирає перший відповідний файл або теку
|
||||
pasted-image = Вставлене зображення
|
||||
pasted-text = Вставлений текст
|
||||
pasted-video = Вставлене відео
|
||||
pasted-video = Вставлене видиво
|
||||
copy-to-button-label = Копіювати
|
||||
move-to-button-label = Перемістити
|
||||
copy-to = Копіювати до…
|
||||
|
|
@ -387,3 +387,4 @@ context-action-confirm-warning =
|
|||
*[other] елементів
|
||||
}.
|
||||
context-action = Контекстна дія
|
||||
rename-confirm = Перейменувати
|
||||
|
|
|
|||
|
|
@ -445,3 +445,4 @@ context-action-confirm-warning =
|
|||
*[other] 项目
|
||||
} 上运行。
|
||||
context-action = 环境行动
|
||||
rename-confirm = 重命名
|
||||
|
|
|
|||
|
|
@ -392,3 +392,4 @@ context-action-confirm-warning =
|
|||
*[other] 項目
|
||||
} 上執行。
|
||||
run = 執行
|
||||
rename-confirm = 重新命名
|
||||
|
|
|
|||
512
src/app.rs
512
src/app.rs
|
|
@ -7,6 +7,7 @@ use cosmic::iced::clipboard::dnd::DndAction;
|
|||
use cosmic::iced::core::SmolStr;
|
||||
use cosmic::iced::core::widget::operation::focusable::unfocus;
|
||||
use cosmic::iced::futures::{self, SinkExt};
|
||||
use cosmic::iced::keyboard::key::Physical;
|
||||
use cosmic::iced::keyboard::{Event as KeyEvent, Key, Modifiers};
|
||||
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
||||
use cosmic::iced::platform_specific::shell::wayland::commands::overlap_notify::overlap_notify;
|
||||
|
|
@ -41,15 +42,21 @@ use notify_debouncer_full::notify::{self, RecommendedWatcher};
|
|||
use notify_debouncer_full::{DebouncedEvent, Debouncer, RecommendedCache, new_debouncer};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use slotmap::Key as SlotMapKey;
|
||||
use std::any::TypeId;
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
|
||||
use std::future::Future;
|
||||
use std::num::NonZeroU16;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::pin::Pin;
|
||||
use std::sync::{Arc, LazyLock, Mutex};
|
||||
use std::time::{self, Duration, Instant};
|
||||
use std::{env, fmt, fs, io, process};
|
||||
#[cfg(feature = "notify")]
|
||||
use std::sync::Mutex;
|
||||
use std::{
|
||||
any::TypeId,
|
||||
collections::{BTreeMap, BTreeSet, HashMap, VecDeque},
|
||||
env, fmt, fs,
|
||||
future::Future,
|
||||
io,
|
||||
num::NonZeroU16,
|
||||
path::{Path, PathBuf},
|
||||
pin::Pin,
|
||||
process,
|
||||
sync::{Arc, LazyLock},
|
||||
time::{self, Duration, Instant},
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
use trash::TrashItem;
|
||||
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
||||
|
|
@ -61,12 +68,12 @@ use crate::clipboard::{
|
|||
};
|
||||
use crate::config::{
|
||||
AppTheme, Config, DesktopConfig, Favorite, IconSizes, State, TIME_CONFIG_ID, TabConfig,
|
||||
TimeConfig, TypeToSearch,
|
||||
TimeConfig, ToolbarAction, TypeToSearch, default_toolbar,
|
||||
};
|
||||
use crate::dialog::{Dialog, DialogKind, DialogMessage, DialogResult, DialogSettings};
|
||||
use crate::key_bind::key_binds;
|
||||
use crate::localize::LANGUAGE_SORTER;
|
||||
use crate::mime_app::{self, MimeApp, MimeAppCache};
|
||||
use crate::mime_app::{MimeApp, MimeAppCache};
|
||||
use crate::mounter::{
|
||||
MOUNTERS, MounterAuth, MounterItem, MounterItems, MounterKey, MounterMessage,
|
||||
};
|
||||
|
|
@ -127,6 +134,105 @@ pub struct Flags {
|
|||
pub uris: Vec<url::Url>,
|
||||
}
|
||||
|
||||
/// Yoda phase 3: MIME for the DnD payload carried when a user drags a
|
||||
/// toolbar row in the Settings editor. A single byte = ToolbarAction
|
||||
/// discriminant (see `ToolbarAction::to_u8`).
|
||||
const TOOLBAR_MIME: &str = "application/x-cosmic-files-toolbar-action";
|
||||
|
||||
/// Yoda phase 3: DnD payload wrapping a ToolbarAction discriminant.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ToolbarActionPayload(pub u8);
|
||||
|
||||
impl cosmic::iced::clipboard::mime::AsMimeTypes for ToolbarActionPayload {
|
||||
fn available(&self) -> std::borrow::Cow<'static, [String]> {
|
||||
std::borrow::Cow::Owned(vec![TOOLBAR_MIME.to_owned()])
|
||||
}
|
||||
fn as_bytes(&self, mime_type: &str) -> Option<std::borrow::Cow<'static, [u8]>> {
|
||||
if mime_type == TOOLBAR_MIME {
|
||||
Some(std::borrow::Cow::Owned(vec![self.0]))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl cosmic::iced::clipboard::mime::AllowedMimeTypes for ToolbarActionPayload {
|
||||
fn allowed() -> std::borrow::Cow<'static, [String]> {
|
||||
std::borrow::Cow::Owned(vec![TOOLBAR_MIME.to_owned()])
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<(Vec<u8>, String)> for ToolbarActionPayload {
|
||||
type Error = ();
|
||||
fn try_from((data, _mime): (Vec<u8>, String)) -> Result<Self, Self::Error> {
|
||||
if data.len() == 1 {
|
||||
Ok(Self(data[0]))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Yoda phase 3 helper: map a ToolbarAction to its button UI (icon name,
|
||||
/// localized label, app Message). Shared by the toolbar renderer in
|
||||
/// `view()` and by the Settings page row renderer so the two stay in
|
||||
/// sync.
|
||||
fn toolbar_action_ui(a: ToolbarAction) -> (&'static str, String, Message) {
|
||||
match a {
|
||||
ToolbarAction::LocationUp => (
|
||||
"go-up-symbolic",
|
||||
fl!("parent-directory"),
|
||||
Action::LocationUp.message(None),
|
||||
),
|
||||
ToolbarAction::Reload => (
|
||||
"view-refresh-symbolic",
|
||||
fl!("reload-folder"),
|
||||
Action::Reload.message(None),
|
||||
),
|
||||
ToolbarAction::NewFolder => (
|
||||
"folder-new-symbolic",
|
||||
fl!("new-folder"),
|
||||
Action::NewFolder.message(None),
|
||||
),
|
||||
ToolbarAction::NewFile => (
|
||||
"document-new-symbolic",
|
||||
fl!("new-file"),
|
||||
Action::NewFile.message(None),
|
||||
),
|
||||
ToolbarAction::Rename => (
|
||||
"pencil-symbolic",
|
||||
fl!("rename"),
|
||||
Action::Rename.message(None),
|
||||
),
|
||||
ToolbarAction::Delete => (
|
||||
"edit-delete-symbolic",
|
||||
fl!("delete"),
|
||||
Action::Delete.message(None),
|
||||
),
|
||||
ToolbarAction::Cut => ("edit-cut-symbolic", fl!("cut"), Action::Cut.message(None)),
|
||||
ToolbarAction::Copy => (
|
||||
"edit-copy-symbolic",
|
||||
fl!("copy"),
|
||||
Action::Copy.message(None),
|
||||
),
|
||||
ToolbarAction::Paste => (
|
||||
"edit-paste-symbolic",
|
||||
fl!("paste"),
|
||||
Action::Paste.message(None),
|
||||
),
|
||||
ToolbarAction::ToggleShowHidden => (
|
||||
"view-reveal-symbolic",
|
||||
fl!("show-hidden-files"),
|
||||
Action::ToggleShowHidden.message(None),
|
||||
),
|
||||
ToolbarAction::OpenTerminal => (
|
||||
"utilities-terminal-symbolic",
|
||||
fl!("open-in-terminal"),
|
||||
Action::OpenTerminal.message(None),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum Action {
|
||||
About,
|
||||
|
|
@ -355,7 +461,7 @@ pub enum Message {
|
|||
ExtractToResult(DialogResult),
|
||||
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
||||
Focused(window::Id),
|
||||
Key(window::Id, Modifiers, Key, Option<SmolStr>),
|
||||
Key(window::Id, Modifiers, Key, Physical, Option<SmolStr>),
|
||||
LaunchUrl(String),
|
||||
MaybeExit,
|
||||
ModifiersChanged(window::Id, Modifiers),
|
||||
|
|
@ -389,6 +495,7 @@ pub enum Message {
|
|||
OpenWithBrowse,
|
||||
OpenWithDialog(Option<Entity>),
|
||||
OpenWithSelection(usize),
|
||||
OpenWithToggleDefault(bool),
|
||||
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
||||
Overlap(window::Id, OverlapNotifyEvent),
|
||||
Paste(Option<Entity>),
|
||||
|
|
@ -429,6 +536,22 @@ pub enum Message {
|
|||
SearchInput(String),
|
||||
SetShowDetails(bool),
|
||||
SetShowRecents(bool),
|
||||
/// Yoda phase 3 — toolbar editing messages.
|
||||
ToolbarAdd(ToolbarAction),
|
||||
ToolbarRemove(ToolbarAction),
|
||||
ToolbarReorder {
|
||||
src: ToolbarAction,
|
||||
target: ToolbarAction,
|
||||
},
|
||||
/// Move one step up (toward index 0) inside the enabled toolbar list.
|
||||
ToolbarMoveUp(ToolbarAction),
|
||||
/// Move one step down (toward the end) inside the enabled toolbar list.
|
||||
ToolbarMoveDown(ToolbarAction),
|
||||
ToolbarReset,
|
||||
/// Click on a toolbar button (via segmented_button activation).
|
||||
ToolbarTabActivate(segmented_button::Entity),
|
||||
/// Drag-reorder inside the toolbar (via segmented_button drag).
|
||||
ToolbarTabReorder(segmented_button::ReorderEvent),
|
||||
SetTypeToSearch(TypeToSearch),
|
||||
SystemThemeModeChange,
|
||||
Size(window::Id, Size),
|
||||
|
|
@ -559,6 +682,9 @@ pub enum DialogPage {
|
|||
mime: mime_guess::Mime,
|
||||
selected: usize,
|
||||
store_opt: Option<MimeApp>,
|
||||
/// When true, the chosen app is written to mimeapps.list as the
|
||||
/// default handler for `mime` after it spawns.
|
||||
set_default: bool,
|
||||
},
|
||||
PermanentlyDelete {
|
||||
paths: Box<[PathBuf]>,
|
||||
|
|
@ -716,6 +842,11 @@ pub struct App {
|
|||
nav_bar_context_id: segmented_button::Entity,
|
||||
nav_model: segmented_button::SingleSelectModel,
|
||||
tab_model: segmented_button::Model<segmented_button::SingleSelect>,
|
||||
/// Yoda phase 3: segmented_button model mirroring config.toolbar so the
|
||||
/// toolbar row gets free drag-reorder + click activation (same widget
|
||||
/// that powers the tab bar, its reorder is proven to work in this
|
||||
/// setup unlike the generic dnd_source/dnd_destination wrappers).
|
||||
toolbar_model: segmented_button::Model<segmented_button::SingleSelect>,
|
||||
config_handler: Option<cosmic_config::Config>,
|
||||
state_handler: Option<cosmic_config::Config>,
|
||||
config: Config,
|
||||
|
|
@ -883,6 +1014,7 @@ impl App {
|
|||
|
||||
#[cfg(feature = "desktop")]
|
||||
fn launch_desktop_entries(paths: &[impl AsRef<Path>]) {
|
||||
use crate::mime_app;
|
||||
use cosmic::desktop::fde::DesktopEntry;
|
||||
let locales = cosmic::desktop::fde::get_languages_from_env();
|
||||
|
||||
|
|
@ -1071,7 +1203,7 @@ impl App {
|
|||
.sort_by(|a, b| (b.1.width * b.1.height).total_cmp(&(a.1.width * b.1.height)));
|
||||
|
||||
for (w_id, overlap) in sorted_overlaps {
|
||||
let Some((bl, br, tl, tr, mut size)) = self.layer_sizes.get(w_id).map(|s| {
|
||||
let Some((bl, br, tl, tr, size)) = self.layer_sizes.get(w_id).map(|s| {
|
||||
(
|
||||
Rectangle::new(
|
||||
Point::new(0., s.height / 2.),
|
||||
|
|
@ -1121,30 +1253,18 @@ impl App {
|
|||
if tl && !(tr || bl) {
|
||||
*top += min_dim.1;
|
||||
*left += min_dim.0;
|
||||
|
||||
size.height -= min_dim.1;
|
||||
size.width -= min_dim.0;
|
||||
}
|
||||
if tr && !(tl || br) {
|
||||
*top += min_dim.1;
|
||||
*right += min_dim.0;
|
||||
|
||||
size.height -= min_dim.1;
|
||||
size.width -= min_dim.0;
|
||||
}
|
||||
if bl && !(br || tl) {
|
||||
*bottom += min_dim.1;
|
||||
*left += min_dim.0;
|
||||
|
||||
size.height -= min_dim.1;
|
||||
size.width -= min_dim.0;
|
||||
}
|
||||
if br && !(bl || tr) {
|
||||
*bottom += min_dim.1;
|
||||
*right += min_dim.0;
|
||||
|
||||
size.height -= min_dim.1;
|
||||
size.width -= min_dim.0;
|
||||
}
|
||||
}
|
||||
self.margin = overlaps;
|
||||
|
|
@ -1503,12 +1623,18 @@ impl App {
|
|||
) -> Task<Message> {
|
||||
log::info!("rescan_tab {entity:?} {location:?} {selection_paths:?}");
|
||||
let icon_sizes = self.config.tab.icon_sizes;
|
||||
#[cfg(feature = "gvfs")]
|
||||
let mounter_items = self.mounter_items.clone();
|
||||
|
||||
Task::future(async move {
|
||||
let location2 = location.clone();
|
||||
match tokio::task::spawn_blocking(move || location2.scan(icon_sizes)).await {
|
||||
Ok((parent_item_opt, mut items)) => {
|
||||
Ok((parent_item_opt, items)) => {
|
||||
#[cfg(feature = "gvfs")]
|
||||
let mut items = items;
|
||||
#[cfg(not(feature = "gvfs"))]
|
||||
let items = items;
|
||||
|
||||
#[cfg(feature = "gvfs")]
|
||||
{
|
||||
let mounter_paths: Box<[_]> = mounter_items
|
||||
|
|
@ -1678,6 +1804,7 @@ impl App {
|
|||
|
||||
fn update_config(&mut self) -> Task<Message> {
|
||||
self.update_nav_model();
|
||||
self.rebuild_toolbar_model();
|
||||
// Tabs are collected first to placate the borrowck
|
||||
let tabs: Box<[_]> = self.tab_model.iter().collect();
|
||||
// Update main conf and each tab with the new config
|
||||
|
|
@ -1691,6 +1818,52 @@ impl App {
|
|||
Task::batch(commands)
|
||||
}
|
||||
|
||||
/// Yoda phase 3: rebuild `toolbar_model` so it matches `config.toolbar`.
|
||||
/// Called on init and on every config update. Each entity carries the
|
||||
/// associated `ToolbarAction` as data so click/reorder handlers can
|
||||
/// round-trip Entity → ToolbarAction without maintaining a side map.
|
||||
///
|
||||
/// We insert ONLY the icon (no `.text()`) so the toolbar renders as a
|
||||
/// clean icon row — user-visible labels stay in Settings/tooltips on
|
||||
/// other surfaces.
|
||||
fn rebuild_toolbar_model(&mut self) {
|
||||
self.toolbar_model.clear();
|
||||
for action in self.config.toolbar.iter().copied() {
|
||||
let (icon_name, _label, _msg) = toolbar_action_ui(action);
|
||||
self.toolbar_model
|
||||
.insert()
|
||||
.icon(widget::icon::from_name(icon_name).size(16).icon())
|
||||
.data::<ToolbarAction>(action);
|
||||
}
|
||||
}
|
||||
|
||||
/// Yoda phase 3: after a drag-reorder, sync `config.toolbar` with the
|
||||
/// new entity order in `toolbar_model`. Inlines what `config_set!`
|
||||
/// would do (the macro lives inside update()).
|
||||
fn sync_toolbar_config_from_model(&mut self) -> Task<Message> {
|
||||
let new_toolbar: Vec<ToolbarAction> = self
|
||||
.toolbar_model
|
||||
.iter()
|
||||
.filter_map(|e| self.toolbar_model.data::<ToolbarAction>(e).copied())
|
||||
.collect();
|
||||
if new_toolbar == self.config.toolbar {
|
||||
return Task::none();
|
||||
}
|
||||
match self.config_handler.as_ref() {
|
||||
Some(h) => {
|
||||
if let Err(err) = self.config.set_toolbar(h, new_toolbar) {
|
||||
log::warn!("failed to save toolbar order: {err}");
|
||||
}
|
||||
}
|
||||
None => self.config.toolbar = new_toolbar,
|
||||
}
|
||||
// Don't call update_config() — that would rebuild the
|
||||
// toolbar_model from config and undo the reorder the user just
|
||||
// made. The model already has the new order; config is just
|
||||
// catching up for persistence.
|
||||
Task::none()
|
||||
}
|
||||
|
||||
fn update_desktop(&mut self) -> Task<Message> {
|
||||
let needs_reload: Box<[_]> = (self.tab_model.iter())
|
||||
.filter_map(|entity| {
|
||||
|
|
@ -2268,10 +2441,134 @@ impl App {
|
|||
.toggler(self.config.show_recents, Message::SetShowRecents)
|
||||
})
|
||||
.into(),
|
||||
// Yoda phase 3: toolbar editor. Two stacked lists:
|
||||
// - top: enabled buttons in their current order (drag to reorder)
|
||||
// - bottom: available (not-yet-enabled) buttons
|
||||
// Each row's toggle adds/removes; enabled rows are also
|
||||
// drag sources + drop targets.
|
||||
self.toolbar_settings_section(),
|
||||
])
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Yoda phase 3: build the Toolbar settings section.
|
||||
fn toolbar_settings_section(&self) -> Element<'_, Message> {
|
||||
use iced::clipboard::dnd::DndAction;
|
||||
let enabled = &self.config.toolbar;
|
||||
let disabled: Vec<ToolbarAction> = ToolbarAction::ALL
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|a| !enabled.contains(a))
|
||||
.collect();
|
||||
|
||||
let space_xxs = theme::active().cosmic().spacing.space_xxs;
|
||||
|
||||
let drag_icon = |size: u16| -> Element<'static, Message> {
|
||||
widget::icon::from_name("list-drag-handle-symbolic")
|
||||
.size(size)
|
||||
.into()
|
||||
};
|
||||
|
||||
let row_enabled =
|
||||
|action: ToolbarAction, pos: usize, last: usize| -> Element<'_, Message> {
|
||||
let (icon, label, _msg) = toolbar_action_ui(action);
|
||||
let up_btn =
|
||||
widget::button::icon(widget::icon::from_name("go-up-symbolic").size(14));
|
||||
let up_btn = if pos > 0 {
|
||||
up_btn.on_press(Message::ToolbarMoveUp(action))
|
||||
} else {
|
||||
up_btn
|
||||
};
|
||||
let down_btn =
|
||||
widget::button::icon(widget::icon::from_name("go-down-symbolic").size(14));
|
||||
let down_btn = if pos < last {
|
||||
down_btn.on_press(Message::ToolbarMoveDown(action))
|
||||
} else {
|
||||
down_btn
|
||||
};
|
||||
|
||||
let row_content: Element<_> = widget::row::with_children(vec![
|
||||
drag_icon(14),
|
||||
widget::icon::from_name(icon).size(16).into(),
|
||||
widget::text::body(label).width(Length::Fill).into(),
|
||||
up_btn.into(),
|
||||
down_btn.into(),
|
||||
widget::button::icon(widget::icon::from_name("list-remove-symbolic").size(14))
|
||||
.on_press(Message::ToolbarRemove(action))
|
||||
.into(),
|
||||
])
|
||||
.spacing(space_xxs)
|
||||
.align_y(Alignment::Center)
|
||||
.into();
|
||||
|
||||
let row_container = widget::container(row_content)
|
||||
.width(Length::Fill)
|
||||
.padding(space_xxs);
|
||||
|
||||
// Wrap as DnD source (drags itself) + DnD destination (accepts
|
||||
// drops from other enabled rows; on drop, move the src before
|
||||
// this row).
|
||||
let source = widget::dnd_source::<Message, ToolbarActionPayload>(row_container)
|
||||
.drag_content(move || ToolbarActionPayload(action.to_u8()));
|
||||
widget::dnd_destination(source, vec![std::borrow::Cow::Borrowed(TOOLBAR_MIME)])
|
||||
.data_received_for::<ToolbarActionPayload>(
|
||||
move |payload: Option<ToolbarActionPayload>| {
|
||||
match payload.and_then(|p| ToolbarAction::from_u8(p.0)) {
|
||||
Some(src) if src != action => Message::ToolbarReorder {
|
||||
src,
|
||||
target: action,
|
||||
},
|
||||
// No-op if payload missing / malformed / same row.
|
||||
_ => Message::ToolbarReorder {
|
||||
src: action,
|
||||
target: action,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
.action(DndAction::Move)
|
||||
.into()
|
||||
};
|
||||
|
||||
let row_disabled = |action: ToolbarAction| -> Element<'_, Message> {
|
||||
let (icon, label, _msg) = toolbar_action_ui(action);
|
||||
widget::row::with_children(vec![
|
||||
widget::icon::from_name(icon).size(16).into(),
|
||||
widget::text::body(label).width(Length::Fill).into(),
|
||||
widget::button::icon(widget::icon::from_name("list-add-symbolic").size(14))
|
||||
.on_press(Message::ToolbarAdd(action))
|
||||
.into(),
|
||||
])
|
||||
.spacing(space_xxs)
|
||||
.align_y(Alignment::Center)
|
||||
.padding(space_xxs)
|
||||
.into()
|
||||
};
|
||||
|
||||
let mut section = widget::settings::section().title(fl!("toolbar"));
|
||||
if enabled.is_empty() {
|
||||
section = section.add(widget::text::body(fl!("toolbar-empty-hint")));
|
||||
} else {
|
||||
let last = enabled.len() - 1;
|
||||
for (pos, a) in enabled.iter().copied().enumerate() {
|
||||
section = section.add(row_enabled(a, pos, last));
|
||||
}
|
||||
}
|
||||
|
||||
let mut col = widget::column::with_capacity(3).spacing(space_xxs);
|
||||
col = col.push(section);
|
||||
if !disabled.is_empty() {
|
||||
let mut avail = widget::settings::section().title(fl!("toolbar-available"));
|
||||
for a in disabled {
|
||||
avail = avail.add(row_disabled(a));
|
||||
}
|
||||
col = col.push(avail);
|
||||
}
|
||||
col = col
|
||||
.push(widget::button::standard(fl!("toolbar-reset")).on_press(Message::ToolbarReset));
|
||||
col.into()
|
||||
}
|
||||
|
||||
fn get_apps_for_mime(&self, mime_type: &Mime) -> Vec<(&MimeApp, MimeAppMatch)> {
|
||||
let mut results = Vec::new();
|
||||
|
||||
|
|
@ -2443,6 +2740,7 @@ impl Application for App {
|
|||
nav_bar_context_id: segmented_button::Entity::null(),
|
||||
nav_model: segmented_button::ModelBuilder::default().build(),
|
||||
tab_model: segmented_button::ModelBuilder::default().build(),
|
||||
toolbar_model: segmented_button::ModelBuilder::default().build(),
|
||||
config_handler: flags.config_handler,
|
||||
state_handler: flags.state_handler,
|
||||
config: flags.config,
|
||||
|
|
@ -2553,7 +2851,7 @@ impl Application for App {
|
|||
.on_middle_press(|entity| {
|
||||
cosmic::Action::App(Message::NavMenuAction(NavMenuAction::OpenInNewTab(entity)))
|
||||
})
|
||||
.context_menu(self.nav_context_menu(self.nav_bar_context_id))
|
||||
.context_menu(self.nav_context_menu())
|
||||
.close_icon(icon::from_name("media-eject-symbolic").size(16).icon())
|
||||
.into_container();
|
||||
|
||||
|
|
@ -2568,8 +2866,8 @@ impl Application for App {
|
|||
|
||||
fn nav_context_menu(
|
||||
&self,
|
||||
entity: widget::nav_bar::Id,
|
||||
) -> Option<Vec<widget::menu::Tree<cosmic::Action<Self::Message>>>> {
|
||||
let entity = self.nav_bar_context_id;
|
||||
let favorite_index_opt = self.nav_model.data::<FavoriteIndex>(entity);
|
||||
let location_opt = self.nav_model.data::<Location>(entity);
|
||||
|
||||
|
|
@ -3222,6 +3520,7 @@ impl Application for App {
|
|||
path,
|
||||
mime,
|
||||
selected,
|
||||
set_default,
|
||||
..
|
||||
} => {
|
||||
let available_apps = self.get_apps_for_mime(&mime);
|
||||
|
|
@ -3240,6 +3539,11 @@ impl Application for App {
|
|||
None,
|
||||
);
|
||||
}
|
||||
// Yoda: persist as default if the user asked for it.
|
||||
if set_default {
|
||||
self.mime_app_cache
|
||||
.set_default(mime.clone(), app.id.clone());
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!(
|
||||
|
|
@ -3351,7 +3655,7 @@ impl Application for App {
|
|||
return dialog.update(dialog_message);
|
||||
}
|
||||
}
|
||||
Message::Key(window_id, modifiers, key, text) => {
|
||||
Message::Key(window_id, modifiers, key, physical_key, text) => {
|
||||
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
||||
let in_surface_ids = self.surface_ids.values().any(|id| *id == window_id);
|
||||
#[cfg(not(all(feature = "wayland", feature = "desktop-applet")))]
|
||||
|
|
@ -3359,7 +3663,7 @@ impl Application for App {
|
|||
if self.core.main_window_id() == Some(window_id) || in_surface_ids {
|
||||
let entity = self.tab_model.active();
|
||||
for (key_bind, action) in &self.key_binds {
|
||||
if key_bind.matches(modifiers, &key) {
|
||||
if key_bind.matches(modifiers, &key, None) {
|
||||
return self.update(action.message(Some(entity)));
|
||||
}
|
||||
}
|
||||
|
|
@ -3862,6 +4166,7 @@ impl Application for App {
|
|||
.and_then(|mime| {
|
||||
self.mime_app_cache.get(&mime).first().cloned()
|
||||
}),
|
||||
set_default: false,
|
||||
},
|
||||
Some(CONFIRM_OPEN_WITH_BUTTON_ID.clone()),
|
||||
);
|
||||
|
|
@ -3873,6 +4178,13 @@ impl Application for App {
|
|||
*selected = index;
|
||||
}
|
||||
}
|
||||
Message::OpenWithToggleDefault(enabled) => {
|
||||
if let Some(DialogPage::OpenWith { set_default, .. }) =
|
||||
self.dialog_pages.front_mut()
|
||||
{
|
||||
*set_default = enabled;
|
||||
}
|
||||
}
|
||||
Message::Paste(entity_opt) => {
|
||||
let entity = entity_opt.unwrap_or_else(|| self.tab_model.active());
|
||||
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity)
|
||||
|
|
@ -4349,6 +4661,86 @@ impl Application for App {
|
|||
config_set!(show_recents, show_recents);
|
||||
return self.update_config();
|
||||
}
|
||||
Message::ToolbarAdd(action) => {
|
||||
let mut tb = self.config.toolbar.clone();
|
||||
if !tb.contains(&action) {
|
||||
tb.push(action);
|
||||
}
|
||||
config_set!(toolbar, tb);
|
||||
return self.update_config();
|
||||
}
|
||||
Message::ToolbarRemove(action) => {
|
||||
let mut tb = self.config.toolbar.clone();
|
||||
tb.retain(|a| a != &action);
|
||||
config_set!(toolbar, tb);
|
||||
return self.update_config();
|
||||
}
|
||||
Message::ToolbarReorder { src, target } => {
|
||||
let mut tb = self.config.toolbar.clone();
|
||||
if let (Some(src_idx), Some(tgt_idx)) = (
|
||||
tb.iter().position(|a| a == &src),
|
||||
tb.iter().position(|a| a == &target),
|
||||
) && src_idx != tgt_idx
|
||||
{
|
||||
// Pull src out, then insert before the target's new position.
|
||||
let item = tb.remove(src_idx);
|
||||
let new_tgt = if src_idx < tgt_idx {
|
||||
tgt_idx - 1
|
||||
} else {
|
||||
tgt_idx
|
||||
};
|
||||
tb.insert(new_tgt, item);
|
||||
config_set!(toolbar, tb);
|
||||
return self.update_config();
|
||||
}
|
||||
return Task::none();
|
||||
}
|
||||
Message::ToolbarMoveUp(action) => {
|
||||
let mut tb = self.config.toolbar.clone();
|
||||
if let Some(i) = tb.iter().position(|a| a == &action)
|
||||
&& i > 0
|
||||
{
|
||||
tb.swap(i, i - 1);
|
||||
config_set!(toolbar, tb);
|
||||
return self.update_config();
|
||||
}
|
||||
return Task::none();
|
||||
}
|
||||
Message::ToolbarMoveDown(action) => {
|
||||
let mut tb = self.config.toolbar.clone();
|
||||
if let Some(i) = tb.iter().position(|a| a == &action)
|
||||
&& i + 1 < tb.len()
|
||||
{
|
||||
tb.swap(i, i + 1);
|
||||
config_set!(toolbar, tb);
|
||||
return self.update_config();
|
||||
}
|
||||
return Task::none();
|
||||
}
|
||||
Message::ToolbarReset => {
|
||||
config_set!(toolbar, default_toolbar());
|
||||
return self.update_config();
|
||||
}
|
||||
Message::ToolbarTabActivate(entity) => {
|
||||
// Dispatch the stored ToolbarAction's message, then clear
|
||||
// the "active" selection so the button doesn't stay
|
||||
// highlighted after a click (we use segmented_button for
|
||||
// layout/drag but toolbar buttons are action-firing, not
|
||||
// a mutual-exclusive choice).
|
||||
let action = self.toolbar_model.data::<ToolbarAction>(entity).copied();
|
||||
self.toolbar_model.deactivate();
|
||||
if let Some(action) = action {
|
||||
let (_, _, msg) = toolbar_action_ui(action);
|
||||
return self.update(msg);
|
||||
}
|
||||
return Task::none();
|
||||
}
|
||||
Message::ToolbarTabReorder(event) => {
|
||||
let _ = self
|
||||
.toolbar_model
|
||||
.reorder(event.dragged, event.target, event.position);
|
||||
return self.sync_toolbar_config_from_model();
|
||||
}
|
||||
Message::SetTypeToSearch(type_to_search) => {
|
||||
config_set!(type_to_search, type_to_search);
|
||||
return self.update_config();
|
||||
|
|
@ -4524,6 +4916,7 @@ impl Application for App {
|
|||
commands.push(self.update(Message::CheckClipboard));
|
||||
commands.push(self.update(Message::Surface(
|
||||
cosmic::surface::action::app_popup(
|
||||
|_: &Self| cosmic::surface::action::LiveSettings::default(),
|
||||
move |app: &mut Self| -> SctkPopupSettings {
|
||||
let anchor_rect = Rectangle {
|
||||
x: point.x as i32,
|
||||
|
|
@ -5108,6 +5501,7 @@ impl Application for App {
|
|||
.and_then(|mime| {
|
||||
self.mime_app_cache.get(&mime).first().cloned()
|
||||
}),
|
||||
set_default: false,
|
||||
},
|
||||
None,
|
||||
);
|
||||
|
|
@ -5951,7 +6345,7 @@ impl Application for App {
|
|||
mime,
|
||||
selected,
|
||||
store_opt,
|
||||
..
|
||||
set_default,
|
||||
} => {
|
||||
let name = match path.file_name() {
|
||||
Some(file_name) => file_name.to_str(),
|
||||
|
|
@ -6036,7 +6430,21 @@ impl Application for App {
|
|||
} else {
|
||||
Length::Shrink
|
||||
}
|
||||
}));
|
||||
}))
|
||||
// Yoda: let the user make this choice stick. A plain row
|
||||
// instead of settings::item::builder because the latter
|
||||
// returns a section Item, not an Element usable in .control().
|
||||
.control(
|
||||
widget::row::with_children([
|
||||
widget::text::body(fl!("open-with-set-default")).into(),
|
||||
widget::space::horizontal().into(),
|
||||
widget::toggler(*set_default)
|
||||
.on_toggle(Message::OpenWithToggleDefault)
|
||||
.into(),
|
||||
])
|
||||
.spacing(space_s)
|
||||
.align_y(Alignment::Center),
|
||||
);
|
||||
|
||||
if let Some(app) = store_opt {
|
||||
dialog = dialog.tertiary_action(
|
||||
|
|
@ -6442,7 +6850,10 @@ impl Application for App {
|
|||
/// Creates a view after each update.
|
||||
fn view(&self) -> Element<'_, Self::Message> {
|
||||
let cosmic_theme::Spacing {
|
||||
space_xxs, space_s, ..
|
||||
space_xxs,
|
||||
space_xs,
|
||||
space_s,
|
||||
..
|
||||
} = theme::spacing();
|
||||
|
||||
let mut tab_column = widget::column::with_capacity(4);
|
||||
|
|
@ -6486,6 +6897,36 @@ impl Application for App {
|
|||
);
|
||||
}
|
||||
|
||||
// Yoda phase 3: Dolphin-style quick actions toolbar via
|
||||
// segmented_button::horizontal — the same widget that powers the
|
||||
// tab bar, so its built-in drag reorder works reliably (unlike the
|
||||
// generic dnd_source+dnd_destination pairing we tried earlier).
|
||||
// Short click = action (ToolbarTabActivate → dispatch the stored
|
||||
// ToolbarAction's message). Drag past threshold = reorder
|
||||
// (ToolbarTabReorder → model.reorder + sync to config).
|
||||
if !self.config.toolbar.is_empty() {
|
||||
// Use Control style (no TabBar underline, no bottom border)
|
||||
// and let each button shrink to its icon. Spacing = space_xs
|
||||
// keeps the buttons visually separated so it looks like an
|
||||
// icon toolbar rather than a conjoined segmented control.
|
||||
let toolbar = widget::segmented_button::horizontal(&self.toolbar_model)
|
||||
.style(theme::SegmentedButton::Control)
|
||||
.button_height(32)
|
||||
.button_spacing(space_xs)
|
||||
.button_alignment(Alignment::Center)
|
||||
.minimum_button_width(32)
|
||||
.maximum_button_width(32)
|
||||
.enable_tab_drag(String::from("x-cosmic-files/toolbar-dnd"))
|
||||
.on_reorder(Message::ToolbarTabReorder)
|
||||
.tab_drag_threshold(8.)
|
||||
.on_activate(Message::ToolbarTabActivate);
|
||||
tab_column = tab_column.push(
|
||||
widget::container(toolbar)
|
||||
.width(Length::Shrink)
|
||||
.padding([space_xxs, space_s]),
|
||||
);
|
||||
}
|
||||
|
||||
let entity = self.tab_model.active();
|
||||
if let Some(tab) = self.tab_model.data::<Tab>(entity) {
|
||||
let tab_view = tab
|
||||
|
|
@ -6633,11 +7074,14 @@ impl Application for App {
|
|||
},
|
||||
Event::Keyboard(KeyEvent::KeyPressed {
|
||||
key,
|
||||
physical_key,
|
||||
modifiers,
|
||||
text,
|
||||
..
|
||||
}) => match status {
|
||||
event::Status::Ignored => Some(Message::Key(window_id, modifiers, key, text)),
|
||||
event::Status::Ignored => {
|
||||
Some(Message::Key(window_id, modifiers, key, physical_key, text))
|
||||
}
|
||||
event::Status::Captured => None,
|
||||
},
|
||||
Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
|
||||
|
|
|
|||
|
|
@ -130,9 +130,11 @@ impl TryFrom<(Vec<u8>, String)> for ClipboardPaste {
|
|||
match mime.as_str() {
|
||||
"text/uri-list" => {
|
||||
let text = str::from_utf8(&data)?;
|
||||
let _lines = text.lines();
|
||||
|
||||
for line in text.lines() {
|
||||
for line in text.lines().filter(|line| {
|
||||
let line = line.trim();
|
||||
!line.is_empty() && !line.starts_with('#')
|
||||
}) {
|
||||
let url = Url::parse(line)?;
|
||||
match url.to_file_path() {
|
||||
Ok(path) => paths.push(path),
|
||||
|
|
|
|||
|
|
@ -170,6 +170,11 @@ pub struct Config {
|
|||
pub show_details: bool,
|
||||
pub show_recents: bool,
|
||||
pub tab: TabConfig,
|
||||
/// Yoda phase 3: Dolphin-style quick actions toolbar. An ordered list
|
||||
/// of enabled buttons — position in the vec drives the toolbar order.
|
||||
/// Reorder in Settings via drag-drop; items not in the vec are
|
||||
/// hidden. Default = the minimal-6 set from phase 1.
|
||||
pub toolbar: Vec<ToolbarAction>,
|
||||
pub type_to_search: TypeToSearch,
|
||||
}
|
||||
|
||||
|
|
@ -234,11 +239,97 @@ impl Default for Config {
|
|||
show_details: false,
|
||||
show_recents: true,
|
||||
tab: TabConfig::default(),
|
||||
toolbar: default_toolbar(),
|
||||
type_to_search: TypeToSearch::Recursive,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Yoda phase 3: ordered enum of quick-action toolbar buttons.
|
||||
/// The Config stores `Vec<ToolbarAction>` so the user can pick BOTH
|
||||
/// visibility (just include/exclude the variant) AND order (position in
|
||||
/// the vec). Drag-drop reorder in the Settings page moves items around.
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
|
||||
pub enum ToolbarAction {
|
||||
LocationUp,
|
||||
Reload,
|
||||
NewFolder,
|
||||
NewFile,
|
||||
Rename,
|
||||
Delete,
|
||||
Cut,
|
||||
Copy,
|
||||
Paste,
|
||||
ToggleShowHidden,
|
||||
OpenTerminal,
|
||||
}
|
||||
|
||||
impl ToolbarAction {
|
||||
/// Stable list of every supported action. Ordered roughly by logical
|
||||
/// grouping (location → create/edit → clipboard → view/misc) so that
|
||||
/// the default enabled set follows a sensible shape and the Settings
|
||||
/// row for a not-yet-enabled action lands in a predictable spot.
|
||||
pub const ALL: &'static [Self] = &[
|
||||
Self::LocationUp,
|
||||
Self::Reload,
|
||||
Self::NewFolder,
|
||||
Self::NewFile,
|
||||
Self::Rename,
|
||||
Self::Delete,
|
||||
Self::Cut,
|
||||
Self::Copy,
|
||||
Self::Paste,
|
||||
Self::ToggleShowHidden,
|
||||
Self::OpenTerminal,
|
||||
];
|
||||
|
||||
/// u8 discriminant used to carry the action over a DnD mime payload.
|
||||
pub const fn to_u8(self) -> u8 {
|
||||
match self {
|
||||
Self::LocationUp => 0,
|
||||
Self::Reload => 1,
|
||||
Self::NewFolder => 2,
|
||||
Self::NewFile => 3,
|
||||
Self::Rename => 4,
|
||||
Self::Delete => 5,
|
||||
Self::Cut => 6,
|
||||
Self::Copy => 7,
|
||||
Self::Paste => 8,
|
||||
Self::ToggleShowHidden => 9,
|
||||
Self::OpenTerminal => 10,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn from_u8(v: u8) -> Option<Self> {
|
||||
match v {
|
||||
0 => Some(Self::LocationUp),
|
||||
1 => Some(Self::Reload),
|
||||
2 => Some(Self::NewFolder),
|
||||
3 => Some(Self::NewFile),
|
||||
4 => Some(Self::Rename),
|
||||
5 => Some(Self::Delete),
|
||||
6 => Some(Self::Cut),
|
||||
7 => Some(Self::Copy),
|
||||
8 => Some(Self::Paste),
|
||||
9 => Some(Self::ToggleShowHidden),
|
||||
10 => Some(Self::OpenTerminal),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Default set shown on a fresh install — same "minimal 6" as phase 1/2.
|
||||
pub fn default_toolbar() -> Vec<ToolbarAction> {
|
||||
vec![
|
||||
ToolbarAction::NewFolder,
|
||||
ToolbarAction::Rename,
|
||||
ToolbarAction::Delete,
|
||||
ToolbarAction::Cut,
|
||||
ToolbarAction::Copy,
|
||||
ToolbarAction::Paste,
|
||||
]
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, CosmicConfigEntry, Deserialize, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct DesktopConfig {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use cosmic::app::{Core, Task, context_drawer};
|
|||
use cosmic::iced::core::SmolStr;
|
||||
use cosmic::iced::core::widget::operation;
|
||||
use cosmic::iced::futures::{self, SinkExt};
|
||||
use cosmic::iced::keyboard::key::Named;
|
||||
use cosmic::iced::keyboard::key::{Named, Physical};
|
||||
use cosmic::iced::keyboard::{Event as KeyEvent, Key, Modifiers};
|
||||
use cosmic::iced::platform_specific::shell::{self as iced_winit, SurfaceIdWrapper};
|
||||
use cosmic::iced::widget::scrollable;
|
||||
|
|
@ -456,7 +456,7 @@ enum Message {
|
|||
Escape,
|
||||
Filename(String),
|
||||
Filter(usize),
|
||||
Key(Modifiers, Key, Option<SmolStr>),
|
||||
Key(Modifiers, Key, Physical, Option<SmolStr>),
|
||||
ModifiersChanged(Modifiers),
|
||||
MounterItems(MounterKey, MounterItems),
|
||||
Mouse(window::Id, mouse::Button),
|
||||
|
|
@ -732,11 +732,17 @@ impl App {
|
|||
fn rescan_tab(&self, selection_paths: Option<Vec<PathBuf>>) -> Task<Message> {
|
||||
let location = self.tab.location.clone();
|
||||
let icon_sizes = self.tab.config.icon_sizes;
|
||||
#[cfg(feature = "gvfs")]
|
||||
let mounter_items = self.mounter_items.clone();
|
||||
Task::future(async move {
|
||||
let location2 = location.clone();
|
||||
match tokio::task::spawn_blocking(move || location2.scan(icon_sizes)).await {
|
||||
Ok((parent_item_opt, mut items)) => {
|
||||
Ok((parent_item_opt, items)) => {
|
||||
#[cfg(feature = "gvfs")]
|
||||
let mut items = items;
|
||||
#[cfg(not(feature = "gvfs"))]
|
||||
let items = items;
|
||||
|
||||
#[cfg(feature = "gvfs")]
|
||||
{
|
||||
let mounter_paths: Box<[_]> = mounter_items
|
||||
|
|
@ -1450,16 +1456,16 @@ impl Application for App {
|
|||
}
|
||||
return self.rescan_tab(None);
|
||||
}
|
||||
Message::Key(modifiers, key, text) => {
|
||||
Message::Key(modifiers, key, physical_key, text) => {
|
||||
for (key_bind, action) in &self.key_binds {
|
||||
if key_bind.matches(modifiers, &key) {
|
||||
if key_bind.matches(modifiers, &key, None) {
|
||||
return self.update(Message::from(action.message()));
|
||||
}
|
||||
}
|
||||
|
||||
// Check key binds from accept label
|
||||
if let Some(key_bind) = &self.accept_label.key_bind_opt
|
||||
&& key_bind.matches(modifiers, &key)
|
||||
&& key_bind.matches(modifiers, &key, None)
|
||||
{
|
||||
return self.update(if self.flags.kind.save() {
|
||||
Message::Save(false)
|
||||
|
|
@ -1795,6 +1801,7 @@ impl Application for App {
|
|||
let autosize_id = widget::Id::unique();
|
||||
commands.push(self.update(Message::Surface(
|
||||
cosmic::surface::action::app_popup(
|
||||
|_: &Self| cosmic::surface::action::LiveSettings::default(),
|
||||
move |app: &mut Self| -> SctkPopupSettings {
|
||||
let anchor_rect = Rectangle {
|
||||
x: point.x as i32,
|
||||
|
|
@ -2050,11 +2057,14 @@ impl Application for App {
|
|||
},
|
||||
Event::Keyboard(KeyEvent::KeyPressed {
|
||||
key,
|
||||
physical_key,
|
||||
modifiers,
|
||||
text,
|
||||
..
|
||||
}) => match status {
|
||||
event::Status::Ignored => Some(Message::Key(modifiers, key, text)),
|
||||
event::Status::Ignored => {
|
||||
Some(Message::Key(modifiers, key, physical_key, text))
|
||||
}
|
||||
event::Status::Captured => {
|
||||
if key == Key::Named(Named::Escape) {
|
||||
Some(Message::Escape)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ mod zoom;
|
|||
|
||||
pub(crate) type FxOrderMap<K, V> = ordermap::OrderMap<K, V, rustc_hash::FxBuildHasher>;
|
||||
|
||||
#[cfg(feature = "gvfs")]
|
||||
pub(crate) fn err_str<T: ToString>(err: T) -> String {
|
||||
err.to_string()
|
||||
}
|
||||
|
|
|
|||
15
src/menu.rs
15
src/menu.rs
|
|
@ -10,6 +10,7 @@ use cosmic::widget::{
|
|||
self, Row, button, column, container, divider, responsive_menu_bar, space, text,
|
||||
};
|
||||
use cosmic::{Element, theme};
|
||||
#[cfg(feature = "desktop")]
|
||||
use i18n_embed::LanguageLoader;
|
||||
use mime_guess::Mime;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -67,17 +68,19 @@ pub fn context_menu<'a>(
|
|||
String::new()
|
||||
};
|
||||
fn key_style(theme: &cosmic::Theme) -> TextStyle {
|
||||
let mut color = theme.cosmic().background.component.on;
|
||||
let mut color = theme.cosmic().background(false).component.on;
|
||||
color.alpha *= 0.75;
|
||||
TextStyle {
|
||||
color: Some(color.into()),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
fn disabled_style(theme: &cosmic::Theme) -> TextStyle {
|
||||
let mut color = theme.cosmic().background.component.on;
|
||||
let mut color = theme.cosmic().background(false).component.on;
|
||||
color.alpha *= 0.5;
|
||||
TextStyle {
|
||||
color: Some(color.into()),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -190,11 +193,11 @@ pub fn context_menu<'a>(
|
|||
if !Trash::is_empty() {
|
||||
children.push(menu_item(fl!("empty-trash"), Action::EmptyTrash).into());
|
||||
}
|
||||
} else if let Some(entry) = selected_desktop_entry {
|
||||
} else if let Some(_entry) = selected_desktop_entry {
|
||||
children.push(menu_item(fl!("open"), Action::Open).into());
|
||||
#[cfg(feature = "desktop")]
|
||||
{
|
||||
children.extend(entry.desktop_actions.into_iter().enumerate().map(
|
||||
children.extend(_entry.desktop_actions.into_iter().enumerate().map(
|
||||
|(i, action)| menu_item(action.name, Action::ExecEntryAction(i)).into(),
|
||||
));
|
||||
}
|
||||
|
|
@ -415,7 +418,7 @@ pub fn context_menu<'a>(
|
|||
//TODO: move style to libcosmic
|
||||
.style(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background.component;
|
||||
let component = &cosmic.background(false).component;
|
||||
container::Style {
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
|
|
@ -809,7 +812,7 @@ pub fn location_context_menu<'a>(ancestor_index: usize) -> Element<'a, tab::Mess
|
|||
.padding(1)
|
||||
.style(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background.component;
|
||||
let component = &cosmic.background(false).component;
|
||||
container::Style {
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ use cosmic::desktop;
|
|||
use cosmic::widget;
|
||||
pub use mime_guess::Mime;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::cmp::Ordering;
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Instant;
|
||||
use std::{fs, io, process};
|
||||
#[cfg(feature = "desktop")]
|
||||
use std::{cmp::Ordering, fs, io, time::Instant};
|
||||
use std::{
|
||||
ffi::OsStr,
|
||||
os::unix::ffi::OsStrExt,
|
||||
path::{Path, PathBuf},
|
||||
process,
|
||||
};
|
||||
|
||||
pub fn exec_to_command(
|
||||
exec: &str,
|
||||
|
|
@ -364,9 +366,12 @@ impl MimeAppCache {
|
|||
// The current approach works but might not adhere to the spec (yet)
|
||||
|
||||
// Look for and return preferred terminals
|
||||
//TODO: fallback order beyond cosmic-term?
|
||||
|
||||
let mut preference_order = vec!["com.system76.CosmicTerm".to_string()];
|
||||
// Yoda: cosmic-yoterm (our fork) wins over upstream cosmic-term if both
|
||||
// are installed — useful when xdg-mime default is not set.
|
||||
let mut preference_order = vec![
|
||||
"com.aditua.CosmicYoterm".to_string(),
|
||||
"com.system76.CosmicTerm".to_string(),
|
||||
];
|
||||
|
||||
if let Some(id) = self.get_default_terminal() {
|
||||
preference_order.insert(0, id);
|
||||
|
|
|
|||
|
|
@ -75,10 +75,10 @@ impl MounterItem {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn icon(&self, symbolic: bool) -> Option<widget::icon::Handle> {
|
||||
pub fn icon(&self, _symbolic: bool) -> Option<widget::icon::Handle> {
|
||||
match self {
|
||||
#[cfg(feature = "gvfs")]
|
||||
Self::Gvfs(item) => item.icon(symbolic),
|
||||
Self::Gvfs(item) => item.icon(_symbolic),
|
||||
Self::None => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
@ -103,6 +103,7 @@ impl MounterItem {
|
|||
pub type MounterItems = Vec<MounterItem>;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub enum MounterMessage {
|
||||
Items(MounterItems),
|
||||
MountResult(MounterItem, Result<bool, String>),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use compio::driver::ToSharedFd;
|
|||
use compio::driver::op::AsyncifyFd;
|
||||
use compio::io::{AsyncReadAt, AsyncWriteAt};
|
||||
use cosmic::iced::futures;
|
||||
#[cfg(feature = "gvfs")]
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use std::cell::Cell;
|
||||
use std::error::Error;
|
||||
|
|
|
|||
94
src/tab.rs
94
src/tab.rs
|
|
@ -18,6 +18,7 @@ use cosmic::widget::menu::action::MenuAction;
|
|||
use cosmic::widget::menu::key_bind::KeyBind;
|
||||
use cosmic::widget::{self, DndDestination, DndSource, Id, RcElementWrapper, Widget, space};
|
||||
use cosmic::{Apply, Element, cosmic_theme, font, theme};
|
||||
#[cfg(feature = "desktop")]
|
||||
use i18n_embed::LanguageLoader;
|
||||
use icu::datetime::input::DateTime;
|
||||
use icu::datetime::options::TimePrecision;
|
||||
|
|
@ -179,7 +180,7 @@ fn button_appearance(
|
|||
appearance.icon_color = Some(Color::from(cosmic.on_bg_component_color()));
|
||||
appearance.text_color = Some(Color::from(cosmic.on_bg_component_color()));
|
||||
if cut {
|
||||
appearance.text_color = Some(Color::from(cosmic.background.component.on_disabled));
|
||||
appearance.text_color = Some(Color::from(cosmic.background(false).component.on_disabled));
|
||||
} else {
|
||||
appearance.text_color = Some(Color::from(cosmic.on_bg_component_color()));
|
||||
}
|
||||
|
|
@ -190,12 +191,12 @@ fn button_appearance(
|
|||
appearance.background = Some(Color::from(cosmic.bg_color()).into());
|
||||
appearance.icon_color = Some(Color::from(cosmic.on_bg_color()));
|
||||
if cut {
|
||||
appearance.text_color = Some(Color::from(cosmic.background.component.disabled));
|
||||
appearance.text_color = Some(Color::from(cosmic.background(false).component.disabled));
|
||||
} else {
|
||||
appearance.text_color = Some(Color::from(cosmic.on_bg_color()));
|
||||
}
|
||||
} else if cut {
|
||||
appearance.text_color = Some(Color::from(cosmic.background.component.on_disabled));
|
||||
appearance.text_color = Some(Color::from(cosmic.background(false).component.on_disabled));
|
||||
}
|
||||
if focused && accent {
|
||||
appearance.outline_width = 1.0;
|
||||
|
|
@ -288,6 +289,26 @@ pub fn folder_icon_symbolic(path: &PathBuf, icon_size: u16) -> widget::icon::Han
|
|||
.handle()
|
||||
}
|
||||
|
||||
fn generic_file_icons(
|
||||
sizes: IconSizes,
|
||||
) -> (
|
||||
widget::icon::Handle,
|
||||
widget::icon::Handle,
|
||||
widget::icon::Handle,
|
||||
) {
|
||||
(
|
||||
widget::icon::from_name("text-x-generic")
|
||||
.size(sizes.grid())
|
||||
.handle(),
|
||||
widget::icon::from_name("text-x-generic")
|
||||
.size(sizes.list())
|
||||
.handle(),
|
||||
widget::icon::from_name("text-x-generic")
|
||||
.size(sizes.list_condensed())
|
||||
.handle(),
|
||||
)
|
||||
}
|
||||
|
||||
//TODO: replace with Path::has_trailing_sep when stable
|
||||
fn has_trailing_sep(path: &Path) -> bool {
|
||||
path.as_os_str()
|
||||
|
|
@ -544,7 +565,7 @@ pub fn fs_kind(_metadata: &Metadata) -> FsKind {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "desktop"))]
|
||||
fn get_desktop_file_display_name(path: &Path) -> Option<String> {
|
||||
fn get_desktop_file_display_name(_path: &Path) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
@ -563,7 +584,7 @@ fn get_desktop_file_display_name(path: &Path) -> Option<String> {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "desktop"))]
|
||||
fn get_desktop_file_icon(path: &Path) -> Option<String> {
|
||||
fn get_desktop_file_icon(_path: &Path) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
@ -654,9 +675,9 @@ pub fn item_from_gvfs_info(path: PathBuf, file_info: gio::FileInfo, sizes: IconS
|
|||
folder_icon(&path, sizes.list_condensed()),
|
||||
)
|
||||
} else {
|
||||
// ALWAYS assume we're remote for mime guessing here, since gvfs reading can be expensive
|
||||
// @todo - expose this as a config option?
|
||||
let mime = mime_for_path(&path, None, true);
|
||||
// Keep the initial directory scan cheap. Opening files still
|
||||
// recalculates MIME from the real path before launching apps.
|
||||
let mime = mime_guess::from_path(&path).first_or_octet_stream();
|
||||
|
||||
//TODO: clean this up, implement for trash
|
||||
let icon_name_opt = if mime == "application/x-desktop" {
|
||||
|
|
@ -673,28 +694,21 @@ pub fn item_from_gvfs_info(path: PathBuf, file_info: gio::FileInfo, sizes: IconS
|
|||
desktop_icon_handle(&icon_name, sizes.list_condensed()),
|
||||
)
|
||||
} else {
|
||||
let (icon_handle_grid, icon_handle_list, icon_handle_list_condensed) =
|
||||
generic_file_icons(sizes);
|
||||
(
|
||||
mime.clone(),
|
||||
mime_icon(mime.clone(), sizes.grid()),
|
||||
mime_icon(mime.clone(), sizes.list()),
|
||||
mime_icon(mime, sizes.list_condensed()),
|
||||
mime,
|
||||
icon_handle_grid,
|
||||
icon_handle_list,
|
||||
icon_handle_list_condensed,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
let mut children_opt = None;
|
||||
let children_opt = None;
|
||||
let mut dir_size = DirSize::NotDirectory;
|
||||
if is_dir && !remote {
|
||||
dir_size = DirSize::Calculating(Controller::default());
|
||||
//TODO: calculate children in the background (and make it cancellable?)
|
||||
match fs::read_dir(&path) {
|
||||
Ok(entries) => {
|
||||
children_opt = Some(entries.count());
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("failed to read directory {}: {}", path.display(), err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let display_name = display_name_for_file(&path, &file_info.display_name(), false, is_desktop);
|
||||
|
|
@ -748,7 +762,10 @@ pub fn item_from_entry(
|
|||
sizes: IconSizes,
|
||||
) -> Item {
|
||||
let mut is_desktop = false;
|
||||
#[cfg(feature = "gvfs")]
|
||||
let mut is_gvfs = false;
|
||||
#[cfg(not(feature = "gvfs"))]
|
||||
let is_gvfs = false;
|
||||
|
||||
let hidden = name.starts_with('.') || hidden_attribute(&metadata);
|
||||
|
||||
|
|
@ -796,7 +813,9 @@ pub fn item_from_entry(
|
|||
folder_icon(&path, sizes.list_condensed()),
|
||||
)
|
||||
} else {
|
||||
let mime = mime_for_path(&path, Some(&metadata), remote);
|
||||
// Keep the initial directory scan cheap. Opening files still
|
||||
// recalculates MIME from the real path before launching apps.
|
||||
let mime = mime_guess::from_path(&path).first_or_octet_stream();
|
||||
//TODO: clean this up, implement for trash
|
||||
let icon_name_opt = if mime == "application/x-desktop" {
|
||||
is_desktop = true;
|
||||
|
|
@ -812,28 +831,21 @@ pub fn item_from_entry(
|
|||
desktop_icon_handle(&icon_name, sizes.list_condensed()),
|
||||
)
|
||||
} else {
|
||||
let (icon_handle_grid, icon_handle_list, icon_handle_list_condensed) =
|
||||
generic_file_icons(sizes);
|
||||
(
|
||||
mime.clone(),
|
||||
mime_icon(mime.clone(), sizes.grid()),
|
||||
mime_icon(mime.clone(), sizes.list()),
|
||||
mime_icon(mime, sizes.list_condensed()),
|
||||
mime,
|
||||
icon_handle_grid,
|
||||
icon_handle_list,
|
||||
icon_handle_list_condensed,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
let mut children_opt = None;
|
||||
let children_opt = None;
|
||||
let mut dir_size = DirSize::NotDirectory;
|
||||
if metadata.is_dir() && !remote {
|
||||
dir_size = DirSize::Calculating(Controller::default());
|
||||
//TODO: calculate children in the background (and make it cancellable?)
|
||||
match fs::read_dir(&path) {
|
||||
Ok(entries) => {
|
||||
children_opt = Some(entries.count());
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("failed to read directory {}: {}", path.display(), err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let display_name = display_name_for_file(&path, &name, is_gvfs, is_desktop);
|
||||
|
|
@ -947,7 +959,10 @@ pub fn item_from_path<P: Into<PathBuf>>(path: P, sizes: IconSizes) -> Result<Ite
|
|||
pub fn scan_path(tab_path: &PathBuf, sizes: IconSizes) -> Vec<Item> {
|
||||
let mut items = Vec::new();
|
||||
let mut hidden_files = Box::from([]);
|
||||
#[cfg(feature = "gvfs")]
|
||||
let mut remote_scannable = false;
|
||||
#[cfg(not(feature = "gvfs"))]
|
||||
let remote_scannable = false;
|
||||
|
||||
#[cfg(feature = "gvfs")]
|
||||
{
|
||||
|
|
@ -7580,7 +7595,10 @@ mod tests {
|
|||
// Text editor content may add a trailing newline
|
||||
assert_eq!(content.text().trim_end(), "ab");
|
||||
}
|
||||
_ => panic!("expected Text thumbnail with valid prefix only, got {:?}", thumb),
|
||||
_ => panic!(
|
||||
"expected Text thumbnail with valid prefix only, got {:?}",
|
||||
thumb
|
||||
),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,13 @@
|
|||
use cosmic::desktop::fde::GenericEntry;
|
||||
use mime_guess::Mime;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::path::Path;
|
||||
use std::sync::{LazyLock, Mutex};
|
||||
use std::time::Instant;
|
||||
use std::{fs, process};
|
||||
#[cfg(feature = "desktop")]
|
||||
use std::{fs, time::Instant};
|
||||
use std::{
|
||||
path::Path,
|
||||
process,
|
||||
sync::{LazyLock, Mutex},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Thumbnailer {
|
||||
|
|
|
|||
10
src/trash.rs
10
src/trash.rs
|
|
@ -142,4 +142,12 @@ impl TrashExt for Trash {
|
|||
not(target_os = "android")
|
||||
)
|
||||
)))]
|
||||
impl TrashExt for Trash {}
|
||||
impl TrashExt for Trash {
|
||||
fn scan_search<F: Fn(SearchItem) -> bool + Sync>(callback: F, regex: &Regex) {
|
||||
log::warn!(
|
||||
"searching trash not supported on this platform for pattern {:?}",
|
||||
regex.as_str()
|
||||
);
|
||||
drop(callback);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue