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 module gio.ActionGroupIF; 26 27 private import gio.c.functions; 28 public import gio.c.types; 29 private import glib.Str; 30 private import glib.Variant; 31 private import glib.VariantType; 32 private import glib.c.functions; 33 private import gobject.Signals; 34 private import std.algorithm; 35 36 37 /** 38 * #GActionGroup represents a group of actions. Actions can be used to 39 * expose functionality in a structured way, either from one part of a 40 * program to another, or to the outside world. Action groups are often 41 * used together with a #GMenuModel that provides additional 42 * representation data for displaying the actions to the user, e.g. in 43 * a menu. 44 * 45 * The main way to interact with the actions in a GActionGroup is to 46 * activate them with g_action_group_activate_action(). Activating an 47 * action may require a #GVariant parameter. The required type of the 48 * parameter can be inquired with g_action_group_get_action_parameter_type(). 49 * Actions may be disabled, see g_action_group_get_action_enabled(). 50 * Activating a disabled action has no effect. 51 * 52 * Actions may optionally have a state in the form of a #GVariant. The 53 * current state of an action can be inquired with 54 * g_action_group_get_action_state(). Activating a stateful action may 55 * change its state, but it is also possible to set the state by calling 56 * g_action_group_change_action_state(). 57 * 58 * As typical example, consider a text editing application which has an 59 * option to change the current font to 'bold'. A good way to represent 60 * this would be a stateful action, with a boolean state. Activating the 61 * action would toggle the state. 62 * 63 * Each action in the group has a unique name (which is a string). All 64 * method calls, except g_action_group_list_actions() take the name of 65 * an action as an argument. 66 * 67 * The #GActionGroup API is meant to be the 'public' API to the action 68 * group. The calls here are exactly the interaction that 'external 69 * forces' (eg: UI, incoming D-Bus messages, etc.) are supposed to have 70 * with actions. 'Internal' APIs (ie: ones meant only to be accessed by 71 * the action group implementation) are found on subclasses. This is 72 * why you will find - for example - g_action_group_get_action_enabled() 73 * but not an equivalent set() call. 74 * 75 * Signals are emitted on the action group in response to state changes 76 * on individual actions. 77 * 78 * Implementations of #GActionGroup should provide implementations for 79 * the virtual functions g_action_group_list_actions() and 80 * g_action_group_query_action(). The other virtual functions should 81 * not be implemented - their "wrappers" are actually implemented with 82 * calls to g_action_group_query_action(). 83 */ 84 public interface ActionGroupIF{ 85 /** Get the main Gtk struct */ 86 public GActionGroup* getActionGroupStruct(bool transferOwnership = false); 87 88 /** the main Gtk struct as a void* */ 89 protected void* getStruct(); 90 91 92 /** */ 93 public static GType getType() 94 { 95 return g_action_group_get_type(); 96 } 97 98 /** 99 * Emits the #GActionGroup::action-added signal on @action_group. 100 * 101 * This function should only be called by #GActionGroup implementations. 102 * 103 * Params: 104 * actionName = the name of an action in the group 105 * 106 * Since: 2.28 107 */ 108 public void actionAdded(string actionName); 109 110 /** 111 * Emits the #GActionGroup::action-enabled-changed signal on @action_group. 112 * 113 * This function should only be called by #GActionGroup implementations. 114 * 115 * Params: 116 * actionName = the name of an action in the group 117 * enabled = whether or not the action is now enabled 118 * 119 * Since: 2.28 120 */ 121 public void actionEnabledChanged(string actionName, bool enabled); 122 123 /** 124 * Emits the #GActionGroup::action-removed signal on @action_group. 125 * 126 * This function should only be called by #GActionGroup implementations. 127 * 128 * Params: 129 * actionName = the name of an action in the group 130 * 131 * Since: 2.28 132 */ 133 public void actionRemoved(string actionName); 134 135 /** 136 * Emits the #GActionGroup::action-state-changed signal on @action_group. 137 * 138 * This function should only be called by #GActionGroup implementations. 139 * 140 * Params: 141 * actionName = the name of an action in the group 142 * state = the new state of the named action 143 * 144 * Since: 2.28 145 */ 146 public void actionStateChanged(string actionName, Variant state); 147 148 /** 149 * Activate the named action within @action_group. 150 * 151 * If the action is expecting a parameter, then the correct type of 152 * parameter must be given as @parameter. If the action is expecting no 153 * parameters then @parameter must be %NULL. See 154 * g_action_group_get_action_parameter_type(). 155 * 156 * If the #GActionGroup implementation supports asynchronous remote 157 * activation over D-Bus, this call may return before the relevant 158 * D-Bus traffic has been sent, or any replies have been received. In 159 * order to block on such asynchronous activation calls, 160 * g_dbus_connection_flush() should be called prior to the code, which 161 * depends on the result of the action activation. Without flushing 162 * the D-Bus connection, there is no guarantee that the action would 163 * have been activated. 164 * 165 * The following code which runs in a remote app instance, shows an 166 * example of a "quit" action being activated on the primary app 167 * instance over D-Bus. Here g_dbus_connection_flush() is called 168 * before `exit()`. Without g_dbus_connection_flush(), the "quit" action 169 * may fail to be activated on the primary instance. 170 * 171 * |[<!-- language="C" --> 172 * // call "quit" action on primary instance 173 * g_action_group_activate_action (G_ACTION_GROUP (app), "quit", NULL); 174 * 175 * // make sure the action is activated now 176 * g_dbus_connection_flush (...); 177 * 178 * g_debug ("application has been terminated. exiting."); 179 * 180 * exit (0); 181 * ]| 182 * 183 * Params: 184 * actionName = the name of the action to activate 185 * parameter = parameters to the activation 186 * 187 * Since: 2.28 188 */ 189 public void activateAction(string actionName, Variant parameter); 190 191 /** 192 * Request for the state of the named action within @action_group to be 193 * changed to @value. 194 * 195 * The action must be stateful and @value must be of the correct type. 196 * See g_action_group_get_action_state_type(). 197 * 198 * This call merely requests a change. The action may refuse to change 199 * its state or may change its state to something other than @value. 200 * See g_action_group_get_action_state_hint(). 201 * 202 * If the @value GVariant is floating, it is consumed. 203 * 204 * Params: 205 * actionName = the name of the action to request the change on 206 * value = the new state 207 * 208 * Since: 2.28 209 */ 210 public void changeActionState(string actionName, Variant value); 211 212 /** 213 * Checks if the named action within @action_group is currently enabled. 214 * 215 * An action must be enabled in order to be activated or in order to 216 * have its state changed from outside callers. 217 * 218 * Params: 219 * actionName = the name of the action to query 220 * 221 * Returns: whether or not the action is currently enabled 222 * 223 * Since: 2.28 224 */ 225 public bool getActionEnabled(string actionName); 226 227 /** 228 * Queries the type of the parameter that must be given when activating 229 * the named action within @action_group. 230 * 231 * When activating the action using g_action_group_activate_action(), 232 * the #GVariant given to that function must be of the type returned 233 * by this function. 234 * 235 * In the case that this function returns %NULL, you must not give any 236 * #GVariant, but %NULL instead. 237 * 238 * The parameter type of a particular action will never change but it is 239 * possible for an action to be removed and for a new action to be added 240 * with the same name but a different parameter type. 241 * 242 * Params: 243 * actionName = the name of the action to query 244 * 245 * Returns: the parameter type 246 * 247 * Since: 2.28 248 */ 249 public VariantType getActionParameterType(string actionName); 250 251 /** 252 * Queries the current state of the named action within @action_group. 253 * 254 * If the action is not stateful then %NULL will be returned. If the 255 * action is stateful then the type of the return value is the type 256 * given by g_action_group_get_action_state_type(). 257 * 258 * The return value (if non-%NULL) should be freed with 259 * g_variant_unref() when it is no longer required. 260 * 261 * Params: 262 * actionName = the name of the action to query 263 * 264 * Returns: the current state of the action 265 * 266 * Since: 2.28 267 */ 268 public Variant getActionState(string actionName); 269 270 /** 271 * Requests a hint about the valid range of values for the state of the 272 * named action within @action_group. 273 * 274 * If %NULL is returned it either means that the action is not stateful 275 * or that there is no hint about the valid range of values for the 276 * state of the action. 277 * 278 * If a #GVariant array is returned then each item in the array is a 279 * possible value for the state. If a #GVariant pair (ie: two-tuple) is 280 * returned then the tuple specifies the inclusive lower and upper bound 281 * of valid values for the state. 282 * 283 * In any case, the information is merely a hint. It may be possible to 284 * have a state value outside of the hinted range and setting a value 285 * within the range may fail. 286 * 287 * The return value (if non-%NULL) should be freed with 288 * g_variant_unref() when it is no longer required. 289 * 290 * Params: 291 * actionName = the name of the action to query 292 * 293 * Returns: the state range hint 294 * 295 * Since: 2.28 296 */ 297 public Variant getActionStateHint(string actionName); 298 299 /** 300 * Queries the type of the state of the named action within 301 * @action_group. 302 * 303 * If the action is stateful then this function returns the 304 * #GVariantType of the state. All calls to 305 * g_action_group_change_action_state() must give a #GVariant of this 306 * type and g_action_group_get_action_state() will return a #GVariant 307 * of the same type. 308 * 309 * If the action is not stateful then this function will return %NULL. 310 * In that case, g_action_group_get_action_state() will return %NULL 311 * and you must not call g_action_group_change_action_state(). 312 * 313 * The state type of a particular action will never change but it is 314 * possible for an action to be removed and for a new action to be added 315 * with the same name but a different state type. 316 * 317 * Params: 318 * actionName = the name of the action to query 319 * 320 * Returns: the state type, if the action is stateful 321 * 322 * Since: 2.28 323 */ 324 public VariantType getActionStateType(string actionName); 325 326 /** 327 * Checks if the named action exists within @action_group. 328 * 329 * Params: 330 * actionName = the name of the action to check for 331 * 332 * Returns: whether the named action exists 333 * 334 * Since: 2.28 335 */ 336 public bool hasAction(string actionName); 337 338 /** 339 * Lists the actions contained within @action_group. 340 * 341 * The caller is responsible for freeing the list with g_strfreev() when 342 * it is no longer required. 343 * 344 * Returns: a %NULL-terminated array of the names of the 345 * actions in the group 346 * 347 * Since: 2.28 348 */ 349 public string[] listActions(); 350 351 /** 352 * Queries all aspects of the named action within an @action_group. 353 * 354 * This function acquires the information available from 355 * g_action_group_has_action(), g_action_group_get_action_enabled(), 356 * g_action_group_get_action_parameter_type(), 357 * g_action_group_get_action_state_type(), 358 * g_action_group_get_action_state_hint() and 359 * g_action_group_get_action_state() with a single function call. 360 * 361 * This provides two main benefits. 362 * 363 * The first is the improvement in efficiency that comes with not having 364 * to perform repeated lookups of the action in order to discover 365 * different things about it. The second is that implementing 366 * #GActionGroup can now be done by only overriding this one virtual 367 * function. 368 * 369 * The interface provides a default implementation of this function that 370 * calls the individual functions, as required, to fetch the 371 * information. The interface also provides default implementations of 372 * those functions that call this function. All implementations, 373 * therefore, must override either this function or all of the others. 374 * 375 * If the action exists, %TRUE is returned and any of the requested 376 * fields (as indicated by having a non-%NULL reference passed in) are 377 * filled. If the action doesn't exist, %FALSE is returned and the 378 * fields may or may not have been modified. 379 * 380 * Params: 381 * actionName = the name of an action in the group 382 * enabled = if the action is presently enabled 383 * parameterType = the parameter type, or %NULL if none needed 384 * stateType = the state type, or %NULL if stateless 385 * stateHint = the state hint, or %NULL if none 386 * state = the current state, or %NULL if stateless 387 * 388 * Returns: %TRUE if the action exists, else %FALSE 389 * 390 * Since: 2.32 391 */ 392 public bool queryAction(string actionName, out bool enabled, out VariantType parameterType, out VariantType stateType, out Variant stateHint, out Variant state); 393 394 /** 395 * Signals that a new action was just added to the group. 396 * This signal is emitted after the action has been added 397 * and is now visible. 398 * 399 * Params: 400 * actionName = the name of the action in @action_group 401 * 402 * Since: 2.28 403 */ 404 gulong addOnActionAdded(void delegate(string, ActionGroupIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 405 406 /** 407 * Signals that the enabled status of the named action has changed. 408 * 409 * Params: 410 * actionName = the name of the action in @action_group 411 * enabled = whether the action is enabled or not 412 * 413 * Since: 2.28 414 */ 415 gulong addOnActionEnabledChanged(void delegate(string, bool, ActionGroupIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 416 417 /** 418 * Signals that an action is just about to be removed from the group. 419 * This signal is emitted before the action is removed, so the action 420 * is still visible and can be queried from the signal handler. 421 * 422 * Params: 423 * actionName = the name of the action in @action_group 424 * 425 * Since: 2.28 426 */ 427 gulong addOnActionRemoved(void delegate(string, ActionGroupIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 428 429 /** 430 * Signals that the state of the named action has changed. 431 * 432 * Params: 433 * actionName = the name of the action in @action_group 434 * value = the new value of the state 435 * 436 * Since: 2.28 437 */ 438 gulong addOnActionStateChanged(void delegate(string, Variant, ActionGroupIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 439 }