refactor(applet): move applet module to crate root
This commit is contained in:
parent
69cd9a3bfa
commit
8f7b400143
6 changed files with 20 additions and 17 deletions
|
|
@ -3,5 +3,5 @@ use crate::window::Window;
|
|||
mod window;
|
||||
|
||||
fn main() -> cosmic::iced::Result {
|
||||
cosmic::app::applet::run::<Window>(true, ())
|
||||
cosmic::applet::run::<Window>(true, ())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ impl cosmic::Application for Window {
|
|||
self.popup.replace(new_id);
|
||||
let mut popup_settings =
|
||||
self.core
|
||||
.applet_helper
|
||||
.applet
|
||||
.get_popup_settings(Id(0), new_id, None, None, None);
|
||||
popup_settings.positioner.size_limits = Limits::NONE
|
||||
.max_width(372.0)
|
||||
|
|
@ -87,7 +87,7 @@ impl cosmic::Application for Window {
|
|||
|
||||
fn view(&self) -> Element<Self::Message> {
|
||||
self.core
|
||||
.applet_helper
|
||||
.applet
|
||||
.icon_button(ID)
|
||||
.on_press(Message::TogglePopup)
|
||||
.style(Button::Text)
|
||||
|
|
@ -102,10 +102,10 @@ impl cosmic::Application for Window {
|
|||
}),
|
||||
));
|
||||
|
||||
self.core.applet_helper.popup_container(content_list).into()
|
||||
self.core.applet.popup_container(content_list).into()
|
||||
}
|
||||
|
||||
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
|
||||
Some(cosmic::app::applet::style())
|
||||
Some(cosmic::applet::style())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,9 +47,11 @@ pub struct Core {
|
|||
pub(super) system_theme: Theme,
|
||||
|
||||
pub(super) title: String,
|
||||
|
||||
pub window: Window,
|
||||
|
||||
#[cfg(feature = "applet")]
|
||||
pub applet_helper: super::applet::CosmicAppletHelper,
|
||||
pub applet: crate::applet::Context,
|
||||
}
|
||||
|
||||
impl Default for Core {
|
||||
|
|
@ -78,7 +80,7 @@ impl Default for Core {
|
|||
width: 0,
|
||||
},
|
||||
#[cfg(feature = "applet")]
|
||||
applet_helper: super::applet::CosmicAppletHelper::default(),
|
||||
applet: crate::applet::Context::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
//! Check out our [application](https://github.com/pop-os/libcosmic/tree/master/examples/application)
|
||||
//! example in our repository.
|
||||
|
||||
#[cfg(feature = "applet")]
|
||||
pub mod applet;
|
||||
pub mod command;
|
||||
mod core;
|
||||
pub mod cosmic;
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ use iced_widget::runtime::command::platform_specific::wayland::popup::{
|
|||
};
|
||||
use sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{Anchor, Gravity};
|
||||
|
||||
use super::cosmic;
|
||||
use crate::app::cosmic;
|
||||
|
||||
const APPLET_PADDING: u32 = 8;
|
||||
|
||||
#[must_use]
|
||||
pub fn applet_button_theme() -> Button {
|
||||
pub fn button_theme() -> Button {
|
||||
Button::Custom {
|
||||
active: Box::new(|active, t| widget::button::Appearance {
|
||||
border_radius: 0.0.into(),
|
||||
|
|
@ -46,7 +46,7 @@ pub fn applet_button_theme() -> Button {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CosmicAppletHelper {
|
||||
pub struct Context {
|
||||
pub size: Size,
|
||||
pub anchor: PanelAnchor,
|
||||
pub background: CosmicPanelBackground,
|
||||
|
|
@ -60,7 +60,7 @@ pub enum Size {
|
|||
Hardcoded((u16, u16)),
|
||||
}
|
||||
|
||||
impl Default for CosmicAppletHelper {
|
||||
impl Default for Context {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
size: Size::PanelSize(
|
||||
|
|
@ -82,7 +82,7 @@ impl Default for CosmicAppletHelper {
|
|||
}
|
||||
}
|
||||
|
||||
impl CosmicAppletHelper {
|
||||
impl Context {
|
||||
#[must_use]
|
||||
pub fn suggested_size(&self) -> (u16, u16) {
|
||||
match &self.size {
|
||||
|
|
@ -104,11 +104,11 @@ impl CosmicAppletHelper {
|
|||
|
||||
#[must_use]
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
pub fn window_settings(&self) -> super::Settings {
|
||||
pub fn window_settings(&self) -> crate::app::Settings {
|
||||
let (width, height) = self.suggested_size();
|
||||
let width = u32::from(width);
|
||||
let height = u32::from(height);
|
||||
let mut settings = super::Settings::default()
|
||||
let mut settings = crate::app::Settings::default()
|
||||
.size((width + APPLET_PADDING * 2, height + APPLET_PADDING * 2))
|
||||
.size_limits(
|
||||
Limits::NONE
|
||||
|
|
@ -225,7 +225,7 @@ impl CosmicAppletHelper {
|
|||
///
|
||||
/// Returns error on application failure.
|
||||
pub fn run<App: Application>(autosize: bool, flags: App::Flags) -> iced::Result {
|
||||
let helper = CosmicAppletHelper::default();
|
||||
let helper = Context::default();
|
||||
let mut settings = helper.window_settings();
|
||||
settings.autosize = autosize;
|
||||
if autosize {
|
||||
|
|
@ -20,6 +20,9 @@ pub use apply::{Also, Apply};
|
|||
pub mod app;
|
||||
pub use app::{Application, ApplicationExt};
|
||||
|
||||
#[cfg(feature = "applet")]
|
||||
pub mod applet;
|
||||
|
||||
pub use iced::Command;
|
||||
pub mod command;
|
||||
pub use cosmic_config;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue