callbacks: remove unused global functions
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -23,33 +23,19 @@ struct Environment {
|
|||||||
rust_log: String,
|
rust_log: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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 `PolicyCheckState`).
|
||||||
pub trait GlobalState {
|
pub trait GlobalState {
|
||||||
/// Navigates to the given entity.
|
// /// Navigates to the given entity.
|
||||||
fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
|
// fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
|
||||||
if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
|
// if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
|
||||||
let mut old_focused_element = ctx.get_widget(old_focused_element);
|
// let mut old_focused_element = ctx.get_widget(old_focused_element);
|
||||||
old_focused_element.set("focused", false);
|
// old_focused_element.set("focused", false);
|
||||||
//old_focused_element.update_theme_by_state(false);
|
// //old_focused_element.update_theme_by_state(false);
|
||||||
}
|
// }
|
||||||
ctx.window().get_mut::<Global>("global").focused_widget = None;
|
// ctx.window().get_mut::<Global>("global").focused_widget = None;
|
||||||
ctx.widget().set("visibility", Visibility::Collapsed);
|
// ctx.widget().set("visibility", Visibility::Collapsed);
|
||||||
ctx.get_widget(to).set("visibility", Visibility::Visible);
|
// ctx.get_widget(to).set("visibility", Visibility::Visible);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// Get the text of a widget.
|
|
||||||
fn get_text(&self, ctx: &mut Context<'_>, entity: Entity) -> Option<String> {
|
|
||||||
let mut widget = ctx.get_widget(entity);
|
|
||||||
|
|
||||||
let entry = widget.get_mut::<String>("text");
|
|
||||||
if entry.is_empty() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
let copy = entry.to_string();
|
|
||||||
entry.clear();
|
|
||||||
Some(copy)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Save the our data structure and convert it to `ron` file format.
|
/// 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.
|
/// The cargo package identifier (here: 'nwx.advotracker') is taken to create the app directory.
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ pub struct PolicyCheckState {
|
|||||||
duration: Duration,
|
duration: Duration,
|
||||||
label_result: Entity,
|
label_result: Entity,
|
||||||
lang: String,
|
lang: String,
|
||||||
last_focused: Option<Entity>,
|
//last_focused: Option<Entity>,
|
||||||
button_menu: Entity,
|
button_menu: Entity,
|
||||||
menu: Entity,
|
menu: Entity,
|
||||||
policy_data_count: u64,
|
policy_data_count: u64,
|
||||||
@@ -144,10 +144,10 @@ impl PolicyCheckState {
|
|||||||
match envy::from_env::<Environment>() {
|
match envy::from_env::<Environment>() {
|
||||||
Ok(environment) => {
|
Ok(environment) => {
|
||||||
if environment.test_lang != lang { lang = environment.test_lang; }
|
if environment.test_lang != lang { lang = environment.test_lang; }
|
||||||
trace!(target: "advotracker", lang = ?lang);
|
|
||||||
},
|
},
|
||||||
Err(e) => { info!(target: "advotracker", "{}", e) }
|
Err(e) => { info!(target: "advotracker", "{}", e) }
|
||||||
}
|
}
|
||||||
|
trace!(target: "advotracker", lang = ?lang);
|
||||||
lang
|
lang
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,15 +472,15 @@ impl State for PolicyCheckState {
|
|||||||
|
|
||||||
/// Update the widget state.
|
/// Update the widget state.
|
||||||
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
|
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
// clear focus on focus moved
|
// // clear focus on focus moved
|
||||||
if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
|
// if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
|
||||||
if let Some(last_focused) = self.last_focused {
|
// if let Some(last_focused) = self.last_focused {
|
||||||
ctx.get_widget(last_focused).set("focused", false);
|
// ctx.get_widget(last_focused).set("focused", false);
|
||||||
// widget is unvisible, but takes space to be considered
|
// // widget is unvisible, but takes space to be considered
|
||||||
ctx.get_widget(last_focused)
|
// ctx.get_widget(last_focused)
|
||||||
.set("visibility", Visibility::Collapsed);
|
// .set("visibility", Visibility::Collapsed);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
if let Some(action) = self.action {
|
if let Some(action) = self.action {
|
||||||
match action {
|
match action {
|
||||||
|
|||||||
Reference in New Issue
Block a user