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