diff --git a/advotracker/src/callbacks/global_state.rs b/advotracker/src/callbacks/global_state.rs index ffb9733..46cd69c 100644 --- a/advotracker/src/callbacks/global_state.rs +++ b/advotracker/src/callbacks/global_state.rs @@ -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") - // .save( - // PROP_POLICY_LIST, - // ctx.widget().get::(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") + .save( + PROP_ADVOTRACKER, + ctx.widget().get::(PROP_ADVOTRACKER), + ) + .unwrap(); + } }