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