Implement open with buttons
This commit is contained in:
parent
a54957ddf2
commit
ac4626d9cf
2 changed files with 23 additions and 5 deletions
20
src/app.rs
20
src/app.rs
|
|
@ -145,6 +145,7 @@ pub enum Message {
|
||||||
NotifyEvent(notify::Event),
|
NotifyEvent(notify::Event),
|
||||||
NotifyWatcher(WatcherWrapper),
|
NotifyWatcher(WatcherWrapper),
|
||||||
OpenTerminal(Option<Entity>),
|
OpenTerminal(Option<Entity>),
|
||||||
|
OpenWith(PathBuf, mime_app::MimeApp),
|
||||||
Paste(Option<Entity>),
|
Paste(Option<Entity>),
|
||||||
PendingComplete(u64),
|
PendingComplete(u64),
|
||||||
PendingError(u64, String),
|
PendingError(u64, String),
|
||||||
|
|
@ -896,9 +897,9 @@ impl Application for App {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"failed to launch terminal {:?} in {:?}: {}",
|
"failed to open {:?} with terminal {:?}: {}",
|
||||||
terminal.id,
|
|
||||||
path,
|
path,
|
||||||
|
terminal.id,
|
||||||
err
|
err
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -909,6 +910,21 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::OpenWith(path, app) => {
|
||||||
|
if let Some(mut command) = app.command(Some(path.clone())) {
|
||||||
|
match spawn_detached(&mut command) {
|
||||||
|
Ok(()) => {}
|
||||||
|
Err(err) => {
|
||||||
|
log::warn!("failed to open {:?} with {:?}: {}", path, app.id, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::warn!("failed to get command for {:?}", app.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close Open With context view
|
||||||
|
self.core.window.show_context = false;
|
||||||
|
}
|
||||||
Message::Paste(_entity_opt) => {
|
Message::Paste(_entity_opt) => {
|
||||||
log::warn!("TODO: PASTE");
|
log::warn!("TODO: PASTE");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::Action,
|
app::{self, Action},
|
||||||
config::{IconSizes, TabConfig},
|
config::{IconSizes, TabConfig},
|
||||||
dialog::DialogKind,
|
dialog::DialogKind,
|
||||||
fl,
|
fl,
|
||||||
|
|
@ -485,7 +485,7 @@ pub struct Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
pub fn open_with_view(&self, sizes: IconSizes) -> Element<crate::app::Message> {
|
pub fn open_with_view(&self, sizes: IconSizes) -> Element<app::Message> {
|
||||||
let cosmic_theme::Spacing {
|
let cosmic_theme::Spacing {
|
||||||
space_xs,
|
space_xs,
|
||||||
space_xxxs,
|
space_xxxs,
|
||||||
|
|
@ -505,6 +505,8 @@ impl Item {
|
||||||
])
|
])
|
||||||
.spacing(space_xs),
|
.spacing(space_xs),
|
||||||
)
|
)
|
||||||
|
//TODO: do not clone so much?
|
||||||
|
.on_press(app::Message::OpenWith(self.path.clone(), app.clone()))
|
||||||
.padding(space_xs)
|
.padding(space_xs)
|
||||||
.width(Length::Fill),
|
.width(Length::Fill),
|
||||||
);
|
);
|
||||||
|
|
@ -513,7 +515,7 @@ impl Item {
|
||||||
column.into()
|
column.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn property_view(&self, sizes: IconSizes) -> Element<crate::app::Message> {
|
pub fn property_view(&self, sizes: IconSizes) -> Element<app::Message> {
|
||||||
let cosmic_theme::Spacing { space_xxxs, .. } = theme::active().cosmic().spacing;
|
let cosmic_theme::Spacing { space_xxxs, .. } = theme::active().cosmic().spacing;
|
||||||
|
|
||||||
let mut column = widget::column().spacing(space_xxxs);
|
let mut column = widget::column().spacing(space_xxxs);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue