From 62bfcc3550cdac1a492b1f4c040e09aa7de09bc3 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 17 Apr 2026 12:41:02 -0600 Subject: [PATCH] Put libcosmic/desktop behind desktop feature --- Cargo.toml | 3 +-- src/app.rs | 16 ++++++++++------ src/tab.rs | 19 ++++++++++++++++--- src/thumbnailer.rs | 1 + 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9ef9807..949f99d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,7 +81,6 @@ features = [ "about", "advanced-shaping", "autosize", - "desktop", "multi-window", "tokio", "winit", @@ -113,7 +112,7 @@ default = [ "wgpu", ] dbus-config = ["libcosmic/dbus-config"] -desktop = ["dep:cosmic-mime-apps", "dep:xdg"] +desktop = ["libcosmic/desktop", "dep:cosmic-mime-apps", "dep:xdg"] desktop-applet = [] gvfs = ["dep:gio", "dep:glib"] io-uring = ["compio/io-uring"] diff --git a/src/app.rs b/src/app.rs index af0ecbe..feca9c5 100644 --- a/src/app.rs +++ b/src/app.rs @@ -18,9 +18,7 @@ use cosmic::{ Application, ApplicationExt, Element, app::{self, Core, Task, context_drawer}, cosmic_config::{self, ConfigSet}, - cosmic_theme, - desktop::fde::DesktopEntry, - executor, + cosmic_theme, executor, iced::core::widget::operation::focusable::unfocus, iced::runtime::{clipboard, task}, iced::widget::{button::focus, scrollable::AbsoluteOffset}, @@ -835,9 +833,12 @@ impl App { // First launch apps that can be launched directly if mime == "application/x-desktop" { - // Try opening desktop application - Self::launch_desktop_entries(&paths); - continue; + #[cfg(feature = "desktop")] + { + // Try opening desktop application + Self::launch_desktop_entries(&paths); + continue; + } } else if mime == "application/x-executable" || mime == "application/vnd.appimage" { // Try opening executable for path in paths { @@ -898,7 +899,10 @@ impl App { Task::batch(tasks) } + #[cfg(feature = "desktop")] fn launch_desktop_entries(paths: &[impl AsRef]) { + use cosmic::desktop::fde::DesktopEntry; + for path in paths.iter().map(AsRef::as_ref) { match DesktopEntry::from_path::<&str>(path, None) { Ok(entry) => match entry.exec() { diff --git a/src/tab.rs b/src/tab.rs index a350f08..2aeea04 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -1,7 +1,7 @@ +#[cfg(feature = "desktop")] +use cosmic::desktop::fde::{DesktopEntry, get_languages_from_env}; use cosmic::{ - Apply, Element, cosmic_theme, - desktop::fde::{DesktopEntry, get_languages_from_env}, - font, + Apply, Element, cosmic_theme, font, iced::core::{mouse::ScrollDelta, widget::tree}, iced::{ Alignment, Border, Color, ContentFit, Length, Point, Rectangle, Size, Subscription, Vector, @@ -557,6 +557,12 @@ pub fn fs_kind(_metadata: &Metadata) -> FsKind { FsKind::Local } +#[cfg(not(feature = "desktop"))] +fn get_desktop_file_display_name(path: &Path) -> Option { + None +} + +#[cfg(feature = "desktop")] fn get_desktop_file_display_name(path: &Path) -> Option { let locales = get_languages_from_env(); let entry = match DesktopEntry::from_path(path, Some(&locales)) { @@ -570,6 +576,12 @@ fn get_desktop_file_display_name(path: &Path) -> Option { entry.name(&locales).map(|s| s.into_owned()) } +#[cfg(not(feature = "desktop"))] +fn get_desktop_file_icon(path: &Path) -> Option { + None +} + +#[cfg(feature = "desktop")] fn get_desktop_file_icon(path: &Path) -> Option { let entry = match DesktopEntry::from_path::<&str>(path, None) { Ok(ok) => ok, @@ -593,6 +605,7 @@ fn desktop_icon_handle(icon: &str, size: u16) -> widget::icon::Handle { } } +#[cfg(feature = "desktop")] pub fn parse_desktop_file(path: &Path) -> (Option, Option) { let locales = get_languages_from_env(); let entry = match DesktopEntry::from_path(path, Some(&locales)) { diff --git a/src/thumbnailer.rs b/src/thumbnailer.rs index f996f03..f7786ed 100644 --- a/src/thumbnailer.rs +++ b/src/thumbnailer.rs @@ -1,6 +1,7 @@ // Copyright 2023 System76 // SPDX-License-Identifier: GPL-3.0-only +#[cfg(feature = "desktop")] use cosmic::desktop::fde::GenericEntry; use mime_guess::Mime; use rustc_hash::FxHashMap;