Start on power applet
This commit is contained in:
parent
835774a5a7
commit
fa03b0553b
4 changed files with 81 additions and 1 deletions
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