gio/auto/
menu_link_iter.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, MenuModel};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// #GMenuLinkIter is an opaque structure type.  You must access it using
10    /// the functions below.
11    ///
12    /// This is an Abstract Base Class, you cannot instantiate it.
13    ///
14    /// # Implements
15    ///
16    /// [`MenuLinkIterExt`][trait@crate::prelude::MenuLinkIterExt], [`trait@glib::ObjectExt`]
17    #[doc(alias = "GMenuLinkIter")]
18    pub struct MenuLinkIter(Object<ffi::GMenuLinkIter, ffi::GMenuLinkIterClass>);
19
20    match fn {
21        type_ => || ffi::g_menu_link_iter_get_type(),
22    }
23}
24
25impl MenuLinkIter {
26    pub const NONE: Option<&'static MenuLinkIter> = None;
27}
28
29mod sealed {
30    pub trait Sealed {}
31    impl<T: super::IsA<super::MenuLinkIter>> Sealed for T {}
32}
33
34/// Trait containing all [`struct@MenuLinkIter`] methods.
35///
36/// # Implementors
37///
38/// [`MenuLinkIter`][struct@crate::MenuLinkIter]
39pub trait MenuLinkIterExt: IsA<MenuLinkIter> + sealed::Sealed + 'static {
40    /// This function combines g_menu_link_iter_next() with
41    /// g_menu_link_iter_get_name() and g_menu_link_iter_get_value().
42    ///
43    /// First the iterator is advanced to the next (possibly first) link.
44    /// If that fails, then [`false`] is returned and there are no other effects.
45    ///
46    /// If successful, @out_link and @value are set to the name and #GMenuModel
47    /// of the link that has just been advanced to.  At this point,
48    /// g_menu_link_iter_get_name() and g_menu_link_iter_get_value() will return the
49    /// same values again.
50    ///
51    /// The value returned in @out_link remains valid for as long as the iterator
52    /// remains at the current position.  The value returned in @value must
53    /// be unreffed using g_object_unref() when it is no longer in use.
54    ///
55    /// # Returns
56    ///
57    /// [`true`] on success, or [`false`] if there is no additional link
58    ///
59    /// ## `out_link`
60    /// the name of the link
61    ///
62    /// ## `value`
63    /// the linked #GMenuModel
64    #[doc(alias = "g_menu_link_iter_get_next")]
65    #[doc(alias = "get_next")]
66    fn next(&self) -> Option<(glib::GString, MenuModel)> {
67        unsafe {
68            let mut out_link = std::ptr::null();
69            let mut value = std::ptr::null_mut();
70            let ret = from_glib(ffi::g_menu_link_iter_get_next(
71                self.as_ref().to_glib_none().0,
72                &mut out_link,
73                &mut value,
74            ));
75            if ret {
76                Some((from_glib_none(out_link), from_glib_full(value)))
77            } else {
78                None
79            }
80        }
81    }
82}
83
84impl<O: IsA<MenuLinkIter>> MenuLinkIterExt for O {}