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 
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(bool transferOwnership = false)
98 	{
99 		if (transferOwnership)
100 			ownedRef = false;
101 		return gPropertyAction;
102 	}
103 
104 	/** the main Gtk struct as a void* */
105 	protected override void* getStruct()
106 	{
107 		return cast(void*)gPropertyAction;
108 	}
109 
110 	/**
111 	 * Sets our main struct and passes it to the parent class.
112 	 */
113 	public this (GPropertyAction* gPropertyAction, bool ownedRef = false)
114 	{
115 		this.gPropertyAction = gPropertyAction;
116 		super(cast(GObject*)gPropertyAction, ownedRef);
117 	}
118 
119 	// add the Action capabilities
120 	mixin ActionT!(GPropertyAction);
121 
122 
123 	/** */
124 	public static GType getType()
125 	{
126 		return g_property_action_get_type();
127 	}
128 
129 	/**
130 	 * Creates a #GAction corresponding to the value of property
131 	 * @property_name on @object.
132 	 *
133 	 * The property must be existent and readable and writable (and not
134 	 * construct-only).
135 	 *
136 	 * This function takes a reference on @object and doesn't release it
137 	 * until the action is destroyed.
138 	 *
139 	 * Params:
140 	 *     name = the name of the action to create
141 	 *     object = the object that has the property
142 	 *         to wrap
143 	 *     propertyName = the name of the property
144 	 *
145 	 * Returns: a new #GPropertyAction
146 	 *
147 	 * Since: 2.38
148 	 *
149 	 * Throws: ConstructionException GTK+ fails to create the object.
150 	 */
151 	public this(string name, ObjectG object, string propertyName)
152 	{
153 		auto __p = g_property_action_new(Str.toStringz(name), (object is null) ? null : object.getObjectGStruct(), Str.toStringz(propertyName));
154 
155 		if(__p is null)
156 		{
157 			throw new ConstructionException("null returned by new");
158 		}
159 
160 		this(cast(GPropertyAction*) __p, true);
161 	}
162 }