Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/actions/tempfiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ pub fn open_dir() -> anyhow::Result<()> {
Ok(())
}

pub fn open_file(path: &str) -> anyhow::Result<()> {
open::that(Path::new(path))?;
Ok(())
}

pub fn clear() -> anyhow::Result<()> {
crate::plugins::tempfile::clear_files()?;
Ok(())
Expand Down
20 changes: 20 additions & 0 deletions src/dashboard/widgets/tempfiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ impl TempfilesWidget {
args: None,
}
}

fn open_action(path: &Path, name: &str) -> Action {
Action {
label: format!("Open {name}"),
desc: "Tempfile".into(),
action: format!("tempfile:open:{}", path.to_string_lossy()),
args: None,
}
}
}

impl Default for TempfilesWidget {
Expand Down Expand Up @@ -267,6 +276,17 @@ impl Widget for TempfilesWidget {
.small());
}
}
if ui
.small_button("Open")
.on_hover_text("Open file (not folder)")
.clicked()
{
let action = Self::open_action(&entry.path, display_name);
clicked = Some(WidgetAction {
query_override: Some(action.label.clone()),
action,
});
}
if ui.small_button("Clear").clicked() {
let action = Self::remove_action(&entry.path, display_name);
clicked = Some(WidgetAction {
Expand Down
5 changes: 5 additions & 0 deletions src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ enum ActionKind<'a> {
BrowserTabClear,
TempfileNew(Option<&'a str>),
TempfileOpen,
TempfileOpenFile(&'a str),
TempfileClear,
TempfileRemove(&'a str),
TempfileAlias {
Expand Down Expand Up @@ -713,6 +714,9 @@ fn parse_action_kind(action: &Action) -> ActionKind<'_> {
if s == "tempfile:new" {
return ActionKind::TempfileNew(None);
}
if let Some(path) = s.strip_prefix("tempfile:open:") {
return ActionKind::TempfileOpenFile(path);
}
if s == "tempfile:open" {
return ActionKind::TempfileOpen;
}
Expand Down Expand Up @@ -910,6 +914,7 @@ pub fn launch_action(action: &Action) -> anyhow::Result<()> {
}
ActionKind::TempfileNew(alias) => tempfiles::new(alias),
ActionKind::TempfileOpen => tempfiles::open_dir(),
ActionKind::TempfileOpenFile(path) => tempfiles::open_file(path),
ActionKind::TempfileClear => tempfiles::clear(),
ActionKind::TempfileRemove(path) => tempfiles::remove(path),
ActionKind::TempfileAlias { path, alias } => tempfiles::set_alias(path, alias),
Expand Down