1#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{Widget, ffi};
9use glib::{
10 prelude::*,
11 signal::{SignalHandlerId, connect_raw},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16#[cfg(feature = "v4_10")]
17#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
18glib::wrapper! {
19 #[doc(alias = "GtkStackPage")]
83 pub struct StackPage(Object<ffi::GtkStackPage>) @implements Accessible;
84
85 match fn {
86 type_ => || ffi::gtk_stack_page_get_type(),
87 }
88}
89
90#[cfg(not(feature = "v4_10"))]
91glib::wrapper! {
92 #[doc(alias = "GtkStackPage")]
93 pub struct StackPage(Object<ffi::GtkStackPage>);
94
95 match fn {
96 type_ => || ffi::gtk_stack_page_get_type(),
97 }
98}
99
100impl StackPage {
101 #[doc(alias = "gtk_stack_page_get_child")]
107 #[doc(alias = "get_child")]
108 pub fn child(&self) -> Widget {
109 unsafe { from_glib_none(ffi::gtk_stack_page_get_child(self.to_glib_none().0)) }
110 }
111
112 #[doc(alias = "gtk_stack_page_get_icon_name")]
118 #[doc(alias = "get_icon_name")]
119 #[doc(alias = "icon-name")]
120 pub fn icon_name(&self) -> Option<glib::GString> {
121 unsafe { from_glib_none(ffi::gtk_stack_page_get_icon_name(self.to_glib_none().0)) }
122 }
123
124 #[doc(alias = "gtk_stack_page_get_name")]
130 #[doc(alias = "get_name")]
131 pub fn name(&self) -> Option<glib::GString> {
132 unsafe { from_glib_none(ffi::gtk_stack_page_get_name(self.to_glib_none().0)) }
133 }
134
135 #[doc(alias = "gtk_stack_page_get_needs_attention")]
142 #[doc(alias = "get_needs_attention")]
143 #[doc(alias = "needs-attention")]
144 pub fn needs_attention(&self) -> bool {
145 unsafe {
146 from_glib(ffi::gtk_stack_page_get_needs_attention(
147 self.to_glib_none().0,
148 ))
149 }
150 }
151
152 #[doc(alias = "gtk_stack_page_get_title")]
158 #[doc(alias = "get_title")]
159 pub fn title(&self) -> Option<glib::GString> {
160 unsafe { from_glib_none(ffi::gtk_stack_page_get_title(self.to_glib_none().0)) }
161 }
162
163 #[doc(alias = "gtk_stack_page_get_use_underline")]
169 #[doc(alias = "get_use_underline")]
170 #[doc(alias = "use-underline")]
171 pub fn uses_underline(&self) -> bool {
172 unsafe { from_glib(ffi::gtk_stack_page_get_use_underline(self.to_glib_none().0)) }
173 }
174
175 #[doc(alias = "gtk_stack_page_get_visible")]
184 #[doc(alias = "get_visible")]
185 #[doc(alias = "visible")]
186 pub fn is_visible(&self) -> bool {
187 unsafe { from_glib(ffi::gtk_stack_page_get_visible(self.to_glib_none().0)) }
188 }
189
190 #[doc(alias = "gtk_stack_page_set_icon_name")]
194 #[doc(alias = "icon-name")]
195 pub fn set_icon_name(&self, setting: &str) {
196 unsafe {
197 ffi::gtk_stack_page_set_icon_name(self.to_glib_none().0, setting.to_glib_none().0);
198 }
199 }
200
201 #[doc(alias = "gtk_stack_page_set_name")]
205 #[doc(alias = "name")]
206 pub fn set_name(&self, setting: &str) {
207 unsafe {
208 ffi::gtk_stack_page_set_name(self.to_glib_none().0, setting.to_glib_none().0);
209 }
210 }
211
212 #[doc(alias = "gtk_stack_page_set_needs_attention")]
216 #[doc(alias = "needs-attention")]
217 pub fn set_needs_attention(&self, setting: bool) {
218 unsafe {
219 ffi::gtk_stack_page_set_needs_attention(self.to_glib_none().0, setting.into_glib());
220 }
221 }
222
223 #[doc(alias = "gtk_stack_page_set_title")]
227 #[doc(alias = "title")]
228 pub fn set_title(&self, setting: &str) {
229 unsafe {
230 ffi::gtk_stack_page_set_title(self.to_glib_none().0, setting.to_glib_none().0);
231 }
232 }
233
234 #[doc(alias = "gtk_stack_page_set_use_underline")]
238 #[doc(alias = "use-underline")]
239 pub fn set_use_underline(&self, setting: bool) {
240 unsafe {
241 ffi::gtk_stack_page_set_use_underline(self.to_glib_none().0, setting.into_glib());
242 }
243 }
244
245 #[doc(alias = "gtk_stack_page_set_visible")]
249 #[doc(alias = "visible")]
250 pub fn set_visible(&self, visible: bool) {
251 unsafe {
252 ffi::gtk_stack_page_set_visible(self.to_glib_none().0, visible.into_glib());
253 }
254 }
255
256 #[doc(alias = "icon-name")]
257 pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
258 unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&StackPage) + 'static>(
259 this: *mut ffi::GtkStackPage,
260 _param_spec: glib::ffi::gpointer,
261 f: glib::ffi::gpointer,
262 ) {
263 unsafe {
264 let f: &F = &*(f as *const F);
265 f(&from_glib_borrow(this))
266 }
267 }
268 unsafe {
269 let f: Box_<F> = Box_::new(f);
270 connect_raw(
271 self.as_ptr() as *mut _,
272 c"notify::icon-name".as_ptr(),
273 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
274 notify_icon_name_trampoline::<F> as *const (),
275 )),
276 Box_::into_raw(f),
277 )
278 }
279 }
280
281 #[doc(alias = "name")]
282 pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
283 unsafe extern "C" fn notify_name_trampoline<F: Fn(&StackPage) + 'static>(
284 this: *mut ffi::GtkStackPage,
285 _param_spec: glib::ffi::gpointer,
286 f: glib::ffi::gpointer,
287 ) {
288 unsafe {
289 let f: &F = &*(f as *const F);
290 f(&from_glib_borrow(this))
291 }
292 }
293 unsafe {
294 let f: Box_<F> = Box_::new(f);
295 connect_raw(
296 self.as_ptr() as *mut _,
297 c"notify::name".as_ptr(),
298 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
299 notify_name_trampoline::<F> as *const (),
300 )),
301 Box_::into_raw(f),
302 )
303 }
304 }
305
306 #[doc(alias = "needs-attention")]
307 pub fn connect_needs_attention_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
308 unsafe extern "C" fn notify_needs_attention_trampoline<F: Fn(&StackPage) + 'static>(
309 this: *mut ffi::GtkStackPage,
310 _param_spec: glib::ffi::gpointer,
311 f: glib::ffi::gpointer,
312 ) {
313 unsafe {
314 let f: &F = &*(f as *const F);
315 f(&from_glib_borrow(this))
316 }
317 }
318 unsafe {
319 let f: Box_<F> = Box_::new(f);
320 connect_raw(
321 self.as_ptr() as *mut _,
322 c"notify::needs-attention".as_ptr(),
323 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
324 notify_needs_attention_trampoline::<F> as *const (),
325 )),
326 Box_::into_raw(f),
327 )
328 }
329 }
330
331 #[doc(alias = "title")]
332 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
333 unsafe extern "C" fn notify_title_trampoline<F: Fn(&StackPage) + 'static>(
334 this: *mut ffi::GtkStackPage,
335 _param_spec: glib::ffi::gpointer,
336 f: glib::ffi::gpointer,
337 ) {
338 unsafe {
339 let f: &F = &*(f as *const F);
340 f(&from_glib_borrow(this))
341 }
342 }
343 unsafe {
344 let f: Box_<F> = Box_::new(f);
345 connect_raw(
346 self.as_ptr() as *mut _,
347 c"notify::title".as_ptr(),
348 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
349 notify_title_trampoline::<F> as *const (),
350 )),
351 Box_::into_raw(f),
352 )
353 }
354 }
355
356 #[doc(alias = "use-underline")]
357 pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
358 unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&StackPage) + 'static>(
359 this: *mut ffi::GtkStackPage,
360 _param_spec: glib::ffi::gpointer,
361 f: glib::ffi::gpointer,
362 ) {
363 unsafe {
364 let f: &F = &*(f as *const F);
365 f(&from_glib_borrow(this))
366 }
367 }
368 unsafe {
369 let f: Box_<F> = Box_::new(f);
370 connect_raw(
371 self.as_ptr() as *mut _,
372 c"notify::use-underline".as_ptr(),
373 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
374 notify_use_underline_trampoline::<F> as *const (),
375 )),
376 Box_::into_raw(f),
377 )
378 }
379 }
380
381 #[doc(alias = "visible")]
382 pub fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
383 unsafe extern "C" fn notify_visible_trampoline<F: Fn(&StackPage) + 'static>(
384 this: *mut ffi::GtkStackPage,
385 _param_spec: glib::ffi::gpointer,
386 f: glib::ffi::gpointer,
387 ) {
388 unsafe {
389 let f: &F = &*(f as *const F);
390 f(&from_glib_borrow(this))
391 }
392 }
393 unsafe {
394 let f: Box_<F> = Box_::new(f);
395 connect_raw(
396 self.as_ptr() as *mut _,
397 c"notify::visible".as_ptr(),
398 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
399 notify_visible_trampoline::<F> as *const (),
400 )),
401 Box_::into_raw(f),
402 )
403 }
404 }
405}