graphics: Remove unused applet

This commit is contained in:
Victoria Brekenfeld 2024-02-26 22:04:35 +01:00 committed by Jeremy Soller
parent 5be328f8ad
commit 28e6079ee7
26 changed files with 1 additions and 783 deletions

13
Cargo.lock generated
View file

@ -927,19 +927,6 @@ dependencies = [
"tracing-subscriber",
]
[[package]]
name = "cosmic-applet-graphics"
version = "0.1.0"
dependencies = [
"i18n-embed 0.13.9",
"i18n-embed-fl 0.6.7",
"libcosmic",
"once_cell",
"rust-embed 6.8.1",
"tracing",
"zbus",
]
[[package]]
name = "cosmic-applet-network"
version = "0.1.0"

View file

@ -5,7 +5,6 @@ members = [
"cosmic-applet-audio",
"cosmic-applet-battery",
"cosmic-applet-bluetooth",
"cosmic-applet-graphics",
"cosmic-applet-network",
"cosmic-applet-notifications",
"cosmic-applet-power",

View file

@ -1,16 +0,0 @@
[package]
name = "cosmic-applet-graphics"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
zbus.workspace = true
libcosmic.workspace = true
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"
tracing = "0.1"

View file

@ -1,13 +0,0 @@
[Desktop Entry]
Name=Cosmic Applet Graphics
Comment=Applet for Cosmic Panel
Type=Application
Exec=cosmic-applet-graphics
Terminal=false
Categories=Cosmic;Iced;
Keywords=Cosmic;Iced;
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
Icon=com.system76.CosmicAppletGraphics
StartupNotify=true
NoDisplay=true
X-CosmicApplet=true

View file

@ -1,41 +0,0 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="applet-graphics-mode">
<rect id="Rectangle 47" x="4" y="4" width="8" height="8" fill="#232323"/>
<g id="Rectangle 48">
<path d="M4 0.75C4 0.75 4 0 5 0C6 0 6 0.75 6 0.75V3H4V0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 54">
<path d="M0.75 6C0.75 6 0 6 0 5C0 4 0.75 4 0.75 4H3V6H0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 57">
<path d="M15.25 6C15.25 6 16 6 16 5C16 4 15.25 4 15.25 4H13V6H15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 51">
<path d="M4 15.25C4 15.25 4 16 5 16C6 16 6 15.25 6 15.25V13H4V15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 49">
<path d="M7 0.75C7 0.75 7 0 8 0C9 0 9 0.75 9 0.75V3H7V0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 55">
<path d="M0.75 9C0.75 9 0 9 0 8C0 7 0.75 7 0.75 7H3V9H0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 58">
<path d="M15.25 9C15.25 9 16 9 16 8C16 7 15.25 7 15.25 7H13V9H15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 52">
<path d="M7 15.25C7 15.25 7 16 8 16C9 16 9 15.25 9 15.25V13H7V15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 50">
<path d="M10 0.75C10 0.75 10 0 11 0C12 0 12 0.75 12 0.75V3H10V0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 56">
<path d="M0.75 12C0.75 12 0 12 0 11C0 10 0.75 10 0.75 10H3V12H0.75Z" fill="#232323"/>
</g>
<g id="Rectangle 59">
<path d="M15.25 12C15.25 12 16 12 16 11C16 10 15.25 10 15.25 10H13V12H15.25Z" fill="#232323"/>
</g>
<g id="Rectangle 53">
<path d="M10 15.25C10 15.25 10 16 11 16C12 16 12 15.25 12 15.25V13H10V15.25Z" fill="#232323"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View file

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

View file

@ -1,9 +0,0 @@
graphics-mode = Grafikmodus
graphics = Graphik
integrated = Integriert
integrated-desc = Deaktiviert externe Bildschirme. Neustart erforderlich.
nvidia = NVIDIA
hybrid = Hybrid
hybrid-desc = Neustart erforderlich.
compute = Compute
compute-desc = Deaktiviert externe Bildschirme. Neustart erforderlich.

View file

@ -1,9 +0,0 @@
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

@ -1,9 +0,0 @@
graphics-mode = حالت گرافیکی
graphics = گرافیک
integrated = Integrated
integrated-desc = نمایشگر های خارجی را غیر فعال می کنم، نیازمند راه اندازی مجدد
nvidia = انویدیا
hybrid = Hybrid
hybrid-desc = نیازمند راه اندازی مجدد.
compute = Compute
compute-desc = نمایشگر های خارجی را غیر فعال می کنم، نیازمند راه اندازی مجدد

View file

@ -1,9 +0,0 @@
graphics-mode = Grafiikkatila
graphics = Grafiikka
integrated = Integroitu
integrated-desc = Poistaa ulkoiset näytöt käytöstä. Vaatii Uudelleenkäynnistyksen.
nvidia = NVIDIA
hybrid = Hybridi
hybrid-desc = Vaatii Uudelleenkäynnistyksen.
compute = Laskelmoi
compute-desc = Poistaa ulkoiset näytöt käytöstä. Vaatii Uudelleenkäynnistyksen.

View file

@ -1,9 +0,0 @@
graphics-mode = Modes graphique
graphics = Graphiques
integrated = Intégré
integrated-desc = Désactive les moniteurs externes. Nécessite un redémarrage.
nvidia = NVIDIA
hybrid = Hybride
hybrid-desc = Nécessite un redémarrage.
compute = Calcul
compute-desc = Désactive les moniteurs externes. Nécessite un redémarrage.

View file

@ -1,9 +0,0 @@
graphics-mode = グラフィックスモード
graphics = グラフィックス
integrated = 内蔵
integrated-desc = 再起動して外付けのモニターを無効にすることは必要です。
nvidia = NVIDIA
hybrid = ハイブリッド
hybrid-desc = 再起動が必要です。
compute = 計算
compute-desc = 再起動して外付けのモニターを無効にすることは必要です。

View file

@ -1,9 +0,0 @@
graphics-mode = 그래픽 모드
graphics = 그래픽
integrated = 내장 그래픽
integrated-desc = 외부 디스플레이를 비활성화하며, 시스템을 다시 시작해야 합니다.
nvidia = NVIDIA
hybrid = 하이브리드
hybrid-desc = 시스템을 다시 시작해야 합니다.
compute = 컴퓨팅
compute-desc = 외부 디스플레이를 비활성화하며, 시스템을 다시 시작해야 합니다.

View file

@ -1,9 +0,0 @@
graphics-mode = Grafische Modus
graphics = Grafisch
integrated = Geïntegreerd
integrated-desc = Zet alle externe schermen af. Herstart vereist.
nvidia = NVIDIA
hybrid = Hybride
hybrid-desc = Hertart vereist.
compute = Bereken
compute-desc = Zet alle externe schermen af. Herstart vereist.

View file

@ -1,9 +0,0 @@
graphics-mode = Tryb Graficzny
graphics = Grafika
integrated = Zintegrowana
integrated-desc = Wyłącza zewnętrzne wyświetlacze. Wymaga Restartu.
nvidia = NVIDIA
hybrid = Hybrydowa
hybrid-desc = Wymaga Restartu.
compute = Oblicz
compute-desc = Wyłącza zewnętrzne wyświetlacze. Wymaga Restartu.

View file

@ -1,9 +0,0 @@
graphics-mode = Modo Gráfico
graphics = Gráfico
integrated = Integrado
integrated-desc = Desativa monitores externos. Requer reinicialização.
nvidia = NVIDIA
hybrid = Híbrido
hybrid-desc = Requer reinicialização.
compute = Calcular
compute-desc = Desativa monitores externos. Requer reinicialização.

View file

@ -1,9 +0,0 @@
graphics-mode = Режим графики
graphics = Графика
integrated = Интегрированная
integrated-desc = Отключит внешние дисплеи. Требуется перезагрузка.
nvidia = NVIDIA
hybrid = Гибридная
hybrid-desc = Требуется перезагрузка.
compute = Вычислительная
compute-desc = Отключит внешние дисплеи. Требуется перезагрузка.

View file

@ -1,9 +0,0 @@
graphics-mode = Графички режим
graphics = Графика
integrated = Интегрисани
integrated-desc = Искључује екстерне дисплеје. Захтева поновно покретање система.
nvidia = NVIDIA
hybrid = Хибридни
hybrid-desc = Захтева поновно покретање система.
compute = Рачунски
compute-desc = Искључује екстерне дисплеје. Захтева поновно покретање система.

View file

@ -1,9 +0,0 @@
graphics-mode = Grafički režim
graphics = Grafika
integrated = Integrisani
integrated-desc = Isključuje eksterne displeje. Zahteva ponovno pokretanje sistema.
nvidia = NVIDIA
hybrid = Hibridni
hybrid-desc = Zahteva ponovno pokretanje sistema.
compute = Računski
compute-desc = Isključuje eksterne displeje. Zahteva ponovno pokretanje sistema.

View file

@ -1,9 +0,0 @@
graphics-mode = Режим графіки
graphics = Графіка
integrated = Інтегрована
integrated-desc = Вимикає зовнішні дисплеї. Потребує перезапуску.
nvidia = NVIDIA
hybrid = Гібридна
hybrid-desc = Потребує перезапуску.
compute = Обчислювальна
compute-desc = Вимикає зовнішні дисплеї. Потребує перезапуску.

View file

@ -1,100 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//! # DBus interface proxy for: `com.system76.PowerDaemon`
//!
//! This code was generated by `zbus-xmlgen` `3.0.0` from DBus introspection data.
//! Source: `Interface '/com/system76/PowerDaemon' from service 'com.system76.PowerDaemon' on system bus`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
//!
//! More information can be found in the
//! [Writing a client proxy](https://dbus.pages.freedesktop.org/zbus/client.html)
//! section of the zbus documentation.
//!
//! This DBus object implements
//! [standard DBus interfaces](https://dbus.freedesktop.org/doc/dbus-specification.html),
//! (`org.freedesktop.DBus.*`) for which the following zbus proxies can be used:
//!
//! * [`zbus::fdo::IntrospectableProxy`]
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use zbus::{dbus_proxy, Connection};
#[dbus_proxy(
interface = "com.system76.PowerDaemon",
default_path = "/com/system76/PowerDaemon"
)]
trait PowerDaemon {
/// Balanced method
fn balanced(&self) -> zbus::Result<()>;
/// Battery method
fn battery(&self) -> zbus::Result<()>;
/// GetChargeProfiles method
fn get_charge_profiles(
&self,
) -> zbus::Result<Vec<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>>;
/// GetChargeThresholds method
fn get_charge_thresholds(&self) -> zbus::Result<(u8, u8)>;
/// GetDefaultGraphics method
fn get_default_graphics(&self) -> zbus::Result<String>;
/// GetExternalDisplaysRequireDGPU method
fn get_external_displays_require_dgpu(&self) -> zbus::Result<bool>;
/// GetGraphics method
fn get_graphics(&self) -> zbus::Result<String>;
/// GetGraphicsPower method
fn get_graphics_power(&self) -> zbus::Result<bool>;
/// GetProfile method
fn get_profile(&self) -> zbus::Result<String>;
/// GetSwitchable method
fn get_switchable(&self) -> zbus::Result<bool>;
/// Performance method
fn performance(&self) -> zbus::Result<()>;
/// SetChargeThresholds method
fn set_charge_thresholds(&self, thresholds: &(u8, u8)) -> zbus::Result<()>;
/// SetGraphics method
fn set_graphics(&self, vendor: &str) -> zbus::Result<()>;
/// SetGraphicsPower method
fn set_graphics_power(&self, power: bool) -> zbus::Result<()>;
/// HotPlugDetect signal
#[dbus_proxy(signal)]
fn hot_plug_detect(&self, port: u64) -> zbus::Result<()>;
/// PowerProfileSwitch signal
#[dbus_proxy(signal)]
fn power_profile_switch(&self, profile: &str) -> zbus::Result<()>;
}
pub async fn init() -> Option<(Connection, PowerDaemonProxy<'static>)> {
let conn = match Connection::system().await {
Ok(conn) => conn,
_ => return None,
};
let proxy = match PowerDaemonProxy::new(&conn).await {
Ok(p) => p,
_ => return None,
};
if matches!(
proxy.introspect().await,
Err(zbus::fdo::Error::ServiceUnknown(_))
) {
return None;
}
Some((conn, proxy))
}

