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 [CCode (array_length_type = "guint")]
63 public Type[] interfaces ();
64 public bool is_a (Type is_a_type);
65 public unowned string name ();
66 public Quark qname ();
67 public Type parent ();
69 public void query (out TypeQuery query);
71 public TypeClass class_ref ();
72 public unowned TypeClass class_peek ();
74 public const Type INVALID;
75 public const Type INTERFACE;
76 public const Type ENUM;
77 public const Type FLAGS;
78 public const Type BOXED;
81 public struct TypeQuery {
83 public unowned string type_name;
84 public uint class_size;
85 public uint instance_size;
89 [CCode (ref_function = "g_type_class_ref", unref_function = "g_type_class_unref")]
90 public class TypeClass {
91 [CCode (cname = "G_TYPE_FROM_CLASS")]
92 public Type get_type ();
95 [CCode (cprefix = "G_TYPE_DEBUG_", has_type_id = false)]
96 public enum TypeDebugFlags {
103 public interface TypePlugin {
106 [CCode (lower_case_csuffix = "type_module")]
107 public class TypeModule : Object, TypePlugin {
108 [CCode (has_construct_function = false)]
109 protected TypeModule ();
111 public void unuse ();
112 public void set_name (string name);
114 public virtual bool load ();
116 public virtual void unload ();
119 [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")]
120 public class ParamSpec {
122 public ParamFlags flags;
123 public Type value_type;
124 public Type owner_type;
125 public ParamSpec.internal (string name, string nick, string blurb);
126 public ParamSpec ref ();
127 public void unref ();
129 public ParamSpec ref_sink ();
130 [CCode (cname = "g_param_value_set_default")]
131 public void set_value_default (Value value);
132 [CCode (cname = "g_param_value_defaults")]
133 public bool value_defaults (Value value);
134 [CCode (cname = "g_param_value_validate")]
135 public bool value_validate (Value value);
136 [CCode (cname = "g_param_value_convert")]
137 public bool value_convert (Value src_value, Value dest_value, bool strict_validation);
138 [CCode (cname = "g_param_values_cmp")]
139 public int values_cmp (Value value1, Value value2);
140 public unowned string get_blurb ();
141 public unowned string get_name ();
142 public unowned string get_nick ();
143 public void* get_qdata (Quark quark);
144 public void set_qdata (Quark quark, void* data);
145 public void set_qdata_full (Quark quark, void* data, DestroyNotify destroy);
146 public void* steal_qdata (Quark quark);
147 public ParamSpec get_redirect_target ();
150 public class ParamSpecBoolean : ParamSpec {
151 [CCode (cname = "g_param_spec_boolean")]
152 public ParamSpecBoolean (string name, string nick, string blurb, bool defaultvalue, ParamFlags flags);
153 public bool default_value;
156 public class ParamSpecChar : ParamSpec {
157 [CCode (cname = "g_param_spec_char")]
158 public ParamSpecChar (string name, string nick, string blurb, int8 minimum, int8 maximum, int8 default_value, ParamFlags flags);
161 public int8 default_value;
164 public class ParamSpecUChar : ParamSpec {
165 [CCode (cname = "g_param_spec_uchar")]
166 public ParamSpecUChar (string name, string nick, string blurb, uint8 minimum, uint8 maximum, uint8 default_value, ParamFlags flags);
167 public uint8 minimum;
168 public uint8 maximum;
169 public uint8 default_value;
172 public class ParamSpecInt : ParamSpec {
173 [CCode (cname = "g_param_spec_int")]
174 public ParamSpecInt (string name, string nick, string blurb, int minimum, int maximum, int default_value, ParamFlags flags);
177 public int default_value;
180 public class ParamSpecUInt : ParamSpec {
181 [CCode (cname = "g_param_spec_uint")]
182 public ParamSpecUInt (string name, string nick, string blurb, uint minimum, uint maximum, uint default_value, ParamFlags flags);
185 public uint default_value;
188 public class ParamSpecLong : ParamSpec {
189 [CCode (cname = "g_param_spec_long")]
190 public ParamSpecLong (string name, string nick, string blurb, long minimum, long maximum, long default_value, ParamFlags flags);
193 public long default_value;
196 public class ParamSpecULong : ParamSpec {
197 [CCode (cname = "g_param_spec_ulong")]
198 public ParamSpecULong (string name, string nick, string blurb, ulong minimum, ulong maximum, ulong default_value, ParamFlags flags);
199 public ulong minimum;
200 public ulong maximum;
201 public ulong default_value;
204 public class ParamSpecInt64 : ParamSpec {
205 [CCode (cname = "g_param_spec_int64")]
206 public ParamSpecInt64 (string name, string nick, string blurb, int64 minimum, int64 maximum, int64 default_value, ParamFlags flags);
207 public int64 minimum;
208 public int64 maximum;
209 public int64 default_value;
212 public class ParamSpecUInt64 : ParamSpec {
213 [CCode (cname = "g_param_spec_uint64")]
214 public ParamSpecUInt64 (string name, string nick, string blurb, uint64 minimum, uint64 maximum, uint64 default_value, ParamFlags flags);
215 public uint64 minimum;
216 public uint64 maximum;
217 public uint64 default_value;
220 public class ParamSpecFloat : ParamSpec {
221 [CCode (cname = "g_param_spec_float")]
222 public ParamSpecFloat (string name, string nick, string blurb, float minimum, float maximum, float default_value, ParamFlags flags);
223 public float minimum;
224 public float maximum;
225 public float default_value;
228 public class ParamSpecDouble : ParamSpec {
229 [CCode (cname = "g_param_spec_double")]
230 public ParamSpecDouble (string name, string nick, string blurb, double minimum, double maximum, double default_value, ParamFlags flags);
231 public double minimum;
232 public double maximum;
233 public double default_value;
236 public class ParamSpecEnum : ParamSpec {
237 [CCode (cname = "g_param_spec_enum")]
238 public ParamSpecEnum (string name, string nick, string blurb, Type enum_type, int default_value, ParamFlags flags);
239 public unowned EnumClass enum_class;
240 public int default_value;
243 public class ParamSpecFlags : ParamSpec {
244 [CCode (cname = "g_param_spec_flags")]
245 public ParamSpecFlags (string name, string nick, string blurb, Type flags_type, uint default_value, ParamFlags flags);
246 public unowned FlagsClass flags_class;
247 public uint default_value;
250 public class ParamSpecString : ParamSpec {
251 [CCode (cname = "g_param_spec_string")]
252 public ParamSpecString (string name, string nick, string blurb, string default_value, ParamFlags flags);
253 public string default_value;
254 public string cset_first;
255 public string cset_nth;
256 public char substitutor;
257 public uint null_fold_if_empty;
258 public uint ensure_non_null;
261 public class ParamSpecParam : ParamSpec {
262 [CCode (cname = "g_param_spec_param")]
263 public ParamSpecParam (string name, string nick, string blurb, Type param_type, ParamFlags flags);
266 [CCode (cprefix = "G_PARAM_", has_type_id = false)]
267 public enum ParamFlags {
280 [CCode (lower_case_csuffix = "object_class")]
281 public class ObjectClass : TypeClass {
282 public unowned ParamSpec? find_property (string property_name);
283 [CCode (array_length_type = "guint")]
284 public unowned ParamSpec[] list_properties ();
285 public void install_property (uint property_id, ParamSpec pspec);
288 public struct ObjectConstructParam {
292 [CCode (cprefix = "G_BINDING_")]
293 public enum BindingFlags {
300 public delegate bool BindingTransformFunc (GLib.Binding binding, GLib.Value source_value, GLib.Value target_value);
302 public class Binding : GLib.Object {
303 public weak GLib.Object source { get; }
304 public string source_property { get; }
305 public weak GLib.Object target { get; }
306 public string target_property { get; }
307 public GLib.BindingFlags flags { get; }
310 [CCode (has_target = false)]
311 public delegate void ObjectGetPropertyFunc (Object object, uint property_id, Value value, ParamSpec pspec);
312 [CCode (has_target = false)]
313 public delegate void ObjectSetPropertyFunc (Object object, uint property_id, Value value, ParamSpec pspec);
314 [CCode (instance_pos = 0)]
315 public delegate void WeakNotify (Object object);
317 [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")]
318 public class Object {
319 public uint ref_count;
321 [CCode (has_new_function = false, construct_function = "g_object_new")]
324 public static Object @new (Type type, ...);
325 public static Object newv (Type type, [CCode (array_length_pos = 1.9)] Parameter[] parameters);
327 [CCode (cname = "G_TYPE_FROM_INSTANCE")]
328 public Type get_type ();
329 [CCode (cname = "G_OBJECT_GET_CLASS")]
330 public unowned ObjectClass get_class ();
331 public unowned Object @ref ();
332 public void unref ();
333 public Object ref_sink ();
334 public void weak_ref (WeakNotify notify);
335 public void weak_unref (WeakNotify notify);
336 public void add_weak_pointer (void **data);
337 public void remove_weak_pointer (void **data);
338 public void get (string first_property_name, ...);
339 public void set (string first_property_name, ...);
340 public void get_property (string property_name, ref Value value);
341 public void set_property (string property_name, Value value);
342 [CCode (simple_generics = true)]
343 public unowned T get_data<T> (string key);
344 [CCode (cname = "g_object_set_data_full", simple_generics = true)]
345 public void set_data<T> (string key, owned T data);
346 public void set_data_full (string key, void* data, DestroyNotify? destroy);
347 [CCode (simple_generics = true)]
348 public T steal_data<T> (string key);
349 [CCode (simple_generics = true)]
350 public unowned T get_qdata<T> (Quark quark);
351 [CCode (cname = "g_object_set_qdata_full", simple_generics = true)]
352 public void set_qdata<T> (Quark quark, owned T data);
353 public void set_qdata_full (Quark quark, void* data, DestroyNotify? destroy);
354 [CCode (simple_generics = true)]
355 public T steal_qdata<T> (Quark quark);
356 public void freeze_notify ();
357 public void thaw_notify ();
358 [CCode (cname = "g_object_run_dispose")]
359 public virtual void dispose ();
360 public virtual void constructed ();
362 public signal void notify (ParamSpec pspec);
363 [CCode (cname = "g_object_notify")]
364 public void notify_property (string property_name);
366 public unowned Object connect (string signal_spec, ...);
367 [CCode (cname = "g_signal_handler_disconnect")]
368 public void disconnect (ulong handler_id);
370 public void add_toggle_ref (ToggleNotify notify);
371 public void remove_toggle_ref (ToggleNotify notify);
373 [CCode (cname = "g_object_bind_property_with_closures")]
374 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);
377 [CCode (instance_pos = 0)]
378 public delegate void ToggleNotify (GLib.Object object, bool is_last_ref);
380 [CCode (has_copy_function = false, has_destroy_function = false)]
381 public struct Parameter {
382 public unowned string name;
386 [CCode (ref_sink_function = "g_object_ref_sink")]
387 public class InitiallyUnowned : Object {
388 [CCode (has_construct_function = false)]
389 protected InitiallyUnowned ();
392 [CCode (lower_case_csuffix = "enum")]
393 public class EnumClass : TypeClass {
394 public unowned EnumValue? get_value (int value);
395 public unowned EnumValue? get_value_by_name (string name);
396 public unowned EnumValue? get_value_by_nick (string name);
399 public uint n_values;
400 [CCode (array_length_cname = "n_values")]
401 public unowned EnumValue[] values;
404 [CCode (has_type_id = false)]
405 public struct EnumValue {
407 public unowned string value_name;
408 public unowned string value_nick;
411 [CCode (lower_case_csuffix = "flags")]
412 public class FlagsClass : TypeClass {
413 public unowned FlagsValue? get_first_value (uint value);
414 public unowned FlagsValue? get_value_by_name (string name);
415 public unowned FlagsValue? get_value_by_nick (string name);
417 public uint n_values;
418 [CCode (array_length_cname = "n_values")]
419 public FlagsValue[] values;
423 public class FlagsValue {
425 public unowned string value_name;
426 public unowned string value_nick;
429 [CCode (has_target = false)]
430 public delegate void ValueTransform (Value src_value, out Value dest_value);
432 [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")]
433 public struct Value {
434 [CCode (cname = "G_VALUE_HOLDS")]
435 public bool holds (Type type);
436 [CCode (cname = "G_VALUE_TYPE")]
438 [CCode (cname = "G_VALUE_TYPE_NAME")]
439 public unowned string type_name ();
441 public Value (Type g_type);
442 public void copy (ref Value dest_value);
443 public unowned Value? reset ();
444 public void init (Type g_type);
445 public void unset ();
446 public void set_instance (void* instance);
447 public bool fits_pointer ();
448 public void* peek_pointer ();
449 public static bool type_compatible (Type src_type, Type dest_type);
450 public static bool type_transformable (Type src_type, Type dest_type);
451 public bool transform (ref Value dest_value);
452 [CCode (cname = "g_strdup_value_contents")]
453 public string strdup_contents ();
454 public static void register_transform_func (Type src_type, Type dest_type, ValueTransform transform);
455 public void set_boolean (bool v_boolean);
456 public bool get_boolean ();
457 public void set_char (char v_char);
458 public char get_char ();
459 public void set_uchar (uchar v_uchar);
460 public uchar get_uchar ();
461 public void set_int (int v_int);
462 public int get_int ();
463 public void set_uint (uint v_uint);
464 public uint get_uint ();
465 public void set_long (long v_long);
466 public long get_long ();
467 public void set_ulong (ulong v_ulong);
468 public ulong get_ulong ();
469 public void set_int64 (int64 v_int64);
470 public int64 get_int64 ();
471 public void set_uint64 (uint64 v_uint64);
472 public uint64 get_uint64 ();
473 public void set_float (float v_float);
474 public float get_float ();
475 public void set_double (double v_double);
476 public double get_double ();
477 public void set_enum (int v_enum);
478 public int get_enum ();
479 public void set_flags (uint v_flags);
480 public uint get_flags ();
481 public void set_string (string v_string);
482 public void set_static_string (string v_string);
483 public void take_string (owned string v_string);
484 public unowned string get_string ();
485 public string dup_string ();
486 public void set_pointer (void* v_pointer);
487 public void* get_pointer ();
488 public void set_boxed (void* v_boxed);
489 public void* get_boxed ();
490 public void* dup_boxed ();
491 public void set_object (Object v_object);
492 public void take_object (owned Object v_object);
493 public unowned Object get_object ();
494 public Object dup_object ();
495 public void set_gtype (Type v_gtype);
496 public Type get_gtype ();
497 public void set_param(ParamSpec param);
498 public ParamSpec get_param();
499 public void take_param(out ParamSpec param);
500 public void param_take_ownership(out ParamSpec param);
503 public struct SignalInvocationHint {
504 public uint signal_id;
506 public SignalFlags run_type;
509 public delegate bool SignalEmissionHook (SignalInvocationHint ihint, [CCode (array_length_pos = 1.9)] Value[] param_values);
511 [CCode (cprefix = "G_SIGNAL_", has_type_id = false)]
512 public enum SignalFlags {
521 [CCode (cprefix = "G_CONNECT_", has_type_id = false)]
522 public enum ConnectFlags {
527 [CCode (has_target = false)]
528 public delegate void Callback ();
531 [CCode (ref_function = "g_closure_ref", unref_function = "g_closure_unref", type_id = "G_TYPE_CLOSURE")]
532 public class Closure {
534 public void invoke (out Value? return_value, [CCode (array_length_pos = 1.9)] Value[] param_values, void *invocation_hint);
535 public void invalidate ();
536 public void add_finalize_notifier (void *notify_data, ClosureNotify notify_func);
537 public void add_invalidate_notifier (void *notify_data, ClosureNotify notify_func);
538 public void remove_finalize_notifier (void *notify_data, ClosureNotify notify_func);
539 public void remove_invalidate_notifier (void *notify_data, ClosureNotify notify_func);
540 [CCode (cname = "g_closure_new_object")]
541 public Closure (ulong sizeof_closure, Object object);
542 public void set_marshal (ClosureMarshal marshal);
543 public void add_marshal_guards (void *pre_marshal_data, ClosureNotify pre_marshal_notify, void *post_marshal_data, ClosureNotify post_marshal_notify);
544 public void set_meta_marshal (void *marshal_data, ClosureMarshal meta_marshal);
547 [CCode (has_target = false)]
548 public delegate void ClosureNotify (void* data, Closure closure);
550 [CCode (instance_pos = 0, has_target = false)]
551 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);
554 [CCode (type_id = "G_TYPE_VALUE_ARRAY", copy_function = "g_value_array_copy", free_function = "g_value_array_free")]
555 public class ValueArray {
556 public uint n_values;
557 [CCode (array_length_cname = "n_values", array_length_type = "guint")]
558 public Value[] values;
559 public ValueArray (uint n_prealloced);
560 public ValueArray copy ();
561 public unowned Value? get_nth (uint index_);
562 public void append (Value value);
563 public void prepend (Value value);
564 public void insert (uint index_, Value value);
565 public void remove (uint index_);
566 public void sort (CompareFunc compare_func);
567 public void sort_with_data (CompareDataFunc compare_func);
571 public static void query (uint signal_id, out SignalQuery query);
572 public static uint lookup (string name, Type itype);
573 public static unowned string name (uint signal_id);
574 public static uint[] list_ids (Type itype);
575 public static void emit (void* instance, uint signal_id, Quark detail, ...);
576 public static void emit_by_name (void* instance, string detailed_signal, ...);
577 public static ulong connect (void* instance, string detailed_signal, Callback handler, void* data);
578 public static ulong connect_after (void* instance, string detailed_signal, Callback handler, void* data);
579 public static ulong connect_swapped (void* instance, string detailed_signal, Callback handler, void* data);
580 public static ulong connect_object (void* instance, string detailed_signal, Callback handler, Object gobject, ConnectFlags flags);
581 public static ulong connect_data (void* instance, string detailed_signal, Callback handler, void* data, ClosureNotify destroy_data, ConnectFlags flags);
582 public static ulong connect_closure (void* instance, string detailed_signal, Closure closure, bool after);
583 public static ulong connect_closure_by_id (void* instance, uint signal_id, Quark detail, Closure closure, bool after);
584 public static bool has_handler_pending (void* instance, uint signal_id, Quark detail, bool may_be_blocked);
585 public static void stop_emission (void* instance, uint signal_id, Quark detail);
586 public static void stop_emission_by_name (void* instance, string detailed_signal);
587 public static void override_class_closure (uint signal_id, Type instance_type, Closure class_closure);
588 public static void chain_from_overridden ([CCode (array_length = false)] Value[] instance_and_params, out Value return_value);
589 public static ulong add_emission_hook (uint signal_id, Quark detail, SignalEmissionHook hook_func, DestroyNotify? data_destroy);
590 public static void remove_emission_hook (uint signal_id, ulong hook_id);
591 public static bool parse_name (string detailed_signal, Type itype, out uint signal_id, out Quark detail, bool force_detail_quark);
594 namespace SignalHandler {
595 public static void block (void* instance, ulong handler_id);
596 public static void unblock (void* instance, ulong handler_id);
597 public static void disconnect (void* instance, ulong handler_id);
598 public static ulong find (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
599 public static bool is_connected (void* instance, ulong handler_id);
601 [CCode (cname = "g_signal_handlers_block_matched")]
602 public static uint block_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
603 [CCode (cname = "g_signal_handlers_unblock_matched")]
604 public static uint unblock_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
605 [CCode (cname = "g_signal_handlers_disconnect_matched")]
606 public static uint disconnect_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
607 [CCode (cname = "g_signal_handlers_block_by_func")]
608 public static uint block_by_func (void* instance, void* func, void* data);
609 [CCode (cname = "g_signal_handlers_unblock_by_func")]
610 public static uint unblock_by_func (void* instance, void* func, void* data);
611 [CCode (cname = "g_signal_handlers_disconnect_by_func")]
612 public static uint disconnect_by_func (void* instance, void* func, void* data);
615 public struct SignalQuery {
616 public uint signal_id;
617 public unowned string signal_name;
619 public SignalFlags signal_flags;
620 public Type return_type;
621 public uint n_params;
622 [CCode (array_length = false)]
623 public unowned Type[] param_types;
626 [CCode (cprefix = "G_SIGNAL_MATCH_", has_type_id = false)]
627 public enum SignalMatchType {