refactor: make the graphics applet more like the mockup

This commit is contained in:
Ashley Wulber 2023-01-12 14:30:58 -05:00 committed by Ashley Wulber
parent c009d14eea
commit a253dee83a
13 changed files with 311 additions and 149 deletions

46
Cargo.lock generated
View file

@ -127,9 +127,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
[[package]]
name = "ash"
version = "0.37.1+1.3.235"
version = "0.37.2+1.3.238"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "911015c962d56e2e4052f40182ca5462ba60a3d2ff04e827c365a0ab3d65726d"
checksum = "28bf19c1f0a470be5fbf7522a308a05df06610252c5bcf5143e1b23f629a9a03"
dependencies = [
"libloading",
]
@ -558,7 +558,11 @@ dependencies = [
name = "cosmic-applet-graphics"
version = "0.1.0"
dependencies = [
"i18n-embed",
"i18n-embed-fl",
"libcosmic",
"once_cell",
"rust-embed",
"smithay-client-toolkit",
"zbus",
]
@ -716,7 +720,7 @@ dependencies = [
[[package]]
name = "cosmic-theme"
version = "0.1.0"
source = "git+https://github.com/pop-os/cosmic-theme.git#77aad06a6e3e2996ef24fc12e5f59d6da7226692"
source = "git+https://github.com/pop-os/cosmic-theme.git#5c84b81c67a69e3752bc2fdc451f9d49857ceabf"
dependencies = [
"anyhow",
"csscolorparser",
@ -955,7 +959,7 @@ dependencies = [
"hashbrown",
"lock_api",
"once_cell",
"parking_lot_core 0.9.5",
"parking_lot_core 0.9.6",
]
[[package]]
@ -1422,9 +1426,9 @@ dependencies = [
[[package]]
name = "freedesktop-icons"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e31823094643eabe14030d2f1b3f0aa10164f27b1a31e2b938ffe8ea9c9fc91b"
checksum = "00e61ac115df4632b592d36b71fda3c259f4c8061c70b7fa429bac145890e880"
dependencies = [
"dirs 4.0.0",
"once_cell",
@ -2007,7 +2011,7 @@ dependencies = [
[[package]]
name = "iced"
version = "0.6.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"iced_core",
"iced_futures",
@ -2024,7 +2028,7 @@ dependencies = [
[[package]]
name = "iced_core"
version = "0.6.2"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"bitflags",
"palette",
@ -2034,7 +2038,7 @@ dependencies = [
[[package]]
name = "iced_futures"
version = "0.5.1"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"futures",
"log",
@ -2046,7 +2050,7 @@ dependencies = [
[[package]]
name = "iced_glow"
version = "0.5.1"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"bytemuck",
"euclid",
@ -2061,7 +2065,7 @@ dependencies = [
[[package]]
name = "iced_graphics"
version = "0.5.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"bitflags",
"bytemuck",
@ -2081,7 +2085,7 @@ dependencies = [
[[package]]
name = "iced_lazy"
version = "0.3.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"iced_native",
"ouroboros 0.13.0",
@ -2090,7 +2094,7 @@ dependencies = [
[[package]]
name = "iced_native"
version = "0.7.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"iced_core",
"iced_futures",
@ -2104,7 +2108,7 @@ dependencies = [
[[package]]
name = "iced_sctk"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"enum-repr",
"futures",
@ -2123,7 +2127,7 @@ dependencies = [
[[package]]
name = "iced_softbuffer"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"cosmic-text",
"iced_graphics",
@ -2138,7 +2142,7 @@ dependencies = [
[[package]]
name = "iced_style"
version = "0.5.1"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"iced_core",
"once_cell",
@ -2148,7 +2152,7 @@ dependencies = [
[[package]]
name = "iced_wgpu"
version = "0.7.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"bitflags",
"bytemuck",
@ -2338,7 +2342,7 @@ checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
name = "libcosmic"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#5224c9b75c000fcf92a1851391fe1dc82486610a"
source = "git+https://github.com/pop-os/libcosmic/?branch=master#3bb193c3d2f41f87359d80e3eebba365425c4018"
dependencies = [
"apply",
"cosmic-panel-config",
@ -2909,7 +2913,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"lock_api",
"parking_lot_core 0.9.5",
"parking_lot_core 0.9.6",
]
[[package]]
@ -2928,9 +2932,9 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.9.5"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba"
checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf"
dependencies = [
"cfg-if",
"libc",

View file

@ -10,5 +10,5 @@ icon-loader = { version = "0.3.6", features = ["gtk"] }
libpulse-binding = "2.26.0"
libpulse-glib-binding = "2.25.0"
tokio = { version = "1.20.1", features=["full"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "3776d4a" }

View file

@ -5,7 +5,7 @@ edition = "2021"
[dependencies]
once_cell = "1.16.0"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "3776d4a" }
futures = "0.3"
zbus = { version = "3.5", default-features = false, features = ["tokio"] }

View file

@ -7,6 +7,10 @@ edition = "2021"
[dependencies]
zbus = "3.4"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "3776d4a" }
once_cell = "1"
# Application i18n
i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.6.4"
rust-embed = "6.3.0"

View file

@ -0,0 +1,4 @@
fallback_language = "en"
[fluent]
assets_dir = "i18n"

View file

@ -0,0 +1,9 @@
graphics-mode = Graphics Mode
graphics = Graphics
integrated = Integrated
integrated-desc = Disables external displays. Requires Restart.
nvidia = NVIDIA
hybrid = Hybrid
hybrid-desc = Requires Restart.
compute = Compute
compute-desc = Disables external displays. Requires Restart.

View file

@ -0,0 +1,47 @@
// SPDX-License-Identifier: MPL-2.0-only
use i18n_embed::{
fluent::{fluent_language_loader, FluentLanguageLoader},
DefaultLocalizer, LanguageLoader, Localizer,
};
use once_cell::sync::Lazy;
use rust_embed::RustEmbed;
#[derive(RustEmbed)]
#[folder = "i18n/"]
struct Localizations;
pub static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| {
let loader: FluentLanguageLoader = fluent_language_loader!();
loader
.load_fallback_language(&Localizations)
.expect("Error while loading fallback language");
loader
});
#[macro_export]
macro_rules! fl {
($message_id:literal) => {{
i18n_embed_fl::fl!($crate::localize::LANGUAGE_LOADER, $message_id)
}};
($message_id:literal, $($args:expr),*) => {{
i18n_embed_fl::fl!($crate::localize::LANGUAGE_LOADER, $message_id, $($args), *)
}};
}
// Get the `Localizer` to be used for localizing this library.
pub fn localizer() -> Box<dyn Localizer> {
Box::from(DefaultLocalizer::new(&*LANGUAGE_LOADER, &Localizations))
}
pub fn localize() {
let localizer = localizer();
let requested_languages = i18n_embed::DesktopLanguageRequester::requested_languages();
if let Err(error) = localizer.select(&requested_languages) {
eprintln!("Error while loading language for App List {}", error);
}
}

View file

@ -1,11 +1,34 @@
mod dbus;
mod graphics;
mod localize;
mod window;
use cosmic::{applet::CosmicAppletHelper, iced::Application};
use cosmic::{
applet::{cosmic_panel_config::PanelAnchor, CosmicAppletHelper},
iced::{wayland::InitialSurface, Application, Settings},
iced_native::layout::Limits,
};
use window::*;
pub fn main() -> cosmic::iced::Result {
let helper = CosmicAppletHelper::default();
Window::run(helper.window_settings())
let mut settings: Settings<()> = helper.window_settings();
match helper.anchor {
PanelAnchor::Top | PanelAnchor::Bottom => {
match &mut settings.initial_surface {
InitialSurface::LayerSurface(_) => todo!(),
InitialSurface::XdgWindow(w) => {
w.autosize = true;
w.size_limits = Limits::NONE
.min_height(1)
.max_height(200)
.min_width(1)
.max_width(1000);
}
};
}
_ => {}
};
Window::run(settings)
}

View file

@ -1,31 +1,29 @@
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::wayland::SurfaceIdWrapper;
use cosmic::iced_native::alignment::Horizontal;
use cosmic::iced_native::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, PanelSize},
iced::widget::{column, radio, text},
applet::{cosmic_panel_config::PanelAnchor, APPLET_BUTTON_THEME},
iced::widget::{column, container, row, text},
iced::{self, Application, Command, Length},
iced_native::window,
theme::Theme,
widget::horizontal_rule,
theme::{Svg, Theme},
widget::{button, horizontal_rule},
Element,
};
use zbus::Connection;
#[derive(Clone, Copy)]
enum State {
SelectGraphicsMode(bool),
SettingGraphicsMode(Graphics),
}
#[derive(Clone, Copy)]
enum GraphicsMode {
AppliedGraphicsMode(Graphics),
SelectedGraphicsMode(Graphics),
CurrentGraphicsMode(Graphics),
}
@ -35,26 +33,18 @@ impl GraphicsMode {
match self {
GraphicsMode::SelectedGraphicsMode(g) => *g,
GraphicsMode::CurrentGraphicsMode(g) => *g,
GraphicsMode::AppliedGraphicsMode(g) => *g,
}
}
}
impl Default for State {
fn default() -> Self {
Self::SelectGraphicsMode(false)
}
}
#[derive(Default)]
pub struct Window {
popup: Option<window::Id>,
graphics_mode: Option<GraphicsMode>,
id_ctr: u32,
icon_size: u16,
anchor: PanelAnchor,
theme: Theme,
dbus: Option<(Connection, PowerDaemonProxy<'static>)>,
state: State,
applet_helper: CosmicAppletHelper,
}
@ -62,7 +52,7 @@ pub struct Window {
#[derive(Clone, Debug)]
pub enum Message {
CurrentGraphics(Option<Graphics>),
SelectedGraphicsMode(Option<Graphics>),
AppliedGraphics(Option<Graphics>),
DBusInit(Option<(Connection, PowerDaemonProxy<'static>)>),
SelectGraphicsMode(Graphics),
TogglePopup,
@ -76,26 +66,7 @@ impl Application for Window {
type Theme = Theme;
fn new(_flags: ()) -> (Self, Command<Self::Message>) {
let mut window = Window::default();
let pixels = std::env::var("COSMIC_PANEL_SIZE")
.ok()
.map(|size| match size.parse::<PanelSize>() {
Ok(PanelSize::XL) => 64,
Ok(PanelSize::L) => 36,
Ok(PanelSize::M) => 24,
Ok(PanelSize::S) => 16,
Ok(PanelSize::XS) => 12,
Err(_) => 12,
})
.unwrap_or(16);
window.icon_size = pixels;
window.anchor = std::env::var("COSMIC_PANEL_ANCHOR")
.ok()
.map(|size| match size.parse::<PanelAnchor>() {
Ok(p) => p,
Err(_) => PanelAnchor::Top,
})
.unwrap_or(PanelAnchor::Top);
let window = Window::default();
(window, Command::perform(dbus::init(), Message::DBusInit))
}
@ -107,22 +78,16 @@ impl Application for Window {
match message {
Message::SelectGraphicsMode(new_graphics_mode) => {
if let Some((_, proxy)) = self.dbus.as_ref() {
self.state = State::SettingGraphicsMode(new_graphics_mode);
self.graphics_mode =
Some(GraphicsMode::SelectedGraphicsMode(new_graphics_mode));
return Command::perform(
set_graphics(proxy.clone(), new_graphics_mode),
move |success| {
Message::SelectedGraphicsMode(success.ok().map(|_| new_graphics_mode))
Message::AppliedGraphics(success.ok().map(|_| new_graphics_mode))
},
);
}
}
Message::SelectedGraphicsMode(g) => {
if let Some(g) = g {
self.graphics_mode
.replace(GraphicsMode::SelectedGraphicsMode(g));
self.state = State::SelectGraphicsMode(true);
}
}
Message::TogglePopup => {
if let Some(p) = self.popup.take() {
return destroy_popup(p);
@ -178,6 +143,11 @@ impl Application for Window {
self.popup = None;
}
}
Message::AppliedGraphics(g) => {
if let Some(g) = g {
self.graphics_mode = Some(GraphicsMode::AppliedGraphicsMode(g));
}
}
}
Command::none()
}
@ -185,86 +155,187 @@ impl Application for Window {
fn view(&self, id: SurfaceIdWrapper) -> Element<Message> {
match id {
SurfaceIdWrapper::LayerSurface(_) => unimplemented!(),
SurfaceIdWrapper::Window(_) => self
.applet_helper
.icon_button("input-gaming-symbolic")
.on_press(Message::TogglePopup)
.style(Button::Text)
.into(),
SurfaceIdWrapper::Window(_) => match self.applet_helper.anchor {
PanelAnchor::Left | PanelAnchor::Right => self
.applet_helper
.icon_button("input-gaming-symbolic")
.on_press(Message::TogglePopup)
.style(Button::Text)
.into(),
PanelAnchor::Top | PanelAnchor::Bottom => button(Button::Text)
.custom(vec![row![
icon(
"input-gaming-symbolic",
self.applet_helper.suggested_size().0,
)
.style(Svg::Symbolic),
text(match self.graphics_mode.map(|g| g.inner()) {
Some(Graphics::Integrated) => fl!("integrated"),
Some(Graphics::Nvidia) => fl!("nvidia"),
Some(Graphics::Compute) => fl!("compute"),
Some(Graphics::Hybrid) => fl!("hybrid"),
None => "".into(),
})
]
.spacing(8)
.padding([0, self.applet_helper.suggested_size().0 / 2])
.align_items(Alignment::Center)
.into()])
.style(Button::Text)
.on_press(Message::TogglePopup)
.padding(8)
.width(Length::Shrink)
.height(Length::Shrink)
.into(),
},
SurfaceIdWrapper::Popup(_) => {
let content = match self.state {
State::SelectGraphicsMode(pending_restart) => {
let mut content_list = vec![
radio(
"Integrated Graphics",
Graphics::Integrated,
self.graphics_mode.map(|g| g.inner()),
Message::SelectGraphicsMode,
let content_list = vec![
button(APPLET_BUTTON_THEME)
.custom(vec![row![
column![
text(format!("{} {}", fl!("integrated"), fl!("graphics"))).size(14),
text(fl!("integrated-desc")).size(12)
]
.width(Length::Fill),
icon(
match self.graphics_mode {
Some(GraphicsMode::SelectedGraphicsMode(
Graphics::Integrated,
)) => "process-working-symbolic",
_ => "emblem-ok-symbolic",
},
12
)
.into(),
radio(
"Nvidia Graphics",
Graphics::Nvidia,
self.graphics_mode.map(|g| g.inner()),
Message::SelectGraphicsMode,
)
.into(),
radio(
"Hybrid Graphics",
Graphics::Hybrid,
self.graphics_mode.map(|g| g.inner()),
Message::SelectGraphicsMode,
)
.into(),
radio(
"Compute Graphics",
Graphics::Compute,
self.graphics_mode.map(|g| g.inner()),
Message::SelectGraphicsMode,
)
.into(),
];
if pending_restart {
content_list.insert(
0,
text("Restart to apply changes")
.width(Length::Fill)
.horizontal_alignment(Horizontal::Center)
.size(16)
.into(),
)
}
column(content_list).padding([8, 0]).spacing(8).into()
}
State::SettingGraphicsMode(graphics) => {
let graphics_str = match graphics {
Graphics::Integrated => "integrated",
Graphics::Hybrid => "hybrid",
Graphics::Nvidia => "nvidia",
Graphics::Compute => "compute",
};
column(vec![text(format!(
"Setting graphics mode to {graphics_str}..."
))
.width(Length::Fill)
.horizontal_alignment(Horizontal::Center)
.size(12)
.style(match self.graphics_mode {
Some(GraphicsMode::CurrentGraphicsMode(Graphics::Integrated)) =>
Svg::SymbolicActive,
Some(GraphicsMode::AppliedGraphicsMode(Graphics::Integrated)) =>
Svg::SymbolicActive,
Some(GraphicsMode::SelectedGraphicsMode(Graphics::Integrated)) =>
Svg::Symbolic,
_ => Svg::Default,
},),
]
.align_items(Alignment::Center)
.into()])
.into()
}
};
.padding([8, 24])
.on_press(Message::SelectGraphicsMode(Graphics::Integrated))
.width(Length::Fill)
.into(),
button(APPLET_BUTTON_THEME)
.custom(vec![row![
column![
text(format!("{} {}", fl!("nvidia"), fl!("graphics"))).size(14),
]
.width(Length::Fill),
icon(
match self.graphics_mode {
Some(GraphicsMode::SelectedGraphicsMode(Graphics::Nvidia)) =>
"process-working-symbolic",
_ => "emblem-ok-symbolic",
},
12
)
.size(12)
.style(match self.graphics_mode {
Some(GraphicsMode::CurrentGraphicsMode(Graphics::Nvidia)) =>
Svg::SymbolicActive,
Some(GraphicsMode::AppliedGraphicsMode(Graphics::Nvidia)) =>
Svg::SymbolicActive,
Some(GraphicsMode::SelectedGraphicsMode(Graphics::Nvidia)) =>
Svg::Symbolic,
_ => Svg::Default,
}),
]
.align_items(Alignment::Center)
.into()])
.padding([8, 24])
.on_press(Message::SelectGraphicsMode(Graphics::Nvidia))
.width(Length::Fill)
.into(),
button(APPLET_BUTTON_THEME)
.custom(vec![row![
column![
text(format!("{} {}", fl!("hybrid"), fl!("graphics"))).size(14),
text(fl!("hybrid-desc")).size(12)
]
.width(Length::Fill),
icon(
match self.graphics_mode {
Some(GraphicsMode::SelectedGraphicsMode(Graphics::Hybrid)) =>
"process-working-symbolic",
_ => "emblem-ok-symbolic",
},
12
)
.size(12)
.style(match self.graphics_mode {
Some(GraphicsMode::CurrentGraphicsMode(Graphics::Hybrid)) =>
Svg::SymbolicActive,
Some(GraphicsMode::AppliedGraphicsMode(Graphics::Hybrid)) =>
Svg::SymbolicActive,
Some(GraphicsMode::SelectedGraphicsMode(Graphics::Hybrid)) =>
Svg::Symbolic,
_ => Svg::Default,
})
]
.align_items(Alignment::Center)
.into()])
.padding([8, 24])
.on_press(Message::SelectGraphicsMode(Graphics::Hybrid))
.width(Length::Fill)
.into(),
button(APPLET_BUTTON_THEME)
.custom(vec![row![
column![
text(format!("{} {}", fl!("compute"), fl!("graphics"))).size(14),
text(fl!("compute-desc")).size(12)
]
.width(Length::Fill),
icon(
match self.graphics_mode {
Some(GraphicsMode::SelectedGraphicsMode(Graphics::Compute)) =>
"process-working-symbolic",
_ => "emblem-ok-symbolic",
},
12
)
.size(12)
.style(match self.graphics_mode {
Some(GraphicsMode::CurrentGraphicsMode(Graphics::Compute)) =>
Svg::SymbolicActive,
Some(GraphicsMode::AppliedGraphicsMode(Graphics::Compute)) =>
Svg::SymbolicActive,
Some(GraphicsMode::SelectedGraphicsMode(Graphics::Compute)) =>
Svg::Symbolic,
_ => Svg::Default,
}),
]
.align_items(Alignment::Center)
.into()])
.padding([8, 24])
.on_press(Message::SelectGraphicsMode(Graphics::Compute))
.width(Length::Fill)
.into(),
];
self.applet_helper
.popup_container(
column(vec![
text("Graphics Mode")
text(fl!("graphics-mode"))
.width(Length::Fill)
.horizontal_alignment(Horizontal::Center)
.size(24)
.into(),
horizontal_rule(1).into(),
content,
container(horizontal_rule(1))
.padding([0, 12])
.width(Length::Fill)
.into(),
column(content_list).into(),
])
.padding(8)
.spacing(4),
.padding([8, 0])
.spacing(12),
)
.into()
}

View file

@ -6,5 +6,5 @@ license = "GPL-3.0-or-later"
[dependencies]
icon-loader = { version = "0.3.6", features = ["gtk"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
nix = "0.24.1"

View file

@ -9,7 +9,7 @@ icon-loader = { version = "0.3.6", features = ["gtk"] }
libpulse-binding = "2.26.0"
libpulse-glib-binding = "2.25.0"
tokio = { version = "1.20.1", features=["full"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "3776d4a" }
nix = "0.26.1"
zbus = "3.7"

View file

@ -6,6 +6,6 @@ license = "GPL-3.0-or-later"
[dependencies]
icon-loader = { version = "0.3.6", features = ["gtk"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
nix = "0.24.1"
chrono = { version = "0.4.23", features = ["clock"] }

View file

@ -5,7 +5,7 @@ authors = ["Ashley Wulber <ashley@system76.com>"]
edition = "2021"
[dependencies]
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["tokio", "wayland", "applet"] }
cosmic-client-toolkit = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"] }
wayland-backend = {version = "0.1.0-beta.14", features = ["client_system"]}