gtk4/auto/object_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;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// A `GObject` value in a [`Expression`][crate::Expression].
10 #[doc(alias = "GtkObjectExpression")]
11 pub struct ObjectExpression(Shared<ffi::GtkObjectExpression>);
12
13 match fn {
14 ref => |ptr| ffi::gtk_expression_ref(ptr as *mut ffi::GtkExpression),
15 unref => |ptr| ffi::gtk_expression_unref(ptr as *mut ffi::GtkExpression),
16 }
17}
18
19impl StaticType for ObjectExpression {
20 fn static_type() -> glib::Type {
21 unsafe { from_glib(ffi::gtk_object_expression_get_type()) }
22 }
23}
24
25impl ObjectExpression {
26 /// Creates an expression evaluating to the given `object` with a weak reference.
27 ///
28 /// Once the `object` is disposed, it will fail to evaluate.
29 ///
30 /// This expression is meant to break reference cycles.
31 ///
32 /// If you want to keep a reference to `object`, use [`ConstantExpression::new()`][crate::ConstantExpression::new()].
33 /// ## `object`
34 /// object to watch
35 ///
36 /// # Returns
37 ///
38 /// a new [`Expression`][crate::Expression]
39 #[doc(alias = "gtk_object_expression_new")]
40 pub fn new(object: &impl IsA<glib::Object>) -> ObjectExpression {
41 assert_initialized_main_thread!();
42 unsafe {
43 from_glib_full(ffi::gtk_object_expression_new(
44 object.as_ref().to_glib_none().0,
45 ))
46 }
47 }
48
49 /// Gets the object that the expression evaluates to.
50 ///
51 /// # Returns
52 ///
53 /// the object, or `NULL`
54 #[doc(alias = "gtk_object_expression_get_object")]
55 #[doc(alias = "get_object")]
56 pub fn object(&self) -> Option<glib::Object> {
57 unsafe { from_glib_none(ffi::gtk_object_expression_get_object(self.to_glib_none().0)) }
58 }
59}