removes unneeded borrows (#212)
This commit is contained in:
parent
31730bea32
commit
9e00f8f154
10 changed files with 15 additions and 15 deletions
|
|
@ -204,7 +204,7 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close_window(&mut self, window_name: &WindowName) -> Result<()> {
|
fn close_window(&mut self, window_name: &WindowName) -> Result<()> {
|
||||||
for unused_var in self.variables_only_used_in(&window_name) {
|
for unused_var in self.variables_only_used_in(window_name) {
|
||||||
log::info!("stopping for {}", &unused_var);
|
log::info!("stopping for {}", &unused_var);
|
||||||
self.script_var_handler.stop_for_variable(unused_var.clone());
|
self.script_var_handler.stop_for_variable(unused_var.clone());
|
||||||
}
|
}
|
||||||
|
|
@ -246,7 +246,7 @@ impl App {
|
||||||
// initialize script var handlers for variables that where not used before opening this window.
|
// initialize script var handlers for variables that where not used before opening this window.
|
||||||
// TODO somehow make this less shit
|
// TODO somehow make this less shit
|
||||||
for newly_used_var in
|
for newly_used_var in
|
||||||
self.variables_only_used_in(&window_name).filter_map(|var| self.eww_config.get_script_var(&var).ok())
|
self.variables_only_used_in(window_name).filter_map(|var| self.eww_config.get_script_var(var).ok())
|
||||||
{
|
{
|
||||||
self.script_var_handler.add(newly_used_var.clone());
|
self.script_var_handler.add(newly_used_var.clone());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,14 @@ lazy_static::lazy_static! {
|
||||||
|
|
||||||
/// Notify all listening tasks of the termination of the eww application process.
|
/// Notify all listening tasks of the termination of the eww application process.
|
||||||
pub fn send_exit() -> Result<()> {
|
pub fn send_exit() -> Result<()> {
|
||||||
(&*APPLICATION_EXIT_SENDER).send(()).context("Failed to send exit lifecycle event")?;
|
(APPLICATION_EXIT_SENDER).send(()).context("Failed to send exit lifecycle event")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Yields Ok(()) on application termination. Await on this in all long-running tasks
|
/// Yields Ok(()) on application termination. Await on this in all long-running tasks
|
||||||
/// and perform any cleanup if necessary.
|
/// and perform any cleanup if necessary.
|
||||||
pub async fn recv_exit() -> Result<()> {
|
pub async fn recv_exit() -> Result<()> {
|
||||||
(&*APPLICATION_EXIT_SENDER).subscribe().recv().await.context("Failed to receive lifecycle event")
|
(APPLICATION_EXIT_SENDER).subscribe().recv().await.context("Failed to receive lifecycle event")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Select in a loop, breaking once a application termination event (see `crate::application_lifecycle`) is received.
|
/// Select in a loop, breaking once a application termination event (see `crate::application_lifecycle`) is received.
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ impl WidgetUse {
|
||||||
.map(|attr| {
|
.map(|attr| {
|
||||||
(
|
(
|
||||||
AttrName(attr.name().to_owned()),
|
AttrName(attr.name().to_owned()),
|
||||||
AttrVal::parse_string(&xml_ext::resolve_escaped_symbols(&attr.value())),
|
AttrVal::parse_string(&xml_ext::resolve_escaped_symbols(attr.value())),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<HashMap<_, _>>(),
|
.collect::<HashMap<_, _>>(),
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ impl ScriptVar {
|
||||||
ScriptVar::Poll(x) => match &x.command {
|
ScriptVar::Poll(x) => match &x.command {
|
||||||
VarSource::Function(f) => f().with_context(|| format!("Failed to compute initial value for {}", &self.name())),
|
VarSource::Function(f) => f().with_context(|| format!("Failed to compute initial value for {}", &self.name())),
|
||||||
VarSource::Shell(f) => {
|
VarSource::Shell(f) => {
|
||||||
run_command(&f).with_context(|| format!("Failed to compute initial value for {}", &self.name()))
|
run_command(f).with_context(|| format!("Failed to compute initial value for {}", &self.name()))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ScriptVar::Tail(_) => Ok(PrimVal::from_string(String::new())),
|
ScriptVar::Tail(_) => Ok(PrimVal::from_string(String::new())),
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ pub fn join_path_pretty<P: AsRef<std::path::Path>, P2: AsRef<std::path::Path>>(a
|
||||||
if b.is_absolute() {
|
if b.is_absolute() {
|
||||||
b.to_path_buf()
|
b.to_path_buf()
|
||||||
} else {
|
} else {
|
||||||
a.parent().unwrap().join(b.strip_prefix("./").unwrap_or(&b))
|
a.parent().unwrap().join(b.strip_prefix("./").unwrap_or(b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,14 +160,14 @@ impl AttrValElement {
|
||||||
|
|
||||||
pub fn as_expr(&self) -> Option<&AttrValExpr> {
|
pub fn as_expr(&self) -> Option<&AttrValExpr> {
|
||||||
match self {
|
match self {
|
||||||
AttrValElement::Expr(x) => Some(&x),
|
AttrValElement::Expr(x) => Some(x),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_primitive(&self) -> Option<&PrimVal> {
|
pub fn as_primitive(&self) -> Option<&PrimVal> {
|
||||||
match self {
|
match self {
|
||||||
AttrValElement::Primitive(x) => Some(&x),
|
AttrValElement::Primitive(x) => Some(x),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ impl AttrValExpr {
|
||||||
|
|
||||||
pub fn eval(self, values: &HashMap<VarName, PrimVal>) -> Result<PrimVal> {
|
pub fn eval(self, values: &HashMap<VarName, PrimVal>) -> Result<PrimVal> {
|
||||||
match self {
|
match self {
|
||||||
AttrValExpr::Literal(x) => x.resolve_fully(&values),
|
AttrValExpr::Literal(x) => x.resolve_fully(values),
|
||||||
AttrValExpr::VarRef(ref name) => values
|
AttrValExpr::VarRef(ref name) => values
|
||||||
.get(name)
|
.get(name)
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ fn build_builtin_gtk_widget(
|
||||||
// run resolve functions for superclasses such as range, orientable, and widget
|
// run resolve functions for superclasses such as range, orientable, and widget
|
||||||
|
|
||||||
if let Some(gtk_widget) = gtk_widget.dynamic_cast_ref::<gtk::Container>() {
|
if let Some(gtk_widget) = gtk_widget.dynamic_cast_ref::<gtk::Container>() {
|
||||||
resolve_container_attrs(&mut bargs, >k_widget);
|
resolve_container_attrs(&mut bargs, gtk_widget);
|
||||||
for child in &widget.children {
|
for child in &widget.children {
|
||||||
let child_widget = child.render(bargs.eww_state, window_name, widget_definitions).with_context(|| {
|
let child_widget = child.render(bargs.eww_state, window_name, widget_definitions).with_context(|| {
|
||||||
format!(
|
format!(
|
||||||
|
|
@ -98,10 +98,10 @@ fn build_builtin_gtk_widget(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(w) = gtk_widget.dynamic_cast_ref() {
|
if let Some(w) = gtk_widget.dynamic_cast_ref() {
|
||||||
resolve_range_attrs(&mut bargs, &w)
|
resolve_range_attrs(&mut bargs, w)
|
||||||
}
|
}
|
||||||
if let Some(w) = gtk_widget.dynamic_cast_ref() {
|
if let Some(w) = gtk_widget.dynamic_cast_ref() {
|
||||||
resolve_orientable_attrs(&mut bargs, &w)
|
resolve_orientable_attrs(&mut bargs, w)
|
||||||
};
|
};
|
||||||
resolve_widget_attrs(&mut bargs, >k_widget);
|
resolve_widget_attrs(&mut bargs, >k_widget);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -608,7 +608,7 @@ fn connect_first_map<W: IsA<gtk::Widget>, F: Fn(&W) + 'static>(widget: &W, func:
|
||||||
let is_first_map = std::rc::Rc::new(std::cell::RefCell::new(true));
|
let is_first_map = std::rc::Rc::new(std::cell::RefCell::new(true));
|
||||||
widget.connect_map(move |w| {
|
widget.connect_map(move |w| {
|
||||||
if is_first_map.replace(false) {
|
if is_first_map.replace(false) {
|
||||||
func(&w);
|
func(w);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ impl WidgetNode for Generic {
|
||||||
window_name: &WindowName,
|
window_name: &WindowName,
|
||||||
widget_definitions: &HashMap<String, WidgetDefinition>,
|
widget_definitions: &HashMap<String, WidgetDefinition>,
|
||||||
) -> Result<gtk::Widget> {
|
) -> Result<gtk::Widget> {
|
||||||
crate::widgets::build_builtin_gtk_widget(eww_state, window_name, widget_definitions, &self)?
|
crate::widgets::build_builtin_gtk_widget(eww_state, window_name, widget_definitions, self)?
|
||||||
.with_context(|| format!("Unknown widget '{}'", self.get_name()))
|
.with_context(|| format!("Unknown widget '{}'", self.get_name()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue