17
17
* Boston, MA 02111-1307, USA.
20
#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
21
#error "Only <glib.h> can be included directly."
24
20
#ifndef __G_MAIN_H__
25
21
#define __G_MAIN_H__
23
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
24
#error "Only <glib.h> can be included directly."
27
27
#include <glib/gpoll.h>
28
28
#include <glib/gslist.h>
29
29
#include <glib/gthread.h>
33
typedef enum /*< flags >*/
35
G_IO_IN GLIB_SYSDEF_POLLIN,
36
G_IO_OUT GLIB_SYSDEF_POLLOUT,
37
G_IO_PRI GLIB_SYSDEF_POLLPRI,
38
G_IO_ERR GLIB_SYSDEF_POLLERR,
39
G_IO_HUP GLIB_SYSDEF_POLLHUP,
40
G_IO_NVAL GLIB_SYSDEF_POLLNVAL
75
86
* a @timeout_ value which should be the maximum timeout (in milliseconds)
76
87
* which should be passed to the poll() call. The actual timeout used will
77
88
* be -1 if all sources returned -1, or it will be the minimum of all the
78
* @timeout_ values returned which were >= 0.
89
* @timeout_ values returned which were >= 0. Since 2.36 this may
90
* be %NULL, in which case the effect is as if the function always
91
* returns %FALSE with a timeout of -1. If @prepare returns a
92
* timeout and the source also has a 'ready time' set then the
93
* nearer of the two will be used.
79
94
* @check: Called after all the file descriptors are polled. The source
80
95
* should return %TRUE if it is ready to be dispatched. Note that some
81
96
* time may have passed since the previous prepare function was called,
82
* so the source should be checked again here.
97
* so the source should be checked again here. Since 2.36 this may
98
* be %NULL, in which case the effect is as if the function always
83
100
* @dispatch: Called to dispatch the event source, after it has returned
84
101
* %TRUE in either its @prepare or its @check function. The @dispatch
85
102
* function is passed in a callback function and data. The callback
283
302
/* GMainContext: */
304
GLIB_AVAILABLE_IN_ALL
285
305
GMainContext *g_main_context_new (void);
306
GLIB_AVAILABLE_IN_ALL
286
307
GMainContext *g_main_context_ref (GMainContext *context);
308
GLIB_AVAILABLE_IN_ALL
287
309
void g_main_context_unref (GMainContext *context);
310
GLIB_AVAILABLE_IN_ALL
288
311
GMainContext *g_main_context_default (void);
313
GLIB_AVAILABLE_IN_ALL
290
314
gboolean g_main_context_iteration (GMainContext *context,
291
315
gboolean may_block);
316
GLIB_AVAILABLE_IN_ALL
292
317
gboolean g_main_context_pending (GMainContext *context);
294
319
/* For implementation of legacy interfaces
321
GLIB_AVAILABLE_IN_ALL
296
322
GSource *g_main_context_find_source_by_id (GMainContext *context,
297
323
guint source_id);
324
GLIB_AVAILABLE_IN_ALL
298
325
GSource *g_main_context_find_source_by_user_data (GMainContext *context,
299
326
gpointer user_data);
327
GLIB_AVAILABLE_IN_ALL
300
328
GSource *g_main_context_find_source_by_funcs_user_data (GMainContext *context,
301
329
GSourceFuncs *funcs,
302
330
gpointer user_data);
304
332
/* Low level functions for implementing custom main loops.
334
GLIB_AVAILABLE_IN_ALL
306
335
void g_main_context_wakeup (GMainContext *context);
336
GLIB_AVAILABLE_IN_ALL
307
337
gboolean g_main_context_acquire (GMainContext *context);
338
GLIB_AVAILABLE_IN_ALL
308
339
void g_main_context_release (GMainContext *context);
340
GLIB_AVAILABLE_IN_ALL
309
341
gboolean g_main_context_is_owner (GMainContext *context);
342
GLIB_AVAILABLE_IN_ALL
310
343
gboolean g_main_context_wait (GMainContext *context,
347
GLIB_AVAILABLE_IN_ALL
314
348
gboolean g_main_context_prepare (GMainContext *context,
350
GLIB_AVAILABLE_IN_ALL
316
351
gint g_main_context_query (GMainContext *context,
317
352
gint max_priority,
356
GLIB_AVAILABLE_IN_ALL
321
357
gint g_main_context_check (GMainContext *context,
322
358
gint max_priority,
361
GLIB_AVAILABLE_IN_ALL
325
362
void g_main_context_dispatch (GMainContext *context);
364
GLIB_AVAILABLE_IN_ALL
327
365
void g_main_context_set_poll_func (GMainContext *context,
367
GLIB_AVAILABLE_IN_ALL
329
368
GPollFunc g_main_context_get_poll_func (GMainContext *context);
331
370
/* Low level functions for use by source implementations
372
GLIB_AVAILABLE_IN_ALL
333
373
void g_main_context_add_poll (GMainContext *context,
376
GLIB_AVAILABLE_IN_ALL
336
377
void g_main_context_remove_poll (GMainContext *context,
380
GLIB_AVAILABLE_IN_ALL
339
381
gint g_main_depth (void);
382
GLIB_AVAILABLE_IN_ALL
340
383
GSource *g_main_current_source (void);
342
385
/* GMainContexts for other threads
387
GLIB_AVAILABLE_IN_ALL
344
388
void g_main_context_push_thread_default (GMainContext *context);
389
GLIB_AVAILABLE_IN_ALL
345
390
void g_main_context_pop_thread_default (GMainContext *context);
391
GLIB_AVAILABLE_IN_ALL
346
392
GMainContext *g_main_context_get_thread_default (void);
393
GLIB_AVAILABLE_IN_ALL
347
394
GMainContext *g_main_context_ref_thread_default (void);
398
GLIB_AVAILABLE_IN_ALL
351
399
GMainLoop *g_main_loop_new (GMainContext *context,
352
400
gboolean is_running);
401
GLIB_AVAILABLE_IN_ALL
353
402
void g_main_loop_run (GMainLoop *loop);
403
GLIB_AVAILABLE_IN_ALL
354
404
void g_main_loop_quit (GMainLoop *loop);
405
GLIB_AVAILABLE_IN_ALL
355
406
GMainLoop *g_main_loop_ref (GMainLoop *loop);
407
GLIB_AVAILABLE_IN_ALL
356
408
void g_main_loop_unref (GMainLoop *loop);
409
GLIB_AVAILABLE_IN_ALL
357
410
gboolean g_main_loop_is_running (GMainLoop *loop);
411
GLIB_AVAILABLE_IN_ALL
358
412
GMainContext *g_main_loop_get_context (GMainLoop *loop);
416
GLIB_AVAILABLE_IN_ALL
362
417
GSource *g_source_new (GSourceFuncs *source_funcs,
363
418
guint struct_size);
419
GLIB_AVAILABLE_IN_ALL
364
420
GSource *g_source_ref (GSource *source);
421
GLIB_AVAILABLE_IN_ALL
365
422
void g_source_unref (GSource *source);
424
GLIB_AVAILABLE_IN_ALL
367
425
guint g_source_attach (GSource *source,
368
426
GMainContext *context);
427
GLIB_AVAILABLE_IN_ALL
369
428
void g_source_destroy (GSource *source);
430
GLIB_AVAILABLE_IN_ALL
371
431
void g_source_set_priority (GSource *source,
433
GLIB_AVAILABLE_IN_ALL
373
434
gint g_source_get_priority (GSource *source);
435
GLIB_AVAILABLE_IN_ALL
374
436
void g_source_set_can_recurse (GSource *source,
375
437
gboolean can_recurse);
438
GLIB_AVAILABLE_IN_ALL
376
439
gboolean g_source_get_can_recurse (GSource *source);
440
GLIB_AVAILABLE_IN_ALL
377
441
guint g_source_get_id (GSource *source);
443
GLIB_AVAILABLE_IN_ALL
379
444
GMainContext *g_source_get_context (GSource *source);
446
GLIB_AVAILABLE_IN_ALL
381
447
void g_source_set_callback (GSource *source,
382
448
GSourceFunc func,
384
450
GDestroyNotify notify);
452
GLIB_AVAILABLE_IN_ALL
386
453
void g_source_set_funcs (GSource *source,
387
454
GSourceFuncs *funcs);
455
GLIB_AVAILABLE_IN_ALL
388
456
gboolean g_source_is_destroyed (GSource *source);
458
GLIB_AVAILABLE_IN_ALL
390
459
void g_source_set_name (GSource *source,
391
460
const char *name);
461
GLIB_AVAILABLE_IN_ALL
392
462
const char * g_source_get_name (GSource *source);
463
GLIB_AVAILABLE_IN_ALL
393
464
void g_source_set_name_by_id (guint tag,
394
465
const char *name);
467
GLIB_AVAILABLE_IN_2_36
468
void g_source_set_ready_time (GSource *source,
470
GLIB_AVAILABLE_IN_2_36
471
gint64 g_source_get_ready_time (GSource *source);
474
GLIB_AVAILABLE_IN_2_36
475
gpointer g_source_add_unix_fd (GSource *source,
477
GIOCondition events);
478
GLIB_AVAILABLE_IN_2_36
479
void g_source_modify_unix_fd (GSource *source,
481
GIOCondition new_events);
482
GLIB_AVAILABLE_IN_2_36
483
void g_source_remove_unix_fd (GSource *source,
485
GLIB_AVAILABLE_IN_2_36
486
GIOCondition g_source_query_unix_fd (GSource *source,
397
490
/* Used to implement g_source_connect_closure and internally*/
491
GLIB_AVAILABLE_IN_ALL
398
492
void g_source_set_callback_indirect (GSource *source,
399
493
gpointer callback_data,
400
494
GSourceCallbackFuncs *callback_funcs);
496
GLIB_AVAILABLE_IN_ALL
402
497
void g_source_add_poll (GSource *source,
499
GLIB_AVAILABLE_IN_ALL
404
500
void g_source_remove_poll (GSource *source,
503
GLIB_AVAILABLE_IN_ALL
407
504
void g_source_add_child_source (GSource *source,
408
505
GSource *child_source);
506
GLIB_AVAILABLE_IN_ALL
409
507
void g_source_remove_child_source (GSource *source,
410
508
GSource *child_source);
422
521
/* Specific source types
523
GLIB_AVAILABLE_IN_ALL
424
524
GSource *g_idle_source_new (void);
525
GLIB_AVAILABLE_IN_ALL
425
526
GSource *g_child_watch_source_new (GPid pid);
527
GLIB_AVAILABLE_IN_ALL
426
528
GSource *g_timeout_source_new (guint interval);
529
GLIB_AVAILABLE_IN_ALL
427
530
GSource *g_timeout_source_new_seconds (guint interval);
429
532
/* Miscellaneous functions
534
GLIB_AVAILABLE_IN_ALL
431
535
void g_get_current_time (GTimeVal *result);
536
GLIB_AVAILABLE_IN_ALL
432
537
gint64 g_get_monotonic_time (void);
538
GLIB_AVAILABLE_IN_ALL
433
539
gint64 g_get_real_time (void);
436
542
/* Source manipulation by ID */
543
GLIB_AVAILABLE_IN_ALL
437
544
gboolean g_source_remove (guint tag);
545
GLIB_AVAILABLE_IN_ALL
438
546
gboolean g_source_remove_by_user_data (gpointer user_data);
547
GLIB_AVAILABLE_IN_ALL
439
548
gboolean g_source_remove_by_funcs_user_data (GSourceFuncs *funcs,
440
549
gpointer user_data);
442
551
/* Idles, child watchers and timeouts */
552
GLIB_AVAILABLE_IN_ALL
443
553
guint g_timeout_add_full (gint priority,
445
555
GSourceFunc function,
447
557
GDestroyNotify notify);
558
GLIB_AVAILABLE_IN_ALL
448
559
guint g_timeout_add (guint interval,
449
560
GSourceFunc function,
562
GLIB_AVAILABLE_IN_ALL
451
563
guint g_timeout_add_seconds_full (gint priority,
453
565
GSourceFunc function,
455
567
GDestroyNotify notify);
568
GLIB_AVAILABLE_IN_ALL
456
569
guint g_timeout_add_seconds (guint interval,
457
570
GSourceFunc function,
572
GLIB_AVAILABLE_IN_ALL
459
573
guint g_child_watch_add_full (gint priority,
461
575
GChildWatchFunc function,
463
577
GDestroyNotify notify);
578
GLIB_AVAILABLE_IN_ALL
464
579
guint g_child_watch_add (GPid pid,
465
580
GChildWatchFunc function,
582
GLIB_AVAILABLE_IN_ALL
467
583
guint g_idle_add (GSourceFunc function,
585
GLIB_AVAILABLE_IN_ALL
469
586
guint g_idle_add_full (gint priority,
470
587
GSourceFunc function,
472
589
GDestroyNotify notify);
590
GLIB_AVAILABLE_IN_ALL
473
591
gboolean g_idle_remove_by_data (gpointer data);
593
GLIB_AVAILABLE_IN_ALL
475
594
void g_main_context_invoke_full (GMainContext *context,
477
596
GSourceFunc function,
479
598
GDestroyNotify notify);
599
GLIB_AVAILABLE_IN_ALL
480
600
void g_main_context_invoke (GMainContext *context,
481
601
GSourceFunc function,