3 * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
4 * Copyright (C) 2007 Mathias Hasselmann
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * Jürg Billeter <j@bitron.ch>
22 * Raffaele Sandrini <rasa@gmx.ch>
23 * Mathias Hasselmann <mathias.hasselmann@gmx.de>
26 [CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h")]
28 [CCode (type_id = "G_TYPE_GTYPE", marshaller_type_name = "GTYPE", get_value_function = "g_value_get_gtype", set_value_function = "g_value_set_gtype")]
29 public struct Type : ulong {
30 [CCode (cname = "G_TYPE_IS_OBJECT")]
31 public bool is_object ();
32 [CCode (cname = "G_TYPE_IS_ABSTRACT")]
33 public bool is_abstract ();
34 [CCode (cname = "G_TYPE_IS_CLASSED")]
35 public bool is_classed ();
36 [CCode (cname = "G_TYPE_IS_DERIVABLE")]
37 public bool is_derivable ();
38 [CCode (cname = "G_TYPE_IS_DEEP_DERIVABLE")]
39 public bool is_deep_derivable ();
40 [CCode (cname = "G_TYPE_IS_DERIVED")]
41 public bool is_derived ();
42 [CCode (cname = "G_TYPE_IS_FUNDAMENTAL")]
43 public bool is_fundamental ();
44 [CCode (cname = "G_TYPE_IS_INSTANTIATABLE")]
45 public bool is_instantiatable ();
46 [CCode (cname = "G_TYPE_IS_INTERFACE")]
47 public bool is_interface ();
48 [CCode (cname = "G_TYPE_IS_VALUE_TYPE")]
49 public bool is_value_type ();
51 public Type[] children ();
53 public static Type from_name (string name);
54 public Type[] interfaces ();
55 public bool is_a (Type is_a_type);
56 public weak string name ();
57 public Quark qname ();
58 public Type parent ();
60 public void query (out TypeQuery query);
62 public TypeClass class_ref ();
63 public weak TypeClass class_peek ();
65 [CCode (cname = "G_TYPE_INVALID")]
66 public static Type INVALID;
69 public struct TypeQuery {
71 public weak string type_name;
72 public uint class_size;
73 public uint instance_size;
77 [CCode (ref_function = "g_type_class_ref", unref_function = "g_type_class_unref")]
78 public class TypeClass {
79 [CCode (cname = "G_TYPE_FROM_CLASS")]
80 public Type get_type ();
83 [CCode (cprefix = "G_TYPE_DEBUG_", has_type_id = false)]
84 public enum TypeDebugFlags {
91 public interface TypePlugin {
94 [CCode (lower_case_csuffix = "type_module")]
95 public class TypeModule : Object, TypePlugin {
98 public void set_name (string name);
100 public virtual bool load ();
102 public virtual void unload ();
105 [CCode (ref_function = "g_param_spec_ref", unref_function = "g_param_spec_unref")]
106 public class ParamSpec {
108 public ParamFlags flags;
109 public Type value_type;
110 public Type owner_type;
111 public weak string get_blurb ();
112 public weak string get_name ();
113 public weak string get_nick ();
116 public class ParamSpecEnum : ParamSpec {
117 [CCode (cname = "g_param_spec_enum")]
118 public ParamSpecEnum (string name, string nick, string blurb, Type enum_type, int default_value, ParamFlags flags);
121 public class ParamSpecFloat : ParamSpec {
122 [CCode (cname = "g_param_spec_float")]
123 public ParamSpecFloat (string name, string nick, string blurb, float minimum, float maximum, float default_value, ParamFlags flags);
126 public class ParamSpecInt : ParamSpec {
127 [CCode (cname = "g_param_spec_int")]
128 public ParamSpecInt (string name, string nick, string blurb, int minimum, int maximum, int default_value, ParamFlags flags);
131 public class ParamSpecUInt : ParamSpec {
132 [CCode (cname = "g_param_spec_uint")]
133 public ParamSpecUInt (string name, string nick, string blurb, uint minimum, uint maximum, uint default_value, ParamFlags flags);
136 public class ParamSpecBoolean : ParamSpec {
137 [CCode (cname = "g_param_spec_boolean")]
138 public ParamSpecBoolean (string name, string nick, string blurb, bool defaultvalue, ParamFlags flags);
141 [CCode (cprefix = "G_PARAM_", has_type_id = false)]
142 public enum ParamFlags {
155 [CCode (lower_case_csuffix = "object_class")]
156 public class ObjectClass : TypeClass {
157 public weak ParamSpec find_property (string property_name);
158 public weak ParamSpec[] list_properties ();
159 public void install_property (uint property_id, ParamSpec pspec);
162 public struct ObjectConstructParam {
165 public static delegate void ObjectGetPropertyFunc (Object object, uint property_id, Value value, ParamSpec pspec);
166 public static delegate void ObjectSetPropertyFunc (Object object, uint property_id, Value value, ParamSpec pspec);
167 public static delegate void WeakNotify (void *data, Object object);
169 [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")]
170 public class Object {
171 public uint ref_count;
173 public static Object @new (Type type, ...);
175 [CCode (cname = "G_TYPE_FROM_INSTANCE")]
176 public Type get_type ();
177 public weak Object @ref ();
178 public void unref ();
179 public Object ref_sink ();
180 public void weak_ref (WeakNotify notify, void *data);
181 public void weak_unref (WeakNotify notify, void *data);
182 public void add_weak_pointer (void **data);
183 public void remove_weak_pointer (void **data);
184 public void get (string first_property_name, ...);
185 public void set (string first_property_name, ...);
186 public void get_property (string property_name, Value value);
187 public void set_property (string property_name, Value value);
188 public void* get_data (string key);
189 public void set_data (string key, void* data);
190 public void set_data_full (string key, void* data, DestroyNotify? destroy);
191 public void* steal_data (string key);
192 public void* get_qdata (Quark quark);
193 public void set_qdata (Quark quark, void* data);
194 public void set_qdata_full (Quark quark, void* data, DestroyNotify? destroy);
195 public void* steal_qdata (Quark quark);
196 public void freeze_notify ();
197 public void thaw_notify ();
198 public virtual void dispose ();
199 public virtual void finalize ();
200 public virtual void constructed ();
202 public signal void notify (ParamSpec pspec);
204 public weak Object connect (string signal_spec, ...);
206 public void add_toggle_ref (ToggleNotify notify);
207 public void remove_toggle_ref (ToggleNotify notify);
210 [CCode (instance_pos = 0)]
211 public delegate void ToggleNotify (GLib.Object object, bool is_last_ref);
213 public struct Parameter {
218 public class InitiallyUnowned : Object {
221 [CCode (lower_case_csuffix = "enum")]
222 public class EnumClass : TypeClass {
223 public weak EnumValue? get_value (int value);
224 public weak EnumValue? get_value_by_name (string name);
225 public weak EnumValue? get_value_by_nick (string name);
229 public class EnumValue {
231 public weak string value_name;
232 public weak string value_nick;
235 [CCode (lower_case_csuffix = "flags")]
236 public class FlagsClass : TypeClass {
237 public weak FlagsValue? get_first_value (uint value);
238 public weak FlagsValue? get_value_by_name (string name);
239 public weak FlagsValue? get_value_by_nick (string name);
243 public class FlagsValue {
245 public weak string value_name;
246 public weak string value_nick;
250 [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")]
251 public abstract class Boxed {
254 public static delegate void ValueTransform (Value src_value, out Value dest_value);
256 [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")]
257 public struct Value {
258 [CCode (cname = "G_VALUE_HOLDS")]
259 public bool holds (Type type);
260 [CCode (cname = "G_VALUE_TYPE")]
262 [CCode (cname = "G_VALUE_TYPE_NAME")]
263 public weak string type_name ();
265 public Value (Type g_type);
266 public void copy (ref Value dest_value);
267 public weak Value? reset ();
268 public void init (Type g_type);
269 public void unset ();
270 public void set_instance (void* instance);
271 public bool fits_pointer ();
272 public void* peek_pointer ();
273 public static bool type_compatible (Type src_type, Type dest_type);
274 public static bool type_transformable (Type src_type, Type dest_type);
275 public bool transform (ref Value dest_value);
276 [CCode (cname = "g_strdup_value_contents")]
277 public string strdup_contents ();
278 public static void register_transform_func (Type src_type, Type dest_type, ValueTransform transform);
279 public void set_boolean (bool v_boolean);
280 public bool get_boolean ();
281 public void set_char (char v_char);
282 public char get_char ();
283 public void set_uchar (uchar v_uchar);
284 public uchar get_uchar ();
285 public void set_int (int v_int);
286 public int get_int ();
287 public void set_uint (uint v_uint);
288 public uint get_uint ();
289 public void set_long (long v_long);
290 public long get_long ();
291 public void set_ulong (ulong v_ulong);
292 public ulong get_ulong ();
293 public void set_int64 (int64 v_int64);
294 public int64 get_int64 ();
295 public void set_uint64 (uint64 v_uint64);
296 public uint64 get_uint64 ();
297 public void set_float (float v_float);
298 public float get_float ();
299 public void set_double (double v_double);
300 public double get_double ();
301 public void set_enum (int v_enum);
302 public int get_enum ();
303 public void set_flags (uint v_flags);
304 public uint get_flags ();
305 public void set_string (string v_string);
306 public void set_static_string (string v_string);
307 public void take_string (string# v_string);
308 public weak string get_string ();
309 public string dup_string ();
310 public void set_pointer (void* v_pointer);
311 public void* get_pointer ();
312 public void set_boxed (void* v_boxed);
313 public weak Boxed get_boxed ();
314 public Boxed dup_boxed ();
315 public void set_object (Object v_object);
316 public void take_object (Object# v_object);
317 public weak Object get_object ();
318 public Object dup_object ();
319 public void set_gtype (Type v_gtype);
320 public Type get_gtype ();
323 public struct SignalInvocationHint {
324 public uint signal_id;
326 public SignalFlags run_type;
329 public delegate bool SignalEmissionHook (SignalInvocationHint ihint, [CCode (array_length_pos = 1.9)] Value[] param_values);
331 [CCode (cprefix = "G_SIGNAL_", has_type_id = false)]
332 public enum SignalFlags {
341 [CCode (cprefix = "G_CONNECT_", has_type_id = false)]
342 public enum ConnectFlags {
347 public static delegate void Callback ();
350 public class Closure : Boxed {
353 public static delegate void ClosureNotify (void* data, Closure closure);
356 [CCode (type_id = "G_TYPE_VALUE_ARRAY")]
357 public class ValueArray : Boxed {
358 public uint n_values;
359 public Value[] values;
360 public ValueArray (uint n_prealloced);
361 public weak Value? get_nth (uint index_);
362 public void append (Value value);
363 public void prepend (Value value);
364 public void insert (uint index_, Value value);
365 public void remove (uint index_);
366 public void sort (CompareFunc compare_func);
367 public void sort_with_data (CompareDataFunc compare_func);
371 public static void query (uint signal_id, out SignalQuery query);
372 public static uint lookup (string name, Type itype);
373 public static weak string name (uint signal_id);
374 public static uint[] list_ids (Type itype);
375 public static void emit (void* instance, uint signal_id, Quark detail, ...);
376 public static void emit_by_name (void* instance, string detailed_signal, ...);
377 public static ulong connect (void* instance, string detailed_signal, Callback handler, void* data);
378 public static ulong connect_after (void* instance, string detailed_signal, Callback handler, void* data);
379 public static ulong connect_swapped (void* instance, string detailed_signal, Callback handler, void* data);
380 public static ulong connect_object (void* instance, string detailed_signal, Callback handler, Object gobject, ConnectFlags flags);
381 public static ulong connect_data (void* instance, string detailed_signal, Callback handler, void* data, ClosureNotify destroy_data, ConnectFlags flags);
382 public static ulong connect_closure (void* instance, string detailed_signal, Closure closure, bool after);
383 public static ulong connect_closure_by_id (void* instance, uint signal_id, Quark detail, Closure closure, bool after);
384 public static bool has_handler_pending (void* instance, uint signal_id, Quark detail, bool may_be_blocked);
385 public static void stop_emission (void* instance, uint signal_id, Quark detail);
386 public static void stop_emission_by_name (void* instance, string detailed_signal);
387 public static void override_class_closure (uint signal_id, Type instance_type, Closure class_closure);
388 public static void chain_from_overridden ([CCode (array_length = false)] Value[] instance_and_params, out Value return_value);
389 public static ulong add_emission_hook (uint signal_id, Quark detail, SignalEmissionHook hook_func, DestroyNotify? data_destroy);
390 public static void remove_emission_hook (uint signal_id, ulong hook_id);
391 public static bool parse_name (string detailed_signal, Type itype, out uint signal_id, out Quark detail, bool force_detail_quark);
394 namespace SignalHandler {
395 public static void block (void* instance, ulong handler_id);
396 public static void unblock (void* instance, ulong handler_id);
397 public static void disconnect (void* instance, ulong handler_id);
398 public static ulong find (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
399 public static bool is_connected (void* instance, ulong handler_id);
401 [CCode (cname = "g_signal_handlers_block_matched")]
402 public static uint block_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
403 [CCode (cname = "g_signal_handlers_unblock_matched")]
404 public static uint unblock_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
405 [CCode (cname = "g_signal_handlers_disconnect_matched")]
406 public static uint disconnect_matched (void* instance, SignalMatchType mask, uint signal_id, Quark detail, Closure? closure, void* func, void* data);
407 [CCode (cname = "g_signal_handlers_block_by_func")]
408 public static uint block_by_func (void* instance, void* func, void* data);
409 [CCode (cname = "g_signal_handlers_unblock_by_func")]
410 public static uint unblock_by_func (void* instance, void* func, void* data);
411 [CCode (cname = "g_signal_handlers_disconnect_by_func")]
412 public static uint disconnect_by_func (void* instance, void* func, void* data);
415 public struct SignalQuery {
416 public uint signal_id;
417 public weak string signal_name;
419 public SignalFlags signal_flags;
420 public Type return_type;
421 public uint n_params;
422 [CCode (array_length = false)]
423 public weak Type[] param_types;
426 [CCode (cprefix = "G_SIGNAL_MATCH_", has_type_id = false)]
427 public enum SignalMatchType {