Merge pull request #45 from pop-os/update-cleanup
update applets using latest libcosmic auto-sizing popups
This commit is contained in:
commit
cf41b2a1b5
13 changed files with 320 additions and 251 deletions
50
Cargo.lock
generated
50
Cargo.lock
generated
|
|
@ -322,9 +322,9 @@ checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "calloop"
|
name = "calloop"
|
||||||
version = "0.10.4"
|
version = "0.10.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "19457a0da465234abd76134a5c2a910c14bd3c5558463e4396ab9a37a328e465"
|
checksum = "1a59225be45a478d772ce015d9743e49e92798ece9e34eda9a6aa2a6a7f40192"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"nix 0.25.1",
|
"nix 0.25.1",
|
||||||
|
|
@ -1421,8 +1421,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "freedesktop-icons"
|
name = "freedesktop-icons"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
source = "git+https://github.com/wash2/freedestkop-icons#ac6343d76f1d2b3b666771b5ec0d22aa571a912e"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e31823094643eabe14030d2f1b3f0aa10164f27b1a31e2b938ffe8ea9c9fc91b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs 4.0.0",
|
"dirs 4.0.0",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -1995,7 +1996,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
|
|
@ -2012,7 +2013,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"palette",
|
"palette",
|
||||||
|
|
@ -2022,7 +2023,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -2034,7 +2035,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_glow"
|
name = "iced_glow"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"euclid",
|
"euclid",
|
||||||
|
|
@ -2049,7 +2050,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2069,7 +2070,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_lazy"
|
name = "iced_lazy"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_native",
|
"iced_native",
|
||||||
"ouroboros 0.13.0",
|
"ouroboros 0.13.0",
|
||||||
|
|
@ -2078,7 +2079,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_native"
|
name = "iced_native"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
|
|
@ -2092,7 +2093,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_sctk"
|
name = "iced_sctk"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"enum-repr",
|
"enum-repr",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
@ -2111,7 +2112,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_style"
|
name = "iced_style"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -2121,7 +2122,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_swbuf"
|
name = "iced_swbuf"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
|
|
@ -2136,7 +2137,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2326,7 +2327,7 @@ checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic/?branch=master#55d00bd21a9ac69983666cd06b2c14a75a4e811f"
|
source = "git+https://github.com/pop-os/libcosmic/?branch=master#f84410608b7a62335f197f96125d27d7df5f8a59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"cosmic-panel-config",
|
"cosmic-panel-config",
|
||||||
|
|
@ -2341,6 +2342,7 @@ dependencies = [
|
||||||
"iced_style",
|
"iced_style",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"palette",
|
"palette",
|
||||||
|
"slotmap",
|
||||||
"smithay-client-toolkit",
|
"smithay-client-toolkit",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -3179,9 +3181,9 @@ checksum = "63e935c45e09cc6dcf00d2f0b2d630a58f4095320223d47fc68918722f0538b6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rangemap"
|
name = "rangemap"
|
||||||
version = "1.1.0"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ed5f515fe4093fa60900ac1918c9ea73f18189114588ec9b99941e22cc2aedd"
|
checksum = "4fa20df61fa7daf0ecf0735b9841ced4a0d25962d1b1eb2dd28dcdd37bb688f2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raqote"
|
name = "raqote"
|
||||||
|
|
@ -3390,9 +3392,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "0.36.5"
|
version = "0.36.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588"
|
checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"errno",
|
"errno",
|
||||||
|
|
@ -3491,18 +3493,18 @@ checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.151"
|
version = "1.0.152"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0"
|
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.151"
|
version = "1.0.152"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8"
|
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ log = "0.4"
|
||||||
tokio = { version = "1.17.0", features = ["sync", "rt", "rt-multi-thread", "macros", "process"] }
|
tokio = { version = "1.17.0", features = ["sync", "rt", "rt-multi-thread", "macros", "process"] }
|
||||||
itertools = "*"
|
itertools = "*"
|
||||||
freedesktop-desktop-entry = "0.5.0"
|
freedesktop-desktop-entry = "0.5.0"
|
||||||
freedesktop-icons = { git = "https://github.com/wash2/freedestkop-icons" }
|
freedesktop-icons = "0.2.2"
|
||||||
i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] }
|
i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] }
|
||||||
i18n-embed-fl = "0.6"
|
i18n-embed-fl = "0.6"
|
||||||
rust-embed = "6.3"
|
rust-embed = "6.3"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::OsStr;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::config;
|
use crate::config;
|
||||||
|
|
@ -22,6 +22,7 @@ use cosmic::iced::widget::{column, row};
|
||||||
use cosmic::iced::{executor, window, Application, Command, Subscription};
|
use cosmic::iced::{executor, window, Application, Command, Subscription};
|
||||||
use cosmic::iced_native::alignment::Horizontal;
|
use cosmic::iced_native::alignment::Horizontal;
|
||||||
use cosmic::iced_native::subscription::events_with;
|
use cosmic::iced_native::subscription::events_with;
|
||||||
|
use cosmic::iced_native::widget::vertical_space;
|
||||||
use cosmic::iced_style::application::{self, Appearance};
|
use cosmic::iced_style::application::{self, Appearance};
|
||||||
use cosmic::iced_style::Color;
|
use cosmic::iced_style::Color;
|
||||||
use cosmic::theme::Button;
|
use cosmic::theme::Button;
|
||||||
|
|
@ -35,8 +36,6 @@ use freedesktop_desktop_entry::DesktopEntry;
|
||||||
use iced::wayland::window::resize_window;
|
use iced::wayland::window::resize_window;
|
||||||
use iced::widget::container;
|
use iced::widget::container;
|
||||||
use iced::widget::horizontal_space;
|
use iced::widget::horizontal_space;
|
||||||
use iced::widget::svg;
|
|
||||||
use iced::widget::Image;
|
|
||||||
use iced::Alignment;
|
use iced::Alignment;
|
||||||
use iced::Background;
|
use iced::Background;
|
||||||
use iced::Length;
|
use iced::Length;
|
||||||
|
|
@ -219,11 +218,11 @@ impl Application for CosmicAppList {
|
||||||
let new_id = window::Id::new(self.surface_id_ctr);
|
let new_id = window::Id::new(self.surface_id_ctr);
|
||||||
self.popup.replace(new_id);
|
self.popup.replace(new_id);
|
||||||
toplevel_group.popup.replace(new_id);
|
toplevel_group.popup.replace(new_id);
|
||||||
|
|
||||||
let mut popup_settings = self.applet_helper.get_popup_settings(
|
let mut popup_settings = self.applet_helper.get_popup_settings(
|
||||||
window::Id::new(0),
|
window::Id::new(0),
|
||||||
new_id,
|
new_id,
|
||||||
(240, 240 + toplevel_group.toplevels.len() as u32 * 24),
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
@ -399,23 +398,24 @@ impl Application for CosmicAppList {
|
||||||
desktop_info,
|
desktop_info,
|
||||||
..
|
..
|
||||||
}| {
|
}| {
|
||||||
let icon = if desktop_info.icon.extension() == Some(&OsStr::new("svg")) {
|
let cosmic_icon = cosmic::widget::icon(Path::new(&desktop_info.icon), self.applet_helper.suggested_size().0);
|
||||||
let handle = svg::Handle::from_path(&desktop_info.icon);
|
// let icon = if desktop_info.icon.extension() == Some(&OsStr::new("svg")) {
|
||||||
svg::Svg::new(handle)
|
// svg::Handle::from_path(&desktop_info.icon);
|
||||||
.width(Length::Units(self.applet_helper.suggested_size().0))
|
// svg::Svg::new(handle)
|
||||||
.height(Length::Units(self.applet_helper.suggested_size().0))
|
// .width(Length::Units(self.applet_helper.suggested_size().0))
|
||||||
.into()
|
// .height(Length::Units(self.applet_helper.suggested_size().0))
|
||||||
} else {
|
// .into()
|
||||||
Image::new(&desktop_info.icon)
|
// } else {
|
||||||
.width(Length::Units(self.applet_helper.suggested_size().0))
|
// Image::new(&desktop_info.icon)
|
||||||
.height(Length::Units(self.applet_helper.suggested_size().0))
|
// .width(Length::Units(self.applet_helper.suggested_size().0))
|
||||||
.into()
|
// .height(Length::Units(self.applet_helper.suggested_size().0))
|
||||||
};
|
// .into()
|
||||||
|
// };
|
||||||
let dot_radius = 2;
|
let dot_radius = 2;
|
||||||
let dots = (0..toplevels.len())
|
let mut dots = (0..toplevels.len())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|_| {
|
.map(|_| {
|
||||||
container(horizontal_space(Length::Units(0)))
|
container(vertical_space(Length::Units(0)))
|
||||||
.padding(dot_radius)
|
.padding(dot_radius)
|
||||||
.style(<Self::Theme as container::StyleSheet>::Style::Custom(
|
.style(<Self::Theme as container::StyleSheet>::Style::Custom(
|
||||||
|theme| container::Appearance {
|
|theme| container::Appearance {
|
||||||
|
|
@ -431,21 +431,21 @@ impl Application for CosmicAppList {
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
dots.push(vertical_space(Length::Units(4)).into());
|
||||||
let icon_wrapper = match &self.applet_helper.anchor {
|
let icon_wrapper = match &self.applet_helper.anchor {
|
||||||
PanelAnchor::Left => row(vec![column(dots).spacing(4).into(), icon])
|
PanelAnchor::Left => row(vec![column(dots).spacing(4).into(), cosmic_icon.into()])
|
||||||
.align_items(iced::Alignment::Center)
|
.align_items(iced::Alignment::Center)
|
||||||
.spacing(4)
|
.spacing(4)
|
||||||
.into(),
|
.into(),
|
||||||
PanelAnchor::Right => row(vec![icon, column(dots).spacing(4).into()])
|
PanelAnchor::Right => row(vec![cosmic_icon.into(), column(dots).spacing(4).into()])
|
||||||
.align_items(iced::Alignment::Center)
|
.align_items(iced::Alignment::Center)
|
||||||
.spacing(4)
|
.spacing(4)
|
||||||
.into(),
|
.into(),
|
||||||
PanelAnchor::Top => column(vec![row(dots).spacing(4).into(), icon])
|
PanelAnchor::Top => column(vec![row(dots).spacing(4).into(), cosmic_icon.into()])
|
||||||
.align_items(iced::Alignment::Center)
|
.align_items(iced::Alignment::Center)
|
||||||
.spacing(4)
|
.spacing(4)
|
||||||
.into(),
|
.into(),
|
||||||
PanelAnchor::Bottom => column(vec![icon, row(dots).spacing(4).into()])
|
PanelAnchor::Bottom => column(vec![cosmic_icon.into(), row(dots).spacing(4).into()])
|
||||||
.align_items(iced::Alignment::Center)
|
.align_items(iced::Alignment::Center)
|
||||||
.spacing(4)
|
.spacing(4)
|
||||||
.into(),
|
.into(),
|
||||||
|
|
@ -567,6 +567,15 @@ impl Application for CosmicAppList {
|
||||||
.on_press(Message::Quit(desktop_info.id.clone())),
|
.on_press(Message::Quit(desktop_info.id.clone())),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
// return Container::new(Container::new(content.width(Length::Shrink).height(Length::Shrink)).style(
|
||||||
|
// cosmic::Container::Custom(|theme| container::Appearance {
|
||||||
|
// text_color: Some(theme.cosmic().on_bg_color().into()),
|
||||||
|
// background: Some(theme.extended_palette().background.base.color.into()),
|
||||||
|
// border_radius: 12.0,
|
||||||
|
// border_width: 0.0,
|
||||||
|
// border_color: Color::TRANSPARENT,
|
||||||
|
// }),
|
||||||
|
// )).into();
|
||||||
return self.applet_helper.popup_container(content).into();
|
return self.applet_helper.popup_container(content).into();
|
||||||
}
|
}
|
||||||
return horizontal_space(Length::Units(1)).into();
|
return horizontal_space(Length::Units(1)).into();
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,24 @@
|
||||||
use cosmic::iced::wayland::SurfaceIdWrapper;
|
use cosmic::iced::wayland::SurfaceIdWrapper;
|
||||||
use cosmic::iced::widget;
|
use cosmic::iced::widget;
|
||||||
|
use cosmic::iced_native::alignment::Horizontal;
|
||||||
|
use cosmic::theme::Svg;
|
||||||
use iced::widget::Space;
|
use iced::widget::Space;
|
||||||
|
|
||||||
use cosmic::widget::{icon, toggler, horizontal_rule};
|
|
||||||
use cosmic::applet::CosmicAppletHelper;
|
use cosmic::applet::CosmicAppletHelper;
|
||||||
|
use cosmic::widget::icon;
|
||||||
use cosmic::Renderer;
|
use cosmic::Renderer;
|
||||||
|
|
||||||
use cosmic::iced_native::window::Settings;
|
|
||||||
use cosmic::iced_style::application::{self, Appearance};
|
|
||||||
use cosmic::iced_style::svg;
|
|
||||||
use cosmic::theme::{self, Svg};
|
|
||||||
use cosmic::{iced_style, settings, Element, Theme};
|
|
||||||
use cosmic::iced::{
|
use cosmic::iced::{
|
||||||
self,
|
self, executor,
|
||||||
executor,
|
widget::{button, column, row, slider, text},
|
||||||
widget::{button, column, row, text, slider},
|
|
||||||
window, Alignment, Application, Command, Length, Subscription,
|
window, Alignment, Application, Command, Length, Subscription,
|
||||||
};
|
};
|
||||||
|
use cosmic::iced_style::application::{self, Appearance};
|
||||||
|
use cosmic::{Element, Theme};
|
||||||
|
|
||||||
use iced::wayland::popup::{destroy_popup, get_popup};
|
use iced::wayland::popup::{destroy_popup, get_popup};
|
||||||
use iced::Color;
|
|
||||||
use iced::widget::container;
|
use iced::widget::container;
|
||||||
|
use iced::Color;
|
||||||
|
|
||||||
mod pulse;
|
mod pulse;
|
||||||
use crate::pulse::DeviceInfo;
|
use crate::pulse::DeviceInfo;
|
||||||
|
|
@ -93,7 +90,7 @@ impl Application for Audio {
|
||||||
String::from("Audio")
|
String::from("Audio")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn theme(&self) -> Theme {
|
fn theme(&self) -> Theme {
|
||||||
self.theme
|
self.theme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,12 +111,17 @@ impl Application for Audio {
|
||||||
if let Some(p) = self.popup.take() {
|
if let Some(p) = self.popup.take() {
|
||||||
return destroy_popup(p);
|
return destroy_popup(p);
|
||||||
} else {
|
} else {
|
||||||
self.id_ctr += 1;
|
self.id_ctr += 1;
|
||||||
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 popup_settings =
|
let popup_settings = self.applet_helper.get_popup_settings(
|
||||||
self.applet_helper.get_popup_settings(window::Id::new(0), new_id, (400, 300), None, None);
|
window::Id::new(0),
|
||||||
|
new_id,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
);
|
||||||
return get_popup(popup_settings);
|
return get_popup(popup_settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -216,7 +218,7 @@ impl Application for Audio {
|
||||||
self.pulse_state = PulseState::Disconnected
|
self.pulse_state = PulseState::Disconnected
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Message::Ignore => {},
|
Message::Ignore => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
Command::none()
|
Command::none()
|
||||||
|
|
@ -226,14 +228,14 @@ impl Application for Audio {
|
||||||
pulse::connect().map(Message::Pulse)
|
pulse::connect().map(Message::Pulse)
|
||||||
}
|
}
|
||||||
|
|
||||||
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(_) => self.applet_helper.icon_button(
|
SurfaceIdWrapper::Window(_) => self
|
||||||
&self.icon_name,
|
.applet_helper
|
||||||
)
|
.icon_button(&self.icon_name)
|
||||||
.on_press(Message::TogglePopup)
|
.on_press(Message::TogglePopup)
|
||||||
.into(),
|
.into(),
|
||||||
SurfaceIdWrapper::Popup(_) => {
|
SurfaceIdWrapper::Popup(_) => {
|
||||||
let out_f64 = VolumeLinear::from(
|
let out_f64 = VolumeLinear::from(
|
||||||
self.current_output
|
self.current_output
|
||||||
|
|
@ -251,19 +253,19 @@ impl Application for Audio {
|
||||||
.0 * 100.0;
|
.0 * 100.0;
|
||||||
|
|
||||||
let sink = row![
|
let sink = row![
|
||||||
icon("status/audio-volume-high-symbolic", 24),
|
icon("audio-volume-high-symbolic", 64).width(Length::Units(24)).height(Length::Units(24)).style(Svg::SymbolicActive),
|
||||||
slider(0.0..=100.0, out_f64, Message::SetOutputVolume),
|
slider(0.0..=100.0, out_f64, Message::SetOutputVolume).width(Length::FillPortion(5)),
|
||||||
text(format!("{}%", out_f64.round()))
|
text(format!("{}%", out_f64.round())).width(Length::FillPortion(1)).horizontal_alignment(Horizontal::Right)
|
||||||
]
|
]
|
||||||
.spacing(10)
|
.spacing(10)
|
||||||
.padding(10);
|
.align_items(Alignment::Center);
|
||||||
let source = row![
|
let source = row![
|
||||||
icon("devices/audio-input-microphone-symbolic", 24),
|
icon("audio-input-microphone-symbolic", 64).width(Length::Units(24)).height(Length::Units(24)).style(Svg::SymbolicActive),
|
||||||
slider(0.0..=100.0, in_f64, Message::SetInputVolume),
|
slider(0.0..=100.0, in_f64, Message::SetInputVolume).width(Length::FillPortion(5)),
|
||||||
text(format!("{}%", in_f64.round()))
|
text(format!("{}%", in_f64.round())).width(Length::FillPortion(1)).horizontal_alignment(Horizontal::Right)
|
||||||
]
|
]
|
||||||
.spacing(10)
|
.spacing(10)
|
||||||
.padding(10);
|
.align_items(Alignment::Center);
|
||||||
|
|
||||||
// TODO change these from helper functions to iced components for improved reusability
|
// TODO change these from helper functions to iced components for improved reusability
|
||||||
let output_drop = revealer(
|
let output_drop = revealer(
|
||||||
|
|
@ -304,11 +306,12 @@ impl Application for Audio {
|
||||||
.push(source)
|
.push(source)
|
||||||
.push(spacer())
|
.push(spacer())
|
||||||
.push(output_drop)
|
.push(output_drop)
|
||||||
.push(input_drop);
|
.push(input_drop)
|
||||||
|
.padding(8);
|
||||||
|
|
||||||
self.applet_helper.popup_container(
|
self.applet_helper
|
||||||
container(content)
|
.popup_container(container(content))
|
||||||
).into()
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,18 +9,19 @@ use crate::upower_kbdbacklight::{
|
||||||
};
|
};
|
||||||
use cosmic::applet::CosmicAppletHelper;
|
use cosmic::applet::CosmicAppletHelper;
|
||||||
use cosmic::iced::alignment::Horizontal;
|
use cosmic::iced::alignment::Horizontal;
|
||||||
use cosmic::iced::wayland::SurfaceIdWrapper;
|
|
||||||
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
|
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
|
||||||
|
use cosmic::iced::wayland::SurfaceIdWrapper;
|
||||||
use cosmic::iced::{
|
use cosmic::iced::{
|
||||||
executor,
|
executor,
|
||||||
widget::{button, column, row, text, slider},
|
widget::{button, column, row, slider, text},
|
||||||
window, Alignment, Application, Command, Length, Subscription,
|
window, Alignment, Application, Command, Length, Subscription,
|
||||||
};
|
};
|
||||||
|
use cosmic::iced_native::layout::Limits;
|
||||||
use cosmic::iced_style::application::{self, Appearance};
|
use cosmic::iced_style::application::{self, Appearance};
|
||||||
use cosmic::iced_style::{svg, Color};
|
use cosmic::iced_style::{svg, Color};
|
||||||
use cosmic::theme::{self, Svg};
|
use cosmic::theme::{self, Svg};
|
||||||
use cosmic::widget::{icon, toggler, horizontal_rule};
|
use cosmic::widget::{horizontal_rule, icon, toggler};
|
||||||
use cosmic::{iced_style, settings, Element, Theme};
|
use cosmic::{iced_style, Element, Theme};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
|
|
@ -139,8 +140,14 @@ 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 popup_settings =
|
let mut popup_settings = self.applet_helper.get_popup_settings(
|
||||||
self.applet_helper.get_popup_settings(window::Id::new(0), new_id, (400, 240), None, None);
|
window::Id::new(0),
|
||||||
|
new_id,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
popup_settings.positioner.size_limits = Limits::NONE.max_width(400).min_width(300).min_height(200).max_height(1080);
|
||||||
return get_popup(popup_settings);
|
return get_popup(popup_settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,11 +183,11 @@ 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(_) => self.applet_helper.icon_button(
|
SurfaceIdWrapper::Window(_) => self
|
||||||
&self.icon_name,
|
.applet_helper
|
||||||
)
|
.icon_button(&self.icon_name)
|
||||||
.on_press(Message::TogglePopup)
|
.on_press(Message::TogglePopup)
|
||||||
.into(),
|
.into(),
|
||||||
SurfaceIdWrapper::Popup(_) => {
|
SurfaceIdWrapper::Popup(_) => {
|
||||||
let name = text(fl!("battery")).size(18);
|
let name = text(fl!("battery")).size(18);
|
||||||
let description = text(
|
let description = text(
|
||||||
|
|
@ -198,82 +205,82 @@ impl Application for CosmicBatteryApplet {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.size(12);
|
.size(12);
|
||||||
self.applet_helper.popup_container(
|
self.applet_helper
|
||||||
column![
|
.popup_container(
|
||||||
row![
|
column![
|
||||||
icon(&*self.icon_name, 24)
|
row![
|
||||||
.style(Svg::Custom(|theme| {
|
icon(&*self.icon_name, 24)
|
||||||
svg::Appearance {
|
.style(Svg::Custom(|theme| {
|
||||||
color: Some(theme.palette().text),
|
svg::Appearance {
|
||||||
}
|
color: Some(theme.palette().text),
|
||||||
}))
|
}
|
||||||
.width(Length::Units(24))
|
}))
|
||||||
.height(Length::Units(24)),
|
.width(Length::Units(24))
|
||||||
column![name, description]
|
.height(Length::Units(24)),
|
||||||
|
column![name, description]
|
||||||
|
]
|
||||||
|
.spacing(8)
|
||||||
|
.align_items(Alignment::Center),
|
||||||
|
horizontal_rule(1),
|
||||||
|
toggler(fl!("max-charge"), self.charging_limit, |_| {
|
||||||
|
Message::SetChargingLimit(!self.charging_limit)
|
||||||
|
}).width(Length::Fill),
|
||||||
|
horizontal_rule(1),
|
||||||
|
row![
|
||||||
|
icon("display-brightness-symbolic", 24)
|
||||||
|
.style(Svg::Custom(|theme| {
|
||||||
|
svg::Appearance {
|
||||||
|
color: Some(theme.palette().text),
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.width(Length::Units(24))
|
||||||
|
.height(Length::Units(24)),
|
||||||
|
slider(
|
||||||
|
0..=100,
|
||||||
|
(self.screen_brightness * 100.0) as i32,
|
||||||
|
Message::SetScreenBrightness
|
||||||
|
),
|
||||||
|
text(format!("{:.0}%", self.screen_brightness * 100.0))
|
||||||
|
.width(Length::Units(40))
|
||||||
|
.horizontal_alignment(Horizontal::Right)
|
||||||
|
]
|
||||||
|
.spacing(12),
|
||||||
|
row![
|
||||||
|
icon("keyboard-brightness-symbolic", 24)
|
||||||
|
.style(Svg::Custom(|theme| {
|
||||||
|
svg::Appearance {
|
||||||
|
color: Some(theme.palette().text),
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.width(Length::Units(24))
|
||||||
|
.height(Length::Units(24)),
|
||||||
|
slider(
|
||||||
|
0..=100,
|
||||||
|
(self.kbd_brightness * 100.0) as i32,
|
||||||
|
Message::SetKbdBrightness
|
||||||
|
),
|
||||||
|
text(format!("{:.0}%", self.kbd_brightness * 100.0))
|
||||||
|
.width(Length::Units(40))
|
||||||
|
.horizontal_alignment(Horizontal::Right)
|
||||||
|
]
|
||||||
|
.spacing(12),
|
||||||
|
button(
|
||||||
|
text(fl!("power-settings"))
|
||||||
|
.horizontal_alignment(Horizontal::Center)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.style(theme::Text::Custom(|theme| {
|
||||||
|
let cosmic = theme.cosmic();
|
||||||
|
iced_style::text::Appearance {
|
||||||
|
color: Some(cosmic.accent.on.into()),
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
.width(Length::Fill)
|
||||||
]
|
]
|
||||||
.spacing(8)
|
.spacing(4)
|
||||||
.align_items(Alignment::Center),
|
.padding(8),
|
||||||
horizontal_rule(1),
|
)
|
||||||
// text{"Limit Battery Charging"},
|
.into()
|
||||||
toggler(fl!("max-charge"), self.charging_limit, |_| {
|
|
||||||
Message::SetChargingLimit(!self.charging_limit)
|
|
||||||
}),
|
|
||||||
horizontal_rule(1),
|
|
||||||
row![
|
|
||||||
icon("display-brightness-symbolic", 24)
|
|
||||||
.style(Svg::Custom(|theme| {
|
|
||||||
svg::Appearance {
|
|
||||||
color: Some(theme.palette().text),
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.width(Length::Units(24))
|
|
||||||
.height(Length::Units(24)),
|
|
||||||
slider(
|
|
||||||
0..=100,
|
|
||||||
(self.screen_brightness * 100.0) as i32,
|
|
||||||
Message::SetScreenBrightness
|
|
||||||
),
|
|
||||||
text(format!("{:.0}%", self.screen_brightness * 100.0))
|
|
||||||
.width(Length::Units(40))
|
|
||||||
.horizontal_alignment(Horizontal::Right)
|
|
||||||
]
|
|
||||||
.spacing(12),
|
|
||||||
row![
|
|
||||||
icon("keyboard-brightness-symbolic", 24)
|
|
||||||
.style(Svg::Custom(|theme| {
|
|
||||||
svg::Appearance {
|
|
||||||
color: Some(theme.palette().text),
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.width(Length::Units(24))
|
|
||||||
.height(Length::Units(24)),
|
|
||||||
slider(
|
|
||||||
0..=100,
|
|
||||||
(self.kbd_brightness * 100.0) as i32,
|
|
||||||
Message::SetKbdBrightness
|
|
||||||
),
|
|
||||||
text(format!("{:.0}%", self.kbd_brightness * 100.0))
|
|
||||||
.width(Length::Units(40))
|
|
||||||
.horizontal_alignment(Horizontal::Right)
|
|
||||||
]
|
|
||||||
.spacing(12),
|
|
||||||
button(
|
|
||||||
text(fl!("power-settings"))
|
|
||||||
.horizontal_alignment(Horizontal::Center)
|
|
||||||
.width(Length::Fill)
|
|
||||||
.style(theme::Text::Custom(|theme| {
|
|
||||||
let cosmic = theme.cosmic();
|
|
||||||
iced_style::text::Appearance {
|
|
||||||
color: Some(cosmic.accent.on.into()),
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
)
|
|
||||||
.width(Length::Fill)
|
|
||||||
]
|
|
||||||
.spacing(4)
|
|
||||||
.padding(8),
|
|
||||||
)
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@ mod dbus;
|
||||||
mod graphics;
|
mod graphics;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{applet::CosmicAppletHelper, iced::Application};
|
||||||
iced::Application, applet::CosmicAppletHelper,
|
|
||||||
};
|
|
||||||
use window::*;
|
use window::*;
|
||||||
|
|
||||||
pub fn main() -> cosmic::iced::Result {
|
pub fn main() -> cosmic::iced::Result {
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
use crate::dbus::{self, PowerDaemonProxy};
|
use crate::dbus::{self, PowerDaemonProxy};
|
||||||
use crate::graphics::{get_current_graphics, set_graphics, Graphics};
|
use crate::graphics::{get_current_graphics, set_graphics, Graphics};
|
||||||
use cosmic::applet::{CosmicAppletHelper};
|
use cosmic::applet::CosmicAppletHelper;
|
||||||
use cosmic::iced::wayland::SurfaceIdWrapper;
|
|
||||||
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
|
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
|
||||||
|
use cosmic::iced::wayland::SurfaceIdWrapper;
|
||||||
use cosmic::iced_native::alignment::Horizontal;
|
use cosmic::iced_native::alignment::Horizontal;
|
||||||
use cosmic::iced_style::Color;
|
|
||||||
use cosmic::iced_style::application::{self, Appearance};
|
use cosmic::iced_style::application::{self, Appearance};
|
||||||
|
use cosmic::iced_style::Color;
|
||||||
use cosmic::theme::Button;
|
use cosmic::theme::Button;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
|
applet::cosmic_panel_config::{PanelAnchor, PanelSize},
|
||||||
iced::widget::{column, radio, text},
|
iced::widget::{column, radio, text},
|
||||||
iced::{self, Application, Command, Length},
|
iced::{self, Application, Command, Length},
|
||||||
iced_native::window,
|
iced_native::window,
|
||||||
theme::Theme,
|
theme::Theme,
|
||||||
widget::{horizontal_rule},
|
widget::horizontal_rule,
|
||||||
Element,
|
Element,
|
||||||
applet::cosmic_panel_config::{PanelAnchor, PanelSize}
|
|
||||||
};
|
};
|
||||||
use zbus::Connection;
|
use zbus::Connection;
|
||||||
|
|
||||||
|
|
@ -140,8 +140,13 @@ impl Application for Window {
|
||||||
|cur_graphics| Message::CurrentGraphics(cur_graphics.ok()),
|
|cur_graphics| Message::CurrentGraphics(cur_graphics.ok()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let popup_settings =
|
let popup_settings = self.applet_helper.get_popup_settings(
|
||||||
self.applet_helper.get_popup_settings(window::Id::new(0), new_id, (200, 240), None, None);
|
window::Id::new(0),
|
||||||
|
new_id,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
);
|
||||||
commands.push(get_popup(popup_settings));
|
commands.push(get_popup(popup_settings));
|
||||||
return Command::batch(commands);
|
return Command::batch(commands);
|
||||||
}
|
}
|
||||||
|
|
@ -183,7 +188,9 @@ impl Application for Window {
|
||||||
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(_) => self.applet_helper.icon_button("input-gaming-symbolic")
|
SurfaceIdWrapper::Window(_) => self
|
||||||
|
.applet_helper
|
||||||
|
.icon_button("input-gaming-symbolic")
|
||||||
.on_press(Message::TogglePopup)
|
.on_press(Message::TogglePopup)
|
||||||
.style(Button::Text)
|
.style(Button::Text)
|
||||||
.into(),
|
.into(),
|
||||||
|
|
@ -248,20 +255,21 @@ impl Application for Window {
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.applet_helper.popup_container(
|
self.applet_helper
|
||||||
column(vec![
|
.popup_container(
|
||||||
text("Graphics Mode")
|
column(vec![
|
||||||
.width(Length::Fill)
|
text("Graphics Mode")
|
||||||
.horizontal_alignment(Horizontal::Center)
|
.width(Length::Fill)
|
||||||
.size(24)
|
.horizontal_alignment(Horizontal::Center)
|
||||||
.into(),
|
.size(24)
|
||||||
horizontal_rule(1).into(),
|
.into(),
|
||||||
content,
|
horizontal_rule(1).into(),
|
||||||
])
|
content,
|
||||||
.padding(4)
|
])
|
||||||
.spacing(4),
|
.padding(8)
|
||||||
)
|
.spacing(4),
|
||||||
.into()
|
)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,12 @@ use cosmic::{
|
||||||
applet::CosmicAppletHelper,
|
applet::CosmicAppletHelper,
|
||||||
iced::{
|
iced::{
|
||||||
executor,
|
executor,
|
||||||
|
wayland::{
|
||||||
|
popup::{destroy_popup, get_popup},
|
||||||
|
SurfaceIdWrapper,
|
||||||
|
},
|
||||||
widget::{column, container, row, scrollable, text},
|
widget::{column, container, row, scrollable, text},
|
||||||
Alignment, Application, Color, Command, Length, Subscription, wayland::{popup::{destroy_popup, get_popup}, SurfaceIdWrapper},
|
Alignment, Application, Color, Command, Length, Subscription,
|
||||||
},
|
},
|
||||||
iced_native::window,
|
iced_native::window,
|
||||||
iced_style::{application, svg},
|
iced_style::{application, svg},
|
||||||
|
|
@ -44,26 +48,22 @@ struct CosmicNetworkApplet {
|
||||||
impl CosmicNetworkApplet {
|
impl CosmicNetworkApplet {
|
||||||
fn update_icon_name(&mut self) {
|
fn update_icon_name(&mut self) {
|
||||||
self.icon_name = self
|
self.icon_name = self
|
||||||
.active_conns
|
.active_conns
|
||||||
.iter()
|
.iter()
|
||||||
.fold("network-offline-symbolic", |icon_name, conn| {
|
.fold("network-offline-symbolic", |icon_name, conn| {
|
||||||
match (icon_name, conn) {
|
match (icon_name, conn) {
|
||||||
("network-offline-symbolic", ActiveConnectionInfo::WiFi { .. }) => {
|
("network-offline-symbolic", ActiveConnectionInfo::WiFi { .. }) => {
|
||||||
"network-wireless-symbolic"
|
"network-wireless-symbolic"
|
||||||
|
}
|
||||||
|
("network-offline-symbolic", ActiveConnectionInfo::Wired { .. })
|
||||||
|
| ("network-wireless-symbolic", ActiveConnectionInfo::Wired { .. }) => {
|
||||||
|
"network-wired-symbolic"
|
||||||
|
}
|
||||||
|
(_, ActiveConnectionInfo::Vpn { .. }) => "network-vpn-symbolic",
|
||||||
|
_ => icon_name,
|
||||||
}
|
}
|
||||||
(
|
})
|
||||||
"network-offline-symbolic",
|
.to_string()
|
||||||
ActiveConnectionInfo::Wired { .. },
|
|
||||||
)
|
|
||||||
| (
|
|
||||||
"network-wireless-symbolic",
|
|
||||||
ActiveConnectionInfo::Wired { .. },
|
|
||||||
) => "network-wired-symbolic",
|
|
||||||
(_, ActiveConnectionInfo::Vpn { .. }) => "network-vpn-symbolic",
|
|
||||||
_ => icon_name,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.to_string()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ impl Application for CosmicNetworkApplet {
|
||||||
let popup_settings = self.applet_helper.get_popup_settings(
|
let popup_settings = self.applet_helper.get_popup_settings(
|
||||||
window::Id::new(0),
|
window::Id::new(0),
|
||||||
new_id,
|
new_id,
|
||||||
(420, 600),
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
@ -156,14 +156,20 @@ impl Application for CosmicNetworkApplet {
|
||||||
self.active_conns = conns;
|
self.active_conns = conns;
|
||||||
self.update_icon_name();
|
self.update_icon_name();
|
||||||
}
|
}
|
||||||
NetworkManagerEvent::RequestResponse { wireless_access_points, active_conns, wifi_enabled, success, ..} => {
|
NetworkManagerEvent::RequestResponse {
|
||||||
|
wireless_access_points,
|
||||||
|
active_conns,
|
||||||
|
wifi_enabled,
|
||||||
|
success,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
if success {
|
if success {
|
||||||
self.wireless_access_points = wireless_access_points;
|
self.wireless_access_points = wireless_access_points;
|
||||||
self.active_conns = active_conns;
|
self.active_conns = active_conns;
|
||||||
self.wifi = wifi_enabled;
|
self.wifi = wifi_enabled;
|
||||||
self.update_icon_name();
|
self.update_icon_name();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Message::SelectWirelessAccessPoint(ssid) => {
|
Message::SelectWirelessAccessPoint(ssid) => {
|
||||||
if let Some(tx) = self.nm_sender.as_ref() {
|
if let Some(tx) = self.nm_sender.as_ref() {
|
||||||
|
|
@ -312,7 +318,7 @@ impl Application for CosmicNetworkApplet {
|
||||||
});
|
});
|
||||||
list_col = list_col.add(button);
|
list_col = list_col.add(button);
|
||||||
}
|
}
|
||||||
content = content.push(scrollable(list_col).height(Length::Fill));
|
content = content.push(scrollable(list_col).height(Length::Units(300)));
|
||||||
}
|
}
|
||||||
self.applet_helper.popup_container(content).into()
|
self.applet_helper.popup_container(content).into()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,22 @@ pub async fn active_connections(
|
||||||
for connection in active_connections {
|
for connection in active_connections {
|
||||||
if connection.vpn().await.unwrap_or_default() {
|
if connection.vpn().await.unwrap_or_default() {
|
||||||
let mut ip_addresses = Vec::new();
|
let mut ip_addresses = Vec::new();
|
||||||
for address_data in connection.ip4_config().await?.address_data().await.unwrap_or_default() {
|
for address_data in connection
|
||||||
|
.ip4_config()
|
||||||
|
.await?
|
||||||
|
.address_data()
|
||||||
|
.await
|
||||||
|
.unwrap_or_default()
|
||||||
|
{
|
||||||
ip_addresses.push(IpAddr::V4(address_data.address));
|
ip_addresses.push(IpAddr::V4(address_data.address));
|
||||||
}
|
}
|
||||||
for address_data in connection.ip6_config().await?.address_data().await.unwrap_or_default() {
|
for address_data in connection
|
||||||
|
.ip6_config()
|
||||||
|
.await?
|
||||||
|
.address_data()
|
||||||
|
.await
|
||||||
|
.unwrap_or_default()
|
||||||
|
{
|
||||||
ip_addresses.push(IpAddr::V6(address_data.address));
|
ip_addresses.push(IpAddr::V6(address_data.address));
|
||||||
}
|
}
|
||||||
info.push(ActiveConnectionInfo::Vpn {
|
info.push(ActiveConnectionInfo::Vpn {
|
||||||
|
|
@ -27,13 +39,30 @@ pub async fn active_connections(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for device in connection.devices().await.unwrap_or_default() {
|
for device in connection.devices().await.unwrap_or_default() {
|
||||||
match device.downcast_to_device().await.ok().and_then(|inner| inner) {
|
match device
|
||||||
|
.downcast_to_device()
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
.and_then(|inner| inner)
|
||||||
|
{
|
||||||
Some(SpecificDevice::Wired(wired_device)) => {
|
Some(SpecificDevice::Wired(wired_device)) => {
|
||||||
let mut ip_addresses = Vec::new();
|
let mut ip_addresses = Vec::new();
|
||||||
for address_data in device.ip4_config().await?.address_data().await.unwrap_or_default() {
|
for address_data in device
|
||||||
|
.ip4_config()
|
||||||
|
.await?
|
||||||
|
.address_data()
|
||||||
|
.await
|
||||||
|
.unwrap_or_default()
|
||||||
|
{
|
||||||
ip_addresses.push(IpAddr::V4(address_data.address));
|
ip_addresses.push(IpAddr::V4(address_data.address));
|
||||||
}
|
}
|
||||||
for address_data in device.ip6_config().await?.address_data().await.unwrap_or_default() {
|
for address_data in device
|
||||||
|
.ip6_config()
|
||||||
|
.await?
|
||||||
|
.address_data()
|
||||||
|
.await
|
||||||
|
.unwrap_or_default()
|
||||||
|
{
|
||||||
ip_addresses.push(IpAddr::V6(address_data.address));
|
ip_addresses.push(IpAddr::V6(address_data.address));
|
||||||
}
|
}
|
||||||
info.push(ActiveConnectionInfo::Wired {
|
info.push(ActiveConnectionInfo::Wired {
|
||||||
|
|
@ -56,10 +85,22 @@ pub async fn active_connections(
|
||||||
}
|
}
|
||||||
Some(SpecificDevice::WireGuard(_)) => {
|
Some(SpecificDevice::WireGuard(_)) => {
|
||||||
let mut ip_addresses = Vec::new();
|
let mut ip_addresses = Vec::new();
|
||||||
for address_data in connection.ip4_config().await?.address_data().await.unwrap_or_default() {
|
for address_data in connection
|
||||||
|
.ip4_config()
|
||||||
|
.await?
|
||||||
|
.address_data()
|
||||||
|
.await
|
||||||
|
.unwrap_or_default()
|
||||||
|
{
|
||||||
ip_addresses.push(IpAddr::V4(address_data.address));
|
ip_addresses.push(IpAddr::V4(address_data.address));
|
||||||
}
|
}
|
||||||
for address_data in connection.ip6_config().await?.address_data().await.unwrap_or_default() {
|
for address_data in connection
|
||||||
|
.ip6_config()
|
||||||
|
.await?
|
||||||
|
.address_data()
|
||||||
|
.await
|
||||||
|
.unwrap_or_default()
|
||||||
|
{
|
||||||
ip_addresses.push(IpAddr::V6(address_data.address));
|
ip_addresses.push(IpAddr::V6(address_data.address));
|
||||||
}
|
}
|
||||||
info.push(ActiveConnectionInfo::Vpn {
|
info.push(ActiveConnectionInfo::Vpn {
|
||||||
|
|
@ -71,14 +112,12 @@ pub async fn active_connections(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info.sort_by(|a, b| {
|
info.sort_by(|a, b| {
|
||||||
let helper = |conn: &ActiveConnectionInfo| {
|
let helper = |conn: &ActiveConnectionInfo| match conn {
|
||||||
match conn {
|
ActiveConnectionInfo::Vpn { name, .. } => format!("0{name}"),
|
||||||
ActiveConnectionInfo::Vpn { name, .. } => format!("0{name}"),
|
ActiveConnectionInfo::Wired { name, .. } => format!("1{name}"),
|
||||||
ActiveConnectionInfo::Wired { name, .. } => format!("1{name}"),
|
ActiveConnectionInfo::WiFi { name, .. } => format!("2{name}"),
|
||||||
ActiveConnectionInfo::WiFi { name, .. } => format!("2{name}"),
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
helper(a).cmp(&helper(b))
|
helper(a).cmp(&helper(b))
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ impl Application for Notifications {
|
||||||
let popup_settings = self.applet_helper.get_popup_settings(
|
let popup_settings = self.applet_helper.get_popup_settings(
|
||||||
window::Id::new(0),
|
window::Id::new(0),
|
||||||
new_id,
|
new_id,
|
||||||
(400, 300),
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
|
|
||||||
use cosmic::applet::CosmicAppletHelper;
|
use cosmic::applet::CosmicAppletHelper;
|
||||||
|
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
|
||||||
use cosmic::iced::wayland::SurfaceIdWrapper;
|
use cosmic::iced::wayland::SurfaceIdWrapper;
|
||||||
use cosmic::iced::wayland::popup::{get_popup, destroy_popup};
|
|
||||||
use cosmic::iced::widget::{self, Row};
|
use cosmic::iced::widget::{self, Row};
|
||||||
use cosmic::iced_native::widget::Space;
|
use cosmic::iced_native::widget::Space;
|
||||||
use cosmic::widget::{horizontal_rule, icon};
|
use cosmic::widget::{horizontal_rule, icon};
|
||||||
|
|
@ -110,7 +109,7 @@ impl Application for Power {
|
||||||
let popup_settings = self.applet_helper.get_popup_settings(
|
let popup_settings = self.applet_helper.get_popup_settings(
|
||||||
window::Id::new(0),
|
window::Id::new(0),
|
||||||
new_id,
|
new_id,
|
||||||
(400, 300),
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
@ -118,8 +117,8 @@ impl Application for Power {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Settings => {
|
Message::Settings => {
|
||||||
let _ = process::Command::new("cosmic-settings").spawn();
|
let _ = process::Command::new("cosmic-settings").spawn();
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
Message::Lock => Command::perform(lock(), Message::Zbus),
|
Message::Lock => Command::perform(lock(), Message::Zbus),
|
||||||
Message::LogOut => Command::perform(log_out(), Message::Zbus),
|
Message::LogOut => Command::perform(log_out(), Message::Zbus),
|
||||||
|
|
@ -145,8 +144,7 @@ impl Application for Power {
|
||||||
.on_press(Message::TogglePopup)
|
.on_press(Message::TogglePopup)
|
||||||
.into(),
|
.into(),
|
||||||
SurfaceIdWrapper::Popup(_) => {
|
SurfaceIdWrapper::Popup(_) => {
|
||||||
let settings = row_button(vec!["Settings...".into()])
|
let settings = row_button(vec!["Settings...".into()]).on_press(Message::Settings);
|
||||||
.on_press(Message::Settings);
|
|
||||||
|
|
||||||
let session = column![
|
let session = column![
|
||||||
row_button(vec![
|
row_button(vec![
|
||||||
|
|
@ -183,7 +181,8 @@ impl Application for Power {
|
||||||
.push(horizontal_rule(1))
|
.push(horizontal_rule(1))
|
||||||
.push(session)
|
.push(session)
|
||||||
.push(horizontal_rule(1))
|
.push(horizontal_rule(1))
|
||||||
.push(power);
|
.push(power)
|
||||||
|
.padding(8);
|
||||||
|
|
||||||
self.applet_helper.popup_container(content).into()
|
self.applet_helper.popup_container(content).into()
|
||||||
}
|
}
|
||||||
|
|
@ -208,10 +207,7 @@ fn row_button(mut content: Vec<Element<Message>>) -> widget::Button<Message, Ren
|
||||||
.style(theme::Button::Text)
|
.style(theme::Button::Text)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn power_buttons<'a>(
|
fn power_buttons<'a>(name: &'a str, text: &'a str) -> widget::Button<'a, Message, Renderer> {
|
||||||
name: &'a str,
|
|
||||||
text: &'a str,
|
|
||||||
) -> widget::Button<'a, Message, Renderer> {
|
|
||||||
button(
|
button(
|
||||||
column![text_icon(name, 40), text]
|
column![text_icon(name, 40), text]
|
||||||
.spacing(5)
|
.spacing(5)
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ impl Application for Time {
|
||||||
let popup_settings = self.applet_helper.get_popup_settings(
|
let popup_settings = self.applet_helper.get_popup_settings(
|
||||||
window::Id::new(0),
|
window::Id::new(0),
|
||||||
new_id,
|
new_id,
|
||||||
(400, 300),
|
None,
|
||||||
Some(60),
|
Some(60),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
@ -166,7 +166,8 @@ impl Application for Time {
|
||||||
.align_items(Alignment::Start)
|
.align_items(Alignment::Start)
|
||||||
.spacing(12)
|
.spacing(12)
|
||||||
.padding([24, 0])
|
.padding([24, 0])
|
||||||
.push(text(calendar));
|
.push(text(calendar))
|
||||||
|
.padding(8);
|
||||||
|
|
||||||
self.applet_helper.popup_container(content).into()
|
self.applet_helper.popup_container(content).into()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
use std::cmp::Ordering;
|
|
||||||
use calloop::channel::SyncSender;
|
use calloop::channel::SyncSender;
|
||||||
use cosmic::applet::CosmicAppletHelper;
|
|
||||||
use cosmic::applet::cosmic_panel_config::PanelAnchor;
|
use cosmic::applet::cosmic_panel_config::PanelAnchor;
|
||||||
|
use cosmic::applet::CosmicAppletHelper;
|
||||||
use cosmic::iced::alignment::{Horizontal, Vertical};
|
use cosmic::iced::alignment::{Horizontal, Vertical};
|
||||||
use cosmic::iced::mouse::{self, ScrollDelta};
|
use cosmic::iced::mouse::{self, ScrollDelta};
|
||||||
use cosmic::iced::wayland::actions::window::SctkWindowSettings;
|
use cosmic::iced::wayland::actions::window::SctkWindowSettings;
|
||||||
|
use cosmic::iced::wayland::{window::resize_window, InitialSurface, SurfaceIdWrapper};
|
||||||
use cosmic::iced::widget::{column, container, row, text};
|
use cosmic::iced::widget::{column, container, row, text};
|
||||||
use cosmic::iced::{
|
use cosmic::iced::{
|
||||||
executor, subscription, widget::button, window, Application, Command, Event::Mouse, Length,
|
executor, subscription, widget::button, window, Application, Command, Event::Mouse, Length,
|
||||||
Settings, Subscription,
|
Settings, Subscription,
|
||||||
};
|
};
|
||||||
use cosmic::iced_style::Color;
|
|
||||||
use cosmic::iced_style::application::{self, Appearance};
|
use cosmic::iced_style::application::{self, Appearance};
|
||||||
|
use cosmic::iced_style::Color;
|
||||||
use cosmic::theme::Button;
|
use cosmic::theme::Button;
|
||||||
use cosmic::{Element, Theme};
|
use cosmic::{Element, Theme};
|
||||||
use cosmic_protocols::workspace::v1::client::zcosmic_workspace_handle_v1;
|
use cosmic_protocols::workspace::v1::client::zcosmic_workspace_handle_v1;
|
||||||
use cosmic::iced::wayland::{SurfaceIdWrapper, InitialSurface, window::resize_window};
|
use std::cmp::Ordering;
|
||||||
use wayland_backend::client::ObjectId;
|
use wayland_backend::client::ObjectId;
|
||||||
|
|
||||||
use crate::config;
|
use crate::config;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue