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