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",
|
"about",
|
||||||
"advanced-shaping",
|
"advanced-shaping",
|
||||||
"autosize",
|
"autosize",
|
||||||
"desktop",
|
|
||||||
"multi-window",
|
"multi-window",
|
||||||
"tokio",
|
"tokio",
|
||||||
"winit",
|
"winit",
|
||||||
|
|
@ -113,7 +112,7 @@ default = [
|
||||||
"wgpu",
|
"wgpu",
|
||||||
]
|
]
|
||||||
dbus-config = ["libcosmic/dbus-config"]
|
dbus-config = ["libcosmic/dbus-config"]
|
||||||
desktop = ["dep:cosmic-mime-apps", "dep:xdg"]
|
desktop = ["libcosmic/desktop", "dep:cosmic-mime-apps", "dep:xdg"]
|
||||||
desktop-applet = []
|
desktop-applet = []
|
||||||
gvfs = ["dep:gio", "dep:glib"]
|
gvfs = ["dep:gio", "dep:glib"]
|
||||||
io-uring = ["compio/io-uring"]
|
io-uring = ["compio/io-uring"]
|
||||||
|
|
|
||||||
16
src/app.rs
16
src/app.rs
|
|
@ -18,9 +18,7 @@ use cosmic::{
|
||||||
Application, ApplicationExt, Element,
|
Application, ApplicationExt, Element,
|
||||||
app::{self, Core, Task, context_drawer},
|
app::{self, Core, Task, context_drawer},
|
||||||
cosmic_config::{self, ConfigSet},
|
cosmic_config::{self, ConfigSet},
|
||||||
cosmic_theme,
|
cosmic_theme, executor,
|
||||||
desktop::fde::DesktopEntry,
|
|
||||||
executor,
|
|
||||||
iced::core::widget::operation::focusable::unfocus,
|
iced::core::widget::operation::focusable::unfocus,
|
||||||
iced::runtime::{clipboard, task},
|
iced::runtime::{clipboard, task},
|
||||||
iced::widget::{button::focus, scrollable::AbsoluteOffset},
|
iced::widget::{button::focus, scrollable::AbsoluteOffset},
|
||||||
|
|
@ -835,9 +833,12 @@ impl App {
|
||||||
|
|
||||||
// First launch apps that can be launched directly
|
// First launch apps that can be launched directly
|
||||||
if mime == "application/x-desktop" {
|
if mime == "application/x-desktop" {
|
||||||
// Try opening desktop application
|
#[cfg(feature = "desktop")]
|
||||||
Self::launch_desktop_entries(&paths);
|
{
|
||||||
continue;
|
// Try opening desktop application
|
||||||
|
Self::launch_desktop_entries(&paths);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
} else if mime == "application/x-executable" || mime == "application/vnd.appimage" {
|
} else if mime == "application/x-executable" || mime == "application/vnd.appimage" {
|
||||||
// Try opening executable
|
// Try opening executable
|
||||||
for path in paths {
|
for path in paths {
|
||||||
|
|
@ -898,7 +899,10 @@ impl App {
|
||||||
Task::batch(tasks)
|
Task::batch(tasks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "desktop")]
|
||||||
fn launch_desktop_entries(paths: &[impl AsRef<Path>]) {
|
fn launch_desktop_entries(paths: &[impl AsRef<Path>]) {
|
||||||
|
use cosmic::desktop::fde::DesktopEntry;
|
||||||
|
|
||||||
for path in paths.iter().map(AsRef::as_ref) {
|
for path in paths.iter().map(AsRef::as_ref) {
|
||||||
match DesktopEntry::from_path::<&str>(path, None) {
|
match DesktopEntry::from_path::<&str>(path, None) {
|
||||||
Ok(entry) => match entry.exec() {
|
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::{
|
use cosmic::{
|
||||||
Apply, Element, cosmic_theme,
|
Apply, Element, cosmic_theme, font,
|
||||||
desktop::fde::{DesktopEntry, get_languages_from_env},
|
|
||||||
font,
|
|
||||||
iced::core::{mouse::ScrollDelta, widget::tree},
|
iced::core::{mouse::ScrollDelta, widget::tree},
|
||||||
iced::{
|
iced::{
|
||||||
Alignment, Border, Color, ContentFit, Length, Point, Rectangle, Size, Subscription, Vector,
|
Alignment, Border, Color, ContentFit, Length, Point, Rectangle, Size, Subscription, Vector,
|
||||||
|
|
@ -557,6 +557,12 @@ pub fn fs_kind(_metadata: &Metadata) -> FsKind {
|
||||||
FsKind::Local
|
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> {
|
fn get_desktop_file_display_name(path: &Path) -> Option<String> {
|
||||||
let locales = get_languages_from_env();
|
let locales = get_languages_from_env();
|
||||||
let entry = match DesktopEntry::from_path(path, Some(&locales)) {
|
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())
|
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> {
|
fn get_desktop_file_icon(path: &Path) -> Option<String> {
|
||||||
let entry = match DesktopEntry::from_path::<&str>(path, None) {
|
let entry = match DesktopEntry::from_path::<&str>(path, None) {
|
||||||
Ok(ok) => ok,
|
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>) {
|
pub fn parse_desktop_file(path: &Path) -> (Option<String>, Option<String>) {
|
||||||
let locales = get_languages_from_env();
|
let locales = get_languages_from_env();
|
||||||
let entry = match DesktopEntry::from_path(path, Some(&locales)) {
|
let entry = match DesktopEntry::from_path(path, Some(&locales)) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright 2023 System76 <info@system76.com>
|
// Copyright 2023 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
#[cfg(feature = "desktop")]
|
||||||
use cosmic::desktop::fde::GenericEntry;
|
use cosmic::desktop::fde::GenericEntry;
|
||||||
use mime_guess::Mime;
|
use mime_guess::Mime;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue