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 glib.Str;
29 private import gobject.ObjectG;
30 private import gtkc.gio;
31 public  import gtkc.giotypes;
32 
33 
34 /**
35  * #GMenuLinkIter is an opaque structure type.  You must access it using
36  * the functions below.
37  *
38  * Since: 2.32
39  */
40 public class MenuLinkIter : ObjectG
41 {
42 	/** the main Gtk struct */
43 	protected GMenuLinkIter* gMenuLinkIter;
44 
45 	/** Get the main Gtk struct */
46 	public GMenuLinkIter* getMenuLinkIterStruct(bool transferOwnership = false)
47 	{
48 		if (transferOwnership)
49 			ownedRef = false;
50 		return gMenuLinkIter;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected override void* getStruct()
55 	{
56 		return cast(void*)gMenuLinkIter;
57 	}
58 
59 	protected override void setStruct(GObject* obj)
60 	{
61 		gMenuLinkIter = cast(GMenuLinkIter*)obj;
62 		super.setStruct(obj);
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (GMenuLinkIter* gMenuLinkIter, bool ownedRef = false)
69 	{
70 		this.gMenuLinkIter = gMenuLinkIter;
71 		super(cast(GObject*)gMenuLinkIter, ownedRef);
72 	}
73 
74 
75 	/** */
76 	public static GType getType()
77 	{
78 		return g_menu_link_iter_get_type();
79 	}
80 
81 	/**
82 	 * Gets the name of the link at the current iterator position.
83 	 *
84 	 * The iterator is not advanced.
85 	 *
86 	 * Returns: the type of the link
87 	 *
88 	 * Since: 2.32
89 	 */
90 	public string getName()
91 	{
92 		return Str.toString(g_menu_link_iter_get_name(gMenuLinkIter));
93 	}
94 
95 	/**
96 	 * This function combines g_menu_link_iter_next() with
97 	 * g_menu_link_iter_get_name() and g_menu_link_iter_get_value().
98 	 *
99 	 * First the iterator is advanced to the next (possibly first) link.
100 	 * If that fails, then %FALSE is returned and there are no other effects.
101 	 *
102 	 * If successful, @out_link and @value are set to the name and #GMenuModel
103 	 * of the link that has just been advanced to.  At this point,
104 	 * g_menu_link_iter_get_name() and g_menu_link_iter_get_value() will return the
105 	 * same values again.
106 	 *
107 	 * The value returned in @out_link remains valid for as long as the iterator
108 	 * remains at the current position.  The value returned in @value must
109 	 * be unreffed using g_object_unref() when it is no longer in use.
110 	 *
111 	 * Params:
112 	 *     outLink = the name of the link
113 	 *     value = the linked #GMenuModel
114 	 *
115 	 * Returns: %TRUE on success, or %FALSE if there is no additional link
116 	 *
117 	 * Since: 2.32
118 	 */
119 	public bool getNext(out string outLink, out MenuModel value)
120 	{
121 		char* outoutLink = null;
122 		GMenuModel* outvalue = null;
123 		
124 		auto p = g_menu_link_iter_get_next(gMenuLinkIter, &outoutLink, &outvalue) != 0;
125 		
126 		outLink = Str.toString(outoutLink);
127 		value = ObjectG.getDObject!(MenuModel)(outvalue);
128 		
129 		return p;
130 	}
131 
132 	/**
133 	 * Gets the linked #GMenuModel at the current iterator position.
134 	 *
135 	 * The iterator is not advanced.
136 	 *
137 	 * Returns: the #GMenuModel that is linked to
138 	 *
139 	 * Since: 2.32
140 	 */
141 	public MenuModel getValue()
142 	{
143 		auto p = g_menu_link_iter_get_value(gMenuLinkIter);
144 		
145 		if(p is null)
146 		{
147 			return null;
148 		}
149 		
150 		return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) p, true);
151 	}
152 
153 	/**
154 	 * Attempts to advance the iterator to the next (possibly first)
155 	 * link.
156 	 *
157 	 * %TRUE is returned on success, or %FALSE if there are no more links.
158 	 *
159 	 * You must call this function when you first acquire the iterator to
160 	 * advance it to the first link (and determine if the first link exists
161 	 * at all).
162 	 *
163 	 * Returns: %TRUE on success, or %FALSE when there are no more links
164 	 *
165 	 * Since: 2.32
166 	 */
167 	public bool next()
168 	{
169 		return g_menu_link_iter_next(gMenuLinkIter) != 0;
170 	}
171 }