wip: update libcosmic (#93)

* wip: update libcosmic

* fix: damge issue resolved by updating iced

* fix: high cpu usage by time applet and app-list

* refactor subscriptions to produce fewer events

* refactor network applet to use less cpu

* fix: text size

* refactor: i18n for audio applet

* refactor: power applet i18n setup

* fix (battery): always send profile update

* fix (battery): set toggler width to layout correctly

* fix (app-list): backoff for restarts of toplevel subscription

* fix (network): alignment

* feat: ask for comfirmation before applying power applet actions

* wip: integrate cosmic-config

* update zbus

* feat: update to use latest libcosmic

* update iced

* udpate deps

* update deps

* refactor: move applet helpers to this repo, outside of libcosmic.

this should help alleviate some dependency hell

* chore update deps

* update deps

* cleanup
This commit is contained in:
Ashley Wulber 2023-06-01 12:23:12 -04:00 committed by GitHub
parent 8b46cc209f
commit 9ebd9b511a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 2841 additions and 1681 deletions

View file

@ -4,10 +4,10 @@ mod localize;
mod window;
use cosmic::{
applet::{cosmic_panel_config::PanelAnchor, CosmicAppletHelper},
iced::{wayland::InitialSurface, Application, Settings},
iced_native::layout::Limits,
iced_runtime::core::layout::Limits,
};
use cosmic_applet::{cosmic_panel_config::PanelAnchor, CosmicAppletHelper};
use window::*;
@ -21,10 +21,10 @@ pub fn main() -> cosmic::iced::Result {
InitialSurface::XdgWindow(w) => {
w.autosize = true;
w.size_limits = Limits::NONE
.min_height(1)
.max_height(200)
.min_width(1)
.max_width(1000);
.min_height(1.0)
.max_height(200.0)
.min_width(1.0)
.max_width(1000.0);
}
InitialSurface::None => unimplemented!(),
};

View file

@ -1,23 +1,22 @@
use crate::dbus::{self, PowerDaemonProxy};
use crate::fl;
use crate::graphics::{get_current_graphics, set_graphics, Graphics};
use cosmic::applet::CosmicAppletHelper;
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced_native::alignment::Horizontal;
use cosmic::iced_native::Alignment;
use cosmic::iced::Color;
use cosmic::iced_runtime::core::alignment::Horizontal;
use cosmic::iced_runtime::core::Alignment;
use cosmic::iced_style::application::{self, Appearance};
use cosmic::iced_style::Color;
use cosmic::theme::Button;
use cosmic::widget::icon;
use cosmic::{
applet::{cosmic_panel_config::PanelAnchor, APPLET_BUTTON_THEME},
iced::widget::{column, container, row, text},
iced::{self, Application, Command, Length},
iced_native::window,
iced_runtime::core::window,
theme::{Svg, Theme},
widget::{button, divider},
Element,
};
use cosmic_applet::{applet_button_theme, cosmic_panel_config::PanelAnchor, CosmicAppletHelper};
use zbus::Connection;
#[derive(Clone, Copy)]
@ -41,7 +40,7 @@ impl GraphicsMode {
pub struct Window {
popup: Option<window::Id>,
graphics_mode: Option<GraphicsMode>,
id_ctr: u32,
id_ctr: u128,
theme: Theme,
dbus: Option<(Connection, PowerDaemonProxy<'static>)>,
applet_helper: CosmicAppletHelper,
@ -92,7 +91,7 @@ impl Application for Window {
return destroy_popup(p);
} else {
self.id_ctr += 1;
let new_id = window::Id::new(self.id_ctr);
let new_id = window::Id(self.id_ctr);
self.popup.replace(new_id);
let mut commands = Vec::new();
if let Some((_, proxy)) = self.dbus.as_ref() {
@ -102,7 +101,7 @@ impl Application for Window {
));
}
let popup_settings = self.applet_helper.get_popup_settings(
window::Id::new(0),
window::Id(0),
new_id,
None,
None,
@ -184,7 +183,7 @@ impl Application for Window {
}
fn view(&self, id: window::Id) -> Element<Message> {
if id == window::Id::new(0) {
if id == window::Id(0) {
match self.applet_helper.anchor {
PanelAnchor::Left | PanelAnchor::Right => self
.applet_helper
@ -206,6 +205,7 @@ impl Application for Window {
Some(Graphics::Hybrid) => fl!("hybrid"),
None => "".into(),
})
.size(14)
]
.spacing(8)
.padding([0, self.applet_helper.suggested_size().0 / 2])
@ -220,7 +220,7 @@ impl Application for Window {
}
} else {
let content_list = vec![
button(APPLET_BUTTON_THEME)
button(applet_button_theme())
.custom(vec![row![
column![
text(format!("{} {}", fl!("integrated"), fl!("graphics"))).size(14),
@ -256,7 +256,7 @@ impl Application for Window {
.on_press(Message::SelectGraphicsMode(Graphics::Integrated))
.width(Length::Fill)
.into(),
button(APPLET_BUTTON_THEME)
button(applet_button_theme())
.custom(vec![row![
column![text(format!("{} {}", fl!("nvidia"), fl!("graphics"))).size(14),]
.width(Length::Fill),
@ -289,7 +289,7 @@ impl Application for Window {
.on_press(Message::SelectGraphicsMode(Graphics::Nvidia))
.width(Length::Fill)
.into(),
button(APPLET_BUTTON_THEME)
button(applet_button_theme())
.custom(vec![row![
column![
text(format!("{} {}", fl!("hybrid"), fl!("graphics"))).size(14),
@ -325,7 +325,7 @@ impl Application for Window {
.on_press(Message::SelectGraphicsMode(Graphics::Hybrid))
.width(Length::Fill)
.into(),
button(APPLET_BUTTON_THEME)
button(applet_button_theme())
.custom(vec![row![
column![
text(format!("{} {}", fl!("compute"), fl!("graphics"))).size(14),
@ -369,7 +369,7 @@ impl Application for Window {
text(fl!("graphics-mode"))
.width(Length::Fill)
.horizontal_alignment(Horizontal::Center)
.size(24)
.size(14)
.into(),
container(divider::horizontal::light())
.padding([0, 12])
@ -385,7 +385,7 @@ impl Application for Window {
}
fn close_requested(&self, id: window::Id) -> Self::Message {
if id != window::Id::new(0) {
if id != window::Id(0) {
Message::PopupClosed(id)
} else {
unimplemented!();
@ -393,10 +393,10 @@ impl Application for Window {
}
fn style(&self) -> <Self::Theme as application::StyleSheet>::Style {
<Self::Theme as application::StyleSheet>::Style::Custom(|theme| Appearance {
<Self::Theme as application::StyleSheet>::Style::Custom(Box::new(|theme| Appearance {
background_color: Color::from_rgba(0.0, 0.0, 0.0, 0.0),
text_color: theme.cosmic().background.on.into(),
})
}))
}
fn should_exit(&self) -> bool {
@ -404,6 +404,6 @@ impl Application for Window {
}
fn theme(&self) -> Theme {
self.theme
self.theme.clone()
}
}