gtk: add a check on BoolFilter::[new|set_expression]
BoolFilter's expression must be either NULL or evaluate to a boolean
@@ -7,6 +7,11 @@ impl BoolFilter {
#[doc(alias = "gtk_bool_filter_new")]
pub fn new<E: AsRef<Expression>>(expression: Option<&E>) -> BoolFilter {
assert_initialized_main_thread!();
+ if let Some(e) = expression {
+ if !e.as_ref().get_value_type().is_a(glib::Type::BOOL) {
+ panic!("BoolFilter::new must take either None or an expression that evaluates to a boolean.");
+ }
+ }
unsafe {
from_glib_full(ffi::gtk_bool_filter_new(
expression.map(|e| e.as_ref()).to_glib_full(),
@@ -16,6 +21,11 @@ impl BoolFilter {
#[doc(alias = "gtk_bool_filter_set_expression")]
pub fn set_expression<E: AsRef<Expression>>(&self, expression: Option<&E>) {
+ if let Some(e) = expression {
+ if !e.as_ref().get_value_type().is_a(glib::Type::BOOL) {
+ panic!("BoolFilter::set_expression must take either None or an expression that evaluates to a boolean.");
+ }
+ }
unsafe {
ffi::gtk_bool_filter_set_expression(
self.to_glib_none().0,
