Breadcrumb view
This commit is contained in:
parent
1aba09a4d0
commit
209622b758
4 changed files with 134 additions and 37 deletions
38
Cargo.lock
generated
38
Cargo.lock
generated
|
|
@ -941,7 +941,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config"
|
name = "cosmic-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomicwrites",
|
"atomicwrites",
|
||||||
"cosmic-config-derive",
|
"cosmic-config-derive",
|
||||||
|
|
@ -956,7 +956,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config-derive"
|
name = "cosmic-config-derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
|
|
@ -986,7 +986,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-text"
|
name = "cosmic-text"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-text.git?branch=refactor#f9a9463ea011f4f349ed6fe802179f0d24c61e7e"
|
source = "git+https://github.com/pop-os/cosmic-text.git?branch=refactor#dd4c4cbbe2d5ed5046054b5361a6eeead50e0bb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.1",
|
"bitflags 2.4.1",
|
||||||
"fontdb",
|
"fontdb",
|
||||||
|
|
@ -1007,7 +1007,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-theme"
|
name = "cosmic-theme"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"almost",
|
"almost",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -2310,7 +2310,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2325,7 +2325,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_accessibility"
|
name = "iced_accessibility"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_winit",
|
"accesskit_winit",
|
||||||
|
|
@ -2334,7 +2334,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"instant",
|
"instant",
|
||||||
|
|
@ -2350,7 +2350,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2363,7 +2363,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2386,7 +2386,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_renderer"
|
name = "iced_renderer"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
|
|
@ -2399,7 +2399,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_runtime"
|
name = "iced_runtime"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
|
|
@ -2409,7 +2409,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_style"
|
name = "iced_style"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -2419,7 +2419,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_tiny_skia"
|
name = "iced_tiny_skia"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
|
|
@ -2437,7 +2437,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2457,7 +2457,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_widget"
|
name = "iced_widget"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_renderer",
|
"iced_renderer",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2471,7 +2471,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_winit"
|
name = "iced_winit"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2768,7 +2768,7 @@ checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic.git#6850e53855ad5884d89a5bd5eeeed08a0705004c"
|
source = "git+https://github.com/pop-os/libcosmic.git#9fb3d874e18ce36fadea931e16488fdbf28d3d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"ashpd",
|
"ashpd",
|
||||||
|
|
@ -6036,9 +6036,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.5.33"
|
version = "0.5.34"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b7520bbdec7211caa7c4e682eb1fbe07abe20cee6756b6e00f537c82c11816aa"
|
checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
empty-folder = Empty folder
|
empty-folder = Empty folder
|
||||||
empty-folder-hidden = Empty folder (has hidden items)
|
empty-folder-hidden = Empty folder (has hidden items)
|
||||||
|
filesystem = Filesystem
|
||||||
trash = Trash
|
trash = Trash
|
||||||
|
|
||||||
# Context Pages
|
# Context Pages
|
||||||
|
|
|
||||||
35
src/main.rs
35
src/main.rs
|
|
@ -9,8 +9,7 @@ use cosmic::{
|
||||||
event,
|
event,
|
||||||
keyboard::{Event as KeyEvent, KeyCode, Modifiers},
|
keyboard::{Event as KeyEvent, KeyCode, Modifiers},
|
||||||
subscription::Subscription,
|
subscription::Subscription,
|
||||||
widget::row,
|
window, Event, Length, Point,
|
||||||
window, Alignment, Event, Length, Point,
|
|
||||||
},
|
},
|
||||||
style,
|
style,
|
||||||
widget::{self, segmented_button},
|
widget::{self, segmented_button},
|
||||||
|
|
@ -601,17 +600,33 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn header_start(&self) -> Vec<Element<Self::Message>> {
|
fn header_start(&self) -> Vec<Element<Self::Message>> {
|
||||||
|
vec![
|
||||||
|
menu::menu_bar().into(),
|
||||||
|
//TODO: use theme defined space?
|
||||||
|
widget::horizontal_space(Length::Fixed(32.0)).into(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn header_center(&self) -> Vec<Element<Self::Message>> {
|
||||||
let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing;
|
let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing;
|
||||||
|
|
||||||
vec![row![
|
let entity = self.tab_model.active();
|
||||||
menu::menu_bar(),
|
let tab = match self.tab_model.data::<Tab>(entity) {
|
||||||
widget::button(widget::icon::from_name("go-up-symbolic").size(16).icon())
|
Some(some) => some,
|
||||||
.on_press(Message::TabMessage(None, tab::Message::Parent))
|
None => return Vec::new(),
|
||||||
.padding(space_xxs)
|
};
|
||||||
.style(style::Button::Icon),
|
|
||||||
|
vec![tab
|
||||||
|
.breadcrumbs_view(&self.core)
|
||||||
|
.map(move |message| Message::TabMessage(Some(entity), message))
|
||||||
|
.into()]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn header_end(&self) -> Vec<Element<Self::Message>> {
|
||||||
|
vec![
|
||||||
|
//TODO: use defined space
|
||||||
|
widget::horizontal_space(Length::Fixed(32.0)).into(),
|
||||||
]
|
]
|
||||||
.align_items(Alignment::Center)
|
|
||||||
.into()]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a view after each update.
|
/// Creates a view after each update.
|
||||||
|
|
|
||||||
97
src/tab.rs
97
src/tab.rs
|
|
@ -102,6 +102,20 @@ pub fn folder_icon_symbolic(path: &PathBuf, icon_size: u16) -> widget::icon::Han
|
||||||
.handle()
|
.handle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn trash_icon_symbolic(icon_size: u16) -> widget::icon::Handle {
|
||||||
|
let full = match trash::os_limited::list() {
|
||||||
|
Ok(entries) => !entries.is_empty(),
|
||||||
|
Err(_err) => false,
|
||||||
|
};
|
||||||
|
widget::icon::from_name(if full {
|
||||||
|
"user-trash-full-symbolic"
|
||||||
|
} else {
|
||||||
|
"user-trash-symbolic"
|
||||||
|
})
|
||||||
|
.size(icon_size)
|
||||||
|
.handle()
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: translate, add more levels?
|
//TODO: translate, add more levels?
|
||||||
fn format_size(size: u64) -> String {
|
fn format_size(size: u64) -> String {
|
||||||
const KIB: u64 = 1024;
|
const KIB: u64 = 1024;
|
||||||
|
|
@ -352,7 +366,6 @@ impl Location {
|
||||||
pub enum Message {
|
pub enum Message {
|
||||||
Click(Option<usize>),
|
Click(Option<usize>),
|
||||||
Location(Location),
|
Location(Location),
|
||||||
Parent,
|
|
||||||
RightClick(usize),
|
RightClick(usize),
|
||||||
View(View),
|
View(View),
|
||||||
}
|
}
|
||||||
|
|
@ -556,13 +569,6 @@ impl Tab {
|
||||||
Message::Location(location) => {
|
Message::Location(location) => {
|
||||||
cd = Some(location);
|
cd = Some(location);
|
||||||
}
|
}
|
||||||
Message::Parent => {
|
|
||||||
if let Location::Path(path) = &self.location {
|
|
||||||
if let Some(parent) = path.parent() {
|
|
||||||
cd = Some(Location::Path(parent.to_owned()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Message::RightClick(click_i) => {
|
Message::RightClick(click_i) => {
|
||||||
if let Some(ref mut items) = self.items_opt {
|
if let Some(ref mut items) = self.items_opt {
|
||||||
if !items.get(click_i).map_or(false, |x| x.selected) {
|
if !items.get(click_i).map_or(false, |x| x.selected) {
|
||||||
|
|
@ -597,6 +603,81 @@ impl Tab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn breadcrumbs_view(&self, core: &Core) -> Element<Message> {
|
||||||
|
let cosmic_theme::Spacing { space_xxxs, .. } = core.system_theme().cosmic().spacing;
|
||||||
|
|
||||||
|
let mut children: Vec<Element<_>> = Vec::new();
|
||||||
|
match &self.location {
|
||||||
|
Location::Path(path) => {
|
||||||
|
let home_dir = crate::home_dir();
|
||||||
|
for ancestor in path.ancestors() {
|
||||||
|
let ancestor = ancestor.to_path_buf();
|
||||||
|
let mut found_home = false;
|
||||||
|
let mut row = widget::row::with_capacity(2)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.spacing(space_xxxs);
|
||||||
|
match ancestor.file_name() {
|
||||||
|
Some(name) => {
|
||||||
|
if ancestor == home_dir {
|
||||||
|
row = row.push(
|
||||||
|
widget::icon::icon(folder_icon_symbolic(&ancestor, 16))
|
||||||
|
.size(16),
|
||||||
|
);
|
||||||
|
found_home = true;
|
||||||
|
}
|
||||||
|
row = row.push(widget::text(name.to_string_lossy().to_string()));
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
row = row.push(
|
||||||
|
widget::icon::from_name("drive-harddisk-system-symbolic")
|
||||||
|
.size(16)
|
||||||
|
.icon(),
|
||||||
|
);
|
||||||
|
row = row.push(widget::text(fl!("filesystem")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !children.is_empty() {
|
||||||
|
children.push(widget::text("/").into());
|
||||||
|
}
|
||||||
|
|
||||||
|
children.push(
|
||||||
|
widget::button(row)
|
||||||
|
.padding(space_xxxs)
|
||||||
|
.on_press(Message::Location(Location::Path(ancestor)))
|
||||||
|
.style(theme::Button::Text)
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
|
||||||
|
if found_home {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
children.reverse();
|
||||||
|
}
|
||||||
|
Location::Trash => {
|
||||||
|
let mut row = widget::row::with_capacity(2)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.spacing(space_xxxs);
|
||||||
|
row = row.push(widget::icon::icon(trash_icon_symbolic(16)).size(16));
|
||||||
|
row = row.push(widget::text(fl!("trash")));
|
||||||
|
|
||||||
|
children.push(
|
||||||
|
widget::button(row)
|
||||||
|
.padding(space_xxxs)
|
||||||
|
.on_press(Message::Location(Location::Trash))
|
||||||
|
.style(theme::Button::Text)
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
children.push(widget::horizontal_space(Length::Fill).into());
|
||||||
|
|
||||||
|
widget::container(widget::row::with_children(children).align_items(Alignment::Center))
|
||||||
|
.style(theme::Container::Primary)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn empty_view(&self, has_hidden: bool, core: &Core) -> Element<Message> {
|
pub fn empty_view(&self, has_hidden: bool, core: &Core) -> Element<Message> {
|
||||||
let cosmic_theme::Spacing { space_xxs, .. } = core.system_theme().cosmic().spacing;
|
let cosmic_theme::Spacing { space_xxs, .. } = core.system_theme().cosmic().spacing;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue