Implement Gtk Network Status (#165)
Implemented - Switch reacts to burrow socket and network changes - meson as build system - Basic diagnostics to ensure burrow is installed properly - Flatpak / Meson Building
This commit is contained in:
parent
baa81eb939
commit
6990f90c2e
31 changed files with 1571 additions and 665 deletions
|
|
@ -1,87 +1,11 @@
|
|||
use adw::prelude::*;
|
||||
use burrow::{DaemonClient, DaemonCommand, DaemonStartOptions};
|
||||
use gtk::Align;
|
||||
use relm4::{
|
||||
component::{AsyncComponent, AsyncComponentParts, AsyncComponentSender},
|
||||
prelude::*,
|
||||
};
|
||||
use anyhow::Result;
|
||||
|
||||
struct App {}
|
||||
pub mod components;
|
||||
mod diag;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Msg {
|
||||
Start,
|
||||
Stop,
|
||||
}
|
||||
|
||||
#[relm4::component(async)]
|
||||
impl AsyncComponent for App {
|
||||
type Init = ();
|
||||
type Input = Msg;
|
||||
type Output = ();
|
||||
type CommandOutput = ();
|
||||
|
||||
view! {
|
||||
adw::Window {
|
||||
set_title: Some("Simple app"),
|
||||
set_default_size: (640, 480),
|
||||
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
set_spacing: 5,
|
||||
set_margin_all: 5,
|
||||
set_valign: Align::Center,
|
||||
|
||||
gtk::Label {
|
||||
set_label: "Burrow GTK Switch",
|
||||
},
|
||||
|
||||
gtk::Switch {
|
||||
set_halign: Align::Center,
|
||||
set_hexpand: false,
|
||||
set_vexpand: false,
|
||||
connect_active_notify => move |switch|
|
||||
sender.input(if switch.is_active() { Msg::Start } else { Msg::Stop })
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn init(
|
||||
_: Self::Init,
|
||||
root: Self::Root,
|
||||
sender: AsyncComponentSender<Self>,
|
||||
) -> AsyncComponentParts<Self> {
|
||||
let model = App {};
|
||||
|
||||
let widgets = view_output!();
|
||||
|
||||
AsyncComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
async fn update(
|
||||
&mut self,
|
||||
msg: Self::Input,
|
||||
_sender: AsyncComponentSender<Self>,
|
||||
_root: &Self::Root,
|
||||
) {
|
||||
match msg {
|
||||
Msg::Start => {
|
||||
let mut client = DaemonClient::new().await.unwrap();
|
||||
client
|
||||
.send_command(DaemonCommand::Start(DaemonStartOptions::default()))
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
Msg::Stop => {
|
||||
let mut client = DaemonClient::new().await.unwrap();
|
||||
client.send_command(DaemonCommand::Stop).await.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Generated using meson
|
||||
mod config;
|
||||
|
||||
fn main() {
|
||||
let app = RelmApp::new("com.hackclub.burrow");
|
||||
app.run_async::<App>(());
|
||||
components::App::run();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue