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