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.PropertyAction; 26 27 private import gio.ActionIF; 28 private import gio.ActionT; 29 private import gio.c.functions; 30 public import gio.c.types; 31 private import glib.ConstructionException; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 public import gtkc.giotypes; 35 36 37 /** 38 * A #GPropertyAction is a way to get a #GAction with a state value 39 * reflecting and controlling the value of a #GObject property. 40 * 41 * The state of the action will correspond to the value of the property. 42 * Changing it will change the property (assuming the requested value 43 * matches the requirements as specified in the #GParamSpec). 44 * 45 * Only the most common types are presently supported. Booleans are 46 * mapped to booleans, strings to strings, signed/unsigned integers to 47 * int32/uint32 and floats and doubles to doubles. 48 * 49 * If the property is an enum then the state will be string-typed and 50 * conversion will automatically be performed between the enum value and 51 * "nick" string as per the #GEnumValue table. 52 * 53 * Flags types are not currently supported. 54 * 55 * Properties of object types, boxed types and pointer types are not 56 * supported and probably never will be. 57 * 58 * Properties of #GVariant types are not currently supported. 59 * 60 * If the property is boolean-valued then the action will have a NULL 61 * parameter type, and activating the action (with no parameter) will 62 * toggle the value of the property. 63 * 64 * In all other cases, the parameter type will correspond to the type of 65 * the property. 66 * 67 * The general idea here is to reduce the number of locations where a 68 * particular piece of state is kept (and therefore has to be synchronised 69 * between). #GPropertyAction does not have a separate state that is kept 70 * in sync with the property value -- its state is the property value. 71 * 72 * For example, it might be useful to create a #GAction corresponding to 73 * the "visible-child-name" property of a #GtkStack so that the current 74 * page can be switched from a menu. The active radio indication in the 75 * menu is then directly determined from the active page of the 76 * #GtkStack. 77 * 78 * An anti-example would be binding the "active-id" property on a 79 * #GtkComboBox. This is because the state of the combobox itself is 80 * probably uninteresting and is actually being used to control 81 * something else. 82 * 83 * Another anti-example would be to bind to the "visible-child-name" 84 * property of a #GtkStack if this value is actually stored in 85 * #GSettings. In that case, the real source of the value is 86 * #GSettings. If you want a #GAction to control a setting stored in 87 * #GSettings, see g_settings_create_action() instead, and possibly 88 * combine its use with g_settings_bind(). 89 * 90 * Since: 2.38 91 */ 92 public class PropertyAction : ObjectG, ActionIF 93 { 94 /** the main Gtk struct */ 95 protected GPropertyAction* gPropertyAction; 96 97 /** Get the main Gtk struct */ 98 public GPropertyAction* getPropertyActionStruct(bool transferOwnership = false) 99 { 100 if (transferOwnership) 101 ownedRef = false; 102 return gPropertyAction; 103 } 104 105 /** the main Gtk struct as a void* */ 106 protected override void* getStruct() 107 { 108 return cast(void*)gPropertyAction; 109 } 110 111 /** 112 * Sets our main struct and passes it to the parent class. 113 */ 114 public this (GPropertyAction* gPropertyAction, bool ownedRef = false) 115 { 116 this.gPropertyAction = gPropertyAction; 117 super(cast(GObject*)gPropertyAction, ownedRef); 118 } 119 120 // add the Action capabilities 121 mixin ActionT!(GPropertyAction); 122 123 124 /** */ 125 public static GType getType() 126 { 127 return g_property_action_get_type(); 128 } 129 130 /** 131 * Creates a #GAction corresponding to the value of property 132 * @property_name on @object. 133 * 134 * The property must be existent and readable and writable (and not 135 * construct-only). 136 * 137 * This function takes a reference on @object and doesn't release it 138 * until the action is destroyed. 139 * 140 * Params: 141 * name = the name of the action to create 142 * object = the object that has the property 143 * to wrap 144 * propertyName = the name of the property 145 * 146 * Returns: a new #GPropertyAction 147 * 148 * Since: 2.38 149 * 150 * Throws: ConstructionException GTK+ fails to create the object. 151 */ 152 public this(string name, ObjectG object, string propertyName) 153 { 154 auto p = g_property_action_new(Str.toStringz(name), (object is null) ? null : object.getObjectGStruct(), Str.toStringz(propertyName)); 155 156 if(p is null) 157 { 158 throw new ConstructionException("null returned by new"); 159 } 160 161 this(cast(GPropertyAction*) p, true); 162 } 163 }