Start on power applet
This commit is contained in:
parent
835774a5a7
commit
fa03b0553b
4 changed files with 81 additions and 1 deletions
24
Cargo.lock
generated
24
Cargo.lock
generated
|
|
@ -244,6 +244,19 @@ dependencies = [
|
||||||
"zbus",
|
"zbus",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cosmic-applet-power"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"futures-util",
|
||||||
|
"gtk4",
|
||||||
|
"logind-zbus",
|
||||||
|
"once_cell",
|
||||||
|
"relm4-macros",
|
||||||
|
"tokio",
|
||||||
|
"zbus",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-dbus-networkmanager"
|
name = "cosmic-dbus-networkmanager"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
@ -939,6 +952,17 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "logind-zbus"
|
||||||
|
version = "3.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c03958f20018a20963daf0c16ada4f271ae2da3e0017fb40caa8b0e3dc5b0226"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"zbus",
|
||||||
|
"zvariant",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.4.1"
|
version = "2.4.1"
|
||||||
|
|
|
||||||
|
|
@ -29,4 +29,4 @@ zvariant = "3"
|
||||||
layer-shell = ["gdk4-wayland", "libcosmic/layer-shell"]
|
layer-shell = ["gdk4-wayland", "libcosmic/layer-shell"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["applets/cosmic-applet-graphics", "applets/cosmic-applet-network"]
|
members = ["applets/cosmic-applet-graphics", "applets/cosmic-applet-network", "applets/cosmic-applet-power"]
|
||||||
|
|
|
||||||
14
applets/cosmic-applet-power/Cargo.toml
Normal file
14
applets/cosmic-applet-power/Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
[package]
|
||||||
|
name = "cosmic-applet-power"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
license = "LGPL-3.0-or-later"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
futures-util = "0.3.21"
|
||||||
|
gtk4 = "0.4.6"
|
||||||
|
logind-zbus = "3.0.1"
|
||||||
|
once_cell = "1.9.0"
|
||||||
|
relm4-macros = "0.4.1"
|
||||||
|
tokio = { version = "1.15.0", features = ["full"] }
|
||||||
|
zbus = "2.0.1"
|
||||||
42
applets/cosmic-applet-power/src/main.rs
Normal file
42
applets/cosmic-applet-power/src/main.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate relm4_macros;
|
||||||
|
|
||||||
|
use gtk4::{gio::ApplicationFlags, prelude::*, Orientation, Separator};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
|
static RT: Lazy<Runtime> = Lazy::new(|| Runtime::new().expect("failed to build tokio runtime"));
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let application = gtk4::Application::new(
|
||||||
|
Some("com.system76.cosmic.applets.power"),
|
||||||
|
ApplicationFlags::default(),
|
||||||
|
);
|
||||||
|
application.connect_activate(build_ui);
|
||||||
|
application.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_ui(application: >k4::Application) {
|
||||||
|
let window = gtk4::ApplicationWindow::builder()
|
||||||
|
.application(application)
|
||||||
|
.title("COSMIC Power Applet")
|
||||||
|
.default_width(400)
|
||||||
|
.default_height(300)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
main_box = gtk4::Box {
|
||||||
|
set_orientation: Orientation::Vertical,
|
||||||
|
set_spacing: 10,
|
||||||
|
set_margin_top: 20,
|
||||||
|
set_margin_bottom: 20,
|
||||||
|
set_margin_start: 24,
|
||||||
|
set_margin_end: 24
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.set_child(Some(&main_box));
|
||||||
|
|
||||||
|
window.show();
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue