MainLoop

The GMainLoop struct is an opaque data type representing the main event loop of a GLib or GTK+ application.

Constructors

this
this(GMainLoop* gMainLoop, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this(MainContext context, bool isRunning)

Creates a new glib.MainLoop structure.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

getContext
MainContext getContext()

Returns the glib.MainContext of loop.

getMainLoopStruct
GMainLoop* getMainLoopStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

isRunning
bool isRunning()

Checks to see if the main loop is currently being run via MainLoop.run.

quit
void quit()

Stops a glib.MainLoop from running. Any calls to MainLoop.run for the loop will return.

ref_
MainLoop ref_()

Increases the reference count on a glib.MainLoop object by one.

run
void run()

Runs a main loop until MainLoop.quit is called on the loop. If this is called for the thread of the loop's glib.MainContext, it will process events from the loop, otherwise it will simply wait.

unref
void unref()

Decreases the reference count on a glib.MainLoop object by one. If the result is zero, free the loop and free all associated memory.

Static functions

mainCurrentSource
Source mainCurrentSource()

Returns the currently firing source for this thread.

mainDepth
int mainDepth()

Returns the depth of the stack of calls to MainContext.dispatch on any glib.MainContext in the current thread. That is, when called from the toplevel, it gives 0. When called from within a callback from MainContext.iteration (or MainLoop.run, etc.) it returns 1. When called from within a callback to a recursive call to MainContext.iteration, it returns 2. And so forth.

poll
int poll(GPollFD* fds, uint nfds, int timeout)

Polls fds, as with the poll() system call, but portably. (On systems that don't have poll(), it is emulated using select().) This is used internally by glib.MainContext, 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.

Variables

gMainLoop
GMainLoop* gMainLoop;

the main Gtk struct