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
29/// Trait containing all [`struct@MenuAttributeIter`] methods.
30///
31/// # Implementors
32///
33/// [`MenuAttributeIter`][struct@crate::MenuAttributeIter]
34pub trait MenuAttributeIterExt: IsA<MenuAttributeIter> + 'static {
35 /// This function combines g_menu_attribute_iter_next() with
36 /// g_menu_attribute_iter_get_name() and g_menu_attribute_iter_get_value().
37 ///
38 /// First the iterator is advanced to the next (possibly first) attribute.
39 /// If that fails, then [`false`] is returned and there are no other
40 /// effects.
41 ///
42 /// If successful, @name and @value are set to the name and value of the
43 /// attribute that has just been advanced to. At this point,
44 /// g_menu_attribute_iter_get_name() and g_menu_attribute_iter_get_value() will
45 /// return the same values again.
46 ///
47 /// The value returned in @name remains valid for as long as the iterator
48 /// remains at the current position. The value returned in @value must
49 /// be unreffed using g_variant_unref() when it is no longer in use.
50 ///
51 /// # Returns
52 ///
53 /// [`true`] on success, or [`false`] if there is no additional
54 /// attribute
55 ///
56 /// ## `out_name`
57 /// the type of the attribute
58 ///
59 /// ## `value`
60 /// the attribute value
61 #[doc(alias = "g_menu_attribute_iter_get_next")]
62 #[doc(alias = "get_next")]
63 fn next(&self) -> Option<(glib::GString, glib::Variant)> {
64 unsafe {
65 let mut out_name = std::ptr::null();
66 let mut value = std::ptr::null_mut();
67 let ret = from_glib(ffi::g_menu_attribute_iter_get_next(
68 self.as_ref().to_glib_none().0,
69 &mut out_name,
70 &mut value,
71 ));
72 if ret {
73 Some((from_glib_none(out_name), from_glib_full(value)))
74 } else {
75 None
76 }
77 }
78 }
79}
80
81impl<O: IsA<MenuAttributeIter>> MenuAttributeIterExt for O {}