3 * Copyright (C) 2006-2010 Jürg Billeter
4 * Copyright (C) 2006-2008 Raffaele Sandrini
5 * Copyright (C) 2007 Mathias Hasselmann
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 * Jürg Billeter <j@bitron.ch>
23 * Raffaele Sandrini <rasa@gmx.ch>
24 * Mathias Hasselmann <mathias.hasselmann@gmx.de>
27 [CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h", gir_namespace = "GObject", gir_version = "2.0")]
29 [CCode (type_id = "G_TYPE_GTYPE", marshaller_type_name = "GTYPE", get_value_function = "g_value_get_gtype", set_value_function = "g_value_set_gtype")]
30 public struct Type : ulong {
31 [CCode (cname = "G_TYPE_IS_OBJECT")]
32 public bool is_object ();
33 [CCode (cname = "G_TYPE_IS_ABSTRACT")]
34 public bool is_abstract ();
35 [CCode (cname = "G_TYPE_IS_CLASSED")]
36 public bool is_classed ();
37 [CCode (cname = "G_TYPE_IS_DERIVABLE")]
38 public bool is_derivable ();
39 [CCode (cname = "G_TYPE_IS_DEEP_DERIVABLE")]
40 public bool is_deep_derivable ();
41 [CCode (cname = "G_TYPE_IS_DERIVED")]
42 public bool is_derived ();
43 [CCode (cname = "G_TYPE_IS_FUNDAMENTAL")]
44 public bool is_fundamental ();
45 [CCode (cname = "G_TYPE_IS_INSTANTIATABLE")]
46 public bool is_instantiatable ();
47 [CCode (cname = "G_TYPE_IS_INTERFACE")]
48 public bool is_interface ();
49 [CCode (cname = "G_TYPE_IS_VALUE_TYPE")]
50 public bool is_value_type ();
51 [CCode (cname = "G_TYPE_IS_ENUM")]
52 public bool is_enum ();
53 [CCode (cname = "G_TYPE_IS_FLAGS")]
54 public bool is_flags ();
56 [CCode (cname = "G_TYPE_FROM_INSTANCE")]
57 public static Type from_instance (void* instance);
59 public Type[] children ();
61 public static Type from_name (string name);
62 public Type[] interfaces ();
63 public bool is_a (Type is_a_type);
64 public unowned string name ();
65 public Quark qname ();
66 public Type parent ();
68 public void query (out TypeQuery query);
70 public TypeClass class_ref ();
71 public unowned TypeClass class_peek ();
73 public const Type INVALID;
74 public const Type INTERFACE;
75 public const Type ENUM;
76 public const Type FLAGS;
77 public const Type BOXED;
80 public struct TypeQuery {
82 public unowned string type_name;
83 public uint class_size;
84 public uint instance_size;
88 [CCode (ref_function = "g_type_class_ref", unref_function = "g_type_class_unref")]
89 public class TypeClass {
90 [CCode (cname = "G_TYPE_FROM_CLASS")]
91 public Type get_type ();
94 [CCode (cprefix = "G_TYPE_DEBUG_", has_type_id = false)]
95 public enum TypeDebugFlags {
102 public interface TypePlugin {
105 [CCode (lower_case_csuffix = "type_module")]
106 public class TypeModule : Object, TypePlugin {
107 [CCode (has_construct_function = false)]
108 protected TypeModule ();
110 public void unuse ();
111 public void set_name (string name);
113 public virtual bool load ();
115 public virtual void unload ();
118 [CCode (type_id = "G_TYPE_PARAM", ref_function = "g_param_spec_ref", unref_function = "g_param_spec_unref", param_spec_function = "g_param_spec_param", get_value_function = "g_value_get_param", set_value_function = "g_value_set_param", take_value_function = "g_value_take_param")]
119 public class ParamSpec {
121 public ParamFlags flags;
122 public Type value_type;
123 public Type owner_type;
124 public ParamSpec.internal (string name, string nick, string blurb);
125 public ParamSpec ref ();
126 public void unref ();
128 public ParamSpec ref_sink ();
129 [CCode (cname = "g_param_value_set_default")]
130 public void set_value_default (Value value);
131 [CCode (cname = "g_param_value_defaults")]
132 public bool value_defaults (Value value);
133 [CCode (cname = "g_param_value_validate")]
134 public bool value_validate (Value value);
135 [CCode (cname = "g_param_value_convert")]
136 public bool value_convert (Value src_value, Value dest_value, bool strict_validation);
137 [CCode (cname = "g_param_values_cmp")]
138 public int values_cmp (Value value1, Value value2);
139 public unowned string get_blurb ();
140 public unowned string get_name ();
141 public unowned string get_nick ();
142 public void* get_qdata (Quark quark);
143 public void set_qdata (Quark quark, void* data);
144 public void set_qdata_full (Quark quark, void* data, DestroyNotify destroy);
145 public void* steal_qdata (Quark quark);
146 public ParamSpec get_redirect_target ();
149 public class ParamSpecBoolean : ParamSpec {
150 [CCode (cname = "g_param_spec_boolean")]
151 public ParamSpecBoolean (string name, string nick, string blurb, bool defaultvalue, ParamFlags flags);
152 public bool default_value;
155 public class ParamSpecChar : ParamSpec {
156 [CCode (cname = "g_param_spec_char")]
157 public ParamSpecChar (string name, string nick, string blurb, int8 minimum, int8 maximum, int8 default_value, ParamFlags flags);
160 public int8 default_value;
163 public class ParamSpecUChar : ParamSpec {
164 [CCode (cname = "g_param_spec_uchar")]
165 public ParamSpecUChar (string name, string nick, string blurb, uint8 minimum, uint8 maximum, uint8 default_value, ParamFlags flags);
166 public uint8 minimum;
167 public uint8 maximum;
168 public uint8 default_value;
171 public class ParamSpecInt : ParamSpec {
172 [CCode (cname = "g_param_spec_int")]
173 public ParamSpecInt (string name, string nick, string blurb, int minimum, int maximum, int default_value, ParamFlags flags);
176 public int default_value;
179 public class ParamSpecUInt : ParamSpec {
180 [CCode (cname = "g_param_spec_uint")]
181 public ParamSpecUInt (string name, string nick, string blurb, uint minimum, uint maximum, uint default_value, ParamFlags flags);
184 public uint default_value;
187 public class ParamSpecLong : ParamSpec {
188 [CCode (cname = "g_param_spec_long")]
189 public ParamSpecLong (string name, string nick, string blurb, long minimum, long maximum, long default_value, ParamFlags flags);
192 public long default_value;
195 public class ParamSpecULong : ParamSpec {
196 [CCode (cname = "g_param_spec_ulong")]
197 public ParamSpecULong (string name, string nick, string blurb, ulong minimum, ulong maximum, ulong default_value, ParamFlags flags);
198 public ulong minimum;
199 public ulong maximum;
200 public ulong default_value;
203 public class ParamSpecInt64 : ParamSpec {
204 [CCode (cname = "g_param_spec_int64")]
205 public ParamSpecInt64 (string name, string nick, string blurb, int64 minimum, int64 maximum, int64 default_value, ParamFlags flags);
206 public int64 minimum;
207 public int64 maximum;
208 public int64 default_value;
211 public class ParamSpecUInt64 : ParamSpec {
212 [CCode (cname = "g_param_spec_uint64")]
213 public ParamSpecUInt64 (string name, string nick, string blurb, uint64 minimum, uint64 maximum, uint64 default_value, ParamFlags flags);
214 public uint64 minimum;
215 public uint64 maximum;
216 public uint64 default_value;
219 public class ParamSpecFloat : ParamSpec {
220 [CCode (cname = "g_param_spec_float")]
221 public ParamSpecFloat (string name, string nick, string blurb, float minimum, float maximum, float default_value, ParamFlags flags);
222 public float minimum;
223 public float maximum;
224 public float default_value;
227 public class ParamSpecDouble : ParamSpec {
228 [CCode (cname = "g_param_spec_double")]
229 public ParamSpecDouble (string name, string nick, string blurb, double minimum, double maximum, double default_value, ParamFlags flags);
230 public double minimum;
231 public double maximum;
232 public double default_value;
235 public class ParamSpecEnum : ParamSpec {
236 [CCode (cname = "g_param_spec_enum")]
237 public ParamSpecEnum (string name, string nick, string blurb, Type enum_type, int default_value, ParamFlags flags);
238 public unowned EnumClass enum_class;
239 public int default_value;
242 public class ParamSpecFlags : ParamSpec {
243 [CCode (cname = "g_param_spec_flags")]
244 public ParamSpecFlags (string name, string nick, string blurb, Type flags_type, uint default_value, ParamFlags flags);
245 public unowned FlagsClass flags_class;
246 public uint default_value;
249 public class ParamSpecString : ParamSpec {
250 [CCode (cname = "g_param_spec_string")]
251 public ParamSpecString (string name, string nick, string blurb, string default_value, ParamFlags flags);
252 public string default_value;
253 public string cset_first;
254 public string cset_nth;
255 public char substitutor;
256 public uint null_fold_if_empty;
257 public uint ensure_non_null;
260 public class ParamSpecParam : ParamSpec {
261 [CCode (cname = "g_param_spec_param")]
262 public ParamSpecParam (string name, string nick, string blurb, Type param_type, ParamFlags flags);
265 [CCode (cprefix = "G_PARAM_", has_type_id = false)]
266 public enum ParamFlags {
279 [CCode (lower_case_csuffix = "object_class")]
280 public class ObjectClass : TypeClass {
281 public unowned ParamSpec? find_property (string property_name);
282 [CCode (array_length_type = "guint")]
283 public unowned ParamSpec[] list_properties ();
284 public void install_property (uint property_id, ParamSpec pspec);
287 public struct ObjectConstructParam {
291 [CCode (cprefix = "G_BINDING_")]
292 public enum BindingFlags {
299 public delegate bool BindingTransformFunc (GLib.Binding binding, GLib.Value source_value, GLib.Value target_value);
301 public class Binding : GLib.Object {
302 public weak GLib.Object source { get; }
303 public string source_property { get; }
304 public weak GLib.Object target { get; }
305 public string target_property { get; }
306 public GLib.BindingFlags flags { get; }
309 [CCode (has_target = false)]
310 public delegate void ObjectGetPropertyFunc (Object object, uint property_id, Value value, ParamSpec pspec);
311 [CCode (has_target = false)]
312 public delegate void ObjectSetPropertyFunc (Object object, uint property_id, Value value, ParamSpec pspec);
313 [CCode (instance_pos = 0)]
314 public delegate void WeakNotify (Object object);
316 [CCode (ref_function = "g_object_ref", unref_function = "g_object_unref", marshaller_type_name = "OBJECT", get_value_function = "g_value_get_object", set_value_function = "g_value_set_object", take_value_function = "g_value_take_object", param_spec_function = "g_param_spec_object", cheader_filename = "glib-object.h")]
317 public class Object {
318 public uint ref_count;
320 [CCode (has_new_function = false, construct_function = "g_object_new")]
323 public static Object @new (Type type, ...);
324 public static Object newv (Type type, [CCode (array_length_pos = 1.9)] Parameter[] parameters);
326 [CCode (cname = "G_TYPE_FROM_INSTANCE")]
327 public Type get_type ();
328 [CCode (cname = "G_OBJECT_GET_CLASS")]
329 public unowned ObjectClass get_class ();
330 public unowned Object @ref ();
331 public void unref ();
332 public Object ref_sink ();
333 public void weak_ref (WeakNotify notify);
334 public void weak_unref (WeakNotify notify);
335 public void add_weak_pointer (void **data);
336 public void remove_weak_pointer (void **data);
337 public void get (string first_property_name, ...);
338 public void set (string first_property_name, ...);
339 public void get_property (string property_name, ref Value value);
340 public void set_property (string property_name, Value value);
341 [CCode (simple_generics = true)]
342 public unowned T get_data<T> (string key);
343 [CCode (cname = "g_object_set_data_full", simple_generics = true)]
344 public void set_data<T> (string key, owned T data);
345 public void set_data_full (string key, void* data, DestroyNotify? destroy);
346 [CCode (simple_generics = true)]
347 public T steal_data<T> (string key);
348 [CCode (simple_generics = true)]
349 public unowned T get_qdata<T> (Quark quark);
350 [CCode (cname = "g_object_set_qdata_full", simple_generics = true)]
351 public void set_qdata<T> (Quark quark, owned T data);
352 public void set_qdata_full (Quark quark, void* data, DestroyNotify? destroy);
353 [CCode (simple_generics = true)]
354 public T steal_qdata<T> (Quark quark);
355 public void freeze_notify ();
356 public void thaw_notify ();
357 [CCode (cname = "g_object_run_dispose")]
358 public virtual void dispose ();
359 public virtual void constructed ();
361 public signal void notify (ParamSpec pspec);
362 [CCode (cname = "g_object_notify")]
363 public void notify_property (string property_name);
365 public unowned Object connect (string signal_spec, ...);
366 [CCode (cname = "g_signal_handler_disconnect")]
367 public void disconnect (ulong handler_id);
369 public void add_toggle_ref (ToggleNotify notify);
370 public void remove_toggle_ref (ToggleNotify notify);
372 [CCode (cname = "g_object_bind_property_with_closures")]
373 public unowned GLib.Binding bind_property (string source_property, GLib.Object target, string target_property, GLib.BindingFlags flags, [CCode (type = "GClosure*")] owned GLib.BindingTransformFunc? transform_to = null, [CCode (type = "GClosure*")] owned GLib.BindingTransformFunc? transform_from = null);
376 [CCode (instance_pos = 0)]
377 public delegate void ToggleNotify (GLib.Object object, bool is_last_ref);
379 [CCode (has_copy_function = false, has_destroy_function = false)]
380 public struct Parameter {
381 public unowned string name;
385 [CCode (ref_sink_function = "g_object_ref_sink")]
386 public class InitiallyUnowned : Object {
387 [CCode (has_construct_function = false)]
388 protected InitiallyUnowned ();
391 [CCode (lower_case_csuffix = "enum")]
392 public class EnumClass : TypeClass {
393 public unowned EnumValue? get_value (int value);
394 public unowned EnumValue? get_value_by_name (string name);
395 public unowned EnumValue? get_value_by_nick (string name);
398 public uint n_values;
399 [CCode (array_length_cname = "n_values")]
400 public unowned EnumValue[] values;
404 public class EnumValue {
406 public unowned string value_name;
407 public unowned string value_nick;
410 [CCode (lower_case_csuffix = "flags")]
411 public class FlagsClass : TypeClass {
412 public unowned FlagsValue? get_first_value (uint value);
413 public unowned FlagsValue? get_value_by_name (string name);
414 public unowned FlagsValue? get_value_by_nick (string name);
416 public uint n_values;
417 [CCode (array_length_cname = "n_values")]
418 public FlagsValue[] values;
422 public class FlagsValue {
424 public unowned string value_name;
425 public unowned string value_nick;
428 [CCode (has_target = false)]
429 public delegate void ValueTransform (Value src_value, out Value dest_value);
431 [CCode (copy_function = "g_value_copy", destroy_function = "g_value_unset", type_id = "G_TYPE_VALUE", marshaller_type_name = "BOXED", get_value_function = "g_value_get_boxed", set_value_function = "g_value_set_boxed", take_value_function = "g_value_take_boxed", type_signature = "v")]
432 public struct Value {
433 [CCode (cname = "G_VALUE_HOLDS")]
434 public bool holds (Type type);
435 [CCode (cname = "G_VALUE_TYPE")]
437 [CCode (cname = "G_VALUE_TYPE_NAME")]
438 public unowned string type_name ();
440 public Value (Type g_type);
441 public void copy (ref Value dest_value);
442 public unowned Value? reset ();
443 public void init (Type g_type);
444 public void unset ();
445 public void set_instance (void* instance);
446 public bool fits_pointer ();
447 public void* peek_pointer ();
448 public static bool type_compatible (Type src_type, Type dest_type);
449 public static bool type_transformable (Type src_type, Type dest_type);
450 public bool transform (ref Value dest_value);
451 [CCode (cname = "g_strdup_value_contents")]
452 public string strdup_contents ();
453 public static void register_transform_func (Type src_type, Type dest_type, ValueTransform transform);
454 public void set_boolean (bool v_boolean);
455 public bool get_boolean ();
456 public void set_char (char v_char);
457 public char get_char ();
458 public void set_uchar (uchar v_uchar);
459 public uchar get_uchar ();
460 public void set_int (int v_int);
461 public int get_int ();
462 public void set_uint (uint v_uint);
463 public uint get_uint ();
464 public void set_long (long v_long);
465 public long get_long ();
466 public void set_ulong (ulong v_ulong);
467 public ulong get_ulong ();
468 public void set_int64 (int64 v_int64);
469 public int64 get_int64 ();
470 public void set_uint64 (uint64 v_uint64);
471 public uint64 get_uint64 ();
472 public void set_float (float v_float);
473 public float get_float ();
474 public void set_double (double v_double);
475 public double get_double ();
476 public void set_enum (int v_enum);
477 public int get_enum ();
478 public void set_flags (uint v_flags);
479 public uint get_flags ();
480 public void set_string (string v_string);
481 public void set_static_string (string v_string);
482 public void take_string (owned string v_string);
483 public unowned string get_string ();
484 public string dup_string ();
485 public void set_pointer (void* v_pointer);
486 public void* get_pointer ();
487 public void set_boxed (void* v_boxed);
488 public void* get_boxed ();
489 public void* dup_boxed ();
490 public void set_object (Object v_object);
491 public void take_object (owned Object v_object);
492 public unowned Object get_object ();
493 public Object dup_object ();
494 public void set_gtype (Type v_gtype);
495 public Type get_gtype ();
496 public void set_param(ParamSpec param);
497 public ParamSpec get_param();
498 public void take_param(out ParamSpec param);
499 public void param_take_ownership(out ParamSpec param);
502 public struct SignalInvocationHint {
503 public uint signal_id;
505 public SignalFlags run_type;
508 public delegate bool SignalEmissionHook (SignalInvocationHint ihint, [CCode (array_length_pos = 1.9)] Value[] param_values);
510 [CCode (cprefix = "G_SIGNAL_", has_type_id = false)]
511 public enum SignalFlags {
520 [CCode (cprefix = "G_CONNECT_", has_type_id = false)]
521 public enum ConnectFlags {
526 [CCode (has_target = false)]
527 public delegate void Callback ();
530 [CCode (ref_function = "g_closure_ref", unref_function = "g_closure_unref", type_id = "G_TYPE_CLOSURE")]
531 public class Closure {
533 public void invoke (out Value? return_value, [CCode (array_length_pos = 1.9)] Value[] param_values, void *invocation_hint);
534 public void invalidate ();
535 public void add_finalize_notifier (void *notify_data, ClosureNotify notify_func);
536 public void add_invalidate_notifier (void *notify_data, ClosureNotify notify_func);
537 public void remove_finalize_notifier (void *notify_data, ClosureNotify notify_func);
538 public void remove_invalidate_notifier (void *notify_data, ClosureNotify notify_func);
539 [CCode (cname = "g_closure_new_object")]
540 public Closure (ulong sizeof_closure, Object object);
541 public void set_marshal (ClosureMarshal marshal);
542 public void add_marshal_guards (void *pre_marshal_data, ClosureNotify pre_marshal_notify, void *post_marshal_data, ClosureNotify post_marshal_notify);
543 public void set_meta_marshal (void *marshal_data, ClosureMarshal meta_marshal);
546 [CCode (has_target = false)]
547 public delegate void ClosureNotify (void* data, Closure closure);
549 [CCode (instance_pos = 0, has_target = false)]
550 public delegate void ClosureMarshal (Closure closure, out Value return_value, [CCode (array_length_pos = 2.9)] Value[] param_values, void *invocation_hint, void *marshal_data);
553 [CCode (type_id = "G_TYPE_VALUE_ARRAY", copy_function = "g_value_array_copy", free_function = "g_value_array_free")]
554 public class ValueArray {
555 public uint n_values;
556 [CCode (array_length_cname = "n_values", array_length_type = "guint")]
557 public Value[] values;
558 public ValueArray (uint n_prealloced);
559 public ValueArray copy ();
560 public unowned Value? get_nth (uint index_);
561 public void append (Value value);
562 public void prepend (Value value);
563 public void insert (uint index_, Value value);
564 public void remove (uint index_);
565 public void sort (CompareFunc compare_func);
566 public void sort_with_data (CompareDataFunc compare_func);
570 public static void query (uint signal_id, out SignalQuery query);
571 public static uint lookup (string name, Type itype);
572 public static unowned string name (uint signal_id);
573 public static uint[] list_ids (Type itype);
574 public static void emit (void* instance, uint signal_id, Quark detail, ...);
575 public static void emit_by_name (void* instance, string detailed_signal, ...);
576 public static ulong connect (void* instance, string detailed_signal, Callback handler, void* data);
577 public static ulong connect_after (void* instance, string detailed_signal, Callback handler, void* data);
578 public static ulong connect_swapped (void* instance, string detailed_signal, Callback handler, void* data);
579 public static ulong connect_object (void* instance, string detailed_signal, Callback handler, Object gobject, ConnectFlags flags);
580 public static ulong connect_data (void* instance, string detailed_signal, Callback handler, void* data, ClosureNotify destroy_data, ConnectFlags flags);
581 public static ulong connect_closure (void* instance, string detailed_signal, Closure closure, bool after);
582 public static ulong connect_closure_by_id (void* instance, uint signal_id, Quark detail, Closure closure, bool after);
583 public static bool has_handler_pending (void* instance, uint signal_id, Quark detail, bool may_be_blocked);
584 public static void stop_emission (void* instance, uint signal_id, Quark detail);
585 public static void stop_emission_by_name (void* instance, string detailed_signal);
586 public static void override_class_closure (uint signal_id, Type instance_type, Closure class_closure);
587 public static void chain_from_overridden ([CCode (array_length = false)] Value[] instance_and_params, out Value return_value);
588 public static ulong add_emission_hook (uint signal_id, Quark detail, SignalEmissionHook hook_func, DestroyNotify? data_destroy);
589 public static void remove_emission_hook (uint signal_id, ulong hook_id);
590 public static bool parse_name (string detailed_signal, Type itype, out uint signal_id, out Quark detail, bool force_detail_quark);
593 namespace SignalHandler {
594 public static void block (void* instance, ulong handler_id);
595 public static void unblock (void* instance, ulong handler_id);
596 public static void disconnect (void* instance, ulong handler_id);
597 public static ulong find (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
598 public static bool is_connected (void* instance, ulong handler_id);
600 [CCode (cname = "g_signal_handlers_block_matched")]
601 public static uint block_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
602 [CCode (cname = "g_signal_handlers_unblock_matched")]
603 public static uint unblock_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
604 [CCode (cname = "g_signal_handlers_disconnect_matched")]
605 public static uint disconnect_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
606 [CCode (cname = "g_signal_handlers_block_by_func")]
607 public static uint block_by_func (void* instance, void* func, void* data);
608 [CCode (cname = "g_signal_handlers_unblock_by_func")]
609 public static uint unblock_by_func (void* instance, void* func, void* data);
610 [CCode (cname = "g_signal_handlers_disconnect_by_func")]
611 public static uint disconnect_by_func (void* instance, void* func, void* data);
614 public struct SignalQuery {
615 public uint signal_id;
616 public unowned string signal_name;
618 public SignalFlags signal_flags;
619 public Type return_type;
620 public uint n_params;
621 [CCode (array_length = false)]
622 public unowned Type[] param_types;
625 [CCode (cprefix = "G_SIGNAL_MATCH_", has_type_id = false)]
626 public enum SignalMatchType {