Skip to content

Commit 6d62700

Browse files
authored
Merge branch 'master' into weblate-pop-os-cosmic-files
2 parents e8f55b1 + 6e3406a commit 6d62700

File tree

11 files changed

+174
-260
lines changed

11 files changed

+174
-260
lines changed

Cargo.lock

Lines changed: 71 additions & 130 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ xdg-mime = { git = "https://github.com/ebassi/xdg-mime-rs" }
4444
bzip2 = { version = "0.6", optional = true } #TODO: replace with pure Rust crate
4545
flate2 = "1.1"
4646
tar = "0.4.44"
47-
lzma-rust2 = { version = "0.13", optional = true }
48-
ordermap = { version = "0.5.10", features = ["serde"] }
47+
lzma-rust2 = { version = "0.14", optional = true }
48+
ordermap = { version = "0.5.12", features = ["serde"] }
4949
# Internationalization
5050
i18n-embed = { version = "0.16", features = [
5151
"fluent-system",
@@ -59,7 +59,7 @@ zip = "5.1.1"
5959
uzers = "0.12.1"
6060
md-5 = "0.10.6"
6161
png = "0.18"
62-
jxl-oxide = { version = "0.12.4", features = ["image"] }
62+
jxl-oxide = { version = "0.12.5", features = ["image"] }
6363
num_cpus = "1.17.0"
6464

6565
# Completion-based IO runtime to enable io_uring / IOCP file IO support.
@@ -135,6 +135,3 @@ tokio = { version = "1", features = ["rt", "macros"] }
135135

136136
[workspace]
137137
members = ["cosmic-files-applet"]
138-
139-
[patch.crates-io]
140-
license = { git = "https://github.com/evenorog/license.git" }

src/app.rs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,12 @@ pub struct DialogPages {
534534
pages: VecDeque<DialogPage>,
535535
}
536536

537+
impl Default for DialogPages {
538+
fn default() -> Self {
539+
Self::new()
540+
}
541+
}
542+
537543
impl DialogPages {
538544
pub fn new() -> Self {
539545
Self {
@@ -996,7 +1002,6 @@ impl App {
9961002
self.margin = overlaps;
9971003
}
9981004

999-
#[must_use]
10001005
fn open_tab_entity(
10011006
&mut self,
10021007
location: Location,
@@ -1061,18 +1066,14 @@ impl App {
10611066
}
10621067

10631068
// This wrapper ensures that local folders use trash and remote folders permanently delete with a dialog
1064-
#[must_use]
10651069
fn delete(&mut self, paths: Vec<PathBuf>) -> Task<Message> {
10661070
let mut dialog_paths = Vec::new();
10671071
let mut trash_paths = Vec::new();
10681072

10691073
for path in paths {
10701074
//TODO: is there a smarter way to check this? (like checking for trash folders)
10711075
let can_trash = match path.metadata() {
1072-
Ok(metadata) => match tab::fs_kind(&metadata) {
1073-
tab::FsKind::Local => true,
1074-
_ => false,
1075-
},
1076+
Ok(metadata) => matches!(tab::fs_kind(&metadata), tab::FsKind::Local),
10761077
Err(err) => {
10771078
log::warn!("failed to get metadata for {:?}: {}", path, err);
10781079
false
@@ -1097,7 +1098,6 @@ impl App {
10971098
Task::batch(tasks)
10981099
}
10991100

1100-
#[must_use]
11011101
fn operation(&mut self, operation: Operation) -> Task<Message> {
11021102
let id = self.pending_operation_id;
11031103
let controller = Controller::default();
@@ -1157,7 +1157,6 @@ impl App {
11571157
}
11581158
}
11591159

1160-
#[must_use]
11611160
fn rescan_operation_selection(&mut self, op_sel: OperationSelection) -> Task<Message> {
11621161
log::info!("rescan_operation_selection {:?}", op_sel);
11631162
let entity = self.tab_model.active();
@@ -2023,7 +2022,7 @@ impl App {
20232022
}
20242023
}
20252024

2026-
return false;
2025+
false
20272026
}
20282027
}
20292028

@@ -2085,7 +2084,7 @@ impl Application for App {
20852084
.unwrap()
20862085
.block_on(async move {
20872086
while let Some(task) = compio_rx.recv().await {
2088-
_ = compio::runtime::spawn(task).detach();
2087+
compio::runtime::spawn(task).detach();
20892088
}
20902089
})
20912090
});
@@ -2096,6 +2095,7 @@ impl Application for App {
20962095
.version(env!("CARGO_PKG_VERSION"))
20972096
.author("System76")
20982097
.license("GPL-3.0-only")
2098+
.license_url("https://spdx.org/licenses/GPL-3.0-only")
20992099
.developers([("Jeremy Soller", "[email protected]")])
21002100
.links([
21012101
(fl!("repository"), "https://github.com/pop-os/cosmic-files"),
@@ -2241,7 +2241,7 @@ impl Application for App {
22412241

22422242
if location_opt
22432243
.and_then(|x| x.path_opt())
2244-
.map_or(false, |x| x.is_file())
2244+
.is_some_and(|x| x.is_file())
22452245
{
22462246
items.push(cosmic::widget::menu::Item::Button(
22472247
fl!("open"),
@@ -2319,14 +2319,14 @@ impl Application for App {
23192319
found |= item.path().is_some_and(|p| path.starts_with(&p))
23202320
|| item.name() == *name
23212321
|| item.uri() == *uri;
2322-
(!item.is_mounted() && found).then(|| *k)
2322+
(!item.is_mounted() && found).then_some(*k)
23232323
})
23242324
})
23252325
.or(if found {
23262326
None
23272327
} else {
23282328
// TODO do we need to choose the correct mounter?
2329-
self.mounter_items.iter().map(|(k, _)| *k).next()
2329+
self.mounter_items.keys().map(|k| *k).next()
23302330
})
23312331
{
23322332
if let Some(mounter) = MOUNTERS.get(&key) {
@@ -2968,8 +2968,8 @@ impl Application for App {
29682968
}
29692969
},
29702970
Message::ModifiersChanged(window_id, modifiers) => {
2971+
self.modifiers = modifiers;
29712972
if self.core.main_window_id() == Some(window_id) {
2972-
self.modifiers = modifiers;
29732973
let entity = self.tab_model.active();
29742974
return self.update(Message::TabMessage(
29752975
Some(entity),
@@ -3078,7 +3078,7 @@ impl Application for App {
30783078
}
30793079
Message::NetworkDriveSubmit => {
30803080
//TODO: know which mounter to use for network drives
3081-
for (mounter_key, mounter) in MOUNTERS.iter() {
3081+
if let Some((mounter_key, mounter)) = MOUNTERS.iter().next() {
30823082
self.network_drive_connecting =
30833083
Some((*mounter_key, self.network_drive_input.clone()));
30843084
return mounter
@@ -3876,7 +3876,7 @@ impl Application for App {
38763876
};
38773877
let window_id = WindowId::unique();
38783878
self.windows.insert(
3879-
window_id.clone(),
3879+
window_id,
38803880
WindowKind::ContextMenu(entity, widget::Id::unique()),
38813881
);
38823882
commands.push(self.update(Message::Surface(
@@ -3900,7 +3900,7 @@ impl Application for App {
39003900
parent: parent_id.unwrap_or(
39013901
app.core
39023902
.main_window_id()
3903-
.unwrap_or_else(|| WindowId::NONE),
3903+
.unwrap_or(WindowId::NONE),
39043904
),
39053905
id: window_id,
39063906
positioner,
@@ -4061,7 +4061,7 @@ impl Application for App {
40614061
.sort_names
40624062
.get(&location_str)
40634063
.or_else(|| SORT_OPTION_FALLBACK.get(&location_str))
4064-
.unwrap_or_else(|| &(HeadingOptions::Name, true));
4064+
.unwrap_or(&(HeadingOptions::Name, true));
40654065

40664066
tab.sort_name = sort.0;
40674067
tab.sort_direction = sort.1;
@@ -4376,7 +4376,7 @@ impl Application for App {
43764376
.and_then(|x| x.path_opt())
43774377
.map(ToOwned::to_owned)
43784378
{
4379-
return self.open_file(&[path]).into();
4379+
return self.open_file(&[path]);
43804380
}
43814381
}
43824382
NavMenuAction::OpenWith(entity) => {
@@ -4634,7 +4634,7 @@ impl Application for App {
46344634
if let Some(p) = paths.first() {
46354635
{
46364636
for (k, mounter_items) in &self.mounter_items {
4637-
if let Some(mounter) = MOUNTERS.get(&k) {
4637+
if let Some(mounter) = MOUNTERS.get(k) {
46384638
if let Some(item) = mounter_items
46394639
.iter()
46404640
.find(|item| item.path().is_some_and(|path| path == *p))
@@ -4695,7 +4695,7 @@ impl Application for App {
46954695
Some(match &self.context_page {
46964696
ContextPage::About => context_drawer::about(
46974697
&self.about,
4698-
Message::LaunchUrl,
4698+
|url| Message::LaunchUrl(url.to_string()),
46994699
Message::ToggleContextPage(ContextPage::About),
47004700
),
47014701
ContextPage::EditHistory => context_drawer::context_drawer(
@@ -4766,10 +4766,7 @@ impl Application for App {
47664766
);
47674767
}
47684768
}
4769-
4770-
let Some(dialog_page) = self.dialog_pages.front() else {
4771-
return None;
4772-
};
4769+
let dialog_page = self.dialog_pages.front()?;
47734770

47744771
let cosmic_theme::Spacing {
47754772
space_xxs, space_s, ..
@@ -4854,8 +4851,7 @@ impl Application for App {
48544851
archive_type: archive_types[index],
48554852
password: password.clone(),
48564853
})
4857-
})
4858-
.into(),
4854+
}),
48594855
])
48604856
.align_y(Alignment::Center)
48614857
.spacing(space_xxs)
@@ -5962,8 +5958,7 @@ impl Application for App {
59625958
// watching the trash which is slow but also properly get events.
59635959
let trash_paths = trash_bins
59645960
.into_iter()
5965-
.map(|path| [path.join("files"), path])
5966-
.flatten();
5961+
.flat_map(|path| [path.join("files"), path]);
59675962
for path in trash_paths {
59685963
if let Err(e) =
59695964
watcher.watch(&path, notify::RecursiveMode::NonRecursive)

src/archive.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ fn zip_extract<R: io::Read + io::Seek, P: AsRef<Path>>(
245245
controller.set_progress(total_progress);
246246
}
247247
}
248-
outfile.sync_all()?;
249248
#[cfg(unix)]
250249
{
251250
// Check for real permissions, which we'll set in a second pass

src/dialog.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,9 @@ impl<T: AsRef<str>> From<T> for DialogLabel {
159159
let underline = next_underline;
160160
next_underline = false;
161161

162-
if c == '_' {
163-
if !underline {
164-
next_underline = true;
165-
continue;
166-
}
162+
if c == '_' && !underline {
163+
next_underline = true;
164+
continue;
167165
}
168166

169167
if underline && key_bind_opt.is_none() {
@@ -1041,10 +1039,7 @@ impl Application for App {
10411039
);
10421040
}
10431041

1044-
let dialog_page = match self.dialog_pages.front() {
1045-
Some(some) => some,
1046-
None => return None,
1047-
};
1042+
let dialog_page = self.dialog_pages.front()?;
10481043

10491044
let dialog = match dialog_page {
10501045
DialogPage::NewFolder { parent, name } => {
@@ -1628,7 +1623,7 @@ impl Application for App {
16281623
};
16291624
use cosmic::iced::Rectangle;
16301625
let window_id = window::Id::unique();
1631-
self.context_menu_window = Some(window_id.clone());
1626+
self.context_menu_window = Some(window_id);
16321627
let autosize_id = widget::Id::unique();
16331628
commands.push(self.update(Message::Surface(
16341629
cosmic::surface::action::app_popup(

src/menu.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,13 @@ pub fn menu_bar<'a>(
535535
menu::Item::CheckBox(
536536
label,
537537
None,
538-
sort_options.map_or(false, |(sort_name, sort_direction, _)| {
538+
sort_options.is_some_and(|(sort_name, sort_direction, _)| {
539539
sort_name == sort && sort_direction == dir
540540
}),
541541
Action::SetSort(sort, dir),
542542
)
543543
};
544-
let in_trash = tab_opt.map_or(false, |tab| tab.location == Location::Trash);
544+
let in_trash = tab_opt.is_some_and(|tab| tab.location == Location::Trash);
545545

546546
let mut selected_dir = 0;
547547
let mut selected = 0;
@@ -637,26 +637,26 @@ pub fn menu_bar<'a>(
637637
menu::Item::CheckBox(
638638
fl!("grid-view"),
639639
None,
640-
tab_opt.map_or(false, |tab| matches!(tab.config.view, tab::View::Grid)),
640+
tab_opt.is_some_and(|tab| matches!(tab.config.view, tab::View::Grid)),
641641
Action::TabViewGrid,
642642
),
643643
menu::Item::CheckBox(
644644
fl!("list-view"),
645645
None,
646-
tab_opt.map_or(false, |tab| matches!(tab.config.view, tab::View::List)),
646+
tab_opt.is_some_and(|tab| matches!(tab.config.view, tab::View::List)),
647647
Action::TabViewList,
648648
),
649649
menu::Item::Divider,
650650
menu::Item::CheckBox(
651651
fl!("show-hidden-files"),
652652
None,
653-
tab_opt.map_or(false, |tab| tab.config.show_hidden),
653+
tab_opt.is_some_and(|tab| tab.config.show_hidden),
654654
Action::ToggleShowHidden,
655655
),
656656
menu::Item::CheckBox(
657657
fl!("list-directories-first"),
658658
None,
659-
tab_opt.map_or(false, |tab| tab.config.folders_first),
659+
tab_opt.is_some_and(|tab| tab.config.folders_first),
660660
Action::ToggleFoldersFirst,
661661
),
662662
menu::Item::CheckBox(

src/mime_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl MimeAppCache {
439439

440440
fn get_default_terminal(&self) -> Option<String> {
441441
let output = process::Command::new("xdg-mime")
442-
.args(&["query", "default", "x-scheme-handler/terminal"])
442+
.args(["query", "default", "x-scheme-handler/terminal"])
443443
.output()
444444
.ok()?;
445445

src/mime_icon.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ pub fn mime_for_path<P: AsRef<Path>>(
6969
gb.file_name(file_name);
7070
}
7171
} else {
72-
gb.path(&path);
72+
gb.path(path);
7373
}
7474
if let Some(metadata) = metadata_opt {
7575
gb.metadata(metadata.clone());
7676
}
7777
let guess = gb.guess();
7878
if guess.uncertain() {
7979
// If uncertain, try mime_guess. This could happen on platforms without shared-mime-info
80-
mime_guess::from_path(&path).first_or_octet_stream()
80+
mime_guess::from_path(path).first_or_octet_stream()
8181
} else {
8282
guess.mime_type().clone()
8383
}

src/mounter/gvfs.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ fn network_scan(uri: &str, sizes: IconSizes) -> Result<Vec<tab::Item>, String> {
9999

100100
let metadata = if !force_dir && !info.boolean(gio::FILE_ATTRIBUTE_FILESYSTEM_REMOTE) {
101101
let mtime = info.attribute_uint64(gio::FILE_ATTRIBUTE_TIME_MODIFIED);
102-
let is_dir = match info.file_type() {
103-
gio::FileType::Directory => true,
104-
_ => false,
105-
};
102+
let is_dir = matches!(info.file_type(), gio::FileType::Directory);
106103
let size_opt = match is_dir {
107104
true => None,
108105
false => Some(info.size() as u64),

0 commit comments

Comments
 (0)