update battery applet to use latest libcosmic
This commit is contained in:
parent
df67bc3206
commit
f2d3dbec5c
3 changed files with 20 additions and 31 deletions
9
applets/cosmic-applet-battery/Cargo.lock
generated
9
applets/cosmic-applet-battery/Cargo.lock
generated
|
|
@ -470,7 +470,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-panel-config"
|
name = "cosmic-panel-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-panel#a452fc323b574c28aef832951edd413a1d87bc3d"
|
source = "git+https://github.com/pop-os/cosmic-panel#35d61a3a617b2ef552931645ec35c545a3a688f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"ron",
|
"ron",
|
||||||
|
|
@ -1730,7 +1730,7 @@ checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=sctk-cosmic-design-system#0f857b18ea0987a192b99a2dc34d29b9e41e5bf8"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=fix/applets#0760008f54428ef44968df8db465dfceb7ee837d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"cosmic-panel-config",
|
"cosmic-panel-config",
|
||||||
|
|
@ -2946,13 +2946,14 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.22.0"
|
version = "1.23.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3"
|
checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
"windows-sys 0.42.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
once_cell = "1.16.0"
|
once_cell = "1.16.0"
|
||||||
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "sctk-cosmic-design-system", default-features = false, features = ["wayland", "applet"] }
|
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "fix/applets", default-features = false, features = ["wayland", "applet"] }
|
||||||
cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", default-features = false }
|
cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", default-features = false }
|
||||||
iced_sctk = { git = "https://github.com/pop-os/iced-sctk" }
|
iced_sctk = { git = "https://github.com/pop-os/iced-sctk" }
|
||||||
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", version = "0.16" }
|
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", version = "0.16" }
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,18 @@ use crate::upower_device::{device_subscription, DeviceDbusEvent};
|
||||||
use crate::upower_kbdbacklight::{
|
use crate::upower_kbdbacklight::{
|
||||||
kbd_backlight_subscription, KeyboardBacklightRequest, KeyboardBacklightUpdate,
|
kbd_backlight_subscription, KeyboardBacklightRequest, KeyboardBacklightUpdate,
|
||||||
};
|
};
|
||||||
use cosmic::applet::{get_popup_settings, icon_button, popup_container};
|
use cosmic::applet::CosmicAppletHelper;
|
||||||
use cosmic::iced::alignment::Horizontal;
|
use cosmic::iced::alignment::Horizontal;
|
||||||
use cosmic::iced::{
|
use cosmic::iced::{
|
||||||
executor,
|
executor,
|
||||||
widget::{button, column, row, text},
|
widget::{button, column, row, text, slider},
|
||||||
window, Alignment, Application, Command, Length, Subscription,
|
window, Alignment, Application, Command, Length, Subscription,
|
||||||
};
|
};
|
||||||
use cosmic::iced_native::window::Settings;
|
use cosmic::iced_native::window::Settings;
|
||||||
use cosmic::iced_style::application::{self, Appearance};
|
use cosmic::iced_style::application::{self, Appearance};
|
||||||
use cosmic::iced_style::svg;
|
use cosmic::iced_style::svg;
|
||||||
use cosmic::separator;
|
use cosmic::theme::{self, Svg};
|
||||||
use cosmic::theme::{self, Button, Svg};
|
use cosmic::widget::{icon, toggler, horizontal_rule};
|
||||||
use cosmic::widget::{icon, widget};
|
|
||||||
use cosmic::{iced_style, settings, Element, Theme};
|
use cosmic::{iced_style, settings, Element, Theme};
|
||||||
use cosmic_panel_config::{PanelAnchor, PanelSize};
|
use cosmic_panel_config::{PanelAnchor, PanelSize};
|
||||||
use iced_sctk::application::SurfaceIdWrapper;
|
use iced_sctk::application::SurfaceIdWrapper;
|
||||||
|
|
@ -82,9 +81,9 @@ struct CosmicBatteryApplet {
|
||||||
screen_brightness: f64,
|
screen_brightness: f64,
|
||||||
popup: Option<window::Id>,
|
popup: Option<window::Id>,
|
||||||
id_ctr: u32,
|
id_ctr: u32,
|
||||||
anchor: PanelAnchor,
|
|
||||||
screen_sender: Option<UnboundedSender<ScreenBacklightRequest>>,
|
screen_sender: Option<UnboundedSender<ScreenBacklightRequest>>,
|
||||||
kbd_sender: Option<UnboundedSender<KeyboardBacklightRequest>>,
|
kbd_sender: Option<UnboundedSender<KeyboardBacklightRequest>>,
|
||||||
|
applet_helper: CosmicAppletHelper,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
@ -117,13 +116,6 @@ impl Application for CosmicBatteryApplet {
|
||||||
(
|
(
|
||||||
CosmicBatteryApplet {
|
CosmicBatteryApplet {
|
||||||
icon_name: "battery-symbolic".to_string(),
|
icon_name: "battery-symbolic".to_string(),
|
||||||
anchor: std::env::var("COSMIC_PANEL_ANCHOR")
|
|
||||||
.ok()
|
|
||||||
.map(|size| match size.parse::<PanelAnchor>() {
|
|
||||||
Ok(p) => p,
|
|
||||||
Err(_) => PanelAnchor::Top,
|
|
||||||
})
|
|
||||||
.unwrap_or(PanelAnchor::Top),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Command::none(),
|
Command::none(),
|
||||||
|
|
@ -172,8 +164,8 @@ impl Application for CosmicBatteryApplet {
|
||||||
let new_id = window::Id::new(self.id_ctr);
|
let new_id = window::Id::new(self.id_ctr);
|
||||||
self.popup.replace(new_id);
|
self.popup.replace(new_id);
|
||||||
|
|
||||||
let mut popup_settings =
|
let popup_settings =
|
||||||
get_popup_settings(window::Id::new(0), new_id, (400, 240), None, None);
|
self.applet_helper.get_popup_settings(window::Id::new(0), new_id, (400, 240), None, None);
|
||||||
return get_popup(popup_settings);
|
return get_popup(popup_settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -209,14 +201,10 @@ impl Application for CosmicBatteryApplet {
|
||||||
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
|
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
|
||||||
match id {
|
match id {
|
||||||
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
|
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
|
||||||
SurfaceIdWrapper::Window(_) => icon_button(
|
SurfaceIdWrapper::Window(_) => self.applet_helper.icon_button(
|
||||||
&self.icon_name,
|
&self.icon_name,
|
||||||
Svg::Custom(|theme| svg::Appearance {
|
|
||||||
fill: Some(theme.palette().text),
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
.on_press(Message::TogglePopup)
|
.on_press(Message::TogglePopup)
|
||||||
.style(Button::Text)
|
|
||||||
.into(),
|
.into(),
|
||||||
SurfaceIdWrapper::Popup(_) => {
|
SurfaceIdWrapper::Popup(_) => {
|
||||||
let name = text(fl!("battery")).size(18);
|
let name = text(fl!("battery")).size(18);
|
||||||
|
|
@ -235,7 +223,7 @@ impl Application for CosmicBatteryApplet {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.size(12);
|
.size(12);
|
||||||
popup_container(
|
self.applet_helper.popup_container(
|
||||||
column![
|
column![
|
||||||
row![
|
row![
|
||||||
icon(&self.icon_name, 24)
|
icon(&self.icon_name, 24)
|
||||||
|
|
@ -250,12 +238,12 @@ impl Application for CosmicBatteryApplet {
|
||||||
]
|
]
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
.align_items(Alignment::Center),
|
.align_items(Alignment::Center),
|
||||||
separator!(1),
|
horizontal_rule(1),
|
||||||
// text{"Limit Battery Charging"},
|
// text{"Limit Battery Charging"},
|
||||||
widget::Toggler::new(self.charging_limit, fl!("max-charge"), |_| {
|
toggler(fl!("max-charge"), self.charging_limit, |_| {
|
||||||
Message::SetChargingLimit(!self.charging_limit)
|
Message::SetChargingLimit(!self.charging_limit)
|
||||||
}),
|
}),
|
||||||
separator!(1),
|
horizontal_rule(1),
|
||||||
row![
|
row![
|
||||||
icon("display-brightness-symbolic", 24)
|
icon("display-brightness-symbolic", 24)
|
||||||
.style(Svg::Custom(|theme| {
|
.style(Svg::Custom(|theme| {
|
||||||
|
|
@ -265,7 +253,7 @@ impl Application for CosmicBatteryApplet {
|
||||||
}))
|
}))
|
||||||
.width(Length::Units(24))
|
.width(Length::Units(24))
|
||||||
.height(Length::Units(24)),
|
.height(Length::Units(24)),
|
||||||
widget::slider(
|
slider(
|
||||||
0..=100,
|
0..=100,
|
||||||
(self.screen_brightness * 100.0) as i32,
|
(self.screen_brightness * 100.0) as i32,
|
||||||
Message::SetScreenBrightness
|
Message::SetScreenBrightness
|
||||||
|
|
@ -284,7 +272,7 @@ impl Application for CosmicBatteryApplet {
|
||||||
}))
|
}))
|
||||||
.width(Length::Units(24))
|
.width(Length::Units(24))
|
||||||
.height(Length::Units(24)),
|
.height(Length::Units(24)),
|
||||||
widget::slider(
|
slider(
|
||||||
0..=100,
|
0..=100,
|
||||||
(self.kbd_brightness * 100.0) as i32,
|
(self.kbd_brightness * 100.0) as i32,
|
||||||
Message::SetKbdBrightness
|
Message::SetKbdBrightness
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue