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