Fix compilation without desktop feature

This commit is contained in:
Jeremy Soller 2024-11-11 11:38:07 -07:00
parent e4a37273fd
commit 63126810b1
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
3 changed files with 13 additions and 2 deletions

View file

@ -97,6 +97,7 @@ pub enum Action {
EditHistory,
EditLocation,
EmptyTrash,
#[cfg(feature = "desktop")]
ExecEntryAction(usize),
ExtractHere,
Gallery,
@ -159,6 +160,7 @@ impl Action {
}
Action::EmptyTrash => Message::TabMessage(None, tab::Message::EmptyTrash),
Action::ExtractHere => Message::ExtractHere(entity_opt),
#[cfg(feature = "desktop")]
Action::ExecEntryAction(action) => {
Message::TabMessage(entity_opt, tab::Message::ExecEntryAction(None, *action))
}
@ -618,6 +620,7 @@ impl App {
}
}
#[cfg(feature = "desktop")]
fn exec_entry_action(entry: cosmic::desktop::DesktopEntryData, action: usize) {
if let Some(action) = entry.desktop_actions.get(action) {
// Largely copied from COSMIC app library
@ -2667,6 +2670,7 @@ impl Application for App {
tab::Command::EmptyTrash => {
self.dialog_pages.push_back(DialogPage::EmptyTrash);
}
#[cfg(feature = "desktop")]
tab::Command::ExecEntryAction(entry, action) => {
App::exec_entry_action(entry, action);
}

View file

@ -115,6 +115,7 @@ pub fn context_menu<'a>(
selected_types.dedup();
selected_trash_only = selected_trash_only && selected == 1;
// Parse the desktop entry if it is the only selection
#[cfg(feature = "desktop")]
let selected_desktop_entry = selected_desktop_entry.and_then(|path| {
if selected == 1 {
let lang_id = crate::localize::LANGUAGE_LOADER.current_language();
@ -139,8 +140,11 @@ pub fn context_menu<'a>(
}
} else if let Some(entry) = selected_desktop_entry {
children.push(menu_item(fl!("open"), Action::Open).into());
for (i, action) in entry.desktop_actions.into_iter().enumerate() {
children.push(menu_item(action.name, Action::ExecEntryAction(i)).into())
#[cfg(feature = "desktop")]
{
for (i, action) in entry.desktop_actions.into_iter().enumerate() {
children.push(menu_item(action.name, Action::ExecEntryAction(i)).into())
}
}
children.push(divider::horizontal::light().into());
children.push(menu_item(fl!("rename"), Action::Rename).into());

View file

@ -1006,6 +1006,7 @@ pub enum Command {
ChangeLocation(String, Location, Option<PathBuf>),
DropFiles(PathBuf, ClipboardPaste),
EmptyTrash,
#[cfg(feature = "desktop")]
ExecEntryAction(cosmic::desktop::DesktopEntryData, usize),
Iced(TaskWrapper),
MoveToTrash(Vec<PathBuf>),
@ -1036,6 +1037,7 @@ pub enum Message {
EditLocationEnable,
OpenInNewTab(PathBuf),
EmptyTrash,
#[cfg(feature = "desktop")]
ExecEntryAction(Option<PathBuf>, usize),
Gallery(bool),
GalleryPrevious,
@ -2322,6 +2324,7 @@ impl Tab {
Message::EmptyTrash => {
commands.push(Command::EmptyTrash);
}
#[cfg(feature = "desktop")]
Message::ExecEntryAction(path, action) => {
let lang_id = crate::localize::LANGUAGE_LOADER.current_language();
let language = lang_id.language.as_str();