source: appstream-generator/build/girepo/gobject/TypeModule.d @ 4841

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

Initial release

File size: 7.7 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 gobject.TypeModule;
22
23private import gi.gobject;
24public  import gi.gobjecttypes;
25private import glib.Str;
26private import gobject.ObjectG;
27private import gobject.TypePluginIF;
28private import gobject.TypePluginT;
29
30
31/**
32 * #GTypeModule provides a simple implementation of the #GTypePlugin
33 * interface. The model of #GTypeModule is a dynamically loaded module
34 * which implements some number of types and interface implementations.
35 * When the module is loaded, it registers its types and interfaces
36 * using g_type_module_register_type() and g_type_module_add_interface().
37 * As long as any instances of these types and interface implementations
38 * are in use, the module is kept loaded. When the types and interfaces
39 * are gone, the module may be unloaded. If the types and interfaces
40 * become used again, the module will be reloaded. Note that the last
41 * unref cannot happen in module code, since that would lead to the
42 * caller's code being unloaded before g_object_unref() returns to it.
43 *
44 * Keeping track of whether the module should be loaded or not is done by
45 * using a use count - it starts at zero, and whenever it is greater than
46 * zero, the module is loaded. The use count is maintained internally by
47 * the type system, but also can be explicitly controlled by
48 * g_type_module_use() and g_type_module_unuse(). Typically, when loading
49 * a module for the first type, g_type_module_use() will be used to load
50 * it so that it can initialize its types. At some later point, when the
51 * module no longer needs to be loaded except for the type
52 * implementations it contains, g_type_module_unuse() is called.
53 *
54 * #GTypeModule does not actually provide any implementation of module
55 * loading and unloading. To create a particular module type you must
56 * derive from #GTypeModule and implement the load and unload functions
57 * in #GTypeModuleClass.
58 */
59public class TypeModule : ObjectG, TypePluginIF
60{
61        /** the main Gtk struct */
62        protected GTypeModule* gTypeModule;
63
64        /** Get the main Gtk struct */
65        public GTypeModule* getTypeModuleStruct()
66        {
67                return gTypeModule;
68        }
69
70        /** the main Gtk struct as a void* */
71        protected override void* getStruct()
72        {
73                return cast(void*)gTypeModule;
74        }
75
76        protected override void setStruct(GObject* obj)
77        {
78                gTypeModule = cast(GTypeModule*)obj;
79                super.setStruct(obj);
80        }
81
82        /**
83         * Sets our main struct and passes it to the parent class.
84         */
85        public this (GTypeModule* gTypeModule, bool ownedRef = false)
86        {
87                this.gTypeModule = gTypeModule;
88                super(cast(GObject*)gTypeModule, ownedRef);
89        }
90
91        // add the TypePlugin capabilities
92        mixin TypePluginT!(GTypeModule);
93
94
95        /** */
96        public static GType getType()
97        {
98                return g_type_module_get_type();
99        }
100
101        /**
102         * Registers an additional interface for a type, whose interface lives
103         * in the given type plugin. If the interface was already registered
104         * for the type in this plugin, nothing will be done.
105         *
106         * As long as any instances of the type exist, the type plugin will
107         * not be unloaded.
108         *
109         * Params:
110         *     instanceType = type to which to add the interface.
111         *     interfaceType = interface type to add
112         *     interfaceInfo = type information structure
113         */
114        public void addInterface(GType instanceType, GType interfaceType, GInterfaceInfo* interfaceInfo)
115        {
116                g_type_module_add_interface(gTypeModule, instanceType, interfaceType, interfaceInfo);
117        }
118
119        /**
120         * Looks up or registers an enumeration that is implemented with a particular
121         * type plugin. If a type with name @type_name was previously registered,
122         * the #GType identifier for the type is returned, otherwise the type
123         * is newly registered, and the resulting #GType identifier returned.
124         *
125         * As long as any instances of the type exist, the type plugin will
126         * not be unloaded.
127         *
128         * Params:
129         *     name = name for the type
130         *     constStaticValues = an array of #GEnumValue structs for the
131         *         possible enumeration values. The array is
132         *         terminated by a struct with all members being
133         *         0.
134         *
135         * Returns: the new or existing type ID
136         *
137         * Since: 2.6
138         */
139        public GType registerEnum(string name, GEnumValue* constStaticValues)
140        {
141                return g_type_module_register_enum(gTypeModule, Str.toStringz(name), constStaticValues);
142        }
143
144        /**
145         * Looks up or registers a flags type that is implemented with a particular
146         * type plugin. If a type with name @type_name was previously registered,
147         * the #GType identifier for the type is returned, otherwise the type
148         * is newly registered, and the resulting #GType identifier returned.
149         *
150         * As long as any instances of the type exist, the type plugin will
151         * not be unloaded.
152         *
153         * Params:
154         *     name = name for the type
155         *     constStaticValues = an array of #GFlagsValue structs for the
156         *         possible flags values. The array is
157         *         terminated by a struct with all members being
158         *         0.
159         *
160         * Returns: the new or existing type ID
161         *
162         * Since: 2.6
163         */
164        public GType registerFlags(string name, GFlagsValue* constStaticValues)
165        {
166                return g_type_module_register_flags(gTypeModule, Str.toStringz(name), constStaticValues);
167        }
168
169        /**
170         * Looks up or registers a type that is implemented with a particular
171         * type plugin. If a type with name @type_name was previously registered,
172         * the #GType identifier for the type is returned, otherwise the type
173         * is newly registered, and the resulting #GType identifier returned.
174         *
175         * When reregistering a type (typically because a module is unloaded
176         * then reloaded, and reinitialized), @module and @parent_type must
177         * be the same as they were previously.
178         *
179         * As long as any instances of the type exist, the type plugin will
180         * not be unloaded.
181         *
182         * Params:
183         *     parentType = the type for the parent class
184         *     typeName = name for the type
185         *     typeInfo = type information structure
186         *     flags = flags field providing details about the type
187         *
188         * Returns: the new or existing type ID
189         */
190        public GType registerType(GType parentType, string typeName, GTypeInfo* typeInfo, GTypeFlags flags)
191        {
192                return g_type_module_register_type(gTypeModule, parentType, Str.toStringz(typeName), typeInfo, flags);
193        }
194
195        /**
196         * Sets the name for a #GTypeModule
197         *
198         * Params:
199         *     name = a human-readable name to use in error messages.
200         */
201        public void setName(string name)
202        {
203                g_type_module_set_name(gTypeModule, Str.toStringz(name));
204        }
205
206        /**
207         * Decreases the use count of a #GTypeModule by one. If the
208         * result is zero, the module will be unloaded. (However, the
209         * #GTypeModule will not be freed, and types associated with the
210         * #GTypeModule are not unregistered. Once a #GTypeModule is
211         * initialized, it must exist forever.)
212         */
213        public void unuse()
214        {
215                g_type_module_unuse(gTypeModule);
216        }
217
218        /**
219         * Increases the use count of a #GTypeModule by one. If the
220         * use count was zero before, the plugin will be loaded.
221         * If loading the plugin fails, the use count is reset to
222         * its prior value.
223         *
224         * Returns: %FALSE if the plugin needed to be loaded and
225         *     loading the plugin failed.
226         */
227        public bool use()
228        {
229                return g_type_module_use(gTypeModule) != 0;
230        }
231}
Note: See TracBrowser for help on using the repository browser.