callbacks: global_state: save data vector to ron file on disk

* new functionality
* save imported / edited data-structures persitantliy
  on disk to file in 'ron' format

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-07-03 01:05:33 +02:00
parent bf0ee18f55
commit e8c7d78de3

View File

@@ -8,10 +8,10 @@
use orbtk::prelude::*; use orbtk::prelude::*;
//use crate::data::keys; //use crate::data::keys;
// use crate::{ use crate::{
// //data::structures::PolicyList, data::structures::PolicyList,
// data::keys::* data::keys::*
// }; };
/// Provides generic methods to handle states of datatypes (e.g. used in `PolicyList`). /// Provides generic methods to handle states of datatypes (e.g. used in `PolicyList`).
pub trait GlobalState { pub trait GlobalState {
@@ -41,14 +41,19 @@ pub trait GlobalState {
Some(copy) Some(copy)
} }
// Save the data. /// Save the our data structure and convert it to `ron` file format.
// fn save(&self, registry: &mut Registry, ctx: &mut Context) { /// The cargo package identifier (here: 'nwx.advotracker') is taken to create the app directory.
// registry /// in users 'settings directory'. The directory location is OS dependant
// .get::<Settings>("settings") /// (Windows: AppData, Unix: XDG_CONFIG_HOME, MacOS: $HOME/Library/Preferences).
// .save( /// The data is stored in filename PROP_ADVOTRACKER (here: `advotracker.ron`)
// PROP_POLICY_LIST,
// ctx.widget().get::<PolicyList>(PROP_POLICY_LIST), fn save(&self, registry: &mut Registry, ctx: &mut Context<'_>) {
// ) registry
// .unwrap(); .get::<Settings>("settings")
// } .save(
PROP_ADVOTRACKER,
ctx.widget().get::<PolicyList>(PROP_ADVOTRACKER),
)
.unwrap();
}
} }