From 63126810b10cdf03144d7c06916a1f282735cf2a Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 11 Nov 2024 11:38:07 -0700 Subject: [PATCH] Fix compilation without desktop feature --- src/app.rs | 4 ++++ src/menu.rs | 8 ++++++-- src/tab.rs | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index 0e9b120..897e07f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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); } diff --git a/src/menu.rs b/src/menu.rs index 86fcb73..d3616ae 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -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()); diff --git a/src/tab.rs b/src/tab.rs index 0741ef8..6f940c4 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -1006,6 +1006,7 @@ pub enum Command { ChangeLocation(String, Location, Option), DropFiles(PathBuf, ClipboardPaste), EmptyTrash, + #[cfg(feature = "desktop")] ExecEntryAction(cosmic::desktop::DesktopEntryData, usize), Iced(TaskWrapper), MoveToTrash(Vec), @@ -1036,6 +1037,7 @@ pub enum Message { EditLocationEnable, OpenInNewTab(PathBuf), EmptyTrash, + #[cfg(feature = "desktop")] ExecEntryAction(Option, 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();