Update to version 2.33.1
[profile/ivi/glib2.git] / docs / reference / glib / html / glib-The-Main-Event-Loop.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>The Main Event Loop</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GLib Reference Manual">
8 <link rel="up" href="glib-core.html" title="GLib Core Application Support">
9 <link rel="prev" href="glib-core.html" title="GLib Core Application Support">
10 <link rel="next" href="glib-Threads.html" title="Threads">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
16 <tr valign="middle">
17 <td><a accesskey="p" href="glib-core.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="glib-core.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GLib Reference Manual</th>
21 <td><a accesskey="n" href="glib-Threads.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
22 </tr>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#glib-The-Main-Event-Loop.synopsis" class="shortcut">Top</a>
25                    | 
26                   <a href="#glib-The-Main-Event-Loop.description" class="shortcut">Description</a>
27 </td></tr>
28 </table>
29 <div class="refentry">
30 <a name="glib-The-Main-Event-Loop"></a><div class="titlepage"></div>
31 <div class="refnamediv"><table width="100%"><tr>
32 <td valign="top">
33 <h2><span class="refentrytitle"><a name="glib-The-Main-Event-Loop.top_of_page"></a>The Main Event Loop</span></h2>
34 <p>The Main Event Loop — manages all available sources of events</p>
35 </td>
36 <td valign="top" align="right"></td>
37 </tr></table></div>
38 <div class="refsynopsisdiv">
39 <a name="glib-The-Main-Event-Loop.synopsis"></a><h2>Synopsis</h2>
40 <pre class="synopsis">
41 #include &lt;glib.h&gt;
42
43                     <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop">GMainLoop</a>;
44 <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="returnvalue">GMainLoop</span></a> *         <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-new" title="g_main_loop_new ()">g_main_loop_new</a>                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
45                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> is_running</code></em>);
46 <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="returnvalue">GMainLoop</span></a> *         <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-ref" title="g_main_loop_ref ()">g_main_loop_ref</a>                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);
47 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-unref" title="g_main_loop_unref ()">g_main_loop_unref</a>                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);
48 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()">g_main_loop_run</a>                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);
49 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()">g_main_loop_quit</a>                    (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);
50 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-is-running" title="g_main_loop_is_running ()">g_main_loop_is_running</a>              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);
51 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-get-context" title="g_main_loop_get_context ()">g_main_loop_get_context</a>             (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);
52 #define             <a class="link" href="glib-The-Main-Event-Loop.html#g-main-new" title="g_main_new()">g_main_new</a>                          (is_running)
53 #define             <a class="link" href="glib-The-Main-Event-Loop.html#g-main-destroy" title="g_main_destroy()">g_main_destroy</a>                      (loop)
54 #define             <a class="link" href="glib-The-Main-Event-Loop.html#g-main-run" title="g_main_run()">g_main_run</a>                          (loop)
55 #define             <a class="link" href="glib-The-Main-Event-Loop.html#g-main-quit" title="g_main_quit()">g_main_quit</a>                         (loop)
56 #define             <a class="link" href="glib-The-Main-Event-Loop.html#g-main-is-running" title="g_main_is_running()">g_main_is_running</a>                   (loop)
57
58 #define             <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH:CAPS" title="G_PRIORITY_HIGH">G_PRIORITY_HIGH</a>
59 #define             <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT">G_PRIORITY_DEFAULT</a>
60 #define             <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE">G_PRIORITY_HIGH_IDLE</a>
61 #define             <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE">G_PRIORITY_DEFAULT_IDLE</a>
62 #define             <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-LOW:CAPS" title="G_PRIORITY_LOW">G_PRIORITY_LOW</a>
63
64 #define             <a class="link" href="glib-The-Main-Event-Loop.html#G-SOURCE-CONTINUE:CAPS" title="G_SOURCE_CONTINUE">G_SOURCE_CONTINUE</a>
65 #define             <a class="link" href="glib-The-Main-Event-Loop.html#G-SOURCE-REMOVE:CAPS" title="G_SOURCE_REMOVE">G_SOURCE_REMOVE</a>
66
67                     <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext">GMainContext</a>;
68 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-new" title="g_main_context_new ()">g_main_context_new</a>                  (<em class="parameter"><code><span class="type">void</span></code></em>);
69 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref" title="g_main_context_ref ()">g_main_context_ref</a>                  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
70 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-unref" title="g_main_context_unref ()">g_main_context_unref</a>                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
71 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-default" title="g_main_context_default ()">g_main_context_default</a>              (<em class="parameter"><code><span class="type">void</span></code></em>);
72 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()">g_main_context_iteration</a>            (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
73                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> may_block</code></em>);
74 #define             <a class="link" href="glib-The-Main-Event-Loop.html#g-main-iteration" title="g_main_iteration()">g_main_iteration</a>                    (may_block)
75 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pending" title="g_main_context_pending ()">g_main_context_pending</a>              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
76 #define             <a class="link" href="glib-The-Main-Event-Loop.html#g-main-pending" title="g_main_pending">g_main_pending</a>
77 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-find-source-by-id" title="g_main_context_find_source_by_id ()">g_main_context_find_source_by_id</a>    (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
78                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> source_id</code></em>);
79 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-find-source-by-user-data" title="g_main_context_find_source_by_user_data ()">g_main_context_find_source_by_user_data</a>
80                                                         (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
81                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
82 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-find-source-by-funcs-user-data" title="g_main_context_find_source_by_funcs_user_data ()">g_main_context_find_source_by_funcs_user_data</a>
83                                                         (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
84                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>,
85                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
86 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-wakeup" title="g_main_context_wakeup ()">g_main_context_wakeup</a>               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
87 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()">g_main_context_acquire</a>              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
88 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-release" title="g_main_context_release ()">g_main_context_release</a>              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
89 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-is-owner" title="g_main_context_is_owner ()">g_main_context_is_owner</a>             (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
90 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-wait" title="g_main_context_wait ()">g_main_context_wait</a>                 (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
91                                                          <em class="parameter"><code><a class="link" href="glib-Threads.html#GCond" title="struct GCond"><span class="type">GCond</span></a> *cond</code></em>,
92                                                          <em class="parameter"><code><a class="link" href="glib-Threads.html#GMutex" title="union GMutex"><span class="type">GMutex</span></a> *mutex</code></em>);
93 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-prepare" title="g_main_context_prepare ()">g_main_context_prepare</a>              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
94                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *priority</code></em>);
95 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()">g_main_context_query</a>                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
96                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> max_priority</code></em>,
97                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *timeout_</code></em>,
98                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>,
99                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> n_fds</code></em>);
100 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-check" title="g_main_context_check ()">g_main_context_check</a>                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
101                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> max_priority</code></em>,
102                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>,
103                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> n_fds</code></em>);
104 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-dispatch" title="g_main_context_dispatch ()">g_main_context_dispatch</a>             (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
105 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-set-poll-func" title="g_main_context_set_poll_func ()">g_main_context_set_poll_func</a>        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
106                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFunc" title="GPollFunc ()"><span class="type">GPollFunc</span></a> func</code></em>);
107 <a class="link" href="glib-The-Main-Event-Loop.html#GPollFunc" title="GPollFunc ()"><span class="returnvalue">GPollFunc</span></a>           <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-poll-func" title="g_main_context_get_poll_func ()">g_main_context_get_poll_func</a>        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
108 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                (<a class="link" href="glib-The-Main-Event-Loop.html#GPollFunc" title="GPollFunc ()">*GPollFunc</a>)                        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *ufds</code></em>,
109                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> nfsd</code></em>,
110                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> timeout_</code></em>);
111 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-add-poll" title="g_main_context_add_poll ()">g_main_context_add_poll</a>             (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
112                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>,
113                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>);
114 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-remove-poll" title="g_main_context_remove_poll ()">g_main_context_remove_poll</a>          (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
115                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);
116 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-depth" title="g_main_depth ()">g_main_depth</a>                        (<em class="parameter"><code><span class="type">void</span></code></em>);
117 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-main-current-source" title="g_main_current_source ()">g_main_current_source</a>               (<em class="parameter"><code><span class="type">void</span></code></em>);
118 #define             <a class="link" href="glib-The-Main-Event-Loop.html#g-main-set-poll-func" title="g_main_set_poll_func()">g_main_set_poll_func</a>                (func)
119 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-invoke" title="g_main_context_invoke ()">g_main_context_invoke</a>               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
120                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
121                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
122 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-invoke-full" title="g_main_context_invoke_full ()">g_main_context_invoke_full</a>          (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
123                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
124                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
125                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
126                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);
127
128 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()">g_main_context_get_thread_default</a>   (<em class="parameter"><code><span class="type">void</span></code></em>);
129 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref-thread-default" title="g_main_context_ref_thread_default ()">g_main_context_ref_thread_default</a>   (<em class="parameter"><code><span class="type">void</span></code></em>);
130 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-push-thread-default" title="g_main_context_push_thread_default ()">g_main_context_push_thread_default</a>  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
131 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pop-thread-default" title="g_main_context_pop_thread_default ()">g_main_context_pop_thread_default</a>   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
132
133 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new" title="g_timeout_source_new ()">g_timeout_source_new</a>                (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>);
134 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new-seconds" title="g_timeout_source_new_seconds ()">g_timeout_source_new_seconds</a>        (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>);
135 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()">g_timeout_add</a>                       (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
136                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
137                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
138 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-full" title="g_timeout_add_full ()">g_timeout_add_full</a>                  (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
139                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
140                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
141                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
142                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);
143 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds" title="g_timeout_add_seconds ()">g_timeout_add_seconds</a>               (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
144                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
145                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
146 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds-full" title="g_timeout_add_seconds_full ()">g_timeout_add_seconds_full</a>          (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
147                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
148                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
149                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
150                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);
151
152 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-source-new" title="g_idle_source_new ()">g_idle_source_new</a>                   (<em class="parameter"><code><span class="type">void</span></code></em>);
153 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()">g_idle_add</a>                          (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
154                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
155 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add-full" title="g_idle_add_full ()">g_idle_add_full</a>                     (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
156                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
157                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
158                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);
159 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-remove-by-data" title="g_idle_remove_by_data ()">g_idle_remove_by_data</a>               (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
160
161 typedef             <a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid">GPid</a>;
162 <span class="returnvalue">void</span>                (<a class="link" href="glib-The-Main-Event-Loop.html#GChildWatchFunc" title="GChildWatchFunc ()">*GChildWatchFunc</a>)                  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>,
163                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> status</code></em>,
164                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
165 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-source-new" title="g_child_watch_source_new ()">g_child_watch_source_new</a>            (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>);
166 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add" title="g_child_watch_add ()">g_child_watch_add</a>                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>,
167                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GChildWatchFunc" title="GChildWatchFunc ()"><span class="type">GChildWatchFunc</span></a> function</code></em>,
168                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
169 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add-full" title="g_child_watch_add_full ()">g_child_watch_add_full</a>              (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
170                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>,
171                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GChildWatchFunc" title="GChildWatchFunc ()"><span class="type">GChildWatchFunc</span></a> function</code></em>,
172                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
173                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);
174
175 struct              <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD">GPollFD</a>;
176 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-The-Main-Event-Loop.html#g-poll" title="g_poll ()">g_poll</a>                              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>,
177                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> nfds</code></em>,
178                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> timeout</code></em>);
179 #define             <a class="link" href="glib-The-Main-Event-Loop.html#G-POLLFD-FORMAT:CAPS" title="G_POLLFD_FORMAT">G_POLLFD_FORMAT</a>
180
181 struct              <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource">GSource</a>;
182 <span class="returnvalue">void</span>                (<a class="link" href="glib-The-Main-Event-Loop.html#GSourceDummyMarshal" title="GSourceDummyMarshal ()">*GSourceDummyMarshal</a>)              (<em class="parameter"><code><span class="type">void</span></code></em>);
183 struct              <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs">GSourceFuncs</a>;
184 struct              <a class="link" href="glib-The-Main-Event-Loop.html#GSourceCallbackFuncs" title="struct GSourceCallbackFuncs">GSourceCallbackFuncs</a>;
185 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()">g_source_new</a>                        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *source_funcs</code></em>,
186                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> struct_size</code></em>);
187 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           <a class="link" href="glib-The-Main-Event-Loop.html#g-source-ref" title="g_source_ref ()">g_source_ref</a>                        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
188 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-unref" title="g_source_unref ()">g_source_unref</a>                      (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
189 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-funcs" title="g_source_set_funcs ()">g_source_set_funcs</a>                  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
190                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>);
191 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()">g_source_attach</a>                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
192                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);
193 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-destroy" title="g_source_destroy ()">g_source_destroy</a>                    (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
194 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-source-is-destroyed" title="g_source_is_destroyed ()">g_source_is_destroyed</a>               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
195 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-priority" title="g_source_set_priority ()">g_source_set_priority</a>               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
196                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>);
197 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-priority" title="g_source_get_priority ()">g_source_get_priority</a>               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
198 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-can-recurse" title="g_source_set_can_recurse ()">g_source_set_can_recurse</a>            (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
199                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> can_recurse</code></em>);
200 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-can-recurse" title="g_source_get_can_recurse ()">g_source_get_can_recurse</a>            (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
201 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-id" title="g_source_get_id ()">g_source_get_id</a>                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
202 const <span class="returnvalue">char</span> *        <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-name" title="g_source_get_name ()">g_source_get_name</a>                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
203 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-name" title="g_source_set_name ()">g_source_set_name</a>                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
204                                                          <em class="parameter"><code>const <span class="type">char</span> *name</code></em>);
205 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-name-by-id" title="g_source_set_name_by_id ()">g_source_set_name_by_id</a>             (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> tag</code></em>,
206                                                          <em class="parameter"><code>const <span class="type">char</span> *name</code></em>);
207 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-context" title="g_source_get_context ()">g_source_get_context</a>                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
208 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-callback" title="g_source_set_callback ()">g_source_set_callback</a>               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
209                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> func</code></em>,
210                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
211                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);
212 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            (<a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()">*GSourceFunc</a>)                      (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
213 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-callback-indirect" title="g_source_set_callback_indirect ()">g_source_set_callback_indirect</a>      (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
214                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> callback_data</code></em>,
215                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceCallbackFuncs" title="struct GSourceCallbackFuncs"><span class="type">GSourceCallbackFuncs</span></a> *callback_funcs</code></em>);
216 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-poll" title="g_source_add_poll ()">g_source_add_poll</a>                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
217                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);
218 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-poll" title="g_source_remove_poll ()">g_source_remove_poll</a>                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
219                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);
220 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-child-source" title="g_source_add_child_source ()">g_source_add_child_source</a>           (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
221                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *child_source</code></em>);
222 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-child-source" title="g_source_remove_child_source ()">g_source_remove_child_source</a>        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
223                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *child_source</code></em>);
224 <a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="returnvalue">gint64</span></a>              <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-time" title="g_source_get_time ()">g_source_get_time</a>                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);
225 <span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-current-time" title="g_source_get_current_time ()">g_source_get_current_time</a>           (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
226                                                          <em class="parameter"><code><a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="struct GTimeVal"><span class="type">GTimeVal</span></a> *timeval</code></em>);
227 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove" title="g_source_remove ()">g_source_remove</a>                     (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> tag</code></em>);
228 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-by-funcs-user-data" title="g_source_remove_by_funcs_user_data ()">g_source_remove_by_funcs_user_data</a>  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>,
229                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
230 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-by-user-data" title="g_source_remove_by_user_data ()">g_source_remove_by_user_data</a>        (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
231 </pre>
232 </div>
233 <div class="refsect1">
234 <a name="glib-The-Main-Event-Loop.description"></a><h2>Description</h2>
235 <p>
236 The main event loop manages all the available sources of events for
237 GLib and GTK+ applications. These events can come from any number of
238 different types of sources such as file descriptors (plain files,
239 pipes or sockets) and timeouts. New types of event sources can also
240 be added using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>.
241 </p>
242 <p>
243 To allow multiple independent sets of sources to be handled in
244 different threads, each source is associated with a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>.
245 A GMainContext can only be running in a single thread, but
246 sources can be added to it and removed from it from other threads.
247 </p>
248 <p>
249 Each event source is assigned a priority. The default priority,
250 <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a>, is 0. Values less than 0 denote higher priorities.
251 Values greater than 0 denote lower priorities. Events from high priority
252 sources are always processed before events from lower priority sources.
253 </p>
254 <p>
255 Idle functions can also be added, and assigned a priority. These will
256 be run whenever no events with a higher priority are ready to be processed.
257 </p>
258 <p>
259 The <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> data type represents a main event loop. A GMainLoop is
260 created with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-new" title="g_main_loop_new ()"><code class="function">g_main_loop_new()</code></a>. After adding the initial event sources,
261 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a> is called. This continuously checks for new events from
262 each of the event sources and dispatches them. Finally, the processing of
263 an event from one of the sources leads to a call to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()"><code class="function">g_main_loop_quit()</code></a> to
264 exit the main loop, and <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a> returns.
265 </p>
266 <p>
267 It is possible to create new instances of <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> recursively.
268 This is often used in GTK+ applications when showing modal dialog
269 boxes. Note that event sources are associated with a particular
270 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, and will be checked and dispatched for all main
271 loops associated with that GMainContext.
272 </p>
273 <p>
274 GTK+ contains wrappers of some of these functions, e.g. <a href="http://developer.gnome.org/devel/gtk/gtk3-General.html#gtk-main"><code class="function">gtk_main()</code></a>,
275 <a href="http://developer.gnome.org/devel/gtk/gtk3-General.html#gtk-main-quit"><code class="function">gtk_main_quit()</code></a> and <a href="http://developer.gnome.org/devel/gtk/gtk3-General.html#gtk-events-pending"><code class="function">gtk_events_pending()</code></a>.
276 </p>
277 <p>
278 </p>
279 <div class="refsect2">
280 <a name="idp17339088"></a><h3>Creating new source types</h3>
281 <p>One of the unusual features of the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> functionality
282 is that new types of event source can be created and used in
283 addition to the builtin type of event source. A new event source
284 type is used for handling GDK events. A new source type is created
285 by <em class="firstterm">deriving</em> from the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> structure.
286 The derived type of source is represented by a structure that has
287 the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> structure as a first element, and other elements specific
288 to the new source type. To create an instance of the new source type,
289 call <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()"><code class="function">g_source_new()</code></a> passing in the size of the derived structure and
290 a table of functions. These <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> determine the behavior of
291 the new source type.</p>
292 <p>New source types basically interact with the main context
293 in two ways. Their prepare function in <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> can set a timeout
294 to determine the maximum amount of time that the main loop will sleep
295 before checking the source again. In addition, or as well, the source
296 can add file descriptors to the set that the main context checks using
297 <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-poll" title="g_source_add_poll ()"><code class="function">g_source_add_poll()</code></a>.</p>
298 </div>
299 <p>
300 </p>
301 <hr>
302 <div class="refsect2">
303 <a name="idp17347344"></a><h3>Customizing the main loop iteration</h3>
304 <p>Single iterations of a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> can be run with
305 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a>. In some cases, more detailed control
306 of exactly how the details of the main loop work is desired, for
307 instance, when integrating the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> with an external main loop.
308 In such cases, you can call the component functions of
309 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a> directly. These functions are
310 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-prepare" title="g_main_context_prepare ()"><code class="function">g_main_context_prepare()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a>,
311 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-check" title="g_main_context_check ()"><code class="function">g_main_context_check()</code></a> and <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-dispatch" title="g_main_context_dispatch ()"><code class="function">g_main_context_dispatch()</code></a>.</p>
312 <p>The operation of these functions can best be seen in terms
313 of a state diagram, as shown in <a class="xref" href="glib-The-Main-Event-Loop.html#mainloop-states" title="Figure 1. States of a Main Context">Figure 1, “States of a Main Context”</a>.</p>
314 <div class="figure">
315 <a name="mainloop-states"></a><p class="title"><b>Figure 1. States of a Main Context</b></p>
316 <div class="figure-contents"><div><img src="mainloop-states.gif" alt="States of a Main Context"></div></div>
317 </div>
318 <br class="figure-break">
319 </div>
320 <p>
321 </p>
322 <p>
323 On Unix, the GLib mainloop is incompatible with <code class="function">fork()</code>.  Any program
324 using the mainloop must either <code class="function">exec()</code> or <code class="function">exit()</code> from the child
325 without returning to the mainloop.
326 </p>
327 </div>
328 <div class="refsect1">
329 <a name="glib-The-Main-Event-Loop.details"></a><h2>Details</h2>
330 <div class="refsect2">
331 <a name="GMainLoop"></a><h3>GMainLoop</h3>
332 <pre class="programlisting">typedef struct _GMainLoop GMainLoop;</pre>
333 <p>
334 The <span class="structname">GMainLoop</span> struct is an opaque data type
335 representing the main event loop of a GLib or GTK+ application.
336 </p>
337 </div>
338 <hr>
339 <div class="refsect2">
340 <a name="g-main-loop-new"></a><h3>g_main_loop_new ()</h3>
341 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="returnvalue">GMainLoop</span></a> *         g_main_loop_new                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
342                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> is_running</code></em>);</pre>
343 <p>
344 Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> structure.
345 </p>
346 <div class="variablelist"><table border="0">
347 <col align="left" valign="top">
348 <tbody>
349 <tr>
350 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
351 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>  (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
352 </td>
353 </tr>
354 <tr>
355 <td><p><span class="term"><em class="parameter"><code>is_running</code></em> :</span></p></td>
356 <td>set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> to indicate that the loop is running. This
357 is not very important since calling <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a> will set this to
358 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> anyway.</td>
359 </tr>
360 <tr>
361 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
362 <td>a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.</td>
363 </tr>
364 </tbody>
365 </table></div>
366 </div>
367 <hr>
368 <div class="refsect2">
369 <a name="g-main-loop-ref"></a><h3>g_main_loop_ref ()</h3>
370 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="returnvalue">GMainLoop</span></a> *         g_main_loop_ref                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre>
371 <p>
372 Increases the reference count on a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> object by one.
373 </p>
374 <div class="variablelist"><table border="0">
375 <col align="left" valign="top">
376 <tbody>
377 <tr>
378 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
379 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
380 </td>
381 </tr>
382 <tr>
383 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
384 <td><em class="parameter"><code>loop</code></em></td>
385 </tr>
386 </tbody>
387 </table></div>
388 </div>
389 <hr>
390 <div class="refsect2">
391 <a name="g-main-loop-unref"></a><h3>g_main_loop_unref ()</h3>
392 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_loop_unref                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre>
393 <p>
394 Decreases the reference count on a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> object by one. If
395 the result is zero, free the loop and free all associated memory.
396 </p>
397 <div class="variablelist"><table border="0">
398 <col align="left" valign="top">
399 <tbody><tr>
400 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
401 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
402 </td>
403 </tr></tbody>
404 </table></div>
405 </div>
406 <hr>
407 <div class="refsect2">
408 <a name="g-main-loop-run"></a><h3>g_main_loop_run ()</h3>
409 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_loop_run                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre>
410 <p>
411 Runs a main loop until <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()"><code class="function">g_main_loop_quit()</code></a> is called on the loop.
412 If this is called for the thread of the loop's <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>,
413 it will process events from the loop, otherwise it will
414 simply wait.
415 </p>
416 <div class="variablelist"><table border="0">
417 <col align="left" valign="top">
418 <tbody><tr>
419 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
420 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
421 </td>
422 </tr></tbody>
423 </table></div>
424 </div>
425 <hr>
426 <div class="refsect2">
427 <a name="g-main-loop-quit"></a><h3>g_main_loop_quit ()</h3>
428 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_loop_quit                    (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre>
429 <p>
430 Stops a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> from running. Any calls to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a>
431 for the loop will return. 
432 </p>
433 <p>
434 Note that sources that have already been dispatched when 
435 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()"><code class="function">g_main_loop_quit()</code></a> is called will still be executed.
436 </p>
437 <div class="variablelist"><table border="0">
438 <col align="left" valign="top">
439 <tbody><tr>
440 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
441 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
442 </td>
443 </tr></tbody>
444 </table></div>
445 </div>
446 <hr>
447 <div class="refsect2">
448 <a name="g-main-loop-is-running"></a><h3>g_main_loop_is_running ()</h3>
449 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_main_loop_is_running              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre>
450 <p>
451 Checks to see if the main loop is currently being run via <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a>.
452 </p>
453 <div class="variablelist"><table border="0">
454 <col align="left" valign="top">
455 <tbody>
456 <tr>
457 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
458 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.</td>
459 </tr>
460 <tr>
461 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
462 <td>
463 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the mainloop is currently being run.</td>
464 </tr>
465 </tbody>
466 </table></div>
467 </div>
468 <hr>
469 <div class="refsect2">
470 <a name="g-main-loop-get-context"></a><h3>g_main_loop_get_context ()</h3>
471 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      g_main_loop_get_context             (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre>
472 <p>
473 Returns the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> of <em class="parameter"><code>loop</code></em>.
474 </p>
475 <div class="variablelist"><table border="0">
476 <col align="left" valign="top">
477 <tbody>
478 <tr>
479 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
480 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.</td>
481 </tr>
482 <tr>
483 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
484 <td>the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> of <em class="parameter"><code>loop</code></em>. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
485 </td>
486 </tr>
487 </tbody>
488 </table></div>
489 </div>
490 <hr>
491 <div class="refsect2">
492 <a name="g-main-new"></a><h3>g_main_new()</h3>
493 <pre class="programlisting">#define             g_main_new(is_running)</pre>
494 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
495 <h3 class="title">Warning</h3>
496 <p><code class="literal">g_main_new</code> has been deprecated since version 2.2 and should not be used in newly-written code. Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-new" title="g_main_loop_new ()"><code class="function">g_main_loop_new()</code></a> instead</p>
497 </div>
498 <p>
499 Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> for th default main context.
500 </p>
501 <div class="variablelist"><table border="0">
502 <col align="left" valign="top">
503 <tbody>
504 <tr>
505 <td><p><span class="term"><em class="parameter"><code>is_running</code></em> :</span></p></td>
506 <td>set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> to indicate that the loop is running. This
507 is not very important since calling <a class="link" href="glib-The-Main-Event-Loop.html#g-main-run" title="g_main_run()"><code class="function">g_main_run()</code></a> will set this
508 to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> anyway.</td>
509 </tr>
510 <tr>
511 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
512 <td>a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
513 </td>
514 </tr>
515 </tbody>
516 </table></div>
517 </div>
518 <hr>
519 <div class="refsect2">
520 <a name="g-main-destroy"></a><h3>g_main_destroy()</h3>
521 <pre class="programlisting">#define             g_main_destroy(loop)</pre>
522 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
523 <h3 class="title">Warning</h3>
524 <p><code class="literal">g_main_destroy</code> has been deprecated since version 2.2 and should not be used in newly-written code. Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-unref" title="g_main_loop_unref ()"><code class="function">g_main_loop_unref()</code></a> instead</p>
525 </div>
526 <p>
527 Frees the memory allocated for the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.
528 </p>
529 <div class="variablelist"><table border="0">
530 <col align="left" valign="top">
531 <tbody><tr>
532 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
533 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
534 </td>
535 </tr></tbody>
536 </table></div>
537 </div>
538 <hr>
539 <div class="refsect2">
540 <a name="g-main-run"></a><h3>g_main_run()</h3>
541 <pre class="programlisting">#define             g_main_run(loop)</pre>
542 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
543 <h3 class="title">Warning</h3>
544 <p><code class="literal">g_main_run</code> has been deprecated since version 2.2 and should not be used in newly-written code. Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a> instead</p>
545 </div>
546 <p>
547 Runs a main loop until it stops running.
548 </p>
549 <div class="variablelist"><table border="0">
550 <col align="left" valign="top">
551 <tbody><tr>
552 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
553 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
554 </td>
555 </tr></tbody>
556 </table></div>
557 </div>
558 <hr>
559 <div class="refsect2">
560 <a name="g-main-quit"></a><h3>g_main_quit()</h3>
561 <pre class="programlisting">#define             g_main_quit(loop)</pre>
562 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
563 <h3 class="title">Warning</h3>
564 <p><code class="literal">g_main_quit</code> has been deprecated since version 2.2 and should not be used in newly-written code. Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()"><code class="function">g_main_loop_quit()</code></a> instead</p>
565 </div>
566 <p>
567 Stops the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.
568 If <a class="link" href="glib-The-Main-Event-Loop.html#g-main-run" title="g_main_run()"><code class="function">g_main_run()</code></a> was called to run the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>, it will now return.
569 </p>
570 <div class="variablelist"><table border="0">
571 <col align="left" valign="top">
572 <tbody><tr>
573 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
574 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
575 </td>
576 </tr></tbody>
577 </table></div>
578 </div>
579 <hr>
580 <div class="refsect2">
581 <a name="g-main-is-running"></a><h3>g_main_is_running()</h3>
582 <pre class="programlisting">#define             g_main_is_running(loop)</pre>
583 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
584 <h3 class="title">Warning</h3>
585 <p><code class="literal">g_main_is_running</code> has been deprecated since version 2.2 and should not be used in newly-written code. Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-is-running" title="g_main_loop_is_running ()"><code class="function">g_main_loop_is_running()</code></a> instead</p>
586 </div>
587 <p>
588 Checks if the main loop is running.
589 </p>
590 <div class="variablelist"><table border="0">
591 <col align="left" valign="top">
592 <tbody>
593 <tr>
594 <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td>
595 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
596 </td>
597 </tr>
598 <tr>
599 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
600 <td>
601 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the main loop is running</td>
602 </tr>
603 </tbody>
604 </table></div>
605 </div>
606 <hr>
607 <div class="refsect2">
608 <a name="G-PRIORITY-HIGH:CAPS"></a><h3>G_PRIORITY_HIGH</h3>
609 <pre class="programlisting">#define G_PRIORITY_HIGH            -100
610 </pre>
611 <p>
612 Use this for high priority event sources.
613 </p>
614 <p>
615 It is not used within GLib or GTK+.
616 </p>
617 </div>
618 <hr>
619 <div class="refsect2">
620 <a name="G-PRIORITY-DEFAULT:CAPS"></a><h3>G_PRIORITY_DEFAULT</h3>
621 <pre class="programlisting">#define G_PRIORITY_DEFAULT          0
622 </pre>
623 <p>
624 Use this for default priority event sources.
625 </p>
626 <p>
627 In GLib this priority is used when adding timeout functions
628 with <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>. In GDK this priority is used for events
629 from the X server.
630 </p>
631 </div>
632 <hr>
633 <div class="refsect2">
634 <a name="G-PRIORITY-HIGH-IDLE:CAPS"></a><h3>G_PRIORITY_HIGH_IDLE</h3>
635 <pre class="programlisting">#define G_PRIORITY_HIGH_IDLE        100
636 </pre>
637 <p>
638 Use this for high priority idle functions.
639 </p>
640 <p>
641 GTK+ uses <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE"><span class="type">G_PRIORITY_HIGH_IDLE</span></a> + 10 for resizing operations,
642 and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE"><span class="type">G_PRIORITY_HIGH_IDLE</span></a> + 20 for redrawing operations. (This is
643 done to ensure that any pending resizes are processed before any
644 pending redraws, so that widgets are not redrawn twice unnecessarily.)
645 </p>
646 </div>
647 <hr>
648 <div class="refsect2">
649 <a name="G-PRIORITY-DEFAULT-IDLE:CAPS"></a><h3>G_PRIORITY_DEFAULT_IDLE</h3>
650 <pre class="programlisting">#define G_PRIORITY_DEFAULT_IDLE     200
651 </pre>
652 <p>
653 Use this for default priority idle functions.
654 </p>
655 <p>
656 In GLib this priority is used when adding idle functions with
657 <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>.
658 </p>
659 </div>
660 <hr>
661 <div class="refsect2">
662 <a name="G-PRIORITY-LOW:CAPS"></a><h3>G_PRIORITY_LOW</h3>
663 <pre class="programlisting">#define G_PRIORITY_LOW              300
664 </pre>
665 <p>
666 Use this for very low priority background tasks.
667 </p>
668 <p>
669 It is not used within GLib or GTK+.
670 </p>
671 </div>
672 <hr>
673 <div class="refsect2">
674 <a name="G-SOURCE-CONTINUE:CAPS"></a><h3>G_SOURCE_CONTINUE</h3>
675 <pre class="programlisting">#define G_SOURCE_CONTINUE       TRUE
676 </pre>
677 <p>
678 Use this macro as the return value of a <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> to leave
679 the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> in the main loop.
680 </p>
681 <p class="since">Since 2.28</p>
682 </div>
683 <hr>
684 <div class="refsect2">
685 <a name="G-SOURCE-REMOVE:CAPS"></a><h3>G_SOURCE_REMOVE</h3>
686 <pre class="programlisting">#define G_SOURCE_REMOVE         FALSE
687 </pre>
688 <p>
689 Use this macro as the return value of a <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> to remove
690 the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> from the main loop.
691 </p>
692 <p class="since">Since 2.28</p>
693 </div>
694 <hr>
695 <div class="refsect2">
696 <a name="GMainContext"></a><h3>GMainContext</h3>
697 <pre class="programlisting">typedef struct _GMainContext GMainContext;</pre>
698 <p>
699 The <span class="structname">GMainContext</span> struct is an opaque data
700 type representing a set of sources to be handled in a main loop.
701 </p>
702 </div>
703 <hr>
704 <div class="refsect2">
705 <a name="g-main-context-new"></a><h3>g_main_context_new ()</h3>
706 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      g_main_context_new                  (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
707 <p>
708 Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> structure.
709 </p>
710 <div class="variablelist"><table border="0">
711 <col align="left" valign="top">
712 <tbody><tr>
713 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
714 <td>the new <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
715 </td>
716 </tr></tbody>
717 </table></div>
718 </div>
719 <hr>
720 <div class="refsect2">
721 <a name="g-main-context-ref"></a><h3>g_main_context_ref ()</h3>
722 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      g_main_context_ref                  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
723 <p>
724 Increases the reference count on a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> object by one.
725 </p>
726 <div class="variablelist"><table border="0">
727 <col align="left" valign="top">
728 <tbody>
729 <tr>
730 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
731 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
732 </td>
733 </tr>
734 <tr>
735 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
736 <td>the <em class="parameter"><code>context</code></em> that was passed in (since 2.6)</td>
737 </tr>
738 </tbody>
739 </table></div>
740 </div>
741 <hr>
742 <div class="refsect2">
743 <a name="g-main-context-unref"></a><h3>g_main_context_unref ()</h3>
744 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_unref                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
745 <p>
746 Decreases the reference count on a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> object by one. If
747 the result is zero, free the context and free all associated memory.
748 </p>
749 <div class="variablelist"><table border="0">
750 <col align="left" valign="top">
751 <tbody><tr>
752 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
753 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
754 </td>
755 </tr></tbody>
756 </table></div>
757 </div>
758 <hr>
759 <div class="refsect2">
760 <a name="g-main-context-default"></a><h3>g_main_context_default ()</h3>
761 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      g_main_context_default              (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
762 <p>
763 Returns the global default main context. This is the main context
764 used for main loop functions when a main loop is not explicitly
765 specified, and corresponds to the "main" main loop. See also
766 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()"><code class="function">g_main_context_get_thread_default()</code></a>.
767 </p>
768 <div class="variablelist"><table border="0">
769 <col align="left" valign="top">
770 <tbody><tr>
771 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
772 <td>the global default main context. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
773 </td>
774 </tr></tbody>
775 </table></div>
776 </div>
777 <hr>
778 <div class="refsect2">
779 <a name="g-main-context-iteration"></a><h3>g_main_context_iteration ()</h3>
780 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_main_context_iteration            (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
781                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> may_block</code></em>);</pre>
782 <p>
783 Runs a single iteration for the given main loop. This involves
784 checking to see if any event sources are ready to be processed,
785 then if no events sources are ready and <em class="parameter"><code>may_block</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, waiting
786 for a source to become ready, then dispatching the highest priority
787 events sources that are ready. Otherwise, if <em class="parameter"><code>may_block</code></em> is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> 
788 sources are not waited to become ready, only those highest priority 
789 events sources will be dispatched (if any), that are ready at this 
790 given moment without further waiting.
791 </p>
792 <p>
793 Note that even when <em class="parameter"><code>may_block</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, it is still possible for 
794 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a> to return <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, since the the wait may 
795 be interrupted for other reasons than an event source becoming ready.
796 </p>
797 <div class="variablelist"><table border="0">
798 <col align="left" valign="top">
799 <tbody>
800 <tr>
801 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
802 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
803 </td>
804 </tr>
805 <tr>
806 <td><p><span class="term"><em class="parameter"><code>may_block</code></em> :</span></p></td>
807 <td>whether the call may block.</td>
808 </tr>
809 <tr>
810 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
811 <td>
812 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if events were dispatched.</td>
813 </tr>
814 </tbody>
815 </table></div>
816 </div>
817 <hr>
818 <div class="refsect2">
819 <a name="g-main-iteration"></a><h3>g_main_iteration()</h3>
820 <pre class="programlisting">#define             g_main_iteration(may_block)</pre>
821 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
822 <h3 class="title">Warning</h3>
823 <p><code class="literal">g_main_iteration</code> has been deprecated since version 2.2 and should not be used in newly-written code. Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a> instead.</p>
824 </div>
825 <p>
826 Runs a single iteration for the default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>.
827 </p>
828 <div class="variablelist"><table border="0">
829 <col align="left" valign="top">
830 <tbody>
831 <tr>
832 <td><p><span class="term"><em class="parameter"><code>may_block</code></em> :</span></p></td>
833 <td>set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if it should block (i.e. wait) until an event
834 source becomes ready. It will return after an event source has been
835 processed. If set to <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> it will return immediately if no event
836 source is ready to be processed.</td>
837 </tr>
838 <tr>
839 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
840 <td>
841 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if more events are pending.</td>
842 </tr>
843 </tbody>
844 </table></div>
845 </div>
846 <hr>
847 <div class="refsect2">
848 <a name="g-main-context-pending"></a><h3>g_main_context_pending ()</h3>
849 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_main_context_pending              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
850 <p>
851 Checks if any sources have pending events for the given context.
852 </p>
853 <div class="variablelist"><table border="0">
854 <col align="left" valign="top">
855 <tbody>
856 <tr>
857 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
858 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
859 </td>
860 </tr>
861 <tr>
862 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
863 <td>
864 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if events are pending.</td>
865 </tr>
866 </tbody>
867 </table></div>
868 </div>
869 <hr>
870 <div class="refsect2">
871 <a name="g-main-pending"></a><h3>g_main_pending</h3>
872 <pre class="programlisting">#define             g_main_pending()</pre>
873 <p>
874 Checks if any events are pending for the default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
875 (i.e. ready to be processed).
876 </p>
877 <div class="variablelist"><table border="0">
878 <col align="left" valign="top">
879 <tbody><tr>
880 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
881 <td>
882 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if any events are pending.
883 Deprected: 2.2: Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pending" title="g_main_context_pending ()"><code class="function">g_main_context_pending()</code></a> instead.</td>
884 </tr></tbody>
885 </table></div>
886 </div>
887 <hr>
888 <div class="refsect2">
889 <a name="g-main-context-find-source-by-id"></a><h3>g_main_context_find_source_by_id ()</h3>
890 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_main_context_find_source_by_id    (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
891                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> source_id</code></em>);</pre>
892 <p>
893 Finds a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> given a pair of context and ID.
894 </p>
895 <div class="variablelist"><table border="0">
896 <col align="left" valign="top">
897 <tbody>
898 <tr>
899 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
900 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
901 </td>
902 </tr>
903 <tr>
904 <td><p><span class="term"><em class="parameter"><code>source_id</code></em> :</span></p></td>
905 <td>the source ID, as returned by <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-id" title="g_source_get_id ()"><code class="function">g_source_get_id()</code></a>.</td>
906 </tr>
907 <tr>
908 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
909 <td>the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> if found, otherwise, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
910 </td>
911 </tr>
912 </tbody>
913 </table></div>
914 </div>
915 <hr>
916 <div class="refsect2">
917 <a name="g-main-context-find-source-by-user-data"></a><h3>g_main_context_find_source_by_user_data ()</h3>
918 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_main_context_find_source_by_user_data
919                                                         (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
920                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
921 <p>
922 Finds a source with the given user data for the callback.  If
923 multiple sources exist with the same user data, the first
924 one found will be returned.
925 </p>
926 <div class="variablelist"><table border="0">
927 <col align="left" valign="top">
928 <tbody>
929 <tr>
930 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
931 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
932 </td>
933 </tr>
934 <tr>
935 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
936 <td>the user_data for the callback.</td>
937 </tr>
938 <tr>
939 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
940 <td>the source, if one was found, otherwise <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
941 </td>
942 </tr>
943 </tbody>
944 </table></div>
945 </div>
946 <hr>
947 <div class="refsect2">
948 <a name="g-main-context-find-source-by-funcs-user-data"></a><h3>g_main_context_find_source_by_funcs_user_data ()</h3>
949 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_main_context_find_source_by_funcs_user_data
950                                                         (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
951                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>,
952                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
953 <p>
954 Finds a source with the given source functions and user data.  If
955 multiple sources exist with the same source function and user data,
956 the first one found will be returned.
957 </p>
958 <div class="variablelist"><table border="0">
959 <col align="left" valign="top">
960 <tbody>
961 <tr>
962 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
963 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
964 </td>
965 </tr>
966 <tr>
967 <td><p><span class="term"><em class="parameter"><code>funcs</code></em> :</span></p></td>
968 <td>the <em class="parameter"><code>source_funcs</code></em> passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()"><code class="function">g_source_new()</code></a>.</td>
969 </tr>
970 <tr>
971 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
972 <td>the user data from the callback.</td>
973 </tr>
974 <tr>
975 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
976 <td>the source, if one was found, otherwise <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
977 </td>
978 </tr>
979 </tbody>
980 </table></div>
981 </div>
982 <hr>
983 <div class="refsect2">
984 <a name="g-main-context-wakeup"></a><h3>g_main_context_wakeup ()</h3>
985 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_wakeup               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
986 <p>
987 If <em class="parameter"><code>context</code></em> is currently waiting in a <code class="function">poll()</code>, interrupt
988 the <code class="function">poll()</code>, and continue the iteration process.
989 </p>
990 <div class="variablelist"><table border="0">
991 <col align="left" valign="top">
992 <tbody><tr>
993 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
994 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
995 </td>
996 </tr></tbody>
997 </table></div>
998 </div>
999 <hr>
1000 <div class="refsect2">
1001 <a name="g-main-context-acquire"></a><h3>g_main_context_acquire ()</h3>
1002 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_main_context_acquire              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
1003 <p>
1004 Tries to become the owner of the specified context.
1005 If some other thread is the owner of the context,
1006 returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> immediately. Ownership is properly
1007 recursive: the owner can require ownership again
1008 and will release ownership when <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-release" title="g_main_context_release ()"><code class="function">g_main_context_release()</code></a>
1009 is called as many times as <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a>.
1010 </p>
1011 <p>
1012 You must be the owner of a context before you
1013 can call <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-prepare" title="g_main_context_prepare ()"><code class="function">g_main_context_prepare()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a>,
1014 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-check" title="g_main_context_check ()"><code class="function">g_main_context_check()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-dispatch" title="g_main_context_dispatch ()"><code class="function">g_main_context_dispatch()</code></a>.
1015 </p>
1016 <div class="variablelist"><table border="0">
1017 <col align="left" valign="top">
1018 <tbody>
1019 <tr>
1020 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1021 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1022 </td>
1023 </tr>
1024 <tr>
1025 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1026 <td>
1027 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the operation succeeded, and
1028 this thread is now the owner of <em class="parameter"><code>context</code></em>.</td>
1029 </tr>
1030 </tbody>
1031 </table></div>
1032 </div>
1033 <hr>
1034 <div class="refsect2">
1035 <a name="g-main-context-release"></a><h3>g_main_context_release ()</h3>
1036 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_release              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
1037 <p>
1038 Releases ownership of a context previously acquired by this thread
1039 with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a>. If the context was acquired multiple
1040 times, the ownership will be released only when <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-release" title="g_main_context_release ()"><code class="function">g_main_context_release()</code></a>
1041 is called as many times as it was acquired.
1042 </p>
1043 <div class="variablelist"><table border="0">
1044 <col align="left" valign="top">
1045 <tbody><tr>
1046 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1047 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1048 </td>
1049 </tr></tbody>
1050 </table></div>
1051 </div>
1052 <hr>
1053 <div class="refsect2">
1054 <a name="g-main-context-is-owner"></a><h3>g_main_context_is_owner ()</h3>
1055 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_main_context_is_owner             (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
1056 <p>
1057 Determines whether this thread holds the (recursive)
1058 ownership of this <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>. This is useful to
1059 know before waiting on another thread that may be
1060 blocking to get ownership of <em class="parameter"><code>context</code></em>.
1061 </p>
1062 <div class="variablelist"><table border="0">
1063 <col align="left" valign="top">
1064 <tbody>
1065 <tr>
1066 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1067 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1068 </td>
1069 </tr>
1070 <tr>
1071 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1072 <td>
1073 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if current thread is owner of <em class="parameter"><code>context</code></em>.</td>
1074 </tr>
1075 </tbody>
1076 </table></div>
1077 <p class="since">Since 2.10</p>
1078 </div>
1079 <hr>
1080 <div class="refsect2">
1081 <a name="g-main-context-wait"></a><h3>g_main_context_wait ()</h3>
1082 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_main_context_wait                 (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
1083                                                          <em class="parameter"><code><a class="link" href="glib-Threads.html#GCond" title="struct GCond"><span class="type">GCond</span></a> *cond</code></em>,
1084                                                          <em class="parameter"><code><a class="link" href="glib-Threads.html#GMutex" title="union GMutex"><span class="type">GMutex</span></a> *mutex</code></em>);</pre>
1085 <p>
1086 Tries to become the owner of the specified context,
1087 as with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a>. But if another thread
1088 is the owner, atomically drop <em class="parameter"><code>mutex</code></em> and wait on <em class="parameter"><code>cond</code></em> until 
1089 that owner releases ownership or until <em class="parameter"><code>cond</code></em> is signaled, then
1090 try again (once) to become the owner.
1091 </p>
1092 <div class="variablelist"><table border="0">
1093 <col align="left" valign="top">
1094 <tbody>
1095 <tr>
1096 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1097 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1098 </td>
1099 </tr>
1100 <tr>
1101 <td><p><span class="term"><em class="parameter"><code>cond</code></em> :</span></p></td>
1102 <td>a condition variable</td>
1103 </tr>
1104 <tr>
1105 <td><p><span class="term"><em class="parameter"><code>mutex</code></em> :</span></p></td>
1106 <td>a mutex, currently held</td>
1107 </tr>
1108 <tr>
1109 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1110 <td>
1111 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the operation succeeded, and
1112 this thread is now the owner of <em class="parameter"><code>context</code></em>.</td>
1113 </tr>
1114 </tbody>
1115 </table></div>
1116 </div>
1117 <hr>
1118 <div class="refsect2">
1119 <a name="g-main-context-prepare"></a><h3>g_main_context_prepare ()</h3>
1120 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_main_context_prepare              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
1121                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *priority</code></em>);</pre>
1122 <p>
1123 Prepares to poll sources within a main loop. The resulting information
1124 for polling is determined by calling <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a>.
1125 </p>
1126 <div class="variablelist"><table border="0">
1127 <col align="left" valign="top">
1128 <tbody>
1129 <tr>
1130 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1131 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1132 </td>
1133 </tr>
1134 <tr>
1135 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
1136 <td>location to store priority of highest priority
1137 source already ready.</td>
1138 </tr>
1139 <tr>
1140 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1141 <td>
1142 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if some source is ready to be dispatched
1143 prior to polling.</td>
1144 </tr>
1145 </tbody>
1146 </table></div>
1147 </div>
1148 <hr>
1149 <div class="refsect2">
1150 <a name="g-main-context-query"></a><h3>g_main_context_query ()</h3>
1151 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_main_context_query                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
1152                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> max_priority</code></em>,
1153                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *timeout_</code></em>,
1154                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>,
1155                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> n_fds</code></em>);</pre>
1156 <p>
1157 Determines information necessary to poll this main loop.
1158 </p>
1159 <div class="variablelist"><table border="0">
1160 <col align="left" valign="top">
1161 <tbody>
1162 <tr>
1163 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1164 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1165 </td>
1166 </tr>
1167 <tr>
1168 <td><p><span class="term"><em class="parameter"><code>max_priority</code></em> :</span></p></td>
1169 <td>maximum priority source to check</td>
1170 </tr>
1171 <tr>
1172 <td><p><span class="term"><em class="parameter"><code>timeout_</code></em> :</span></p></td>
1173 <td>location to store timeout to be used in polling. <span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span>
1174 </td>
1175 </tr>
1176 <tr>
1177 <td><p><span class="term"><em class="parameter"><code>fds</code></em> :</span></p></td>
1178 <td>location to
1179 store <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> records that need to be polled. <span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym> caller-allocates][<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=n_fds]</span>
1180 </td>
1181 </tr>
1182 <tr>
1183 <td><p><span class="term"><em class="parameter"><code>n_fds</code></em> :</span></p></td>
1184 <td>length of <em class="parameter"><code>fds</code></em>.</td>
1185 </tr>
1186 <tr>
1187 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1188 <td>the number of records actually stored in <em class="parameter"><code>fds</code></em>,
1189 or, if more than <em class="parameter"><code>n_fds</code></em> records need to be stored, the number
1190 of records that need to be stored.</td>
1191 </tr>
1192 </tbody>
1193 </table></div>
1194 </div>
1195 <hr>
1196 <div class="refsect2">
1197 <a name="g-main-context-check"></a><h3>g_main_context_check ()</h3>
1198 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_main_context_check                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
1199                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> max_priority</code></em>,
1200                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>,
1201                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> n_fds</code></em>);</pre>
1202 <p>
1203 Passes the results of polling back to the main loop.
1204 </p>
1205 <div class="variablelist"><table border="0">
1206 <col align="left" valign="top">
1207 <tbody>
1208 <tr>
1209 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1210 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1211 </td>
1212 </tr>
1213 <tr>
1214 <td><p><span class="term"><em class="parameter"><code>max_priority</code></em> :</span></p></td>
1215 <td>the maximum numerical priority of sources to check</td>
1216 </tr>
1217 <tr>
1218 <td><p><span class="term"><em class="parameter"><code>fds</code></em> :</span></p></td>
1219 <td>array of <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a>'s that was passed to
1220 the last call to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a>. <span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=n_fds]</span>
1221 </td>
1222 </tr>
1223 <tr>
1224 <td><p><span class="term"><em class="parameter"><code>n_fds</code></em> :</span></p></td>
1225 <td>return value of <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a>
1226 </td>
1227 </tr>
1228 <tr>
1229 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1230 <td>
1231 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if some sources are ready to be dispatched.</td>
1232 </tr>
1233 </tbody>
1234 </table></div>
1235 </div>
1236 <hr>
1237 <div class="refsect2">
1238 <a name="g-main-context-dispatch"></a><h3>g_main_context_dispatch ()</h3>
1239 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_dispatch             (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
1240 <p>
1241 Dispatches all pending sources.
1242 </p>
1243 <div class="variablelist"><table border="0">
1244 <col align="left" valign="top">
1245 <tbody><tr>
1246 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1247 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1248 </td>
1249 </tr></tbody>
1250 </table></div>
1251 </div>
1252 <hr>
1253 <div class="refsect2">
1254 <a name="g-main-context-set-poll-func"></a><h3>g_main_context_set_poll_func ()</h3>
1255 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_set_poll_func        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
1256                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFunc" title="GPollFunc ()"><span class="type">GPollFunc</span></a> func</code></em>);</pre>
1257 <p>
1258 Sets the function to use to handle polling of file descriptors. It
1259 will be used instead of the <code class="function">poll()</code> system call 
1260 (or GLib's replacement function, which is used where 
1261 <code class="function">poll()</code> isn't available).
1262 </p>
1263 <p>
1264 This function could possibly be used to integrate the GLib event
1265 loop with an external event loop.
1266 </p>
1267 <div class="variablelist"><table border="0">
1268 <col align="left" valign="top">
1269 <tbody>
1270 <tr>
1271 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1272 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1273 </td>
1274 </tr>
1275 <tr>
1276 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
1277 <td>the function to call to poll all file descriptors</td>
1278 </tr>
1279 </tbody>
1280 </table></div>
1281 </div>
1282 <hr>
1283 <div class="refsect2">
1284 <a name="g-main-context-get-poll-func"></a><h3>g_main_context_get_poll_func ()</h3>
1285 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GPollFunc" title="GPollFunc ()"><span class="returnvalue">GPollFunc</span></a>           g_main_context_get_poll_func        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
1286 <p>
1287 Gets the poll function set by <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-set-poll-func" title="g_main_context_set_poll_func ()"><code class="function">g_main_context_set_poll_func()</code></a>.
1288 </p>
1289 <div class="variablelist"><table border="0">
1290 <col align="left" valign="top">
1291 <tbody>
1292 <tr>
1293 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1294 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1295 </td>
1296 </tr>
1297 <tr>
1298 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1299 <td>the poll function</td>
1300 </tr>
1301 </tbody>
1302 </table></div>
1303 </div>
1304 <hr>
1305 <div class="refsect2">
1306 <a name="GPollFunc"></a><h3>GPollFunc ()</h3>
1307 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                (*GPollFunc)                        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *ufds</code></em>,
1308                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> nfsd</code></em>,
1309                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> timeout_</code></em>);</pre>
1310 <p>
1311 Specifies the type of function passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-set-poll-func" title="g_main_context_set_poll_func ()"><code class="function">g_main_context_set_poll_func()</code></a>.
1312 The semantics of the function should match those of the <code class="function">poll()</code> system call.
1313 </p>
1314 <div class="variablelist"><table border="0">
1315 <col align="left" valign="top">
1316 <tbody>
1317 <tr>
1318 <td><p><span class="term"><em class="parameter"><code>ufds</code></em> :</span></p></td>
1319 <td>an array of <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> elements</td>
1320 </tr>
1321 <tr>
1322 <td><p><span class="term"><em class="parameter"><code>nfsd</code></em> :</span></p></td>
1323 <td>the number of elements in <em class="parameter"><code>ufds</code></em>
1324 </td>
1325 </tr>
1326 <tr>
1327 <td><p><span class="term"><em class="parameter"><code>timeout_</code></em> :</span></p></td>
1328 <td>the maximum time to wait for an event of the file descriptors.
1329 A negative value indicates an infinite timeout.</td>
1330 </tr>
1331 <tr>
1332 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1333 <td>the number of <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> elements which have events or errors
1334 reported, or -1 if an error occurred.</td>
1335 </tr>
1336 </tbody>
1337 </table></div>
1338 </div>
1339 <hr>
1340 <div class="refsect2">
1341 <a name="g-main-context-add-poll"></a><h3>g_main_context_add_poll ()</h3>
1342 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_add_poll             (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
1343                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>,
1344                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>);</pre>
1345 <p>
1346 Adds a file descriptor to the set of file descriptors polled for
1347 this context. This will very seldom be used directly. Instead
1348 a typical event source will use <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-poll" title="g_source_add_poll ()"><code class="function">g_source_add_poll()</code></a> instead.
1349 </p>
1350 <div class="variablelist"><table border="0">
1351 <col align="left" valign="top">
1352 <tbody>
1353 <tr>
1354 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1355 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for the default context). <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
1356 </td>
1357 </tr>
1358 <tr>
1359 <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td>
1360 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> structure holding information about a file
1361 descriptor to watch.</td>
1362 </tr>
1363 <tr>
1364 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
1365 <td>the priority for this file descriptor which should be
1366 the same as the priority used for <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> to ensure that the
1367 file descriptor is polled whenever the results may be needed.</td>
1368 </tr>
1369 </tbody>
1370 </table></div>
1371 </div>
1372 <hr>
1373 <div class="refsect2">
1374 <a name="g-main-context-remove-poll"></a><h3>g_main_context_remove_poll ()</h3>
1375 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_remove_poll          (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
1376                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);</pre>
1377 <p>
1378 Removes file descriptor from the set of file descriptors to be
1379 polled for a particular context.
1380 </p>
1381 <div class="variablelist"><table border="0">
1382 <col align="left" valign="top">
1383 <tbody>
1384 <tr>
1385 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1386 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1387 </td>
1388 </tr>
1389 <tr>
1390 <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td>
1391 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> descriptor previously added with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-add-poll" title="g_main_context_add_poll ()"><code class="function">g_main_context_add_poll()</code></a>
1392 </td>
1393 </tr>
1394 </tbody>
1395 </table></div>
1396 </div>
1397 <hr>
1398 <div class="refsect2">
1399 <a name="g-main-depth"></a><h3>g_main_depth ()</h3>
1400 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_main_depth                        (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
1401 <p>
1402 Returns the depth of the stack of calls to
1403 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-dispatch" title="g_main_context_dispatch ()"><code class="function">g_main_context_dispatch()</code></a> on any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> in the current thread.
1404  That is, when called from the toplevel, it gives 0. When
1405 called from within a callback from <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a>
1406 (or <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a>, etc.) it returns 1. When called from within 
1407 a callback to a recursive call to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a>,
1408 it returns 2. And so forth.
1409 </p>
1410 <p>
1411 This function is useful in a situation like the following:
1412 Imagine an extremely simple "garbage collected" system.
1413 </p>
1414 <p>
1415 </p>
1416 <div class="informalexample"><pre class="programlisting">
1417 static GList *free_list;
1418
1419 gpointer
1420 allocate_memory (gsize size)
1421
1422   gpointer result = g_malloc (size);
1423   free_list = g_list_prepend (free_list, result);
1424   return result;
1425 }
1426
1427 void
1428 free_allocated_memory (void)
1429 {
1430   GList *l;
1431   for (l = free_list; l; l = l-&gt;next);
1432     g_free (l-&gt;data);
1433   g_list_free (free_list);
1434   free_list = NULL;
1435  }
1436
1437 [...]
1438
1439 while (TRUE); 
1440  {
1441    g_main_context_iteration (NULL, TRUE);
1442    free_allocated_memory();
1443   }
1444 </pre></div>
1445 <p>
1446 </p>
1447 <p>
1448 This works from an application, however, if you want to do the same
1449 thing from a library, it gets more difficult, since you no longer
1450 control the main loop. You might think you can simply use an idle
1451 function to make the call to <code class="function">free_allocated_memory()</code>, but that
1452 doesn't work, since the idle function could be called from a
1453 recursive callback. This can be fixed by using <a class="link" href="glib-The-Main-Event-Loop.html#g-main-depth" title="g_main_depth ()"><code class="function">g_main_depth()</code></a>
1454 </p>
1455 <p>
1456 </p>
1457 <div class="informalexample"><pre class="programlisting">
1458 gpointer
1459 allocate_memory (gsize size)
1460
1461   FreeListBlock *block = g_new (FreeListBlock, 1);
1462   block-&gt;mem = g_malloc (size);
1463   block-&gt;depth = g_main_depth ();   
1464   free_list = g_list_prepend (free_list, block);
1465   return block-&gt;mem;
1466 }
1467
1468 void
1469 free_allocated_memory (void)
1470 {
1471   GList *l;
1472   
1473   int depth = g_main_depth ();
1474   for (l = free_list; l; );
1475     {
1476       GList *next = l-&gt;next;
1477       FreeListBlock *block = l-&gt;data;
1478       if (block-&gt;depth &gt; depth)
1479         {
1480           g_free (block-&gt;mem);
1481           g_free (block);
1482           free_list = g_list_delete_link (free_list, l);
1483         }
1484               
1485       l = next;
1486     }
1487   }
1488 </pre></div>
1489 <p>
1490 </p>
1491 <p>
1492 There is a temptation to use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-depth" title="g_main_depth ()"><code class="function">g_main_depth()</code></a> to solve
1493 problems with reentrancy. For instance, while waiting for data
1494 to be received from the network in response to a menu item,
1495 the menu item might be selected again. It might seem that
1496 one could make the menu item's callback return immediately
1497 and do nothing if <a class="link" href="glib-The-Main-Event-Loop.html#g-main-depth" title="g_main_depth ()"><code class="function">g_main_depth()</code></a> returns a value greater than 1.
1498 However, this should be avoided since the user then sees selecting
1499 the menu item do nothing. Furthermore, you'll find yourself adding
1500 these checks all over your code, since there are doubtless many,
1501 many things that the user could do. Instead, you can use the
1502 following techniques:
1503 </p>
1504 <p>
1505 </p>
1506 <div class="orderedlist"><ol class="orderedlist" type="1">
1507 <li class="listitem"><p>
1508     Use <a href="http://developer.gnome.org/devel/gtk/GtkWidget.html#gtk-widget-set-sensitive"><code class="function">gtk_widget_set_sensitive()</code></a> or modal dialogs to prevent
1509     the user from interacting with elements while the main
1510     loop is recursing.
1511   </p></li>
1512 <li class="listitem"><p>
1513     Avoid main loop recursion in situations where you can't handle
1514     arbitrary  callbacks. Instead, structure your code so that you
1515     simply return to the main loop and then get called again when
1516     there is more work to do.
1517   </p></li>
1518 </ol></div>
1519 <p>
1520 </p>
1521 <div class="variablelist"><table border="0">
1522 <col align="left" valign="top">
1523 <tbody><tr>
1524 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1525 <td>The main loop recursion level in the current thread</td>
1526 </tr></tbody>
1527 </table></div>
1528 </div>
1529 <hr>
1530 <div class="refsect2">
1531 <a name="g-main-current-source"></a><h3>g_main_current_source ()</h3>
1532 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_main_current_source               (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
1533 <p>
1534 Returns the currently firing source for this thread.
1535 </p>
1536 <div class="variablelist"><table border="0">
1537 <col align="left" valign="top">
1538 <tbody><tr>
1539 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1540 <td>The currently firing source or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
1541 </td>
1542 </tr></tbody>
1543 </table></div>
1544 <p class="since">Since 2.12</p>
1545 </div>
1546 <hr>
1547 <div class="refsect2">
1548 <a name="g-main-set-poll-func"></a><h3>g_main_set_poll_func()</h3>
1549 <pre class="programlisting">#define             g_main_set_poll_func(func)</pre>
1550 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
1551 <h3 class="title">Warning</h3>
1552 <p><code class="literal">g_main_set_poll_func</code> has been deprecated since version 2.2 and should not be used in newly-written code. Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-set-poll-func" title="g_main_context_set_poll_func ()"><code class="function">g_main_context_set_poll_func()</code></a> again</p>
1553 </div>
1554 <p>
1555 Sets the function to use for the handle polling of file descriptors
1556 for the default main context.
1557 </p>
1558 <div class="variablelist"><table border="0">
1559 <col align="left" valign="top">
1560 <tbody><tr>
1561 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
1562 <td>the function to call to poll all file descriptors</td>
1563 </tr></tbody>
1564 </table></div>
1565 </div>
1566 <hr>
1567 <div class="refsect2">
1568 <a name="g-main-context-invoke"></a><h3>g_main_context_invoke ()</h3>
1569 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_invoke               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
1570                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
1571                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
1572 <p>
1573 Invokes a function in such a way that <em class="parameter"><code>context</code></em> is owned during the
1574 invocation of <em class="parameter"><code>function</code></em>.
1575 </p>
1576 <p>
1577 If <em class="parameter"><code>context</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> then the global default main context — as
1578 returned by <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-default" title="g_main_context_default ()"><code class="function">g_main_context_default()</code></a> — is used.
1579 </p>
1580 <p>
1581 If <em class="parameter"><code>context</code></em> is owned by the current thread, <em class="parameter"><code>function</code></em> is called
1582 directly.  Otherwise, if <em class="parameter"><code>context</code></em> is the thread-default main context
1583 of the current thread and <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a> succeeds, then
1584 <em class="parameter"><code>function</code></em> is called and <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-release" title="g_main_context_release ()"><code class="function">g_main_context_release()</code></a> is called
1585 afterwards.
1586 </p>
1587 <p>
1588 In any other case, an idle source is created to call <em class="parameter"><code>function</code></em> and
1589 that source is attached to <em class="parameter"><code>context</code></em> (presumably to be run in another
1590 thread).  The idle source is attached with <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a>
1591 priority.  If you want a different priority, use
1592 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-invoke-full" title="g_main_context_invoke_full ()"><code class="function">g_main_context_invoke_full()</code></a>.
1593 </p>
1594 <p>
1595 Note that, as with normal idle functions, <em class="parameter"><code>function</code></em> should probably
1596 return <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>.  If it returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, it will be continuously run in a
1597 loop (and may prevent this call from returning).
1598 </p>
1599 <div class="variablelist"><table border="0">
1600 <col align="left" valign="top">
1601 <tbody>
1602 <tr>
1603 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1604 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
1605 </td>
1606 </tr>
1607 <tr>
1608 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
1609 <td>function to call</td>
1610 </tr>
1611 <tr>
1612 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1613 <td>data to pass to <em class="parameter"><code>function</code></em>
1614 </td>
1615 </tr>
1616 </tbody>
1617 </table></div>
1618 <p class="since">Since 2.28</p>
1619 </div>
1620 <hr>
1621 <div class="refsect2">
1622 <a name="g-main-context-invoke-full"></a><h3>g_main_context_invoke_full ()</h3>
1623 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_invoke_full          (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>,
1624                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
1625                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
1626                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
1627                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
1628 <p>
1629 Invokes a function in such a way that <em class="parameter"><code>context</code></em> is owned during the
1630 invocation of <em class="parameter"><code>function</code></em>.
1631 </p>
1632 <p>
1633 This function is the same as <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-invoke" title="g_main_context_invoke ()"><code class="function">g_main_context_invoke()</code></a> except that it
1634 lets you specify the priority incase <em class="parameter"><code>function</code></em> ends up being
1635 scheduled as an idle and also lets you give a <a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> for <em class="parameter"><code>data</code></em>.
1636 </p>
1637 <p>
1638 <em class="parameter"><code>notify</code></em> should not assume that it is called from any particular
1639 thread or with any particular context acquired.
1640 </p>
1641 <div class="variablelist"><table border="0">
1642 <col align="left" valign="top">
1643 <tbody>
1644 <tr>
1645 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1646 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
1647 </td>
1648 </tr>
1649 <tr>
1650 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
1651 <td>the priority at which to run <em class="parameter"><code>function</code></em>
1652 </td>
1653 </tr>
1654 <tr>
1655 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
1656 <td>function to call</td>
1657 </tr>
1658 <tr>
1659 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1660 <td>data to pass to <em class="parameter"><code>function</code></em>
1661 </td>
1662 </tr>
1663 <tr>
1664 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
1665 <td>a function to call when <em class="parameter"><code>data</code></em> is no longer in use, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
1666 </td>
1667 </tr>
1668 </tbody>
1669 </table></div>
1670 <p class="since">Since 2.28</p>
1671 </div>
1672 <hr>
1673 <div class="refsect2">
1674 <a name="g-main-context-get-thread-default"></a><h3>g_main_context_get_thread_default ()</h3>
1675 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      g_main_context_get_thread_default   (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
1676 <p>
1677 Gets the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> for this thread. Asynchronous
1678 operations that want to be able to be run in contexts other than
1679 the default one should call this method or
1680 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref-thread-default" title="g_main_context_ref_thread_default ()"><code class="function">g_main_context_ref_thread_default()</code></a> to get a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> to add
1681 their <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>s to. (Note that even in single-threaded
1682 programs applications may sometimes want to temporarily push a
1683 non-default context, so it is not safe to assume that this will
1684 always return <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if you are running in the default thread.)
1685 </p>
1686 <p>
1687 If you need to hold a reference on the context, use
1688 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref-thread-default" title="g_main_context_ref_thread_default ()"><code class="function">g_main_context_ref_thread_default()</code></a> instead.
1689 </p>
1690 <div class="variablelist"><table border="0">
1691 <col align="left" valign="top">
1692 <tbody><tr>
1693 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1694 <td>the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, or
1695 <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the thread-default context is the global default context. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
1696 </td>
1697 </tr></tbody>
1698 </table></div>
1699 <p class="since">Since 2.22</p>
1700 </div>
1701 <hr>
1702 <div class="refsect2">
1703 <a name="g-main-context-ref-thread-default"></a><h3>g_main_context_ref_thread_default ()</h3>
1704 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      g_main_context_ref_thread_default   (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
1705 <p>
1706 Gets the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> for this thread, as with
1707 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()"><code class="function">g_main_context_get_thread_default()</code></a>, but also adds a reference to
1708 it with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref" title="g_main_context_ref ()"><code class="function">g_main_context_ref()</code></a>. In addition, unlike
1709 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()"><code class="function">g_main_context_get_thread_default()</code></a>, if the thread-default context
1710 is the global default context, this will return that <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1711 (with a ref added to it) rather than returning <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
1712 </p>
1713 <div class="variablelist"><table border="0">
1714 <col align="left" valign="top">
1715 <tbody><tr>
1716 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1717 <td>the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>. Unref
1718 with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-unref" title="g_main_context_unref ()"><code class="function">g_main_context_unref()</code></a> when you are done with it. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
1719 </td>
1720 </tr></tbody>
1721 </table></div>
1722 <p class="since">Since 2.32</p>
1723 </div>
1724 <hr>
1725 <div class="refsect2">
1726 <a name="g-main-context-push-thread-default"></a><h3>g_main_context_push_thread_default ()</h3>
1727 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_push_thread_default  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
1728 <p>
1729 Acquires <em class="parameter"><code>context</code></em> and sets it as the thread-default context for the
1730 current thread. This will cause certain asynchronous operations
1731 (such as most gio-based I/O) which are
1732 started in this thread to run under <em class="parameter"><code>context</code></em> and deliver their
1733 results to its main loop, rather than running under the global
1734 default context in the main thread. Note that calling this function
1735 changes the context returned by
1736 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()"><code class="function">g_main_context_get_thread_default()</code></a>, <span class="emphasis"><em>not</em></span> the
1737 one returned by <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-default" title="g_main_context_default ()"><code class="function">g_main_context_default()</code></a>, so it does not affect the
1738 context used by functions like <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>.
1739 </p>
1740 <p>
1741 Normally you would call this function shortly after creating a new
1742 thread, passing it a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> which will be run by a
1743 <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> in that thread, to set a new default context for all
1744 async operations in that thread. (In this case, you don't need to
1745 ever call <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pop-thread-default" title="g_main_context_pop_thread_default ()"><code class="function">g_main_context_pop_thread_default()</code></a>.) In some cases
1746 however, you may want to schedule a single operation in a
1747 non-default context, or temporarily use a non-default context in
1748 the main thread. In that case, you can wrap the call to the
1749 asynchronous operation inside a
1750 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-push-thread-default" title="g_main_context_push_thread_default ()"><code class="function">g_main_context_push_thread_default()</code></a> /
1751 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pop-thread-default" title="g_main_context_pop_thread_default ()"><code class="function">g_main_context_pop_thread_default()</code></a> pair, but it is up to you to
1752 ensure that no other asynchronous operations accidentally get
1753 started while the non-default context is active.
1754 </p>
1755 <p>
1756 Beware that libraries that predate this function may not correctly
1757 handle being used from a thread with a thread-default context. Eg,
1758 see <a href="http://library.gnome.org/devel/gio/unstable/GFile.html#g-file-supports-thread-contexts"><code class="function">g_file_supports_thread_contexts()</code></a>.
1759 </p>
1760 <div class="variablelist"><table border="0">
1761 <col align="left" valign="top">
1762 <tbody><tr>
1763 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1764 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for the global default context. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
1765 </td>
1766 </tr></tbody>
1767 </table></div>
1768 <p class="since">Since 2.22</p>
1769 </div>
1770 <hr>
1771 <div class="refsect2">
1772 <a name="g-main-context-pop-thread-default"></a><h3>g_main_context_pop_thread_default ()</h3>
1773 <pre class="programlisting"><span class="returnvalue">void</span>                g_main_context_pop_thread_default   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
1774 <p>
1775 Pops <em class="parameter"><code>context</code></em> off the thread-default context stack (verifying that
1776 it was on the top of the stack).
1777 </p>
1778 <div class="variablelist"><table border="0">
1779 <col align="left" valign="top">
1780 <tbody><tr>
1781 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1782 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> object, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
1783 </td>
1784 </tr></tbody>
1785 </table></div>
1786 <p class="since">Since 2.22</p>
1787 </div>
1788 <hr>
1789 <div class="refsect2">
1790 <a name="g-timeout-source-new"></a><h3>g_timeout_source_new ()</h3>
1791 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_timeout_source_new                (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>);</pre>
1792 <p>
1793 Creates a new timeout source.
1794 </p>
1795 <p>
1796 The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1797 and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be
1798 executed.
1799 </p>
1800 <p>
1801 The interval given is in terms of monotonic time, not wall clock
1802 time.  See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.
1803 </p>
1804 <div class="variablelist"><table border="0">
1805 <col align="left" valign="top">
1806 <tbody>
1807 <tr>
1808 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
1809 <td>the timeout interval in milliseconds.</td>
1810 </tr>
1811 <tr>
1812 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1813 <td>the newly-created timeout source</td>
1814 </tr>
1815 </tbody>
1816 </table></div>
1817 </div>
1818 <hr>
1819 <div class="refsect2">
1820 <a name="g-timeout-source-new-seconds"></a><h3>g_timeout_source_new_seconds ()</h3>
1821 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_timeout_source_new_seconds        (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>);</pre>
1822 <p>
1823 Creates a new timeout source.
1824 </p>
1825 <p>
1826 The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
1827 and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be
1828 executed.
1829 </p>
1830 <p>
1831 The scheduling granularity/accuracy of this timeout source will be
1832 in seconds.
1833 </p>
1834 <p>
1835 The interval given in terms of monotonic time, not wall clock time.
1836 See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.
1837 </p>
1838 <div class="variablelist"><table border="0">
1839 <col align="left" valign="top">
1840 <tbody>
1841 <tr>
1842 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
1843 <td>the timeout interval in seconds</td>
1844 </tr>
1845 <tr>
1846 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1847 <td>the newly-created timeout source</td>
1848 </tr>
1849 </tbody>
1850 </table></div>
1851 <p class="since">Since 2.14</p>
1852 </div>
1853 <hr>
1854 <div class="refsect2">
1855 <a name="g-timeout-add"></a><h3>g_timeout_add ()</h3>
1856 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_timeout_add                       (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
1857                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
1858                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
1859 <p>
1860 Sets a function to be called at regular intervals, with the default
1861 priority, <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a>.  The function is called repeatedly
1862 until it returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, at which point the timeout is automatically
1863 destroyed and the function will not be called again.  The first call
1864 to the function will be at the end of the first <em class="parameter"><code>interval</code></em>.
1865 </p>
1866 <p>
1867 Note that timeout functions may be delayed, due to the processing of other
1868 event sources. Thus they should not be relied on for precise timing.
1869 After each call to the timeout function, the time of the next
1870 timeout is recalculated based on the current time and the given interval
1871 (it does not try to 'catch up' time lost in delays).
1872 </p>
1873 <p>
1874 If you want to have a timer in the "seconds" range and do not care
1875 about the exact time of the first call of the timer, use the
1876 <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds" title="g_timeout_add_seconds ()"><code class="function">g_timeout_add_seconds()</code></a> function; this function allows for more
1877 optimizations and more efficient system power usage.
1878 </p>
1879 <p>
1880 This internally creates a main loop source using <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new" title="g_timeout_source_new ()"><code class="function">g_timeout_source_new()</code></a>
1881 and attaches it to the main loop context using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can
1882 do these steps manually if you need greater control.
1883 </p>
1884 <p>
1885 The interval given is in terms of monotonic time, not wall clock
1886 time.  See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.
1887 </p>
1888 <div class="variablelist"><table border="0">
1889 <col align="left" valign="top">
1890 <tbody>
1891 <tr>
1892 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
1893 <td>the time between calls to the function, in milliseconds
1894 (1/1000ths of a second)</td>
1895 </tr>
1896 <tr>
1897 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
1898 <td>function to call</td>
1899 </tr>
1900 <tr>
1901 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1902 <td>data to pass to <em class="parameter"><code>function</code></em>
1903 </td>
1904 </tr>
1905 <tr>
1906 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1907 <td>the ID (greater than 0) of the event source.</td>
1908 </tr>
1909 </tbody>
1910 </table></div>
1911 </div>
1912 <hr>
1913 <div class="refsect2">
1914 <a name="g-timeout-add-full"></a><h3>g_timeout_add_full ()</h3>
1915 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_timeout_add_full                  (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
1916                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
1917                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
1918                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
1919                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
1920 <p>
1921 Sets a function to be called at regular intervals, with the given
1922 priority.  The function is called repeatedly until it returns
1923 <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, at which point the timeout is automatically destroyed and
1924 the function will not be called again.  The <em class="parameter"><code>notify</code></em> function is
1925 called when the timeout is destroyed.  The first call to the
1926 function will be at the end of the first <em class="parameter"><code>interval</code></em>.
1927 </p>
1928 <p>
1929 Note that timeout functions may be delayed, due to the processing of other
1930 event sources. Thus they should not be relied on for precise timing.
1931 After each call to the timeout function, the time of the next
1932 timeout is recalculated based on the current time and the given interval
1933 (it does not try to 'catch up' time lost in delays).
1934 </p>
1935 <p>
1936 This internally creates a main loop source using <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new" title="g_timeout_source_new ()"><code class="function">g_timeout_source_new()</code></a>
1937 and attaches it to the main loop context using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can
1938 do these steps manually if you need greater control.
1939 </p>
1940 <p>
1941 The interval given in terms of monotonic time, not wall clock time.
1942 See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.
1943 </p>
1944 <div class="variablelist"><table border="0">
1945 <col align="left" valign="top">
1946 <tbody>
1947 <tr>
1948 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
1949 <td>the priority of the timeout source. Typically this will be in
1950 the range between <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a> and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH:CAPS" title="G_PRIORITY_HIGH"><span class="type">G_PRIORITY_HIGH</span></a>.</td>
1951 </tr>
1952 <tr>
1953 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
1954 <td>the time between calls to the function, in milliseconds
1955 (1/1000ths of a second)</td>
1956 </tr>
1957 <tr>
1958 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
1959 <td>function to call</td>
1960 </tr>
1961 <tr>
1962 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1963 <td>data to pass to <em class="parameter"><code>function</code></em>
1964 </td>
1965 </tr>
1966 <tr>
1967 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
1968 <td>function to call when the timeout is removed, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
1969 </td>
1970 </tr>
1971 <tr>
1972 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1973 <td>the ID (greater than 0) of the event source.
1974 Rename to: g_timeout_add</td>
1975 </tr>
1976 </tbody>
1977 </table></div>
1978 </div>
1979 <hr>
1980 <div class="refsect2">
1981 <a name="g-timeout-add-seconds"></a><h3>g_timeout_add_seconds ()</h3>
1982 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_timeout_add_seconds               (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
1983                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
1984                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
1985 <p>
1986 Sets a function to be called at regular intervals with the default
1987 priority, <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a>. The function is called repeatedly until
1988 it returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, at which point the timeout is automatically destroyed
1989 and the function will not be called again.
1990 </p>
1991 <p>
1992 This internally creates a main loop source using
1993 <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new-seconds" title="g_timeout_source_new_seconds ()"><code class="function">g_timeout_source_new_seconds()</code></a> and attaches it to the main loop context
1994 using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can do these steps manually if you need
1995 greater control. Also see <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds-full" title="g_timeout_add_seconds_full ()"><code class="function">g_timeout_add_seconds_full()</code></a>.
1996 </p>
1997 <p>
1998 Note that the first call of the timer may not be precise for timeouts
1999 of one second. If you need finer precision and have such a timeout,
2000 you may want to use <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a> instead.
2001 </p>
2002 <p>
2003 The interval given is in terms of monotonic time, not wall clock
2004 time.  See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.
2005 </p>
2006 <div class="variablelist"><table border="0">
2007 <col align="left" valign="top">
2008 <tbody>
2009 <tr>
2010 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
2011 <td>the time between calls to the function, in seconds</td>
2012 </tr>
2013 <tr>
2014 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2015 <td>function to call</td>
2016 </tr>
2017 <tr>
2018 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2019 <td>data to pass to <em class="parameter"><code>function</code></em>
2020 </td>
2021 </tr>
2022 <tr>
2023 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2024 <td>the ID (greater than 0) of the event source.</td>
2025 </tr>
2026 </tbody>
2027 </table></div>
2028 <p class="since">Since 2.14</p>
2029 </div>
2030 <hr>
2031 <div class="refsect2">
2032 <a name="g-timeout-add-seconds-full"></a><h3>g_timeout_add_seconds_full ()</h3>
2033 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_timeout_add_seconds_full          (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
2034                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
2035                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
2036                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
2037                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
2038 <p>
2039 Sets a function to be called at regular intervals, with <em class="parameter"><code>priority</code></em>.
2040 The function is called repeatedly until it returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, at which
2041 point the timeout is automatically destroyed and the function will
2042 not be called again.
2043 </p>
2044 <p>
2045 Unlike <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>, this function operates at whole second granularity.
2046 The initial starting point of the timer is determined by the implementation
2047 and the implementation is expected to group multiple timers together so that
2048 they fire all at the same time.
2049 To allow this grouping, the <em class="parameter"><code>interval</code></em> to the first timer is rounded
2050 and can deviate up to one second from the specified interval.
2051 Subsequent timer iterations will generally run at the specified interval.
2052 </p>
2053 <p>
2054 Note that timeout functions may be delayed, due to the processing of other
2055 event sources. Thus they should not be relied on for precise timing.
2056 After each call to the timeout function, the time of the next
2057 timeout is recalculated based on the current time and the given <em class="parameter"><code>interval</code></em>
2058 </p>
2059 <p>
2060 If you want timing more precise than whole seconds, use <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>
2061 instead.
2062 </p>
2063 <p>
2064 The grouping of timers to fire at the same time results in a more power
2065 and CPU efficient behavior so if your timer is in multiples of seconds
2066 and you don't require the first timer exactly one second from now, the
2067 use of <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds" title="g_timeout_add_seconds ()"><code class="function">g_timeout_add_seconds()</code></a> is preferred over <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>.
2068 </p>
2069 <p>
2070 This internally creates a main loop source using 
2071 <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new-seconds" title="g_timeout_source_new_seconds ()"><code class="function">g_timeout_source_new_seconds()</code></a> and attaches it to the main loop context 
2072 using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can do these steps manually if you need 
2073 greater control.
2074 </p>
2075 <p>
2076 The interval given is in terms of monotonic time, not wall clock
2077 time.  See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.
2078 </p>
2079 <div class="variablelist"><table border="0">
2080 <col align="left" valign="top">
2081 <tbody>
2082 <tr>
2083 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
2084 <td>the priority of the timeout source. Typically this will be in
2085 the range between <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a> and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH:CAPS" title="G_PRIORITY_HIGH"><span class="type">G_PRIORITY_HIGH</span></a>.</td>
2086 </tr>
2087 <tr>
2088 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
2089 <td>the time between calls to the function, in seconds</td>
2090 </tr>
2091 <tr>
2092 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2093 <td>function to call</td>
2094 </tr>
2095 <tr>
2096 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2097 <td>data to pass to <em class="parameter"><code>function</code></em>
2098 </td>
2099 </tr>
2100 <tr>
2101 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
2102 <td>function to call when the timeout is removed, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
2103 </td>
2104 </tr>
2105 <tr>
2106 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2107 <td>the ID (greater than 0) of the event source.
2108 Rename to: g_timeout_add_seconds</td>
2109 </tr>
2110 </tbody>
2111 </table></div>
2112 <p class="since">Since 2.14</p>
2113 </div>
2114 <hr>
2115 <div class="refsect2">
2116 <a name="g-idle-source-new"></a><h3>g_idle_source_new ()</h3>
2117 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_idle_source_new                   (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
2118 <p>
2119 Creates a new idle source.
2120 </p>
2121 <p>
2122 The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
2123 and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be
2124 executed. Note that the default priority for idle sources is
2125 <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE"><code class="literal">G_PRIORITY_DEFAULT_IDLE</code></a>, as compared to other sources which
2126 have a default priority of <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><code class="literal">G_PRIORITY_DEFAULT</code></a>.
2127 </p>
2128 <div class="variablelist"><table border="0">
2129 <col align="left" valign="top">
2130 <tbody><tr>
2131 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2132 <td>the newly-created idle source</td>
2133 </tr></tbody>
2134 </table></div>
2135 </div>
2136 <hr>
2137 <div class="refsect2">
2138 <a name="g-idle-add"></a><h3>g_idle_add ()</h3>
2139 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_idle_add                          (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
2140                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
2141 <p>
2142 Adds a function to be called whenever there are no higher priority
2143 events pending to the default main loop. The function is given the
2144 default idle priority, <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a>.  If the function
2145 returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> it is automatically removed from the list of event
2146 sources and will not be called again.
2147 </p>
2148 <p>
2149 This internally creates a main loop source using <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-source-new" title="g_idle_source_new ()"><code class="function">g_idle_source_new()</code></a>
2150 and attaches it to the main loop context using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. 
2151 You can do these steps manually if you need greater control.
2152 </p>
2153 <div class="variablelist"><table border="0">
2154 <col align="left" valign="top">
2155 <tbody>
2156 <tr>
2157 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2158 <td>function to call</td>
2159 </tr>
2160 <tr>
2161 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2162 <td>data to pass to <em class="parameter"><code>function</code></em>.</td>
2163 </tr>
2164 <tr>
2165 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2166 <td>the ID (greater than 0) of the event source.</td>
2167 </tr>
2168 </tbody>
2169 </table></div>
2170 </div>
2171 <hr>
2172 <div class="refsect2">
2173 <a name="g-idle-add-full"></a><h3>g_idle_add_full ()</h3>
2174 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_idle_add_full                     (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
2175                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>,
2176                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
2177                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
2178 <p>
2179 Adds a function to be called whenever there are no higher priority
2180 events pending.  If the function returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> it is automatically
2181 removed from the list of event sources and will not be called again.
2182 </p>
2183 <p>
2184 This internally creates a main loop source using <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-source-new" title="g_idle_source_new ()"><code class="function">g_idle_source_new()</code></a>
2185 and attaches it to the main loop context using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. 
2186 You can do these steps manually if you need greater control.
2187 </p>
2188 <div class="variablelist"><table border="0">
2189 <col align="left" valign="top">
2190 <tbody>
2191 <tr>
2192 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
2193 <td>the priority of the idle source. Typically this will be in the
2194 range between <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a> and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE"><span class="type">G_PRIORITY_HIGH_IDLE</span></a>.</td>
2195 </tr>
2196 <tr>
2197 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2198 <td>function to call</td>
2199 </tr>
2200 <tr>
2201 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2202 <td>data to pass to <em class="parameter"><code>function</code></em>
2203 </td>
2204 </tr>
2205 <tr>
2206 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
2207 <td>function to call when the idle is removed, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
2208 </td>
2209 </tr>
2210 <tr>
2211 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2212 <td>the ID (greater than 0) of the event source.
2213 Rename to: g_idle_add</td>
2214 </tr>
2215 </tbody>
2216 </table></div>
2217 </div>
2218 <hr>
2219 <div class="refsect2">
2220 <a name="g-idle-remove-by-data"></a><h3>g_idle_remove_by_data ()</h3>
2221 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_idle_remove_by_data               (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
2222 <p>
2223 Removes the idle function with the given data.
2224 </p>
2225 <div class="variablelist"><table border="0">
2226 <col align="left" valign="top">
2227 <tbody>
2228 <tr>
2229 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2230 <td>the data for the idle source's callback.</td>
2231 </tr>
2232 <tr>
2233 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2234 <td>
2235 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if an idle source was found and removed.</td>
2236 </tr>
2237 </tbody>
2238 </table></div>
2239 </div>
2240 <hr>
2241 <div class="refsect2">
2242 <a name="GPid"></a><h3>GPid</h3>
2243 <pre class="programlisting">typedef int GPid;
2244 </pre>
2245 <p>
2246 A type which is used to hold a process identification.
2247 </p>
2248 <p>
2249 On UNIX, processes are identified by a process id (an integer),
2250 while Windows uses process handles (which are pointers).
2251 </p>
2252 <p>
2253 GPid is used in GLib only for descendant processes spawned with
2254 the g_spawn functions.
2255 </p>
2256 </div>
2257 <hr>
2258 <div class="refsect2">
2259 <a name="GChildWatchFunc"></a><h3>GChildWatchFunc ()</h3>
2260 <pre class="programlisting"><span class="returnvalue">void</span>                (*GChildWatchFunc)                  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>,
2261                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> status</code></em>,
2262                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
2263 <p>
2264 The type of functions to be called when a child exists.
2265 </p>
2266 <div class="variablelist"><table border="0">
2267 <col align="left" valign="top">
2268 <tbody>
2269 <tr>
2270 <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td>
2271 <td>the process id of the child process</td>
2272 </tr>
2273 <tr>
2274 <td><p><span class="term"><em class="parameter"><code>status</code></em> :</span></p></td>
2275 <td>Status information about the child process,
2276 see waitpid(2) for more information about this field</td>
2277 </tr>
2278 <tr>
2279 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
2280 <td>user data passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add" title="g_child_watch_add ()"><code class="function">g_child_watch_add()</code></a>
2281 </td>
2282 </tr>
2283 </tbody>
2284 </table></div>
2285 </div>
2286 <hr>
2287 <div class="refsect2">
2288 <a name="g-child-watch-source-new"></a><h3>g_child_watch_source_new ()</h3>
2289 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_child_watch_source_new            (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>);</pre>
2290 <p>
2291 Creates a new child_watch source.
2292 </p>
2293 <p>
2294 The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
2295 and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be
2296 executed.
2297 </p>
2298 <p>
2299 Note that child watch sources can only be used in conjunction with
2300 <code class="literal">g_spawn...</code> when the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></a>
2301 flag is used.
2302 </p>
2303 <p>
2304 Note that on platforms where <a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> must be explicitly closed
2305 (see <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a>) <em class="parameter"><code>pid</code></em> must not be closed while the
2306 source is still active. Typically, you will want to call
2307 <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a> in the callback function for the source.
2308 </p>
2309 <p>
2310 Note further that using <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-source-new" title="g_child_watch_source_new ()"><code class="function">g_child_watch_source_new()</code></a> is not 
2311 compatible with calling <code class="literal">waitpid(-1)</code> in 
2312 the application. Calling <code class="function">waitpid()</code> for individual pids will
2313 still work fine.
2314 </p>
2315 <div class="variablelist"><table border="0">
2316 <col align="left" valign="top">
2317 <tbody>
2318 <tr>
2319 <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td>
2320 <td>process to watch. On POSIX the pid of a child process. On
2321 Windows a handle for a process (which doesn't have to be a child).</td>
2322 </tr>
2323 <tr>
2324 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2325 <td>the newly-created child watch source</td>
2326 </tr>
2327 </tbody>
2328 </table></div>
2329 <p class="since">Since 2.4</p>
2330 </div>
2331 <hr>
2332 <div class="refsect2">
2333 <a name="g-child-watch-add"></a><h3>g_child_watch_add ()</h3>
2334 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_child_watch_add                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>,
2335                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GChildWatchFunc" title="GChildWatchFunc ()"><span class="type">GChildWatchFunc</span></a> function</code></em>,
2336                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
2337 <p>
2338 Sets a function to be called when the child indicated by <em class="parameter"><code>pid</code></em> 
2339 exits, at a default priority, <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a>.
2340 </p>
2341 <p>
2342 If you obtain <em class="parameter"><code>pid</code></em> from <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()"><code class="function">g_spawn_async()</code></a> or <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()"><code class="function">g_spawn_async_with_pipes()</code></a> 
2343 you will need to pass <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><span class="type">G_SPAWN_DO_NOT_REAP_CHILD</span></a> as flag to 
2344 the spawn function for the child watching to work.
2345 </p>
2346 <p>
2347 Note that on platforms where <a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> must be explicitly closed
2348 (see <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a>) <em class="parameter"><code>pid</code></em> must not be closed while the
2349 source is still active. Typically, you will want to call
2350 <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a> in the callback function for the source.
2351 </p>
2352 <p>
2353 GLib supports only a single callback per process id.
2354 </p>
2355 <p>
2356 This internally creates a main loop source using 
2357 <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-source-new" title="g_child_watch_source_new ()"><code class="function">g_child_watch_source_new()</code></a> and attaches it to the main loop context 
2358 using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can do these steps manually if you 
2359 need greater control.
2360 </p>
2361 <div class="variablelist"><table border="0">
2362 <col align="left" valign="top">
2363 <tbody>
2364 <tr>
2365 <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td>
2366 <td>process id to watch. On POSIX the pid of a child process. On
2367 Windows a handle for a process (which doesn't have to be a child).</td>
2368 </tr>
2369 <tr>
2370 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2371 <td>function to call</td>
2372 </tr>
2373 <tr>
2374 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2375 <td>data to pass to <em class="parameter"><code>function</code></em>
2376 </td>
2377 </tr>
2378 <tr>
2379 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2380 <td>the ID (greater than 0) of the event source.</td>
2381 </tr>
2382 </tbody>
2383 </table></div>
2384 <p class="since">Since 2.4</p>
2385 </div>
2386 <hr>
2387 <div class="refsect2">
2388 <a name="g-child-watch-add-full"></a><h3>g_child_watch_add_full ()</h3>
2389 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_child_watch_add_full              (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
2390                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>,
2391                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GChildWatchFunc" title="GChildWatchFunc ()"><span class="type">GChildWatchFunc</span></a> function</code></em>,
2392                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
2393                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
2394 <p>
2395 Sets a function to be called when the child indicated by <em class="parameter"><code>pid</code></em> 
2396 exits, at the priority <em class="parameter"><code>priority</code></em>.
2397 </p>
2398 <p>
2399 If you obtain <em class="parameter"><code>pid</code></em> from <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()"><code class="function">g_spawn_async()</code></a> or <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()"><code class="function">g_spawn_async_with_pipes()</code></a> 
2400 you will need to pass <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><span class="type">G_SPAWN_DO_NOT_REAP_CHILD</span></a> as flag to 
2401 the spawn function for the child watching to work.
2402 </p>
2403 <p>
2404 Note that on platforms where <a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> must be explicitly closed
2405 (see <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a>) <em class="parameter"><code>pid</code></em> must not be closed while the
2406 source is still active. Typically, you will want to call
2407 <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a> in the callback function for the source.
2408 </p>
2409 <p>
2410 GLib supports only a single callback per process id.
2411 </p>
2412 <p>
2413 This internally creates a main loop source using 
2414 <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-source-new" title="g_child_watch_source_new ()"><code class="function">g_child_watch_source_new()</code></a> and attaches it to the main loop context 
2415 using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can do these steps manually if you 
2416 need greater control.
2417 </p>
2418 <div class="variablelist"><table border="0">
2419 <col align="left" valign="top">
2420 <tbody>
2421 <tr>
2422 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
2423 <td>the priority of the idle source. Typically this will be in the
2424 range between <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a> and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE"><span class="type">G_PRIORITY_HIGH_IDLE</span></a>.</td>
2425 </tr>
2426 <tr>
2427 <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td>
2428 <td>process to watch. On POSIX the pid of a child process. On
2429 Windows a handle for a process (which doesn't have to be a child).</td>
2430 </tr>
2431 <tr>
2432 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2433 <td>function to call</td>
2434 </tr>
2435 <tr>
2436 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2437 <td>data to pass to <em class="parameter"><code>function</code></em>
2438 </td>
2439 </tr>
2440 <tr>
2441 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
2442 <td>function to call when the idle is removed, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
2443 </td>
2444 </tr>
2445 <tr>
2446 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2447 <td>the ID (greater than 0) of the event source.
2448 Rename to: g_child_watch_add</td>
2449 </tr>
2450 </tbody>
2451 </table></div>
2452 <p class="since">Since 2.4</p>
2453 </div>
2454 <hr>
2455 <div class="refsect2">
2456 <a name="GPollFD"></a><h3>struct GPollFD</h3>
2457 <pre class="programlisting">struct GPollFD {
2458 #if defined (G_OS_WIN32) &amp;&amp; GLIB_SIZEOF_VOID_P == 8
2459   gint64 fd;
2460 #else
2461   gint          fd;
2462 #endif
2463   gushort       events;
2464   gushort       revents;
2465 };
2466 </pre>
2467 <p>
2468 Represents a file descriptor, which events to poll for, and which events
2469 occurred.
2470 </p>
2471 <div class="variablelist"><table border="0">
2472 <col align="left" valign="top">
2473 <tbody>
2474 <tr>
2475 <td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="type">gint64</span></a> <em class="structfield"><code><a name="GPollFD.fd"></a>fd</code></em>;</span></p></td>
2476 <td>the file descriptor to poll (or a <span class="type">HANDLE</span> on Win32)</td>
2477 </tr>
2478 <tr>
2479 <td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> <em class="structfield"><code><a name="GPollFD.fd"></a>fd</code></em>;</span></p></td>
2480 <td></td>
2481 </tr>
2482 <tr>
2483 <td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gushort" title="gushort"><span class="type">gushort</span></a> <em class="structfield"><code><a name="GPollFD.events"></a>events</code></em>;</span></p></td>
2484 <td>a bitwise combination from <a class="link" href="glib-IO-Channels.html#GIOCondition" title="enum GIOCondition"><span class="type">GIOCondition</span></a>, specifying which
2485 events should be polled for. Typically for reading from a file
2486 descriptor you would use <a class="link" href="glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</code></a> | <a class="link" href="glib-IO-Channels.html#G-IO-HUP:CAPS"><code class="literal">G_IO_HUP</code></a> | <a class="link" href="glib-IO-Channels.html#G-IO-ERR:CAPS"><code class="literal">G_IO_ERR</code></a>, and
2487 for writing you would use <a class="link" href="glib-IO-Channels.html#G-IO-OUT:CAPS"><code class="literal">G_IO_OUT</code></a> | <a class="link" href="glib-IO-Channels.html#G-IO-ERR:CAPS"><code class="literal">G_IO_ERR</code></a>.</td>
2488 </tr>
2489 <tr>
2490 <td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gushort" title="gushort"><span class="type">gushort</span></a> <em class="structfield"><code><a name="GPollFD.revents"></a>revents</code></em>;</span></p></td>
2491 <td>a bitwise combination of flags from <a class="link" href="glib-IO-Channels.html#GIOCondition" title="enum GIOCondition"><span class="type">GIOCondition</span></a>, returned
2492 from the <code class="function">poll()</code> function to indicate which events occurred.</td>
2493 </tr>
2494 </tbody>
2495 </table></div>
2496 </div>
2497 <hr>
2498 <div class="refsect2">
2499 <a name="g-poll"></a><h3>g_poll ()</h3>
2500 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_poll                              (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>,
2501                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> nfds</code></em>,
2502                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> timeout</code></em>);</pre>
2503 <p>
2504 Polls <em class="parameter"><code>fds</code></em>, as with the <code class="function">poll()</code> system call, but portably. (On
2505 systems that don't have <code class="function">poll()</code>, it is emulated using <code class="function">select()</code>.)
2506 This is used internally by <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, but it can be called
2507 directly if you need to block until a file descriptor is ready, but
2508 don't want to run the full main loop.
2509 </p>
2510 <p>
2511 Each element of <em class="parameter"><code>fds</code></em> is a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> describing a single file
2512 descriptor to poll. The <code class="literal">fd</code> field indicates the file descriptor,
2513 and the <code class="literal">events</code> field indicates the events to poll for. On return,
2514 the <code class="literal">revents</code> fields will be filled with the events that actually
2515 occurred.
2516 </p>
2517 <p>
2518 On POSIX systems, the file descriptors in <em class="parameter"><code>fds</code></em> can be any sort of
2519 file descriptor, but the situation is much more complicated on
2520 Windows. If you need to use <a class="link" href="glib-The-Main-Event-Loop.html#g-poll" title="g_poll ()"><code class="function">g_poll()</code></a> in code that has to run on
2521 Windows, the easiest solution is to construct all of your
2522 <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a>s with <code class="function">g_io_channel_win32_make_pollfd()</code>.
2523 </p>
2524 <div class="variablelist"><table border="0">
2525 <col align="left" valign="top">
2526 <tbody>
2527 <tr>
2528 <td><p><span class="term"><em class="parameter"><code>fds</code></em> :</span></p></td>
2529 <td>file descriptors to poll</td>
2530 </tr>
2531 <tr>
2532 <td><p><span class="term"><em class="parameter"><code>nfds</code></em> :</span></p></td>
2533 <td>the number of file descriptors in <em class="parameter"><code>fds</code></em>
2534 </td>
2535 </tr>
2536 <tr>
2537 <td><p><span class="term"><em class="parameter"><code>timeout</code></em> :</span></p></td>
2538 <td>amount of time to wait, in milliseconds, or -1 to wait forever</td>
2539 </tr>
2540 <tr>
2541 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2542 <td>the number of entries in <em class="parameter"><code>fds</code></em> whose <code class="literal">revents</code> fields
2543 were filled in, or 0 if the operation timed out, or -1 on error or
2544 if the call was interrupted.</td>
2545 </tr>
2546 </tbody>
2547 </table></div>
2548 <p class="since">Since 2.20</p>
2549 </div>
2550 <hr>
2551 <div class="refsect2">
2552 <a name="G-POLLFD-FORMAT:CAPS"></a><h3>G_POLLFD_FORMAT</h3>
2553 <pre class="programlisting">#define G_POLLFD_FORMAT "%#I64x"
2554 </pre>
2555 </div>
2556 <hr>
2557 <div class="refsect2">
2558 <a name="GSource"></a><h3>struct GSource</h3>
2559 <pre class="programlisting">struct GSource {
2560 };
2561 </pre>
2562 <p>
2563 The <span class="structname">GSource</span> struct is an opaque data type
2564 representing an event source.
2565 </p>
2566 </div>
2567 <hr>
2568 <div class="refsect2">
2569 <a name="GSourceDummyMarshal"></a><h3>GSourceDummyMarshal ()</h3>
2570 <pre class="programlisting"><span class="returnvalue">void</span>                (*GSourceDummyMarshal)              (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
2571 <p>
2572 This is just a placeholder for <a href="http://library.gnome.org/devel/gobject/unstable/gobject-Closures.html#GClosureMarshal"><span class="type">GClosureMarshal</span></a>,
2573 which cannot be used here for dependency reasons.
2574 </p>
2575 </div>
2576 <hr>
2577 <div class="refsect2">
2578 <a name="GSourceFuncs"></a><h3>struct GSourceFuncs</h3>
2579 <pre class="programlisting">struct GSourceFuncs {
2580   gboolean (*prepare)  (GSource    *source,
2581                         gint       *timeout_);
2582   gboolean (*check)    (GSource    *source);
2583   gboolean (*dispatch) (GSource    *source,
2584                         GSourceFunc callback,
2585                         gpointer    user_data);
2586   void     (*finalize) (GSource    *source); /* Can be NULL */
2587 };
2588 </pre>
2589 <p>
2590 The <span class="structname">GSourceFuncs</span> struct contains a table of
2591 functions used to handle event sources in a generic manner.
2592 </p>
2593 <p>
2594 For idle sources, the prepare and check functions always return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>
2595 to indicate that the source is always ready to be processed. The prepare
2596 function also returns a timeout value of 0 to ensure that the <code class="function">poll()</code> call
2597 doesn't block (since that would be time wasted which could have been spent
2598 running the idle function).
2599 </p>
2600 <p>
2601 For timeout sources, the prepare and check functions both return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>
2602 if the timeout interval has expired. The prepare function also returns
2603 a timeout value to ensure that the <code class="function">poll()</code> call doesn't block too long
2604 and miss the next timeout.
2605 </p>
2606 <p>
2607 For file descriptor sources, the prepare function typically returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>,
2608 since it must wait until <code class="function">poll()</code> has been called before it knows whether
2609 any events need to be processed. It sets the returned timeout to -1 to
2610 indicate that it doesn't mind how long the <code class="function">poll()</code> call blocks. In the
2611 check function, it tests the results of the <code class="function">poll()</code> call to see if the
2612 required condition has been met, and returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if so.
2613 </p>
2614 <div class="variablelist"><table border="0">
2615 <col align="left" valign="top">
2616 <tbody>
2617 <tr>
2618 <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.prepare"></a>prepare</code></em> ()</span></p></td>
2619 <td>Called before all the file descriptors are polled. If the
2620 source can determine that it is ready here (without waiting for the
2621 results of the <code class="function">poll()</code> call) it should return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>. It can also return
2622 a <em class="parameter"><code>timeout_</code></em> value which should be the maximum timeout (in milliseconds)
2623 which should be passed to the <code class="function">poll()</code> call. The actual timeout used will
2624 be -1 if all sources returned -1, or it will be the minimum of all the
2625 <em class="parameter"><code>timeout_</code></em> values returned which were &gt;= 0.</td>
2626 </tr>
2627 <tr>
2628 <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.check"></a>check</code></em> ()</span></p></td>
2629 <td>Called after all the file descriptors are polled. The source
2630 should return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if it is ready to be dispatched. Note that some
2631 time may have passed since the previous prepare function was called,
2632 so the source should be checked again here.</td>
2633 </tr>
2634 <tr>
2635 <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.dispatch"></a>dispatch</code></em> ()</span></p></td>
2636 <td>Called to dispatch the event source, after it has returned
2637 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> in either its <em class="parameter"><code>prepare</code></em> or its <em class="parameter"><code>check</code></em> function. The <em class="parameter"><code>dispatch</code></em>
2638 function is passed in a callback function and data. The callback
2639 function may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the source was never connected to a callback
2640 using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-callback" title="g_source_set_callback ()"><code class="function">g_source_set_callback()</code></a>. The <em class="parameter"><code>dispatch</code></em> function should call the
2641 callback function with <em class="parameter"><code>user_data</code></em> and whatever additional parameters
2642 are needed for this type of event source.</td>
2643 </tr>
2644 <tr>
2645 <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.finalize"></a>finalize</code></em> ()</span></p></td>
2646 <td>Called when the source is finalized.</td>
2647 </tr>
2648 </tbody>
2649 </table></div>
2650 </div>
2651 <hr>
2652 <div class="refsect2">
2653 <a name="GSourceCallbackFuncs"></a><h3>struct GSourceCallbackFuncs</h3>
2654 <pre class="programlisting">struct GSourceCallbackFuncs {
2655   void (*ref)   (gpointer     cb_data);
2656   void (*unref) (gpointer     cb_data);
2657   void (*get)   (gpointer     cb_data,
2658                  GSource     *source, 
2659                  GSourceFunc *func,
2660                  gpointer    *data);
2661 };
2662 </pre>
2663 <p>
2664 The <span class="structname">GSourceCallbackFuncs</span> struct contains
2665 functions for managing callback objects.
2666 </p>
2667 <div class="variablelist"><table border="0">
2668 <col align="left" valign="top">
2669 <tbody>
2670 <tr>
2671 <td><p><span class="term"><em class="structfield"><code><a name="GSourceCallbackFuncs.ref"></a>ref</code></em> ()</span></p></td>
2672 <td>Called when a reference is added to the callback object</td>
2673 </tr>
2674 <tr>
2675 <td><p><span class="term"><em class="structfield"><code><a name="GSourceCallbackFuncs.unref"></a>unref</code></em> ()</span></p></td>
2676 <td>Called when a reference to the callback object is dropped</td>
2677 </tr>
2678 <tr>
2679 <td><p><span class="term"><em class="structfield"><code><a name="GSourceCallbackFuncs.get"></a>get</code></em> ()</span></p></td>
2680 <td>Called to extract the callback function and data from the
2681 callback object.</td>
2682 </tr>
2683 </tbody>
2684 </table></div>
2685 </div>
2686 <hr>
2687 <div class="refsect2">
2688 <a name="g-source-new"></a><h3>g_source_new ()</h3>
2689 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_source_new                        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *source_funcs</code></em>,
2690                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> struct_size</code></em>);</pre>
2691 <p>
2692 Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> structure. The size is specified to
2693 allow creating structures derived from <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that contain
2694 additional data. The size passed in must be at least
2695 <code class="literal">sizeof (GSource)</code>.
2696 </p>
2697 <p>
2698 The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>
2699 and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be
2700 executed.
2701 </p>
2702 <div class="variablelist"><table border="0">
2703 <col align="left" valign="top">
2704 <tbody>
2705 <tr>
2706 <td><p><span class="term"><em class="parameter"><code>source_funcs</code></em> :</span></p></td>
2707 <td>structure containing functions that implement
2708 the sources behavior.</td>
2709 </tr>
2710 <tr>
2711 <td><p><span class="term"><em class="parameter"><code>struct_size</code></em> :</span></p></td>
2712 <td>size of the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> structure to create.</td>
2713 </tr>
2714 <tr>
2715 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2716 <td>the newly-created <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>.</td>
2717 </tr>
2718 </tbody>
2719 </table></div>
2720 </div>
2721 <hr>
2722 <div class="refsect2">
2723 <a name="g-source-ref"></a><h3>g_source_ref ()</h3>
2724 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> *           g_source_ref                        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
2725 <p>
2726 Increases the reference count on a source by one.
2727 </p>
2728 <div class="variablelist"><table border="0">
2729 <col align="left" valign="top">
2730 <tbody>
2731 <tr>
2732 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2733 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2734 </td>
2735 </tr>
2736 <tr>
2737 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2738 <td><em class="parameter"><code>source</code></em></td>
2739 </tr>
2740 </tbody>
2741 </table></div>
2742 </div>
2743 <hr>
2744 <div class="refsect2">
2745 <a name="g-source-unref"></a><h3>g_source_unref ()</h3>
2746 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_unref                      (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
2747 <p>
2748 Decreases the reference count of a source by one. If the
2749 resulting reference count is zero the source and associated
2750 memory will be destroyed.
2751 </p>
2752 <div class="variablelist"><table border="0">
2753 <col align="left" valign="top">
2754 <tbody><tr>
2755 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2756 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2757 </td>
2758 </tr></tbody>
2759 </table></div>
2760 </div>
2761 <hr>
2762 <div class="refsect2">
2763 <a name="g-source-set-funcs"></a><h3>g_source_set_funcs ()</h3>
2764 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_set_funcs                  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
2765                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>);</pre>
2766 <p>
2767 Sets the source functions (can be used to override 
2768 default implementations) of an unattached source.
2769 </p>
2770 <div class="variablelist"><table border="0">
2771 <col align="left" valign="top">
2772 <tbody>
2773 <tr>
2774 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2775 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2776 </td>
2777 </tr>
2778 <tr>
2779 <td><p><span class="term"><em class="parameter"><code>funcs</code></em> :</span></p></td>
2780 <td>the new <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a>
2781 </td>
2782 </tr>
2783 </tbody>
2784 </table></div>
2785 <p class="since">Since 2.12</p>
2786 </div>
2787 <hr>
2788 <div class="refsect2">
2789 <a name="g-source-attach"></a><h3>g_source_attach ()</h3>
2790 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_source_attach                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
2791                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre>
2792 <p>
2793 Adds a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> to a <em class="parameter"><code>context</code></em> so that it will be executed within
2794 that context. Remove it by calling <a class="link" href="glib-The-Main-Event-Loop.html#g-source-destroy" title="g_source_destroy ()"><code class="function">g_source_destroy()</code></a>.
2795 </p>
2796 <div class="variablelist"><table border="0">
2797 <col align="left" valign="top">
2798 <tbody>
2799 <tr>
2800 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2801 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2802 </td>
2803 </tr>
2804 <tr>
2805 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
2806 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
2807 </td>
2808 </tr>
2809 <tr>
2810 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2811 <td>the ID (greater than 0) for the source within the
2812 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>.</td>
2813 </tr>
2814 </tbody>
2815 </table></div>
2816 </div>
2817 <hr>
2818 <div class="refsect2">
2819 <a name="g-source-destroy"></a><h3>g_source_destroy ()</h3>
2820 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_destroy                    (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
2821 <p>
2822 Removes a source from its <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, if any, and mark it as
2823 destroyed.  The source cannot be subsequently added to another
2824 context.
2825 </p>
2826 <div class="variablelist"><table border="0">
2827 <col align="left" valign="top">
2828 <tbody><tr>
2829 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2830 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2831 </td>
2832 </tr></tbody>
2833 </table></div>
2834 </div>
2835 <hr>
2836 <div class="refsect2">
2837 <a name="g-source-is-destroyed"></a><h3>g_source_is_destroyed ()</h3>
2838 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_source_is_destroyed               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
2839 <p>
2840 Returns whether <em class="parameter"><code>source</code></em> has been destroyed.
2841 </p>
2842 <p>
2843 This is important when you operate upon your objects 
2844 from within idle handlers, but may have freed the object 
2845 before the dispatch of your idle handler.
2846 </p>
2847 <p>
2848 </p>
2849 <div class="informalexample"><pre class="programlisting">
2850 static gboolean 
2851 idle_callback (gpointer data)
2852 {
2853   SomeWidget *self = data;
2854    
2855   GDK_THREADS_ENTER ();
2856   /* do stuff with self */
2857   self-&gt;idle_id = 0;
2858   GDK_THREADS_LEAVE ();
2859    
2860   return G_SOURCE_REMOVE;
2861 }
2862  
2863 static void 
2864 some_widget_do_stuff_later (SomeWidget *self)
2865 {
2866   self-&gt;idle_id = g_idle_add (idle_callback, self);
2867 }
2868  
2869 static void 
2870 some_widget_finalize (GObject *object)
2871 {
2872   SomeWidget *self = SOME_WIDGET (object);
2873    
2874   if (self-&gt;idle_id)
2875     g_source_remove (self-&gt;idle_id);
2876    
2877   G_OBJECT_CLASS (parent_class)-&gt;finalize (object);
2878 }
2879 </pre></div>
2880 <p>
2881 </p>
2882 <p>
2883 This will fail in a multi-threaded application if the 
2884 widget is destroyed before the idle handler fires due 
2885 to the use after free in the callback. A solution, to 
2886 this particular problem, is to check to if the source
2887 has already been destroy within the callback.
2888 </p>
2889 <p>
2890 </p>
2891 <div class="informalexample"><pre class="programlisting">
2892 static gboolean 
2893 idle_callback (gpointer data)
2894 {
2895   SomeWidget *self = data;
2896   
2897   GDK_THREADS_ENTER ();
2898   if (!g_source_is_destroyed (g_main_current_source ()))
2899     {
2900       /* do stuff with self */
2901     }
2902   GDK_THREADS_LEAVE ();
2903   
2904   return FALSE;
2905 }
2906 </pre></div>
2907 <p>
2908 </p>
2909 <div class="variablelist"><table border="0">
2910 <col align="left" valign="top">
2911 <tbody>
2912 <tr>
2913 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2914 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2915 </td>
2916 </tr>
2917 <tr>
2918 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2919 <td>
2920 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the source has been destroyed</td>
2921 </tr>
2922 </tbody>
2923 </table></div>
2924 <p class="since">Since 2.12</p>
2925 </div>
2926 <hr>
2927 <div class="refsect2">
2928 <a name="g-source-set-priority"></a><h3>g_source_set_priority ()</h3>
2929 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_set_priority               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
2930                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>);</pre>
2931 <p>
2932 Sets the priority of a source. While the main loop is being run, a
2933 source will be dispatched if it is ready to be dispatched and no
2934 sources at a higher (numerically smaller) priority are ready to be
2935 dispatched.
2936 </p>
2937 <div class="variablelist"><table border="0">
2938 <col align="left" valign="top">
2939 <tbody>
2940 <tr>
2941 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2942 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2943 </td>
2944 </tr>
2945 <tr>
2946 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
2947 <td>the new priority.</td>
2948 </tr>
2949 </tbody>
2950 </table></div>
2951 </div>
2952 <hr>
2953 <div class="refsect2">
2954 <a name="g-source-get-priority"></a><h3>g_source_get_priority ()</h3>
2955 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_source_get_priority               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
2956 <p>
2957 Gets the priority of a source.
2958 </p>
2959 <div class="variablelist"><table border="0">
2960 <col align="left" valign="top">
2961 <tbody>
2962 <tr>
2963 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2964 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2965 </td>
2966 </tr>
2967 <tr>
2968 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2969 <td>the priority of the source</td>
2970 </tr>
2971 </tbody>
2972 </table></div>
2973 </div>
2974 <hr>
2975 <div class="refsect2">
2976 <a name="g-source-set-can-recurse"></a><h3>g_source_set_can_recurse ()</h3>
2977 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_set_can_recurse            (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
2978                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> can_recurse</code></em>);</pre>
2979 <p>
2980 Sets whether a source can be called recursively. If <em class="parameter"><code>can_recurse</code></em> is
2981 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, then while the source is being dispatched then this source
2982 will be processed normally. Otherwise, all processing of this
2983 source is blocked until the dispatch function returns.
2984 </p>
2985 <div class="variablelist"><table border="0">
2986 <col align="left" valign="top">
2987 <tbody>
2988 <tr>
2989 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2990 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2991 </td>
2992 </tr>
2993 <tr>
2994 <td><p><span class="term"><em class="parameter"><code>can_recurse</code></em> :</span></p></td>
2995 <td>whether recursion is allowed for this source</td>
2996 </tr>
2997 </tbody>
2998 </table></div>
2999 </div>
3000 <hr>
3001 <div class="refsect2">
3002 <a name="g-source-get-can-recurse"></a><h3>g_source_get_can_recurse ()</h3>
3003 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_source_get_can_recurse            (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
3004 <p>
3005 Checks whether a source is allowed to be called recursively.
3006 see <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-can-recurse" title="g_source_set_can_recurse ()"><code class="function">g_source_set_can_recurse()</code></a>.
3007 </p>
3008 <div class="variablelist"><table border="0">
3009 <col align="left" valign="top">
3010 <tbody>
3011 <tr>
3012 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3013 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3014 </td>
3015 </tr>
3016 <tr>
3017 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3018 <td>whether recursion is allowed.</td>
3019 </tr>
3020 </tbody>
3021 </table></div>
3022 </div>
3023 <hr>
3024 <div class="refsect2">
3025 <a name="g-source-get-id"></a><h3>g_source_get_id ()</h3>
3026 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_source_get_id                     (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
3027 <p>
3028 Returns the numeric ID for a particular source. The ID of a source
3029 is a positive integer which is unique within a particular main loop 
3030 context. The reverse
3031 mapping from ID to source is done by <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-find-source-by-id" title="g_main_context_find_source_by_id ()"><code class="function">g_main_context_find_source_by_id()</code></a>.
3032 </p>
3033 <div class="variablelist"><table border="0">
3034 <col align="left" valign="top">
3035 <tbody>
3036 <tr>
3037 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3038 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3039 </td>
3040 </tr>
3041 <tr>
3042 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3043 <td>the ID (greater than 0) for the source</td>
3044 </tr>
3045 </tbody>
3046 </table></div>
3047 </div>
3048 <hr>
3049 <div class="refsect2">
3050 <a name="g-source-get-name"></a><h3>g_source_get_name ()</h3>
3051 <pre class="programlisting">const <span class="returnvalue">char</span> *        g_source_get_name                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
3052 <p>
3053 Gets a name for the source, used in debugging and profiling.
3054 The name may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><span class="type">NULL</span></a> if it has never been set with
3055 <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-name" title="g_source_set_name ()"><code class="function">g_source_set_name()</code></a>.
3056 </p>
3057 <div class="variablelist"><table border="0">
3058 <col align="left" valign="top">
3059 <tbody>
3060 <tr>
3061 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3062 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3063 </td>
3064 </tr>
3065 <tr>
3066 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3067 <td>the name of the source</td>
3068 </tr>
3069 </tbody>
3070 </table></div>
3071 <p class="since">Since 2.26</p>
3072 </div>
3073 <hr>
3074 <div class="refsect2">
3075 <a name="g-source-set-name"></a><h3>g_source_set_name ()</h3>
3076 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_set_name                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
3077                                                          <em class="parameter"><code>const <span class="type">char</span> *name</code></em>);</pre>
3078 <p>
3079 Sets a name for the source, used in debugging and profiling.
3080 The name defaults to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><span class="type">NULL</span></a>.
3081 </p>
3082 <p>
3083 The source name should describe in a human-readable way
3084 what the source does. For example, "X11 event queue"
3085 or "GTK+ repaint idle handler" or whatever it is.
3086 </p>
3087 <p>
3088 It is permitted to call this function multiple times, but is not
3089 recommended due to the potential performance impact.  For example,
3090 one could change the name in the "check" function of a <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> 
3091 to include details like the event type in the source name.
3092 </p>
3093 <div class="variablelist"><table border="0">
3094 <col align="left" valign="top">
3095 <tbody>
3096 <tr>
3097 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3098 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3099 </td>
3100 </tr>
3101 <tr>
3102 <td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
3103 <td>debug name for the source</td>
3104 </tr>
3105 </tbody>
3106 </table></div>
3107 <p class="since">Since 2.26</p>
3108 </div>
3109 <hr>
3110 <div class="refsect2">
3111 <a name="g-source-set-name-by-id"></a><h3>g_source_set_name_by_id ()</h3>
3112 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_set_name_by_id             (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> tag</code></em>,
3113                                                          <em class="parameter"><code>const <span class="type">char</span> *name</code></em>);</pre>
3114 <p>
3115 Sets the name of a source using its ID.
3116 </p>
3117 <p>
3118 This is a convenience utility to set source names from the return
3119 value of <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>, etc.
3120 </p>
3121 <div class="variablelist"><table border="0">
3122 <col align="left" valign="top">
3123 <tbody>
3124 <tr>
3125 <td><p><span class="term"><em class="parameter"><code>tag</code></em> :</span></p></td>
3126 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> ID</td>
3127 </tr>
3128 <tr>
3129 <td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
3130 <td>debug name for the source</td>
3131 </tr>
3132 </tbody>
3133 </table></div>
3134 <p class="since">Since 2.26</p>
3135 </div>
3136 <hr>
3137 <div class="refsect2">
3138 <a name="g-source-get-context"></a><h3>g_source_get_context ()</h3>
3139 <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> *      g_source_get_context                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
3140 <p>
3141 Gets the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> with which the source is associated.
3142 Calling this function on a destroyed source is an error.
3143 </p>
3144 <div class="variablelist"><table border="0">
3145 <col align="left" valign="top">
3146 <tbody>
3147 <tr>
3148 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3149 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3150 </td>
3151 </tr>
3152 <tr>
3153 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3154 <td>the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> with which the
3155 source is associated, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the context has not
3156 yet been added to a source. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>][<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
3157 </td>
3158 </tr>
3159 </tbody>
3160 </table></div>
3161 </div>
3162 <hr>
3163 <div class="refsect2">
3164 <a name="g-source-set-callback"></a><h3>g_source_set_callback ()</h3>
3165 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_set_callback               (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
3166                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> func</code></em>,
3167                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
3168                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
3169 <p>
3170 Sets the callback function for a source. The callback for a source is
3171 called from the source's dispatch function.
3172 </p>
3173 <p>
3174 The exact type of <em class="parameter"><code>func</code></em> depends on the type of source; ie. you
3175 should not count on <em class="parameter"><code>func</code></em> being called with <em class="parameter"><code>data</code></em> as its first
3176 parameter.
3177 </p>
3178 <p>
3179 Typically, you won't use this function. Instead use functions specific
3180 to the type of source you are using.
3181 </p>
3182 <div class="variablelist"><table border="0">
3183 <col align="left" valign="top">
3184 <tbody>
3185 <tr>
3186 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3187 <td>the source</td>
3188 </tr>
3189 <tr>
3190 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
3191 <td>a callback function</td>
3192 </tr>
3193 <tr>
3194 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
3195 <td>the data to pass to callback function</td>
3196 </tr>
3197 <tr>
3198 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
3199 <td>a function to call when <em class="parameter"><code>data</code></em> is no longer in use, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
3200 </td>
3201 </tr>
3202 </tbody>
3203 </table></div>
3204 </div>
3205 <hr>
3206 <div class="refsect2">
3207 <a name="GSourceFunc"></a><h3>GSourceFunc ()</h3>
3208 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            (*GSourceFunc)                      (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
3209 <p>
3210 Specifies the type of function passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>,
3211 <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-full" title="g_timeout_add_full ()"><code class="function">g_timeout_add_full()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>, and <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add-full" title="g_idle_add_full ()"><code class="function">g_idle_add_full()</code></a>.
3212 </p>
3213 <div class="variablelist"><table border="0">
3214 <col align="left" valign="top">
3215 <tbody>
3216 <tr>
3217 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
3218 <td>data passed to the function, set when the source was
3219 created with one of the above functions</td>
3220 </tr>
3221 <tr>
3222 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3223 <td>
3224 <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> if the source should be removed</td>
3225 </tr>
3226 </tbody>
3227 </table></div>
3228 </div>
3229 <hr>
3230 <div class="refsect2">
3231 <a name="g-source-set-callback-indirect"></a><h3>g_source_set_callback_indirect ()</h3>
3232 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_set_callback_indirect      (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
3233                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> callback_data</code></em>,
3234                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceCallbackFuncs" title="struct GSourceCallbackFuncs"><span class="type">GSourceCallbackFuncs</span></a> *callback_funcs</code></em>);</pre>
3235 <p>
3236 Sets the callback function storing the data as a refcounted callback
3237 "object". This is used internally. Note that calling 
3238 <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-callback-indirect" title="g_source_set_callback_indirect ()"><code class="function">g_source_set_callback_indirect()</code></a> assumes
3239 an initial reference count on <em class="parameter"><code>callback_data</code></em>, and thus
3240 <em class="parameter"><code>callback_funcs-&gt;unref</code></em> will eventually be called once more
3241 than <em class="parameter"><code>callback_funcs-&gt;ref</code></em>.
3242 </p>
3243 <div class="variablelist"><table border="0">
3244 <col align="left" valign="top">
3245 <tbody>
3246 <tr>
3247 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3248 <td>the source</td>
3249 </tr>
3250 <tr>
3251 <td><p><span class="term"><em class="parameter"><code>callback_data</code></em> :</span></p></td>
3252 <td>pointer to callback data "object"</td>
3253 </tr>
3254 <tr>
3255 <td><p><span class="term"><em class="parameter"><code>callback_funcs</code></em> :</span></p></td>
3256 <td>functions for reference counting <em class="parameter"><code>callback_data</code></em>
3257 and getting the callback and data</td>
3258 </tr>
3259 </tbody>
3260 </table></div>
3261 </div>
3262 <hr>
3263 <div class="refsect2">
3264 <a name="g-source-add-poll"></a><h3>g_source_add_poll ()</h3>
3265 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_add_poll                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
3266                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);</pre>
3267 <p>
3268 Adds a file descriptor to the set of file descriptors polled for
3269 this source. This is usually combined with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()"><code class="function">g_source_new()</code></a> to add an
3270 event source. The event source's check function will typically test
3271 the <em class="parameter"><code>revents</code></em> field in the <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> struct and return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if events need
3272 to be processed.
3273 </p>
3274 <div class="variablelist"><table border="0">
3275 <col align="left" valign="top">
3276 <tbody>
3277 <tr>
3278 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3279 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3280 </td>
3281 </tr>
3282 <tr>
3283 <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td>
3284 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> structure holding information about a file
3285 descriptor to watch.</td>
3286 </tr>
3287 </tbody>
3288 </table></div>
3289 </div>
3290 <hr>
3291 <div class="refsect2">
3292 <a name="g-source-remove-poll"></a><h3>g_source_remove_poll ()</h3>
3293 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_remove_poll                (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
3294                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);</pre>
3295 <p>
3296 Removes a file descriptor from the set of file descriptors polled for
3297 this source.
3298 </p>
3299 <div class="variablelist"><table border="0">
3300 <col align="left" valign="top">
3301 <tbody>
3302 <tr>
3303 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3304 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3305 </td>
3306 </tr>
3307 <tr>
3308 <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td>
3309 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> structure previously passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-poll" title="g_source_add_poll ()"><code class="function">g_source_add_poll()</code></a>.</td>
3310 </tr>
3311 </tbody>
3312 </table></div>
3313 </div>
3314 <hr>
3315 <div class="refsect2">
3316 <a name="g-source-add-child-source"></a><h3>g_source_add_child_source ()</h3>
3317 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_add_child_source           (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
3318                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *child_source</code></em>);</pre>
3319 <p>
3320 Adds <em class="parameter"><code>child_source</code></em> to <em class="parameter"><code>source</code></em> as a "polled" source; when <em class="parameter"><code>source</code></em> is
3321 added to a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, <em class="parameter"><code>child_source</code></em> will be automatically added
3322 with the same priority, when <em class="parameter"><code>child_source</code></em> is triggered, it will
3323 cause <em class="parameter"><code>source</code></em> to dispatch (in addition to calling its own
3324 callback), and when <em class="parameter"><code>source</code></em> is destroyed, it will destroy
3325 <em class="parameter"><code>child_source</code></em> as well. (<em class="parameter"><code>source</code></em> will also still be dispatched if
3326 its own prepare/check functions indicate that it is ready.)
3327 </p>
3328 <p>
3329 If you don't need <em class="parameter"><code>child_source</code></em> to do anything on its own when it
3330 triggers, you can call <a href="http://library.gnome.org/devel/gobject/unstable/gobject-Closures.html#g-source-set-dummy-callback"><code class="function">g_source_set_dummy_callback()</code></a> on it to set a
3331 callback that does nothing (except return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if appropriate).
3332 </p>
3333 <p>
3334 <em class="parameter"><code>source</code></em> will hold a reference on <em class="parameter"><code>child_source</code></em> while <em class="parameter"><code>child_source</code></em>
3335 is attached to it.
3336 </p>
3337 <div class="variablelist"><table border="0">
3338 <col align="left" valign="top">
3339 <tbody>
3340 <tr>
3341 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3342 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3343 </td>
3344 </tr>
3345 <tr>
3346 <td><p><span class="term"><em class="parameter"><code>child_source</code></em> :</span></p></td>
3347 <td>a second <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that <em class="parameter"><code>source</code></em> should "poll"</td>
3348 </tr>
3349 </tbody>
3350 </table></div>
3351 <p class="since">Since 2.28</p>
3352 </div>
3353 <hr>
3354 <div class="refsect2">
3355 <a name="g-source-remove-child-source"></a><h3>g_source_remove_child_source ()</h3>
3356 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_remove_child_source        (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
3357                                                          <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *child_source</code></em>);</pre>
3358 <p>
3359 Detaches <em class="parameter"><code>child_source</code></em> from <em class="parameter"><code>source</code></em> and destroys it.
3360 </p>
3361 <div class="variablelist"><table border="0">
3362 <col align="left" valign="top">
3363 <tbody>
3364 <tr>
3365 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3366 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3367 </td>
3368 </tr>
3369 <tr>
3370 <td><p><span class="term"><em class="parameter"><code>child_source</code></em> :</span></p></td>
3371 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> previously passed to
3372 <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-child-source" title="g_source_add_child_source ()"><code class="function">g_source_add_child_source()</code></a>.</td>
3373 </tr>
3374 </tbody>
3375 </table></div>
3376 <p class="since">Since 2.28</p>
3377 </div>
3378 <hr>
3379 <div class="refsect2">
3380 <a name="g-source-get-time"></a><h3>g_source_get_time ()</h3>
3381 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="returnvalue">gint64</span></a>              g_source_get_time                   (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre>
3382 <p>
3383 Gets the time to be used when checking this source. The advantage of
3384 calling this function over calling <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a> directly is
3385 that when checking multiple sources, GLib can cache a single value
3386 instead of having to repeatedly get the system monotonic time.
3387 </p>
3388 <p>
3389 The time here is the system monotonic time, if available, or some
3390 other reasonable alternative otherwise.  See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.
3391 </p>
3392 <div class="variablelist"><table border="0">
3393 <col align="left" valign="top">
3394 <tbody>
3395 <tr>
3396 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3397 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3398 </td>
3399 </tr>
3400 <tr>
3401 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3402 <td>the monotonic time in microseconds</td>
3403 </tr>
3404 </tbody>
3405 </table></div>
3406 <p class="since">Since 2.28</p>
3407 </div>
3408 <hr>
3409 <div class="refsect2">
3410 <a name="g-source-get-current-time"></a><h3>g_source_get_current_time ()</h3>
3411 <pre class="programlisting"><span class="returnvalue">void</span>                g_source_get_current_time           (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>,
3412                                                          <em class="parameter"><code><a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="struct GTimeVal"><span class="type">GTimeVal</span></a> *timeval</code></em>);</pre>
3413 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
3414 <h3 class="title">Warning</h3>
3415 <p><code class="literal">g_source_get_current_time</code> has been deprecated since version 2.28 and should not be used in newly-written code. use <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-time" title="g_source_get_time ()"><code class="function">g_source_get_time()</code></a> instead</p>
3416 </div>
3417 <p>
3418 This function ignores <em class="parameter"><code>source</code></em> and is otherwise the same as
3419 <a class="link" href="glib-Date-and-Time-Functions.html#g-get-current-time" title="g_get_current_time ()"><code class="function">g_get_current_time()</code></a>.
3420 </p>
3421 <div class="variablelist"><table border="0">
3422 <col align="left" valign="top">
3423 <tbody>
3424 <tr>
3425 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3426 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3427 </td>
3428 </tr>
3429 <tr>
3430 <td><p><span class="term"><em class="parameter"><code>timeval</code></em> :</span></p></td>
3431 <td>
3432 <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="struct GTimeVal"><span class="type">GTimeVal</span></a> structure in which to store current time.</td>
3433 </tr>
3434 </tbody>
3435 </table></div>
3436 </div>
3437 <hr>
3438 <div class="refsect2">
3439 <a name="g-source-remove"></a><h3>g_source_remove ()</h3>
3440 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_source_remove                     (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> tag</code></em>);</pre>
3441 <p>
3442 Removes the source with the given id from the default main context. 
3443 The id of
3444 a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> is given by <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-id" title="g_source_get_id ()"><code class="function">g_source_get_id()</code></a>, or will be returned by the
3445 functions <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add-full" title="g_idle_add_full ()"><code class="function">g_idle_add_full()</code></a>,
3446 <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-full" title="g_timeout_add_full ()"><code class="function">g_timeout_add_full()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add" title="g_child_watch_add ()"><code class="function">g_child_watch_add()</code></a>,
3447 <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add-full" title="g_child_watch_add_full ()"><code class="function">g_child_watch_add_full()</code></a>, <a class="link" href="glib-IO-Channels.html#g-io-add-watch" title="g_io_add_watch ()"><code class="function">g_io_add_watch()</code></a>, and <a class="link" href="glib-IO-Channels.html#g-io-add-watch-full" title="g_io_add_watch_full ()"><code class="function">g_io_add_watch_full()</code></a>.
3448 </p>
3449 <p>
3450 See also <a class="link" href="glib-The-Main-Event-Loop.html#g-source-destroy" title="g_source_destroy ()"><code class="function">g_source_destroy()</code></a>. You must use <a class="link" href="glib-The-Main-Event-Loop.html#g-source-destroy" title="g_source_destroy ()"><code class="function">g_source_destroy()</code></a> for sources
3451 added to a non-default main context.
3452 </p>
3453 <div class="variablelist"><table border="0">
3454 <col align="left" valign="top">
3455 <tbody>
3456 <tr>
3457 <td><p><span class="term"><em class="parameter"><code>tag</code></em> :</span></p></td>
3458 <td>the ID of the source to remove.</td>
3459 </tr>
3460 <tr>
3461 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3462 <td>
3463 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the source was found and removed.</td>
3464 </tr>
3465 </tbody>
3466 </table></div>
3467 </div>
3468 <hr>
3469 <div class="refsect2">
3470 <a name="g-source-remove-by-funcs-user-data"></a><h3>g_source_remove_by_funcs_user_data ()</h3>
3471 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_source_remove_by_funcs_user_data  (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>,
3472                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
3473 <p>
3474 Removes a source from the default main loop context given the
3475 source functions and user data. If multiple sources exist with the
3476 same source functions and user data, only one will be destroyed.
3477 </p>
3478 <div class="variablelist"><table border="0">
3479 <col align="left" valign="top">
3480 <tbody>
3481 <tr>
3482 <td><p><span class="term"><em class="parameter"><code>funcs</code></em> :</span></p></td>
3483 <td>The <em class="parameter"><code>source_funcs</code></em> passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()"><code class="function">g_source_new()</code></a>
3484 </td>
3485 </tr>
3486 <tr>
3487 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
3488 <td>the user data for the callback</td>
3489 </tr>
3490 <tr>
3491 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3492 <td>
3493 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if a source was found and removed.</td>
3494 </tr>
3495 </tbody>
3496 </table></div>
3497 </div>
3498 <hr>
3499 <div class="refsect2">
3500 <a name="g-source-remove-by-user-data"></a><h3>g_source_remove_by_user_data ()</h3>
3501 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_source_remove_by_user_data        (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
3502 <p>
3503 Removes a source from the default main loop context given the user
3504 data for the callback. If multiple sources exist with the same user
3505 data, only one will be destroyed.
3506 </p>
3507 <div class="variablelist"><table border="0">
3508 <col align="left" valign="top">
3509 <tbody>
3510 <tr>
3511 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
3512 <td>the user_data for the callback.</td>
3513 </tr>
3514 <tr>
3515 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3516 <td>
3517 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if a source was found and removed.</td>
3518 </tr>
3519 </tbody>
3520 </table></div>
3521 </div>
3522 </div>
3523 </div>
3524 <div class="footer">
3525 <hr>
3526           Generated by GTK-Doc V1.18</div>
3527 </body>
3528 </html>