source: appstream-generator/contrib/girwrap/APILookupGObject.txt @ 4841

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

Initial release

File size: 16.8 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#############################################
19### Definitions for wrapping Gtk+ ###########
20#############################################
21
22# must start with wrap
23wrap: gobject
24file: GObject-2.0.gir
25
26addAliases: start
27        public import gi.glibtypes;
28addAliases: end
29
30noAlias: Type
31addEnums: start
32
33        /**
34         * A value which represents the unique identifier of a registered type.
35         */
36        enum GType : size_t
37        {
38                INVALID = 0<<2,
39                NONE = 1<<2,
40                INTERFACE = 2<<2,
41                CHAR = 3<<2,
42                UCHAR = 4<<2,
43                BOOLEAN = 5<<2,
44                INT = 6<<2,
45                UINT = 7<<2,
46                LONG = 8<<2,
47                ULONG = 9<<2,
48                INT64 = 10<<2,
49                UINT64 = 11<<2,
50                ENUM = 12<<2,
51                FLAGS = 13<<2,
52                FLOAT = 14<<2,
53                DOUBLE = 15<<2,
54                STRING = 16<<2,
55                POINTER = 17<<2,
56                BOXED = 18<<2,
57                PARAM = 19<<2,
58                OBJECT = 20<<2,
59                VARIANT = 21<<2,
60        }
61addEnums: end
62
63struct: CClosure
64class: CClosure
65import: glib.ConstructionException
66import: gobject.ObjectG
67noCode: new
68noCode: new_swap
69noCode: new_object
70noCode: new_object_swap
71code: start
72        /**
73         * Creates a new closure which invokes callbackFunc with userData as
74         * the last parameter.
75         *
76         * Params:
77         *     callbackFunc = the function to invoke
78         *     userData = user data to pass to callbackFunc
79         *     destroyData = destroy notify to be called when userData is no longer used
80         *     swap = if true invoce with usrData as the first parameter
81         *
82         * Throws: ConstructionException GTK+ fails to create the object.
83         */
84        public this(GCallback callbackFunc, void* userData, GClosureNotify destroyData, bool swap)
85        {
86                GClosure* p;
87
88                if ( swap )
89                        p = g_cclosure_new_swap(callbackFunc, userData, destroyData);
90                else
91                        p = g_cclosure_new(callbackFunc, userData, destroyData);
92
93                if(p is null)
94                {
95                        throw new ConstructionException("null returned by new");
96                }
97
98                this(cast(GCClosure*) p);
99        }
100
101        /**
102         * A variant of this() which uses object as userData and
103         * calls ObjectG.watchClosure() on object and the created
104         * closure. This function is useful when you have a callback closely
105         * associated with a gobject.ObjectG, and want the callback to no longer run
106         * after the object is is freed.
107         *
108         * Params:
109         *     callbackFunc = the function to invoke
110         *     object = a gobject.ObjectG.ObjectG to pass to callbackFunc
111         *     swap = if true invoce with usrData as the first parameter
112         *
113         * Throws: ConstructionException GTK+ fails to create the object.
114         */
115        public this(GCallback callbackFunc, ObjectG object, bool swap)
116        {
117                GClosure* p;
118
119                if ( swap )
120                        p = g_cclosure_new_object_swap(callbackFunc, (object is null) ? null : object.getObjectGStruct());
121                else
122                        p = g_cclosure_new_object(callbackFunc, (object is null) ? null : object.getObjectGStruct());
123
124                if(p is null)
125                {
126                        throw new ConstructionException("null returned by new_object");
127                }
128
129                this(cast(GCClosure*) p);
130        }
131code: end
132
133struct: Object
134class: ObjectG
135import: core.memory
136import: gobject.Signals
137merge: InitiallyUnowned
138noSignal: notify
139move: clear_object Object
140inout: clear_object object_ptr
141
142code: start
143        protected bool isGcRoot;
144
145        /**
146         * Sets our main struct and passes store it on the gobject.
147         * Add a gabage collector root to the gtk+ struct so it doesn't get collect
148         */
149        public this (GObject* gObject, bool ownedRef = false)
150        {
151                this.gObject = gObject;
152                if ( gObject !is  null )
153                {
154                        setDataFull("GObject", cast(void*)this, cast(GDestroyNotify)&destroyNotify);
155                        addToggleRef(cast(GToggleNotify)&toggleNotify, cast(void*)this);
156
157                        //If the refCount is larger then 1 toggleNotify isn't called
158                        if (gObject.refCount > 1 && !isGcRoot)
159                        {
160                                GC.addRoot(cast(void*)this);
161                                isGcRoot = true;
162                        }
163
164                        //Remove the floating reference if there is one.
165                        if ( isFloating() )
166                        {
167                                refSink();
168                                unref();
169                        }
170                        //If we already owned this reference remove the one added by addToggleRef.
171                        else if ( ownedRef )
172                        {
173                                unref();
174                        }
175
176                        //When constructed via GtkBuilder set the structs.
177                        if ( getStruct() is null)
178                        {
179                                setStruct(gObject);
180                        }
181                }
182        }
183
184        extern(C)
185        {
186                static void destroyNotify(ObjectG obj)
187                {
188                        if ( obj.isGcRoot )
189                        {
190                                GC.removeRoot(cast(void*)obj);
191                                obj.isGcRoot = false;
192                        }
193
194                        obj.gObject = null;
195                }
196
197                static void toggleNotify(ObjectG obj, GObject* object, int isLastRef)
198                {
199                        if ( isLastRef && obj.isGcRoot )
200                        {
201                                GC.removeRoot(cast(void*)obj);
202                                obj.isGcRoot = false;
203                        }
204                        else if ( !obj.isGcRoot )
205                        {
206                                GC.addRoot(cast(void*)obj);
207                                obj.isGcRoot = true;
208                        }
209                }
210        }
211
212        ~this()
213        {
214                if ( gObject !is null )
215                {
216                        // Remove the GDestroyNotify callback,
217                        // for when the D object is destroyed before the C one.
218                        g_object_steal_data(gObject, cast(char*)"GObject");
219
220                        if ( isGcRoot )
221                        {
222                                GC.removeRoot(cast(void*)this);
223                                isGcRoot = false;
224                        }
225
226                        unref();
227                }
228        }
229
230        /**
231         * Gets a D Object from the objects table of associations.
232         * Params:
233         *  obj = GObject containing the associations.
234         * Returns: the D Object if found, or a newly constructed object if no such Object exists.
235         */
236        public static RT getDObject(T, RT=T, U)(U obj, bool ownedRef = false)
237        {
238                if ( obj is null )
239                {
240                        return null;
241                }
242
243                static if ( is(T : ObjectG) )
244                {
245                        auto p = g_object_get_data(cast(GObject*)obj, Str.toStringz("GObject"));
246
247                        if ( p !is null )
248                        {
249                                static if ( is(RT == interface ) )
250                                {
251                                        return cast(RT)cast(ObjectG)p;
252                                }
253                                else
254                                {
255                                        return cast(RT)p;
256                                }
257                        }
258                        else
259                        {
260                                return new T(obj, ownedRef);
261                        }
262                }
263                else
264                {
265                        return new T(obj);
266                }
267        }
268
269        protected void setStruct(GObject* obj)
270        {
271                gObject = cast(GObject*)obj;
272        }
273
274        /** */
275        public void setProperty(string propertyName, int value)
276        {
277                setProperty(propertyName, new Value(value));
278        }
279
280        /** */
281        public void setProperty(string propertyName, string value)
282        {
283                setProperty(propertyName, new Value(value));
284        }
285
286        /** */
287        public void setProperty(string propertyName, long value)
288        {
289                //We use g_object_set instead of g_object_set_property, because Value doesn't like longs and ulongs for some reason.
290                g_object_set( gObject, Str.toStringz(propertyName), value, null);
291        }
292
293        /** */
294        public void setProperty(string propertyName, ulong value)
295        {
296                g_object_set( gObject, Str.toStringz(propertyName), value, null);
297        }
298
299        deprecated("Use the member function")
300        public static void unref(ObjectG obj)
301        {
302                obj.unref();
303        }
304
305        deprecated("Use the member function")
306        public static ObjectG doref(ObjectG obj)
307        {
308                return obj.doref();
309        }
310
311        int[string] connectedSignals;
312
313        void delegate(ParamSpec, ObjectG)[] onNotifyListeners;
314        /**
315         * The notify signal is emitted on an object when one of its
316         * properties has been changed. Note that getting this signal
317         * doesn't guarantee that the value of the property has actually
318         * changed, it may also be emitted when the setter for the property
319         * is called to reinstate the previous value.
320         *
321         * This signal is typically used to obtain change notification for a
322         * single property.
323         *
324         * It is important to note that you must use
325         * canonical parameter names for the property.
326         *
327         * Params:
328         *     dlg          = The callback.
329         *     property     = Set this if you only want to receive the signal for a specific property.
330         *     connectFlags = The behavior of the signal's connection.
331         */
332        void addOnNotify(void delegate(ParamSpec, ObjectG) dlg, string property = "", ConnectFlags connectFlags=cast(ConnectFlags)0)
333        {
334                string signalName;
335
336                if ( property == "" )
337                        signalName = "notify";
338                else
339                        signalName = "notify::"~ property;
340
341                if ( !(signalName in connectedSignals) )
342                {
343                        Signals.connectData(
344                        this,
345                        signalName,
346                        cast(GCallback)&callBackNotify,
347                        cast(void*)this,
348                        null,
349                        connectFlags);
350                        connectedSignals[signalName] = 1;
351                }
352                onNotifyListeners ~= dlg;
353        }
354        extern(C) static void callBackNotify(GObject* gobjectStruct, GParamSpec* pspec, ObjectG _objectG)
355        {
356                foreach ( void delegate(ParamSpec, ObjectG) dlg ; _objectG.onNotifyListeners )
357                {
358                        dlg(ObjectG.getDObject!(ParamSpec)(pspec), _objectG);
359                }
360        }
361code: end
362
363struct: ObjectClass
364merge: InitiallyUnownedClass
365
366struct: ParamSpecBoolean
367noCode: true
368
369struct: ParamSpecBoxed
370noCode: true
371
372struct: ParamSpecChar
373noCode: true
374
375struct: ParamSpecDouble
376noCode: true
377
378struct: ParamSpecEnum
379noCode: true
380
381struct: ParamSpecFlags
382noCode: true
383
384struct: ParamSpecFloat
385noCode: true
386
387struct: ParamSpecGType
388noCode: true
389
390struct: ParamSpecInt
391noCode: true
392
393struct: ParamSpecInt64
394noCode: true
395
396struct: ParamSpecLong
397noCode: true
398
399struct: ParamSpecObject
400noCode: true
401
402struct: ParamSpecOverride
403noCode: true
404
405struct: ParamSpecParam
406noCode: true
407
408struct: ParamSpecPointer
409noCode: true
410
411struct: ParamSpecString
412noCode: true
413
414struct: ParamSpecUChar
415noCode: true
416
417struct: ParamSpecUInt
418noCode: true
419
420struct: ParamSpecUInt64
421noCode: true
422
423struct: ParamSpecULong
424noCode: true
425
426struct: ParamSpecUnichar
427noCode: true
428
429struct: ParamSpecValueArray
430noCode: true
431
432struct: ParamSpecVariant
433noCode: true
434
435struct: Signals
436code: start
437        /** */
438        public static gulong connectData(void* instanc, string detailedSignal, GCallback cHandler, Object data, GClosureNotify destroyData, GConnectFlags connectFlags)
439        {
440                return g_signal_connect_data(instanc, Str.toStringz(detailedSignal), cHandler, cast(void*)data, destroyData, connectFlags);
441        }
442code: end
443
444struct: Type
445import: gobject.ObjectG
446code: start
447        public static T* getInstanceClass(T)(ObjectG obj)
448        {
449                return cast(T*) (cast(GTypeInstance*)obj.getObjectGStruct()).gClass;
450        }
451
452        /**
453         * Get the unique name that is assigned to the Objects type.
454         * Returns: Static type name or NULL.
455         */
456        public static string name(ObjectG obj)
457        {
458                GType type = (cast(GTypeInstance*)obj.getObjectGStruct()).gClass.gType;
459
460                return name(type);
461        }
462code: end
463
464struct:
465class: TypePlugin
466extend: Object
467implements: TypePlugin
468
469struct: Value
470code: start
471        /** */
472        public this()
473        {
474                this(new GValue);
475        }
476
477        /** */
478        this(string value)
479        {
480                this();
481                init(GType.STRING);
482                setString(value);
483        }
484
485        /** */
486        this(int value)
487        {
488                this();
489                init(GType.INT);
490                setInt(value);
491        }
492
493        /** */
494        this(float value)
495        {
496                this();
497                init(GType.FLOAT);
498                setFloat(value);
499        }
500
501        /** */
502        this(double value)
503        {
504                this();
505                init(GType.DOUBLE);
506                setDouble(value);
507        }
508code: end
509
510struct: WeakRef
511code: start
512        /** */
513        this(void* object)
514        {
515                g_weak_ref_init(gWeakRef, object);
516        }
517code: end
518
519#
520# Move functions defined as global into there respective classes
521#
522
523move: boxed_copy Boxed copy
524move: boxed_free Boxed free
525move: boxed_type_register_static Boxed type_register_static
526move: pointer_type_register_static Boxed
527
528move: enum_complete_type_info Enums complete_type_info
529move: enum_get_value Enums get_value
530move: enum_get_value_by_name Enums get_value_by_name
531move: enum_get_value_by_nick Enums get_value_by_nick
532move: enum_register_static Enums register_static
533
534move: flags_complete_type_info Flags complete_type_info
535move: flags_get_first_value Flags get_first_value
536move: flags_get_value_by_name Flags get_value_by_name
537move: flags_get_value_by_nick Flags get_value_by_nick
538move: flags_register_static Flags register_static
539
540# ParamSpec Constructors?
541move: param_spec_boolean Value
542move: param_spec_boxed Value
543move: param_spec_char Value
544move: param_spec_double Value
545move: param_spec_enum Value
546move: param_spec_flags Value
547move: param_spec_float Value
548move: param_spec_gtype Value
549move: param_spec_int Value
550move: param_spec_int64 Value
551move: param_spec_long Value
552move: param_spec_object Value
553move: param_spec_override Value
554move: param_spec_param Value
555move: param_spec_pointer Value
556move: param_spec_string Value
557move: param_spec_uchar Value
558move: param_spec_uint Value
559move: param_spec_uint64 Value
560move: param_spec_ulong Value
561move: param_spec_unichar Value
562move: param_spec_value_array Value
563move: param_spec_variant Value
564
565move: param_type_register_static ParamSpec
566move: param_value_convert ParamSpec
567move: param_value_defaults ParamSpec
568move: param_value_set_default ParamSpec
569move: param_value_validate ParamSpec
570move: param_values_cmp ParamSpec
571
572move: signal_accumulator_first_wins Signals accumulator_first_wins
573move: signal_accumulator_true_handled Signals accumulator_true_handled
574move: signal_add_emission_hook Signals add_emission_hook
575move: signal_chain_from_overridden Signals chain_from_overridden
576move: signal_chain_from_overridden_handler Signals chain_from_overridden_handler
577move: signal_connect_closure Signals connect_closure
578move: signal_connect_closure_by_id Signals connect_closure_by_id
579move: signal_connect_data Signals connect_data
580move: signal_connect_object Signals connect_object
581move: signal_emit Signals emit
582move: signal_emit_by_name Signals emit_by_name
583move: signal_emit_valist Signals emit_valist
584move: signal_emitv Signals emitv
585move: signal_get_invocation_hint Signals get_invocation_hint
586move: signal_handler_block Signals handler_block
587move: signal_handler_disconnect Signals handler_disconnect
588move: signal_handler_find Signals handler_find
589move: signal_handler_is_connected Signals handler_is_connected
590move: signal_handler_unblock Signals handler_unblock
591move: signal_handlers_block_matched Signals handlers_block_matched
592move: signal_handlers_destroy Signals handlers_destroy
593move: signal_handlers_disconnect_matched Signals handlers_disconnect_matched
594move: signal_handlers_unblock_matched Signals handlers_unblock_matched
595move: signal_has_handler_pending Signals has_handler_pending
596move: signal_list_ids Signals list_ids
597move: signal_lookup Signals lookup
598move: signal_name Signals name
599move: signal_new Signals new
600move: signal_new_class_handler Signals new_class_handler
601move: signal_new_valist Signals new_valist
602move: signal_newv Signals newv
603move: signal_override_class_closure Signals override_class_closure
604move: signal_override_class_handler Signals override_class_handler
605move: signal_parse_name Signals parse_name
606move: signal_query Signals query
607move: signal_remove_emission_hook Signals remove_emission_
608move: signal_set_va_marshaller Signals set_va_marshaller
609move: signal_stop_emission Signals stop_emission
610move: signal_stop_emission_by_name Signals stop_emission_by_name
611move: signal_type_cclosure_new Signals type_cclosure_new
612
613move: source_set_closure Closure
614move: source_set_dummy_callback Closure
615
616move: strdup_value_contents Value
617
618move: type_add_class_cache_func Type add_class_cache_func
619move: type_add_class_private Type add_class_private
620move: type_add_instance_private Type add_instance_private
621move: type_add_interface_check Type add_interface_check
622move: type_add_interface_dynamic Type add_interface_dynamic
623move: type_add_interface_static Type add_interface_static
624move: type_check_class_cast Type check_class_cast
625move: type_check_class_is_a Type check_class_is_a
626move: type_check_instance Type check_instance
627move: type_check_instance_cast Type check_instance_cast
628move: type_check_instance_is_a Type check_instance_is_a
629move: type_check_instance_is_fundamentally_a Type check_instance_is_fundamentally_a
630move: type_check_is_value_type Type check_is_value_type
631move: type_check_value Type check_value
632move: type_check_value_holds Type check_value_holds
633move: type_children Type children
634move: type_create_instance Type create_instance
635move: type_default_interface_peek Type default_interface_peek
636move: type_default_interface_ref Type default_interface_ref
637move: type_default_interface_unref Type default_interface_unref
638move: type_depth Type depth
639move: type_ensure Type ensure
640move: type_free_instance Type free_instance
641move: type_from_name Type from_name
642move: type_fundamental Type fundamental
643move: type_fundamental_next Type fundamental_next
644move: type_get_plugin Type get_plugin
645move: type_get_qdata Type get_qdata
646move: type_get_type_registration_serial Type get_type_registration_serial
647move: type_init Type init
648move: type_init_with_debug_flags Type init_with_debug_flags
649move: type_interfaces Type interfaces
650move: type_is_a Type is_a
651move: type_name Type name
652move: type_name_from_class Type name_from_class
653move: type_name_from_instance Type name_from_instance
654move: type_next_base Type next_base
655move: type_parent Type parent
656move: type_qname Type qname
657move: type_query Type query
658move: type_register_dynamic Type register_dynamic
659move: type_register_fundamental Type register_fundamental
660move: type_register_static Type register_static
661move: type_register_static_simple Type register_static_simple
662move: type_remove_class_cache_func Type remove_class_cache_func
663move: type_remove_interface_check Type remove_interface_check
664move: type_set_qdata Type set_qdata
665move: type_test_flags Type test_flags
666#move: type_value_table_peek Type value_table_peek
Note: See TracBrowser for help on using the repository browser.