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