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
use glib::translate::*;
use glib::value::FromValue;
use glib::Value;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[doc(alias = "GtkExpressionWatch")]
pub struct ExpressionWatch(Shared<ffi::GtkExpressionWatch>);
match fn {
ref => |ptr| ffi::gtk_expression_watch_ref(ptr),
unref => |ptr| ffi::gtk_expression_watch_unref(ptr),
}
}
impl ExpressionWatch {
#[doc(alias = "gtk_expression_watch_evaluate")]
pub fn evaluate(&self) -> Option<Value> {
assert_initialized_main_thread!();
unsafe {
let mut value = Value::uninitialized();
let ret = ffi::gtk_expression_watch_evaluate(
self.to_glib_none().0,
value.to_glib_none_mut().0,
);
if from_glib(ret) {
Some(value)
} else {
None
}
}
}
#[doc(alias = "gtk_expression_evaluate")]
pub fn evaluate_as<V: for<'b> FromValue<'b> + 'static>(&self) -> Option<V> {
self.evaluate().map(|v| {
v.get_owned::<V>()
.expect("Failed to evaluate to this value type")
})
}
#[doc(alias = "gtk_expression_watch_unwatch")]
pub fn unwatch(&self) {
unsafe { ffi::gtk_expression_watch_unwatch(self.to_glib_none().0) }
}
}
#[cfg(any(feature = "v4_2", feature = "dox"))]
impl glib::StaticType for ExpressionWatch {
#[doc(alias = "gtk_expression_watch_get_type")]
fn static_type() -> glib::Type {
unsafe { from_glib(ffi::gtk_expression_watch_get_type()) }
}
}