3 * Copyright (C) 2006-2009 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")]
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 ();
52 [CCode (cname = "G_TYPE_FROM_INSTANCE")]
53 public static Type from_instance (void* instance);
55 public Type[] children ();
57 public static Type from_name (string name);
58 public Type[] interfaces ();
59 public bool is_a (Type is_a_type);
60 public weak string name ();
61 public Quark qname ();
62 public Type parent ();
64 public void query (out TypeQuery query);
66 public TypeClass class_ref ();
67 public weak TypeClass class_peek ();
69 [CCode (cname = "G_TYPE_INVALID")]
70 public static Type INVALID;
73 public struct TypeQuery {
75 public weak string type_name;
76 public uint class_size;
77 public uint instance_size;
81 [CCode (ref_function = "g_type_class_ref", unref_function = "g_type_class_unref")]
82 public class TypeClass {
83 [CCode (cname = "G_TYPE_FROM_CLASS")]
84 public Type get_type ();
87 [CCode (cprefix = "G_TYPE_DEBUG_", has_type_id = false)]
88 public enum TypeDebugFlags {
95 public interface TypePlugin {
98 [CCode (lower_case_csuffix = "type_module")]
99 public class TypeModule : Object, TypePlugin {
101 public void unuse ();
102 public void set_name (string name);
104 public virtual bool load ();
106 public virtual void unload ();
109 [CCode (ref_function = "g_param_spec_ref", unref_function = "g_param_spec_unref")]
110 public class ParamSpec {
112 public ParamFlags flags;
113 public Type value_type;
114 public Type owner_type;
115 public weak string get_blurb ();
116 public weak string get_name ();
117 public weak string get_nick ();
120 public class ParamSpecEnum : ParamSpec {
121 [CCode (cname = "g_param_spec_enum")]
122 public ParamSpecEnum (string name, string nick, string blurb, Type enum_type, int default_value, ParamFlags flags);
125 public class ParamSpecFloat : ParamSpec {
126 [CCode (cname = "g_param_spec_float")]
127 public ParamSpecFloat (string name, string nick, string blurb, float minimum, float maximum, float default_value, ParamFlags flags);
130 public class ParamSpecInt : ParamSpec {
131 [CCode (cname = "g_param_spec_int")]
132 public ParamSpecInt (string name, string nick, string blurb, int minimum, int maximum, int default_value, ParamFlags flags);
135 public class ParamSpecUInt : ParamSpec {
136 [CCode (cname = "g_param_spec_uint")]
137 public ParamSpecUInt (string name, string nick, string blurb, uint minimum, uint maximum, uint default_value, ParamFlags flags);
140 public class ParamSpecBoolean : ParamSpec {
141 [CCode (cname = "g_param_spec_boolean")]
142 public ParamSpecBoolean (string name, string nick, string blurb, bool defaultvalue, ParamFlags flags);
145 [CCode (cprefix = "G_PARAM_", has_type_id = false)]
146 public enum ParamFlags {
159 [CCode (lower_case_csuffix = "object_class")]
160 public class ObjectClass : TypeClass {
161 public weak ParamSpec? find_property (string property_name);
162 public weak ParamSpec[] list_properties ();
163 public void install_property (uint property_id, ParamSpec pspec);
166 public struct ObjectConstructParam {
169 public static delegate void ObjectGetPropertyFunc (Object object, uint property_id, Value value, ParamSpec pspec);
170 public static delegate void ObjectSetPropertyFunc (Object object, uint property_id, Value value, ParamSpec pspec);
171 public static delegate void WeakNotify (void *data, Object object);
173 [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", param_spec_function = "g_param_spec_object", cheader_filename = "glib-object.h")]
174 public class Object {
175 public uint ref_count;
177 public static Object @new (Type type, ...);
179 [CCode (cname = "G_TYPE_FROM_INSTANCE")]
180 public Type get_type ();
181 public weak Object @ref ();
182 public void unref ();
183 public Object ref_sink ();
184 public void weak_ref (WeakNotify notify, void *data);
185 public void weak_unref (WeakNotify notify, void *data);
186 public void add_weak_pointer (void **data);
187 public void remove_weak_pointer (void **data);
188 public void get (string first_property_name, ...);
189 public void set (string first_property_name, ...);
190 public void get_property (string property_name, Value value);
191 public void set_property (string property_name, Value value);
192 public void* get_data (string key);
193 public void set_data (string key, void* data);
194 public void set_data_full (string key, void* data, DestroyNotify? destroy);
195 public void* steal_data (string key);
196 public void* get_qdata (Quark quark);
197 public void set_qdata (Quark quark, void* data);
198 public void set_qdata_full (Quark quark, void* data, DestroyNotify? destroy);
199 public void* steal_qdata (Quark quark);
200 public void freeze_notify ();
201 public void thaw_notify ();
202 public virtual void dispose ();
203 public virtual void finalize ();
204 public virtual void constructed ();
206 public signal void notify (ParamSpec pspec);
208 public weak Object connect (string signal_spec, ...);
210 public void add_toggle_ref (ToggleNotify notify);
211 public void remove_toggle_ref (ToggleNotify notify);
214 [CCode (instance_pos = 0)]
215 public delegate void ToggleNotify (GLib.Object object, bool is_last_ref);
217 public struct Parameter {
222 public class InitiallyUnowned : Object {
225 [CCode (lower_case_csuffix = "enum")]
226 public class EnumClass : TypeClass {
227 public weak EnumValue? get_value (int value);
228 public weak EnumValue? get_value_by_name (string name);
229 public weak EnumValue? get_value_by_nick (string name);
233 public class EnumValue {
235 public weak string value_name;
236 public weak string value_nick;
239 [CCode (lower_case_csuffix = "flags")]
240 public class FlagsClass : TypeClass {
241 public weak FlagsValue? get_first_value (uint value);
242 public weak FlagsValue? get_value_by_name (string name);
243 public weak FlagsValue? get_value_by_nick (string name);
247 public class FlagsValue {
249 public weak string value_name;
250 public weak string value_nick;
254 [CCode (cname = "gpointer", has_type_id = true, type_id = "G_TYPE_BOXED", marshaller_type_name = "BOXED", get_value_function = "g_value_get_boxed", set_value_function = "g_value_set_boxed")]
255 public abstract class Boxed {
258 public static delegate void ValueTransform (Value src_value, out Value dest_value);
260 [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", type_signature = "v")]
261 public struct Value {
262 [CCode (cname = "G_VALUE_HOLDS")]
263 public bool holds (Type type);
264 [CCode (cname = "G_VALUE_TYPE")]
266 [CCode (cname = "G_VALUE_TYPE_NAME")]
267 public weak string type_name ();
269 public Value (Type g_type);
270 public void copy (ref Value dest_value);
271 public weak Value? reset ();
272 public void init (Type g_type);
273 public void unset ();
274 public void set_instance (void* instance);
275 public bool fits_pointer ();
276 public void* peek_pointer ();
277 public static bool type_compatible (Type src_type, Type dest_type);
278 public static bool type_transformable (Type src_type, Type dest_type);
279 public bool transform (ref Value dest_value);
280 [CCode (cname = "g_strdup_value_contents")]
281 public string strdup_contents ();
282 public static void register_transform_func (Type src_type, Type dest_type, ValueTransform transform);
283 public void set_boolean (bool v_boolean);
284 public bool get_boolean ();
285 public void set_char (char v_char);
286 public char get_char ();
287 public void set_uchar (uchar v_uchar);
288 public uchar get_uchar ();
289 public void set_int (int v_int);
290 public int get_int ();
291 public void set_uint (uint v_uint);
292 public uint get_uint ();
293 public void set_long (long v_long);
294 public long get_long ();
295 public void set_ulong (ulong v_ulong);
296 public ulong get_ulong ();
297 public void set_int64 (int64 v_int64);
298 public int64 get_int64 ();
299 public void set_uint64 (uint64 v_uint64);
300 public uint64 get_uint64 ();
301 public void set_float (float v_float);
302 public float get_float ();
303 public void set_double (double v_double);
304 public double get_double ();
305 public void set_enum (int v_enum);
306 public int get_enum ();
307 public void set_flags (uint v_flags);
308 public uint get_flags ();
309 public void set_string (string v_string);
310 public void set_static_string (string v_string);
311 public void take_string (string# v_string);
312 public weak string get_string ();
313 public string dup_string ();
314 public void set_pointer (void* v_pointer);
315 public void* get_pointer ();
316 public void set_boxed (void* v_boxed);
317 public weak Boxed get_boxed ();
318 public Boxed dup_boxed ();
319 public void set_object (Object v_object);
320 public void take_object (Object# v_object);
321 public weak Object get_object ();
322 public Object dup_object ();
323 public void set_gtype (Type v_gtype);
324 public Type get_gtype ();
327 public struct SignalInvocationHint {
328 public uint signal_id;
330 public SignalFlags run_type;
333 public delegate bool SignalEmissionHook (SignalInvocationHint ihint, [CCode (array_length_pos = 1.9)] Value[] param_values);
335 [CCode (cprefix = "G_SIGNAL_", has_type_id = false)]
336 public enum SignalFlags {
345 [CCode (cprefix = "G_CONNECT_", has_type_id = false)]
346 public enum ConnectFlags {
351 public static delegate void Callback ();
354 public class Closure : Boxed {
357 public static delegate void ClosureNotify (void* data, Closure closure);
360 [CCode (type_id = "G_TYPE_VALUE_ARRAY")]
361 public class ValueArray : Boxed {
362 public uint n_values;
363 public Value[] values;
364 public ValueArray (uint n_prealloced);
365 public weak Value? get_nth (uint index_);
366 public void append (Value value);
367 public void prepend (Value value);
368 public void insert (uint index_, Value value);
369 public void remove (uint index_);
370 public void sort (CompareFunc compare_func);
371 public void sort_with_data (CompareDataFunc compare_func);
375 public static void query (uint signal_id, out SignalQuery query);
376 public static uint lookup (string name, Type itype);
377 public static weak string name (uint signal_id);
378 public static uint[] list_ids (Type itype);
379 public static void emit (void* instance, uint signal_id, Quark detail, ...);
380 public static void emit_by_name (void* instance, string detailed_signal, ...);
381 public static ulong connect (void* instance, string detailed_signal, Callback handler, void* data);
382 public static ulong connect_after (void* instance, string detailed_signal, Callback handler, void* data);
383 public static ulong connect_swapped (void* instance, string detailed_signal, Callback handler, void* data);
384 public static ulong connect_object (void* instance, string detailed_signal, Callback handler, Object gobject, ConnectFlags flags);
385 public static ulong connect_data (void* instance, string detailed_signal, Callback handler, void* data, ClosureNotify destroy_data, ConnectFlags flags);
386 public static ulong connect_closure (void* instance, string detailed_signal, Closure closure, bool after);
387 public static ulong connect_closure_by_id (void* instance, uint signal_id, Quark detail, Closure closure, bool after);
388 public static bool has_handler_pending (void* instance, uint signal_id, Quark detail, bool may_be_blocked);
389 public static void stop_emission (void* instance, uint signal_id, Quark detail);
390 public static void stop_emission_by_name (void* instance, string detailed_signal);
391 public static void override_class_closure (uint signal_id, Type instance_type, Closure class_closure);
392 public static void chain_from_overridden ([CCode (array_length = false)] Value[] instance_and_params, out Value return_value);
393 public static ulong add_emission_hook (uint signal_id, Quark detail, SignalEmissionHook hook_func, DestroyNotify? data_destroy);
394 public static void remove_emission_hook (uint signal_id, ulong hook_id);
395 public static bool parse_name (string detailed_signal, Type itype, out uint signal_id, out Quark detail, bool force_detail_quark);
398 namespace SignalHandler {
399 public static void block (void* instance, ulong handler_id);
400 public static void unblock (void* instance, ulong handler_id);
401 public static void disconnect (void* instance, ulong handler_id);
402 public static ulong find (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
403 public static bool is_connected (void* instance, ulong handler_id);
405 [CCode (cname = "g_signal_handlers_block_matched")]
406 public static uint block_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
407 [CCode (cname = "g_signal_handlers_unblock_matched")]
408 public static uint unblock_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
409 [CCode (cname = "g_signal_handlers_disconnect_matched")]
410 public static uint disconnect_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
411 [CCode (cname = "g_signal_handlers_block_by_func")]
412 public static uint block_by_func (void* instance, void* func, void* data);
413 [CCode (cname = "g_signal_handlers_unblock_by_func")]
414 public static uint unblock_by_func (void* instance, void* func, void* data);
415 [CCode (cname = "g_signal_handlers_disconnect_by_func")]
416 public static uint disconnect_by_func (void* instance, void* func, void* data);
419 public struct SignalQuery {
420 public uint signal_id;
421 public weak string signal_name;
423 public SignalFlags signal_flags;
424 public Type return_type;
425 public uint n_params;
426 [CCode (array_length = false)]
427 public weak Type[] param_types;
430 [CCode (cprefix = "G_SIGNAL_MATCH_", has_type_id = false)]
431 public enum SignalMatchType {