source: appstream-generator/build/girepo/gio/PropertyAction.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 5.2 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.PropertyAction;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.ActionIF;
26private import gio.ActionT;
27private import glib.ConstructionException;
28private import glib.Str;
29private import gobject.ObjectG;
30
31
32/**
33 * A #GPropertyAction is a way to get a #GAction with a state value
34 * reflecting and controlling the value of a #GObject property.
35 *
36 * The state of the action will correspond to the value of the property.
37 * Changing it will change the property (assuming the requested value
38 * matches the requirements as specified in the #GParamSpec).
39 *
40 * Only the most common types are presently supported.  Booleans are
41 * mapped to booleans, strings to strings, signed/unsigned integers to
42 * int32/uint32 and floats and doubles to doubles.
43 *
44 * If the property is an enum then the state will be string-typed and
45 * conversion will automatically be performed between the enum value and
46 * "nick" string as per the #GEnumValue table.
47 *
48 * Flags types are not currently supported.
49 *
50 * Properties of object types, boxed types and pointer types are not
51 * supported and probably never will be.
52 *
53 * Properties of #GVariant types are not currently supported.
54 *
55 * If the property is boolean-valued then the action will have a NULL
56 * parameter type, and activating the action (with no parameter) will
57 * toggle the value of the property.
58 *
59 * In all other cases, the parameter type will correspond to the type of
60 * the property.
61 *
62 * The general idea here is to reduce the number of locations where a
63 * particular piece of state is kept (and therefore has to be synchronised
64 * between). #GPropertyAction does not have a separate state that is kept
65 * in sync with the property value -- its state is the property value.
66 *
67 * For example, it might be useful to create a #GAction corresponding to
68 * the "visible-child-name" property of a #GtkStack so that the current
69 * page can be switched from a menu.  The active radio indication in the
70 * menu is then directly determined from the active page of the
71 * #GtkStack.
72 *
73 * An anti-example would be binding the "active-id" property on a
74 * #GtkComboBox.  This is because the state of the combobox itself is
75 * probably uninteresting and is actually being used to control
76 * something else.
77 *
78 * Another anti-example would be to bind to the "visible-child-name"
79 * property of a #GtkStack if this value is actually stored in
80 * #GSettings.  In that case, the real source of the value is
81 * #GSettings.  If you want a #GAction to control a setting stored in
82 * #GSettings, see g_settings_create_action() instead, and possibly
83 * combine its use with g_settings_bind().
84 *
85 * Since: 2.38
86 */
87public class PropertyAction : ObjectG, ActionIF
88{
89        /** the main Gtk struct */
90        protected GPropertyAction* gPropertyAction;
91
92        /** Get the main Gtk struct */
93        public GPropertyAction* getPropertyActionStruct()
94        {
95                return gPropertyAction;
96        }
97
98        /** the main Gtk struct as a void* */
99        protected override void* getStruct()
100        {
101                return cast(void*)gPropertyAction;
102        }
103
104        protected override void setStruct(GObject* obj)
105        {
106                gPropertyAction = cast(GPropertyAction*)obj;
107                super.setStruct(obj);
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}
Note: See TracBrowser for help on using the repository browser.