~ubuntu-branches/debian/sid/glib2.0/sid

« back to all changes in this revision

Viewing changes to glib/gmain.h

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 06:25:57 UTC
  • mfrom: (1.27.14) (3.1.181 experimental)
  • Revision ID: package-import@ubuntu.com-20130508062557-i7gbku66mls70gi2
Tags: 2.36.1-2
Merge experimental branch, upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * Boston, MA 02111-1307, USA.
18
18
 */
19
19
 
20
 
#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
21
 
#error "Only <glib.h> can be included directly."
22
 
#endif
23
 
 
24
20
#ifndef __G_MAIN_H__
25
21
#define __G_MAIN_H__
26
22
 
 
23
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
 
24
#error "Only <glib.h> can be included directly."
 
25
#endif
 
26
 
27
27
#include <glib/gpoll.h>
28
28
#include <glib/gslist.h>
29
29
#include <glib/gthread.h>
30
30
 
31
31
G_BEGIN_DECLS
32
32
 
 
33
typedef enum /*< flags >*/
 
34
{
 
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
 
41
} GIOCondition;
 
42
 
 
43
 
33
44
/**
34
45
 * GMainContext:
35
46
 *
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
 
99
 *     returns %FALSE.
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
139
156
/**
140
157
 * GChildWatchFunc:
141
158
 * @pid: the process id of the child process
142
 
 * @status: Status information about the child process,
143
 
 *     see waitpid(2) for more information about this field
 
159
 * @status: Status information about the child process, encoded
 
160
 *     in a platform-specific manner
144
161
 * @user_data: user data passed to g_child_watch_add()
145
162
 *
146
 
 * The type of functions to be called when a child exists.
 
163
 * Prototype of a #GChildWatchSource callback, called when a child
 
164
 * process has exited.  To interpret @status, see the documentation
 
165
 * for g_spawn_check_exit_status().
147
166
 */
148
167
typedef void     (*GChildWatchFunc)   (GPid     pid,
149
168
                                       gint     status,
154
173
  gpointer callback_data;
155
174
  GSourceCallbackFuncs *callback_funcs;
156
175
 
157
 
  GSourceFuncs *source_funcs;
 
176
  const GSourceFuncs *source_funcs;
158
177
  guint ref_count;
159
178
 
160
179
  GMainContext *context;
282
301
 
283
302
/* GMainContext: */
284
303
 
 
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);
289
312
 
 
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);
293
318
 
294
319
/* For implementation of legacy interfaces
295
320
 */
 
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);
303
331
 
304
332
/* Low level functions for implementing custom main loops.
305
333
 */
 
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,
311
344
                                 GCond        *cond,
312
345
                                 GMutex       *mutex);
313
346
 
 
347
GLIB_AVAILABLE_IN_ALL
314
348
gboolean g_main_context_prepare  (GMainContext *context,
315
349
                                  gint         *priority);
 
350
GLIB_AVAILABLE_IN_ALL
316
351
gint     g_main_context_query    (GMainContext *context,
317
352
                                  gint          max_priority,
318
353
                                  gint         *timeout_,
319
354
                                  GPollFD      *fds,
320
355
                                  gint          n_fds);
 
356
GLIB_AVAILABLE_IN_ALL
321
357
gint     g_main_context_check    (GMainContext *context,
322
358
                                  gint          max_priority,
323
359
                                  GPollFD      *fds,
324
360
                                  gint          n_fds);
 
361
GLIB_AVAILABLE_IN_ALL
325
362
void     g_main_context_dispatch (GMainContext *context);
326
363
 
 
364
GLIB_AVAILABLE_IN_ALL
327
365
void     g_main_context_set_poll_func (GMainContext *context,
328
366
                                       GPollFunc     func);
 
367
GLIB_AVAILABLE_IN_ALL
329
368
GPollFunc g_main_context_get_poll_func (GMainContext *context);
330
369
 
331
370
/* Low level functions for use by source implementations
332
371
 */
 
372
GLIB_AVAILABLE_IN_ALL
333
373
void     g_main_context_add_poll    (GMainContext *context,
334
374
                                     GPollFD      *fd,
335
375
                                     gint          priority);
 
376
GLIB_AVAILABLE_IN_ALL
336
377
void     g_main_context_remove_poll (GMainContext *context,
337
378
                                     GPollFD      *fd);
338
379
 
 
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);
341
384
 
342
385
/* GMainContexts for other threads
343
386
 */
 
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);
348
395
 
349
396
/* GMainLoop: */
350
397
 
 
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);
359
413
 
360
414
/* GSource: */
361
415
 
 
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);
366
423
 
 
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);
370
429
 
 
430
GLIB_AVAILABLE_IN_ALL
371
431
void     g_source_set_priority    (GSource        *source,
372
432
                                   gint            priority);
 
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);
378
442
 
 
443
GLIB_AVAILABLE_IN_ALL
379
444
GMainContext *g_source_get_context (GSource       *source);
380
445
 
 
446
GLIB_AVAILABLE_IN_ALL
381
447
void     g_source_set_callback    (GSource        *source,
382
448
                                   GSourceFunc     func,
383
449
                                   gpointer        data,
384
450
                                   GDestroyNotify  notify);
