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