Fix warnings
This commit is contained in:
parent
e9da2bfb90
commit
9b22c8f9ed
4 changed files with 23 additions and 45 deletions
36
src/app.rs
36
src/app.rs
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
app::{message, Command, Core},
|
app::{message, Command, Core},
|
||||||
cosmic_config::{self, CosmicConfigEntry},
|
cosmic_config, cosmic_theme, executor,
|
||||||
cosmic_theme, executor,
|
|
||||||
iced::{
|
iced::{
|
||||||
event,
|
event,
|
||||||
futures::{self, SinkExt},
|
futures::{self, SinkExt},
|
||||||
|
|
@ -237,19 +236,6 @@ impl App {
|
||||||
cosmic::app::command::set_theme(self.config.app_theme.theme())
|
cosmic::app::command::set_theme(self.config.app_theme.theme())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_config(&mut self) -> Command<Message> {
|
|
||||||
match self.config_handler {
|
|
||||||
Some(ref config_handler) => match self.config.write_entry(&config_handler) {
|
|
||||||
Ok(()) => {}
|
|
||||||
Err(err) => {
|
|
||||||
log::error!("failed to save config: {}", err);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
self.update_config()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_title(&mut self) -> Command<Message> {
|
fn update_title(&mut self) -> Command<Message> {
|
||||||
let (header_title, window_title) = match self.tab_model.text(self.tab_model.active()) {
|
let (header_title, window_title) = match self.tab_model.text(self.tab_model.active()) {
|
||||||
Some(tab_title) => (
|
Some(tab_title) => (
|
||||||
|
|
@ -317,7 +303,7 @@ impl App {
|
||||||
|
|
||||||
if !self.pending_operations.is_empty() {
|
if !self.pending_operations.is_empty() {
|
||||||
let mut section = widget::settings::view_section(fl!("pending"));
|
let mut section = widget::settings::view_section(fl!("pending"));
|
||||||
for (id, (op, progress)) in self.pending_operations.iter().rev() {
|
for (_id, (op, progress)) in self.pending_operations.iter().rev() {
|
||||||
section = section.add(widget::column::with_children(vec![
|
section = section.add(widget::column::with_children(vec![
|
||||||
widget::text(format!("{:?}", op)).into(),
|
widget::text(format!("{:?}", op)).into(),
|
||||||
widget::progress_bar(0.0..=100.0, *progress)
|
widget::progress_bar(0.0..=100.0, *progress)
|
||||||
|
|
@ -330,7 +316,7 @@ impl App {
|
||||||
|
|
||||||
if !self.failed_operations.is_empty() {
|
if !self.failed_operations.is_empty() {
|
||||||
let mut section = widget::settings::view_section(fl!("failed"));
|
let mut section = widget::settings::view_section(fl!("failed"));
|
||||||
for (id, (op, error)) in self.failed_operations.iter().rev() {
|
for (_id, (op, error)) in self.failed_operations.iter().rev() {
|
||||||
section = section.add(widget::column::with_children(vec![
|
section = section.add(widget::column::with_children(vec![
|
||||||
widget::text(format!("{:?}", op)).into(),
|
widget::text(format!("{:?}", op)).into(),
|
||||||
widget::text(error).into(),
|
widget::text(error).into(),
|
||||||
|
|
@ -341,7 +327,7 @@ impl App {
|
||||||
|
|
||||||
if !self.complete_operations.is_empty() {
|
if !self.complete_operations.is_empty() {
|
||||||
let mut section = widget::settings::view_section(fl!("complete"));
|
let mut section = widget::settings::view_section(fl!("complete"));
|
||||||
for (id, op) in self.complete_operations.iter().rev() {
|
for (_id, op) in self.complete_operations.iter().rev() {
|
||||||
section = section.add(widget::text(format!("{:?}", op)));
|
section = section.add(widget::text(format!("{:?}", op)));
|
||||||
}
|
}
|
||||||
children.push(section.into());
|
children.push(section.into());
|
||||||
|
|
@ -635,10 +621,10 @@ impl Application for App {
|
||||||
return self.update_config();
|
return self.update_config();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Copy(entity_opt) => {
|
Message::Copy(_entity_opt) => {
|
||||||
log::warn!("TODO: COPY");
|
log::warn!("TODO: COPY");
|
||||||
}
|
}
|
||||||
Message::Cut(entity_opt) => {
|
Message::Cut(_entity_opt) => {
|
||||||
log::warn!("TODO: CUT");
|
log::warn!("TODO: CUT");
|
||||||
}
|
}
|
||||||
Message::Key(modifiers, key) => {
|
Message::Key(modifiers, key) => {
|
||||||
|
|
@ -668,10 +654,10 @@ impl Application for App {
|
||||||
self.operation(Operation::Delete { paths });
|
self.operation(Operation::Delete { paths });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::NewFile(entity_opt) => {
|
Message::NewFile(_entity_opt) => {
|
||||||
log::warn!("TODO: NEW FILE");
|
log::warn!("TODO: NEW FILE");
|
||||||
}
|
}
|
||||||
Message::NewFolder(entity_opt) => {
|
Message::NewFolder(_entity_opt) => {
|
||||||
log::warn!("TODO: NEW FOLDER");
|
log::warn!("TODO: NEW FOLDER");
|
||||||
}
|
}
|
||||||
Message::NotifyEvent(event) => {
|
Message::NotifyEvent(event) => {
|
||||||
|
|
@ -712,7 +698,7 @@ impl Application for App {
|
||||||
log::warn!("message did not contain notify watcher");
|
log::warn!("message did not contain notify watcher");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Message::Paste(entity_opt) => {
|
Message::Paste(_entity_opt) => {
|
||||||
log::warn!("TODO: PASTE");
|
log::warn!("TODO: PASTE");
|
||||||
}
|
}
|
||||||
Message::PendingComplete(id) => {
|
Message::PendingComplete(id) => {
|
||||||
|
|
@ -1112,10 +1098,10 @@ impl Application for App {
|
||||||
move |mut msg_tx| async move {
|
move |mut msg_tx| async move {
|
||||||
match pending_operation.perform(id, &mut msg_tx).await {
|
match pending_operation.perform(id, &mut msg_tx).await {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
msg_tx.send(Message::PendingComplete(id)).await;
|
let _ = msg_tx.send(Message::PendingComplete(id)).await;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
msg_tx
|
let _ = msg_tx
|
||||||
.send(Message::PendingError(id, err.to_string()))
|
.send(Message::PendingError(id, err.to_string()))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ use cosmic::{
|
||||||
subscription::{self, Subscription},
|
subscription::{self, Subscription},
|
||||||
window, Event, Length, Size,
|
window, Event, Length, Size,
|
||||||
},
|
},
|
||||||
style,
|
|
||||||
widget::{self, segmented_button},
|
widget::{self, segmented_button},
|
||||||
Application, ApplicationExt, Element,
|
Application, ApplicationExt, Element,
|
||||||
};
|
};
|
||||||
|
|
@ -600,12 +599,7 @@ impl Application for App {
|
||||||
|
|
||||||
/// Creates a view after each update.
|
/// Creates a view after each update.
|
||||||
fn view(&self) -> Element<Message> {
|
fn view(&self) -> Element<Message> {
|
||||||
let cosmic_theme::Spacing {
|
let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing;
|
||||||
space_m,
|
|
||||||
space_s,
|
|
||||||
space_xxs,
|
|
||||||
..
|
|
||||||
} = self.core().system_theme().cosmic().spacing;
|
|
||||||
|
|
||||||
let mut tab_column = widget::column::with_capacity(2);
|
let mut tab_column = widget::column::with_capacity(2);
|
||||||
tab_column = tab_column.push(
|
tab_column = tab_column.push(
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@ pub enum Operation {
|
||||||
impl Operation {
|
impl Operation {
|
||||||
/// Perform the operation
|
/// Perform the operation
|
||||||
pub async fn perform(self, id: u64, msg_tx: &mut mpsc::Sender<Message>) -> Result<(), String> {
|
pub async fn perform(self, id: u64, msg_tx: &mut mpsc::Sender<Message>) -> Result<(), String> {
|
||||||
msg_tx.send(Message::PendingProgress(id, 0.0)).await;
|
let _ = msg_tx.send(Message::PendingProgress(id, 0.0)).await;
|
||||||
|
|
||||||
//TODO: IF ERROR, RETURN AN Operation THAT CAN UNDO THE CURRENT STATE
|
//TODO: IF ERROR, RETURN AN Operation THAT CAN UNDO THE CURRENT STATE
|
||||||
//TODO: SAFELY HANDLE CANCEL
|
//TODO: SAFELY HANDLE CANCEL
|
||||||
match self {
|
match self {
|
||||||
Self::Delete { paths } => {
|
Self::Delete { paths } => {
|
||||||
let mut total = paths.len();
|
let total = paths.len();
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for path in paths {
|
for path in paths {
|
||||||
tokio::task::spawn_blocking(|| trash::delete(path))
|
tokio::task::spawn_blocking(|| trash::delete(path))
|
||||||
|
|
@ -36,7 +36,7 @@ impl Operation {
|
||||||
.map_err(err_str)?
|
.map_err(err_str)?
|
||||||
.map_err(err_str)?;
|
.map_err(err_str)?;
|
||||||
count += 1;
|
count += 1;
|
||||||
msg_tx
|
let _ = msg_tx
|
||||||
.send(Message::PendingProgress(
|
.send(Message::PendingProgress(
|
||||||
id,
|
id,
|
||||||
100.0 * (count as f32) / (total as f32),
|
100.0 * (count as f32) / (total as f32),
|
||||||
|
|
@ -45,7 +45,7 @@ impl Operation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Restore { paths } => {
|
Self::Restore { paths } => {
|
||||||
let mut total = paths.len();
|
let total = paths.len();
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for path in paths {
|
for path in paths {
|
||||||
tokio::task::spawn_blocking(|| trash::os_limited::restore_all([path]))
|
tokio::task::spawn_blocking(|| trash::os_limited::restore_all([path]))
|
||||||
|
|
@ -53,7 +53,7 @@ impl Operation {
|
||||||
.map_err(err_str)?
|
.map_err(err_str)?
|
||||||
.map_err(err_str)?;
|
.map_err(err_str)?;
|
||||||
count += 1;
|
count += 1;
|
||||||
msg_tx
|
let _ = msg_tx
|
||||||
.send(Message::PendingProgress(
|
.send(Message::PendingProgress(
|
||||||
id,
|
id,
|
||||||
100.0 * (count as f32) / (total as f32),
|
100.0 * (count as f32) / (total as f32),
|
||||||
|
|
@ -66,7 +66,7 @@ impl Operation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_tx.send(Message::PendingProgress(id, 100.0)).await;
|
let _ = msg_tx.send(Message::PendingProgress(id, 100.0)).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
src/tab.rs
12
src/tab.rs
|
|
@ -25,7 +25,6 @@ use std::{
|
||||||
fmt,
|
fmt,
|
||||||
fs::{self, Metadata},
|
fs::{self, Metadata},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
process,
|
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -566,7 +565,7 @@ impl Tab {
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("{:?}", rect);
|
println!("{:?}", rect);
|
||||||
for (i, item) in items.iter_mut().enumerate() {
|
for (_i, item) in items.iter_mut().enumerate() {
|
||||||
item.selected = false;
|
item.selected = false;
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
@ -1125,7 +1124,7 @@ impl Tab {
|
||||||
mouse_area::MouseArea::new(widget::container(item_view).height(Length::Fill))
|
mouse_area::MouseArea::new(widget::container(item_view).height(Length::Fill))
|
||||||
.on_drag(move |point_opt| Message::Drag(point_opt))
|
.on_drag(move |point_opt| Message::Drag(point_opt))
|
||||||
.on_press(move |_point_opt| Message::Click(None))
|
.on_press(move |_point_opt| Message::Click(None))
|
||||||
.on_release(move |point_opt| Message::Drag(None))
|
.on_release(move |_point_opt| Message::Drag(None))
|
||||||
.on_back_press(move |_point_opt| Message::GoPrevious)
|
.on_back_press(move |_point_opt| Message::GoPrevious)
|
||||||
.on_forward_press(move |_point_opt| Message::GoNext)
|
.on_forward_press(move |_point_opt| Message::GoNext)
|
||||||
.show_drag_box(true);
|
.show_drag_box(true);
|
||||||
|
|
@ -1240,12 +1239,11 @@ mod tests {
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
use test_log::test;
|
use test_log::test;
|
||||||
|
|
||||||
use super::{scan_path, Item, Location, Message, Tab};
|
use super::{scan_path, Location, Message, Tab};
|
||||||
use crate::{
|
use crate::{
|
||||||
app::test_utils::{
|
app::test_utils::{
|
||||||
assert_eq_tab_path, assert_eq_tab_path_contents, empty_fs, eq_path_item, filter_dirs,
|
assert_eq_tab_path, empty_fs, eq_path_item, filter_dirs, read_dir_sorted, simple_fs,
|
||||||
read_dir_sorted, simple_fs, sort_files, tab_click_new, NAME_LEN, NUM_DIRS, NUM_FILES,
|
tab_click_new, NAME_LEN, NUM_DIRS, NUM_FILES, NUM_HIDDEN, NUM_NESTED,
|
||||||
NUM_HIDDEN, NUM_NESTED,
|
|
||||||
},
|
},
|
||||||
config::{IconSizes, TabConfig},
|
config::{IconSizes, TabConfig},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue