From 4ba816b151641215c6681e2f4699279f581dcc0e Mon Sep 17 00:00:00 2001 From: Austin Riba Date: Wed, 21 Aug 2024 13:52:52 -0700 Subject: [PATCH 1/6] Display file ownership and permissions. This subsumes #414. Took feedback into account to display more human-readble permissions. Also, display the owner and group ownership inline with the permissions themselves. --- Cargo.lock | 22 ++++++++- Cargo.toml | 2 + i18n/en/cosmic_files.ftl | 9 ++++ src/tab.rs | 97 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db22cf4..5a45adc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1261,7 +1261,9 @@ dependencies = [ "test-log", "tokio", "trash", + "unix_permissions_ext", "url", + "users", "vergen", "xdg", "xdg-mime", @@ -1530,7 +1532,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] @@ -6093,6 +6095,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "unix_permissions_ext" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7497808a85e03f612f13e9c5061e4c81cdee86e6c00adfa1096690990ccd08e9" + [[package]] name = "url" version = "2.5.2" @@ -6111,6 +6119,16 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "users" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032" +dependencies = [ + "libc", + "log", +] + [[package]] name = "usvg" version = "0.37.0" @@ -7413,7 +7431,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e25b637..dcd7e3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,8 @@ i18n-embed-fl = "0.7" rust-embed = "8" slotmap = "1.0.7" zip = "2.1.6" +unix_permissions_ext = "0.1.2" +users = "0.11.0" [dependencies.libcosmic] git = "https://github.com/pop-os/libcosmic.git" diff --git a/i18n/en/cosmic_files.ftl b/i18n/en/cosmic_files.ftl index a157052..b150ffc 100644 --- a/i18n/en/cosmic_files.ftl +++ b/i18n/en/cosmic_files.ftl @@ -58,6 +58,15 @@ apply-to-all = Apply to all keep-both = Keep both skip = Skip + +## Metadata Dialog +owner = Owner +group = Group +other = Other +read = Read +write = Write +execute = Execute + # Context Pages ## About diff --git a/src/tab.rs b/src/tab.rs index 78ae8bb..2302b34 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -43,6 +43,7 @@ use std::{ fmt, fs::{self, Metadata}, num::NonZeroU16, + os::unix::fs::MetadataExt, path::PathBuf, sync::{Arc, Mutex}, time::{Duration, Instant}, @@ -60,6 +61,8 @@ use crate::{ mime_icon::{mime_for_path, mime_icon}, mouse_area, }; +use unix_permissions_ext::UNIXPermissionsExt; +use users::{get_group_by_gid, get_user_by_uid}; pub const DOUBLE_CLICK_DURATION: Duration = Duration::from_millis(500); pub const HOVER_DURATION: Duration = Duration::from_millis(1600); @@ -199,6 +202,60 @@ fn format_size(size: u64) -> String { format!("{} B", size) } } +enum PermissionOwner { + Owner, + Group, + Other, +} + +fn format_permissions_owner(metadata: &Metadata, owner: PermissionOwner) -> String { + return match owner { + PermissionOwner::Owner => get_user_by_uid(metadata.uid()) + .and_then(|user| user.name().to_str().map(ToOwned::to_owned)) + .unwrap_or_default(), + PermissionOwner::Group => get_group_by_gid(metadata.gid()) + .and_then(|group| group.name().to_str().map(ToOwned::to_owned)) + .unwrap_or_default(), + PermissionOwner::Other => String::from(""), + }; +} +fn format_permissions(metadata: &Metadata, owner: PermissionOwner) -> String { + let readable = match owner { + PermissionOwner::Owner => metadata.permissions().readable_by_owner(), + PermissionOwner::Group => metadata.permissions().readable_by_group(), + PermissionOwner::Other => metadata.permissions().readable_by_other(), + }; + let writeable = match owner { + PermissionOwner::Owner => metadata.permissions().writable_by_owner(), + PermissionOwner::Group => metadata.permissions().writable_by_group(), + PermissionOwner::Other => metadata.permissions().writable_by_other(), + }; + let executable = match owner { + PermissionOwner::Owner => metadata.permissions().executable_by_owner(), + PermissionOwner::Group => metadata.permissions().executable_by_group(), + PermissionOwner::Other => metadata.permissions().executable_by_other(), + }; + format!( + "{} {} {}", + if readable { + fl!("read") + } else { + String::from("") + }, + if writeable { + fl!("write") + } else { + String::from("") + }, + if executable { + fl!("execute") + } else { + String::from("") + } + ) + .trim_end() + .to_string() +} #[cfg(not(target_os = "windows"))] fn hidden_attribute(_metadata: &Metadata) -> bool { @@ -828,6 +885,46 @@ impl Item { .format_localized(TIME_FORMAT, *LANGUAGE_CHRONO) ))); } + #[cfg(not(target_os = "windows"))] + { + column = column.push( + widget::Row::new() + .push(widget::text(format!("{}:", fl!("owner")))) + .push(widget::text(format_permissions_owner( + metadata, + PermissionOwner::Owner, + ))) + .push(widget::text(format!( + "({})", + format_permissions(metadata, PermissionOwner::Owner,) + ))) + .spacing(10), + ); + + column = column.push( + widget::Row::new() + .push(widget::text(format!("{}:", fl!("group")))) + .push(widget::text(format_permissions_owner( + metadata, + PermissionOwner::Group, + ))) + .push(widget::text(format!( + "({})", + format_permissions(metadata, PermissionOwner::Group,) + ))) + .spacing(10), + ); + + column = column.push( + widget::Row::new() + .push(widget::text(format!("{}", fl!("other")))) + .push(widget::text(format!( + "({})", + format_permissions(metadata, PermissionOwner::Other,) + ))) + .spacing(10), + ); + } } ItemMetadata::Trash { .. } => { //TODO: trash metadata From 34a00c2121d539604cff2fffcb07f535b55bbc9d Mon Sep 17 00:00:00 2001 From: VandaLHJ Date: Fri, 23 Aug 2024 20:50:52 +0200 Subject: [PATCH 2/6] Update cosmic_files.ftl PL translation Added extract and did minor tweaks. --- i18n/pl/cosmic_files.ftl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/i18n/pl/cosmic_files.ftl b/i18n/pl/cosmic_files.ftl index 0ca880d..07e26bb 100644 --- a/i18n/pl/cosmic_files.ftl +++ b/i18n/pl/cosmic_files.ftl @@ -1,9 +1,10 @@ cosmic-files = Pliki COSMIC empty-folder = Pusty katalog empty-folder-hidden = Pusty katalog (z ukrytymi plikami) +no-results = Brak wyników filesystem = System plików home = Katalog Domowy -notification-in-progress = Są przeprowadzane operacje na plikach. +notification-in-progress = Operacje na plikach w toku. trash = Kosz undo = Cofnij @@ -36,6 +37,7 @@ open-file = Otwórz plik open-folder = Otwórz katalog open-in-new-tab = Otwórz w nowej karcie open-in-new-window = Otwórz w nowym oknie +open-item-location = Otwórz położenie elementu open-multiple-files = Otwórz wiele plików open-multiple-folders = Otwórz wiele katalogów save = Zapisz @@ -82,6 +84,15 @@ copied = Skopiowano {$items} {$items -> } z {$from} do {$to} emptying-trash = Opróżnianie {trash} emptied-trash = Opróżniono {trash} +extracting = Wypakowywanie {$items} {$items -> + [one] elementu + *[other] elementów + } z {$from} do {$to} +extracted = Wypakowano {$items} {$items -> + [one] element + [few] elementy + *[other] elementów + } z {$from} do {$to} moving = Przenoszenie {$items} {$items -> [one] elementu *[other] elementów @@ -132,6 +143,7 @@ dark = Ciemny light = Jasny # Context menu +extract-here = Wypakuj add-to-sidebar = Dodaj do bocznego panelu new-file = Nowy plik new-folder = Nowy katalog @@ -172,3 +184,8 @@ show-hidden-files = Pokaż ukryte pliki list-directories-first = Najpierw wyświetlaj katalogi menu-settings = Ustawienia... menu-about = O Plikach COSMIC... +list-view = Widok listy +show-hidden-files = Pokaż ukryte pliki +list-directories-first = Najpierw wyświetlaj katalogi +menu-settings = Ustawienia... +menu-about = O Plikach COSMIC... From 80783f6cd13bb75db4a3203b2c5e57fdee9d5b56 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 26 Aug 2024 13:24:13 -0600 Subject: [PATCH 3/6] Sort dependencies alphabetically --- Cargo.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e25b637..af80a7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,17 +17,17 @@ freedesktop_entry_parser = { version = "1.3", optional = true } fs_extra = { git = "https://github.com/pop-os/fs_extra.git" } gio = { version = "0.19", optional = true } glob = "0.3" -ignore = "0.4" -image = "0.24" -notify-rust = "4" -once_cell = "1.19" -open = "5.0.2" icu_collator = "1.5" icu_provider = { version = "1.5", features = ["sync"] } +ignore = "0.4" +image = "0.24" libc = "0.2" log = "0.4" mime_guess = "2" notify-debouncer-full = "0.3" +notify-rust = "4" +once_cell = "1.19" +open = "5.0.2" paste = "1.0" rayon = "1" regex = "1" @@ -36,9 +36,9 @@ shlex = { version = "1.3" } tar = "0.4.41" tokio = { version = "1", features = ["sync"] } trash = { git = "https://github.com/jackpot51/trash-rs.git", branch = "delete-info" } +url = "2.5" xdg = { version = "2.5.2", optional = true } xdg-mime = "0.3" -url = "2.5" # Internationalization i18n-embed = { version = "0.14", features = [ "fluent-system", From f51e4f5016721f26c1f30ba1ff4bdc9fffe9ecda Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 26 Aug 2024 13:31:01 -0600 Subject: [PATCH 4/6] Make notify support optional, update libcosmic --- Cargo.lock | 191 +++++++++++++++++++++++++++++------------------------ Cargo.toml | 5 +- src/app.rs | 76 ++++++++++++--------- 3 files changed, 149 insertions(+), 123 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db22cf4..37a0b2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,6 +104,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "aes" version = "0.8.4" @@ -396,7 +402,7 @@ checksum = "d7ebdfa2ebdab6b1760375fa7d6f382b9f486eac35fc994625a00e89280bdbb7" dependencies = [ "async-task", "concurrent-queue", - "fastrand 2.1.0", + "fastrand 2.1.1", "futures-lite 2.3.0", "slab", ] @@ -539,7 +545,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -574,7 +580,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -657,7 +663,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.4", "object", "rustc-demangle", ] @@ -818,7 +824,7 @@ checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -908,9 +914,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.13" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" dependencies = [ "jobserver", "libc", @@ -1196,7 +1202,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -1215,7 +1221,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "quote", "syn 1.0.109", @@ -1228,7 +1234,7 @@ dependencies = [ "chrono", "dirs 5.0.1", "env_logger", - "fastrand 2.1.0", + "fastrand 2.1.1", "fork", "freedesktop_entry_parser", "fs_extra", @@ -1307,7 +1313,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "almost", "cosmic-config", @@ -1463,7 +1469,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1474,7 +1480,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1530,7 +1536,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -1542,7 +1548,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1632,7 +1638,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1751,7 +1757,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1866,7 +1872,7 @@ dependencies = [ "flume", "half", "lebe", - "miniz_oxide", + "miniz_oxide 0.7.4", "rayon-core", "smallvec", "zune-inflate", @@ -1889,9 +1895,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fdeflate" @@ -1934,12 +1940,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.8.0", ] [[package]] @@ -2066,7 +2072,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2223,7 +2229,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.1.0", + "fastrand 2.1.1", "futures-core", "futures-io", "parking", @@ -2238,7 +2244,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2428,7 +2434,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2710,7 +2716,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.75", + "syn 2.0.76", "unic-langid", ] @@ -2724,7 +2730,7 @@ dependencies = [ "i18n-config", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2753,7 +2759,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "dnd", "iced_accessibility", @@ -2772,7 +2778,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "accesskit", "accesskit_unix", @@ -2782,7 +2788,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "bitflags 2.6.0", "dnd", @@ -2804,7 +2810,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "futures", "iced_core", @@ -2817,7 +2823,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "bitflags 2.6.0", "bytemuck", @@ -2841,7 +2847,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2853,7 +2859,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "dnd", "iced_accessibility", @@ -2867,7 +2873,7 @@ dependencies = [ [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "enum-repr", "float-cmp", @@ -2894,7 +2900,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "iced_core", "once_cell", @@ -2904,7 +2910,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "bytemuck", "cosmic-text", @@ -2921,7 +2927,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "as-raw-xcb-connection", "bitflags 2.6.0", @@ -2950,7 +2956,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "dnd", "iced_accessibility", @@ -2968,7 +2974,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "dnd", "iced_accessibility", @@ -3145,7 +3151,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3475,7 +3481,7 @@ checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ba7001ee5922105a4000c4a432acaabb5befb300" +source = "git+https://github.com/pop-os/libcosmic.git#fdc04ddf1245bf42b085cb2b5c944b0bfce31a4e" dependencies = [ "apply", "ashpd 0.9.1", @@ -3824,6 +3830,15 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mio" version = "0.8.11" @@ -4114,7 +4129,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4297,7 +4312,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4337,7 +4352,7 @@ dependencies = [ "by_address", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4452,7 +4467,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4489,7 +4504,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" dependencies = [ "atomic-waker", - "fastrand 2.1.0", + "fastrand 2.1.1", "futures-io", ] @@ -4509,7 +4524,7 @@ dependencies = [ "crc32fast", "fdeflate", "flate2", - "miniz_oxide", + "miniz_oxide 0.7.4", ] [[package]] @@ -4663,9 +4678,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -4944,7 +4959,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.75", + "syn 2.0.76", "walkdir", ] @@ -5103,29 +5118,29 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" [[package]] name = "serde" -version = "1.0.208" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "indexmap", "itoa", @@ -5142,7 +5157,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -5359,7 +5374,7 @@ dependencies = [ "cocoa", "core-graphics", "drm", - "fastrand 2.1.0", + "fastrand 2.1.1", "foreign-types", "js-sys", "log", @@ -5475,9 +5490,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.75" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -5492,7 +5507,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -5569,7 +5584,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", - "fastrand 2.1.0", + "fastrand 2.1.1", "once_cell", "rustix 0.38.34", "windows-sys 0.59.0", @@ -5603,7 +5618,7 @@ checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -5623,7 +5638,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -5779,7 +5794,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -5877,7 +5892,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6059,9 +6074,9 @@ dependencies = [ [[package]] name = "unicode-properties" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" +checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524" [[package]] name = "unicode-script" @@ -6089,9 +6104,9 @@ checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" [[package]] name = "url" @@ -6264,7 +6279,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -6298,7 +6313,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6725,7 +6740,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6747,7 +6762,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -7214,7 +7229,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "synstructure", ] @@ -7322,7 +7337,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "zvariant_utils 2.1.0", ] @@ -7372,7 +7387,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -7392,7 +7407,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "synstructure", ] @@ -7413,7 +7428,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.76", ] [[package]] @@ -7435,14 +7450,14 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] name = "zip" -version = "2.1.6" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40dd8c92efc296286ce1fbd16657c5dbefff44f1b4ca01cc5f517d8b7b3d3e2e" +checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" dependencies = [ "aes", "arbitrary", @@ -7568,7 +7583,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "zvariant_utils 2.1.0", ] @@ -7591,5 +7606,5 @@ checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] diff --git a/Cargo.toml b/Cargo.toml index af80a7e..5c0a197 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ libc = "0.2" log = "0.4" mime_guess = "2" notify-debouncer-full = "0.3" -notify-rust = "4" +notify-rust = { version = "4", optional = true } once_cell = "1.19" open = "5.0.2" paste = "1.0" @@ -59,9 +59,10 @@ version = "0.2.1" features = ["serde"] [features] -default = ["desktop", "gvfs", "winit", "wgpu"] +default = ["desktop", "gvfs", "notify", "winit", "wgpu"] desktop = ["libcosmic/desktop", "dep:freedesktop_entry_parser", "dep:xdg"] gvfs = ["dep:gio"] +notify = ["dep:notify-rust"] wayland = ["libcosmic/wayland"] winit = ["libcosmic/winit"] wgpu = ["libcosmic/wgpu"] diff --git a/src/app.rs b/src/app.rs index 630d643..87cbab7 100644 --- a/src/app.rs +++ b/src/app.rs @@ -209,7 +209,7 @@ impl MenuAction for NavMenuAction { pub enum Message { AddToSidebar(Option), AppTheme(AppTheme), - CloseToast(usize), + CloseToast(widget::ToastId), Config(Config), Copy(Option), Cut(Option), @@ -229,6 +229,7 @@ pub enum Message { NavBarContext(Entity), NavMenuAction(NavMenuAction), NewItem(Option, bool), + #[cfg(feature = "notify")] Notification(Arc>), NotifyEvents(Vec), NotifyWatcher(WatcherWrapper), @@ -261,7 +262,7 @@ pub enum Message { TabRescan(Entity, Location, Vec, Option), ToggleContextPage(ContextPage), Undo(usize), - UndoTrash(usize, Arc<[PathBuf]>), + UndoTrash(widget::ToastId, Arc<[PathBuf]>), UndoTrashStart(Vec), WindowClose, WindowNew, @@ -365,6 +366,7 @@ pub struct App { modifiers: Modifiers, mounters: Mounters, mounter_items: HashMap, + #[cfg(feature = "notify")] notification_opt: Option>>, pending_operation_id: u64, pending_operations: BTreeMap, @@ -594,6 +596,7 @@ impl App { fn update_notification(&mut self) -> Command { // Handle closing notification if there are no operations if self.pending_operations.is_empty() { + #[cfg(feature = "notify")] if let Some(notification_arc) = self.notification_opt.take() { return Command::perform( async move { @@ -1057,6 +1060,7 @@ impl Application for App { modifiers: Modifiers::empty(), mounters: mounters(), mounter_items: HashMap::new(), + #[cfg(feature = "notify")] notification_opt: None, pending_operation_id: 0, pending_operations: BTreeMap::new(), @@ -1453,6 +1457,7 @@ impl Application for App { } } } + #[cfg(feature = "notify")] Message::Notification(notification) => { self.notification_opt = Some(notification); } @@ -2817,38 +2822,43 @@ impl Application for App { //TODO: inhibit suspend/shutdown? if self.window_id_opt.is_none() { - struct NotificationSubscription; - subscriptions.push(subscription::channel( - TypeId::of::(), - 1, - move |msg_tx| async move { - let msg_tx = Arc::new(tokio::sync::Mutex::new(msg_tx)); - tokio::task::spawn_blocking(move || match notify_rust::Notification::new() - .summary(&fl!("notification-in-progress")) - .timeout(notify_rust::Timeout::Never) - .show() - { - Ok(notification) => { - let _ = futures::executor::block_on(async { - msg_tx - .lock() - .await - .send(Message::Notification(Arc::new(Mutex::new( - notification, - )))) - .await - }); - } - Err(err) => { - log::warn!("failed to create notification: {}", err); - } - }) - .await - .unwrap(); + #[cfg(feature = "notify")] + { + struct NotificationSubscription; + subscriptions.push(subscription::channel( + TypeId::of::(), + 1, + move |msg_tx| async move { + let msg_tx = Arc::new(tokio::sync::Mutex::new(msg_tx)); + tokio::task::spawn_blocking(move || { + match notify_rust::Notification::new() + .summary(&fl!("notification-in-progress")) + .timeout(notify_rust::Timeout::Never) + .show() + { + Ok(notification) => { + let _ = futures::executor::block_on(async { + msg_tx + .lock() + .await + .send(Message::Notification(Arc::new(Mutex::new( + notification, + )))) + .await + }); + } + Err(err) => { + log::warn!("failed to create notification: {}", err); + } + } + }) + .await + .unwrap(); - pending().await - }, - )); + pending().await + }, + )); + } } } From d2346268898e08d922d33fa49082497f32fd81c3 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 26 Aug 2024 13:59:28 -0600 Subject: [PATCH 5/6] Downgrade filetime to fix redox compilation --- Cargo.lock | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37a0b2f..068c484 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1919,14 +1919,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.24" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if", "libc", - "libredox 0.1.3", - "windows-sys 0.59.0", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", ] [[package]] @@ -3541,7 +3541,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -3569,7 +3569,6 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.6.0", "libc", - "redox_syscall 0.5.3", ] [[package]] @@ -6645,7 +6644,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] From a5a5f229acf746682ef46573f277d599f8028380 Mon Sep 17 00:00:00 2001 From: Austin Riba Date: Mon, 26 Aug 2024 13:28:44 -0700 Subject: [PATCH 6/6] Fix poor formatting and smelly code in format_permissions --- src/tab.rs | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/tab.rs b/src/tab.rs index 2302b34..cfc90dd 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -220,41 +220,30 @@ fn format_permissions_owner(metadata: &Metadata, owner: PermissionOwner) -> Stri }; } fn format_permissions(metadata: &Metadata, owner: PermissionOwner) -> String { - let readable = match owner { + let mut perms: Vec = Vec::new(); + if match owner { PermissionOwner::Owner => metadata.permissions().readable_by_owner(), PermissionOwner::Group => metadata.permissions().readable_by_group(), PermissionOwner::Other => metadata.permissions().readable_by_other(), - }; - let writeable = match owner { + } { + perms.push(fl!("read")); + } + if match owner { PermissionOwner::Owner => metadata.permissions().writable_by_owner(), PermissionOwner::Group => metadata.permissions().writable_by_group(), PermissionOwner::Other => metadata.permissions().writable_by_other(), - }; - let executable = match owner { + } { + perms.push(fl!("write")); + } + if match owner { PermissionOwner::Owner => metadata.permissions().executable_by_owner(), PermissionOwner::Group => metadata.permissions().executable_by_group(), PermissionOwner::Other => metadata.permissions().executable_by_other(), - }; - format!( - "{} {} {}", - if readable { - fl!("read") - } else { - String::from("") - }, - if writeable { - fl!("write") - } else { - String::from("") - }, - if executable { - fl!("execute") - } else { - String::from("") - } - ) - .trim_end() - .to_string() + } { + perms.push(fl!("execute")); + } + + perms.join(" ") } #[cfg(not(target_os = "windows"))]