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