Put libcosmic/desktop behind desktop feature
This commit is contained in:
parent
9c0eb63b82
commit
62bfcc3550
4 changed files with 28 additions and 11 deletions
|
|
@ -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"]
|
||||
|
|
|
|||
16
src/app.rs
16
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<Path>]) {
|
||||
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() {
|
||||
|
|
|
|||
19
src/tab.rs
19
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<String> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "desktop")]
|
||||
fn get_desktop_file_display_name(path: &Path) -> Option<String> {
|
||||
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<String> {
|
|||
entry.name(&locales).map(|s| s.into_owned())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "desktop"))]
|
||||
fn get_desktop_file_icon(path: &Path) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "desktop")]
|
||||
fn get_desktop_file_icon(path: &Path) -> Option<String> {
|
||||
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<String>, Option<String>) {
|
||||
let locales = get_languages_from_env();
|
||||
let entry = match DesktopEntry::from_path(path, Some(&locales)) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2023 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#[cfg(feature = "desktop")]
|
||||
use cosmic::desktop::fde::GenericEntry;
|
||||
use mime_guess::Mime;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue