gtk4/auto/
constant_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 constant value in a [`Expression`][crate::Expression].
10    #[doc(alias = "GtkConstantExpression")]
11    pub struct ConstantExpression(Shared<ffi::GtkConstantExpression>);
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 ConstantExpression {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gtk_constant_expression_get_type()) }
22    }
23}
24
25impl ConstantExpression {
26    /// Creates an expression that always evaluates to the given `value`.
27    /// ## `value`
28    /// a `GValue`
29    ///
30    /// # Returns
31    ///
32    /// a new [`Expression`][crate::Expression]
33    #[doc(alias = "gtk_constant_expression_new_for_value")]
34    #[doc(alias = "new_for_value")]
35    pub fn for_value(value: &glib::Value) -> ConstantExpression {
36        assert_initialized_main_thread!();
37        unsafe {
38            from_glib_full(ffi::gtk_constant_expression_new_for_value(
39                value.to_glib_none().0,
40            ))
41        }
42    }
43
44    /// Gets the value that a constant expression evaluates to.
45    ///
46    /// # Returns
47    ///
48    /// the value
49    #[doc(alias = "gtk_constant_expression_get_value")]
50    #[doc(alias = "get_value")]
51    pub fn value(&self) -> glib::Value {
52        unsafe {
53            from_glib_none(ffi::gtk_constant_expression_get_value(
54                self.to_glib_none().0,
55            ))
56        }
57    }
58}