| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>The Main Event Loop</title> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> |
| <link rel="home" href="index.html" title="GLib Reference Manual"> |
| <link rel="up" href="glib-core.html" title="GLib Core Application Support"> |
| <link rel="prev" href="glib-core.html" title="GLib Core Application Support"> |
| <link rel="next" href="glib-Threads.html" title="Threads"> |
| <meta name="generator" content="GTK-Doc V1.14 (XML mode)"> |
| <link rel="stylesheet" href="style.css" type="text/css"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"> |
| <tr valign="middle"> |
| <td><a accesskey="p" href="glib-core.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> |
| <td><a accesskey="u" href="glib-core.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> |
| <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> |
| <th width="100%" align="center">GLib Reference Manual</th> |
| <td><a accesskey="n" href="glib-Threads.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> |
| </tr> |
| <tr><td colspan="5" class="shortcuts"> |
| <a href="#glib-The-Main-Event-Loop.synopsis" class="shortcut">Top</a> |
| | |
| <a href="#glib-The-Main-Event-Loop.description" class="shortcut">Description</a> |
| </td></tr> |
| </table> |
| <div class="refentry" title="The Main Event Loop"> |
| <a name="glib-The-Main-Event-Loop"></a><div class="titlepage"></div> |
| <div class="refnamediv"><table width="100%"><tr> |
| <td valign="top"> |
| <h2><span class="refentrytitle"><a name="glib-The-Main-Event-Loop.top_of_page"></a>The Main Event Loop</span></h2> |
| <p>The Main Event Loop — manages all available sources of events</p> |
| </td> |
| <td valign="top" align="right"></td> |
| </tr></table></div> |
| <div class="refsynopsisdiv" title="Synopsis"> |
| <a name="glib-The-Main-Event-Loop.synopsis"></a><h2>Synopsis</h2> |
| <pre class="synopsis"> |
| #include <glib.h> |
| |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop">GMainLoop</a>; |
| <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>, |
| <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>); |
| <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>); |
| <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>); |
| <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>); |
| <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>); |
| <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>); |
| <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>); |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#g-main-new" title="g_main_new()">g_main_new</a> (is_running) |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#g-main-destroy" title="g_main_destroy()">g_main_destroy</a> (loop) |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#g-main-run" title="g_main_run()">g_main_run</a> (loop) |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#g-main-quit" title="g_main_quit()">g_main_quit</a> (loop) |
| #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) |
| |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH:CAPS" title="G_PRIORITY_HIGH">G_PRIORITY_HIGH</a> |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT">G_PRIORITY_DEFAULT</a> |
| #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> |
| #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> |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-LOW:CAPS" title="G_PRIORITY_LOW">G_PRIORITY_LOW</a> |
| |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext">GMainContext</a>; |
| <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>); |
| <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>); |
| <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>); |
| <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>); |
| <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>, |
| <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>); |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#g-main-iteration" title="g_main_iteration()">g_main_iteration</a> (may_block) |
| <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>); |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#g-main-pending" title="g_main_pending">g_main_pending</a> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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>, |
| <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>); |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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> |
| (<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>, |
| <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>); |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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> |
| (<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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>, |
| <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>); |
| <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>); |
| <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>); |
| <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>); |
| <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>); |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Threads.html#GCond" title="GCond"><span class="type">GCond</span></a> *cond</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Threads.html#GMutex" title="GMutex"><span class="type">GMutex</span></a> *mutex</code></em>); |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *priority</code></em>); |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *timeout_</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>, |
| <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>); |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>, |
| <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>); |
| <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>); |
| <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>, |
| <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>); |
| <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>); |
| <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="GPollFD"><span class="type">GPollFD</span></a> *ufds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> nfsd</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> timeout_</code></em>); |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>); |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>); |
| <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>); |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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>); |
| #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) |
| |
| <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>); |
| <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>); |
| <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>); |
| |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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>); |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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>); |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>); |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>); |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>); |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>); |
| |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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>); |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>); |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>); |
| <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>); |
| |
| typedef <a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid">GPid</a>; |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> status</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>); |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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>); |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>); |
| <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>, |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>); |
| |
| <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD">GPollFD</a>; |
| <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="GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> nfds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> timeout</code></em>); |
| #define <a class="link" href="glib-The-Main-Event-Loop.html#G-POLLFD-FORMAT:CAPS" title="G_POLLFD_FORMAT">G_POLLFD_FORMAT</a> |
| |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource">GSource</a>; |
| <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>); |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="GSourceFuncs">GSourceFuncs</a>; |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSourceCallbackFuncs" title="GSourceCallbackFuncs">GSourceCallbackFuncs</a>; |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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="GSourceFuncs"><span class="type">GSourceFuncs</span></a> *source_funcs</code></em>, |
| <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>); |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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="GSource"><span class="type">GSource</span></a> *source</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <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>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> priority</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <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>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>); |
| <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> data</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceCallbackFuncs" title="GSourceCallbackFuncs"><span class="type">GSourceCallbackFuncs</span></a> *callback_funcs</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>); |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="GTimeVal"><span class="type">GTimeVal</span></a> *timeval</code></em>); |
| <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>); |
| <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="GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>, |
| <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>); |
| <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>); |
| </pre> |
| </div> |
| <div class="refsect1" title="Description"> |
| <a name="glib-The-Main-Event-Loop.description"></a><h2>Description</h2> |
| <p> |
| The main event loop manages all the available sources of events for |
| GLib and GTK+ applications. These events can come from any number of |
| different types of sources such as file descriptors (plain files, |
| pipes or sockets) and timeouts. New types of event sources can also |
| 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>. |
| </p> |
| <p> |
| To allow multiple independent sets of sources to be handled in |
| 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>. |
| A <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> can only be running in a single thread, but |
| sources can be added to it and removed from it from other threads. |
| </p> |
| <p> |
| Each event source is assigned a priority. The 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>, is 0. Values less than 0 denote higher |
| priorities. Values greater than 0 denote lower priorities. Events |
| from high priority sources are always processed before events from |
| lower priority sources. |
| </p> |
| <p> |
| Idle functions can also be added, and assigned a priority. These will |
| be run whenever no events with a higher priority are ready to be |
| processed. |
| </p> |
| <p> |
| 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 <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> |
| is 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, |
| <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 |
| each of the event sources and dispatches them. Finally, the |
| processing of 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 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. |
| </p> |
| <p> |
| 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. |
| This is often used in GTK+ applications when showing modal dialog |
| boxes. Note that event sources are associated with a particular |
| <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 |
| loops associated with that <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>. |
| </p> |
| <p> |
| GTK+ contains wrappers of some of these functions, e.g. <a href="http://library.gnome.org/devel/gtk/unstable/gtk-General.html#gtk-main"><code class="function">gtk_main()</code></a>, |
| <a href="http://library.gnome.org/devel/gtk/unstable/gtk-General.html#gtk-main-quit"><code class="function">gtk_main_quit()</code></a> and <a href="http://library.gnome.org/devel/gtk/unstable/gtk-General.html#gtk-events-pending"><code class="function">gtk_events_pending()</code></a>. |
| </p> |
| <div class="refsect2" title="Creating new sources types"> |
| <a name="id524581"></a><h3>Creating new sources types</h3> |
| <p> |
| One of the unusual features of the GTK+ main loop functionality |
| is that new types of event source can be created and used in |
| addition to the builtin type of event source. A new event source |
| type is used for handling GDK events. A new source type is |
| created by <em class="firstterm">deriving</em> from the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| structure. The derived type of source is represented by a |
| structure that has the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> structure as a first element, |
| and other elements specific to the new source type. To create |
| an instance of the new source type, 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 a table of functions. |
| These <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="GSourceFuncs"><span class="type">GSourceFuncs</span></a> determine the behavior of the new source |
| types. |
| </p> |
| <p> |
| New source types basically interact with the main context |
| in two ways. Their prepare function in <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="GSourceFuncs"><span class="type">GSourceFuncs</span></a> can set |
| a timeout to determine the maximum amount of time that the |
| main loop will sleep before checking the source again. In |
| addition, or as well, the source can add file descriptors to |
| the set that the main context checks using <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> |
| </div> |
| <hr> |
| <div class="refsect2" title="Customizing the main loop iteration"> |
| <a name="id524656"></a><h3>Customizing the main loop iteration</h3> |
| <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 |
| <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 |
| of exactly how the details of the main loop work is desired, |
| for 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. In such cases, you can call the component functions |
| of <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 <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>, |
| <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> |
| <p> |
| The operation of these functions can best be seen in terms |
| 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> |
| <div class="figure"> |
| <a name="mainloop-states"></a><p class="title"><b>Figure 1. States of a Main Context</b></p> |
| <div class="figure-contents"><div><img src="mainloop-states.gif" alt="States of a Main Context"></div></div> |
| </div> |
| <br class="figure-break"> |
| </div> |
| </div> |
| <div class="refsect1" title="Details"> |
| <a name="glib-The-Main-Event-Loop.details"></a><h2>Details</h2> |
| <div class="refsect2" title="GMainLoop"> |
| <a name="GMainLoop"></a><h3>GMainLoop</h3> |
| <pre class="programlisting">typedef struct _GMainLoop GMainLoop;</pre> |
| <p> |
| The <span class="structname">GMainLoop</span> struct is an opaque data type |
| representing the main event loop of a GLib or GTK+ application. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_loop_new ()"> |
| <a name="g-main-loop-new"></a><h3>g_main_loop_new ()</h3> |
| <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>, |
| <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> |
| <p> |
| Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> structure. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <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). |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>is_running</code></em> :</span></p></td> |
| <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 |
| 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 |
| <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> anyway. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_loop_ref ()"> |
| <a name="g-main-loop-ref"></a><h3>g_main_loop_ref ()</h3> |
| <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> |
| <p> |
| 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. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <em class="parameter"><code>loop</code></em> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_loop_unref ()"> |
| <a name="g-main-loop-unref"></a><h3>g_main_loop_unref ()</h3> |
| <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> |
| <p> |
| 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 |
| the result is zero, free the loop and free all associated memory. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_loop_run ()"> |
| <a name="g-main-loop-run"></a><h3>g_main_loop_run ()</h3> |
| <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> |
| <p> |
| 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. |
| 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>, |
| it will process events from the loop, otherwise it will |
| simply wait. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_loop_quit ()"> |
| <a name="g-main-loop-quit"></a><h3>g_main_loop_quit ()</h3> |
| <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> |
| <p> |
| 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> |
| for the loop will return. |
| </p> |
| <p> |
| Note that sources that have already been dispatched when |
| <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. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_loop_is_running ()"> |
| <a name="g-main-loop-is-running"></a><h3>g_main_loop_is_running ()</h3> |
| <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> |
| <p> |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_loop_get_context ()"> |
| <a name="g-main-loop-get-context"></a><h3>g_main_loop_get_context ()</h3> |
| <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> |
| <p> |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <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> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_new()"> |
| <a name="g-main-new"></a><h3>g_main_new()</h3> |
| <pre class="programlisting">#define g_main_new(is_running)</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <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> |
| </div> |
| <p> |
| Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> for the default main loop. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>is_running</code></em> :</span></p></td> |
| <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 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 to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> anyway. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td>a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_destroy()"> |
| <a name="g-main-destroy"></a><h3>g_main_destroy()</h3> |
| <pre class="programlisting">#define g_main_destroy(loop)</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <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> |
| </div> |
| <p> |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_run()"> |
| <a name="g-main-run"></a><h3>g_main_run()</h3> |
| <pre class="programlisting">#define g_main_run(loop)</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <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> |
| </div> |
| <p> |
| Runs a main loop until it stops running. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_quit()"> |
| <a name="g-main-quit"></a><h3>g_main_quit()</h3> |
| <pre class="programlisting">#define g_main_quit(loop)</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <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> |
| </div> |
| <p> |
| Stops the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. 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. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_is_running()"> |
| <a name="g-main-is-running"></a><h3>g_main_is_running()</h3> |
| <pre class="programlisting">#define g_main_is_running(loop)</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <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> |
| </div> |
| <p> |
| Checks if the main loop is running. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>loop</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> |
| <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> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_PRIORITY_HIGH"> |
| <a name="G-PRIORITY-HIGH:CAPS"></a><h3>G_PRIORITY_HIGH</h3> |
| <pre class="programlisting">#define G_PRIORITY_HIGH -100 |
| </pre> |
| <p> |
| Use this for high priority event sources. |
| It is not used within GLib or GTK+. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_PRIORITY_DEFAULT"> |
| <a name="G-PRIORITY-DEFAULT:CAPS"></a><h3>G_PRIORITY_DEFAULT</h3> |
| <pre class="programlisting">#define G_PRIORITY_DEFAULT 0 |
| </pre> |
| <p> |
| Use this for default priority event sources. |
| In GLib this priority is used when adding timeout functions 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 from the X server. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_PRIORITY_HIGH_IDLE"> |
| <a name="G-PRIORITY-HIGH-IDLE:CAPS"></a><h3>G_PRIORITY_HIGH_IDLE</h3> |
| <pre class="programlisting">#define G_PRIORITY_HIGH_IDLE 100 |
| </pre> |
| <p> |
| Use this for high priority idle functions. |
| 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, 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 done to |
| ensure that any pending resizes are processed before any pending redraws, |
| so that widgets are not redrawn twice unnecessarily.) |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_PRIORITY_DEFAULT_IDLE"> |
| <a name="G-PRIORITY-DEFAULT-IDLE:CAPS"></a><h3>G_PRIORITY_DEFAULT_IDLE</h3> |
| <pre class="programlisting">#define G_PRIORITY_DEFAULT_IDLE 200 |
| </pre> |
| <p> |
| Use this for default priority idle functions. |
| In GLib this priority is used when adding idle functions with <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>. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_PRIORITY_LOW"> |
| <a name="G-PRIORITY-LOW:CAPS"></a><h3>G_PRIORITY_LOW</h3> |
| <pre class="programlisting">#define G_PRIORITY_LOW 300 |
| </pre> |
| <p> |
| Use this for very low priority background tasks. |
| It is not used within GLib or GTK+. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GMainContext"> |
| <a name="GMainContext"></a><h3>GMainContext</h3> |
| <pre class="programlisting">typedef struct _GMainContext GMainContext;</pre> |
| <p> |
| The <span class="structname">GMainContext</span> struct is an opaque data type |
| representing a set of sources to be handled in a main loop. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_new ()"> |
| <a name="g-main-context-new"></a><h3>g_main_context_new ()</h3> |
| <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> |
| <p> |
| Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> structure. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the new <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_ref ()"> |
| <a name="g-main-context-ref"></a><h3>g_main_context_ref ()</h3> |
| <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> |
| <p> |
| 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. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the <em class="parameter"><code>context</code></em> that was passed in (since 2.6) |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_unref ()"> |
| <a name="g-main-context-unref"></a><h3>g_main_context_unref ()</h3> |
| <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> |
| <p> |
| 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 |
| the result is zero, free the context and free all associated memory. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_default ()"> |
| <a name="g-main-context-default"></a><h3>g_main_context_default ()</h3> |
| <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> |
| <p> |
| Returns the global default main context. This is the main context |
| used for main loop functions when a main loop is not explicitly |
| specified, and corresponds to the "main" main loop. See also |
| <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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the global default main context. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_iteration ()"> |
| <a name="g-main-context-iteration"></a><h3>g_main_context_iteration ()</h3> |
| <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>, |
| <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> |
| <p> |
| Runs a single iteration for the given main loop. This involves |
| checking to see if any event sources are ready to be processed, |
| 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 |
| for a source to become ready, then dispatching the highest priority |
| 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> |
| sources are not waited to become ready, only those highest priority |
| events sources will be dispatched (if any), that are ready at this |
| given moment without further waiting. |
| </p> |
| <p> |
| 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 |
| <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 |
| be interrupted for other reasons than an event source becoming ready. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <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) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>may_block</code></em> :</span></p></td> |
| <td>whether the call may block. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if events were dispatched. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_iteration()"> |
| <a name="g-main-iteration"></a><h3>g_main_iteration()</h3> |
| <pre class="programlisting">#define g_main_iteration(may_block)</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <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> |
| </div> |
| <p> |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>may_block</code></em> :</span></p></td> |
| <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 source |
| becomes ready. It will return after an event source has been 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 source is ready to be |
| processed. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> |
| <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if more events are pending. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_pending ()"> |
| <a name="g-main-context-pending"></a><h3>g_main_context_pending ()</h3> |
| <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> |
| <p> |
| Checks if any sources have pending events for the given context. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <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) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if events are pending. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_pending"> |
| <a name="g-main-pending"></a><h3>g_main_pending</h3> |
| <pre class="programlisting">#define g_main_pending()</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <p><code class="literal">g_main_pending</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-pending" title="g_main_context_pending ()"><code class="function">g_main_context_pending()</code></a> instead.</p> |
| </div> |
| <p> |
| 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> |
| (i.e. ready to be processed). |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> |
| <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if any events are pending. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_find_source_by_id ()"> |
| <a name="g-main-context-find-source-by-id"></a><h3>g_main_context_find_source_by_id ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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>, |
| <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> |
| <p> |
| Finds a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> given a pair of context and ID. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <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) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source_id</code></em> :</span></p></td> |
| <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> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_find_source_by_user_data ()"> |
| <a name="g-main-context-find-source-by-user-data"></a><h3>g_main_context_find_source_by_user_data ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="returnvalue">GSource</span></a> * g_main_context_find_source_by_user_data |
| (<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>, |
| <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> |
| <p> |
| Finds a source with the given user data for the callback. If |
| multiple sources exist with the same user data, the first |
| one found will be returned. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td> |
| <td>the user_data for the callback. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <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> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_find_source_by_funcs_user_data ()"> |
| <a name="g-main-context-find-source-by-funcs-user-data"></a><h3>g_main_context_find_source_by_funcs_user_data ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="returnvalue">GSource</span></a> * g_main_context_find_source_by_funcs_user_data |
| (<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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>, |
| <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> |
| <p> |
| Finds a source with the given source functions and user data. If |
| multiple sources exist with the same source function and user data, |
| the first one found will be returned. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <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). |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>funcs</code></em> :</span></p></td> |
| <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> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td> |
| <td>the user data from the callback. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <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> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_wakeup ()"> |
| <a name="g-main-context-wakeup"></a><h3>g_main_context_wakeup ()</h3> |
| <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> |
| <p> |
| If <em class="parameter"><code>context</code></em> is currently waiting in a <code class="function">poll()</code>, interrupt |
| the <code class="function">poll()</code>, and continue the iteration process. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_acquire ()"> |
| <a name="g-main-context-acquire"></a><h3>g_main_context_acquire ()</h3> |
| <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> |
| <p> |
| Tries to become the owner of the specified context. |
| If some other thread is the owner of the context, |
| returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> immediately. Ownership is properly |
| recursive: the owner can require ownership again |
| 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> |
| 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>. |
| </p> |
| <p> |
| You must be the owner of a context before you |
| 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>, |
| <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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the operation succeeded, and |
| this thread is now the owner of <em class="parameter"><code>context</code></em>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_release ()"> |
| <a name="g-main-context-release"></a><h3>g_main_context_release ()</h3> |
| <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> |
| <p> |
| Releases ownership of a context previously acquired by this thread |
| 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 |
| 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> |
| is called as many times as it was acquired. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_is_owner ()"> |
| <a name="g-main-context-is-owner"></a><h3>g_main_context_is_owner ()</h3> |
| <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> |
| <p> |
| Determines whether this thread holds the (recursive) |
| ownership of this <span class="type">GMaincontext</span>. This is useful to |
| know before waiting on another thread that may be |
| blocking to get ownership of <em class="parameter"><code>context</code></em>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.10</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_wait ()"> |
| <a name="g-main-context-wait"></a><h3>g_main_context_wait ()</h3> |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Threads.html#GCond" title="GCond"><span class="type">GCond</span></a> *cond</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Threads.html#GMutex" title="GMutex"><span class="type">GMutex</span></a> *mutex</code></em>);</pre> |
| <p> |
| Tries to become the owner of the specified context, |
| 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 |
| is the owner, atomically drop <em class="parameter"><code>mutex</code></em> and wait on <em class="parameter"><code>cond</code></em> until |
| that owner releases ownership or until <em class="parameter"><code>cond</code></em> is signaled, then |
| try again (once) to become the owner. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cond</code></em> :</span></p></td> |
| <td>a condition variable |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>mutex</code></em> :</span></p></td> |
| <td>a mutex, currently held |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the operation succeeded, and |
| this thread is now the owner of <em class="parameter"><code>context</code></em>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_prepare ()"> |
| <a name="g-main-context-prepare"></a><h3>g_main_context_prepare ()</h3> |
| <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>, |
| <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> |
| <p> |
| Prepares to poll sources within a main loop. The resulting information |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td> |
| <td>location to store priority of highest priority |
| source already ready. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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 |
| prior to polling. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_query ()"> |
| <a name="g-main-context-query"></a><h3>g_main_context_query ()</h3> |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *timeout_</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>, |
| <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> |
| <p> |
| Determines information necessary to poll this main loop. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>max_priority</code></em> :</span></p></td> |
| <td>maximum priority source to check |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>timeout_</code></em> :</span></p></td> |
| <td>location to store timeout to be used in polling |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fds</code></em> :</span></p></td> |
| <td>location to store <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> records that need to be polled. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n_fds</code></em> :</span></p></td> |
| <td>length of <em class="parameter"><code>fds</code></em>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the number of records actually stored in <em class="parameter"><code>fds</code></em>, |
| or, if more than <em class="parameter"><code>n_fds</code></em> records need to be stored, the number |
| of records that need to be stored. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_check ()"> |
| <a name="g-main-context-check"></a><h3>g_main_context_check ()</h3> |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>, |
| <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> |
| <p> |
| Passes the results of polling back to the main loop. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>max_priority</code></em> :</span></p></td> |
| <td>the maximum numerical priority of sources to check |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fds</code></em> :</span></p></td> |
| <td>array of <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a>'s that was passed to 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> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n_fds</code></em> :</span></p></td> |
| <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> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_dispatch ()"> |
| <a name="g-main-context-dispatch"></a><h3>g_main_context_dispatch ()</h3> |
| <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> |
| <p> |
| Dispatches all pending sources. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_set_poll_func ()"> |
| <a name="g-main-context-set-poll-func"></a><h3>g_main_context_set_poll_func ()</h3> |
| <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>, |
| <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> |
| <p> |
| Sets the function to use to handle polling of file descriptors. It |
| will be used instead of the <code class="function">poll()</code> system call |
| (or GLib's replacement function, which is used where |
| <code class="function">poll()</code> isn't available). |
| </p> |
| <p> |
| This function could possibly be used to integrate the GLib event |
| loop with an external event loop. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td> |
| <td>the function to call to poll all file descriptors |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_get_poll_func ()"> |
| <a name="g-main-context-get-poll-func"></a><h3>g_main_context_get_poll_func ()</h3> |
| <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> |
| <p> |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the poll function |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="GPollFunc ()"> |
| <a name="GPollFunc"></a><h3>GPollFunc ()</h3> |
| <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="GPollFD"><span class="type">GPollFD</span></a> *ufds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> nfsd</code></em>, |
| <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> |
| <p> |
| 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>. |
| The semantics of the function should match those of the |
| <code class="function"><code class="function">poll()</code></code> system call. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>ufds</code></em> :</span></p></td> |
| <td>an array of <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> elements. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>nfsd</code></em> :</span></p></td> |
| <td>the number of elements in <em class="parameter"><code>ufds</code></em>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>timeout_</code></em> :</span></p></td> |
| <td>the maximum time to wait for an event of the file descriptors. |
| A negative value indicates an infinite timeout. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td>the number of <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> elements which have events or errors reported, |
| or -1 if an error occurred. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_add_poll ()"> |
| <a name="g-main-context-add-poll"></a><h3>g_main_context_add_poll ()</h3> |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>, |
| <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> |
| <p> |
| Adds a file descriptor to the set of file descriptors polled for |
| this context. This will very seldomly be used directly. Instead |
| 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. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <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) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> structure holding information about a file |
| descriptor to watch. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td> |
| <td>the priority for this file descriptor which should be |
| 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 |
| file descriptor is polled whenever the results may be needed. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_remove_poll ()"> |
| <a name="g-main-context-remove-poll"></a><h3>g_main_context_remove_poll ()</h3> |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);</pre> |
| <p> |
| Removes file descriptor from the set of file descriptors to be |
| polled for a particular context. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="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> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_depth ()"> |
| <a name="g-main-depth"></a><h3>g_main_depth ()</h3> |
| <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> |
| <p> |
| Returns the depth of the stack of calls to |
| <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. |
| That is, when called from the toplevel, it gives 0. When |
| 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> |
| (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 |
| a callback to a recursive call to <code class="function">g_main_context_iterate()</code>, |
| it returns 2. And so forth. |
| </p> |
| <p> |
| This function is useful in a situation like the following: |
| Imagine an extremely simple "garbage collected" system. |
| </p> |
| <p> |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19 |
| 20 |
| 21 |
| 22 |
| 23 |
| 24 |
| 25 |
| 26 |
| 27</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> </span><span class="symbol">*</span><span class="normal">free_list</span><span class="symbol">;</span> |
| |
| <span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span> |
| <span class="function">allocate_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gsize">gsize</a> size</span><span class="symbol">)</span> |
| <span class="cbracket">{</span><span class="normal"> </span> |
| <span class="normal"> gpointer 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> |
| <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> |
| <span class="normal"> </span><span class="keyword">return</span><span class="normal"> result</span><span class="symbol">;</span> |
| <span class="cbracket">}</span> |
| |
| <span class="type">void</span> |
| <span class="function">free_allocated_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> </span><span class="symbol">*</span><span class="normal">l</span><span class="symbol">;</span> |
| <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">-></span><span class="normal">next</span><span class="symbol">);</span> |
| <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">-></span><span class="normal">data</span><span class="symbol">);</span> |
| <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> |
| <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> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| |
| <span class="symbol">[...]</span> |
| |
| <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> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <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> |
| <span class="normal"> </span><span class="function">free_allocated_memory</span><span class="symbol">();</span> |
| <span class="normal"> </span><span class="cbracket">}</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p> |
| </p> |
| <p> |
| This works from an application, however, if you want to do the same |
| thing from a library, it gets more difficult, since you no longer |
| control the main loop. You might think you can simply use an idle |
| function to make the call to <code class="function">free_allocated_memory()</code>, but that |
| doesn't work, since the idle function could be called from a |
| 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> |
| </p> |
| <p> |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19 |
| 20 |
| 21 |
| 22 |
| 23 |
| 24 |
| 25 |
| 26 |
| 27 |
| 28 |
| 29 |
| 30</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span> |
| <span class="function">allocate_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gsize">gsize</a> size</span><span class="symbol">)</span> |
| <span class="cbracket">{</span><span class="normal"> </span> |
| <span class="normal"> FreeListBlock </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> |
| <span class="normal"> block</span><span class="symbol">-></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> |
| <span class="normal"> block</span><span class="symbol">-></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> |
| <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> |
| <span class="normal"> </span><span class="keyword">return</span><span class="normal"> block</span><span class="symbol">-></span><span class="normal">mem</span><span class="symbol">;</span> |
| <span class="cbracket">}</span> |
| |
| <span class="type">void</span> |
| <span class="function">free_allocated_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> </span><span class="symbol">*</span><span class="normal">l</span><span class="symbol">;</span> |
| <span class="normal"> </span> |
| <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> |
| <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> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <span class="normal"> <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> </span><span class="symbol">*</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> l</span><span class="symbol">-></span><span class="normal">next</span><span class="symbol">;</span> |
| <span class="normal"> FreeListBlock </span><span class="symbol">*</span><span class="normal">block </span><span class="symbol">=</span><span class="normal"> l</span><span class="symbol">-></span><span class="normal">data</span><span class="symbol">;</span> |
| <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">-></span><span class="normal">depth </span><span class="symbol">></span><span class="normal"> depth</span><span class="symbol">)</span> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <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><span class="normal">mem</span><span class="symbol">);</span> |
| <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> |
| <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> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| <span class="normal"> </span> |
| <span class="normal"> l </span><span class="symbol">=</span><span class="normal"> next</span><span class="symbol">;</span> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| <span class="normal"> </span><span class="cbracket">}</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p> |
| </p> |
| <p> |
| 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 |
| problems with reentrancy. For instance, while waiting for data |
| to be received from the network in response to a menu item, |
| the menu item might be selected again. It might seem that |
| one could make the menu item's callback return immediately |
| 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. |
| However, this should be avoided since the user then sees selecting |
| the menu item do nothing. Furthermore, you'll find yourself adding |
| these checks all over your code, since there are doubtless many, |
| many things that the user could do. Instead, you can use the |
| following techniques: |
| </p> |
| <p> |
| </p> |
| <div class="orderedlist"><ol class="orderedlist" type="1"> |
| <li class="listitem"><p> |
| Use <a href="http://library.gnome.org/devel/gtk/unstable/GtkWidget.html#gtk-widget-set-sensitive"><code class="function">gtk_widget_set_sensitive()</code></a> or modal dialogs to prevent |
| the user from interacting with elements while the main |
| loop is recursing. |
| </p></li> |
| <li class="listitem"><p> |
| Avoid main loop recursion in situations where you can't handle |
| arbitrary callbacks. Instead, structure your code so that you |
| simply return to the main loop and then get called again when |
| there is more work to do. |
| </p></li> |
| </ol></div> |
| <p> |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> The main loop recursion level in the current thread |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_current_source ()"> |
| <a name="g-main-current-source"></a><h3>g_main_current_source ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="returnvalue">GSource</span></a> * g_main_current_source (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p> |
| Returns the currently firing source for this thread. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> The currently firing source or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.12</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_set_poll_func()"> |
| <a name="g-main-set-poll-func"></a><h3>g_main_set_poll_func()</h3> |
| <pre class="programlisting">#define g_main_set_poll_func(func)</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <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> instead.</p> |
| </div> |
| <p> |
| Sets the function to use for the handle polling of file descriptors |
| for the default main context. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td> |
| <td>the function to call to poll all file descriptors. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_get_thread_default ()"> |
| <a name="g-main-context-get-thread-default"></a><h3>g_main_context_get_thread_default ()</h3> |
| <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> |
| <p> |
| 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 |
| operations that want to be able to be run in contexts other than |
| the default one should call this method to get a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> to |
| add their <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a>s to. (Note that even in single-threaded |
| programs applications may sometimes want to temporarily push a |
| non-default context, so it is not safe to assume that this will |
| always return <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if threads are not initialized.) |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the thread-default <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> if the |
| thread-default context is the global default context. |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_push_thread_default ()"> |
| <a name="g-main-context-push-thread-default"></a><h3>g_main_context_push_thread_default ()</h3> |
| <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> |
| <p> |
| Acquires <em class="parameter"><code>context</code></em> and sets it as the thread-default context for the |
| current thread. This will cause certain asynchronous operations |
| (such as most gio-based I/O) which are |
| started in this thread to run under <em class="parameter"><code>context</code></em> and deliver their |
| results to its main loop, rather than running under the global |
| default context in the main thread. Note that calling this function |
| changes the context returned by |
| <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 |
| 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 |
| 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>. |
| </p> |
| <p> |
| Normally you would call this function shortly after creating a new |
| 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 |
| <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 |
| async operations in that thread. (In this case, you don't need to |
| 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 |
| however, you may want to schedule a single operation in a |
| non-default context, or temporarily use a non-default context in |
| the main thread. In that case, you can wrap the call to the |
| asynchronous operation inside a |
| <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> / |
| <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 |
| ensure that no other asynchronous operations accidentally get |
| started while the non-default context is active. |
| </p> |
| <p> |
| Beware that libraries that predate this function may not correctly |
| handle being used from a thread with a thread-default context. Eg, |
| see <a href="/usr/share/gtk-doc/html/gio/GFile.html#g-file-supports-thread-contexts"><code class="function">g_file_supports_thread_contexts()</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <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 |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_main_context_pop_thread_default ()"> |
| <a name="g-main-context-pop-thread-default"></a><h3>g_main_context_pop_thread_default ()</h3> |
| <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> |
| <p> |
| Pops <em class="parameter"><code>context</code></em> off the thread-default context stack (verifying that |
| it was on the top of the stack). |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <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> |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_timeout_source_new ()"> |
| <a name="g-timeout-source-new"></a><h3>g_timeout_source_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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> |
| <p> |
| Creates a new timeout source. |
| </p> |
| <p> |
| 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> |
| 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 |
| executed. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td> |
| <td>the timeout interval in milliseconds. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the newly-created timeout source |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_timeout_source_new_seconds ()"> |
| <a name="g-timeout-source-new-seconds"></a><h3>g_timeout_source_new_seconds ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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> |
| <p> |
| Creates a new timeout source. |
| </p> |
| <p> |
| 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> |
| 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 |
| executed. |
| </p> |
| <p> |
| The scheduling granularity/accuracy of this timeout source will be |
| in seconds. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td> |
| <td>the timeout interval in seconds |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the newly-created timeout source |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.14</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_timeout_add ()"> |
| <a name="g-timeout-add"></a><h3>g_timeout_add ()</h3> |
| <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>, |
| <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>, |
| <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> |
| <p> |
| Sets a function to be called at regular intervals, with the 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>. 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 point the timeout is automatically |
| destroyed and the function will not be called again. The first call |
| to the function will be at the end of the first <em class="parameter"><code>interval</code></em>. |
| </p> |
| <p> |
| Note that timeout functions may be delayed, due to the processing of other |
| event sources. Thus they should not be relied on for precise timing. |
| After each call to the timeout function, the time of the next |
| timeout is recalculated based on the current time and the given interval |
| (it does not try to 'catch up' time lost in delays). |
| </p> |
| <p> |
| If you want to have a timer in the "seconds" range and do not care |
| about the exact time of the first call of the timer, use the |
| <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 |
| optimizations and more efficient system power usage. |
| </p> |
| <p> |
| 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> |
| 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 |
| do these steps manually if you need greater control. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td> |
| <td>the time between calls to the function, in milliseconds |
| (1/1000ths of a second) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td> |
| <td>function to call |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>data to pass to <em class="parameter"><code>function</code></em> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) of the event source. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_timeout_add_full ()"> |
| <a name="g-timeout-add-full"></a><h3>g_timeout_add_full ()</h3> |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p> |
| Sets a function to be called at regular intervals, with the given |
| priority. 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 point the timeout is automatically destroyed and |
| the function will not be called again. The <em class="parameter"><code>notify</code></em> function is |
| called when the timeout is destroyed. The first call to the |
| function will be at the end of the first <em class="parameter"><code>interval</code></em>. |
| </p> |
| <p> |
| Note that timeout functions may be delayed, due to the processing of other |
| event sources. Thus they should not be relied on for precise timing. |
| After each call to the timeout function, the time of the next |
| timeout is recalculated based on the current time and the given interval |
| (it does not try to 'catch up' time lost in delays). |
| </p> |
| <p> |
| 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> |
| 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 |
| do these steps manually if you need greater control. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td> |
| <td>the priority of the timeout source. Typically this will be in |
| 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> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td> |
| <td>the time between calls to the function, in milliseconds |
| (1/1000ths of a second) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td> |
| <td>function to call |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>data to pass to <em class="parameter"><code>function</code></em> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td> |
| <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> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) of the event source. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_timeout_add_seconds ()"> |
| <a name="g-timeout-add-seconds"></a><h3>g_timeout_add_seconds ()</h3> |
| <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>, |
| <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>, |
| <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> |
| <p> |
| Sets a function to be called at regular intervals with the 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>. 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 point the timeout is automatically destroyed |
| and the function will not be called again. |
| </p> |
| <p> |
| This internally creates a main loop source using |
| <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 |
| 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 |
| greater control. Also see <code class="function">g_timout_add_seconds_full()</code>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td> |
| <td>the time between calls to the function, in seconds |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td> |
| <td>function to call |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>data to pass to <em class="parameter"><code>function</code></em> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) of the event source. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.14</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_timeout_add_seconds_full ()"> |
| <a name="g-timeout-add-seconds-full"></a><h3>g_timeout_add_seconds_full ()</h3> |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> interval</code></em>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p> |
| Sets a function to be called at regular intervals, with <em class="parameter"><code>priority</code></em>. |
| 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 |
| point the timeout is automatically destroyed and the function will |
| not be called again. |
| </p> |
| <p> |
| 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. |
| The initial starting point of the timer is determined by the implementation |
| and the implementation is expected to group multiple timers together so that |
| they fire all at the same time. |
| To allow this grouping, the <em class="parameter"><code>interval</code></em> to the first timer is rounded |
| and can deviate up to one second from the specified interval. |
| Subsequent timer iterations will generally run at the specified interval. |
| </p> |
| <p> |
| Note that timeout functions may be delayed, due to the processing of other |
| event sources. Thus they should not be relied on for precise timing. |
| After each call to the timeout function, the time of the next |
| timeout is recalculated based on the current time and the given <em class="parameter"><code>interval</code></em> |
| </p> |
| <p> |
| 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> |
| instead. |
| </p> |
| <p> |
| The grouping of timers to fire at the same time results in a more power |
| and CPU efficient behavior so if your timer is in multiples of seconds |
| and you don't require the first timer exactly one second from now, the |
| 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>. |
| </p> |
| <p> |
| This internally creates a main loop source using |
| <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 |
| 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 |
| greater control. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td> |
| <td>the priority of the timeout source. Typically this will be in |
| 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> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td> |
| <td>the time between calls to the function, in seconds |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td> |
| <td>function to call |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>data to pass to <em class="parameter"><code>function</code></em> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td> |
| <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> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) of the event source. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.14</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_idle_source_new ()"> |
| <a name="g-idle-source-new"></a><h3>g_idle_source_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="returnvalue">GSource</span></a> * g_idle_source_new (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p> |
| Creates a new idle source. |
| </p> |
| <p> |
| 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> |
| 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 |
| executed. Note that the default priority for idle sources is |
| <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 |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the newly-created idle source |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_idle_add ()"> |
| <a name="g-idle-add"></a><h3>g_idle_add ()</h3> |
| <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>, |
| <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> |
| <p> |
| Adds a function to be called whenever there are no higher priority |
| events pending to the default main loop. The function is given the |
| 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 |
| 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 |
| sources and will not be called again. |
| </p> |
| <p> |
| 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> |
| 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 do these steps manually if you need greater control. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td> |
| <td>function to call |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>data to pass to <em class="parameter"><code>function</code></em>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) of the event source. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_idle_add_full ()"> |
| <a name="g-idle-add-full"></a><h3>g_idle_add_full ()</h3> |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p> |
| Adds a function to be called whenever there are no higher priority |
| 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 |
| removed from the list of event sources and will not be called again. |
| </p> |
| <p> |
| 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> |
| 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 do these steps manually if you need greater control. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td> |
| <td>the priority of the idle source. Typically this will be in the |
| 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> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td> |
| <td>function to call |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>data to pass to <em class="parameter"><code>function</code></em> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td> |
| <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> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) of the event source. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_idle_remove_by_data ()"> |
| <a name="g-idle-remove-by-data"></a><h3>g_idle_remove_by_data ()</h3> |
| <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> |
| <p> |
| Removes the idle function with the given data. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>the data for the idle source's callback. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="GPid"> |
| <a name="GPid"></a><h3>GPid</h3> |
| <pre class="programlisting">typedef int GPid; |
| </pre> |
| <p> |
| A type which is used to hold a process identification. |
| On Unix, processes are identified by a process id (an |
| integer), while Windows uses process handles (which are |
| pointers). |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GChildWatchFunc ()"> |
| <a name="GChildWatchFunc"></a><h3>GChildWatchFunc ()</h3> |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> status</code></em>, |
| <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> |
| <p> |
| The type of functions to be called when a child exists. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td> |
| <td>the process id of the child process |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>status</code></em> :</span></p></td> |
| <td>Status information about the child process, |
| see waitpid(2) for more information about this field |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <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> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_child_watch_source_new ()"> |
| <a name="g-child-watch-source-new"></a><h3>g_child_watch_source_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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> |
| <p> |
| Creates a new child_watch source. |
| </p> |
| <p> |
| 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> |
| 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 |
| executed. |
| </p> |
| <p> |
| Note that child watch sources can only be used in conjunction with |
| <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> |
| flag is used. |
| </p> |
| <p> |
| 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 |
| (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 |
| source is still active. Typically, you will want to call |
| <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. |
| </p> |
| <p> |
| 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 |
| compatible with calling <code class="literal">waitpid(-1)</code> in |
| the application. Calling <code class="function">waitpid()</code> for individual pids will |
| still work fine. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td> |
| <td>process to watch. On POSIX the pid of a child process. On |
| Windows a handle for a process (which doesn't have to be a child). |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the newly-created child watch source |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.4</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_child_watch_add ()"> |
| <a name="g-child-watch-add"></a><h3>g_child_watch_add ()</h3> |
| <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>, |
| <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>, |
| <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> |
| <p> |
| Sets a function to be called when the child indicated by <em class="parameter"><code>pid</code></em> |
| 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>. |
| </p> |
| <p> |
| 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> |
| 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 |
| the spawn function for the child watching to work. |
| </p> |
| <p> |
| 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 |
| (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 |
| source is still active. Typically, you will want to call |
| <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. |
| </p> |
| <p> |
| GLib supports only a single callback per process id. |
| </p> |
| <p> |
| This internally creates a main loop source 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> 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 do these steps manually if you |
| need greater control. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td> |
| <td>process id to watch. On POSIX the pid of a child process. On |
| Windows a handle for a process (which doesn't have to be a child). |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td> |
| <td>function to call |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>data to pass to <em class="parameter"><code>function</code></em> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) of the event source. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.4</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_child_watch_add_full ()"> |
| <a name="g-child-watch-add-full"></a><h3>g_child_watch_add_full ()</h3> |
| <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>, |
| <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>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p> |
| Sets a function to be called when the child indicated by <em class="parameter"><code>pid</code></em> |
| exits, at the priority <em class="parameter"><code>priority</code></em>. |
| </p> |
| <p> |
| 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> |
| 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 |
| the spawn function for the child watching to work. |
| </p> |
| <p> |
| 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 |
| (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 |
| source is still active. Typically, you will want to call |
| <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. |
| </p> |
| <p> |
| GLib supports only a single callback per process id. |
| </p> |
| <p> |
| This internally creates a main loop source 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> 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 do these steps manually if you |
| need greater control. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td> |
| <td>the priority of the idle source. Typically this will be in the |
| 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> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>pid</code></em> :</span></p></td> |
| <td>process to watch. On POSIX the pid of a child process. On |
| Windows a handle for a process (which doesn't have to be a child). |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td> |
| <td>function to call |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>data to pass to <em class="parameter"><code>function</code></em> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td> |
| <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> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) of the event source. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.4</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GPollFD"> |
| <a name="GPollFD"></a><h3>GPollFD</h3> |
| <pre class="programlisting">typedef struct { |
| #if defined (G_OS_WIN32) && GLIB_SIZEOF_VOID_P == 8 |
| gint64 fd; |
| #else |
| gint fd; |
| #endif |
| gushort events; |
| gushort revents; |
| } GPollFD; |
| </pre> |
| <p> |
| </p> |
| <div class="informaltable"><table width="100%" border="0"> |
| <colgroup> |
| <col> |
| <col> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td> |
| <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> fd;</td> |
| <td>the file descriptor to poll (or a <span class="type">HANDLE</span> on Win32 platforms).</td> |
| </tr> |
| <tr> |
| <td> |
| <a class="link" href="glib-Basic-Types.html#gushort" title="gushort"><span class="type">gushort</span></a> events;</td> |
| <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>, specifying which |
| events should be polled for. Typically for reading from a file 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 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> |
| </tr> |
| <tr> |
| <td> |
| <a class="link" href="glib-Basic-Types.html#gushort" title="gushort"><span class="type">gushort</span></a> revents;</td> |
| <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 from the |
| <code class="function"><code class="function">poll()</code></code> function to indicate which events occurred. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p> |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_poll ()"> |
| <a name="g-poll"></a><h3>g_poll ()</h3> |
| <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="GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> nfds</code></em>, |
| <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> |
| <p> |
| Polls <em class="parameter"><code>fds</code></em>, as with the <code class="function">poll()</code> system call, but portably. (On |
| systems that don't have <code class="function">poll()</code>, it is emulated using <code class="function">select()</code>.) |
| 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 |
| directly if you need to block until a file descriptor is ready, but |
| don't want to run the full main loop. |
| </p> |
| <p> |
| Each element of <em class="parameter"><code>fds</code></em> is a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> describing a single file |
| descriptor to poll. The <code class="literal">fd</code> field indicates the file descriptor, |
| and the <code class="literal">events</code> field indicates the events to poll for. On return, |
| the <code class="literal">revents</code> fields will be filled with the events that actually |
| occurred. |
| </p> |
| <p> |
| On POSIX systems, the file descriptors in <em class="parameter"><code>fds</code></em> can be any sort of |
| file descriptor, but the situation is much more complicated on |
| 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 |
| Windows, the easiest solution is to construct all of your |
| <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a>s with <code class="function">g_io_channel_win32_make_pollfd()</code>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fds</code></em> :</span></p></td> |
| <td>file descriptors to poll |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>nfds</code></em> :</span></p></td> |
| <td>the number of file descriptors in <em class="parameter"><code>fds</code></em> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>timeout</code></em> :</span></p></td> |
| <td>amount of time to wait, in milliseconds, or -1 to wait forever |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the number of entries in <em class="parameter"><code>fds</code></em> whose <code class="literal">revents</code> fields |
| were filled in, or 0 if the operation timed out, or -1 on error or |
| if the call was interrupted. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.20</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_POLLFD_FORMAT"> |
| <a name="G-POLLFD-FORMAT:CAPS"></a><h3>G_POLLFD_FORMAT</h3> |
| <pre class="programlisting">#define G_POLLFD_FORMAT</pre> |
| <p> |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GSource"> |
| <a name="GSource"></a><h3>GSource</h3> |
| <pre class="programlisting">typedef struct { |
| } GSource; |
| </pre> |
| <p> |
| The <span class="structname">GSource</span> struct is an opaque data type representing |
| an event source. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GSourceDummyMarshal ()"> |
| <a name="GSourceDummyMarshal"></a><h3>GSourceDummyMarshal ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> (*GSourceDummyMarshal) (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p> |
| This is just a placeholder for <a href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#GClosureMarshal"><span class="type">GClosureMarshal</span></a>, which cannot be used here |
| for dependency reasons. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GSourceFuncs"> |
| <a name="GSourceFuncs"></a><h3>GSourceFuncs</h3> |
| <pre class="programlisting">typedef struct { |
| gboolean (*prepare) (GSource *source, |
| gint *timeout_); |
| gboolean (*check) (GSource *source); |
| gboolean (*dispatch) (GSource *source, |
| GSourceFunc callback, |
| gpointer user_data); |
| void (*finalize) (GSource *source); /* Can be NULL */ |
| |
| /* For use by g_source_set_closure */ |
| GSourceFunc closure_callback; |
| GSourceDummyMarshal closure_marshal; /* Really is of type GClosureMarshal */ |
| } GSourceFuncs; |
| </pre> |
| <p> |
| The <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="GSourceFuncs"><span class="type">GSourceFuncs</span></a> struct contains a table of functions used to handle |
| event sources in a generic manner. |
| </p> |
| <p> |
| 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> to |
| indicate that the source is always ready to be processed. |
| The prepare function also returns a timeout value of 0 to ensure that the |
| <code class="function">poll()</code> call doesn't block (since that would be time |
| wasted which could have been spent running the idle function). |
| </p> |
| <p> |
| 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> if the |
| timeout interval has expired. The prepare function also returns a timeout |
| value to ensure that the <code class="function">poll()</code> call doesn't block too |
| long and miss the next timeout. |
| </p> |
| <p> |
| 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>, |
| since it must wait until <code class="function">poll()</code> has been called before |
| it knows whether any events need to be processed. It sets the returned |
| timeout to -1 to indicate that it doesn't mind how long the |
| <code class="function">poll()</code> call blocks. |
| In the check function, it tests the results of the <code class="function">poll()</code> |
| call to see if the 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. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.prepare"></a>prepare</code></em> ()</span></p></td> |
| <td>Called before all the file descriptors are polled. |
| If the source can determine that it is ready here (without waiting for the |
| 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 a <em class="parameter"><code>timeout_</code></em> value which should be the maximum timeout |
| (in milliseconds) which should be passed to the <code class="function">poll()</code> call. |
| The actual timeout used will be -1 if all sources returned -1, or it will |
| be the minimum of all the <em class="parameter"><code>timeout_</code></em> values returned which were >= 0. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.check"></a>check</code></em> ()</span></p></td> |
| <td>Called after all the file descriptors are polled. |
| The source 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 time may have passed since the previous prepare function was |
| called, so the source should be checked again here. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.dispatch"></a>dispatch</code></em> ()</span></p></td> |
| <td>Called to dispatch the event source, after it has returned <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> function is |
| passed in a callback function and data. The callback 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 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 |
| callback function with <em class="parameter"><code>user_data</code></em> and whatever additional parameters are |
| needed for this type of event source. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.finalize"></a>finalize</code></em> ()</span></p></td> |
| <td>Called when the source is finalized. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> <em class="structfield"><code><a name="GSourceFuncs.closure-callback"></a>closure_callback</code></em>;</span></p></td> |
| <td> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><a class="link" href="glib-The-Main-Event-Loop.html#GSourceDummyMarshal" title="GSourceDummyMarshal ()"><span class="type">GSourceDummyMarshal</span></a> <em class="structfield"><code><a name="GSourceFuncs.closure-marshal"></a>closure_marshal</code></em>;</span></p></td> |
| <td> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="GSourceCallbackFuncs"> |
| <a name="GSourceCallbackFuncs"></a><h3>GSourceCallbackFuncs</h3> |
| <pre class="programlisting">typedef struct { |
| void (*ref) (gpointer cb_data); |
| void (*unref) (gpointer cb_data); |
| void (*get) (gpointer cb_data, |
| GSource *source, |
| GSourceFunc *func, |
| gpointer *data); |
| } GSourceCallbackFuncs; |
| </pre> |
| <p> |
| The <span class="structname">GSourceCallbackFuncs</span> struct contains |
| functions for managing callback objects. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="structfield"><code><a name="GSourceCallbackFuncs.ref"></a>ref</code></em> ()</span></p></td> |
| <td>Called when a reference is added to the callback object. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="structfield"><code><a name="GSourceCallbackFuncs.unref"></a>unref</code></em> ()</span></p></td> |
| <td>Called when a reference to the callback object is dropped. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="structfield"><code><a name="GSourceCallbackFuncs.get"></a>get</code></em> ()</span></p></td> |
| <td>Called to extract the callback function and data from the callback object. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_new ()"> |
| <a name="g-source-new"></a><h3>g_source_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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="GSourceFuncs"><span class="type">GSourceFuncs</span></a> *source_funcs</code></em>, |
| <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> |
| <p> |
| Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> structure. The size is specified to |
| allow creating structures derived from <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> that contain |
| additional data. The size passed in must be at least |
| <code class="literal">sizeof (GSource)</code>. |
| </p> |
| <p> |
| 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> |
| 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 |
| executed. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source_funcs</code></em> :</span></p></td> |
| <td>structure containing functions that implement |
| the sources behavior. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>struct_size</code></em> :</span></p></td> |
| <td>size of the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> structure to create. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the newly-created <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_ref ()"> |
| <a name="g-source-ref"></a><h3>g_source_ref ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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="GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p> |
| Increases the reference count on a source by one. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <em class="parameter"><code>source</code></em> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_unref ()"> |
| <a name="g-source-unref"></a><h3>g_source_unref ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p> |
| Decreases the reference count of a source by one. If the |
| resulting reference count is zero the source and associated |
| memory will be destroyed. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_set_funcs ()"> |
| <a name="g-source-set-funcs"></a><h3>g_source_set_funcs ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>);</pre> |
| <p> |
| Sets the source functions (can be used to override |
| default implementations) of an unattached source. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>funcs</code></em> :</span></p></td> |
| <td>the new <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="GSourceFuncs"><span class="type">GSourceFuncs</span></a> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.12</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_attach ()"> |
| <a name="g-source-attach"></a><h3>g_source_attach ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <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> |
| <p> |
| Adds a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> to a <em class="parameter"><code>context</code></em> so that it will be executed within |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td> |
| <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) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) for the source within the |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_destroy ()"> |
| <a name="g-source-destroy"></a><h3>g_source_destroy ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p> |
| 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 |
| destroyed. The source cannot be subsequently added to another |
| context. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_is_destroyed ()"> |
| <a name="g-source-is-destroyed"></a><h3>g_source_is_destroyed ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p> |
| Returns whether <em class="parameter"><code>source</code></em> has been destroyed. |
| </p> |
| <p> |
| This is important when you operate upon your objects |
| from within idle handlers, but may have freed the object |
| before the dispatch of your idle handler. |
| </p> |
| <p> |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19 |
| 20 |
| 21 |
| 22 |
| 23 |
| 24 |
| 25 |
| 26 |
| 27 |
| 28 |
| 29</pre></td> |
| <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> |
| <span class="function">idle_callback</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a> data</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> SomeWidget </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> data</span><span class="symbol">;</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gdk/unstable/gdk-Threads.html#GDK-THREADS-ENTER:CAPS">GDK_THREADS_ENTER</a></span><span class="normal"> </span><span class="symbol">();</span> |
| <span class="normal"> </span><span class="comment">/* do stuff with self */</span> |
| <span class="normal"> self</span><span class="symbol">-></span><span class="normal">idle_id </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span> |
| <span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gdk/unstable/gdk-Threads.html#GDK-THREADS-LEAVE:CAPS">GDK_THREADS_LEAVE</a></span><span class="normal"> </span><span class="symbol">();</span> |
| <span class="normal"> </span> |
| <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> |
| <span class="cbracket">}</span> |
| <span class="normal"> </span> |
| <span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span> |
| <span class="function">some_widget_do_stuff_later</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">SomeWidget </span><span class="symbol">*</span><span class="normal">self</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> self</span><span class="symbol">-></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> |
| <span class="cbracket">}</span> |
| <span class="normal"> </span> |
| <span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span> |
| <span class="function">some_widget_finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a> </span><span class="symbol">*</span><span class="normal">object</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> SomeWidget </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> |
| <span class="normal"> </span> |
| <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">-></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-source-remove">g_source_remove</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">self</span><span class="symbol">-></span><span class="normal">idle_id</span><span class="symbol">);</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/gobject/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">)-></span><span class="function">finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span> |
| <span class="cbracket">}</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p> |
| </p> |
| <p> |
| This will fail in a multi-threaded application if the |
| widget is destroyed before the idle handler fires due |
| to the use after free in the callback. A solution, to |
| this particular problem, is to check to if the source |
| has already been destroy within the callback. |
| </p> |
| <p> |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14</pre></td> |
| <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> |
| <span class="function">idle_callback</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a> data</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> SomeWidget </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> data</span><span class="symbol">;</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gdk/unstable/gdk-Threads.html#GDK-THREADS-ENTER:CAPS">GDK_THREADS_ENTER</a></span><span class="normal"> </span><span class="symbol">();</span> |
| <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> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <span class="normal"> </span><span class="comment">/* do stuff with self */</span> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| <span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gdk/unstable/gdk-Threads.html#GDK-THREADS-LEAVE:CAPS">GDK_THREADS_LEAVE</a></span><span class="normal"> </span><span class="symbol">();</span> |
| <span class="normal"> </span> |
| <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> |
| <span class="cbracket">}</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p> |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.12</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_set_priority ()"> |
| <a name="g-source-set-priority"></a><h3>g_source_set_priority ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <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> |
| <p> |
| Sets the priority of a source. While the main loop is being |
| run, a source will be dispatched if it is ready to be dispatched and no sources |
| at a higher (numerically smaller) priority are ready to be dispatched. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td> |
| <td>the new priority. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_get_priority ()"> |
| <a name="g-source-get-priority"></a><h3>g_source_get_priority ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p> |
| Gets the priority of a source. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the priority of the source |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_set_can_recurse ()"> |
| <a name="g-source-set-can-recurse"></a><h3>g_source_set_can_recurse ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <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> |
| <p> |
| Sets whether a source can be called recursively. If <em class="parameter"><code>can_recurse</code></em> is |
| <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 |
| will be processed normally. Otherwise, all processing of this |
| source is blocked until the dispatch function returns. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>can_recurse</code></em> :</span></p></td> |
| <td>whether recursion is allowed for this source |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_get_can_recurse ()"> |
| <a name="g-source-get-can-recurse"></a><h3>g_source_get_can_recurse ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p> |
| Checks whether a source is allowed to be called recursively. |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> whether recursion is allowed. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_get_id ()"> |
| <a name="g-source-get-id"></a><h3>g_source_get_id ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p> |
| Returns the numeric ID for a particular source. The ID of a source |
| is a positive integer which is unique within a particular main loop |
| context. The reverse |
| 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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the ID (greater than 0) for the source |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_get_context ()"> |
| <a name="g-source-get-context"></a><h3>g_source_get_context ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p> |
| 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. |
| Calling this function on a destroyed source is an error. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> 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, |
| or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the context has not yet been added |
| to a source. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_set_callback ()"> |
| <a name="g-source-set-callback"></a><h3>g_source_set_callback ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p> |
| Sets the callback function for a source. The callback for a source is |
| called from the source's dispatch function. |
| </p> |
| <p> |
| The exact type of <em class="parameter"><code>func</code></em> depends on the type of source; ie. you |
| should not count on <em class="parameter"><code>func</code></em> being called with <em class="parameter"><code>data</code></em> as its first |
| parameter. |
| </p> |
| <p> |
| Typically, you won't use this function. Instead use functions specific |
| to the type of source you are using. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>the source |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td> |
| <td>a callback function |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>the data to pass to callback function |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td> |
| <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>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="GSourceFunc ()"> |
| <a name="GSourceFunc"></a><h3>GSourceFunc ()</h3> |
| <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> data</code></em>);</pre> |
| <p> |
| 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>, <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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td> |
| <td>data passed to the function, set when the source was created with one |
| of the above functions. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td>it should return <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> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_set_callback_indirect ()"> |
| <a name="g-source-set-callback-indirect"></a><h3>g_source_set_callback_indirect ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <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>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceCallbackFuncs" title="GSourceCallbackFuncs"><span class="type">GSourceCallbackFuncs</span></a> *callback_funcs</code></em>);</pre> |
| <p> |
| Sets the callback function storing the data as a refcounted callback |
| "object". This is used internally. Note that calling |
| <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 |
| an initial reference count on <em class="parameter"><code>callback_data</code></em>, and thus |
| <em class="parameter"><code>callback_funcs->unref</code></em> will eventually be called once more |
| than <em class="parameter"><code>callback_funcs->ref</code></em>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>the source |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>callback_data</code></em> :</span></p></td> |
| <td>pointer to callback data "object" |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>callback_funcs</code></em> :</span></p></td> |
| <td>functions for reference counting <em class="parameter"><code>callback_data</code></em> |
| and getting the callback and data |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_add_poll ()"> |
| <a name="g-source-add-poll"></a><h3>g_source_add_poll ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);</pre> |
| <p> |
| Adds a file descriptor to the set of file descriptors polled for |
| 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 |
| event source. The event source's check function will typically test |
| the <em class="parameter"><code>revents</code></em> field in the <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="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 |
| to be processed. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> structure holding information about a file |
| descriptor to watch. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_remove_poll ()"> |
| <a name="g-source-remove-poll"></a><h3>g_source_remove_poll ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);</pre> |
| <p> |
| Removes a file descriptor from the set of file descriptors polled for |
| this source. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="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> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_get_current_time ()"> |
| <a name="g-source-get-current-time"></a><h3>g_source_get_current_time ()</h3> |
| <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="GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="GTimeVal"><span class="type">GTimeVal</span></a> *timeval</code></em>);</pre> |
| <p> |
| Gets the "current time" to be used when checking |
| this source. The advantage of calling this function over |
| calling <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> directly is that when |
| checking multiple sources, GLib can cache a single value |
| instead of having to repeatedly get the system time. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="GSource"><span class="type">GSource</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>timeval</code></em> :</span></p></td> |
| <td> |
| <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="GTimeVal"><span class="type">GTimeVal</span></a> structure in which to store current time. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_remove ()"> |
| <a name="g-source-remove"></a><h3>g_source_remove ()</h3> |
| <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> |
| <p> |
| Removes the source with the given id from the default main context. |
| The id of |
| a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="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 |
| 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>, |
| <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>, |
| <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>. |
| </p> |
| <p> |
| 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 |
| added to a non-default main context. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>tag</code></em> :</span></p></td> |
| <td>the ID of the source to remove. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_remove_by_funcs_user_data ()"> |
| <a name="g-source-remove-by-funcs-user-data"></a><h3>g_source_remove_by_funcs_user_data ()</h3> |
| <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="GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>, |
| <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> |
| <p> |
| Removes a source from the default main loop context given the |
| source functions and user data. If multiple sources exist with the |
| same source functions and user data, only one will be destroyed. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>funcs</code></em> :</span></p></td> |
| <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> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td> |
| <td>the user data for the callback |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_source_remove_by_user_data ()"> |
| <a name="g-source-remove-by-user-data"></a><h3>g_source_remove_by_user_data ()</h3> |
| <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> |
| <p> |
| Removes a source from the default main loop context given the user |
| data for the callback. If multiple sources exist with the same user |
| data, only one will be destroyed. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td> |
| <td>the user_data for the callback. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| </div> |
| <div class="footer"> |
| <hr> |
| Generated by GTK-Doc V1.14</div> |
| </body> |
| </html> |