fix: clean files warnings for terminal build
This commit is contained in:
parent
6f3adcd993
commit
57ab1ecbf4
6 changed files with 114 additions and 77 deletions
170
src/app.rs
170
src/app.rs
|
|
@ -51,6 +51,8 @@ use notify_debouncer_full::{
|
||||||
};
|
};
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
use slotmap::Key as SlotMapKey;
|
use slotmap::Key as SlotMapKey;
|
||||||
|
#[cfg(feature = "notify")]
|
||||||
|
use std::sync::Mutex;
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
collections::{BTreeMap, BTreeSet, HashMap, VecDeque},
|
collections::{BTreeMap, BTreeSet, HashMap, VecDeque},
|
||||||
|
|
@ -64,8 +66,6 @@ use std::{
|
||||||
sync::{Arc, LazyLock},
|
sync::{Arc, LazyLock},
|
||||||
time::{self, Duration, Instant},
|
time::{self, Duration, Instant},
|
||||||
};
|
};
|
||||||
#[cfg(feature = "notify")]
|
|
||||||
use std::sync::Mutex;
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use trash::TrashItem;
|
use trash::TrashItem;
|
||||||
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
||||||
|
|
@ -178,7 +178,11 @@ impl cosmic::iced::clipboard::mime::AllowedMimeTypes for ToolbarActionPayload {
|
||||||
impl TryFrom<(Vec<u8>, String)> for ToolbarActionPayload {
|
impl TryFrom<(Vec<u8>, String)> for ToolbarActionPayload {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
fn try_from((data, _mime): (Vec<u8>, String)) -> Result<Self, Self::Error> {
|
fn try_from((data, _mime): (Vec<u8>, String)) -> Result<Self, Self::Error> {
|
||||||
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"),
|
fl!("delete"),
|
||||||
Action::Delete.message(None),
|
Action::Delete.message(None),
|
||||||
),
|
),
|
||||||
ToolbarAction::Cut => (
|
ToolbarAction::Cut => ("edit-cut-symbolic", fl!("cut"), Action::Cut.message(None)),
|
||||||
"edit-cut-symbolic",
|
|
||||||
fl!("cut"),
|
|
||||||
Action::Cut.message(None),
|
|
||||||
),
|
|
||||||
ToolbarAction::Copy => (
|
ToolbarAction::Copy => (
|
||||||
"edit-copy-symbolic",
|
"edit-copy-symbolic",
|
||||||
fl!("copy"),
|
fl!("copy"),
|
||||||
|
|
@ -552,7 +552,10 @@ pub enum Message {
|
||||||
/// Yoda phase 3 — toolbar editing messages.
|
/// Yoda phase 3 — toolbar editing messages.
|
||||||
ToolbarAdd(ToolbarAction),
|
ToolbarAdd(ToolbarAction),
|
||||||
ToolbarRemove(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.
|
/// Move one step up (toward index 0) inside the enabled toolbar list.
|
||||||
ToolbarMoveUp(ToolbarAction),
|
ToolbarMoveUp(ToolbarAction),
|
||||||
/// Move one step down (toward the end) inside the enabled toolbar list.
|
/// 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)));
|
.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 {
|
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(
|
Rectangle::new(
|
||||||
Point::new(0., s.height / 2.),
|
Point::new(0., s.height / 2.),
|
||||||
|
|
@ -1624,12 +1627,18 @@ impl App {
|
||||||
) -> Task<Message> {
|
) -> Task<Message> {
|
||||||
log::info!("rescan_tab {entity:?} {location:?} {selection_paths:?}");
|
log::info!("rescan_tab {entity:?} {location:?} {selection_paths:?}");
|
||||||
let icon_sizes = self.config.tab.icon_sizes;
|
let icon_sizes = self.config.tab.icon_sizes;
|
||||||
|
#[cfg(feature = "gvfs")]
|
||||||
let mounter_items = self.mounter_items.clone();
|
let mounter_items = self.mounter_items.clone();
|
||||||
|
|
||||||
Task::future(async move {
|
Task::future(async move {
|
||||||
let location2 = location.clone();
|
let location2 = location.clone();
|
||||||
match tokio::task::spawn_blocking(move || location2.scan(icon_sizes)).await {
|
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")]
|
#[cfg(feature = "gvfs")]
|
||||||
{
|
{
|
||||||
let mounter_paths: Box<[_]> = mounter_items
|
let mounter_paths: Box<[_]> = mounter_items
|
||||||
|
|
@ -2466,60 +2475,66 @@ impl App {
|
||||||
.into()
|
.into()
|
||||||
};
|
};
|
||||||
|
|
||||||
let row_enabled = |action: ToolbarAction, pos: usize, last: usize| -> Element<'_, Message> {
|
let row_enabled =
|
||||||
let (icon, label, _msg) = toolbar_action_ui(action);
|
|action: ToolbarAction, pos: usize, last: usize| -> Element<'_, Message> {
|
||||||
let up_btn = widget::button::icon(widget::icon::from_name("go-up-symbolic").size(14));
|
let (icon, label, _msg) = toolbar_action_ui(action);
|
||||||
let up_btn = if pos > 0 {
|
let up_btn =
|
||||||
up_btn.on_press(Message::ToolbarMoveUp(action))
|
widget::button::icon(widget::icon::from_name("go-up-symbolic").size(14));
|
||||||
} else {
|
let up_btn = if pos > 0 {
|
||||||
up_btn
|
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 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 row_disabled = |action: ToolbarAction| -> Element<'_, Message> {
|
||||||
let (icon, label, _msg) = toolbar_action_ui(action);
|
let (icon, label, _msg) = toolbar_action_ui(action);
|
||||||
|
|
@ -2538,8 +2553,7 @@ impl App {
|
||||||
|
|
||||||
let mut section = widget::settings::section().title(fl!("toolbar"));
|
let mut section = widget::settings::section().title(fl!("toolbar"));
|
||||||
if enabled.is_empty() {
|
if enabled.is_empty() {
|
||||||
section = section
|
section = section.add(widget::text::body(fl!("toolbar-empty-hint")));
|
||||||
.add(widget::text::body(fl!("toolbar-empty-hint")));
|
|
||||||
} else {
|
} else {
|
||||||
let last = enabled.len() - 1;
|
let last = enabled.len() - 1;
|
||||||
for (pos, a) in enabled.iter().copied().enumerate() {
|
for (pos, a) in enabled.iter().copied().enumerate() {
|
||||||
|
|
@ -2556,10 +2570,8 @@ impl App {
|
||||||
}
|
}
|
||||||
col = col.push(avail);
|
col = col.push(avail);
|
||||||
}
|
}
|
||||||
col = col.push(
|
col = col
|
||||||
widget::button::standard(fl!("toolbar-reset"))
|
.push(widget::button::standard(fl!("toolbar-reset")).on_press(Message::ToolbarReset));
|
||||||
.on_press(Message::ToolbarReset),
|
|
||||||
);
|
|
||||||
col.into()
|
col.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4672,10 +4684,15 @@ impl Application for App {
|
||||||
if let (Some(src_idx), Some(tgt_idx)) = (
|
if let (Some(src_idx), Some(tgt_idx)) = (
|
||||||
tb.iter().position(|a| a == &src),
|
tb.iter().position(|a| a == &src),
|
||||||
tb.iter().position(|a| a == &target),
|
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.
|
// Pull src out, then insert before the target's new position.
|
||||||
let item = tb.remove(src_idx);
|
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);
|
tb.insert(new_tgt, item);
|
||||||
config_set!(toolbar, tb);
|
config_set!(toolbar, tb);
|
||||||
return self.update_config();
|
return self.update_config();
|
||||||
|
|
@ -4723,7 +4740,9 @@ impl Application for App {
|
||||||
return Task::none();
|
return Task::none();
|
||||||
}
|
}
|
||||||
Message::ToolbarTabReorder(event) => {
|
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();
|
return self.sync_toolbar_config_from_model();
|
||||||
}
|
}
|
||||||
Message::SetTypeToSearch(type_to_search) => {
|
Message::SetTypeToSearch(type_to_search) => {
|
||||||
|
|
@ -6826,7 +6845,10 @@ impl Application for App {
|
||||||
/// Creates a view after each update.
|
/// Creates a view after each update.
|
||||||
fn view(&self) -> Element<'_, Self::Message> {
|
fn view(&self) -> Element<'_, Self::Message> {
|
||||||
let cosmic_theme::Spacing {
|
let cosmic_theme::Spacing {
|
||||||
space_xxs, space_xs, space_s, ..
|
space_xxs,
|
||||||
|
space_xs,
|
||||||
|
space_s,
|
||||||
|
..
|
||||||
} = theme::active().cosmic().spacing;
|
} = theme::active().cosmic().spacing;
|
||||||
|
|
||||||
let mut tab_column = widget::column::with_capacity(4);
|
let mut tab_column = widget::column::with_capacity(4);
|
||||||
|
|
|
||||||
|
|
@ -744,11 +744,17 @@ impl App {
|
||||||
fn rescan_tab(&self, selection_paths: Option<Vec<PathBuf>>) -> Task<Message> {
|
fn rescan_tab(&self, selection_paths: Option<Vec<PathBuf>>) -> Task<Message> {
|
||||||
let location = self.tab.location.clone();
|
let location = self.tab.location.clone();
|
||||||
let icon_sizes = self.tab.config.icon_sizes;
|
let icon_sizes = self.tab.config.icon_sizes;
|
||||||
|
#[cfg(feature = "gvfs")]
|
||||||
let mounter_items = self.mounter_items.clone();
|
let mounter_items = self.mounter_items.clone();
|
||||||
Task::future(async move {
|
Task::future(async move {
|
||||||
let location2 = location.clone();
|
let location2 = location.clone();
|
||||||
match tokio::task::spawn_blocking(move || location2.scan(icon_sizes)).await {
|
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")]
|
#[cfg(feature = "gvfs")]
|
||||||
{
|
{
|
||||||
let mounter_paths: Box<[_]> = mounter_items
|
let mounter_paths: Box<[_]> = mounter_items
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ mod zoom;
|
||||||
|
|
||||||
pub(crate) type FxOrderMap<K, V> = ordermap::OrderMap<K, V, rustc_hash::FxBuildHasher>;
|
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 {
|
pub(crate) fn err_str<T: ToString>(err: T) -> String {
|
||||||
err.to_string()
|
err.to_string()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
match self {
|
||||||
#[cfg(feature = "gvfs")]
|
#[cfg(feature = "gvfs")]
|
||||||
Self::Gvfs(item) => item.icon(symbolic),
|
Self::Gvfs(item) => item.icon(_symbolic),
|
||||||
Self::None => unreachable!(),
|
Self::None => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,6 +103,7 @@ impl MounterItem {
|
||||||
pub type MounterItems = Vec<MounterItem>;
|
pub type MounterItems = Vec<MounterItem>;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum MounterMessage {
|
pub enum MounterMessage {
|
||||||
Items(MounterItems),
|
Items(MounterItems),
|
||||||
MountResult(MounterItem, Result<bool, String>),
|
MountResult(MounterItem, Result<bool, String>),
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use compio::buf::{IntoInner, IoBuf};
|
||||||
use compio::driver::{ToSharedFd, op::AsyncifyFd};
|
use compio::driver::{ToSharedFd, op::AsyncifyFd};
|
||||||
use compio::io::{AsyncReadAt, AsyncWriteAt};
|
use compio::io::{AsyncReadAt, AsyncWriteAt};
|
||||||
use cosmic::iced::futures;
|
use cosmic::iced::futures;
|
||||||
|
#[cfg(feature = "gvfs")]
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
|
|
||||||
|
|
@ -773,7 +773,10 @@ pub fn item_from_entry(
|
||||||
sizes: IconSizes,
|
sizes: IconSizes,
|
||||||
) -> Item {
|
) -> Item {
|
||||||
let mut is_desktop = false;
|
let mut is_desktop = false;
|
||||||
|
#[cfg(feature = "gvfs")]
|
||||||
let mut is_gvfs = false;
|
let mut is_gvfs = false;
|
||||||
|
#[cfg(not(feature = "gvfs"))]
|
||||||
|
let is_gvfs = false;
|
||||||
|
|
||||||
let hidden = name.starts_with('.') || hidden_attribute(&metadata);
|
let hidden = name.starts_with('.') || hidden_attribute(&metadata);
|
||||||
|
|
||||||
|
|
@ -967,7 +970,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> {
|
pub fn scan_path(tab_path: &PathBuf, sizes: IconSizes) -> Vec<Item> {
|
||||||
let mut items = Vec::new();
|
let mut items = Vec::new();
|
||||||
let mut hidden_files = Box::from([]);
|
let mut hidden_files = Box::from([]);
|
||||||
|
#[cfg(feature = "gvfs")]
|
||||||
let mut remote_scannable = false;
|
let mut remote_scannable = false;
|
||||||
|
#[cfg(not(feature = "gvfs"))]
|
||||||
|
let remote_scannable = false;
|
||||||
|
|
||||||
#[cfg(feature = "gvfs")]
|
#[cfg(feature = "gvfs")]
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue