aboutsummaryrefslogtreecommitdiff
path: root/karlgui/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'karlgui/src/main.rs')
-rw-r--r--karlgui/src/main.rs29
1 files changed, 5 insertions, 24 deletions
diff --git a/karlgui/src/main.rs b/karlgui/src/main.rs
index d683a78..b3a6f62 100644
--- a/karlgui/src/main.rs
+++ b/karlgui/src/main.rs
@@ -1,11 +1,12 @@
pub mod client;
+pub mod globals;
pub mod helper;
pub mod views;
-use crate::client::Client;
+use crate::{client::Client, globals::Globals};
use eframe::CreationContext;
use egui::CentralPanel;
-use karlcommon::{socket_path, ClientboundPacket, ServerboundPacket, Task};
+use karlcommon::{socket_path, ServerboundPacket};
use log::{error, info};
use std::{os::unix::net::UnixStream, process::exit};
use views::{calendar::Calendar, edit::ShowAndEdit};
@@ -19,11 +20,6 @@ fn main() {
)
}
-pub struct Globals {
- client: Client,
- tasks: Vec<Task>,
-}
-
struct App {
g: Globals,
@@ -57,31 +53,16 @@ impl App {
client.send(ServerboundPacket::ListTasks);
App {
current_tab: Tab::ShowAndEdit,
- g: Globals {
- client,
- tasks: vec![],
- },
+ g: Globals::new(client),
show_and_edit: Default::default(),
calendar: Default::default(),
}
}
-
- pub fn update_network(&mut self) {
- for p in self.g.client.receiver.try_iter() {
- match p {
- ClientboundPacket::TaskList(t) => self.g.tasks = t,
- ClientboundPacket::Sync => {
- self.g.client.busy = false;
- }
- _ => {}
- }
- }
- }
}
impl eframe::App for App {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
- self.update_network();
+ self.g.update_network();
CentralPanel::default().show(ctx, |ui| {
ui.add_enabled_ui(!self.g.client.busy, |ui| {
ui.horizontal(|ui| {