From 57ab1ecbf44f494973fbdeec11358e65ae44dba2 Mon Sep 17 00:00:00 2001 From: Lionel DARNIS Date: Sun, 24 May 2026 10:27:32 +0200 Subject: [PATCH] fix: clean files warnings for terminal build --- src/app.rs | 170 +++++++++++++++++++++---------------- src/dialog.rs | 8 +- src/lib.rs | 1 + src/mounter/mod.rs | 5 +- src/operation/recursive.rs | 1 + src/tab.rs | 6 ++ 6 files changed, 114 insertions(+), 77 deletions(-) diff --git a/src/app.rs b/src/app.rs index 34d230c..7bd3884 100644 --- a/src/app.rs +++ b/src/app.rs @@ -51,6 +51,8 @@ use notify_debouncer_full::{ }; use rustc_hash::{FxHashMap, FxHashSet}; use slotmap::Key as SlotMapKey; +#[cfg(feature = "notify")] +use std::sync::Mutex; use std::{ any::TypeId, collections::{BTreeMap, BTreeSet, HashMap, VecDeque}, @@ -64,8 +66,6 @@ use std::{ sync::{Arc, LazyLock}, time::{self, Duration, Instant}, }; -#[cfg(feature = "notify")] -use std::sync::Mutex; use tokio::sync::mpsc; use trash::TrashItem; #[cfg(all(feature = "wayland", feature = "desktop-applet"))] @@ -178,7 +178,11 @@ impl cosmic::iced::clipboard::mime::AllowedMimeTypes for ToolbarActionPayload { impl TryFrom<(Vec, String)> for ToolbarActionPayload { type Error = (); fn try_from((data, _mime): (Vec, String)) -> Result { - if data.len() == 1 { Ok(Self(data[0])) } else { Err(()) } + if data.len() == 1 { + Ok(Self(data[0])) + } else { + Err(()) + } } } @@ -218,11 +222,7 @@ fn toolbar_action_ui(a: ToolbarAction) -> (&'static str, String, Message) { fl!("delete"), Action::Delete.message(None), ), - ToolbarAction::Cut => ( - "edit-cut-symbolic", - fl!("cut"), - Action::Cut.message(None), - ), + ToolbarAction::Cut => ("edit-cut-symbolic", fl!("cut"), Action::Cut.message(None)), ToolbarAction::Copy => ( "edit-copy-symbolic", fl!("copy"), @@ -552,7 +552,10 @@ pub enum Message { /// Yoda phase 3 — toolbar editing messages. ToolbarAdd(ToolbarAction), ToolbarRemove(ToolbarAction), - ToolbarReorder { src: ToolbarAction, target: 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. @@ -1204,7 +1207,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.), @@ -1624,12 +1627,18 @@ impl App { ) -> Task { 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 @@ -2466,60 +2475,66 @@ impl App { .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 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::(row_container) + .drag_content(move || ToolbarActionPayload(action.to_u8())); + widget::dnd_destination(source, vec![std::borrow::Cow::Borrowed(TOOLBAR_MIME)]) + .data_received_for::( + move |payload: Option| { + 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 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::(row_container) - .drag_content(move || ToolbarActionPayload(action.to_u8())); - widget::dnd_destination( - source, - vec![std::borrow::Cow::Borrowed(TOOLBAR_MIME)], - ) - .data_received_for::(move |payload: Option| { - 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); @@ -2538,8 +2553,7 @@ impl App { let mut section = widget::settings::section().title(fl!("toolbar")); if enabled.is_empty() { - section = section - .add(widget::text::body(fl!("toolbar-empty-hint"))); + section = section.add(widget::text::body(fl!("toolbar-empty-hint"))); } else { let last = enabled.len() - 1; for (pos, a) in enabled.iter().copied().enumerate() { @@ -2556,10 +2570,8 @@ impl App { } col = col.push(avail); } - col = col.push( - widget::button::standard(fl!("toolbar-reset")) - .on_press(Message::ToolbarReset), - ); + col = col + .push(widget::button::standard(fl!("toolbar-reset")).on_press(Message::ToolbarReset)); col.into() } @@ -4672,10 +4684,15 @@ impl Application for App { if let (Some(src_idx), Some(tgt_idx)) = ( tb.iter().position(|a| a == &src), tb.iter().position(|a| a == &target), - ) && src_idx != tgt_idx { + ) && 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 }; + 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(); @@ -4723,7 +4740,9 @@ impl Application for App { return Task::none(); } Message::ToolbarTabReorder(event) => { - let _ = self.toolbar_model.reorder(event.dragged, event.target, event.position); + let _ = self + .toolbar_model + .reorder(event.dragged, event.target, event.position); return self.sync_toolbar_config_from_model(); } Message::SetTypeToSearch(type_to_search) => { @@ -6826,7 +6845,10 @@ impl Application for App { /// Creates a view after each update. fn view(&self) -> Element<'_, Self::Message> { let cosmic_theme::Spacing { - space_xxs, space_xs, space_s, .. + space_xxs, + space_xs, + space_s, + .. } = theme::active().cosmic().spacing; let mut tab_column = widget::column::with_capacity(4); diff --git a/src/dialog.rs b/src/dialog.rs index cac5907..6bdeee6 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -744,11 +744,17 @@ impl App { fn rescan_tab(&self, selection_paths: Option>) -> Task { 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 diff --git a/src/lib.rs b/src/lib.rs index 3e89861..a426695 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,6 +37,7 @@ mod zoom; pub(crate) type FxOrderMap = ordermap::OrderMap; +#[cfg(feature = "gvfs")] pub(crate) fn err_str(err: T) -> String { err.to_string() } diff --git a/src/mounter/mod.rs b/src/mounter/mod.rs index b97f32a..dc2ab92 100644 --- a/src/mounter/mod.rs +++ b/src/mounter/mod.rs @@ -75,10 +75,10 @@ impl MounterItem { } } - pub fn icon(&self, symbolic: bool) -> Option { + pub fn icon(&self, _symbolic: bool) -> Option { 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; #[derive(Clone, Debug)] +#[allow(dead_code)] pub enum MounterMessage { Items(MounterItems), MountResult(MounterItem, Result), diff --git a/src/operation/recursive.rs b/src/operation/recursive.rs index 9a33ebd..9c9a1c3 100644 --- a/src/operation/recursive.rs +++ b/src/operation/recursive.rs @@ -9,6 +9,7 @@ use compio::buf::{IntoInner, IoBuf}; use compio::driver::{ToSharedFd, op::AsyncifyFd}; use compio::io::{AsyncReadAt, AsyncWriteAt}; use cosmic::iced::futures; +#[cfg(feature = "gvfs")] use futures::{FutureExt, StreamExt}; use std::future::Future; use std::pin::Pin; diff --git a/src/tab.rs b/src/tab.rs index 653dabf..ec2260a 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -773,7 +773,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); @@ -967,7 +970,10 @@ pub fn item_from_path>(path: P, sizes: IconSizes) -> Result Vec { 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")] {