51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#[macro_use]
|
|
extern crate relm4_macros;
|
|
|
|
pub mod session_manager;
|
|
pub mod ui;
|
|
|
|
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();
|
|
|
|
let session_section = ui::session::build();
|
|
let system_section = ui::system::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,
|
|
append: first_separator = &Separator {},
|
|
append: &session_section,
|
|
append: second_separator = &Separator {},
|
|
append: &system_section
|
|
}
|
|
}
|
|
window.set_child(Some(&main_box));
|
|
|
|
window.show();
|
|
}
|