Wrote the README_GIT file to be a proper tutorial on git, repo.or.cz and gtkD.
[gtkD.git] / gtkD / src / glib / Child.d
blob2f84205a755f559e8fe92418c06d6f175dea662a
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile =
26 * outPack = glib
27 * outFile = Child
28 * strct =
29 * realStrct=
30 * ctorStrct=
31 * clss = Child
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_child_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.MainLoop
45 * - glib.Dataset
46 * structWrap:
47 * - GDataset* -> Dataset
48 * - GMainLoop* -> MainLoop
49 * module aliases:
50 * local aliases:
53 module glib.Child;
55 version(noAssert)
57 version(Tango)
59 import tango.io.Stdout; // use the tango loging?
63 private import gtkc.glibtypes;
65 private import gtkc.glib;
68 private import glib.MainLoop;
69 private import glib.Dataset;
74 /**
75 * Description
76 * The main event loop manages all the available sources of events for
77 * GLib and GTK+ applications. These events can come from any number of
78 * different types of sources such as file descriptors (plain files,
79 * pipes or sockets) and timeouts. New types of event sources can also
80 * be added using g_source_attach().
81 * To allow multiple independent sets of sources to be handled in
82 * different threads, each source is associated with a GMainContext.
83 * A GMainContext can only be running in a single thread, but
84 * sources can be added to it and removed from it from other threads.
85 * Each event source is assigned a priority. The default priority,
86 * G_PRIORITY_DEFAULT, is 0. Values less than 0 denote higher
87 * priorities. Values greater than 0 denote lower priorities. Events
88 * from high priority sources are always processed before events from
89 * lower priority sources.
90 * Idle functions can also be added, and assigned a priority. These will
91 * be run whenever no events with a higher priority are ready to be
92 * processed.
93 * The GMainLoop data type represents a main event loop. A GMainLoop
94 * is created with g_main_loop_new(). After adding the initial event sources,
95 * g_main_loop_run() is called. This continuously checks for new events from
96 * each of the event sources and dispatches them. Finally, the
97 * processing of an event from one of the sources leads to a call to
98 * g_main_loop_quit() to exit the main loop, and g_main_loop_run() returns.
99 * It is possible to create new instances of GMainLoop recursively.
100 * This is often used in GTK+ applications when showing modal dialog
101 * boxes. Note that event sources are associated with a particular
102 * GMainContext, and will be checked and dispatched for all main
103 * loops associated with that GMainContext.
104 * GTK+ contains wrappers of some of these functions, e.g. gtk_main(),
105 * gtk_main_quit() and gtk_events_pending().
106 * Creating new sources types
107 * One of the unusual features of the GTK+ main loop functionality
108 * is that new types of event source can be created and used in
109 * addition to the builtin type of event source. A new event source
110 * type is used for handling GDK events. A new source type is
111 * created by deriving from the GSource
112 * structure. The derived type of source is represented by a
113 * structure that has the GSource structure as a first element,
114 * and other elements specific to the new source type. To create
115 * an instance of the new source type, call g_source_new() passing
116 * in the size of the derived structure and a table of functions.
117 * These GSourceFuncs determine the behavior of the new source
118 * types.
119 * New source types basically interact with with the main context
120 * in two ways. Their prepare function in GSourceFuncs can set
121 * a timeout to determine the maximum amount of time that the
122 * main loop will sleep before checking the source again. In
123 * addition, or as well, the source can add file descriptors to
124 * the set that the main context checks using g_source_add_poll().
125 * <hr>
126 * Customizing the main loop iteration
127 * Single iterations of a GMainContext can be run with
128 * g_main_context_iteration(). In some cases, more detailed control
129 * of exactly how the details of the main loop work is desired,
130 * for instance, when integrating the GMainLoop with an external
131 * main loop. In such cases, you can call the component functions
132 * of g_main_context_iteration() directly. These functions
133 * are g_main_context_prepare(), g_main_context_query(),
134 * g_main_context_check() and g_main_context_dispatch().
135 * The operation of these functions can best be seen in terms
136 * of a state diagram, as shown in Figure1, States of a Main Context.
137 * Figure1.States of a Main Context
139 public class Child
204 * Creates a new child_watch source.
205 * The source will not initially be associated with any GMainContext
206 * and must be added to one with g_source_attach() before it will be
207 * executed.
208 * Note that child watch sources can only be used in conjunction with
209 * g_spawn... when the G_SPAWN_DO_NOT_REAP_CHILD
210 * flag is used.
211 * Note that on platforms where GPid must be explicitly closed
212 * (see g_spawn_close_pid()) pid must not be closed while the
213 * source is still active. Typically, you will want to call
214 * g_spawn_close_pid() in the callback function for the source.
215 * Note further that using g_child_watch_source_new() is not
216 * compatible with calling waitpid(-1) in
217 * the application. Calling waitpid() for individual pids will
218 * still work fine.
219 * pid:
220 * process id of a child process to watch. On Windows, a HANDLE
221 * for the process to watch (which actually doesn't have to be a child).
222 * Returns:
223 * the newly-created child watch source
224 * Since 2.4
226 public static GSource* watchSourceNew(GPid pid)
228 // GSource* g_child_watch_source_new (GPid pid);
229 return g_child_watch_source_new(pid);
233 * Sets a function to be called when the child indicated by pid
234 * exits, at a default priority, G_PRIORITY_DEFAULT.
235 * If you obtain pid from g_spawn_async() or g_spawn_async_with_pipes()
236 * you will need to pass G_SPAWN_DO_NOT_REAP_CHILD as flag to
237 * the spawn function for the child watching to work.
238 * Note that on platforms where GPid must be explicitly closed
239 * (see g_spawn_close_pid()) pid must not be closed while the
240 * source is still active. Typically, you will want to call
241 * g_spawn_close_pid() in the callback function for the source.
242 * GLib supports only a single callback per process id.
243 * pid:
244 * process id of a child process to watch
245 * function:
246 * function to call
247 * data:
248 * data to pass to function
249 * Returns:
250 * the ID (greater than 0) of the event source.
251 * Since 2.4
253 public static uint watchAdd(GPid pid, GChildWatchFunc funct, void* data)
255 // guint g_child_watch_add (GPid pid, GChildWatchFunc function, gpointer data);
256 return g_child_watch_add(pid, funct, data);
260 * Sets a function to be called when the child indicated by pid
261 * exits, at the priority priority.
262 * If you obtain pid from g_spawn_async() or g_spawn_async_with_pipes()
263 * you will need to pass G_SPAWN_DO_NOT_REAP_CHILD as flag to
264 * the spawn function for the child watching to work.
265 * Note that on platforms where GPid must be explicitly closed
266 * (see g_spawn_close_pid()) pid must not be closed while the
267 * source is still active. Typically, you will want to call
268 * g_spawn_close_pid() in the callback function for the source.
269 * GLib supports only a single callback per process id.
270 * priority:
271 * the priority of the idle source. Typically this will be in the
272 * range between G_PRIORITY_DEFAULT_IDLE and G_PRIORITY_HIGH_IDLE.
273 * pid:
274 * process id of a child process to watch
275 * function:
276 * function to call
277 * data:
278 * data to pass to function
279 * notify:
280 * function to call when the idle is removed, or NULL
281 * Returns:
282 * the ID (greater than 0) of the event source.
283 * Since 2.4
285 public static uint watchAddFull(int priority, GPid pid, GChildWatchFunc funct, void* data, GDestroyNotify notify)
287 // guint g_child_watch_add_full (gint priority, GPid pid, GChildWatchFunc function, gpointer data, GDestroyNotify notify);
288 return g_child_watch_add_full(priority, pid, funct, data, notify);