WIP: support for network browsing
This commit is contained in:
parent
cd71c895f9
commit
c3d6498042
10 changed files with 251 additions and 85 deletions
64
src/app.rs
64
src/app.rs
|
|
@ -521,11 +521,14 @@ impl App {
|
|||
location: Location,
|
||||
selection_path: Option<PathBuf>,
|
||||
) -> Command<Message> {
|
||||
let mounters = self.mounters.clone();
|
||||
let icon_sizes = self.config.tab.icon_sizes;
|
||||
Command::perform(
|
||||
async move {
|
||||
let location2 = location.clone();
|
||||
match tokio::task::spawn_blocking(move || location2.scan(icon_sizes)).await {
|
||||
match tokio::task::spawn_blocking(move || location2.scan(mounters, icon_sizes))
|
||||
.await
|
||||
{
|
||||
Ok(items) => {
|
||||
message::app(Message::TabRescan(entity, location, items, selection_path))
|
||||
}
|
||||
|
|
@ -672,7 +675,10 @@ impl App {
|
|||
.size(16)
|
||||
.handle(),
|
||||
))
|
||||
.data(Location::Networks)
|
||||
.data(Location::Network(
|
||||
"network:///".to_string(),
|
||||
fl!("networks"),
|
||||
))
|
||||
.divider_above()
|
||||
});
|
||||
|
||||
|
|
@ -941,49 +947,35 @@ impl App {
|
|||
fn properties(&self, entity: Option<ContextItem>) -> Element<Message> {
|
||||
match entity {
|
||||
None => self.tab_properties(self.tab_model.active()),
|
||||
|
||||
Some(ContextItem::TabBar(entity)) => self.tab_properties(entity),
|
||||
|
||||
Some(ContextItem::NavBar(item)) => {
|
||||
let mut children = Vec::new();
|
||||
|
||||
let mut children = Vec::with_capacity(1);
|
||||
if let Some(location) = self.nav_model.data::<Location>(item) {
|
||||
if let Location::Path(path) = location {
|
||||
let parent = path.parent().unwrap_or(path);
|
||||
|
||||
for item in Location::Path(parent.to_owned()).scan(IconSizes::default()) {
|
||||
if item.path_opt() == Some(path) {
|
||||
children.push(item.property_view(IconSizes::default()));
|
||||
}
|
||||
//TODO: this should be done once, not when generating the view!
|
||||
if let Ok(item) = tab::item_from_path(path, self.config.tab.icon_sizes) {
|
||||
children.push(item.property_view(IconSizes::default()));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
widget::settings::view_column(children).into()
|
||||
}
|
||||
|
||||
Some(ContextItem::BreadCrumbs(index)) => {
|
||||
let mut children = Vec::new();
|
||||
|
||||
let mut children = Vec::with_capacity(1);
|
||||
if let Some(tab) = self.tab_model.active_data::<Tab>() {
|
||||
let path = match tab.location {
|
||||
Location::Path(ref path) => Some(path),
|
||||
Location::Search(ref path, _) => Some(path),
|
||||
_ => None,
|
||||
}
|
||||
.and_then(|path| path.ancestors().nth(index))
|
||||
.map(|path| path.to_path_buf());
|
||||
if let Some(ref path) = path {
|
||||
let parent = path.parent().unwrap_or(path);
|
||||
|
||||
for item in Location::Path(parent.to_owned()).scan(IconSizes::default()) {
|
||||
if item.path_opt() == Some(path) {
|
||||
children.push(item.property_view(IconSizes::default()));
|
||||
}
|
||||
let path_opt = tab
|
||||
.location
|
||||
.path_opt()
|
||||
.and_then(|path| path.ancestors().nth(index))
|
||||
.map(|path| path.to_path_buf());
|
||||
if let Some(ref path) = path_opt {
|
||||
//TODO: this should be done once, not when generating the view!
|
||||
if let Ok(item) = tab::item_from_path(path, self.config.tab.icon_sizes) {
|
||||
children.push(item.property_view(IconSizes::default()));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
widget::settings::view_column(children).into()
|
||||
}
|
||||
}
|
||||
|
|
@ -2396,11 +2388,14 @@ impl Application for App {
|
|||
self.toasts.remove(id);
|
||||
|
||||
let mut paths = Vec::with_capacity(recently_trashed.len());
|
||||
let mounters = self.mounters.clone();
|
||||
let icon_sizes = self.config.tab.icon_sizes;
|
||||
|
||||
return cosmic::command::future(async move {
|
||||
match tokio::task::spawn_blocking(move || Location::Trash.scan(icon_sizes))
|
||||
.await
|
||||
match tokio::task::spawn_blocking(move || {
|
||||
Location::Trash.scan(mounters, icon_sizes)
|
||||
})
|
||||
.await
|
||||
{
|
||||
Ok(items) => {
|
||||
for path in &*recently_trashed {
|
||||
|
|
@ -3549,6 +3544,7 @@ pub(crate) mod test_utils {
|
|||
|
||||
use crate::{
|
||||
config::{IconSizes, TabConfig},
|
||||
mounter::MounterMap,
|
||||
tab::Item,
|
||||
};
|
||||
|
||||
|
|
@ -3711,7 +3707,7 @@ pub(crate) mod test_utils {
|
|||
|
||||
// New tab with items
|
||||
let location = Location::Path(path.to_owned());
|
||||
let items = location.scan(IconSizes::default());
|
||||
let items = location.scan(Mounters::new(MounterMap::new()), IconSizes::default());
|
||||
let mut tab = Tab::new(location, TabConfig::default());
|
||||
tab.set_items(items);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue