[go: up one dir, main page]

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
26pub trait ActionableExt: IsA<Actionable> + 'static {
27    #[doc(alias = "gtk_actionable_get_action_name")]
28    #[doc(alias = "get_action_name")]
29    #[doc(alias = "action-name")]
30    fn action_name(&self) -> Option<glib::GString> {
31        unsafe {
32            from_glib_none(ffi::gtk_actionable_get_action_name(
33                self.as_ref().to_glib_none().0,
34            ))
35        }
36    }
37
38    #[doc(alias = "gtk_actionable_get_action_target_value")]
39    #[doc(alias = "get_action_target_value")]
40    #[doc(alias = "action-target")]
41    fn action_target_value(&self) -> Option<glib::Variant> {
42        unsafe {
43            from_glib_none(ffi::gtk_actionable_get_action_target_value(
44                self.as_ref().to_glib_none().0,
45            ))
46        }
47    }
48
49    #[doc(alias = "gtk_actionable_set_action_name")]
50    #[doc(alias = "action-name")]
51    fn set_action_name(&self, action_name: Option<&str>) {
52        unsafe {
53            ffi::gtk_actionable_set_action_name(
54                self.as_ref().to_glib_none().0,
55                action_name.to_glib_none().0,
56            );
57        }
58    }
59
60    #[doc(alias = "gtk_actionable_set_action_target_value")]
61    #[doc(alias = "action-target")]
62    fn set_action_target_value(&self, target_value: Option<&glib::Variant>) {
63        unsafe {
64            ffi::gtk_actionable_set_action_target_value(
65                self.as_ref().to_glib_none().0,
66                target_value.to_glib_none().0,
67            );
68        }
69    }
70
71    #[doc(alias = "gtk_actionable_set_detailed_action_name")]
72    fn set_detailed_action_name(&self, detailed_action_name: &str) {
73        unsafe {
74            ffi::gtk_actionable_set_detailed_action_name(
75                self.as_ref().to_glib_none().0,
76                detailed_action_name.to_glib_none().0,
77            );
78        }
79    }
80
81    #[doc(alias = "action-name")]
82    fn connect_action_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
83        unsafe extern "C" fn notify_action_name_trampoline<
84            P: IsA<Actionable>,
85            F: Fn(&P) + 'static,
86        >(
87            this: *mut ffi::GtkActionable,
88            _param_spec: glib::ffi::gpointer,
89            f: glib::ffi::gpointer,
90        ) {
91            let f: &F = &*(f as *const F);
92            f(Actionable::from_glib_borrow(this).unsafe_cast_ref())
93        }
94        unsafe {
95            let f: Box_<F> = Box_::new(f);
96            connect_raw(
97                self.as_ptr() as *mut _,
98                c"notify::action-name".as_ptr() as *const _,
99                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
100                    notify_action_name_trampoline::<Self, F> as *const (),
101                )),
102                Box_::into_raw(f),
103            )
104        }
105    }
106
107    #[doc(alias = "action-target")]
108    fn connect_action_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
109        unsafe extern "C" fn notify_action_target_trampoline<
110            P: IsA<Actionable>,
111            F: Fn(&P) + 'static,
112        >(
113            this: *mut ffi::GtkActionable,
114            _param_spec: glib::ffi::gpointer,
115            f: glib::ffi::gpointer,
116        ) {
117            let f: &F = &*(f as *const F);
118            f(Actionable::from_glib_borrow(this).unsafe_cast_ref())
119        }
120        unsafe {
121            let f: Box_<F> = Box_::new(f);
122            connect_raw(
123                self.as_ptr() as *mut _,
124                c"notify::action-target".as_ptr() as *const _,
125                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
126                    notify_action_target_trampoline::<Self, F> as *const (),
127                )),
128                Box_::into_raw(f),
129            )
130        }
131    }
132}
133
134impl<O: IsA<Actionable>> ActionableExt for O {}