View file

@ -1,32 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-or-later
use crate::dbus::PowerDaemonProxy;
use zbus::Result;
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub enum Graphics {
Integrated,
Hybrid,
Nvidia,
Compute,
}
pub async fn get_current_graphics(daemon: PowerDaemonProxy<'_>) -> Result<Graphics> {
let graphics = daemon.get_graphics().await?;
match graphics.as_str() {
"integrated" => Ok(Graphics::Integrated),
"hybrid" => Ok(Graphics::Hybrid),
"nvidia" => Ok(Graphics::Nvidia),
"compute" => Ok(Graphics::Compute),
_ => panic!("Unknown graphics profile: {}", graphics),
}
}
pub async fn set_graphics(daemon: PowerDaemonProxy<'_>, graphics: Graphics) -> Result<()> {
let graphics_str = match graphics {
Graphics::Integrated => "integrated",
Graphics::Hybrid => "hybrid",
Graphics::Nvidia => "nvidia",
Graphics::Compute => "compute",
};
daemon.set_graphics(graphics_str).await
}

View file

@ -1,47 +0,0 @@
// 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,12 +0,0 @@
mod dbus;
mod graphics;
mod localize;
mod window;
use window::*;
pub fn main() -> cosmic::iced::Result {
localize::localize();
cosmic::applet::run::<Window>(true, ())
}

