[go: up one dir, main page]

gtk4/auto/
expression.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, ExpressionWatch};
6use glib::{prelude::*, translate::*};
7use std::boxed::Box as Box_;
8
9glib::wrapper! {
10    #[doc(alias = "GtkExpression")]
11    pub struct Expression(Shared<ffi::GtkExpression>);
12
13    match fn {
14        ref => |ptr| ffi::gtk_expression_ref(ptr),
15        unref => |ptr| ffi::gtk_expression_unref(ptr),
16    }
17}
18
19impl StaticType for Expression {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gtk_expression_get_type()) }
22    }
23}
24
25impl Expression {
26    pub const NONE: Option<&'static Expression> = None;
27
28    #[doc(alias = "gtk_expression_bind")]
29    pub fn bind(
30        &self,
31        target: &impl IsA<glib::Object>,
32        property: &str,
33        this_: Option<&impl IsA<glib::Object>>,
34    ) -> ExpressionWatch {
35        unsafe {
36            from_glib_none(ffi::gtk_expression_bind(
37                self.as_ref().to_glib_full(),
38                target.as_ref().to_glib_none().0,
39                property.to_glib_none().0,
40                this_.map(|p| p.as_ref()).to_glib_none().0,
41            ))
42        }
43    }
44
45    #[doc(alias = "gtk_expression_get_value_type")]
46    #[doc(alias = "get_value_type")]
47    pub fn value_type(&self) -> glib::types::Type {
48        unsafe {
49            from_glib(ffi::gtk_expression_get_value_type(
50                self.as_ref().to_glib_none().0,
51            ))
52        }
53    }
54
55    #[doc(alias = "gtk_expression_is_static")]
56    pub fn is_static(&self) -> bool {
57        unsafe {
58            from_glib(ffi::gtk_expression_is_static(
59                self.as_ref().to_glib_none().0,
60            ))
61        }
62    }
63
64    #[doc(alias = "gtk_expression_watch")]
65    pub fn watch<P: Fn() + 'static>(
66        &self,
67        this_: Option<&impl IsA<glib::Object>>,
68        notify: P,
69    ) -> ExpressionWatch {
70        let notify_data: Box_<P> = Box_::new(notify);
71        unsafe extern "C" fn notify_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
72            let callback = &*(user_data as *mut P);
73            (*callback)()
74        }
75        let notify = Some(notify_func::<P> as _);
76        unsafe extern "C" fn user_destroy_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
77            let _callback = Box_::from_raw(data as *mut P);
78        }
79        let destroy_call4 = Some(user_destroy_func::<P> as _);
80        let super_callback0: Box_<P> = notify_data;
81        unsafe {
82            from_glib_none(ffi::gtk_expression_watch(
83                self.as_ref().to_glib_none().0,
84                this_.map(|p| p.as_ref()).to_glib_none().0,
85                notify,
86                Box_::into_raw(super_callback0) as *mut _,
87                destroy_call4,
88            ))
89        }
90    }
91}