libadwaita/auto/
shortcuts_item.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "AdwShortcutsItem")]
16    pub struct ShortcutsItem(Object<ffi::AdwShortcutsItem, ffi::AdwShortcutsItemClass>);
17
18    match fn {
19        type_ => || ffi::adw_shortcuts_item_get_type(),
20    }
21}
22
23impl ShortcutsItem {
24    #[doc(alias = "adw_shortcuts_item_new")]
25    pub fn new(title: &str, accelerator: &str) -> ShortcutsItem {
26        assert_initialized_main_thread!();
27        unsafe {
28            from_glib_full(ffi::adw_shortcuts_item_new(
29                title.to_glib_none().0,
30                accelerator.to_glib_none().0,
31            ))
32        }
33    }
34
35    #[doc(alias = "adw_shortcuts_item_new_from_action")]
36    #[doc(alias = "new_from_action")]
37    pub fn from_action(title: &str, action_name: &str) -> ShortcutsItem {
38        assert_initialized_main_thread!();
39        unsafe {
40            from_glib_full(ffi::adw_shortcuts_item_new_from_action(
41                title.to_glib_none().0,
42                action_name.to_glib_none().0,
43            ))
44        }
45    }
46
47    #[doc(alias = "adw_shortcuts_item_get_accelerator")]
48    #[doc(alias = "get_accelerator")]
49    pub fn accelerator(&self) -> glib::GString {
50        unsafe {
51            from_glib_none(ffi::adw_shortcuts_item_get_accelerator(
52                self.to_glib_none().0,
53            ))
54        }
55    }
56
57    #[doc(alias = "adw_shortcuts_item_get_action_name")]
58    #[doc(alias = "get_action_name")]
59    #[doc(alias = "action-name")]
60    pub fn action_name(&self) -> glib::GString {
61        unsafe {
62            from_glib_none(ffi::adw_shortcuts_item_get_action_name(
63                self.to_glib_none().0,
64            ))
65        }
66    }
67
68    #[doc(alias = "adw_shortcuts_item_get_direction")]
69    #[doc(alias = "get_direction")]
70    pub fn direction(&self) -> gtk::TextDirection {
71        unsafe { from_glib(ffi::adw_shortcuts_item_get_direction(self.to_glib_none().0)) }
72    }
73
74    #[doc(alias = "adw_shortcuts_item_get_subtitle")]
75    #[doc(alias = "get_subtitle")]
76    pub fn subtitle(&self) -> glib::GString {
77        unsafe { from_glib_none(ffi::adw_shortcuts_item_get_subtitle(self.to_glib_none().0)) }
78    }
79
80    #[doc(alias = "adw_shortcuts_item_get_title")]
81    #[doc(alias = "get_title")]
82    pub fn title(&self) -> glib::GString {
83        unsafe { from_glib_none(ffi::adw_shortcuts_item_get_title(self.to_glib_none().0)) }
84    }
85
86    #[doc(alias = "adw_shortcuts_item_set_accelerator")]
87    #[doc(alias = "accelerator")]
88    pub fn set_accelerator(&self, accelerator: &str) {
89        unsafe {
90            ffi::adw_shortcuts_item_set_accelerator(
91                self.to_glib_none().0,
92                accelerator.to_glib_none().0,
93            );
94        }
95    }
96
97    #[doc(alias = "adw_shortcuts_item_set_action_name")]
98    #[doc(alias = "action-name")]
99    pub fn set_action_name(&self, action_name: &str) {
100        unsafe {
101            ffi::adw_shortcuts_item_set_action_name(
102                self.to_glib_none().0,
103                action_name.to_glib_none().0,
104            );
105        }
106    }
107
108    #[doc(alias = "adw_shortcuts_item_set_direction")]
109    #[doc(alias = "direction")]
110    pub fn set_direction(&self, direction: gtk::TextDirection) {
111        unsafe {
112            ffi::adw_shortcuts_item_set_direction(self.to_glib_none().0, direction.into_glib());
113        }
114    }
115
116    #[doc(alias = "adw_shortcuts_item_set_subtitle")]
117    #[doc(alias = "subtitle")]
118    pub fn set_subtitle(&self, subtitle: &str) {
119        unsafe {
120            ffi::adw_shortcuts_item_set_subtitle(self.to_glib_none().0, subtitle.to_glib_none().0);
121        }
122    }
123
124    #[doc(alias = "adw_shortcuts_item_set_title")]
125    #[doc(alias = "title")]
126    pub fn set_title(&self, title: &str) {
127        unsafe {
128            ffi::adw_shortcuts_item_set_title(self.to_glib_none().0, title.to_glib_none().0);
129        }
130    }
131
132    #[cfg(feature = "v1_8")]
133    #[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
134    #[doc(alias = "accelerator")]
135    pub fn connect_accelerator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
136        unsafe extern "C" fn notify_accelerator_trampoline<F: Fn(&ShortcutsItem) + 'static>(
137            this: *mut ffi::AdwShortcutsItem,
138            _param_spec: glib::ffi::gpointer,
139            f: glib::ffi::gpointer,
140        ) {
141            let f: &F = &*(f as *const F);
142            f(&from_glib_borrow(this))
143        }
144        unsafe {
145            let f: Box_<F> = Box_::new(f);
146            connect_raw(
147                self.as_ptr() as *mut _,
148                c"notify::accelerator".as_ptr() as *const _,
149                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
150                    notify_accelerator_trampoline::<F> as *const (),
151                )),
152                Box_::into_raw(f),
153            )
154        }
155    }
156
157    #[cfg(feature = "v1_8")]
158    #[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
159    #[doc(alias = "action-name")]
160    pub fn connect_action_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
161        unsafe extern "C" fn notify_action_name_trampoline<F: Fn(&ShortcutsItem) + 'static>(
162            this: *mut ffi::AdwShortcutsItem,
163            _param_spec: glib::ffi::gpointer,
164            f: glib::ffi::gpointer,
165        ) {
166            let f: &F = &*(f as *const F);
167            f(&from_glib_borrow(this))
168        }
169        unsafe {
170            let f: Box_<F> = Box_::new(f);
171            connect_raw(
172                self.as_ptr() as *mut _,
173                c"notify::action-name".as_ptr() as *const _,
174                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
175                    notify_action_name_trampoline::<F> as *const (),
176                )),
177                Box_::into_raw(f),
178            )
179        }
180    }
181
182    #[cfg(feature = "v1_8")]
183    #[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
184    #[doc(alias = "direction")]
185    pub fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
186        unsafe extern "C" fn notify_direction_trampoline<F: Fn(&ShortcutsItem) + 'static>(
187            this: *mut ffi::AdwShortcutsItem,
188            _param_spec: glib::ffi::gpointer,
189            f: glib::ffi::gpointer,
190        ) {
191            let f: &F = &*(f as *const F);
192            f(&from_glib_borrow(this))
193        }
194        unsafe {
195            let f: Box_<F> = Box_::new(f);
196            connect_raw(
197                self.as_ptr() as *mut _,
198                c"notify::direction".as_ptr() as *const _,
199                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
200                    notify_direction_trampoline::<F> as *const (),
201                )),
202                Box_::into_raw(f),
203            )
204        }
205    }
206
207    #[cfg(feature = "v1_8")]
208    #[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
209    #[doc(alias = "subtitle")]
210    pub fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
211        unsafe extern "C" fn notify_subtitle_trampoline<F: Fn(&ShortcutsItem) + 'static>(
212            this: *mut ffi::AdwShortcutsItem,
213            _param_spec: glib::ffi::gpointer,
214            f: glib::ffi::gpointer,
215        ) {
216            let f: &F = &*(f as *const F);
217            f(&from_glib_borrow(this))
218        }
219        unsafe {
220            let f: Box_<F> = Box_::new(f);
221            connect_raw(
222                self.as_ptr() as *mut _,
223                c"notify::subtitle".as_ptr() as *const _,
224                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
225                    notify_subtitle_trampoline::<F> as *const (),
226                )),
227                Box_::into_raw(f),
228            )
229        }
230    }
231
232    #[cfg(feature = "v1_8")]
233    #[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
234    #[doc(alias = "title")]
235    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
236        unsafe extern "C" fn notify_title_trampoline<F: Fn(&ShortcutsItem) + 'static>(
237            this: *mut ffi::AdwShortcutsItem,
238            _param_spec: glib::ffi::gpointer,
239            f: glib::ffi::gpointer,
240        ) {
241            let f: &F = &*(f as *const F);
242            f(&from_glib_borrow(this))
243        }
244        unsafe {
245            let f: Box_<F> = Box_::new(f);
246            connect_raw(
247                self.as_ptr() as *mut _,
248                c"notify::title".as_ptr() as *const _,
249                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
250                    notify_title_trampoline::<F> as *const (),
251                )),
252                Box_::into_raw(f),
253            )
254        }
255    }
256}