diff --git a/Cargo.lock b/Cargo.lock index f7178be..1150bf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -891,6 +891,20 @@ dependencies = [ "version-compare", ] +[[package]] +name = "tarangam" +version = "0.1.0" +dependencies = [ + "cairo-rs", + "gio", + "glib", + "gtk", + "libmath", + "png", + "rand 0.8.1", + "serialport", +] + [[package]] name = "thiserror" version = "1.0.20" @@ -929,20 +943,6 @@ dependencies = [ "serde", ] -[[package]] -name = "trangam" -version = "0.1.0" -dependencies = [ - "cairo-rs", - "gio", - "glib", - "gtk", - "libmath", - "png", - "rand 0.8.1", - "serialport", -] - [[package]] name = "unicode-segmentation" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index ce60aa8..2737c7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "trangam" +name = "tarangam" version = "0.1.0" authors = ["PiyushXCoder "] edition = "2018" diff --git a/chitra.png b/chitra.png new file mode 100644 index 0000000..afdae13 Binary files /dev/null and b/chitra.png differ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..76b6f75 --- /dev/null +++ b/icon.svg @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/ui/main_window.glade~ b/main_window.glade~ similarity index 100% rename from ui/main_window.glade~ rename to main_window.glade~ diff --git a/src/lib.rs b/src/lib.rs index 853c4a7..d3a7073 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +/// Feel free to see through codes. Application is not written to be used as a library for other app. :) + mod graph; use gtk::prelude::*; @@ -17,13 +19,13 @@ enum Status { JAGRIT, SAYAN, AVRODTIH, PARIVARTIT } +/// Configuration to read from Serial Port pub struct Config { status: Status, bondrate: u32, port: String } -// impl Config { pub fn new() -> Config { Config { @@ -34,13 +36,15 @@ impl Config { } } +/// For communication between mpsc of graph and serial port enum MessageSerialThread { Msg(String), Status(String) } +// Building and configuring GUI pub fn build_ui(app: >k::Application, config: Arc::>) { - let builder = gtk::Builder::from_file("ui/main_window.glade"); + let builder = gtk::Builder::from_file("ui.glade"); let win = builder.get_object::("win").expect("Resource file missing!"); win.set_application(Some(app)); @@ -63,6 +67,7 @@ pub fn build_ui(app: >k::Application, config: Arc::>) { // exit_menu let exit_menu = builder.get_object::("exit_menu").expect("Resource file missing!"); + let tmp_win = win.clone(); exit_menu.connect_activate(move |_|{ unsafe { @@ -364,6 +369,7 @@ pub fn build_ui(app: >k::Application, config: Arc::>) { }); } +// Controls the thread and read from serial port fn serial_thread_work( config: &Arc>, bufread: &mut Option>>, @@ -414,6 +420,7 @@ fn serial_thread_work( } } +// Receives MessageSerialThread from Serial Port managing thread and add points to draw on graph fn receiver_for_msg(text: String, graph: &Rc>, full_log: >k::CheckButton, log_area: >k::TextView) { for text in text.lines() { if text.len() == 0 { diff --git a/src/main.rs b/src/main.rs index 7476050..9bcee56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,14 +3,14 @@ use std::env::args; use std::sync::{Arc, Mutex}; fn main() { - let app = gtk::Application::new(Some("sng.trangm"), Default::default()) + let app = gtk::Application::new(Some("sng.tarangm"), Default::default()) .expect("Failed to initiate gtk"); - let config = Arc::new(Mutex::new(trangam::Config::new())); + let config = Arc::new(Mutex::new(tarangam::Config::new())); app.connect_activate(move |app| { let config = Arc::clone(&config); - trangam::build_ui(app, config); + tarangam::build_ui(app, config); }); app.run(&args().collect::>()); diff --git a/test.txt b/test.txt deleted file mode 100644 index 1fe5476..0000000 --- a/test.txt +++ /dev/null @@ -1 +0,0 @@ -Bhai ka area hai \ No newline at end of file diff --git a/ui/main_window.glade b/ui.glade similarity index 98% rename from ui/main_window.glade rename to ui.glade index 9655ab8..9e7786a 100644 --- a/ui/main_window.glade +++ b/ui.glade @@ -4,11 +4,13 @@ False + Tarangam + icon.svg dialog Tarangam (तरंगम्) A simple serial plotter. एक सरल सीरीय्ल पलौटर। - image-missing + chitra.png False @@ -51,6 +53,7 @@ False + chitra.png dialog select-folder @@ -88,9 +91,10 @@ False - Trangam + Tarangam 850 600 + chitra.png True diff --git a/ui.glade~ b/ui.glade~ new file mode 100644 index 0000000..9e7786a --- /dev/null +++ b/ui.glade~ @@ -0,0 +1,667 @@ + + + + + + False + Tarangam + icon.svg + dialog + Tarangam (तरंगम्) + A simple serial plotter. +एक सरल सीरीय्ल पलौटर। + chitra.png + + + False + vertical + 2 + + + False + end + + + + + + + + + False + False + 0 + + + + + + + + + + True + False + document-save + + + 5 + 500 + 100 + 0.5 + 10 + + + False + chitra.png + dialog + select-folder + + + False + vertical + 2 + + + False + end + + + + + + + + + False + False + 0 + + + + + + + + + + True + False + go-next + + + False + Tarangam + 850 + 600 + chitra.png + + + True + False + vertical + + + True + False + + + True + False + _File + True + + + True + False + + + Save Log + True + False + document_save + False + + + + + True + False + + + + + gtk-quit + True + False + True + True + + + + + + + + + True + False + _Help + True + + + True + False + + + gtk-about + True + False + True + True + + + + + + + + + False + True + 0 + + + + + 30 + True + False + + + True + False + refresh + True + view-refresh + + + False + True + + + + + True + False + + + True + False + + + + + False + True + + + + + True + False + + + True + False + + 9600 + + + + + + False + True + + + + + True + False + Connect + True + media-playback-start + + + False + True + + + + + True + False + Stop + True + media-playback-stop + + + False + True + + + + + False + True + 1 + + + + + True + True + + + 500 + True + False + vertical + + + True + False + + + True + False + Clear + True + + + False + True + + + + + True + False + + + Patches + True + True + False + True + + + + + False + True + + + + + True + False + + + box + True + True + False + True + True + + + + + False + True + + + + + True + False + + + baarik box + True + True + False + True + + + + + False + True + + + + + True + False + + + False + True + + + + + True + False + + + True + False + 4 + Pankti + + + + + False + True + + + + + True + False + + + True + True + pankti_adjustment + 1 + True + True + + + + + False + True + + + + + False + True + 0 + + + + + 500 + 450 + True + False + True + True + + + False + True + 1 + + + + + True + False + + + True + False + + + nimna + True + True + False + True + + + + + False + True + + + + + True + False + + + True + False + 4 + S tambh 1 + + + + + False + True + + + + + True + False + True + + + True + False + True + 8 + 0 + + + + + False + True + + + + + True + False + + + True + False + 4 + Stambh 2 + + + + + False + True + + + + + True + False + True + + + True + False + True + 8 + 100 + + + + + False + True + + + + + False + True + 2 + + + + + True + True + + + + + True + False + vertical + + + True + False + + + True + False + Clear + True + + + False + True + + + + + True + False + + + Show full log + True + True + False + True + + + + + False + True + + + + + False + True + 0 + + + + + 300 + True + True + True + True + in + + + True + True + True + + + + + False + True + 1 + + + + + True + False + + + True + True + + + True + True + 0 + + + + + Send + True + True + True + send_image + + + False + True + 1 + + + + + False + True + 2 + + + + + False + True + + + + + False + True + 2 + + + + + True + False + 10 + 10 + 6 + 6 + True + False + vertical + 2 + + + False + True + 4 + + + + + +