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