cosmic-applets/applets/cosmic-applet-network/src/main.rs

48 lines
1.2 KiB
Rust
Raw Normal View History

2022-02-01 16:46:25 -05:00
// SPDX-License-Identifier: LGPL-3.0-or-later
#[macro_use]
extern crate relm4_macros;
pub mod task;
pub mod ui;
pub mod widgets;
2022-02-01 16:46:25 -05:00
use gtk4::{gio::ApplicationFlags, prelude::*, Orientation};
use once_cell::sync::Lazy;
use tokio::runtime::Runtime;
static RT: Lazy<Runtime> = Lazy::new(|| Runtime::new().expect("failed to build tokio runtime"));
2022-02-01 14:10:15 -05:00
2022-02-01 13:24:00 -05:00
fn main() {
2022-02-01 14:10:15 -05:00
let application = gtk4::Application::new(
Some("com.system76.cosmic.applets.network"),
ApplicationFlags::default(),
);
application.connect_activate(build_ui);
application.run();
}
fn build_ui(application: &gtk4::Application) {
let window = gtk4::ApplicationWindow::builder()
.application(application)
.title("COSMIC Network Applet")
.default_width(400)
2022-02-01 16:46:25 -05:00
.default_height(300)
2022-02-01 14:10:15 -05:00
.build();
2022-02-01 16:46:25 -05:00
view! {
main_box = gtk4::Box {
set_orientation: Orientation::Vertical,
set_spacing: 20,
set_margin_top: 20,
set_margin_bottom: 20,
set_margin_start: 24,
set_margin_end: 24
}
}
ui::toggles::add_toggles(&main_box);
window.set_child(Some(&main_box));
window.show();
2022-02-01 13:24:00 -05:00
}