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 = MenuLinkIter
29  * strct   = GMenuLinkIter
30  * realStrct=
31  * ctorStrct=
32  * clss    = MenuLinkIter
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_menu_link_iter_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * 	- items-changed
46  * imports:
47  * 	- glib.Str
48  * 	- gio.MenuModel
49  * structWrap:
50  * 	- GMenuModel* -> MenuModel
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gio.MenuLinkIter;
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 gio.MenuModel;
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 MenuLinkIter
184 {
185 	
186 	/** the main Gtk struct */
187 	protected GMenuLinkIter* gMenuLinkIter;
188 	
189 	
190 	/** Get the main Gtk struct */
191 	public GMenuLinkIter* getMenuLinkIterStruct()
192 	{
193 		return gMenuLinkIter;
194 	}
195 	
196 	
197 	/** the main Gtk struct as a void* */
198 	protected void* getStruct()
199 	{
200 		return cast(void*)gMenuLinkIter;
201 	}
202 	
203 	/**
204 	 * Sets our main struct and passes it to the parent class
205 	 */
206 	public this (GMenuLinkIter* gMenuLinkIter)
207 	{
208 		this.gMenuLinkIter = gMenuLinkIter;
209 	}
210 	
211 	/**
212 	 */
213 	
214 	/**
215 	 * Gets the name of the link at the current iterator position.
216 	 * The iterator is not advanced.
217 	 * Since 2.32
218 	 * Returns: the type of the link
219 	 */
220 	public string getName()
221 	{
222 		// const gchar * g_menu_link_iter_get_name (GMenuLinkIter *iter);
223 		return Str.toString(g_menu_link_iter_get_name(gMenuLinkIter));
224 	}
225 	
226 	/**
227 	 * This function combines g_menu_link_iter_next() with
228 	 * g_menu_link_iter_get_name() and g_menu_link_iter_get_value().
229 	 * First the iterator is advanced to the next (possibly first) link.
230 	 * If that fails, then FALSE is returned and there are no other effects.
231 	 * If successful, out_link and value are set to the name and GMenuModel
232 	 * of the link that has just been advanced to. At this point,
233 	 * g_menu_link_iter_get_name() and g_menu_link_iter_get_value() will return the
234 	 * same values again.
235 	 * The value returned in out_link remains valid for as long as the iterator
236 	 * remains at the current position. The value returned in value must
237 	 * be unreffed using g_object_unref() when it is no longer in use.
238 	 * Since 2.32
239 	 * Params:
240 	 * outLink = the name of the link. [out][allow-none][transfer none]
241 	 * value = the linked GMenuModel. [out][allow-none][transfer full]
242 	 * Returns: TRUE on success, or FALSE if there is no additional link
243 	 */
244 	public int getNext(char** outLink, out MenuModel value)
245 	{
246 		// gboolean g_menu_link_iter_get_next (GMenuLinkIter *iter,  const gchar **out_link,  GMenuModel **value);
247 		GMenuModel* outvalue = null;
248 		
249 		auto p = g_menu_link_iter_get_next(gMenuLinkIter, outLink, &outvalue);
250 		
251 		value = ObjectG.getDObject!(MenuModel)(outvalue);
252 		return p;
253 	}
254 	
255 	/**
256 	 * Gets the linked GMenuModel at the current iterator position.
257 	 * The iterator is not advanced.
258 	 * Since 2.32
259 	 * Returns: the GMenuModel that is linked to. [transfer full]
260 	 */
261 	public MenuModel getValue()
262 	{
263 		// GMenuModel * g_menu_link_iter_get_value (GMenuLinkIter *iter);
264 		auto p = g_menu_link_iter_get_value(gMenuLinkIter);
265 		
266 		if(p is null)
267 		{
268 			return null;
269 		}
270 		
271 		return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) p);
272 	}
273 	
274 	/**
275 	 * Attempts to advance the iterator to the next (possibly first)
276 	 * link.
277 	 * TRUE is returned on success, or FALSE if there are no more links.
278 	 * You must call this function when you first acquire the iterator to
279 	 * advance it to the first link (and determine if the first link exists
280 	 * at all).
281 	 * Since 2.32
282 	 * Signal Details
283 	 * The "items-changed" signal
284 	 * void user_function (GMenuModel *model,
285 	 *  gint position,
286 	 *  gint removed,
287 	 *  gint added,
288 	 *  gpointer user_data) : Run Last
289 	 * Emitted when a change has occured to the menu.
290 	 * The only changes that can occur to a menu is that items are removed
291 	 * or added. Items may not change (except by being removed and added
292 	 * back in the same location). This signal is capable of describing
293 	 * both of those changes (at the same time).
294 	 * The signal means that starting at the index position, removed
295 	 * items were removed and added items were added in their place. If
296 	 * removed is zero then only items were added. If added is zero
297 	 * then only items were removed.
298 	 * As an example, if the menu contains items a, b, c, d (in that
299 	 * order) and the signal (2, 1, 3) occurs then the new composition of
300 	 * the menu will be a, b, _, _, _, d (with each _ representing some
301 	 * new item).
302 	 * Signal handlers may query the model (particularly the added items)
303 	 * and expect to see the results of the modification that is being
304 	 * reported. The signal is emitted after the modification.
305 	 * Returns: TRUE on success, or FALSE when there are no more links
306 	 */
307 	public int next()
308 	{
309 		// gboolean g_menu_link_iter_next (GMenuLinkIter *iter);
310 		return g_menu_link_iter_next(gMenuLinkIter);
311 	}
312 }