1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.MenuLinkIter;
26 
27 private import gio.MenuModel;
28 private import gio.c.functions;
29 public  import gio.c.types;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 public  import gtkc.giotypes;
33 
34 
35 /**
36  * #GMenuLinkIter is an opaque structure type.  You must access it using
37  * the functions below.
38  *
39  * Since: 2.32
40  */
41 public class MenuLinkIter : ObjectG
42 {
43 	/** the main Gtk struct */
44 	protected GMenuLinkIter* gMenuLinkIter;
45 
46 	/** Get the main Gtk struct */
47 	public GMenuLinkIter* getMenuLinkIterStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gMenuLinkIter;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gMenuLinkIter;
58 	}
59 
60 	protected override void setStruct(GObject* obj)
61 	{
62 		gMenuLinkIter = cast(GMenuLinkIter*)obj;
63 		super.setStruct(obj);
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (GMenuLinkIter* gMenuLinkIter, bool ownedRef = false)
70 	{
71 		this.gMenuLinkIter = gMenuLinkIter;
72 		super(cast(GObject*)gMenuLinkIter, ownedRef);
73 	}
74 
75 
76 	/** */
77 	public static GType getType()
78 	{
79 		return g_menu_link_iter_get_type();
80 	}
81 
82 	/**
83 	 * Gets the name of the link at the current iterator position.
84 	 *
85 	 * The iterator is not advanced.
86 	 *
87 	 * Returns: the type of the link
88 	 *
89 	 * Since: 2.32
90 	 */
91 	public string getName()
92 	{
93 		return Str.toString(g_menu_link_iter_get_name(gMenuLinkIter));
94 	}
95 
96 	/**
97 	 * This function combines g_menu_link_iter_next() with
98 	 * g_menu_link_iter_get_name() and g_menu_link_iter_get_value().
99 	 *
100 	 * First the iterator is advanced to the next (possibly first) link.
101 	 * If that fails, then %FALSE is returned and there are no other effects.
102 	 *
103 	 * If successful, @out_link and @value are set to the name and #GMenuModel
104 	 * of the link that has just been advanced to.  At this point,
105 	 * g_menu_link_iter_get_name() and g_menu_link_iter_get_value() will return the
106 	 * same values again.
107 	 *
108 	 * The value returned in @out_link remains valid for as long as the iterator
109 	 * remains at the current position.  The value returned in @value must
110 	 * be unreffed using g_object_unref() when it is no longer in use.
111 	 *
112 	 * Params:
113 	 *     outLink = the name of the link
114 	 *     value = the linked #GMenuModel
115 	 *
116 	 * Returns: %TRUE on success, or %FALSE if there is no additional link
117 	 *
118 	 * Since: 2.32
119 	 */
120 	public bool getNext(out string outLink, out MenuModel value)
121 	{
122 		char* outoutLink = null;
123 		GMenuModel* outvalue = null;
124 
125 		auto p = g_menu_link_iter_get_next(gMenuLinkIter, &outoutLink, &outvalue) != 0;
126 
127 		outLink = Str.toString(outoutLink);
128 		value = ObjectG.getDObject!(MenuModel)(outvalue);
129 
130 		return p;
131 	}
132 
133 	/**
134 	 * Gets the linked #GMenuModel at the current iterator position.
135 	 *
136 	 * The iterator is not advanced.
137 	 *
138 	 * Returns: the #GMenuModel that is linked to
139 	 *
140 	 * Since: 2.32
141 	 */
142 	public MenuModel getValue()
143 	{
144 		auto p = g_menu_link_iter_get_value(gMenuLinkIter);
145 
146 		if(p is null)
147 		{
148 			return null;
149 		}
150 
151 		return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) p, true);
152 	}
153 
154 	/**
155 	 * Attempts to advance the iterator to the next (possibly first)
156 	 * link.
157 	 *
158 	 * %TRUE is returned on success, or %FALSE if there are no more links.
159 	 *
160 	 * You must call this function when you first acquire the iterator to
161 	 * advance it to the first link (and determine if the first link exists
162 	 * at all).
163 	 *
164 	 * Returns: %TRUE on success, or %FALSE when there are no more links
165 	 *
166 	 * Since: 2.32
167 	 */
168 	public bool next()
169 	{
170 		return g_menu_link_iter_next(gMenuLinkIter) != 0;
171 	}
172 }