View file

@ -1,376 +0,0 @@
use crate::dbus::{self, PowerDaemonProxy};
use crate::fl;
use crate::graphics::{get_current_graphics, set_graphics, Graphics};
use cosmic::applet::{menu_button, padded_control};
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced_runtime::core::alignment::Horizontal;
use cosmic::iced_runtime::core::Alignment;
use cosmic::iced_style::application;
use cosmic::widget::{horizontal_space, icon, Container, Icon};
use cosmic::{applet::cosmic_panel_config::PanelAnchor, Command};
use cosmic::{
iced::widget::{column, row, text},
iced::{self, Length},
iced_runtime::core::window,
theme::Theme,
widget::{button, divider},
Element,
};
use zbus::Connection;
const ID: &str = "com.system76.CosmicAppletGraphics";
#[derive(Clone, Copy)]
enum GraphicsMode {
Applied(Graphics),
Selected { prev: Graphics, new: Graphics },
Current(Graphics),
}
impl GraphicsMode {
fn inner(&self) -> Graphics {
match self {
Self::Selected { new, .. } => *new,
Self::Current(g) => *g,
Self::Applied(g) => *g,
}
}
}
#[derive(Default)]
pub struct Window {
core: cosmic::app::Core,
popup: Option<window::Id>,
graphics_mode: Option<GraphicsMode>,
dbus: Option<(Connection, PowerDaemonProxy<'static>)>,
switchable: bool,
}
#[allow(dead_code)]
#[derive(Clone, Debug)]
pub enum Message {
CurrentGraphics(Option<Graphics>),
AppliedGraphics(Option<Graphics>),
DBusInit(Option<(Connection, PowerDaemonProxy<'static>)>, bool),
SelectGraphicsMode(Graphics),
TogglePopup,
PopupClosed(window::Id),
}
impl cosmic::Application for Window {
type Executor = cosmic::SingleThreadExecutor;
type Flags = ();
type Message = Message;
const APP_ID: &'static str = ID;
fn init(
core: cosmic::app::Core,
_flags: Self::Flags,
) -> (Self, iced::Command<cosmic::app::Message<Self::Message>>) {
let window = Self {
core,
..Default::default()
};
(
window,
iced::Command::perform(
async {
let dbus = dbus::init().await;
let switchable = if let Some((_, proxy)) = dbus.as_ref() {
proxy.get_switchable().await.ok().unwrap_or(false)
} else {
false
};
(dbus, switchable)
},
|(dbus, switchable)| cosmic::app::message::app(Message::DBusInit(dbus, switchable)),
),
)
}
fn core(&self) -> &cosmic::app::Core {
&self.core
}
fn core_mut(&mut self) -> &mut cosmic::app::Core {
&mut self.core
}
fn update(
&mut self,
message: Self::Message,
) -> iced::Command<cosmic::app::Message<Self::Message>> {
match message {
Message::SelectGraphicsMode(new) => {
if let Some((_, proxy)) = self.dbus.as_ref() {
let prev = self
.graphics_mode
.map(|m| m.inner())
.unwrap_or_else(|| Graphics::Integrated);
self.graphics_mode = Some(GraphicsMode::Selected { prev, new });
return iced::Command::perform(
set_graphics(proxy.clone(), new),
move |success| {
cosmic::app::message::app(Message::AppliedGraphics(
success.ok().map(|_| new),
))
},
);
}
}
Message::TogglePopup => {
if let Some(p) = self.popup.take() {
return destroy_popup(p);
} else {
let new_id = window::Id::unique();
self.popup.replace(new_id);
let mut commands = Vec::new();
if let Some((_, proxy)) = self.dbus.as_ref() {
commands.push(iced::Command::perform(
get_current_graphics(proxy.clone()),
|cur_graphics| Message::CurrentGraphics(cur_graphics.ok()),
));
}
let popup_settings = self.core.applet.get_popup_settings(
window::Id::MAIN,
new_id,
None,
None,
None,
);
commands.push(get_popup(popup_settings));
return iced::Command::batch(commands).map(cosmic::app::message::app);
}
}
Message::DBusInit(dbus, switchable) => {
self.switchable = switchable;
if !switchable {
std::process::exit(0);
}
if dbus.is_none() {
eprintln!("Could not connect to com.system76.PowerDaemon. Exiting.");
std::process::exit(0);
}
self.dbus = dbus;
return iced::Command::perform(
get_current_graphics(self.dbus.as_ref().unwrap().1.clone()),
|cur_graphics| {
Message::CurrentGraphics(match cur_graphics {
Ok(g) => Some(g),
Err(err) => {
eprintln!("{err:?}");
None
}
})
},
)
.map(cosmic::app::message::app);
}
Message::CurrentGraphics(g) => {
if let Some(g) = g {
self.graphics_mode = Some(match self.graphics_mode.take() {
Some(GraphicsMode::Current(_)) | None => GraphicsMode::Current(g),
Some(g) => g,
});
}
}
Message::PopupClosed(id) => {
if self.popup.as_ref() == Some(&id) {
self.popup = None;
}
}
Message::AppliedGraphics(g) => {
if let Some(g) = g {
self.graphics_mode = Some(GraphicsMode::Applied(g));
} else {
// Reset graphics
match self.graphics_mode {
Some(GraphicsMode::Selected { prev, new }) => {
// TODO send notification with error?
self.graphics_mode = Some(GraphicsMode::Applied(prev));
// Reset to prev after failing
// https://github.com/pop-os/system76-power/issues/387
if let Some((_, proxy)) = self.dbus.as_ref() {
return iced::Command::perform(
set_graphics(proxy.clone(), prev),
move |success| {
Message::AppliedGraphics(success.ok().map(|_| new))
},
)
.map(cosmic::app::message::app);
}
}
_ => {
return iced::Command::perform(
get_current_graphics(self.dbus.as_ref().unwrap().1.clone()),
|cur_graphics| {
Message::CurrentGraphics(match cur_graphics {
Ok(g) => Some(g),
Err(err) => {
tracing::error!("{:?}", err);
None
}
})
},
)
.map(cosmic::app::message::app)
}
};
}
}
}
Command::none()
}
fn view(&self) -> Element<Message> {
if !self.switchable {
return horizontal_space(1.0).into();
}
match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => self
.core
.applet
.icon_button(ID)
.on_press(Message::TogglePopup)
.into(),
PanelAnchor::Top | PanelAnchor::Bottom => button(
row![
Icon::from(
icon::from_name(ID)
.size(self.core.applet.suggested_size().0)
.symbolic(true)
)
.style(cosmic::theme::Svg::Custom(std::rc::Rc::new(
|theme| {
cosmic::iced_style::svg::Appearance {
color: Some(theme.cosmic().background.on.into()),
}
}
))),
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(),
})
.size(14)
]
.spacing(8)
.padding([0, self.core.applet.suggested_size().0 / 2])
.align_items(Alignment::Center),
)
.on_press(Message::TogglePopup)
.padding(8)
.width(Length::Shrink)
.height(Length::Shrink)
.style(cosmic::theme::Button::AppletIcon)
.into(),
}
}
fn view_window(&self, _id: window::Id) -> Element<Message> {
let content_list = vec![
menu_button(
row![
column![
text(format!("{} {}", fl!("integrated"), fl!("graphics"))).size(14),
text(fl!("integrated-desc")).size(12)
]
.width(Length::Fill),
button_icon(self.graphics_mode, Graphics::Integrated)
]
.align_items(Alignment::Center),
)
.on_press(Message::SelectGraphicsMode(Graphics::Integrated))
.into(),
menu_button(
row![
column![text(format!("{} {}", fl!("nvidia"), fl!("graphics"))).size(14)]
.width(Length::Fill),
button_icon(self.graphics_mode, Graphics::Nvidia)
]
.align_items(Alignment::Center),
)
.on_press(Message::SelectGraphicsMode(Graphics::Nvidia))
.into(),
menu_button(
row![
column![
text(format!("{} {}", fl!("hybrid"), fl!("graphics"))).size(14),
text(fl!("hybrid-desc")).size(12)
]
.width(Length::Fill),
button_icon(self.graphics_mode, Graphics::Hybrid)
]
.align_items(Alignment::Center),
)
.on_press(Message::SelectGraphicsMode(Graphics::Hybrid))
.into(),
menu_button(
row![
column![
text(format!("{} {}", fl!("compute"), fl!("graphics"))).size(14),
text(fl!("compute-desc")).size(12)
]
.width(Length::Fill),
button_icon(self.graphics_mode, Graphics::Compute)
]
.align_items(Alignment::Center),
)
.on_press(Message::SelectGraphicsMode(Graphics::Compute))
.into(),
];
self.core
.applet
.popup_container(
column(vec![
padded_control(
text(fl!("graphics-mode"))
.width(Length::Fill)
.horizontal_alignment(Horizontal::Left)
.size(14),
)
.into(),
padded_control(divider::horizontal::default()).into(),
column(content_list).into(),
])
.padding([16, 0, 8, 0]),
)
.into()
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::applet::style())
}
fn on_close_requested(&self, id: window::Id) -> Option<Message> {
Some(Message::PopupClosed(id))
}
}
fn button_icon<'a>(
cur_mode: Option<GraphicsMode>,
button_mode: Graphics,
) -> Container<'a, Message, cosmic::Theme, cosmic::Renderer> {
match cur_mode {
Some(GraphicsMode::Selected { prev: _, new }) if new == button_mode => {
cosmic::widget::container(
icon::from_name("process-working-symbolic")
.size(12)
.symbolic(true)
.prefer_svg(true),
)
}
Some(GraphicsMode::Applied(g) | GraphicsMode::Current(g)) if g == button_mode => {
cosmic::widget::container(
icon::from_name("emblem-ok-symbolic")
.size(12)
.symbolic(true)
.prefer_svg(true),
)
}
_ => cosmic::widget::container(horizontal_space(1.0)),
}
}

