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