Imported Upstream version 2.50.2
[platform/upstream/glib.git] / docs / reference / gio / html / GPropertyAction.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>GPropertyAction: GIO Reference Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="application.html" title="Application support">
9 <link rel="prev" href="GSimpleAction.html" title="GSimpleAction">
10 <link rel="next" href="GRemoteActionGroup.html" title="GRemoteActionGroup">
11 <meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
16 <td width="100%" align="left" class="shortcuts">
17 <a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
18                   <a href="#GPropertyAction.description" class="shortcut">Description</a></span><span id="nav_hierarchy">  <span class="dim">|</span> 
19                   <a href="#GPropertyAction.object-hierarchy" class="shortcut">Object Hierarchy</a></span><span id="nav_interfaces">  <span class="dim">|</span> 
20                   <a href="#GPropertyAction.implemented-interfaces" class="shortcut">Implemented Interfaces</a></span><span id="nav_properties">  <span class="dim">|</span> 
21                   <a href="#GPropertyAction.properties" class="shortcut">Properties</a></span>
22 </td>
23 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
24 <td><a accesskey="u" href="application.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
25 <td><a accesskey="p" href="GSimpleAction.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
26 <td><a accesskey="n" href="GRemoteActionGroup.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
27 </tr></table>
28 <div class="refentry">
29 <a name="GPropertyAction"></a><div class="titlepage"></div>
30 <div class="refnamediv"><table width="100%"><tr>
31 <td valign="top">
32 <h2><span class="refentrytitle"><a name="GPropertyAction.top_of_page"></a>GPropertyAction</span></h2>
33 <p>GPropertyAction — A GAction reflecting a GObject property</p>
34 </td>
35 <td class="gallery_image" valign="top" align="right"></td>
36 </tr></table></div>
37 <div class="refsect1">
38 <a name="GPropertyAction.functions"></a><h2>Functions</h2>
39 <div class="informaltable"><table class="informaltable" width="100%" border="0">
40 <colgroup>
41 <col width="150px" class="functions_return">
42 <col class="functions_name">
43 </colgroup>
44 <tbody><tr>
45 <td class="function_type">
46 <a class="link" href="GPropertyAction.html" title="GPropertyAction"><span class="returnvalue">GPropertyAction</span></a> *
47 </td>
48 <td class="function_name">
49 <a class="link" href="GPropertyAction.html#g-property-action-new" title="g_property_action_new ()">g_property_action_new</a> <span class="c_punctuation">()</span>
50 </td>
51 </tr></tbody>
52 </table></div>
53 </div>
54 <div class="refsect1">
55 <a name="GPropertyAction.properties"></a><h2>Properties</h2>
56 <div class="informaltable"><table class="informaltable" border="0">
57 <colgroup>
58 <col width="150px" class="properties_type">
59 <col width="300px" class="properties_name">
60 <col width="200px" class="properties_flags">
61 </colgroup>
62 <tbody>
63 <tr>
64 <td class="property_type"><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></td>
65 <td class="property_name"><a class="link" href="GPropertyAction.html#GPropertyAction--enabled" title="The “enabled” property">enabled</a></td>
66 <td class="property_flags">Read</td>
67 </tr>
68 <tr>
69 <td class="property_type"><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></td>
70 <td class="property_name"><a class="link" href="GPropertyAction.html#GPropertyAction--invert-boolean" title="The “invert-boolean” property">invert-boolean</a></td>
71 <td class="property_flags">Read / Write / Construct Only</td>
72 </tr>
73 <tr>
74 <td class="property_type">
75 <a href="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *</td>
76 <td class="property_name"><a class="link" href="GPropertyAction.html#GPropertyAction--name" title="The “name” property">name</a></td>
77 <td class="property_flags">Read / Write / Construct Only</td>
78 </tr>
79 <tr>
80 <td class="property_type">
81 <a href="../gobject-The-Base-Object-Type.html#GObject-struct"><span class="type">GObject</span></a> *</td>
82 <td class="property_name"><a class="link" href="GPropertyAction.html#GPropertyAction--object" title="The “object” property">object</a></td>
83 <td class="property_flags">Write / Construct Only</td>
84 </tr>
85 <tr>
86 <td class="property_type">
87 <a href="../glib-GVariantType.html#GVariantType"><span class="type">GVariantType</span></a> *</td>
88 <td class="property_name"><a class="link" href="GPropertyAction.html#GPropertyAction--parameter-type" title="The “parameter-type” property">parameter-type</a></td>
89 <td class="property_flags">Read</td>
90 </tr>
91 <tr>
92 <td class="property_type">
93 <a href="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *</td>
94 <td class="property_name"><a class="link" href="GPropertyAction.html#GPropertyAction--property-name" title="The “property-name” property">property-name</a></td>
95 <td class="property_flags">Write / Construct Only</td>
96 </tr>
97 <tr>
98 <td class="property_type">
99 <a href="../glib-GVariant.html#GVariant"><span class="type">GVariant</span></a> *</td>
100 <td class="property_name"><a class="link" href="GPropertyAction.html#GPropertyAction--state" title="The “state” property">state</a></td>
101 <td class="property_flags">Read</td>
102 </tr>
103 <tr>
104 <td class="property_type">
105 <a href="../glib-GVariantType.html#GVariantType"><span class="type">GVariantType</span></a> *</td>
106 <td class="property_name"><a class="link" href="GPropertyAction.html#GPropertyAction--state-type" title="The “state-type” property">state-type</a></td>
107 <td class="property_flags">Read</td>
108 </tr>
109 </tbody>
110 </table></div>
111 </div>
112 <div class="refsect1">
113 <a name="GPropertyAction.other"></a><h2>Types and Values</h2>
114 <div class="informaltable"><table class="informaltable" width="100%" border="0">
115 <colgroup>
116 <col width="150px" class="name">
117 <col class="description">
118 </colgroup>
119 <tbody><tr>
120 <td class="datatype_keyword"> </td>
121 <td class="function_name"><a class="link" href="GPropertyAction.html#GPropertyAction-struct" title="GPropertyAction">GPropertyAction</a></td>
122 </tr></tbody>
123 </table></div>
124 </div>
125 <div class="refsect1">
126 <a name="GPropertyAction.object-hierarchy"></a><h2>Object Hierarchy</h2>
127 <pre class="screen">    <a href="../gobject-The-Base-Object-Type.html#GObject-struct">GObject</a>
128     <span class="lineart">╰──</span> GPropertyAction
129 </pre>
130 </div>
131 <div class="refsect1">
132 <a name="GPropertyAction.implemented-interfaces"></a><h2>Implemented Interfaces</h2>
133 <p>
134 GPropertyAction implements
135  <a class="link" href="GAction.html" title="GAction">GAction</a>.</p>
136 </div>
137 <div class="refsect1">
138 <a name="GPropertyAction.includes"></a><h2>Includes</h2>
139 <pre class="synopsis">#include &lt;gio/gio.h&gt;
140 </pre>
141 </div>
142 <div class="refsect1">
143 <a name="GPropertyAction.description"></a><h2>Description</h2>
144 <p>A <a class="link" href="GPropertyAction.html" title="GPropertyAction"><span class="type">GPropertyAction</span></a> is a way to get a <a class="link" href="GAction.html" title="GAction"><span class="type">GAction</span></a> with a state value
145 reflecting and controlling the value of a <a href="../gobject-The-Base-Object-Type.html#GObject-struct"><span class="type">GObject</span></a> property.</p>
146 <p>The state of the action will correspond to the value of the property.
147 Changing it will change the property (assuming the requested value
148 matches the requirements as specified in the <a href="../gobject-GParamSpec.html#GParamSpec"><span class="type">GParamSpec</span></a>).</p>
149 <p>Only the most common types are presently supported.  Booleans are
150 mapped to booleans, strings to strings, signed/unsigned integers to
151 int32/uint32 and floats and doubles to doubles.</p>
152 <p>If the property is an enum then the state will be string-typed and
153 conversion will automatically be performed between the enum value and
154 "nick" string as per the <a href="../gobject-Enumeration-and-Flag-Types.html#GEnumValue"><span class="type">GEnumValue</span></a> table.</p>
155 <p>Flags types are not currently supported.</p>
156 <p>Properties of object types, boxed types and pointer types are not
157 supported and probably never will be.</p>
158 <p>Properties of <a href="../glib-GVariant.html#GVariant"><span class="type">GVariant</span></a> types are not currently supported.</p>
159 <p>If the property is boolean-valued then the action will have a NULL
160 parameter type, and activating the action (with no parameter) will
161 toggle the value of the property.</p>
162 <p>In all other cases, the parameter type will correspond to the type of
163 the property.</p>
164 <p>The general idea here is to reduce the number of locations where a
165 particular piece of state is kept (and therefore has to be synchronised
166 between). <a class="link" href="GPropertyAction.html" title="GPropertyAction"><span class="type">GPropertyAction</span></a> does not have a separate state that is kept
167 in sync with the property value -- its state is the property value.</p>
168 <p>For example, it might be useful to create a <a class="link" href="GAction.html" title="GAction"><span class="type">GAction</span></a> corresponding to
169 the "visible-child-name" property of a <a href="http://developer.gnome.org/gtk4/GtkStack.html#GtkStack-struct"><span class="type">GtkStack</span></a> so that the current
170 page can be switched from a menu.  The active radio indication in the
171 menu is then directly determined from the active page of the
172 <a href="http://developer.gnome.org/gtk4/GtkStack.html#GtkStack-struct"><span class="type">GtkStack</span></a>.</p>
173 <p>An anti-example would be binding the "active-id" property on a
174 <a href="http://developer.gnome.org/gtk4/GtkComboBox.html#GtkComboBox-struct"><span class="type">GtkComboBox</span></a>.  This is because the state of the combobox itself is
175 probably uninteresting and is actually being used to control
176 something else.</p>
177 <p>Another anti-example would be to bind to the "visible-child-name"
178 property of a <a href="http://developer.gnome.org/gtk4/GtkStack.html#GtkStack-struct"><span class="type">GtkStack</span></a> if this value is actually stored in
179 <a class="link" href="GSettings.html" title="GSettings"><span class="type">GSettings</span></a>.  In that case, the real source of the value is
180 <a class="link" href="GSettings.html" title="GSettings"><span class="type">GSettings</span></a>.  If you want a <a class="link" href="GAction.html" title="GAction"><span class="type">GAction</span></a> to control a setting stored in
181 <a class="link" href="GSettings.html" title="GSettings"><span class="type">GSettings</span></a>, see <a class="link" href="GSettings.html#g-settings-create-action" title="g_settings_create_action ()"><code class="function">g_settings_create_action()</code></a> instead, and possibly
182 combine its use with <a class="link" href="GSettings.html#g-settings-bind" title="g_settings_bind ()"><code class="function">g_settings_bind()</code></a>.</p>
183 </div>
184 <div class="refsect1">
185 <a name="GPropertyAction.functions_details"></a><h2>Functions</h2>
186 <div class="refsect2">
187 <a name="g-property-action-new"></a><h3>g_property_action_new ()</h3>
188 <pre class="programlisting"><a class="link" href="GPropertyAction.html" title="GPropertyAction"><span class="returnvalue">GPropertyAction</span></a> *
189 g_property_action_new (<em class="parameter"><code>const <a href="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *name</code></em>,
190                        <em class="parameter"><code><a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> object</code></em>,
191                        <em class="parameter"><code>const <a href="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *property_name</code></em>);</pre>
192 <p>Creates a <a class="link" href="GAction.html" title="GAction"><span class="type">GAction</span></a> corresponding to the value of property
193 <em class="parameter"><code>property_name</code></em>
194  on <em class="parameter"><code>object</code></em>
195 .</p>
196 <p>The property must be existent and readable and writable (and not
197 construct-only).</p>
198 <p>This function takes a reference on <em class="parameter"><code>object</code></em>
199  and doesn't release it
200 until the action is destroyed.</p>
201 <div class="refsect3">
202 <a name="g-property-action-new.parameters"></a><h4>Parameters</h4>
203 <div class="informaltable"><table class="informaltable" width="100%" border="0">
204 <colgroup>
205 <col width="150px" class="parameters_name">
206 <col class="parameters_description">
207 <col width="200px" class="parameters_annotations">
208 </colgroup>
209 <tbody>
210 <tr>
211 <td class="parameter_name"><p>name</p></td>
212 <td class="parameter_description"><p>the name of the action to create</p></td>
213 <td class="parameter_annotations"> </td>
214 </tr>
215 <tr>
216 <td class="parameter_name"><p>object</p></td>
217 <td class="parameter_description"><p> the object that has the property
218 to wrap. </p></td>
219 <td class="parameter_annotations"><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> GObject.Object]</span></td>
220 </tr>
221 <tr>
222 <td class="parameter_name"><p>property_name</p></td>
223 <td class="parameter_description"><p>the name of the property</p></td>
224 <td class="parameter_annotations"> </td>
225 </tr>
226 </tbody>
227 </table></div>
228 </div>
229 <div class="refsect3">
230 <a name="g-property-action-new.returns"></a><h4>Returns</h4>
231 <p> a new <a class="link" href="GPropertyAction.html" title="GPropertyAction"><span class="type">GPropertyAction</span></a></p>
232 </div>
233 <p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
234 </div>
235 </div>
236 <div class="refsect1">
237 <a name="GPropertyAction.other_details"></a><h2>Types and Values</h2>
238 <div class="refsect2">
239 <a name="GPropertyAction-struct"></a><h3>GPropertyAction</h3>
240 <pre class="programlisting">typedef struct _GPropertyAction GPropertyAction;</pre>
241 <p>This type is opaque.</p>
242 <p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
243 </div>
244 </div>
245 <div class="refsect1">
246 <a name="GPropertyAction.property-details"></a><h2>Property Details</h2>
247 <div class="refsect2">
248 <a name="GPropertyAction--enabled"></a><h3>The <code class="literal">“enabled”</code> property</h3>
249 <pre class="programlisting">  “enabled”                  <a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></pre>
250 <p>If <em class="parameter"><code>action</code></em>
251  is currently enabled.</p>
252 <p>If the action is disabled then calls to <a class="link" href="GAction.html#g-action-activate" title="g_action_activate ()"><code class="function">g_action_activate()</code></a> and
253 <a class="link" href="GAction.html#g-action-change-state" title="g_action_change_state ()"><code class="function">g_action_change_state()</code></a> have no effect.</p>
254 <p>Flags: Read</p>
255 <p>Default value: TRUE</p>
256 <p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
257 </div>
258 <hr>
259 <div class="refsect2">
260 <a name="GPropertyAction--invert-boolean"></a><h3>The <code class="literal">“invert-boolean”</code> property</h3>
261 <pre class="programlisting">  “invert-boolean”           <a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></pre>
262 <p>If <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, the state of the action will be the negation of the
263 property value, provided the property is boolean.</p>
264 <p>Flags: Read / Write / Construct Only</p>
265 <p>Default value: FALSE</p>
266 <p class="since">Since: <a class="link" href="api-index-2-46.html#api-index-2.46">2.46</a></p>
267 </div>
268 <hr>
269 <div class="refsect2">
270 <a name="GPropertyAction--name"></a><h3>The <code class="literal">“name”</code> property</h3>
271 <pre class="programlisting">  “name”                     <a href="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *</pre>
272 <p>The name of the action.  This is mostly meaningful for identifying
273 the action once it has been added to a <a class="link" href="GActionMap.html" title="GActionMap"><span class="type">GActionMap</span></a>.</p>
274 <p>Flags: Read / Write / Construct Only</p>
275 <p>Default value: NULL</p>
276 <p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
277 </div>
278 <hr>
279 <div class="refsect2">
280 <a name="GPropertyAction--object"></a><h3>The <code class="literal">“object”</code> property</h3>
281 <pre class="programlisting">  “object”                   <a href="../gobject-The-Base-Object-Type.html#GObject-struct"><span class="type">GObject</span></a> *</pre>
282 <p>The object to wrap a property on.</p>
283 <p>The object must be a non-<a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> <a href="../gobject-The-Base-Object-Type.html#GObject-struct"><span class="type">GObject</span></a> with properties.</p>
284 <p>Flags: Write / Construct Only</p>
285 <p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
286 </div>
287 <hr>
288 <div class="refsect2">
289 <a name="GPropertyAction--parameter-type"></a><h3>The <code class="literal">“parameter-type”</code> property</h3>
290 <pre class="programlisting">  “parameter-type”           <a href="../glib-GVariantType.html#GVariantType"><span class="type">GVariantType</span></a> *</pre>
291 <p>The type of the parameter that must be given when activating the
292 action.</p>
293 <p>Flags: Read</p>
294 <p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
295 </div>
296 <hr>
297 <div class="refsect2">
298 <a name="GPropertyAction--property-name"></a><h3>The <code class="literal">“property-name”</code> property</h3>
299 <pre class="programlisting">  “property-name”            <a href="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *</pre>
300 <p>The name of the property to wrap on the object.</p>
301 <p>The property must exist on the passed-in object and it must be
302 readable and writable (and not construct-only).</p>
303 <p>Flags: Write / Construct Only</p>
304 <p>Default value: NULL</p>
305 <p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
306 </div>
307 <hr>
308 <div class="refsect2">
309 <a name="GPropertyAction--state"></a><h3>The <code class="literal">“state”</code> property</h3>
310 <pre class="programlisting">  “state”                    <a href="../glib-GVariant.html#GVariant"><span class="type">GVariant</span></a> *</pre>
311 <p>The state of the action, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the action is stateless.</p>
312 <p>Flags: Read</p>
313 <p>Allowed values: GVariant&lt;*&gt;</p>
314 <p>Default value: NULL</p>
315 <p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
316 </div>
317 <hr>
318 <div class="refsect2">
319 <a name="GPropertyAction--state-type"></a><h3>The <code class="literal">“state-type”</code> property</h3>
320 <pre class="programlisting">  “state-type”               <a href="../glib-GVariantType.html#GVariantType"><span class="type">GVariantType</span></a> *</pre>
321 <p>The <a href="../glib-GVariantType.html#GVariantType"><span class="type">GVariantType</span></a> of the state that the action has, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the
322 action is stateless.</p>
323 <p>Flags: Read</p>
324 <p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
325 </div>
326 </div>
327 </div>
328 <div class="footer">
329 <hr>Generated by GTK-Doc V1.25.1</div>
330 </body>
331 </html>