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  * Conversion parameters:
26  * inFile  = 
27  * outPack = gio
28  * outFile = MenuAttributeIter
29  * strct   = GMenuAttributeIter
30  * realStrct=
31  * ctorStrct=
32  * clss    = MenuAttributeIter
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_menu_attribute_iter_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * 	- items-changed
46  * imports:
47  * 	- glib.Str
48  * 	- glib.Variant
49  * structWrap:
50  * 	- GVariant* -> Variant
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gio.MenuAttributeIter;
57 
58 public  import gtkc.giotypes;
59 
60 private import gtkc.gio;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 private import gobject.Signals;
65 public  import gtkc.gdktypes;
66 private import glib.Str;
67 private import glib.Variant;
68 
69 
70 
71 /**
72  * GMenuModel represents the contents of a menu -- an ordered list of
73  * menu items. The items are associated with actions, which can be
74  * activated through them. Items can be grouped in sections, and may
75  * have submenus associated with them. Both items and sections usually
76  * have some representation data, such as labels or icons. The type of
77  * the associated action (ie whether it is stateful, and what kind of
78  * state it has) can influence the representation of the item.
79  *
80  * The conceptual model of menus in GMenuModel is hierarchical:
81  * sections and submenus are again represented by GMenuModels.
82  * Menus themselves do not define their own roles. Rather, the role
83  * of a particular GMenuModel is defined by the item that references
84  * it (or, in the case of the 'root' menu, is defined by the context
85  * in which it is used).
86  *
87  * As an example, consider the visible portions of the menu in
88  *  Figure 2, “An example menu”.
89  *
90  * Figure 2. An example menu
91  *
92  * There are 8 "menus" visible in the screenshot: one menubar, two
93  * submenus and 5 sections:
94  *
95  * the toplevel menubar (containing 4 items)
96  * the View submenu (containing 3 sections)
97  * the first section of the View submenu (containing 2 items)
98  * the second section of the View submenu (containing 1 item)
99  * the final section of the View submenu (containing 1 item)
100  * the Highlight Mode submenu (containing 2 sections)
101  * the Sources section (containing 2 items)
102  * the Markup section (containing 2 items)
103  *
104  *  Figure 3, “A menu model” illustrates the conceptual connection between
105  * these 8 menus. Each large block in the figure represents a menu and the
106  * smaller blocks within the large block represent items in that menu. Some
107  * items contain references to other menus.
108  *
109  * Figure 3. A menu model
110  *
111  * Notice that the separators visible in Figure 2, “An example menu”
112  * appear nowhere in Figure 3, “A menu model”. This is because
113  * separators are not explicitly represented in the menu model. Instead,
114  * a separator is inserted between any two non-empty sections of a menu.
115  * Section items can have labels just like any other item. In that case,
116  * a display system may show a section header instead of a separator.
117  *
118  * The motivation for this abstract model of application controls is
119  * that modern user interfaces tend to make these controls available
120  * outside the application. Examples include global menus, jumplists,
121  * dash boards, etc. To support such uses, it is necessary to 'export'
122  * information about actions and their representation in menus, which
123  * is exactly what the
124  * GActionGroup exporter
125  * and the
126  * GMenuModel exporter
127  * do for GActionGroup and GMenuModel. The client-side counterparts
128  * to make use of the exported information are GDBusActionGroup and
129  * GDBusMenuModel.
130  *
131  * The API of GMenuModel is very generic, with iterators for the
132  * attributes and links of an item, see g_menu_model_iterate_item_attributes()
133  * and g_menu_model_iterate_item_links(). The 'standard' attributes and
134  * link types have predefined names: G_MENU_ATTRIBUTE_LABEL,
135  * G_MENU_ATTRIBUTE_ACTION, G_MENU_ATTRIBUTE_TARGET, G_MENU_LINK_SECTION
136  * and G_MENU_LINK_SUBMENU.
137  *
138  * Items in a GMenuModel represent active controls if they refer to
139  * an action that can get activated when the user interacts with the
140  * menu item. The reference to the action is encoded by the string id
141  * in the G_MENU_ATTRIBUTE_ACTION attribute. An action id uniquely
142  * identifies an action in an action group. Which action group(s) provide
143  * actions depends on the context in which the menu model is used.
144  * E.g. when the model is exported as the application menu of a
145  * GtkApplication, actions can be application-wide or window-specific
146  * (and thus come from two different action groups). By convention, the
147  * application-wide actions have names that start with "app.", while the
148  * names of window-specific actions start with "win.".
149  *
150  * While a wide variety of stateful actions is possible, the following
151  * is the minimum that is expected to be supported by all users of exported
152  * menu information:
153  *
154  * an action with no parameter type and no state
155  * an action with no parameter type and boolean state
156  * an action with string parameter type and string state
157  *
158  * Stateless.
159  * A stateless action typically corresponds to an ordinary menu item.
160  *
161  * Selecting such a menu item will activate the action (with no parameter).
162  *
163  * Boolean State.
164  * An action with a boolean state will most typically be used with a "toggle"
165  * or "switch" menu item. The state can be set directly, but activating the
166  * action (with no parameter) results in the state being toggled.
167  *
168  * Selecting a toggle menu item will activate the action. The menu item should
169  * be rendered as "checked" when the state is true.
170  *
171  * String Parameter and State.
172  * Actions with string parameters and state will most typically be used to
173  * represent an enumerated choice over the items available for a group of
174  * radio menu items. Activating the action with a string parameter is
175  * equivalent to setting that parameter as the state.
176  *
177  * Radio menu items, in addition to being associated with the action, will
178  * have a target value. Selecting that menu item will result in activation
179  * of the action with the target value as the parameter. The menu item should
180  * be rendered as "selected" when the state of the action is equal to the
181  * target value of the menu item.
182  */
183 public class MenuAttributeIter
184 {
185 	
186 	/** the main Gtk struct */
187 	protected GMenuAttributeIter* gMenuAttributeIter;
188 	
189 	
190 	/** Get the main Gtk struct */
191 	public GMenuAttributeIter* getMenuAttributeIterStruct()
192 	{
193 		return gMenuAttributeIter;
194 	}
195 	
196 	
197 	/** the main Gtk struct as a void* */
198 	protected void* getStruct()
199 	{
200 		return cast(void*)gMenuAttributeIter;
201 	}
202 	
203 	/**
204 	 * Sets our main struct and passes it to the parent class
205 	 */
206 	public this (GMenuAttributeIter* gMenuAttributeIter)
207 	{
208 		this.gMenuAttributeIter = gMenuAttributeIter;
209 	}
210 	
211 	/**
212 	 */
213 	
214 	/**
215 	 * This function combines g_menu_attribute_iter_next() with
216 	 * g_menu_attribute_iter_get_name() and g_menu_attribute_iter_get_value().
217 	 * First the iterator is advanced to the next (possibly first) attribute.
218 	 * If that fails, then FALSE is returned and there are no other
219 	 * effects.
220 	 * If successful, name and value are set to the name and value of the
221 	 * attribute that has just been advanced to. At this point,
222 	 * g_menu_attribute_iter_get_name() and g_menu_attribute_iter_get_value() will
223 	 * return the same values again.
224 	 * The value returned in name remains valid for as long as the iterator
225 	 * remains at the current position. The value returned in value must
226 	 * be unreffed using g_variant_unref() when it is no longer in use.
227 	 * Since 2.32
228 	 * Params:
229 	 * outName = the type of the attribute. [out][allow-none][transfer none]
230 	 * value = the attribute value. [out][allow-none][transfer full]
231 	 * Returns: TRUE on success, or FALSE if there is no additional attribute
232 	 */
233 	public int getNext(out string outName, out Variant value)
234 	{
235 		// gboolean g_menu_attribute_iter_get_next (GMenuAttributeIter *iter,  const gchar **out_name,  GVariant **value);
236 		char* outoutName = null;
237 		GVariant* outvalue = null;
238 		
239 		auto p = g_menu_attribute_iter_get_next(gMenuAttributeIter, &outoutName, &outvalue);
240 		
241 		outName = Str.toString(outoutName);
242 		value = ObjectG.getDObject!(Variant)(outvalue);
243 		return p;
244 	}
245 	
246 	/**
247 	 * Gets the name of the attribute at the current iterator position, as
248 	 * a string.
249 	 * The iterator is not advanced.
250 	 * Since 2.32
251 	 * Returns: the name of the attribute
252 	 */
253 	public string getName()
254 	{
255 		// const gchar * g_menu_attribute_iter_get_name (GMenuAttributeIter *iter);
256 		return Str.toString(g_menu_attribute_iter_get_name(gMenuAttributeIter));
257 	}
258 	
259 	/**
260 	 * Gets the value of the attribute at the current iterator position.
261 	 * The iterator is not advanced.
262 	 * Since 2.32
263 	 * Returns: the value of the current attribute. [transfer full]
264 	 */
265 	public Variant getValue()
266 	{
267 		// GVariant * g_menu_attribute_iter_get_value (GMenuAttributeIter *iter);
268 		auto p = g_menu_attribute_iter_get_value(gMenuAttributeIter);
269 		
270 		if(p is null)
271 		{
272 			return null;
273 		}
274 		
275 		return ObjectG.getDObject!(Variant)(cast(GVariant*) p);
276 	}
277 	
278 	/**
279 	 * Attempts to advance the iterator to the next (possibly first)
280 	 * attribute.
281 	 * TRUE is returned on success, or FALSE if there are no more
282 	 * attributes.
283 	 * You must call this function when you first acquire the iterator
284 	 * to advance it to the first attribute (and determine if the first
285 	 * attribute exists at all).
286 	 * Since 2.32
287 	 * Returns: TRUE on success, or FALSE when there are no more attributes
288 	 */
289 	public int next()
290 	{
291 		// gboolean g_menu_attribute_iter_next (GMenuAttributeIter *iter);
292 		return g_menu_attribute_iter_next(gMenuAttributeIter);
293 	}
294 }