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