diff --git a/TODO.md b/TODO.md index e49989d..9398c2b 100644 --- a/TODO.md +++ b/TODO.md @@ -28,9 +28,9 @@ - [ ] create a crate for graphview/node/port - [x] Remove a port from a node if possible -- [ ] Implement graphview unit test +- [x] Implement graphview unit test - [x] add a css class for pad (presence always or sometimes) -- [ ] Add property to port to store some specific value(Caps) +- [x] Add property to port to store some specific value(Caps) ### GStreamer: @@ -46,7 +46,7 @@ - [ ] Create a window for the video output - [ ] Add multiple graphviews with tabs. - [x] Property window in the main window -- [ ] Connect the GPS status to GST status +- [x] Connect the GPS status to GST status - [ ] Implement graph dot render/load - [ ] Implement a command line parser to graph - [x] Render the parse launch line in a message box @@ -63,6 +63,7 @@ - [ ] Display tags/meta/message detected - [ ] Seek to position - [ ] Use one listbox with name, favorites and rank (sort list) +- [x] See the link creation with a dashed line ### CI/Infra diff --git a/src/app.rs b/src/app.rs index 60c7e23..357fc12 100644 --- a/src/app.rs +++ b/src/app.rs @@ -30,6 +30,8 @@ use log::error; use once_cell::unsync::OnceCell; use std::cell::RefCell; use std::collections::HashMap; +use std::fs::File; +use std::io::{Read, Write}; use std::ops; use std::rc::{Rc, Weak}; @@ -778,20 +780,25 @@ impl GPSApp { } fn clear_graph(&self) { - let graph_view = self.graphview.borrow_mut(); - graph_view.remove_all_nodes(); + let graph_view = self.graphview.borrow(); + graph_view.clear(); } fn save_graph(&self, filename: &str) -> anyhow::Result<()> { let graph_view = self.graphview.borrow(); - graph_view.render_xml(filename)?; + let mut file = File::create(filename)?; + let buffer = graph_view.render_xml()?; + file.write_all(&buffer)?; + Ok(()) } fn load_graph(&self, filename: &str) -> anyhow::Result<()> { - self.clear_graph(); let graph_view = self.graphview.borrow(); - graph_view.load_xml(filename)?; + let mut file = File::open(filename)?; + let mut buffer = Vec::new(); + file.read_to_end(&mut buffer).expect("buffer overflow"); + graph_view.load_from_xml(buffer)?; Ok(()) } }