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 = GActionGroup.html 27 * outPack = gio 28 * outFile = ActionGroupT 29 * strct = GActionGroup 30 * realStrct= 31 * ctorStrct= 32 * clss = ActionGroupT 33 * interf = ActionGroupIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - g_action_group_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.Variant 49 * - glib.VariantType 50 * structWrap: 51 * - GVariant* -> Variant 52 * - GVariantType* -> VariantType 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gio.ActionGroupT; 59 60 public import gtkc.giotypes; 61 62 public import gtkc.gio; 63 public import glib.ConstructionException; 64 public import gobject.ObjectG; 65 66 public import gobject.Signals; 67 public import gtkc.gdktypes; 68 69 public import glib.Str; 70 public import glib.Variant; 71 public import glib.VariantType; 72 73 74 75 76 /** 77 * Description 78 * GActionGroup represents a group of actions. 79 * Each action in the group has a unique name (which is a string). All 80 * method calls, except g_action_group_list_actions() take the name of 81 * an action as an argument. 82 * The GActionGroup API is meant to be the 'public' API to the action 83 * group. The calls here are exactly the interaction that 'external 84 * forces' (eg: UI, incoming D-Bus messages, etc.) are supposed to have 85 * with actions. 'Internal' APIs (ie: ones meant only to be accessed by 86 * the action group implementation) are found on subclasses. This is 87 * why you will find -- for example -- g_action_group_get_enabled() but 88 * not an equivalent set() call. 89 * Signals are emitted on the action group in response to state changes 90 * on individual actions. 91 */ 92 public template ActionGroupT(TStruct) 93 { 94 95 /** the main Gtk struct */ 96 protected GActionGroup* gActionGroup; 97 98 99 public GActionGroup* getActionGroupTStruct() 100 { 101 return cast(GActionGroup*)getStruct(); 102 } 103 104 105 /** 106 */ 107 int[string] connectedSignals; 108 109 void delegate(string, ActionGroupIF)[] _onActionAddedListeners; 110 void delegate(string, ActionGroupIF)[] onActionAddedListeners() 111 { 112 return _onActionAddedListeners; 113 } 114 /** 115 * Signals that a new action was just added to the group. This signal 116 * is emitted after the action has been added and is now visible. 117 * Since 2.28 118 */ 119 void addOnActionAdded(void delegate(string, ActionGroupIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 120 { 121 if ( !("action-added" in connectedSignals) ) 122 { 123 Signals.connectData( 124 getStruct(), 125 "action-added", 126 cast(GCallback)&callBackActionAdded, 127 cast(void*)cast(ActionGroupIF)this, 128 null, 129 connectFlags); 130 connectedSignals["action-added"] = 1; 131 } 132 _onActionAddedListeners ~= dlg; 133 } 134 extern(C) static void callBackActionAdded(GActionGroup* actionGroupStruct, gchar* actionName, ActionGroupIF _actionGroupIF) 135 { 136 foreach ( void delegate(string, ActionGroupIF) dlg ; _actionGroupIF.onActionAddedListeners ) 137 { 138 dlg(Str.toString(actionName), _actionGroupIF); 139 } 140 } 141 142 void delegate(string, gboolean, ActionGroupIF)[] _onActionEnabledChangedListeners; 143 void delegate(string, gboolean, ActionGroupIF)[] onActionEnabledChangedListeners() 144 { 145 return _onActionEnabledChangedListeners; 146 } 147 /** 148 * Signals that the enabled status of the named action has changed. 149 * Since 2.28 150 */ 151 void addOnActionEnabledChanged(void delegate(string, gboolean, ActionGroupIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 152 { 153 if ( !("action-enabled-changed" in connectedSignals) ) 154 { 155 Signals.connectData( 156 getStruct(), 157 "action-enabled-changed", 158 cast(GCallback)&callBackActionEnabledChanged, 159 cast(void*)cast(ActionGroupIF)this, 160 null, 161 connectFlags); 162 connectedSignals["action-enabled-changed"] = 1; 163 } 164 _onActionEnabledChangedListeners ~= dlg; 165 } 166 extern(C) static void callBackActionEnabledChanged(GActionGroup* actionGroupStruct, gchar* actionName, gboolean enabled, ActionGroupIF _actionGroupIF) 167 { 168 foreach ( void delegate(string, gboolean, ActionGroupIF) dlg ; _actionGroupIF.onActionEnabledChangedListeners ) 169 { 170 dlg(Str.toString(actionName), enabled, _actionGroupIF); 171 } 172 } 173 174 void delegate(string, ActionGroupIF)[] _onActionRemovedListeners; 175 void delegate(string, ActionGroupIF)[] onActionRemovedListeners() 176 { 177 return _onActionRemovedListeners; 178 } 179 /** 180 * Signals that an action is just about to be removed from the group. 181 * This signal is emitted before the action is removed, so the action 182 * is still visible and can be queried from the signal handler. 183 * Since 2.28 184 */ 185 void addOnActionRemoved(void delegate(string, ActionGroupIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 186 { 187 if ( !("action-removed" in connectedSignals) ) 188 { 189 Signals.connectData( 190 getStruct(), 191 "action-removed", 192 cast(GCallback)&callBackActionRemoved, 193 cast(void*)cast(ActionGroupIF)this, 194 null, 195 connectFlags); 196 connectedSignals["action-removed"] = 1; 197 } 198 _onActionRemovedListeners ~= dlg; 199 } 200 extern(C) static void callBackActionRemoved(GActionGroup* actionGroupStruct, gchar* actionName, ActionGroupIF _actionGroupIF) 201 { 202 foreach ( void delegate(string, ActionGroupIF) dlg ; _actionGroupIF.onActionRemovedListeners ) 203 { 204 dlg(Str.toString(actionName), _actionGroupIF); 205 } 206 } 207 208 void delegate(string, Variant, ActionGroupIF)[] _onActionStateChangedListeners; 209 void delegate(string, Variant, ActionGroupIF)[] onActionStateChangedListeners() 210 { 211 return _onActionStateChangedListeners; 212 } 213 /** 214 * Signals that the state of the named action has changed. 215 * Since 2.28 216 */ 217 void addOnActionStateChanged(void delegate(string, Variant, ActionGroupIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 218 { 219 if ( !("action-state-changed" in connectedSignals) ) 220 { 221 Signals.connectData( 222 getStruct(), 223 "action-state-changed", 224 cast(GCallback)&callBackActionStateChanged, 225 cast(void*)cast(ActionGroupIF)this, 226 null, 227 connectFlags); 228 connectedSignals["action-state-changed"] = 1; 229 } 230 _onActionStateChangedListeners ~= dlg; 231 } 232 extern(C) static void callBackActionStateChanged(GActionGroup* actionGroupStruct, gchar* actionName, GVariant* value, ActionGroupIF _actionGroupIF) 233 { 234 foreach ( void delegate(string, Variant, ActionGroupIF) dlg ; _actionGroupIF.onActionStateChangedListeners ) 235 { 236 dlg(Str.toString(actionName), ObjectG.getDObject!(Variant)(value), _actionGroupIF); 237 } 238 } 239 240 241 /** 242 * Checks if the named action exists within action_group. 243 * Since 2.28 244 * Params: 245 * actionName = the name of the action to check for 246 * Returns: whether the named action exists 247 */ 248 public int hasAction(string actionName) 249 { 250 // gboolean g_action_group_has_action (GActionGroup *action_group, const gchar *action_name); 251 return g_action_group_has_action(getActionGroupTStruct(), Str.toStringz(actionName)); 252 } 253 254 /** 255 * Lists the actions contained within action_group. 256 * The caller is responsible for freeing the list with g_strfreev() when 257 * it is no longer required. 258 * Since 2.28 259 * Returns: a NULL-terminated array of the names of the actions in the groupb. [transfer full] 260 */ 261 public string[] listActions() 262 { 263 // gchar ** g_action_group_list_actions (GActionGroup *action_group); 264 return Str.toStringArray(g_action_group_list_actions(getActionGroupTStruct())); 265 } 266 267 /** 268 * Checks if the named action within action_group is currently enabled. 269 * An action must be enabled in order to be activated or in order to 270 * have its state changed from outside callers. 271 * Since 2.28 272 * Params: 273 * actionName = the name of the action to query 274 * Returns: whether or not the action is currently enabled 275 */ 276 public int getActionEnabled(string actionName) 277 { 278 // gboolean g_action_group_get_action_enabled (GActionGroup *action_group, const gchar *action_name); 279 return g_action_group_get_action_enabled(getActionGroupTStruct(), Str.toStringz(actionName)); 280 } 281 282 /** 283 * Queries the type of the parameter that must be given when activating 284 * the named action within action_group. 285 * When activating the action using g_action_group_activate(), the 286 * GVariant given to that function must be of the type returned by this 287 * function. 288 * In the case that this function returns NULL, you must not give any 289 * GVariant, but NULL instead. 290 * The parameter type of a particular action will never change but it is 291 * possible for an action to be removed and for a new action to be added 292 * with the same name but a different parameter type. 293 * Since 2.28 294 * Params: 295 * actionName = the name of the action to query 296 * Returns: the parameter type 297 */ 298 public VariantType getActionParameterType(string actionName) 299 { 300 // const GVariantType * g_action_group_get_action_parameter_type (GActionGroup *action_group, const gchar *action_name); 301 auto p = g_action_group_get_action_parameter_type(getActionGroupTStruct(), Str.toStringz(actionName)); 302 303 if(p is null) 304 { 305 return null; 306 } 307 308 return ObjectG.getDObject!(VariantType)(cast(GVariantType*) p); 309 } 310 311 /** 312 * Queries the type of the state of the named action within 313 * action_group. 314 * If the action is stateful then this function returns the 315 * GVariantType of the state. All calls to g_action_group_set_state() 316 * must give a GVariant of this type and g_action_group_get_state() 317 * will return a GVariant of the same type. 318 * If the action is not stateful then this function will return NULL. 319 * In that case, g_action_group_get_state() will return NULL and you 320 * must not call g_action_group_set_state(). 321 * The state type of a particular action will never change but it is 322 * possible for an action to be removed and for a new action to be added 323 * with the same name but a different state type. 324 * Since 2.28 325 * Params: 326 * actionName = the name of the action to query 327 * Returns: the state type, if the action is stateful. [transfer full] 328 */ 329 public VariantType getActionStateType(string actionName) 330 { 331 // const GVariantType * g_action_group_get_action_state_type (GActionGroup *action_group, const gchar *action_name); 332 auto p = g_action_group_get_action_state_type(getActionGroupTStruct(), Str.toStringz(actionName)); 333 334 if(p is null) 335 { 336 return null; 337 } 338 339 return ObjectG.getDObject!(VariantType)(cast(GVariantType*) p); 340 } 341 342 /** 343 * Requests a hint about the valid range of values for the state of the 344 * named action within action_group. 345 * If NULL is returned it either means that the action is not stateful 346 * or that there is no hint about the valid range of values for the 347 * state of the action. 348 * If a GVariant array is returned then each item in the array is a 349 * possible value for the state. If a GVariant pair (ie: two-tuple) is 350 * returned then the tuple specifies the inclusive lower and upper bound 351 * of valid values for the state. 352 * In any case, the information is merely a hint. It may be possible to 353 * have a state value outside of the hinted range and setting a value 354 * within the range may fail. 355 * The return value (if non-NULL) should be freed with 356 * g_variant_unref() when it is no longer required. 357 * Since 2.28 358 * Params: 359 * actionName = the name of the action to query 360 * Returns: the state range hint. [transfer full] 361 */ 362 public Variant getActionStateHint(string actionName) 363 { 364 // GVariant * g_action_group_get_action_state_hint (GActionGroup *action_group, const gchar *action_name); 365 auto p = g_action_group_get_action_state_hint(getActionGroupTStruct(), Str.toStringz(actionName)); 366 367 if(p is null) 368 { 369 return null; 370 } 371 372 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 373 } 374 375 /** 376 * Queries the current state of the named action within action_group. 377 * If the action is not stateful then NULL will be returned. If the 378 * action is stateful then the type of the return value is the type 379 * given by g_action_group_get_state_type(). 380 * The return value (if non-NULL) should be freed with 381 * g_variant_unref() when it is no longer required. 382 * Since 2.28 383 * Params: 384 * actionName = the name of the action to query 385 * Returns: the current state of the action. [allow-none] 386 */ 387 public Variant getActionState(string actionName) 388 { 389 // GVariant * g_action_group_get_action_state (GActionGroup *action_group, const gchar *action_name); 390 auto p = g_action_group_get_action_state(getActionGroupTStruct(), Str.toStringz(actionName)); 391 392 if(p is null) 393 { 394 return null; 395 } 396 397 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 398 } 399 400 /** 401 * Request for the state of the named action within action_group to be 402 * changed to value. 403 * The action must be stateful and value must be of the correct type. 404 * See g_action_group_get_state_type(). 405 * This call merely requests a change. The action may refuse to change 406 * its state or may change its state to something other than value. 407 * See g_action_group_get_state_hint(). 408 * If the value GVariant is floating, it is consumed. 409 * Since 2.28 410 * Params: 411 * actionName = the name of the action to request the change on 412 * value = the new state 413 */ 414 public void changeActionState(string actionName, Variant value) 415 { 416 // void g_action_group_change_action_state (GActionGroup *action_group, const gchar *action_name, GVariant *value); 417 g_action_group_change_action_state(getActionGroupTStruct(), Str.toStringz(actionName), (value is null) ? null : value.getVariantStruct()); 418 } 419 420 /** 421 * Activate the named action within action_group. 422 * If the action is expecting a parameter, then the correct type of 423 * parameter must be given as parameter. If the action is expecting no 424 * parameters then parameter must be NULL. See 425 * g_action_group_get_parameter_type(). 426 * Since 2.28 427 * Params: 428 * actionName = the name of the action to activate 429 * parameter = parameters to the activation. [allow-none] 430 */ 431 public void activateAction(string actionName, Variant parameter) 432 { 433 // void g_action_group_activate_action (GActionGroup *action_group, const gchar *action_name, GVariant *parameter); 434 g_action_group_activate_action(getActionGroupTStruct(), Str.toStringz(actionName), (parameter is null) ? null : parameter.getVariantStruct()); 435 } 436 437 /** 438 * Emits the "action-added" signal on action_group. 439 * This function should only be called by GActionGroup implementations. 440 * Since 2.28 441 * Params: 442 * actionName = the name of an action in the group 443 */ 444 public void actionAdded(string actionName) 445 { 446 // void g_action_group_action_added (GActionGroup *action_group, const gchar *action_name); 447 g_action_group_action_added(getActionGroupTStruct(), Str.toStringz(actionName)); 448 } 449 450 /** 451 * Emits the "action-removed" signal on action_group. 452 * This function should only be called by GActionGroup implementations. 453 * Since 2.28 454 * Params: 455 * actionName = the name of an action in the group 456 */ 457 public void actionRemoved(string actionName) 458 { 459 // void g_action_group_action_removed (GActionGroup *action_group, const gchar *action_name); 460 g_action_group_action_removed(getActionGroupTStruct(), Str.toStringz(actionName)); 461 } 462 463 /** 464 * Emits the "action-enabled-changed" signal on action_group. 465 * This function should only be called by GActionGroup implementations. 466 * Since 2.28 467 * Params: 468 * actionName = the name of an action in the group 469 * enabled = whether or not the action is now enabled 470 */ 471 public void actionEnabledChanged(string actionName, int enabled) 472 { 473 // void g_action_group_action_enabled_changed (GActionGroup *action_group, const gchar *action_name, gboolean enabled); 474 g_action_group_action_enabled_changed(getActionGroupTStruct(), Str.toStringz(actionName), enabled); 475 } 476 477 /** 478 * Emits the "action-state-changed" signal on action_group. 479 * This function should only be called by GActionGroup implementations. 480 * Since 2.28 481 * Signal Details 482 * The "action-added" signal 483 * void user_function (GActionGroup *action_group, 484 * gchar *action_name, 485 * gpointer user_data) : Has Details 486 * Signals that a new action was just added to the group. This signal 487 * is emitted after the action has been added and is now visible. 488 * Since 2.28 489 * Params: 490 * actionName = the name of an action in the group 491 * state = the new state of the named action 492 * actionName = the name of the action in action_group 493 */ 494 public void actionStateChanged(string actionName, Variant state) 495 { 496 // void g_action_group_action_state_changed (GActionGroup *action_group, const gchar *action_name, GVariant *state); 497 g_action_group_action_state_changed(getActionGroupTStruct(), Str.toStringz(actionName), (state is null) ? null : state.getVariantStruct()); 498 } 499 }