Tizen 2.1 base
[platform/upstream/glib2.0.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="id533838"></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="id533906"></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">
1417   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
1418     <tbody>
1419       <tr>
1420         <td class="listing_lines" align="right"><pre>1
1421 2
1422 3
1423 4
1424 5
1425 6
1426 7
1427 8
1428 9
1429 10
1430 11
1431 12
1432 13
1433 14
1434 15
1435 16
1436 17
1437 18
1438 19
1439 20
1440 21
1441 22
1442 23
1443 24
1444 25
1445 26
1446 27</pre></td>
1447         <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="usertype">GList</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">free_list</span><span class="symbol">;</span>
1448
1449 <span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span>
1450 <span class="function">allocate_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">gsize</span><span class="normal"> size</span><span class="symbol">)</span>
1451 <span class="cbracket">{</span><span class="normal"> </span>
1452 <span class="normal">  </span><span class="usertype">gpointer</span><span class="normal"> result </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Allocation.html#g-malloc">g_malloc</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">size</span><span class="symbol">);</span>
1453 <span class="normal">  free_list </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-prepend">g_list_prepend</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">free_list</span><span class="symbol">,</span><span class="normal"> result</span><span class="symbol">);</span>
1454 <span class="normal">  </span><span class="keyword">return</span><span class="normal"> result</span><span class="symbol">;</span>
1455 <span class="cbracket">}</span>
1456
1457 <span class="type">void</span>
1458 <span class="function">free_allocated_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span>
1459 <span class="cbracket">{</span>
1460 <span class="normal">  </span><span class="usertype">GList</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">l</span><span class="symbol">;</span>
1461 <span class="normal">  </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">l </span><span class="symbol">=</span><span class="normal"> free_list</span><span class="symbol">;</span><span class="normal"> l</span><span class="symbol">;</span><span class="normal"> l </span><span class="symbol">=</span><span class="normal"> l</span><span class="symbol">-&gt;</span><span class="normal">next</span><span class="symbol">);</span>
1462 <span class="normal">    </span><span class="function"><a href="glib-Memory-Allocation.html#g-free">g_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">l</span><span class="symbol">-&gt;</span><span class="normal">data</span><span class="symbol">);</span>
1463 <span class="normal">  </span><span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-free">g_list_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">free_list</span><span class="symbol">);</span>
1464 <span class="normal">  free_list </span><span class="symbol">=</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">;</span>
1465 <span class="normal"> </span><span class="cbracket">}</span>
1466
1467 <span class="symbol">[...]</span>
1468
1469 <span class="keyword">while</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">);</span><span class="normal"> </span>
1470 <span class="normal"> </span><span class="cbracket">{</span>
1471 <span class="normal">   </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-context-iteration">g_main_context_iteration</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">);</span>
1472 <span class="normal">   </span><span class="function">free_allocated_memory</span><span class="symbol">();</span>
1473 <span class="normal">  </span><span class="cbracket">}</span></pre></td>
1474       </tr>
1475     </tbody>
1476   </table>
1477 </div>
1478
1479 <p>
1480 </p>
1481 <p>
1482 This works from an application, however, if you want to do the same
1483 thing from a library, it gets more difficult, since you no longer
1484 control the main loop. You might think you can simply use an idle
1485 function to make the call to <code class="function">free_allocated_memory()</code>, but that
1486 doesn't work, since the idle function could be called from a
1487 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>
1488 </p>
1489 <p>
1490 </p>
1491 <div class="informalexample">
1492   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
1493     <tbody>
1494       <tr>
1495         <td class="listing_lines" align="right"><pre>1
1496 2
1497 3
1498 4
1499 5
1500 6
1501 7
1502 8
1503 9
1504 10
1505 11
1506 12
1507 13
1508 14
1509 15
1510 16
1511 17
1512 18
1513 19
1514 20
1515 21
1516 22
1517 23
1518 24
1519 25
1520 26
1521 27
1522 28
1523 29
1524 30</pre></td>
1525         <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span>
1526 <span class="function">allocate_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">gsize</span><span class="normal"> size</span><span class="symbol">)</span>
1527 <span class="cbracket">{</span><span class="normal"> </span>
1528 <span class="normal">  </span><span class="usertype">FreeListBlock</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">block </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Allocation.html#g-new">g_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">FreeListBlock</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">);</span>
1529 <span class="normal">  block</span><span class="symbol">-&gt;</span><span class="normal">mem </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Allocation.html#g-malloc">g_malloc</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">size</span><span class="symbol">);</span>
1530 <span class="normal">  block</span><span class="symbol">-&gt;</span><span class="normal">depth </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-depth">g_main_depth</a></span><span class="normal"> </span><span class="symbol">();</span><span class="normal">   </span>
1531 <span class="normal">  free_list </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-prepend">g_list_prepend</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">free_list</span><span class="symbol">,</span><span class="normal"> block</span><span class="symbol">);</span>
1532 <span class="normal">  </span><span class="keyword">return</span><span class="normal"> block</span><span class="symbol">-&gt;</span><span class="normal">mem</span><span class="symbol">;</span>
1533 <span class="cbracket">}</span>
1534
1535 <span class="type">void</span>
1536 <span class="function">free_allocated_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span>
1537 <span class="cbracket">{</span>
1538 <span class="normal">  </span><span class="usertype">GList</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">l</span><span class="symbol">;</span>
1539 <span class="normal">  </span>
1540 <span class="normal">  </span><span class="type">int</span><span class="normal"> depth </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-depth">g_main_depth</a></span><span class="normal"> </span><span class="symbol">();</span>
1541 <span class="normal">  </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">l </span><span class="symbol">=</span><span class="normal"> free_list</span><span class="symbol">;</span><span class="normal"> l</span><span class="symbol">;</span><span class="normal"> </span><span class="symbol">);</span>
1542 <span class="normal">    </span><span class="cbracket">{</span>
1543 <span class="normal">      </span><span class="usertype">GList</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> l</span><span class="symbol">-&gt;</span><span class="normal">next</span><span class="symbol">;</span>
1544 <span class="normal">      </span><span class="usertype">FreeListBlock</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">block </span><span class="symbol">=</span><span class="normal"> l</span><span class="symbol">-&gt;</span><span class="normal">data</span><span class="symbol">;</span>
1545 <span class="normal">      </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">block</span><span class="symbol">-&gt;</span><span class="normal">depth </span><span class="symbol">&gt;</span><span class="normal"> depth</span><span class="symbol">)</span>
1546 <span class="normal">        </span><span class="cbracket">{</span>
1547 <span class="normal">          </span><span class="function"><a href="glib-Memory-Allocation.html#g-free">g_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">block</span><span class="symbol">-&gt;</span><span class="normal">mem</span><span class="symbol">);</span>
1548 <span class="normal">          </span><span class="function"><a href="glib-Memory-Allocation.html#g-free">g_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">block</span><span class="symbol">);</span>
1549 <span class="normal">          free_list </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-delete-link">g_list_delete_link</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">free_list</span><span class="symbol">,</span><span class="normal"> l</span><span class="symbol">);</span>
1550 <span class="normal">        </span><span class="cbracket">}</span>
1551 <span class="normal">              </span>
1552 <span class="normal">      l </span><span class="symbol">=</span><span class="normal"> next</span><span class="symbol">;</span>
1553 <span class="normal">    </span><span class="cbracket">}</span>
1554 <span class="normal">  </span><span class="cbracket">}</span></pre></td>
1555       </tr>
1556     </tbody>
1557   </table>
1558 </div>
1559
1560 <p>
1561 </p>
1562 <p>
1563 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
1564 problems with reentrancy. For instance, while waiting for data
1565 to be received from the network in response to a menu item,
1566 the menu item might be selected again. It might seem that
1567 one could make the menu item's callback return immediately
1568 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.
1569 However, this should be avoided since the user then sees selecting
1570 the menu item do nothing. Furthermore, you'll find yourself adding
1571 these checks all over your code, since there are doubtless many,
1572 many things that the user could do. Instead, you can use the
1573 following techniques:
1574 </p>
1575 <p>
1576 </p>
1577 <div class="orderedlist"><ol class="orderedlist" type="1">
1578 <li class="listitem"><p>
1579     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
1580     the user from interacting with elements while the main
1581     loop is recursing.
1582   </p></li>
1583 <li class="listitem"><p>
1584     Avoid main loop recursion in situations where you can't handle
1585     arbitrary  callbacks. Instead, structure your code so that you
1586     simply return to the main loop and then get called again when
1587     there is more work to do.
1588   </p></li>
1589 </ol></div>
1590 <p>
1591 </p>
1592 <div class="variablelist"><table border="0">
1593 <col align="left" valign="top">
1594 <tbody><tr>
1595 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1596 <td>The main loop recursion level in the current thread</td>
1597 </tr></tbody>
1598 </table></div>
1599 </div>
1600 <hr>
1601 <div class="refsect2">
1602 <a name="g-main-current-source"></a><h3>g_main_current_source ()</h3>
1603 <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>
1604 <p>
1605 Returns the currently firing source for this thread.
1606 </p>
1607 <div class="variablelist"><table border="0">
1608 <col align="left" valign="top">
1609 <tbody><tr>
1610 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1611 <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>
1612 </td>
1613 </tr></tbody>
1614 </table></div>
1615 <p class="since">Since 2.12</p>
1616 </div>
1617 <hr>
1618 <div class="refsect2">
1619 <a name="g-main-set-poll-func"></a><h3>g_main_set_poll_func()</h3>
1620 <pre class="programlisting">#define             g_main_set_poll_func(func)</pre>
1621 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
1622 <h3 class="title">Warning</h3>
1623 <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>
1624 </div>
1625 <p>
1626 Sets the function to use for the handle polling of file descriptors
1627 for the default main context.
1628 </p>
1629 <div class="variablelist"><table border="0">
1630 <col align="left" valign="top">
1631 <tbody><tr>
1632 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
1633 <td>the function to call to poll all file descriptors</td>
1634 </tr></tbody>
1635 </table></div>
1636 </div>
1637 <hr>
1638 <div class="refsect2">
1639 <a name="g-main-context-invoke"></a><h3>g_main_context_invoke ()</h3>
1640 <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>,
1641                                                          <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>,
1642                                                          <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>
1643 <p>
1644 Invokes a function in such a way that <em class="parameter"><code>context</code></em> is owned during the
1645 invocation of <em class="parameter"><code>function</code></em>.
1646 </p>
1647 <p>
1648 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
1649 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.
1650 </p>
1651 <p>
1652 If <em class="parameter"><code>context</code></em> is owned by the current thread, <em class="parameter"><code>function</code></em> is called
1653 directly.  Otherwise, if <em class="parameter"><code>context</code></em> is the thread-default main context
1654 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
1655 <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
1656 afterwards.
1657 </p>
1658 <p>
1659 In any other case, an idle source is created to call <em class="parameter"><code>function</code></em> and
1660 that source is attached to <em class="parameter"><code>context</code></em> (presumably to be run in another
1661 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>
1662 priority.  If you want a different priority, use
1663 <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>.
1664 </p>
1665 <p>
1666 Note that, as with normal idle functions, <em class="parameter"><code>function</code></em> should probably
1667 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
1668 loop (and may prevent this call from returning).
1669 </p>
1670 <div class="variablelist"><table border="0">
1671 <col align="left" valign="top">
1672 <tbody>
1673 <tr>
1674 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1675 <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>
1676 </td>
1677 </tr>
1678 <tr>
1679 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
1680 <td>function to call</td>
1681 </tr>
1682 <tr>
1683 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1684 <td>data to pass to <em class="parameter"><code>function</code></em>
1685 </td>
1686 </tr>
1687 </tbody>
1688 </table></div>
1689 <p class="since">Since 2.28</p>
1690 </div>
1691 <hr>
1692 <div class="refsect2">
1693 <a name="g-main-context-invoke-full"></a><h3>g_main_context_invoke_full ()</h3>
1694 <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>,
1695                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>,
1696                                                          <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>,
1697                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
1698                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
1699 <p>
1700 Invokes a function in such a way that <em class="parameter"><code>context</code></em> is owned during the
1701 invocation of <em class="parameter"><code>function</code></em>.
1702 </p>
1703 <p>
1704 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
1705 lets you specify the priority incase <em class="parameter"><code>function</code></em> ends up being
1706 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>.
1707 </p>
1708 <p>
1709 <em class="parameter"><code>notify</code></em> should not assume that it is called from any particular
1710 thread or with any particular context acquired.
1711 </p>
1712 <div class="variablelist"><table border="0">
1713 <col align="left" valign="top">
1714 <tbody>
1715 <tr>
1716 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1717 <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>
1718 </td>
1719 </tr>
1720 <tr>
1721 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
1722 <td>the priority at which to run <em class="parameter"><code>function</code></em>
1723 </td>
1724 </tr>
1725 <tr>
1726 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
1727 <td>function to call</td>
1728 </tr>
1729 <tr>
1730 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1731 <td>data to pass to <em class="parameter"><code>function</code></em>
1732 </td>
1733 </tr>
1734 <tr>
1735 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
1736 <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>
1737 </td>
1738 </tr>
1739 </tbody>
1740 </table></div>
1741 <p class="since">Since 2.28</p>
1742 </div>
1743 <hr>
1744 <div class="refsect2">
1745 <a name="g-main-context-get-thread-default"></a><h3>g_main_context_get_thread_default ()</h3>
1746 <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>
1747 <p>
1748 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
1749 operations that want to be able to be run in contexts other than
1750 the default one should call this method or
1751 <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
1752 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
1753 programs applications may sometimes want to temporarily push a
1754 non-default context, so it is not safe to assume that this will
1755 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.)
1756 </p>
1757 <p>
1758 If you need to hold a reference on the context, use
1759 <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.
1760 </p>
1761 <div class="variablelist"><table border="0">
1762 <col align="left" valign="top">
1763 <tbody><tr>
1764 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1765 <td>the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, or
1766 <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>
1767 </td>
1768 </tr></tbody>
1769 </table></div>
1770 <p class="since">Since 2.22</p>
1771 </div>
1772 <hr>
1773 <div class="refsect2">
1774 <a name="g-main-context-ref-thread-default"></a><h3>g_main_context_ref_thread_default ()</h3>
1775 <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>
1776 <p>
1777 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
1778 <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
1779 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
1780 <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
1781 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>
1782 (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>.
1783 </p>
1784 <div class="variablelist"><table border="0">
1785 <col align="left" valign="top">
1786 <tbody><tr>
1787 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1788 <td>the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>. Unref
1789 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>
1790 </td>
1791 </tr></tbody>
1792 </table></div>
1793 <p class="since">Since 2.32</p>
1794 </div>
1795 <hr>
1796 <div class="refsect2">
1797 <a name="g-main-context-push-thread-default"></a><h3>g_main_context_push_thread_default ()</h3>
1798 <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>
1799 <p>
1800 Acquires <em class="parameter"><code>context</code></em> and sets it as the thread-default context for the
1801 current thread. This will cause certain asynchronous operations
1802 (such as most gio-based I/O) which are
1803 started in this thread to run under <em class="parameter"><code>context</code></em> and deliver their
1804 results to its main loop, rather than running under the global
1805 default context in the main thread. Note that calling this function
1806 changes the context returned by
1807 <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
1808 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
1809 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>.
1810 </p>
1811 <p>
1812 Normally you would call this function shortly after creating a new
1813 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
1814 <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
1815 async operations in that thread. (In this case, you don't need to
1816 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
1817 however, you may want to schedule a single operation in a
1818 non-default context, or temporarily use a non-default context in
1819 the main thread. In that case, you can wrap the call to the
1820 asynchronous operation inside a
1821 <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> /
1822 <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
1823 ensure that no other asynchronous operations accidentally get
1824 started while the non-default context is active.
1825 </p>
1826 <p>
1827 Beware that libraries that predate this function may not correctly
1828 handle being used from a thread with a thread-default context. Eg,
1829 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>.
1830 </p>
1831 <div class="variablelist"><table border="0">
1832 <col align="left" valign="top">
1833 <tbody><tr>
1834 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1835 <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>
1836 </td>
1837 </tr></tbody>
1838 </table></div>
1839 <p class="since">Since 2.22</p>
1840 </div>
1841 <hr>
1842 <div class="refsect2">
1843 <a name="g-main-context-pop-thread-default"></a><h3>g_main_context_pop_thread_default ()</h3>
1844 <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>
1845 <p>
1846 Pops <em class="parameter"><code>context</code></em> off the thread-default context stack (verifying that
1847 it was on the top of the stack).
1848 </p>
1849 <div class="variablelist"><table border="0">
1850 <col align="left" valign="top">
1851 <tbody><tr>
1852 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
1853 <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>
1854 </td>
1855 </tr></tbody>
1856 </table></div>
1857 <p class="since">Since 2.22</p>
1858 </div>
1859 <hr>
1860 <div class="refsect2">
1861 <a name="g-timeout-source-new"></a><h3>g_timeout_source_new ()</h3>
1862 <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>
1863 <p>
1864 Creates a new timeout source.
1865 </p>
1866 <p>
1867 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>
1868 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
1869 executed.
1870 </p>
1871 <p>
1872 The interval given is in terms of monotonic time, not wall clock
1873 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>.
1874 </p>
1875 <div class="variablelist"><table border="0">
1876 <col align="left" valign="top">
1877 <tbody>
1878 <tr>
1879 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
1880 <td>the timeout interval in milliseconds.</td>
1881 </tr>
1882 <tr>
1883 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1884 <td>the newly-created timeout source</td>
1885 </tr>
1886 </tbody>
1887 </table></div>
1888 </div>
1889 <hr>
1890 <div class="refsect2">
1891 <a name="g-timeout-source-new-seconds"></a><h3>g_timeout_source_new_seconds ()</h3>
1892 <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>
1893 <p>
1894 Creates a new timeout source.
1895 </p>
1896 <p>
1897 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>
1898 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
1899 executed.
1900 </p>
1901 <p>
1902 The scheduling granularity/accuracy of this timeout source will be
1903 in seconds.
1904 </p>
1905 <p>
1906 The interval given in terms of monotonic time, not wall clock time.
1907 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>.
1908 </p>
1909 <div class="variablelist"><table border="0">
1910 <col align="left" valign="top">
1911 <tbody>
1912 <tr>
1913 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
1914 <td>the timeout interval in seconds</td>
1915 </tr>
1916 <tr>
1917 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1918 <td>the newly-created timeout source</td>
1919 </tr>
1920 </tbody>
1921 </table></div>
1922 <p class="since">Since 2.14</p>
1923 </div>
1924 <hr>
1925 <div class="refsect2">
1926 <a name="g-timeout-add"></a><h3>g_timeout_add ()</h3>
1927 <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>,
1928                                                          <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>,
1929                                                          <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>
1930 <p>
1931 Sets a function to be called at regular intervals, with the default
1932 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
1933 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
1934 destroyed and the function will not be called again.  The first call
1935 to the function will be at the end of the first <em class="parameter"><code>interval</code></em>.
1936 </p>
1937 <p>
1938 Note that timeout functions may be delayed, due to the processing of other
1939 event sources. Thus they should not be relied on for precise timing.
1940 After each call to the timeout function, the time of the next
1941 timeout is recalculated based on the current time and the given interval
1942 (it does not try to 'catch up' time lost in delays).
1943 </p>
1944 <p>
1945 If you want to have a timer in the "seconds" range and do not care
1946 about the exact time of the first call of the timer, use the
1947 <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
1948 optimizations and more efficient system power usage.
1949 </p>
1950 <p>
1951 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>
1952 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
1953 do these steps manually if you need greater control.
1954 </p>
1955 <p>
1956 The interval given is in terms of monotonic time, not wall clock
1957 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>.
1958 </p>
1959 <div class="variablelist"><table border="0">
1960 <col align="left" valign="top">
1961 <tbody>
1962 <tr>
1963 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
1964 <td>the time between calls to the function, in milliseconds
1965 (1/1000ths of a second)</td>
1966 </tr>
1967 <tr>
1968 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
1969 <td>function to call</td>
1970 </tr>
1971 <tr>
1972 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1973 <td>data to pass to <em class="parameter"><code>function</code></em>
1974 </td>
1975 </tr>
1976 <tr>
1977 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1978 <td>the ID (greater than 0) of the event source.</td>
1979 </tr>
1980 </tbody>
1981 </table></div>
1982 </div>
1983 <hr>
1984 <div class="refsect2">
1985 <a name="g-timeout-add-full"></a><h3>g_timeout_add_full ()</h3>
1986 <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>,
1987                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
1988                                                          <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>,
1989                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
1990                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
1991 <p>
1992 Sets a function to be called at regular intervals, with the given
1993 priority.  The function is called repeatedly until it returns
1994 <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
1995 the function will not be called again.  The <em class="parameter"><code>notify</code></em> function is
1996 called when the timeout is destroyed.  The first call to the
1997 function will be at the end of the first <em class="parameter"><code>interval</code></em>.
1998 </p>
1999 <p>
2000 Note that timeout functions may be delayed, due to the processing of other
2001 event sources. Thus they should not be relied on for precise timing.
2002 After each call to the timeout function, the time of the next
2003 timeout is recalculated based on the current time and the given interval
2004 (it does not try to 'catch up' time lost in delays).
2005 </p>
2006 <p>
2007 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>
2008 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
2009 do these steps manually if you need greater control.
2010 </p>
2011 <p>
2012 The interval given in terms of monotonic time, not wall clock time.
2013 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>.
2014 </p>
2015 <div class="variablelist"><table border="0">
2016 <col align="left" valign="top">
2017 <tbody>
2018 <tr>
2019 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
2020 <td>the priority of the timeout source. Typically this will be in
2021 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>
2022 </tr>
2023 <tr>
2024 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
2025 <td>the time between calls to the function, in milliseconds
2026 (1/1000ths of a second)</td>
2027 </tr>
2028 <tr>
2029 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2030 <td>function to call</td>
2031 </tr>
2032 <tr>
2033 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2034 <td>data to pass to <em class="parameter"><code>function</code></em>
2035 </td>
2036 </tr>
2037 <tr>
2038 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
2039 <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>
2040 </td>
2041 </tr>
2042 <tr>
2043 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2044 <td>the ID (greater than 0) of the event source.
2045 Rename to: g_timeout_add</td>
2046 </tr>
2047 </tbody>
2048 </table></div>
2049 </div>
2050 <hr>
2051 <div class="refsect2">
2052 <a name="g-timeout-add-seconds"></a><h3>g_timeout_add_seconds ()</h3>
2053 <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>,
2054                                                          <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>,
2055                                                          <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>
2056 <p>
2057 Sets a function to be called at regular intervals with the default
2058 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
2059 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
2060 and the function will not be called again.
2061 </p>
2062 <p>
2063 This internally creates a main loop source using
2064 <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
2065 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
2066 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>.
2067 </p>
2068 <p>
2069 Note that the first call of the timer may not be precise for timeouts
2070 of one second. If you need finer precision and have such a timeout,
2071 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.
2072 </p>
2073 <p>
2074 The interval given is in terms of monotonic time, not wall clock
2075 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>.
2076 </p>
2077 <div class="variablelist"><table border="0">
2078 <col align="left" valign="top">
2079 <tbody>
2080 <tr>
2081 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
2082 <td>the time between calls to the function, in seconds</td>
2083 </tr>
2084 <tr>
2085 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2086 <td>function to call</td>
2087 </tr>
2088 <tr>
2089 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2090 <td>data to pass to <em class="parameter"><code>function</code></em>
2091 </td>
2092 </tr>
2093 <tr>
2094 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2095 <td>the ID (greater than 0) of the event source.</td>
2096 </tr>
2097 </tbody>
2098 </table></div>
2099 <p class="since">Since 2.14</p>
2100 </div>
2101 <hr>
2102 <div class="refsect2">
2103 <a name="g-timeout-add-seconds-full"></a><h3>g_timeout_add_seconds_full ()</h3>
2104 <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>,
2105                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>,
2106                                                          <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>,
2107                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
2108                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
2109 <p>
2110 Sets a function to be called at regular intervals, with <em class="parameter"><code>priority</code></em>.
2111 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
2112 point the timeout is automatically destroyed and the function will
2113 not be called again.
2114 </p>
2115 <p>
2116 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.
2117 The initial starting point of the timer is determined by the implementation
2118 and the implementation is expected to group multiple timers together so that
2119 they fire all at the same time.
2120 To allow this grouping, the <em class="parameter"><code>interval</code></em> to the first timer is rounded
2121 and can deviate up to one second from the specified interval.
2122 Subsequent timer iterations will generally run at the specified interval.
2123 </p>
2124 <p>
2125 Note that timeout functions may be delayed, due to the processing of other
2126 event sources. Thus they should not be relied on for precise timing.
2127 After each call to the timeout function, the time of the next
2128 timeout is recalculated based on the current time and the given <em class="parameter"><code>interval</code></em>
2129 </p>
2130 <p>
2131 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>
2132 instead.
2133 </p>
2134 <p>
2135 The grouping of timers to fire at the same time results in a more power
2136 and CPU efficient behavior so if your timer is in multiples of seconds
2137 and you don't require the first timer exactly one second from now, the
2138 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>.
2139 </p>
2140 <p>
2141 This internally creates a main loop source using 
2142 <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 
2143 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 
2144 greater control.
2145 </p>
2146 <p>
2147 The interval given is in terms of monotonic time, not wall clock
2148 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>.
2149 </p>
2150 <div class="variablelist"><table border="0">
2151 <col align="left" valign="top">
2152 <tbody>
2153 <tr>
2154 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
2155 <td>the priority of the timeout source. Typically this will be in
2156 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>
2157 </tr>
2158 <tr>
2159 <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
2160 <td>the time between calls to the function, in seconds</td>
2161 </tr>
2162 <tr>
2163 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2164 <td>function to call</td>
2165 </tr>
2166 <tr>
2167 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2168 <td>data to pass to <em class="parameter"><code>function</code></em>
2169 </td>
2170 </tr>
2171 <tr>
2172 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
2173 <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>
2174 </td>
2175 </tr>
2176 <tr>
2177 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2178 <td>the ID (greater than 0) of the event source.
2179 Rename to: g_timeout_add_seconds</td>
2180 </tr>
2181 </tbody>
2182 </table></div>
2183 <p class="since">Since 2.14</p>
2184 </div>
2185 <hr>
2186 <div class="refsect2">
2187 <a name="g-idle-source-new"></a><h3>g_idle_source_new ()</h3>
2188 <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>
2189 <p>
2190 Creates a new idle source.
2191 </p>
2192 <p>
2193 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>
2194 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
2195 executed. Note that the default priority for idle sources is
2196 <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
2197 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>.
2198 </p>
2199 <div class="variablelist"><table border="0">
2200 <col align="left" valign="top">
2201 <tbody><tr>
2202 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2203 <td>the newly-created idle source</td>
2204 </tr></tbody>
2205 </table></div>
2206 </div>
2207 <hr>
2208 <div class="refsect2">
2209 <a name="g-idle-add"></a><h3>g_idle_add ()</h3>
2210 <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>,
2211                                                          <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>
2212 <p>
2213 Adds a function to be called whenever there are no higher priority
2214 events pending to the default main loop. The function is given the
2215 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
2216 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
2217 sources and will not be called again.
2218 </p>
2219 <p>
2220 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>
2221 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>. 
2222 You can do these steps manually if you need greater control.
2223 </p>
2224 <div class="variablelist"><table border="0">
2225 <col align="left" valign="top">
2226 <tbody>
2227 <tr>
2228 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2229 <td>function to call</td>
2230 </tr>
2231 <tr>
2232 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2233 <td>data to pass to <em class="parameter"><code>function</code></em>.</td>
2234 </tr>
2235 <tr>
2236 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2237 <td>the ID (greater than 0) of the event source.</td>
2238 </tr>
2239 </tbody>
2240 </table></div>
2241 </div>
2242 <hr>
2243 <div class="refsect2">
2244 <a name="g-idle-add-full"></a><h3>g_idle_add_full ()</h3>
2245 <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>,
2246                                                          <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>,
2247                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
2248                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
2249 <p>
2250 Adds a function to be called whenever there are no higher priority
2251 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
2252 removed from the list of event sources and will not be called again.
2253 </p>
2254 <p>
2255 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>
2256 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>. 
2257 You can do these steps manually if you need greater control.
2258 </p>
2259 <div class="variablelist"><table border="0">
2260 <col align="left" valign="top">
2261 <tbody>
2262 <tr>
2263 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
2264 <td>the priority of the idle source. Typically this will be in the
2265 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>
2266 </tr>
2267 <tr>
2268 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2269 <td>function to call</td>
2270 </tr>
2271 <tr>
2272 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2273 <td>data to pass to <em class="parameter"><code>function</code></em>
2274 </td>
2275 </tr>
2276 <tr>
2277 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
2278 <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>
2279 </td>
2280 </tr>
2281 <tr>
2282 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2283 <td>the ID (greater than 0) of the event source.
2284 Rename to: g_idle_add</td>
2285 </tr>
2286 </tbody>
2287 </table></div>
2288 </div>
2289 <hr>
2290 <div class="refsect2">
2291 <a name="g-idle-remove-by-data"></a><h3>g_idle_remove_by_data ()</h3>
2292 <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>
2293 <p>
2294 Removes the idle function with the given data.
2295 </p>
2296 <div class="variablelist"><table border="0">
2297 <col align="left" valign="top">
2298 <tbody>
2299 <tr>
2300 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2301 <td>the data for the idle source's callback.</td>
2302 </tr>
2303 <tr>
2304 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2305 <td>
2306 <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>
2307 </tr>
2308 </tbody>
2309 </table></div>
2310 </div>
2311 <hr>
2312 <div class="refsect2">
2313 <a name="GPid"></a><h3>GPid</h3>
2314 <pre class="programlisting">typedef int GPid;
2315 </pre>
2316 <p>
2317 A type which is used to hold a process identification.
2318 </p>
2319 <p>
2320 On UNIX, processes are identified by a process id (an integer),
2321 while Windows uses process handles (which are pointers).
2322 </p>
2323 <p>
2324 GPid is used in GLib only for descendant processes spawned with
2325 the g_spawn functions.
2326 </p>
2327 </div>
2328 <hr>
2329 <div class="refsect2">
2330 <a name="GChildWatchFunc"></a><h3>GChildWatchFunc ()</h3>
2331 <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>,
2332                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> status</code></em>,
2333                                                          <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>
2334 <p>
2335 The type of functions to be called when a child exists.
2336 </p>
2337 <div class="variablelist"><table border="0">
2338 <col align="left" valign="top">
2339 <tbody>
2340 <tr>
2341 <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td>
2342 <td>the process id of the child process</td>
2343 </tr>
2344 <tr>
2345 <td><p><span class="term"><em class="parameter"><code>status</code></em> :</span></p></td>
2346 <td>Status information about the child process,
2347 see waitpid(2) for more information about this field</td>
2348 </tr>
2349 <tr>
2350 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
2351 <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>
2352 </td>
2353 </tr>
2354 </tbody>
2355 </table></div>
2356 </div>
2357 <hr>
2358 <div class="refsect2">
2359 <a name="g-child-watch-source-new"></a><h3>g_child_watch_source_new ()</h3>
2360 <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>
2361 <p>
2362 Creates a new child_watch source.
2363 </p>
2364 <p>
2365 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>
2366 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
2367 executed.
2368 </p>
2369 <p>
2370 Note that child watch sources can only be used in conjunction with
2371 <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>
2372 flag is used.
2373 </p>
2374 <p>
2375 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
2376 (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
2377 source is still active. Typically, you will want to call
2378 <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.
2379 </p>
2380 <p>
2381 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 
2382 compatible with calling <code class="literal">waitpid(-1)</code> in 
2383 the application. Calling <code class="function">waitpid()</code> for individual pids will
2384 still work fine.
2385 </p>
2386 <div class="variablelist"><table border="0">
2387 <col align="left" valign="top">
2388 <tbody>
2389 <tr>
2390 <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td>
2391 <td>process to watch. On POSIX the pid of a child process. On
2392 Windows a handle for a process (which doesn't have to be a child).</td>
2393 </tr>
2394 <tr>
2395 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2396 <td>the newly-created child watch source</td>
2397 </tr>
2398 </tbody>
2399 </table></div>
2400 <p class="since">Since 2.4</p>
2401 </div>
2402 <hr>
2403 <div class="refsect2">
2404 <a name="g-child-watch-add"></a><h3>g_child_watch_add ()</h3>
2405 <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>,
2406                                                          <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>,
2407                                                          <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>
2408 <p>
2409 Sets a function to be called when the child indicated by <em class="parameter"><code>pid</code></em> 
2410 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>.
2411 </p>
2412 <p>
2413 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> 
2414 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 
2415 the spawn function for the child watching to work.
2416 </p>
2417 <p>
2418 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
2419 (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
2420 source is still active. Typically, you will want to call
2421 <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.
2422 </p>
2423 <p>
2424 GLib supports only a single callback per process id.
2425 </p>
2426 <p>
2427 This internally creates a main loop source using 
2428 <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 
2429 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 
2430 need greater control.
2431 </p>
2432 <div class="variablelist"><table border="0">
2433 <col align="left" valign="top">
2434 <tbody>
2435 <tr>
2436 <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td>
2437 <td>process id to watch. On POSIX the pid of a child process. On
2438 Windows a handle for a process (which doesn't have to be a child).</td>
2439 </tr>
2440 <tr>
2441 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2442 <td>function to call</td>
2443 </tr>
2444 <tr>
2445 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2446 <td>data to pass to <em class="parameter"><code>function</code></em>
2447 </td>
2448 </tr>
2449 <tr>
2450 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2451 <td>the ID (greater than 0) of the event source.</td>
2452 </tr>
2453 </tbody>
2454 </table></div>
2455 <p class="since">Since 2.4</p>
2456 </div>
2457 <hr>
2458 <div class="refsect2">
2459 <a name="g-child-watch-add-full"></a><h3>g_child_watch_add_full ()</h3>
2460 <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>,
2461                                                          <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>,
2462                                                          <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>,
2463                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
2464                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
2465 <p>
2466 Sets a function to be called when the child indicated by <em class="parameter"><code>pid</code></em> 
2467 exits, at the priority <em class="parameter"><code>priority</code></em>.
2468 </p>
2469 <p>
2470 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> 
2471 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 
2472 the spawn function for the child watching to work.
2473 </p>
2474 <p>
2475 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
2476 (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
2477 source is still active. Typically, you will want to call
2478 <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.
2479 </p>
2480 <p>
2481 GLib supports only a single callback per process id.
2482 </p>
2483 <p>
2484 This internally creates a main loop source using 
2485 <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 
2486 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 
2487 need greater control.
2488 </p>
2489 <div class="variablelist"><table border="0">
2490 <col align="left" valign="top">
2491 <tbody>
2492 <tr>
2493 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
2494 <td>the priority of the idle source. Typically this will be in the
2495 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>
2496 </tr>
2497 <tr>
2498 <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td>
2499 <td>process to watch. On POSIX the pid of a child process. On
2500 Windows a handle for a process (which doesn't have to be a child).</td>
2501 </tr>
2502 <tr>
2503 <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
2504 <td>function to call</td>
2505 </tr>
2506 <tr>
2507 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
2508 <td>data to pass to <em class="parameter"><code>function</code></em>
2509 </td>
2510 </tr>
2511 <tr>
2512 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
2513 <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>
2514 </td>
2515 </tr>
2516 <tr>
2517 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2518 <td>the ID (greater than 0) of the event source.
2519 Rename to: g_child_watch_add</td>
2520 </tr>
2521 </tbody>
2522 </table></div>
2523 <p class="since">Since 2.4</p>
2524 </div>
2525 <hr>
2526 <div class="refsect2">
2527 <a name="GPollFD"></a><h3>struct GPollFD</h3>
2528 <pre class="programlisting">struct GPollFD {
2529 #if defined (G_OS_WIN32) &amp;&amp; GLIB_SIZEOF_VOID_P == 8
2530   gint64 fd;
2531 #else
2532   gint          fd;
2533 #endif
2534   gushort       events;
2535   gushort       revents;
2536 };
2537 </pre>
2538 <p>
2539 Represents a file descriptor, which events to poll for, and which events
2540 occurred.
2541 </p>
2542 <div class="variablelist"><table border="0">
2543 <col align="left" valign="top">
2544 <tbody>
2545 <tr>
2546 <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>
2547 <td>the file descriptor to poll (or a <span class="type">HANDLE</span> on Win32)</td>
2548 </tr>
2549 <tr>
2550 <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>
2551 <td></td>
2552 </tr>
2553 <tr>
2554 <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>
2555 <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
2556 events should be polled for. Typically for reading from a file
2557 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
2558 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>
2559 </tr>
2560 <tr>
2561 <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>
2562 <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
2563 from the <code class="function">poll()</code> function to indicate which events occurred.</td>
2564 </tr>
2565 </tbody>
2566 </table></div>
2567 </div>
2568 <hr>
2569 <div class="refsect2">
2570 <a name="g-poll"></a><h3>g_poll ()</h3>
2571 <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>,
2572                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> nfds</code></em>,
2573                                                          <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>
2574 <p>
2575 Polls <em class="parameter"><code>fds</code></em>, as with the <code class="function">poll()</code> system call, but portably. (On
2576 systems that don't have <code class="function">poll()</code>, it is emulated using <code class="function">select()</code>.)
2577 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
2578 directly if you need to block until a file descriptor is ready, but
2579 don't want to run the full main loop.
2580 </p>
2581 <p>
2582 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
2583 descriptor to poll. The <code class="literal">fd</code> field indicates the file descriptor,
2584 and the <code class="literal">events</code> field indicates the events to poll for. On return,
2585 the <code class="literal">revents</code> fields will be filled with the events that actually
2586 occurred.
2587 </p>
2588 <p>
2589 On POSIX systems, the file descriptors in <em class="parameter"><code>fds</code></em> can be any sort of
2590 file descriptor, but the situation is much more complicated on
2591 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
2592 Windows, the easiest solution is to construct all of your
2593 <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>.
2594 </p>
2595 <div class="variablelist"><table border="0">
2596 <col align="left" valign="top">
2597 <tbody>
2598 <tr>
2599 <td><p><span class="term"><em class="parameter"><code>fds</code></em> :</span></p></td>
2600 <td>file descriptors to poll</td>
2601 </tr>
2602 <tr>
2603 <td><p><span class="term"><em class="parameter"><code>nfds</code></em> :</span></p></td>
2604 <td>the number of file descriptors in <em class="parameter"><code>fds</code></em>
2605 </td>
2606 </tr>
2607 <tr>
2608 <td><p><span class="term"><em class="parameter"><code>timeout</code></em> :</span></p></td>
2609 <td>amount of time to wait, in milliseconds, or -1 to wait forever</td>
2610 </tr>
2611 <tr>
2612 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2613 <td>the number of entries in <em class="parameter"><code>fds</code></em> whose <code class="literal">revents</code> fields
2614 were filled in, or 0 if the operation timed out, or -1 on error or
2615 if the call was interrupted.</td>
2616 </tr>
2617 </tbody>
2618 </table></div>
2619 <p class="since">Since 2.20</p>
2620 </div>
2621 <hr>
2622 <div class="refsect2">
2623 <a name="G-POLLFD-FORMAT:CAPS"></a><h3>G_POLLFD_FORMAT</h3>
2624 <pre class="programlisting">#define G_POLLFD_FORMAT "%#I64x"
2625 </pre>
2626 </div>
2627 <hr>
2628 <div class="refsect2">
2629 <a name="GSource"></a><h3>struct GSource</h3>
2630 <pre class="programlisting">struct GSource {
2631 };
2632 </pre>
2633 <p>
2634 The <span class="structname">GSource</span> struct is an opaque data type
2635 representing an event source.
2636 </p>
2637 </div>
2638 <hr>
2639 <div class="refsect2">
2640 <a name="GSourceDummyMarshal"></a><h3>GSourceDummyMarshal ()</h3>
2641 <pre class="programlisting"><span class="returnvalue">void</span>                (*GSourceDummyMarshal)              (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
2642 <p>
2643 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>,
2644 which cannot be used here for dependency reasons.
2645 </p>
2646 </div>
2647 <hr>
2648 <div class="refsect2">
2649 <a name="GSourceFuncs"></a><h3>struct GSourceFuncs</h3>
2650 <pre class="programlisting">struct GSourceFuncs {
2651   gboolean (*prepare)  (GSource    *source,
2652                         gint       *timeout_);
2653   gboolean (*check)    (GSource    *source);
2654   gboolean (*dispatch) (GSource    *source,
2655                         GSourceFunc callback,
2656                         gpointer    user_data);
2657   void     (*finalize) (GSource    *source); /* Can be NULL */
2658 };
2659 </pre>
2660 <p>
2661 The <span class="structname">GSourceFuncs</span> struct contains a table of
2662 functions used to handle event sources in a generic manner.
2663 </p>
2664 <p>
2665 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>
2666 to indicate that the source is always ready to be processed. The prepare
2667 function also returns a timeout value of 0 to ensure that the <code class="function">poll()</code> call
2668 doesn't block (since that would be time wasted which could have been spent
2669 running the idle function).
2670 </p>
2671 <p>
2672 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>
2673 if the timeout interval has expired. The prepare function also returns
2674 a timeout value to ensure that the <code class="function">poll()</code> call doesn't block too long
2675 and miss the next timeout.
2676 </p>
2677 <p>
2678 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>,
2679 since it must wait until <code class="function">poll()</code> has been called before it knows whether
2680 any events need to be processed. It sets the returned timeout to -1 to
2681 indicate that it doesn't mind how long the <code class="function">poll()</code> call blocks. In the
2682 check function, it tests the results of the <code class="function">poll()</code> call to see if the
2683 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.
2684 </p>
2685 <div class="variablelist"><table border="0">
2686 <col align="left" valign="top">
2687 <tbody>
2688 <tr>
2689 <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.prepare"></a>prepare</code></em> ()</span></p></td>
2690 <td>Called before all the file descriptors are polled. If the
2691 source can determine that it is ready here (without waiting for the
2692 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
2693 a <em class="parameter"><code>timeout_</code></em> value which should be the maximum timeout (in milliseconds)
2694 which should be passed to the <code class="function">poll()</code> call. The actual timeout used will
2695 be -1 if all sources returned -1, or it will be the minimum of all the
2696 <em class="parameter"><code>timeout_</code></em> values returned which were &gt;= 0.</td>
2697 </tr>
2698 <tr>
2699 <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.check"></a>check</code></em> ()</span></p></td>
2700 <td>Called after all the file descriptors are polled. The source
2701 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
2702 time may have passed since the previous prepare function was called,
2703 so the source should be checked again here.</td>
2704 </tr>
2705 <tr>
2706 <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.dispatch"></a>dispatch</code></em> ()</span></p></td>
2707 <td>Called to dispatch the event source, after it has returned
2708 <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>
2709 function is passed in a callback function and data. The callback
2710 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
2711 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
2712 callback function with <em class="parameter"><code>user_data</code></em> and whatever additional parameters
2713 are needed for this type of event source.</td>
2714 </tr>
2715 <tr>
2716 <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.finalize"></a>finalize</code></em> ()</span></p></td>
2717 <td>Called when the source is finalized.</td>
2718 </tr>
2719 </tbody>
2720 </table></div>
2721 </div>
2722 <hr>
2723 <div class="refsect2">
2724 <a name="GSourceCallbackFuncs"></a><h3>struct GSourceCallbackFuncs</h3>
2725 <pre class="programlisting">struct GSourceCallbackFuncs {
2726   void (*ref)   (gpointer     cb_data);
2727   void (*unref) (gpointer     cb_data);
2728   void (*get)   (gpointer     cb_data,
2729                  GSource     *source, 
2730                  GSourceFunc *func,
2731                  gpointer    *data);
2732 };
2733 </pre>
2734 <p>
2735 The <span class="structname">GSourceCallbackFuncs</span> struct contains
2736 functions for managing callback objects.
2737 </p>
2738 <div class="variablelist"><table border="0">
2739 <col align="left" valign="top">
2740 <tbody>
2741 <tr>
2742 <td><p><span class="term"><em class="structfield"><code><a name="GSourceCallbackFuncs.ref"></a>ref</code></em> ()</span></p></td>
2743 <td>Called when a reference is added to the callback object</td>
2744 </tr>
2745 <tr>
2746 <td><p><span class="term"><em class="structfield"><code><a name="GSourceCallbackFuncs.unref"></a>unref</code></em> ()</span></p></td>
2747 <td>Called when a reference to the callback object is dropped</td>
2748 </tr>
2749 <tr>
2750 <td><p><span class="term"><em class="structfield"><code><a name="GSourceCallbackFuncs.get"></a>get</code></em> ()</span></p></td>
2751 <td>Called to extract the callback function and data from the
2752 callback object.</td>
2753 </tr>
2754 </tbody>
2755 </table></div>
2756 </div>
2757 <hr>
2758 <div class="refsect2">
2759 <a name="g-source-new"></a><h3>g_source_new ()</h3>
2760 <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>,
2761                                                          <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>
2762 <p>
2763 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
2764 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
2765 additional data. The size passed in must be at least
2766 <code class="literal">sizeof (GSource)</code>.
2767 </p>
2768 <p>
2769 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>
2770 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
2771 executed.
2772 </p>
2773 <div class="variablelist"><table border="0">
2774 <col align="left" valign="top">
2775 <tbody>
2776 <tr>
2777 <td><p><span class="term"><em class="parameter"><code>source_funcs</code></em> :</span></p></td>
2778 <td>structure containing functions that implement
2779 the sources behavior.</td>
2780 </tr>
2781 <tr>
2782 <td><p><span class="term"><em class="parameter"><code>struct_size</code></em> :</span></p></td>
2783 <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>
2784 </tr>
2785 <tr>
2786 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2787 <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>
2788 </tr>
2789 </tbody>
2790 </table></div>
2791 </div>
2792 <hr>
2793 <div class="refsect2">
2794 <a name="g-source-ref"></a><h3>g_source_ref ()</h3>
2795 <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>
2796 <p>
2797 Increases the reference count on a source by one.
2798 </p>
2799 <div class="variablelist"><table border="0">
2800 <col align="left" valign="top">
2801 <tbody>
2802 <tr>
2803 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2804 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2805 </td>
2806 </tr>
2807 <tr>
2808 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2809 <td><em class="parameter"><code>source</code></em></td>
2810 </tr>
2811 </tbody>
2812 </table></div>
2813 </div>
2814 <hr>
2815 <div class="refsect2">
2816 <a name="g-source-unref"></a><h3>g_source_unref ()</h3>
2817 <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>
2818 <p>
2819 Decreases the reference count of a source by one. If the
2820 resulting reference count is zero the source and associated
2821 memory will be destroyed.
2822 </p>
2823 <div class="variablelist"><table border="0">
2824 <col align="left" valign="top">
2825 <tbody><tr>
2826 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2827 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2828 </td>
2829 </tr></tbody>
2830 </table></div>
2831 </div>
2832 <hr>
2833 <div class="refsect2">
2834 <a name="g-source-set-funcs"></a><h3>g_source_set_funcs ()</h3>
2835 <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>,
2836                                                          <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>
2837 <p>
2838 Sets the source functions (can be used to override 
2839 default implementations) of an unattached source.
2840 </p>
2841 <div class="variablelist"><table border="0">
2842 <col align="left" valign="top">
2843 <tbody>
2844 <tr>
2845 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2846 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2847 </td>
2848 </tr>
2849 <tr>
2850 <td><p><span class="term"><em class="parameter"><code>funcs</code></em> :</span></p></td>
2851 <td>the new <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a>
2852 </td>
2853 </tr>
2854 </tbody>
2855 </table></div>
2856 <p class="since">Since 2.12</p>
2857 </div>
2858 <hr>
2859 <div class="refsect2">
2860 <a name="g-source-attach"></a><h3>g_source_attach ()</h3>
2861 <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>,
2862                                                          <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>
2863 <p>
2864 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
2865 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>.
2866 </p>
2867 <div class="variablelist"><table border="0">
2868 <col align="left" valign="top">
2869 <tbody>
2870 <tr>
2871 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2872 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2873 </td>
2874 </tr>
2875 <tr>
2876 <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
2877 <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>
2878 </td>
2879 </tr>
2880 <tr>
2881 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
2882 <td>the ID (greater than 0) for the source within the
2883 <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>.</td>
2884 </tr>
2885 </tbody>
2886 </table></div>
2887 </div>
2888 <hr>
2889 <div class="refsect2">
2890 <a name="g-source-destroy"></a><h3>g_source_destroy ()</h3>
2891 <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>
2892 <p>
2893 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
2894 destroyed.  The source cannot be subsequently added to another
2895 context.
2896 </p>
2897 <div class="variablelist"><table border="0">
2898 <col align="left" valign="top">
2899 <tbody><tr>
2900 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
2901 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
2902 </td>
2903 </tr></tbody>
2904 </table></div>
2905 </div>
2906 <hr>
2907 <div class="refsect2">
2908 <a name="g-source-is-destroyed"></a><h3>g_source_is_destroyed ()</h3>
2909 <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>
2910 <p>
2911 Returns whether <em class="parameter"><code>source</code></em> has been destroyed.
2912 </p>
2913 <p>
2914 This is important when you operate upon your objects 
2915 from within idle handlers, but may have freed the object 
2916 before the dispatch of your idle handler.
2917 </p>
2918 <p>
2919 </p>
2920 <div class="informalexample">
2921   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
2922     <tbody>
2923       <tr>
2924         <td class="listing_lines" align="right"><pre>1
2925 2
2926 3
2927 4
2928 5
2929 6
2930 7
2931 8
2932 9
2933 10
2934 11
2935 12
2936 13
2937 14
2938 15
2939 16
2940 17
2941 18
2942 19
2943 20
2944 21
2945 22
2946 23
2947 24
2948 25
2949 26
2950 27
2951 28
2952 29</pre></td>
2953         <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="glib-Basic-Types.html#gboolean">gboolean</a> </span>
2954 <span class="function">idle_callback</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">gpointer</span><span class="normal"> data</span><span class="symbol">)</span>
2955 <span class="cbracket">{</span>
2956 <span class="normal">  </span><span class="usertype">SomeWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> data</span><span class="symbol">;</span>
2957 <span class="normal">   </span>
2958 <span class="normal">  </span><span class="function"><a href="http://developer.gnome.org/devel/gdk/gdk3-Threads.html#GDK-THREADS-ENTER:CAPS">GDK_THREADS_ENTER</a></span><span class="normal"> </span><span class="symbol">();</span>
2959 <span class="normal">  </span><span class="comment">/* do stuff with self */</span>
2960 <span class="normal">  self</span><span class="symbol">-&gt;</span><span class="normal">idle_id </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span>
2961 <span class="normal">  </span><span class="function"><a href="http://developer.gnome.org/devel/gdk/gdk3-Threads.html#GDK-THREADS-LEAVE:CAPS">GDK_THREADS_LEAVE</a></span><span class="normal"> </span><span class="symbol">();</span>
2962 <span class="normal">   </span>
2963 <span class="normal">  </span><span class="keyword">return</span><span class="normal"> <a href="glib-The-Main-Event-Loop.html#G-SOURCE-REMOVE:CAPS">G_SOURCE_REMOVE</a></span><span class="symbol">;</span>
2964 <span class="cbracket">}</span>
2965 <span class="normal"> </span>
2966 <span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span>
2967 <span class="function">some_widget_do_stuff_later</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">SomeWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self</span><span class="symbol">)</span>
2968 <span class="cbracket">{</span>
2969 <span class="normal">  self</span><span class="symbol">-&gt;</span><span class="normal">idle_id </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-idle-add">g_idle_add</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">idle_callback</span><span class="symbol">,</span><span class="normal"> self</span><span class="symbol">);</span>
2970 <span class="cbracket">}</span>
2971 <span class="normal"> </span>
2972 <span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span>
2973 <span class="function">some_widget_finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">GObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">object</span><span class="symbol">)</span>
2974 <span class="cbracket">{</span>
2975 <span class="normal">  </span><span class="usertype">SomeWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> </span><span class="function">SOME_WIDGET</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span>
2976 <span class="normal">   </span>
2977 <span class="normal">  </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">self</span><span class="symbol">-&gt;</span><span class="normal">idle_id</span><span class="symbol">)</span>
2978 <span class="normal">    </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-source-remove">g_source_remove</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">self</span><span class="symbol">-&gt;</span><span class="normal">idle_id</span><span class="symbol">);</span>
2979 <span class="normal">   </span>
2980 <span class="normal">  </span><span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#G-OBJECT-CLASS:CAPS">G_OBJECT_CLASS</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">parent_class</span><span class="symbol">)-&gt;</span><span class="function">finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span>
2981 <span class="cbracket">}</span></pre></td>
2982       </tr>
2983     </tbody>
2984   </table>
2985 </div>
2986
2987 <p>
2988 </p>
2989 <p>
2990 This will fail in a multi-threaded application if the 
2991 widget is destroyed before the idle handler fires due 
2992 to the use after free in the callback. A solution, to 
2993 this particular problem, is to check to if the source
2994 has already been destroy within the callback.
2995 </p>
2996 <p>
2997 </p>
2998 <div class="informalexample">
2999   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
3000     <tbody>
3001       <tr>
3002         <td class="listing_lines" align="right"><pre>1
3003 2
3004 3
3005 4
3006 5
3007 6
3008 7
3009 8
3010 9
3011 10
3012 11
3013 12
3014 13
3015 14</pre></td>
3016         <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="glib-Basic-Types.html#gboolean">gboolean</a> </span>
3017 <span class="function">idle_callback</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">gpointer</span><span class="normal"> data</span><span class="symbol">)</span>
3018 <span class="cbracket">{</span>
3019 <span class="normal">  </span><span class="usertype">SomeWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> data</span><span class="symbol">;</span>
3020 <span class="normal">  </span>
3021 <span class="normal">  </span><span class="function"><a href="http://developer.gnome.org/devel/gdk/gdk3-Threads.html#GDK-THREADS-ENTER:CAPS">GDK_THREADS_ENTER</a></span><span class="normal"> </span><span class="symbol">();</span>
3022 <span class="normal">  </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-source-is-destroyed">g_source_is_destroyed</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-current-source">g_main_current_source</a></span><span class="normal"> </span><span class="symbol">()))</span>
3023 <span class="normal">    </span><span class="cbracket">{</span>
3024 <span class="normal">      </span><span class="comment">/* do stuff with self */</span>
3025 <span class="normal">    </span><span class="cbracket">}</span>
3026 <span class="normal">  </span><span class="function"><a href="http://developer.gnome.org/devel/gdk/gdk3-Threads.html#GDK-THREADS-LEAVE:CAPS">GDK_THREADS_LEAVE</a></span><span class="normal"> </span><span class="symbol">();</span>
3027 <span class="normal">  </span>
3028 <span class="normal">  </span><span class="keyword">return</span><span class="normal"> <a href="glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">;</span>
3029 <span class="cbracket">}</span></pre></td>
3030       </tr>
3031     </tbody>
3032   </table>
3033 </div>
3034
3035 <p>
3036 </p>
3037 <div class="variablelist"><table border="0">
3038 <col align="left" valign="top">
3039 <tbody>
3040 <tr>
3041 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3042 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3043 </td>
3044 </tr>
3045 <tr>
3046 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3047 <td>
3048 <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>
3049 </tr>
3050 </tbody>
3051 </table></div>
3052 <p class="since">Since 2.12</p>
3053 </div>
3054 <hr>
3055 <div class="refsect2">
3056 <a name="g-source-set-priority"></a><h3>g_source_set_priority ()</h3>
3057 <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>,
3058                                                          <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>
3059 <p>
3060 Sets the priority of a source. While the main loop is being run, a
3061 source will be dispatched if it is ready to be dispatched and no
3062 sources at a higher (numerically smaller) priority are ready to be
3063 dispatched.
3064 </p>
3065 <div class="variablelist"><table border="0">
3066 <col align="left" valign="top">
3067 <tbody>
3068 <tr>
3069 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3070 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3071 </td>
3072 </tr>
3073 <tr>
3074 <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
3075 <td>the new priority.</td>
3076 </tr>
3077 </tbody>
3078 </table></div>
3079 </div>
3080 <hr>
3081 <div class="refsect2">
3082 <a name="g-source-get-priority"></a><h3>g_source_get_priority ()</h3>
3083 <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>
3084 <p>
3085 Gets the priority of a source.
3086 </p>
3087 <div class="variablelist"><table border="0">
3088 <col align="left" valign="top">
3089 <tbody>
3090 <tr>
3091 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3092 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3093 </td>
3094 </tr>
3095 <tr>
3096 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3097 <td>the priority of the source</td>
3098 </tr>
3099 </tbody>
3100 </table></div>
3101 </div>
3102 <hr>
3103 <div class="refsect2">
3104 <a name="g-source-set-can-recurse"></a><h3>g_source_set_can_recurse ()</h3>
3105 <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>,
3106                                                          <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>
3107 <p>
3108 Sets whether a source can be called recursively. If <em class="parameter"><code>can_recurse</code></em> is
3109 <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
3110 will be processed normally. Otherwise, all processing of this
3111 source is blocked until the dispatch function returns.
3112 </p>
3113 <div class="variablelist"><table border="0">
3114 <col align="left" valign="top">
3115 <tbody>
3116 <tr>
3117 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3118 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3119 </td>
3120 </tr>
3121 <tr>
3122 <td><p><span class="term"><em class="parameter"><code>can_recurse</code></em> :</span></p></td>
3123 <td>whether recursion is allowed for this source</td>
3124 </tr>
3125 </tbody>
3126 </table></div>
3127 </div>
3128 <hr>
3129 <div class="refsect2">
3130 <a name="g-source-get-can-recurse"></a><h3>g_source_get_can_recurse ()</h3>
3131 <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>
3132 <p>
3133 Checks whether a source is allowed to be called recursively.
3134 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>.
3135 </p>
3136 <div class="variablelist"><table border="0">
3137 <col align="left" valign="top">
3138 <tbody>
3139 <tr>
3140 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3141 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3142 </td>
3143 </tr>
3144 <tr>
3145 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3146 <td>whether recursion is allowed.</td>
3147 </tr>
3148 </tbody>
3149 </table></div>
3150 </div>
3151 <hr>
3152 <div class="refsect2">
3153 <a name="g-source-get-id"></a><h3>g_source_get_id ()</h3>
3154 <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>
3155 <p>
3156 Returns the numeric ID for a particular source. The ID of a source
3157 is a positive integer which is unique within a particular main loop 
3158 context. The reverse
3159 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>.
3160 </p>
3161 <div class="variablelist"><table border="0">
3162 <col align="left" valign="top">
3163 <tbody>
3164 <tr>
3165 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3166 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3167 </td>
3168 </tr>
3169 <tr>
3170 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3171 <td>the ID (greater than 0) for the source</td>
3172 </tr>
3173 </tbody>
3174 </table></div>
3175 </div>
3176 <hr>
3177 <div class="refsect2">
3178 <a name="g-source-get-name"></a><h3>g_source_get_name ()</h3>
3179 <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>
3180 <p>
3181 Gets a name for the source, used in debugging and profiling.
3182 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
3183 <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>.
3184 </p>
3185 <div class="variablelist"><table border="0">
3186 <col align="left" valign="top">
3187 <tbody>
3188 <tr>
3189 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3190 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3191 </td>
3192 </tr>
3193 <tr>
3194 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3195 <td>the name of the source</td>
3196 </tr>
3197 </tbody>
3198 </table></div>
3199 <p class="since">Since 2.26</p>
3200 </div>
3201 <hr>
3202 <div class="refsect2">
3203 <a name="g-source-set-name"></a><h3>g_source_set_name ()</h3>
3204 <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>,
3205                                                          <em class="parameter"><code>const <span class="type">char</span> *name</code></em>);</pre>
3206 <p>
3207 Sets a name for the source, used in debugging and profiling.
3208 The name defaults to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><span class="type">NULL</span></a>.
3209 </p>
3210 <p>
3211 The source name should describe in a human-readable way
3212 what the source does. For example, "X11 event queue"
3213 or "GTK+ repaint idle handler" or whatever it is.
3214 </p>
3215 <p>
3216 It is permitted to call this function multiple times, but is not
3217 recommended due to the potential performance impact.  For example,
3218 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> 
3219 to include details like the event type in the source name.
3220 </p>
3221 <div class="variablelist"><table border="0">
3222 <col align="left" valign="top">
3223 <tbody>
3224 <tr>
3225 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3226 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3227 </td>
3228 </tr>
3229 <tr>
3230 <td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
3231 <td>debug name for the source</td>
3232 </tr>
3233 </tbody>
3234 </table></div>
3235 <p class="since">Since 2.26</p>
3236 </div>
3237 <hr>
3238 <div class="refsect2">
3239 <a name="g-source-set-name-by-id"></a><h3>g_source_set_name_by_id ()</h3>
3240 <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>,
3241                                                          <em class="parameter"><code>const <span class="type">char</span> *name</code></em>);</pre>
3242 <p>
3243 Sets the name of a source using its ID.
3244 </p>
3245 <p>
3246 This is a convenience utility to set source names from the return
3247 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.
3248 </p>
3249 <div class="variablelist"><table border="0">
3250 <col align="left" valign="top">
3251 <tbody>
3252 <tr>
3253 <td><p><span class="term"><em class="parameter"><code>tag</code></em> :</span></p></td>
3254 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> ID</td>
3255 </tr>
3256 <tr>
3257 <td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
3258 <td>debug name for the source</td>
3259 </tr>
3260 </tbody>
3261 </table></div>
3262 <p class="since">Since 2.26</p>
3263 </div>
3264 <hr>
3265 <div class="refsect2">
3266 <a name="g-source-get-context"></a><h3>g_source_get_context ()</h3>
3267 <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>
3268 <p>
3269 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.
3270 Calling this function on a destroyed source is an error.
3271 </p>
3272 <div class="variablelist"><table border="0">
3273 <col align="left" valign="top">
3274 <tbody>
3275 <tr>
3276 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3277 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3278 </td>
3279 </tr>
3280 <tr>
3281 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3282 <td>the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> with which the
3283 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
3284 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>
3285 </td>
3286 </tr>
3287 </tbody>
3288 </table></div>
3289 </div>
3290 <hr>
3291 <div class="refsect2">
3292 <a name="g-source-set-callback"></a><h3>g_source_set_callback ()</h3>
3293 <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>,
3294                                                          <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>,
3295                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
3296                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
3297 <p>
3298 Sets the callback function for a source. The callback for a source is
3299 called from the source's dispatch function.
3300 </p>
3301 <p>
3302 The exact type of <em class="parameter"><code>func</code></em> depends on the type of source; ie. you
3303 should not count on <em class="parameter"><code>func</code></em> being called with <em class="parameter"><code>data</code></em> as its first
3304 parameter.
3305 </p>
3306 <p>
3307 Typically, you won't use this function. Instead use functions specific
3308 to the type of source you are using.
3309 </p>
3310 <div class="variablelist"><table border="0">
3311 <col align="left" valign="top">
3312 <tbody>
3313 <tr>
3314 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3315 <td>the source</td>
3316 </tr>
3317 <tr>
3318 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
3319 <td>a callback function</td>
3320 </tr>
3321 <tr>
3322 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
3323 <td>the data to pass to callback function</td>
3324 </tr>
3325 <tr>
3326 <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
3327 <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>
3328 </td>
3329 </tr>
3330 </tbody>
3331 </table></div>
3332 </div>
3333 <hr>
3334 <div class="refsect2">
3335 <a name="GSourceFunc"></a><h3>GSourceFunc ()</h3>
3336 <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>
3337 <p>
3338 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>,
3339 <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>.
3340 </p>
3341 <div class="variablelist"><table border="0">
3342 <col align="left" valign="top">
3343 <tbody>
3344 <tr>
3345 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
3346 <td>data passed to the function, set when the source was
3347 created with one of the above functions</td>
3348 </tr>
3349 <tr>
3350 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3351 <td>
3352 <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>
3353 </tr>
3354 </tbody>
3355 </table></div>
3356 </div>
3357 <hr>
3358 <div class="refsect2">
3359 <a name="g-source-set-callback-indirect"></a><h3>g_source_set_callback_indirect ()</h3>
3360 <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>,
3361                                                          <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>,
3362                                                          <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>
3363 <p>
3364 Sets the callback function storing the data as a refcounted callback
3365 "object". This is used internally. Note that calling 
3366 <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
3367 an initial reference count on <em class="parameter"><code>callback_data</code></em>, and thus
3368 <em class="parameter"><code>callback_funcs-&gt;unref</code></em> will eventually be called once more
3369 than <em class="parameter"><code>callback_funcs-&gt;ref</code></em>.
3370 </p>
3371 <div class="variablelist"><table border="0">
3372 <col align="left" valign="top">
3373 <tbody>
3374 <tr>
3375 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3376 <td>the source</td>
3377 </tr>
3378 <tr>
3379 <td><p><span class="term"><em class="parameter"><code>callback_data</code></em> :</span></p></td>
3380 <td>pointer to callback data "object"</td>
3381 </tr>
3382 <tr>
3383 <td><p><span class="term"><em class="parameter"><code>callback_funcs</code></em> :</span></p></td>
3384 <td>functions for reference counting <em class="parameter"><code>callback_data</code></em>
3385 and getting the callback and data</td>
3386 </tr>
3387 </tbody>
3388 </table></div>
3389 </div>
3390 <hr>
3391 <div class="refsect2">
3392 <a name="g-source-add-poll"></a><h3>g_source_add_poll ()</h3>
3393 <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>,
3394                                                          <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>
3395 <p>
3396 Adds a file descriptor to the set of file descriptors polled for
3397 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
3398 event source. The event source's check function will typically test
3399 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
3400 to be processed.
3401 </p>
3402 <div class="variablelist"><table border="0">
3403 <col align="left" valign="top">
3404 <tbody>
3405 <tr>
3406 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3407 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3408 </td>
3409 </tr>
3410 <tr>
3411 <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td>
3412 <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
3413 descriptor to watch.</td>
3414 </tr>
3415 </tbody>
3416 </table></div>
3417 </div>
3418 <hr>
3419 <div class="refsect2">
3420 <a name="g-source-remove-poll"></a><h3>g_source_remove_poll ()</h3>
3421 <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>,
3422                                                          <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>
3423 <p>
3424 Removes a file descriptor from the set of file descriptors polled for
3425 this source.
3426 </p>
3427 <div class="variablelist"><table border="0">
3428 <col align="left" valign="top">
3429 <tbody>
3430 <tr>
3431 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3432 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3433 </td>
3434 </tr>
3435 <tr>
3436 <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td>
3437 <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>
3438 </tr>
3439 </tbody>
3440 </table></div>
3441 </div>
3442 <hr>
3443 <div class="refsect2">
3444 <a name="g-source-add-child-source"></a><h3>g_source_add_child_source ()</h3>
3445 <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>,
3446                                                          <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>
3447 <p>
3448 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
3449 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
3450 with the same priority, when <em class="parameter"><code>child_source</code></em> is triggered, it will
3451 cause <em class="parameter"><code>source</code></em> to dispatch (in addition to calling its own
3452 callback), and when <em class="parameter"><code>source</code></em> is destroyed, it will destroy
3453 <em class="parameter"><code>child_source</code></em> as well. (<em class="parameter"><code>source</code></em> will also still be dispatched if
3454 its own prepare/check functions indicate that it is ready.)
3455 </p>
3456 <p>
3457 If you don't need <em class="parameter"><code>child_source</code></em> to do anything on its own when it
3458 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
3459 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).
3460 </p>
3461 <p>
3462 <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>
3463 is attached to it.
3464 </p>
3465 <div class="variablelist"><table border="0">
3466 <col align="left" valign="top">
3467 <tbody>
3468 <tr>
3469 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3470 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3471 </td>
3472 </tr>
3473 <tr>
3474 <td><p><span class="term"><em class="parameter"><code>child_source</code></em> :</span></p></td>
3475 <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>
3476 </tr>
3477 </tbody>
3478 </table></div>
3479 <p class="since">Since 2.28</p>
3480 </div>
3481 <hr>
3482 <div class="refsect2">
3483 <a name="g-source-remove-child-source"></a><h3>g_source_remove_child_source ()</h3>
3484 <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>,
3485                                                          <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>
3486 <p>
3487 Detaches <em class="parameter"><code>child_source</code></em> from <em class="parameter"><code>source</code></em> and destroys it.
3488 </p>
3489 <div class="variablelist"><table border="0">
3490 <col align="left" valign="top">
3491 <tbody>
3492 <tr>
3493 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3494 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3495 </td>
3496 </tr>
3497 <tr>
3498 <td><p><span class="term"><em class="parameter"><code>child_source</code></em> :</span></p></td>
3499 <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
3500 <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>
3501 </tr>
3502 </tbody>
3503 </table></div>
3504 <p class="since">Since 2.28</p>
3505 </div>
3506 <hr>
3507 <div class="refsect2">
3508 <a name="g-source-get-time"></a><h3>g_source_get_time ()</h3>
3509 <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>
3510 <p>
3511 Gets the time to be used when checking this source. The advantage of
3512 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
3513 that when checking multiple sources, GLib can cache a single value
3514 instead of having to repeatedly get the system monotonic time.
3515 </p>
3516 <p>
3517 The time here is the system monotonic time, if available, or some
3518 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>.
3519 </p>
3520 <div class="variablelist"><table border="0">
3521 <col align="left" valign="top">
3522 <tbody>
3523 <tr>
3524 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3525 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3526 </td>
3527 </tr>
3528 <tr>
3529 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3530 <td>the monotonic time in microseconds</td>
3531 </tr>
3532 </tbody>
3533 </table></div>
3534 <p class="since">Since 2.28</p>
3535 </div>
3536 <hr>
3537 <div class="refsect2">
3538 <a name="g-source-get-current-time"></a><h3>g_source_get_current_time ()</h3>
3539 <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>,
3540                                                          <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>
3541 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
3542 <h3 class="title">Warning</h3>
3543 <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>
3544 </div>
3545 <p>
3546 This function ignores <em class="parameter"><code>source</code></em> and is otherwise the same as
3547 <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>.
3548 </p>
3549 <div class="variablelist"><table border="0">
3550 <col align="left" valign="top">
3551 <tbody>
3552 <tr>
3553 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
3554 <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
3555 </td>
3556 </tr>
3557 <tr>
3558 <td><p><span class="term"><em class="parameter"><code>timeval</code></em> :</span></p></td>
3559 <td>
3560 <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>
3561 </tr>
3562 </tbody>
3563 </table></div>
3564 </div>
3565 <hr>
3566 <div class="refsect2">
3567 <a name="g-source-remove"></a><h3>g_source_remove ()</h3>
3568 <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>
3569 <p>
3570 Removes the source with the given id from the default main context. 
3571 The id of
3572 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
3573 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>,
3574 <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>,
3575 <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>.
3576 </p>
3577 <p>
3578 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
3579 added to a non-default main context.
3580 </p>
3581 <div class="variablelist"><table border="0">
3582 <col align="left" valign="top">
3583 <tbody>
3584 <tr>
3585 <td><p><span class="term"><em class="parameter"><code>tag</code></em> :</span></p></td>
3586 <td>the ID of the source to remove.</td>
3587 </tr>
3588 <tr>
3589 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3590 <td>
3591 <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>
3592 </tr>
3593 </tbody>
3594 </table></div>
3595 </div>
3596 <hr>
3597 <div class="refsect2">
3598 <a name="g-source-remove-by-funcs-user-data"></a><h3>g_source_remove_by_funcs_user_data ()</h3>
3599 <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>,
3600                                                          <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>
3601 <p>
3602 Removes a source from the default main loop context given the
3603 source functions and user data. If multiple sources exist with the
3604 same source functions and user data, only one will be destroyed.
3605 </p>
3606 <div class="variablelist"><table border="0">
3607 <col align="left" valign="top">
3608 <tbody>
3609 <tr>
3610 <td><p><span class="term"><em class="parameter"><code>funcs</code></em> :</span></p></td>
3611 <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>
3612 </td>
3613 </tr>
3614 <tr>
3615 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
3616 <td>the user data for the callback</td>
3617 </tr>
3618 <tr>
3619 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3620 <td>
3621 <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>
3622 </tr>
3623 </tbody>
3624 </table></div>
3625 </div>
3626 <hr>
3627 <div class="refsect2">
3628 <a name="g-source-remove-by-user-data"></a><h3>g_source_remove_by_user_data ()</h3>
3629 <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>
3630 <p>
3631 Removes a source from the default main loop context given the user
3632 data for the callback. If multiple sources exist with the same user
3633 data, only one will be destroyed.
3634 </p>
3635 <div class="variablelist"><table border="0">
3636 <col align="left" valign="top">
3637 <tbody>
3638 <tr>
3639 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
3640 <td>the user_data for the callback.</td>
3641 </tr>
3642 <tr>
3643 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
3644 <td>
3645 <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>
3646 </tr>
3647 </tbody>
3648 </table></div>
3649 </div>
3650 </div>
3651 </div>
3652 <div class="footer">
3653 <hr>
3654           Generated by GTK-Doc V1.18</div>
3655 </body>
3656 </html>