View file

@ -39,7 +39,6 @@ _install_app_list: (_install 'com.system76.CosmicAppList' 'cosmic-app-list')
_install_audio: (_install 'com.system76.CosmicAppletAudio' 'cosmic-applet-audio')
_install_battery: (_install 'com.system76.CosmicAppletBattery' 'cosmic-applet-battery')
_install_bluetooth: (_install 'com.system76.CosmicAppletBluetooth' 'cosmic-applet-bluetooth')
_install_graphics: (_install 'com.system76.CosmicAppletGraphics' 'cosmic-applet-graphics')
_install_network: (_install 'com.system76.CosmicAppletNetwork' 'cosmic-applet-network')
_install_notifications: (_install 'com.system76.CosmicAppletNotifications' 'cosmic-applet-notifications')
_install_power: (_install 'com.system76.CosmicAppletPower' 'cosmic-applet-power')
@ -55,7 +54,7 @@ _install_app_button: (_install_button 'com.system76.CosmicPanelAppButton' 'cosmi
_install_workspaces_button: (_install_button 'com.system76.CosmicPanelWorkspacesButton' 'cosmic-panel-workspaces-button')
# Installs files into the system
install: _install_app_list _install_audio _install_battery _install_bluetooth _install_graphics _install_network _install_notifications _install_power _install_workspace _install_time _install_tiling _install_panel_button _install_app_button _install_workspaces_button _install_status_area
install: _install_app_list _install_audio _install_battery _install_bluetooth _install_network _install_notifications _install_power _install_workspace _install_time _install_tiling _install_panel_button _install_app_button _install_workspaces_button _install_status_area
# Extracts vendored dependencies if vendor=1
_extract_vendor: