1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
use crate::{ffi, ViewStackPage};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// An auxiliary class used by [`ViewStack`][crate::ViewStack].
///
/// See [`pages`][struct@crate::ViewStack#pages].
///
/// ## Properties
///
///
/// #### `selected-page`
/// The selected [`ViewStackPage`][crate::ViewStackPage] within the [`ViewStackPages`][crate::ViewStackPages].
///
/// This can be used to keep an up-to-date view of the [`ViewStackPage`][crate::ViewStackPage] for
/// The visible [`ViewStackPage`][crate::ViewStackPage] within the associated [`ViewStackPages`][crate::ViewStackPages].
///
/// This can be used to keep an up-to-date view of the visible child.
///
/// Readable | Writeable
///
/// # Implements
///
/// [`trait@glib::ObjectExt`], [`trait@gio::prelude::ListModelExt`], [`trait@gtk::prelude::SelectionModelExt`]
#[doc(alias = "AdwViewStackPages")]
pub struct ViewStackPages(Object<ffi::AdwViewStackPages, ffi::AdwViewStackPagesClass>) @implements gio::ListModel, gtk::SelectionModel;
match fn {
type_ => || ffi::adw_view_stack_pages_get_type(),
}
}
impl ViewStackPages {
/// Gets the [`ViewStackPage`][crate::ViewStackPage] for the visible child of a view stack
///
/// Gets the [`ViewStackPage`][crate::ViewStackPage] for the visible child of the associated stack.
///
/// Returns `NULL` if there's no selected page.
///
/// # Returns
///
/// the stack page
#[doc(alias = "adw_view_stack_pages_get_selected_page")]
#[doc(alias = "get_selected_page")]
#[doc(alias = "selected-page")]
pub fn selected_page(&self) -> Option<ViewStackPage> {
unsafe {
from_glib_none(ffi::adw_view_stack_pages_get_selected_page(
self.to_glib_none().0,
))
}
}
/// Sets the visible child in the associated [`ViewStack`][crate::ViewStack].
///
/// See [`visible-child`][struct@crate::ViewStack#visible-child].
/// ## `page`
/// a stack page within the associated stack
#[doc(alias = "adw_view_stack_pages_set_selected_page")]
#[doc(alias = "selected-page")]
pub fn set_selected_page(&self, page: &ViewStackPage) {
unsafe {
ffi::adw_view_stack_pages_set_selected_page(
self.to_glib_none().0,
page.to_glib_none().0,
);
}
}
#[cfg(feature = "v1_4")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
#[doc(alias = "selected-page")]
pub fn connect_selected_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_selected_page_trampoline<F: Fn(&ViewStackPages) + 'static>(
this: *mut ffi::AdwViewStackPages,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::selected-page\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_selected_page_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}