385
451
 
 
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);
389
457
 
 
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);
395
466
 
 
467
GLIB_AVAILABLE_IN_2_36
 
468
void                 g_source_set_ready_time (GSource        *source,
 
469
                                              gint64          ready_time);
 
470
GLIB_AVAILABLE_IN_2_36
 
471
gint64               g_source_get_ready_time (GSource        *source);
 
472
 
 
473
#ifdef G_OS_UNIX
 
474
GLIB_AVAILABLE_IN_2_36
 
475
gpointer             g_source_add_unix_fd    (GSource        *source,
 
476
                                              gint            fd,
 
477
                                              GIOCondition    events);
 
478
GLIB_AVAILABLE_IN_2_36
 
479
void                 g_source_modify_unix_fd (GSource        *source,
 
480
                                              gpointer        tag,
 
481
                                              GIOCondition    new_events);
 
482
GLIB_AVAILABLE_IN_2_36
 
483
void                 g_source_remove_unix_fd (GSource        *source,
 
484
                                              gpointer        tag);
 
485
GLIB_AVAILABLE_IN_2_36
 
486
GIOCondition         g_source_query_unix_fd  (GSource        *source,
 
487
                                              gpointer        tag);
 
488
#endif
396
489
 
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);
401
495
 
 
496
GLIB_AVAILABLE_IN_ALL
402
497
void     g_source_add_poll            (GSource        *source,
403
498
                                       GPollFD        *fd);
 
499
GLIB_AVAILABLE_IN_ALL
404
500
void     g_source_remove_poll         (GSource        *source,
405
501
                                       GPollFD        *fd);
406
502
 
 
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);
411
509
 
413
511
void     g_source_get_current_time (GSource        *source,
414
512
                                    GTimeVal       *timeval);
415
513
 
 
514
GLIB_AVAILABLE_IN_ALL
416
515
gint64   g_source_get_time         (GSource        *source);
417
516
 
418
517
 /* void g_source_connect_closure (GSource        *source,
421
520
 
422
521
/* Specific source types
423
522
 */
 
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);
428
531
 
429
532
/* Miscellaneous functions
430
533
 */
 
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);
434
540
 
435
541
 
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);
441
550
 
442
551
/* Idles, child watchers and timeouts */
 
552
GLIB_AVAILABLE_IN_ALL
443
553
guint    g_timeout_add_full         (gint            priority,
444
554
                                     guint           interval,
445
555
                                     GSourceFunc     function,
446
556
                                     gpointer        data,
447
557
                                     GDestroyNotify  notify);
 
558
GLIB_AVAILABLE_IN_ALL
448
559
guint    g_timeout_add              (guint           interval,
449
560
                                     GSourceFunc     function,
450
561
                                     gpointer        data);
 
562
GLIB_AVAILABLE_IN_ALL
451
563
guint    g_timeout_add_seconds_full (gint            priority,
452
564
                                     guint           interval,
453
565
                                     GSourceFunc     function,
454
566
                                     gpointer        data,
455
567
                                     GDestroyNotify  notify);
 
568
GLIB_AVAILABLE_IN_ALL
456
569
guint    g_timeout_add_seconds      (guint           interval,
457
570
                                     GSourceFunc     function,
458
571
                                     gpointer        data);
 
572
GLIB_AVAILABLE_IN_ALL
459
573
guint    g_child_watch_add_full     (gint            priority,
460
574
                                     GPid            pid,
461
575
                                     GChildWatchFunc function,
462
576
                                     gpointer        data,
463
577
                                     GDestroyNotify  notify);
 
578
GLIB_AVAILABLE_IN_ALL
464
579
guint    g_child_watch_add          (GPid            pid,
465
580
                                     GChildWatchFunc function,
466
581
                                     gpointer        data);
 
582
GLIB_AVAILABLE_IN_ALL
467
583
guint    g_idle_add                 (GSourceFunc     function,
468
584
                                     gpointer        data);
 
585
GLIB_AVAILABLE_IN_ALL
469
586
guint    g_idle_add_full            (gint            priority,
470
587
                                     GSourceFunc     function,
471
588
                                     gpointer        data,
472
589
                                     GDestroyNotify  notify);
 
590
GLIB_AVAILABLE_IN_ALL
473
591
gboolean g_idle_remove_by_data      (gpointer        data);
474
592
 
 
593
GLIB_AVAILABLE_IN_ALL
475
594
void     g_main_context_invoke_full (GMainContext   *context,
476
595
                                     gint            priority,
477
596
                                     GSourceFunc     function,
478
597
                                     gpointer        data,
479
598
                                     GDestroyNotify  notify);
 
599
GLIB_AVAILABLE_IN_ALL
480
600
void     g_main_context_invoke      (GMainContext   *context,
481
601
                                     GSourceFunc     function,
482
602
                                     gpointer        data);