1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::ExpressionWatch;
use glib::object::IsA;
use glib::translate::*;
use glib::StaticType;
use std::boxed::Box as Box_;
use std::fmt;

glib::wrapper! {
    #[doc(alias = "GtkExpression")]
    pub struct Expression(Shared<ffi::GtkExpression>);

    match fn {
        ref => |ptr| ffi::gtk_expression_ref(ptr),
        unref => |ptr| ffi::gtk_expression_unref(ptr),
    }
}

impl glib::StaticType for Expression {
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::gtk_expression_get_type()) }
    }
}

impl Expression {
    pub const NONE: Option<&'static Expression> = None;

    #[doc(alias = "gtk_expression_bind")]
    pub fn bind(
        &self,
        target: &impl IsA<glib::Object>,
        property: &str,
        this_: Option<&impl IsA<glib::Object>>,
    ) -> ExpressionWatch {
        unsafe {
            from_glib_none(ffi::gtk_expression_bind(
                self.as_ref().to_glib_full(),
                target.as_ref().to_glib_none().0,
                property.to_glib_none().0,
                this_.map(|p| p.as_ref()).to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_expression_get_value_type")]
    #[doc(alias = "get_value_type")]
    pub fn value_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(ffi::gtk_expression_get_value_type(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_expression_is_static")]
    pub fn is_static(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_expression_is_static(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_expression_watch")]
    pub fn watch<P: Fn() + 'static>(
        &self,
        this_: Option<&impl IsA<glib::Object>>,
        notify: P,
    ) -> ExpressionWatch {
        let notify_data: Box_<P> = Box_::new(notify);
        unsafe extern "C" fn notify_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
            let callback: &P = &*(user_data as *mut _);
            (*callback)();
        }
        let notify = Some(notify_func::<P> as _);
        unsafe extern "C" fn user_destroy_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
            let _callback: Box_<P> = Box_::from_raw(data as *mut _);
        }
        let destroy_call4 = Some(user_destroy_func::<P> as _);
        let super_callback0: Box_<P> = notify_data;
        unsafe {
            from_glib_none(ffi::gtk_expression_watch(
                self.as_ref().to_glib_none().0,
                this_.map(|p| p.as_ref()).to_glib_none().0,
                notify,
                Box_::into_raw(super_callback0) as *mut _,
                destroy_call4,
            ))
        }
    }
}

impl fmt::Display for Expression {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Expression")
    }
}