fractal/utils/
expression.rsuse gtk::{glib, glib::closure};
use secular::normalized_lower_lay_string;
pub fn and(
a_expr: impl AsRef<gtk::Expression>,
b_expr: impl AsRef<gtk::Expression>,
) -> gtk::ClosureExpression {
gtk::ClosureExpression::new::<bool>(
&[a_expr.as_ref(), b_expr.as_ref()],
closure!(|_: Option<glib::Object>, a: bool, b: bool| { a && b }),
)
}
pub fn or(
a_expr: impl AsRef<gtk::Expression>,
b_expr: impl AsRef<gtk::Expression>,
) -> gtk::ClosureExpression {
gtk::ClosureExpression::new::<bool>(
&[a_expr.as_ref(), b_expr.as_ref()],
closure!(|_: Option<glib::Object>, a: bool, b: bool| { a || b }),
)
}
pub fn not<E: AsRef<gtk::Expression>>(a_expr: E) -> gtk::ClosureExpression {
gtk::ClosureExpression::new::<bool>(
&[a_expr],
closure!(|_: Option<glib::Object>, a: bool| { !a }),
)
}
pub fn normalize_string<E: AsRef<gtk::Expression>>(expr: E) -> gtk::ClosureExpression {
gtk::ClosureExpression::new::<String>(
&[expr],
closure!(|_: Option<glib::Object>, s: &str| { normalized_lower_lay_string(s) }),
)
}