gtk4/auto/
actionable.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, Accessible, Buildable, ConstraintTarget, Widget};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkActionable")]
15    pub struct Actionable(Interface<ffi::GtkActionable, ffi::GtkActionableInterface>) @requires Widget, Accessible, Buildable, ConstraintTarget;
16
17    match fn {
18        type_ => || ffi::gtk_actionable_get_type(),
19    }
20}
21
22impl Actionable {
23    pub const NONE: Option<&'static Actionable> = None;
24}
25
26mod sealed {
27    pub trait Sealed {}
28    impl<T: super::IsA<super::Actionable>> Sealed for T {}
29}
30
31pub trait ActionableExt: IsA<Actionable> + sealed::Sealed + 'static {
32    #[doc(alias = "gtk_actionable_get_action_name")]
33    #[doc(alias = "get_action_name")]
34    #[doc(alias = "action-name")]
35    fn action_name(&self) -> Option<glib::GString> {
36        unsafe {
37            from_glib_none(ffi::gtk_actionable_get_action_name(
38                self.as_ref().to_glib_none().0,
39            ))
40        }
41    }
42
43    #[doc(alias = "gtk_actionable_get_action_target_value")]
44    #[doc(alias = "get_action_target_value")]
45    #[doc(alias = "action-target")]
46    fn action_target_value(&self) -> Option<glib::Variant> {
47        unsafe {
48            from_glib_none(ffi::gtk_actionable_get_action_target_value(
49                self.as_ref().to_glib_none().0,
50            ))
51        }
52    }
53
54    #[doc(alias = "gtk_actionable_set_action_name")]
55    #[doc(alias = "action-name")]
56    fn set_action_name(&self, action_name: Option<&str>) {
57        unsafe {
58            ffi::gtk_actionable_set_action_name(
59                self.as_ref().to_glib_none().0,
60                action_name.to_glib_none().0,
61            );
62        }
63    }
64
65    #[doc(alias = "gtk_actionable_set_action_target_value")]
66    #[doc(alias = "action-target")]
67    fn set_action_target_value(&self, target_value: Option<&glib::Variant>) {
68        unsafe {
69            ffi::gtk_actionable_set_action_target_value(
70                self.as_ref().to_glib_none().0,
71                target_value.to_glib_none().0,
72            );
73        }
74    }
75
76    #[doc(alias = "gtk_actionable_set_detailed_action_name")]
77    fn set_detailed_action_name(&self, detailed_action_name: &str) {
78        unsafe {
79            ffi::gtk_actionable_set_detailed_action_name(
80                self.as_ref().to_glib_none().0,
81                detailed_action_name.to_glib_none().0,
82            );
83        }
84    }
85
86    #[doc(alias = "action-name")]
87    fn connect_action_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
88        unsafe extern "C" fn notify_action_name_trampoline<
89            P: IsA<Actionable>,
90            F: Fn(&P) + 'static,
91        >(
92            this: *mut ffi::GtkActionable,
93            _param_spec: glib::ffi::gpointer,
94            f: glib::ffi::gpointer,
95        ) {
96            let f: &F = &*(f as *const F);
97            f(Actionable::from_glib_borrow(this).unsafe_cast_ref())
98        }
99        unsafe {
100            let f: Box_<F> = Box_::new(f);
101            connect_raw(
102                self.as_ptr() as *mut _,
103                b"notify::action-name\0".as_ptr() as *const _,
104                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
105                    notify_action_name_trampoline::<Self, F> as *const (),
106                )),
107                Box_::into_raw(f),
108            )
109        }
110    }
111
112    #[doc(alias = "action-target")]
113    fn connect_action_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
114        unsafe extern "C" fn notify_action_target_trampoline<
115            P: IsA<Actionable>,
116            F: Fn(&P) + 'static,
117        >(
118            this: *mut ffi::GtkActionable,
119            _param_spec: glib::ffi::gpointer,
120            f: glib::ffi::gpointer,
121        ) {
122            let f: &F = &*(f as *const F);
123            f(Actionable::from_glib_borrow(this).unsafe_cast_ref())
124        }
125        unsafe {
126            let f: Box_<F> = Box_::new(f);
127            connect_raw(
128                self.as_ptr() as *mut _,
129                b"notify::action-target\0".as_ptr() as *const _,
130                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
131                    notify_action_target_trampoline::<Self, F> as *const (),
132                )),
133                Box_::into_raw(f),
134            )
135        }
136    }
137}
138
139impl<O: IsA<Actionable>> ActionableExt for O {}