fix: conditional features and tests
This commit is contained in:
parent
5a7e766c08
commit
e9b87cb1df
8 changed files with 19 additions and 25 deletions
|
|
@ -6,7 +6,7 @@ use cosmic::iced::{self, Length, Limits, Task};
|
||||||
use cosmic::iced_runtime::core::window;
|
use cosmic::iced_runtime::core::window;
|
||||||
use cosmic::iced_runtime::platform_specific::wayland::popup::SctkPopupSettings;
|
use cosmic::iced_runtime::platform_specific::wayland::popup::SctkPopupSettings;
|
||||||
use cosmic::iced_runtime::platform_specific::wayland::subsurface;
|
use cosmic::iced_runtime::platform_specific::wayland::subsurface;
|
||||||
use cosmic::surface_message::{MessageWrapper, SurfaceMessage};
|
use cosmic::surface::{MessageWrapper, SurfaceMessage};
|
||||||
use cosmic::widget::dropdown::DropdownView;
|
use cosmic::widget::dropdown::DropdownView;
|
||||||
use cosmic::widget::{autosize, dropdown, layer_container, list_column, settings, toggler};
|
use cosmic::widget::{autosize, dropdown, layer_container, list_column, settings, toggler};
|
||||||
use cosmic::{iced_core, Element};
|
use cosmic::{iced_core, Element};
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,10 @@ pub enum NavMenuAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl menu::Action for NavMenuAction {
|
impl menu::Action for NavMenuAction {
|
||||||
type Message = cosmic::app::Message<Message>;
|
type Message = cosmic::Action<Message>;
|
||||||
|
|
||||||
fn message(&self) -> Self::Message {
|
fn message(&self) -> Self::Message {
|
||||||
cosmic::app::Message::App(Message::NavMenuAction(*self))
|
cosmic::Action::App(Message::NavMenuAction(*self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ impl cosmic::Application for App {
|
||||||
fn nav_context_menu(
|
fn nav_context_menu(
|
||||||
&self,
|
&self,
|
||||||
id: nav_bar::Id,
|
id: nav_bar::Id,
|
||||||
) -> Option<Vec<menu::Tree<cosmic::app::Message<Self::Message>>>> {
|
) -> Option<Vec<menu::Tree<cosmic::Action<Self::Message>>>> {
|
||||||
Some(menu::items(
|
Some(menu::items(
|
||||||
&HashMap::new(),
|
&HashMap::new(),
|
||||||
vec![
|
vec![
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ use apply::Apply;
|
||||||
use cosmic::app::{Core, Settings, Task};
|
use cosmic::app::{Core, Settings, Task};
|
||||||
use cosmic::dialog::file_chooser::{self, FileFilter};
|
use cosmic::dialog::file_chooser::{self, FileFilter};
|
||||||
use cosmic::iced_core::Length;
|
use cosmic::iced_core::Length;
|
||||||
use cosmic::surface_message::{MessageWrapper, SurfaceMessage};
|
|
||||||
use cosmic::widget::button;
|
use cosmic::widget::button;
|
||||||
use cosmic::{executor, iced, ApplicationExt, Element};
|
use cosmic::{executor, iced, ApplicationExt, Element};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
@ -35,22 +34,7 @@ pub enum Message {
|
||||||
OpenError(Arc<file_chooser::Error>),
|
OpenError(Arc<file_chooser::Error>),
|
||||||
OpenFile,
|
OpenFile,
|
||||||
Selected(Url),
|
Selected(Url),
|
||||||
Surface(SurfaceMessage),
|
Surface(cosmic::surface::Action),
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Message> for MessageWrapper<Message> {
|
|
||||||
fn from(value: Message) -> Self {
|
|
||||||
match value {
|
|
||||||
Message::Surface(s) => MessageWrapper::Surface(s),
|
|
||||||
m => MessageWrapper::Message(m),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<SurfaceMessage> for Message {
|
|
||||||
fn from(value: SurfaceMessage) -> Self {
|
|
||||||
Message::Surface(value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The [`App`] stores application-specific state.
|
/// The [`App`] stores application-specific state.
|
||||||
|
|
@ -202,7 +186,7 @@ impl cosmic::Application for App {
|
||||||
Message::CloseError => {
|
Message::CloseError => {
|
||||||
self.error_status = None;
|
self.error_status = None;
|
||||||
}
|
}
|
||||||
Message::Surface(surface_message) => {}
|
Message::Surface(surface) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::none()
|
Task::none()
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
// Copyright 2023 System76 <info@system76.com>
|
// Copyright 2023 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
use crate::app;
|
use crate::app;
|
||||||
|
|
||||||
pub const fn app<M>(message: M) -> Action<M> {
|
pub const fn app<M>(message: M) -> Action<M> {
|
||||||
Action::App(message)
|
Action::App(message)
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub const fn cosmic<M>(message: app::Action) -> Action<M> {
|
pub const fn cosmic<M>(message: app::Action) -> Action<M> {
|
||||||
Action::Cosmic(message)
|
Action::Cosmic(message)
|
||||||
}
|
}
|
||||||
|
|
@ -20,9 +21,10 @@ pub const fn none<M>() -> Action<M> {
|
||||||
pub enum Action<M> {
|
pub enum Action<M> {
|
||||||
/// Messages from the application, for the application.
|
/// Messages from the application, for the application.
|
||||||
App(M),
|
App(M),
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
/// Internal messages to be handled by libcosmic.
|
/// Internal messages to be handled by libcosmic.
|
||||||
Cosmic(app::Action),
|
Cosmic(app::Action),
|
||||||
#[cfg(feature = "single-instance")]
|
#[cfg(all(feature = "winit", feature = "single-instance"))]
|
||||||
/// Dbus activation messages
|
/// Dbus activation messages
|
||||||
DbusActivation(app::DbusActivationMessage),
|
DbusActivation(app::DbusActivationMessage),
|
||||||
/// Do nothing
|
/// Do nothing
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,12 @@ pub fn set_title<M>(id: window::Id, title: String) -> iced::Task<crate::Action<M
|
||||||
iced::Task::none()
|
iced::Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub fn set_scaling_factor<M: Send + 'static>(factor: f32) -> iced::Task<crate::Action<M>> {
|
pub fn set_scaling_factor<M: Send + 'static>(factor: f32) -> iced::Task<crate::Action<M>> {
|
||||||
iced::Task::done(crate::app::Action::ScaleFactor(factor)).map(crate::Action::Cosmic)
|
iced::Task::done(crate::app::Action::ScaleFactor(factor)).map(crate::Action::Cosmic)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub fn set_theme<M: Send + 'static>(theme: crate::Theme) -> iced::Task<crate::Action<M>> {
|
pub fn set_theme<M: Send + 'static>(theme: crate::Theme) -> iced::Task<crate::Action<M>> {
|
||||||
iced::Task::done(crate::app::Action::AppThemeChange(theme)).map(crate::Action::Cosmic)
|
iced::Task::done(crate::app::Action::AppThemeChange(theme)).map(crate::Action::Cosmic)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -382,6 +382,7 @@ impl Core {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub fn drag<M: Send + 'static>(&self, id: Option<window::Id>) -> crate::app::Task<M> {
|
pub fn drag<M: Send + 'static>(&self, id: Option<window::Id>) -> crate::app::Task<M> {
|
||||||
let Some(id) = id.or(self.main_window) else {
|
let Some(id) = id.or(self.main_window) else {
|
||||||
return iced::Task::none();
|
return iced::Task::none();
|
||||||
|
|
@ -389,6 +390,7 @@ impl Core {
|
||||||
crate::command::drag(id)
|
crate::command::drag(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub fn maximize<M: Send + 'static>(
|
pub fn maximize<M: Send + 'static>(
|
||||||
&self,
|
&self,
|
||||||
id: Option<window::Id>,
|
id: Option<window::Id>,
|
||||||
|
|
@ -400,6 +402,7 @@ impl Core {
|
||||||
crate::command::maximize(id, maximized)
|
crate::command::maximize(id, maximized)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub fn minimize<M: Send + 'static>(&self, id: Option<window::Id>) -> crate::app::Task<M> {
|
pub fn minimize<M: Send + 'static>(&self, id: Option<window::Id>) -> crate::app::Task<M> {
|
||||||
let Some(id) = id.or(self.main_window) else {
|
let Some(id) = id.or(self.main_window) else {
|
||||||
return iced::Task::none();
|
return iced::Task::none();
|
||||||
|
|
@ -407,6 +410,7 @@ impl Core {
|
||||||
crate::command::minimize(id)
|
crate::command::minimize(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub fn set_title<M: Send + 'static>(
|
pub fn set_title<M: Send + 'static>(
|
||||||
&self,
|
&self,
|
||||||
id: Option<window::Id>,
|
id: Option<window::Id>,
|
||||||
|
|
@ -418,6 +422,7 @@ impl Core {
|
||||||
crate::command::set_title(id, title)
|
crate::command::set_title(id, title)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub fn set_windowed<M: Send + 'static>(&self, id: Option<window::Id>) -> crate::app::Task<M> {
|
pub fn set_windowed<M: Send + 'static>(&self, id: Option<window::Id>) -> crate::app::Task<M> {
|
||||||
let Some(id) = id.or(self.main_window) else {
|
let Some(id) = id.or(self.main_window) else {
|
||||||
return iced::Task::none();
|
return iced::Task::none();
|
||||||
|
|
@ -425,6 +430,7 @@ impl Core {
|
||||||
crate::command::set_windowed(id)
|
crate::command::set_windowed(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub fn toggle_maximize<M: Send + 'static>(
|
pub fn toggle_maximize<M: Send + 'static>(
|
||||||
&self,
|
&self,
|
||||||
id: Option<window::Id>,
|
id: Option<window::Id>,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright 2025 System76 <info@system76.com>
|
// Copyright 2025 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
#[cfg(feature = "winit")]
|
||||||
pub mod action;
|
pub mod action;
|
||||||
|
|
||||||
use iced::Limits;
|
use iced::Limits;
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,6 @@ pub mod aspect_ratio;
|
||||||
#[cfg(feature = "autosize")]
|
#[cfg(feature = "autosize")]
|
||||||
pub mod autosize;
|
pub mod autosize;
|
||||||
|
|
||||||
#[cfg(feature = "winit")]
|
|
||||||
pub(crate) mod responsive_container;
|
pub(crate) mod responsive_container;
|
||||||
|
|
||||||
#[cfg(feature = "surface-message")]
|
#[cfg(feature = "surface-message")]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue