glib-2.0.vala 66.7 KB
Newer Older
1
/* glib-2.0.vala
2
 *
3
 * Copyright (C) 2006-2007  Jürg Billeter, Raffaele Sandrini
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Jürg Billeter <j@bitron.ch>
21
 *	Raffaele Sandrini <rasa@gmx.ch>
22
23
 */

24
[CCode (cname = "gboolean", cheader_filename = "glib.h", type_id = "G_TYPE_BOOLEAN", marshaller_type_name = "BOOLEAN", get_value_function = "g_value_get_boolean", set_value_function = "g_value_set_boolean", default_value = "FALSE")]
25
26
27
public struct bool {
}

28
[CCode (cname = "gpointer", cheader_filename = "glib.h", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER", get_value_function = "g_value_get_pointer", set_value_function = "g_value_set_pointer", default_value = "NULL")]
29
public struct pointer {
30
31
32
33
	[CCode (cname ="GPOINTER_TO_INT")]
	public int to_int ();
	[CCode (cname ="GPOINTER_TO_UINT")]
	public uint to_uint ();
34
35
}

36
[CCode (cname = "gconstpointer", cheader_filename = "glib.h", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER", get_value_function = "g_value_get_pointer", set_value_function = "g_value_set_pointer", default_value = "NULL")]
37
38
39
public struct constpointer {
}

40
[CCode (cname = "gchar", cprefix = "g_ascii_", cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_char", set_value_function = "g_value_set_char", default_value = "\'\\0\'")]
41
[IntegerType (rank = 1)]
42
public struct char {
43
44
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
45
	public string! to_string (string! format = "%hhi");
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
	public bool isalnum ();
	public bool isalpha ();
	public bool iscntrl ();
	public bool isdigit ();
	public bool isgraph ();
	public bool islower ();
	public bool isprint ();
	public bool ispunct ();
	public bool isspace ();
	public bool isupper ();
	public bool isxdigit ();
	public int digit_value ();
	public int xdigit_value ();
	public char tolower ();
	public char toupper ();
61
62
}

63
[CCode (cname = "guchar", cheader_filename = "glib.h", type_id = "G_TYPE_UCHAR", marshaller_type_name = "UCHAR", get_value_function = "g_value_get_uchar", set_value_function = "g_value_set_uchar", default_value = "\'\\0\'")]
64
[IntegerType (rank = 2)]
65
public struct uchar {
66
67
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
68
	public string! to_string (string! format = "%hhu");
69
70
}

71
[CCode (cname = "gint", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0")]
72
[IntegerType (rank = 9)]
73
public struct int {
74
75
76
77
78
	[CCode (cname = "G_MININT")]
	public static int MIN;
	[CCode (cname = "G_MAXINT")]
	public static int MAX;

79
80
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
81
	public string! to_string (string! format = "%i");
82
83
84

	[CCode (cname = "CLAMP")]
	public int clamp (int low, int high);
85
86
87

	[CCode (cname ="GINT_TO_POINTER")]
	public pointer to_pointer ();
88
89
}

90
[CCode (cname = "guint", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U")]
91
[IntegerType (rank = 10)]
92
public struct uint {
93
94
95
96
97
	[CCode (cname = "0")]
	public static uint MIN;
	[CCode (cname = "G_MAXUINT")]
	public static uint MAX;

98
99
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
100
	public string! to_string (string! format = "%u");
101
102
103

	[CCode (cname = "CLAMP")]
	public uint clamp (uint low, uint high);
104
105
106

	[CCode (cname ="GUINT_TO_POINTER")]
	public pointer to_pointer ();
107
108
}

109
[CCode (cname = "gshort", cheader_filename = "glib.h", default_value = "0")]
110
[IntegerType (rank = 5)]
111
public struct short {
112
113
114
115
116
	[CCode (cname = "G_MINSHORT")]
	public static short MIN;
	[CCode (cname = "G_MAXSHORT")]
	public static short MAX;

117
118
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
119
	public string! to_string (string! format = "%hi");
120
121
}

122
[CCode (cname = "gushort", cheader_filename = "glib.h", default_value = "0U")]
123
[IntegerType (rank = 6)]
124
public struct ushort {
125
126
127
128
129
	[CCode (cname = "0U")]
	public static ushort MIN;
	[CCode (cname = "G_MAXUSHORT")]
	public static ushort MAX;

130
131
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
132
	public string! to_string (string! format = "%hu");
133
134
}

135
[CCode (cname = "glong", cheader_filename = "glib.h", type_id = "G_TYPE_LONG", marshaller_type_name = "LONG", get_value_function = "g_value_get_long", set_value_function = "g_value_set_long", default_value = "0L")]
136
[IntegerType (rank = 14)]
137
public struct long {
138
139
140
141
142
	[CCode (cname = "G_MINLONG")]
	public static long MIN;
	[CCode (cname = "G_MAXLONG")]
	public static long MAX;

143
144
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
145
	public string! to_string (string! format = "%li");
146
147
}

148
[CCode (cname = "gulong", cheader_filename = "glib.h", type_id = "G_TYPE_ULONG", marshaller_type_name = "ULONG", get_value_function = "g_value_get_ulong", set_value_function = "g_value_set_ulong", default_value = "0UL")]
149
[IntegerType (rank = 15)]
150
public struct ulong {
151
152
153
154
155
	[CCode (cname = "0UL")]
	public static ulong MIN;
	[CCode (cname = "G_MAXULONG")]
	public static ulong MAX;

156
157
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
158
	public string! to_string (string! format = "%lu");
159
160
}

161
[CCode (cname = "gint8", cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_char", set_value_function = "g_value_set_char", default_value = "0")]
162
163
164
165
166
167
168
169
[IntegerType (rank = 3)]
public struct int8 {
	[CCode (cname = "G_MININT8")]
	public static int8 MIN;
	[CCode (cname = "G_MAXINT8")]
	public static int8 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
170
	public string! to_string (string! format = "%hhi");
171
172
}

173
[CCode (cname = "guint8", cheader_filename = "glib.h", default_value = "0U")]
174
175
176
177
178
179
180
181
[IntegerType (rank = 4)]
public struct uint8 {
	[CCode (cname = "0U")]
	public static uint8 MIN;
	[CCode (cname = "G_MAXUINT8")]
	public static uint8 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
182
	public string! to_string (string! format = "%hhu");
183
184
}

185
[CCode (cname = "gint16", cheader_filename = "glib.h", default_value = "0")]
186
[IntegerType (rank = 7)]
187
public struct int16 {
188
189
190
191
192
193
	[CCode (cname = "G_MININT16")]
	public static int16 MIN;
	[CCode (cname = "G_MAXINT16")]
	public static int16 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
194
	public string! to_string (string! format = "%hi");
195
196
}

197
[CCode (cname = "guint16", cheader_filename = "glib.h", default_value = "0U")]
198
[IntegerType (rank = 8)]
199
public struct uint16 {
200
201
202
203
204
205
	[CCode (cname = "0U")]
	public static uint16 MIN;
	[CCode (cname = "G_MAXUINT16")]
	public static uint16 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
206
	public string! to_string (string! format = "%hu");
207
208
}

209
[CCode (cname = "gint32", cheader_filename = "glib.h", default_value = "0")]
210
[IntegerType (rank = 11)]
211
public struct int32 {
212
213
214
215
216
217
	[CCode (cname = "G_MININT32")]
	public static int32 MIN;
	[CCode (cname = "G_MAXINT32")]
	public static int32 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
218
	public string! to_string (string! format = "%i");
219
220
}

221
[CCode (cname = "guint32", cheader_filename = "glib.h", default_value = "0U")]
222
[IntegerType (rank = 12)]
223
public struct uint32 {
224
225
226
227
228
229
230
	[CCode (cname = "0U")]
	public static uint32 MIN;
	[CCode (cname = "G_MAXUINT32")]
	public static uint32 MAX;

	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
231
	public string! to_string (string! format = "%u");
232
233
}

234
[CCode (cname = "gint64", cheader_filename = "glib.h", type_id = "G_TYPE_INT64", marshaller_type_name = "INT64", get_value_function = "g_value_get_int64", set_value_function = "g_value_set_int64", default_value = "0LL")]
235
[IntegerType (rank = 16)]
236
public struct int64 {
237
238
239
240
241
	[CCode (cname = "G_MININT64")]
	public static int64 MIN;
	[CCode (cname = "G_MAXINT64")]
	public static int64 MAX;

242
243
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
244
	public string! to_string (string! format = "%lli");
245
246
}

247
[CCode (cname = "guint64", cheader_filename = "glib.h", type_id = "G_TYPE_UINT64", marshaller_type_name = "UINT64", get_value_function = "g_value_get_uint64", set_value_function = "g_value_set_uint64", default_value = "0ULL")]
248
[IntegerType (rank = 17)]
249
public struct uint64 {
250
251
252
253
254
	[CCode (cname = "0ULL")]
	public static uint64 MIN;
	[CCode (cname = "G_MAXUINT64")]
	public static uint64 MAX;

255
256
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
257
	public string! to_string (string! format = "%llu");
258
259
}

260
[CCode (cname = "float", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_FLOAT", marshaller_type_name = "FLOAT", get_value_function = "g_value_get_float", set_value_function = "g_value_set_float", default_value = "0.0F")]
261
[FloatingType (rank = 1)]
262
public struct float {
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
	[CCode (cname = "FLT_MANT_DIG")]
	public static int MANT_DIG;
	[CCode (cname = "FLT_DIG")]
	public static int DIG;

	[CCode (cname = "FLT_MIN_EXP")]
	public static int MIN_EXP;
	[CCode (cname = "FLT_MAX_EXP")]
	public static int MAX_EXP;

	[CCode (cname = "FLT_MIN_10_EXP")]
	public static int MIN_10_EXP;
	[CCode (cname = "FLT_MAX_10_EXP")]
	public static int MAX_10_EXP;

	[CCode (cname = "FLT_EPSILON")]
	public static float EPSILON;
	[CCode (cname = "FLT_MIN")]
	public static float MIN;
	[CCode (cname = "FLT_MAX")]
	public static float MAX;

	[CCode (cname = "NAN")]
	public static float NAN;
	[CCode (cname = "INFINITY")]
	public static float INFINITY;

	[CCode (cname = "isnan")]
	public bool is_nan ();
	[CCode (cname = "isfinite")]
	public bool is_finite ();
	[CCode (cname = "isnormal")]
	public bool is_normal ();
	[CCode (cname = "isinf")]
	public int is_infinity ();

	[CCode (cname = "g_strdup_printf"), InstanceLast]
300
	public string! to_string (string! format = "%g");
301
302
}

303
[CCode (cname = "double", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_DOUBLE", marshaller_type_name = "DOUBLE", get_value_function = "g_value_get_double", set_value_function = "g_value_set_double", default_value = "0.0")]
304
[FloatingType (rank = 2)]
305
public struct double {
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
	[CCode (cname = "DBL_MANT_DIG")]
	public static int MANT_DIG;
	[CCode (cname = "DBL_DIG")]
	public static int DIG;

	[CCode (cname = "DBL_MIN_EXP")]
	public static int MIN_EXP;
	[CCode (cname = "DBL_MAX_EXP")]
	public static int MAX_EXP;

	[CCode (cname = "DBL_MIN_10_EXP")]
	public static int MIN_10_EXP;
	[CCode (cname = "DBL_MAX_10_EXP")]
	public static int MAX_10_EXP;

	[CCode (cname = "DBL_EPSILON")]
	public static double EPSILON;
	[CCode (cname = "DBL_MIN")]
	public static double MIN;
	[CCode (cname = "DBL_MAX")]
	public static double MAX;

	[CCode (cname = "((double) NAN)")]
	public static double NAN;
	[CCode (cname = "((double) INFINITY)")]
	public static double INFINITY;

	[CCode (cname = "isnan")]
	public bool is_nan ();
	[CCode (cname = "isfinite")]
	public bool is_finite ();
	[CCode (cname = "isnormal")]
	public bool is_normal ();
	[CCode (cname = "isinf")]
	public int is_infinity ();

	[CCode (cname = "g_strdup_printf"), InstanceLast]
343
	public string! to_string (string! format = "%g");
344
345
}

346
[CCode (cname = "gunichar", cprefix = "g_unichar_", cheader_filename = "glib.h", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0U")]
347
[IntegerType (rank = 13)]
348
public struct unichar {
349
	public bool validate ();
350
	public bool isalnum ();
351
352
	public bool isalpha ();
	public bool iscntrl ();
353
	public bool isdigit ();
354
355
356
357
	public bool isgraph ();
	public bool islower ();
	public bool isprint ();
	public bool ispunct ();
358
	public bool isspace ();
359
	public bool isupper ();
360
	public bool isxdigit ();
361
362
363
364
365
	public bool istitle ();
	public bool isdefined ();
	public bool iswide ();
	public bool iswide_cjk ();
	public bool iszerowidth ();
366
	public unichar toupper ();
367
	public unichar tolower ();
368
	public unichar totitle ();
369
370
	public int digit_value ();
	public int xdigit_value ();
371
372
373
	public UnicodeType type ();
	public UnicodeBreakType break_type ();

374
	public int to_utf8 (string outbuf);
375
376
}

377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
[CCode (cprefix = "G_UNICODE_")]
public enum UnicodeType {
	CONTROL,
	FORMAT,
	UNASSIGNED,
	PRIVATE_USE,
	SURROGATE,
	LOWERCASE_LETTER,
	MODIFIER_LETTER,
	OTHER_LETTER,
	TITLECASE_LETTER,
	UPPERCASE_LETTER,
	COMBINING_MARK,
	ENCLOSING_MARK,
	NON_SPACING_MARK,
	DECIMAL_NUMBER,
	LETTER_NUMBER,
	OTHER_NUMBER,
	CONNECT_PUNCTUATION,
	DASH_PUNCTUATION,
	CLOSE_PUNCTUATION,
	FINAL_PUNCTUATION,
	INITIAL_PUNCTUATION,
	OTHER_PUNCTUATION,
	OPEN_PUNCTUATION,
	CURRENCY_SYMBOL,
	MODIFIER_SYMBOL,
	MATH_SYMBOL,
	OTHER_SYMBOL,
	LINE_SEPARATOR,
	PARAGRAPH_SEPARATOR,
	SPACE_SEPARATOR
}

[CCode (cprefix = "G_UNICODE_BREAK_")]
public enum UnicodeBreakType {
	MANDATORY,
	CARRIAGE_RETURN,
	LINE_FEED,
	COMBINING_MARK,
	SURROGATE,
	ZERO_WIDTH_SPACE,
	INSEPARABLE,
	NON_BREAKING_GLUE,
	CONTINGENT,
	SPACE,
	AFTER,
	BEFORE,
	BEFORE_AND_AFTER,
	HYPHEN,
	NON_STARTER,
	OPEN_PUNCTUATION,
	CLOSE_PUNCTUATION,
	QUOTATION,
	EXCLAMATION,
	IDEOGRAPHIC,
	NUMERIC,
	INFIX_SEPARATOR,
	SYMBOL,
	ALPHABETIC,
	PREFIX,
	POSTFIX,
	COMPLEX_CONTEXT,
	AMBIGUOUS,
	UNKNOWN,
	NEXT_LINE,
	WORD_JOINER,
	HANGUL_L_JAMO,
	HANGUL_V_JAMO,
	HANGUL_T_JAMO,
	HANGUL_LV_SYLLABLE,
	HANGUL_LVT_SYLLABLE
}

Jürg Billeter's avatar
Jürg Billeter committed
451
[ReferenceType (dup_function = "g_strdup", free_function = "g_free", type_id = "G_TYPE_STRING")]
452
[CCode (cname = "char", const_cname = "const char", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string")]
453
public struct string {
454
	[CCode (cname = "strstr")]
455
	public weak string str (string! needle);
456
457
	[CCode (cname = "g_str_has_prefix")]
	public bool has_prefix (string! prefix);
458
	[CCode (cname = "g_str_has_suffix")]
459
	public bool has_suffix (string! suffix);
460
	[CCode (cname = "g_strdup_printf"), PrintfFormat]
461
	public string printf (...);
462
	[CCode (cname = "g_strconcat")]
463
	public string concat (string string2, ...);
464
	[CCode (cname = "g_strndup")]
465
	public string ndup (ulong n); /* FIXME: only UTF-8 */
466
	[CCode (cname = "g_strcompress")]
467
	public string compress ();
468
	[CCode (cname = "g_strsplit")]
469
	[NoArrayLength]
470
	public string[] split (string! delimiter, int max_tokens = 0);
471
	[CCode (cname = "g_strsplit_set")]
472
	[NoArrayLength]
473
	public string[] split_set (string! delimiters, int max_tokens = 0);
474
475
476
	[CCode (cname = "g_strjoinv")]
	[NoArrayLength]
	public static string joinv (string! separator, string[] str_array);
477
	
478
	[CCode (cname = "g_utf8_next_char")]
479
	public weak string next_char ();
480
481
	[CCode (cname = "g_utf8_get_char")]
	public unichar get_char ();
482
483
	[CCode (cname = "g_utf8_get_char_validated")]
	public unichar get_char_validated (long max_len = -1);
484
485
	[CCode (cname = "g_utf8_offset_to_pointer")]
	[PlusOperator ()]
486
	public weak string offset (long offset);
487
488
	[CCode (cname = "g_utf8_pointer_to_offset")]
	public long pointer_to_offset (string pos);
489
	[CCode (cname = "g_utf8_prev_char")]
490
	public weak string prev_char ();
491
	[CCode (cname = "g_utf8_strlen")]
492
	public long len (long max = -1);
493
	[CCode (cname = "g_utf8_strchr")]
494
	public weak string chr (long len, unichar c);
495
496
	[CCode (cname = "g_utf8_strrchr")]
	public weak string rchr (long len, unichar c);
497
	[CCode (cname = "g_utf8_strreverse")]
498
	public string! reverse (int len = -1);
499
500
	[CCode (cname = "g_utf8_validate")]
	public bool validate (long max_len = -1, out string end = null);
501
502
	
	[CCode (cname = "g_utf8_strup")]
503
	public string up (long len = -1);
504
	[CCode (cname = "g_utf8_strdown")]
505
	public string down (long len = -1);
506
	[CCode (cname = "g_utf8_casefold")]
507
	public string casefold (long len = -1);
508
509
	[CCode (cname = "g_utf8_collate")]
	public int collate (string str2);
510

511
512
513
514
	[CCode (cname = "g_locale_to_utf8")]
	public string! locale_to_utf8 (long len, out ulong bytes_read, out ulong bytes_written, out GLib.Error error = null);
  
	[CCode (cname = "g_strchomp")]
515
	public weak string chomp();
516
	[CCode (cname = "g_strchug")]
517
	public weak string chug();
518
519
	[CCode (cname = "g_strstrip")]
	public weak string strip ();
520
	
521
522
523
	[CCode (cname = "g_str_hash")]
	public uint hash ();
	
524
525
	[CCode (cname = "atoi")]
	public int to_int ();
526
527
	[CCode (cname = "strtoul")]
	public ulong to_ulong (out string endptr = null, int _base = 0);
528
	[CCode (cname = "g_ascii_strtoll")]
529
	public int64 to_int64 (out string endptr = null, int _base = 0);
530
531
	[CCode (cname = "strlen")]
	public long size ();
532
533
534

	[CCode (cname = "g_utf8_skip")]
	public static char[] skip;
535
536

	public string! substring (long offset, long len);
537
538
539
}

[Import ()]
540
[CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h")]
541
namespace GLib {
542
	public struct Type {
543
544
		[CCode (cname = "G_TYPE_IS_OBJECT")]
		public bool is_object ();
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
		[CCode (cname = "G_TYPE_IS_ABSTRACT")]
		public bool is_abstract ();
		[CCode (cname = "G_TYPE_IS_CLASSED")]
		public bool is_classed ();
		[CCode (cname = "G_TYPE_IS_DERIVABLE")]
		public bool is_derivable ();
		[CCode (cname = "G_TYPE_IS_DEEP_DERIVABLE")]
		public bool is_deep_derivable ();
		[CCode (cname = "G_TYPE_IS_DERIVED")]
		public bool is_derived ();
		[CCode (cname = "G_TYPE_IS_FUNDAMENTAL")]
		public bool is_fundamental ();
		[CCode (cname = "G_TYPE_IS_INSTANTIATABLE")]
		public bool is_instantiatable ();
		[CCode (cname = "G_TYPE_IS_INTERFACE")]
		public bool is_interface ();
		[CCode (cname = "G_TYPE_IS_VALUE_TYPE")]
		public bool is_value_type ();
563
		
564
		//public Type[] children (out uint n_children = null);
565
566
		public uint depth ();
		public static Type from_name (string! name);
567
		//public Type[] interfaces (out uint n_interfaces = null);
568
569
570
571
		public bool is_a (Type is_a_type);
		public string! name ();
		public Type parent ();
				
572
		public TypeClass class_ref ();
573
		
574
	}
Jürg Billeter's avatar
Jürg Billeter committed
575
576
577
578
579

	[ReferenceType]
	public struct TypeInstance {
	}

580
	[ReferenceType]
581
	public struct TypeClass {
582
583
		[CCode (cname = "G_TYPE_FROM_CLASS")]
		public Type get_type ();
584
	}
585
586
587
588
589
590
591
592
593
594

	public interface TypePlugin {
	}

	public class TypeModule : TypePlugin {
		public bool use ();
		public void unuse ();
		public void set_name (string! name);
	}

595
596
597
	[ReferenceType ()]
	public struct ParamSpec {
	}
Jürg Billeter's avatar
Jürg Billeter committed
598
599
600
601
602
603
604
605
606
607
608
609
610

	[CCode (cprefix = "G_PARAM_")]
	public enum ParamFlags {
		READABLE,
		WRITABLE,
		CONSTRUCT,
		CONSTRUCT_ONLY,
		LAX_VALIDATION,
		STATIC_NAME,
		STATIC_NICK,
		STATIC_BLURB
	}

611
612
	[ReferenceType ()]
	public struct ObjectClass {
613
		public ParamSpec[] list_properties (out int n_properties);
614
615
616
617
618
	}
	
	public struct ObjectConstructParam {
	}

619
	[CCode (cheader_filename = "glib-object.h")]
620
	public class Object {
621
622
		[CCode (cname = "G_TYPE_FROM_INSTANCE")]
		public Type get_type ();
623
624
625
		public Object @ref ();
		public void unref ();
		public Object ref_sink ();
Jürg Billeter's avatar
Jürg Billeter committed
626
		public void set (...);
627
		public void get_property (string! property_name, Value value);
Jürg Billeter's avatar
Jürg Billeter committed
628
629
630
		public virtual void dispose ();
		public virtual void finalize ();
		public virtual void constructed ();
631
		public void notify(string! property_name);
632
	}
633
	
634
	public class InitiallyUnowned : Object {
635
	}
636
637
638
639
640
641

	public /* static */ interface Boxed<G> {
		public abstract G copy ();
		public abstract void free ();
	}

642
643
	[ReferenceType (free_function = "g_free")]
	public struct Value {
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
		public weak Value init (Type g_type);
		public void copy (Value dest_value);
		public weak Value reset ();
		public void unset ();
		public void set_instance (pointer instance);
		public bool fits_pointer ();
		public pointer peek_pointer ();
		public static bool type_compatible (Type src_type, Type dest_type);
		public static bool type_transformable (Type src_type, Type dest_type);
		public bool transform (Value dest_value);
		[CCode (cname = "g_strdup_value_contents")]
		public string strdup_contents ();
		public void set_boolean (bool v_boolean);
		public bool get_boolean ();
		public void set_char (char v_char);
		public char get_char ();
		public void set_uchar (uchar v_uchar);
		public uchar get_uchar ();
		public void set_int (int v_int);
		public int get_int ();
		public void set_uint (uint v_uint);
		public uint get_uint ();
		public void set_long (long v_long);
		public long get_long ();
		public void set_ulong (ulong v_ulong);
		public ulong get_ulong ();
		public void set_int64 (int64 v_int64);
		public int64 get_int64 ();
		public void set_uint64 (uint64 v_uint64);
		public uint64 get_uint64 ();
		public void set_float (float v_float);
		public float get_float ();
		public void set_double (double v_double);
		public double get_double ();
		public void set_enum (int v_enum);
		public int get_enum ();
		public void set_flags (uint v_flags);
		public uint get_flags ();
		public void set_string (string v_string);
		public void set_static_string (string v_string);
		public void take_string (string# v_string);
		public weak string get_string ();
		public string dup_string ();
		public void set_pointer (pointer v_pointer);
		public pointer get_pointer ();
		public void set_object (Object v_object);
		public void take_object (Object# v_object);
691
		public weak Object get_object ();
692
693
694
		public Object dup_object ();
		public void set_gtype (Type v_gtype);
		public Type get_gtype ();
695
696
	}
	
697
698
699
700
701
702
	public struct SignalInvocationHint {
		public uint signal_id;
		public Quark detail;
		public SignalFlags run_type;
	}
	
703
	[NoArrayLength ()]
704
	public static delegate bool SignalEmissionHook (SignalInvocationHint ihint, uint n_param_values, Value[] param_values, pointer data);
705
706
707
708
709
710
711
712
713
714
	
	[CCode (cprefix = "G_SIGNAL_")]
	public enum SignalFlags {
		RUN_FIRST,
		RUN_LAST,
		RUN_CLEANUP,
		DETAILED,
		ACTION,
		NO_HOOKS
	}
715
716
717
718
719
720
721

	[CCode (cprefix = "G_CONNECT_")]
	public enum ConnectFlags {
		AFTER,
		SWAPPED
	}

722
	public static delegate void Callback ();
723
724
725
726
	
	public struct Closure {
	}
	
727
728
729
730
731
732
733
734
735
736
737
738
739
740
	public struct ValueArray {
	}

	[CCode (cheader_filename = "math.h")]
	public struct Math {
		[CCode (cname = "sqrt")]
		public static double sqrt (double v);
		
		[CCode (cname = "G_E")]
		public static double E;
		
		[CCode (cname = "G_PI")]
		public static double PI;
	}
741

Jürg Billeter's avatar
Jürg Billeter committed
742
743
	/* The Main Event Loop */
	
744
745
	[ReferenceType (dup_function = "g_main_loop_ref", free_function = "g_main_loop_unref")]
	public struct MainLoop {
746
		public MainLoop (MainContext context, bool is_running);
747
748
749
		public void run ();
		public void quit ();
		public bool is_running ();
750
		public weak MainContext get_context ();
751
752
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
753
754
755
756
757
758
759
760
	public enum Priority {
		HIGH,
		DEFAULT,
		HIGH_IDLE,
		DEFAULT_IDLE,
		LOW
	}
	
761
762
	[ReferenceType (dup_function = "g_main_context_ref", free_function = "g_main_context_unref")]
	public struct MainContext {
763
		public MainContext ();
764
		public static weak MainContext @default ();
765
766
		public bool iteration (bool may_block);
		public bool pending ();
767
768
769
		public weak Source find_source_by_id (uint source_id);
		public weak Source find_source_by_user_data (pointer user_data);
		public weak Source find_source_by_funcs_user_data (SourceFuncs funcs, pointer user_data);
770
771
772
773
		public void wakeup ();
		public bool acquire ();
		public void release ();
		public bool is_owner ();
Jürg Billeter's avatar
Jürg Billeter committed
774
		public bool wait (Cond cond, Mutex mutex);
775
		public bool prepare (out int priority);
Jürg Billeter's avatar
Jürg Billeter committed
776
		[NoArrayLength ()]
777
		public int query (int max_priority, out int timeout_, PollFD[] fds, int n_fds);
Jürg Billeter's avatar
Jürg Billeter committed
778
779
780
781
782
783
784
		public int check (int max_priority, PollFD[] fds, int n_fds);
		public void dispatch ();
		public void set_poll_func (PollFunc func);
		public PollFunc get_poll_func ();
		public void add_poll (ref PollFD fd, int priority);
		public void remove_poll (ref PollFD fd);
		public int depth ();
785
		public weak Source current_source ();
786
787
	}
	
788
	public static delegate int PollFunc (PollFD[] ufds, uint nfsd, int timeout_);
Jürg Billeter's avatar
Jürg Billeter committed
789
790
	
	public struct TimeoutSource : Source {
791
		public TimeoutSource (uint interval);
Jürg Billeter's avatar
Jürg Billeter committed
792
793
	}

794
795
	public struct Timeout {
		public static uint add (uint interval, SourceFunc function, pointer data);
Jürg Billeter's avatar
Jürg Billeter committed
796
		public static uint add_full (int priority, uint interval, SourceFunc function, pointer data, DestroyNotify notify);
797
798
	}
	
799
	[ReferenceType ()]
Jürg Billeter's avatar
Jürg Billeter committed
800
	public struct IdleSource : Source {
801
		public IdleSource ();
Jürg Billeter's avatar
Jürg Billeter committed
802
803
804
	}

	public struct Idle {
805
		public static uint add (SourceFunc function, pointer data);
Jürg Billeter's avatar
Jürg Billeter committed
806
807
		public static uint add_full (int priority, SourceFunc function, pointer data, DestroyNotify notify);
		public static bool remove_by_data (pointer data);
808
	}
Jürg Billeter's avatar
Jürg Billeter committed
809
810

	[CCode (default_value = "0")]
811
812
	public struct Pid {
	}
Jürg Billeter's avatar
Jürg Billeter committed
813

814
	public static delegate void ChildWatchFunc (Pid pid, int status, pointer data);
Jürg Billeter's avatar
Jürg Billeter committed
815
816
817
	
	[ReferenceType ()]
	public struct ChildWatchSource : Source {
818
		public ChildWatchSource (Pid pid, int status, pointer data);
Jürg Billeter's avatar
Jürg Billeter committed
819
820
821
822
823
824
825
826
	}
	
	public struct ChildWatch {
		public static uint add (Pid pid, ChildWatchFunc function, pointer data);
		public static uint add_full (int priority, Pid pid, ChildWatchFunc function, pointer data, DestroyNotify notify);
	}
	
	public struct PollFD {
Jürg Billeter's avatar
Jürg Billeter committed
827
828
829
		public int fd;
		public IOCondition events;
		public IOCondition revents;
Jürg Billeter's avatar
Jürg Billeter committed
830
831
	}
	
832
833
	[ReferenceType (dup_function = "g_source_ref", free_function = "g_source_unref")]
	public struct Source {
834
		public Source (SourceFuncs source_funcs, uint struct_size /* = sizeof (Source) */);
Jürg Billeter's avatar
Jürg Billeter committed
835
		public void set_funcs (SourceFuncs funcs);
836
		public uint attach (MainContext context);
Jürg Billeter's avatar
Jürg Billeter committed
837
838
839
840
841
842
843
		public void destroy ();
		public bool is_destroyed ();
		public void set_priority (int priority);
		public int get_priority ();
		public void set_can_recurse (bool can_recurse);
		public bool get_can_recurse ();
		public uint get_id ();
844
		public weak MainContext get_context ();
845
		public void set_callback (SourceFunc func, pointer data, DestroyNotify notify);
Jürg Billeter's avatar
Jürg Billeter committed
846
847
848
		public void set_callback_indirect (pointer callback_data, SourceCallbackFuncs callback_funcs);
		public void add_poll (ref PollFD fd);
		public void remove_poll (ref PollFD fd);
849
		public void get_current_time (out TimeVal timeval);
850
		public static void remove (uint id);
Jürg Billeter's avatar
Jürg Billeter committed
851
852
		public static bool remove_by_funcs_user_data (pointer user_data);
		public static bool remove_by_user_data (pointer user_data);
853
854
	}
	
855
	public static delegate void SourceDummyMarshal ();
Jürg Billeter's avatar
Jürg Billeter committed
856
	
857
858
859
860
	public static delegate bool SourcePrepareFunc (Source source, out int timeout_);
	public static delegate bool SourceCheckFunc (Source source);
	public static delegate bool SourceDispatchFunc (Source source, SourceFunc _callback, pointer user_data);
	public static delegate void SourceFinalizeFunc (Source source);
861
862
863
864
865
866
867
868
869
	
	[ReferenceType ()]
	public struct SourceFuncs {
		public SourcePrepareFunc prepare;
		public SourceCheckFunc check;
		public SourceDispatchFunc dispatch;
		public SourceFinalizeFunc finalize;
	}
	
870
871
872
	public static delegate void SourceCallbackRefFunc (pointer cb_data);
	public static delegate void SourceCallbackUnrefFunc (pointer cb_data);
	public static delegate void SourceCallbackGetFunc (pointer cb_data, Source source, SourceFunc func, pointer data);
Jürg Billeter's avatar
Jürg Billeter committed
873
874
875
876
877
878
879
880
	
	[ReferenceType ()]
	public struct SourceCallbackFuncs {
		public SourceCallbackRefFunc @ref;
		public SourceCallbackUnrefFunc unref;
		public SourceCallbackGetFunc @get;
	}
	
881
	public static delegate bool SourceFunc (pointer data);
882
883
884
885
886
887

	[ErrorDomain]
	public enum ThreadError {
		AGAIN
	}

888
	/* Thread support */
889
890
891
892
	[ReferenceType ()]
	public struct ThreadFunctions {
	}
	
893
894
	public static delegate pointer ThreadFunc (pointer data);
	public static delegate void Func (pointer data, pointer user_data);
895
896
897
898
899
900
901
902
	
	public enum ThreadPriority {
		LOW,
		NORMAL,
		HIGH,
		URGENT
	}
	
903
904
	[ReferenceType ()]
	public struct Thread {
905
		public static void init (ThreadFunctions vtable = null);
906
		public static bool supported ();
907
908
		public static weak Thread create (ThreadFunc func, pointer data, bool joinable) throws ThreadError;
		public static weak Thread create_full (ThreadFunc func, pointer data, ulong stack_size, bool joinable, bool bound, ThreadPriority priority) throws ThreadError;
909
		public static weak Thread self ();
910
911
912
913
914
		public pointer join ();
		public void set_priority (ThreadPriority priority);
		public static void yield ();
		public static void exit (pointer retval);
		public static void @foreach (Func thread_func, pointer user_data);
915
916
917
		
		[CCode (cname = "g_usleep")]
		public static void usleep (ulong microseconds);
918
919
	}
	
920
921
	[ReferenceType (free_function = "g_mutex_free")]
	public struct Mutex {
922
		public Mutex ();
923
924
925
926
927
928
929
		public void @lock ();
		public bool try_lock ();
		public void unlock ();
	}
	
	[ReferenceType (free_function = "g_cond_free")]
	public struct Cond {
930
		public Cond ();
931
932
933
934
935
936
		public void @signal ();
		public void broadcast ();
		public void wait (Mutex mutex);
		public bool timed_wait (Mutex mutex, TimeVal abs_time);
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
937
938
939
940
	/* Thread Pools */
	
	[ReferenceType (free_function = "g_thread_pool_free")]
	public struct ThreadPool {
941
942
943
		public ThreadPool (Func func, pointer user_data, int max_threads, bool exclusive) throws ThreadError;
		public void push (pointer data) throws ThreadError;
		public void set_max_threads (int max_threads) throws ThreadError;
Jürg Billeter's avatar
Jürg Billeter committed
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
		public int get_max_threads ();
		public uint get_num_threads ();
		public uint unprocessed ();
		public static void set_max_unused_threads (int max_threads);
		public static int get_max_unused_threads ();
		public static uint get_num_unused_threads ();
		public static void stop_unused_threads ();
		public void set_sort_function (CompareDataFunc func, pointer user_data);
		public static void set_max_idle_time (uint interval);
		public static uint get_max_idle_time ();
	}
	
	/* Asynchronous Queues */
	
	[ReferenceType (dup_function = "g_async_queue_ref", free_function = "g_async_queue_unref")]
	public struct AsyncQueue {
960
		public AsyncQueue ();
Jürg Billeter's avatar
Jürg Billeter committed
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
		public void push (pointer data);
		public void push_sorted (pointer data, CompareDataFunc func, pointer user_data);
		public pointer pop ();
		public pointer try_pop ();
		public pointer timed_pop (ref TimeVal end_time);
		public int length ();
		public void sort (CompareDataFunc func, pointer user_data);
		public void @lock ();
		public void unlock ();
		public void ref_unlocked ();
		public void unref_and_unlock ();
		public void push_unlocked (pointer data);
		public void push_sorted_unlocked (pointer data, CompareDataFunc func, pointer user_data);
		public pointer pop_unlocked ();
		public pointer try_pop_unlocked ();
		public pointer timed_pop_unlocked (ref TimeVal end_time);
		public int length_unlocked ();
		public void sort_unlocked (CompareDataFunc func, pointer user_data);
	}
	
	/* Dynamic Loading of Modules */
	
	[ReferenceType (free_function = "g_module_close")]
	public struct Module {
		public static bool supported ();
986
987
988
		public static string build_path (string directory, string module_name);
		public static Module open (string file_name, ModuleFlags @flags);
		public bool symbol (string! symbol_name, out pointer symbol);
989
		public weak string name ();
Jürg Billeter's avatar
Jürg Billeter committed
990
		public void make_resident ();
991
		public weak string error ();
Jürg Billeter's avatar
Jürg Billeter committed
992
993
994
995
996
997
998
999
1000
	}
	
	[CCode (cprefix = "G_MODULE_")]
	public enum ModuleFlags {
		BIND_LAZY,
		BIND_LOCAL,
		BIND_MASK
	}