Source

The glib.source.Source struct is an opaque data type representing an event source.

Constructors

this
this(glib.types.SourceFuncs sourceFuncs, uint structSize)

Creates a new #GSource structure. The size is specified to allow creating structures derived from #GSource that contain additional data. The size passed in must be at least sizeof (GSource).

Members

Functions

addChildSource
void addChildSource(glib.source.Source childSource)

Adds child_source to source as a "polled" source; when source is added to a #GMainContext, child_source will be automatically added with the same priority, when child_source is triggered, it will cause source to dispatch (in addition to calling its own callback), and when source is destroyed, it will destroy child_source as well. (source will also still be dispatched if its own prepare/check functions indicate that it is ready.)

addPoll
void addPoll(glib.types.PollFD fd)

Adds a file descriptor to the set of file descriptors polled for this source. This is usually combined with glib.source.Source.new_ to add an event source. The event source's check function will typically test the revents field in the #GPollFD struct and return true if events need to be processed.

addUnixFd
void* addUnixFd(int fd, glib.types.IOCondition events)

Monitors fd for the IO events in events.

attach
uint attach(glib.main_context.MainContext context)

Adds a #GSource to a context so that it will be executed within that context. Remove it by calling glib.source.Source.destroy.

destroy
void destroy()

Removes a source from its #GMainContext, if any, and mark it as destroyed. The source cannot be subsequently added to another context. It is safe to call this on sources which have already been removed from their context.

getCanRecurse
bool getCanRecurse()

Checks whether a source is allowed to be called recursively. see glib.source.Source.setCanRecurse.

getContext
glib.main_context.MainContext getContext()

Gets the #GMainContext with which the source is associated.

getCurrentTime
void getCurrentTime(glib.time_val.TimeVal timeval)

This function ignores source and is otherwise the same as glib.global.getCurrentTime.

getId
uint getId()

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 glib.main_context.MainContext.findSourceById.

getName
string getName()

Gets a name for the source, used in debugging and profiling. The name may be #NULL if it has never been set with glib.source.Source.setName.

getPriority
int getPriority()

Gets the priority of a source.

getReadyTime
long getReadyTime()

Gets the "ready time" of source, as set by glib.source.Source.setReadyTime.

getTime
long getTime()

Gets the time to be used when checking this source. The advantage of calling this function over calling glib.global.getMonotonicTime directly is that when checking multiple sources, GLib can cache a single value instead of having to repeatedly get the system monotonic time.

isDestroyed
bool isDestroyed()

Returns whether source has been destroyed.

modifyUnixFd
void modifyUnixFd(void* tag, glib.types.IOCondition newEvents)

Updates the event mask to watch for the fd identified by tag.

queryUnixFd
glib.types.IOCondition queryUnixFd(void* tag)

Queries the events reported for the fd corresponding to tag on source during the last poll.

removeChildSource
void removeChildSource(glib.source.Source childSource)

Detaches child_source from source and destroys it.

removePoll
void removePoll(glib.types.PollFD fd)

Removes a file descriptor from the set of file descriptors polled for this source.

removeUnixFd
void removeUnixFd(void* tag)

Reverses the effect of a previous call to glib.source.Source.addUnixFd.

setCallback
void setCallback(glib.types.SourceFunc func)

Sets the callback function for a source. The callback for a source is called from the source's dispatch function.

setCallbackIndirect
void setCallbackIndirect(void* callbackData, glib.types.SourceCallbackFuncs callbackFuncs)

Sets the callback function storing the data as a refcounted callback "object". This is used internally. Note that calling glib.source.Source.setCallbackIndirect assumes an initial reference count on callback_data, and thus callback_funcs->unref will eventually be called once more than callback_funcs->ref.

setCanRecurse
void setCanRecurse(bool canRecurse)

Sets whether a source can be called recursively. If can_recurse is true, 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.

setFuncs
void setFuncs(glib.types.SourceFuncs funcs)

Sets the source functions (can be used to override default implementations) of an unattached source.

setName
void setName(string name)

Sets a name for the source, used in debugging and profiling. The name defaults to #NULL.

setPriority
void setPriority(int priority)

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.

setReadyTime
void setReadyTime(long readyTime)

Sets a #GSource to be dispatched when the given monotonic time is reached (or passed). If the monotonic time is in the past (as it always will be if ready_time is 0) then the source will be dispatched immediately.

setStaticName
void setStaticName(string name)

A variant of glib.source.Source.setName that does not duplicate the name, and can only be used with string literals.

Static functions

remove
bool remove(uint tag)

Removes the source with the given ID from the default main context. You must use glib.source.Source.destroy for sources added to a non-default main context.

removeByFuncsUserData
bool removeByFuncsUserData(glib.types.SourceFuncs funcs, void* userData)

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.

removeByUserData
bool removeByUserData(void* userData)

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.

setNameById
void setNameById(uint tag, string name)

Sets the name of a source using its ID.

Inherited Members

From Boxed

cInstancePtr
void* cInstancePtr;

Pointer to the C boxed value

getType
GType getType()

Get the GType of this boxed type.

gType
GType gType [@property getter]

Boxed GType property.

self
Boxed self()

Convenience method to return this cast to a type. For use in D with statements.

copy_
void* copy_()

Make a copy of the wrapped C boxed data.

boxedCopy
void* boxedCopy(void* cBoxed)

Copy a C boxed value using g_boxed_copy.

boxedFree
void boxedFree(void* cBoxed)

Free a C boxed value using g_boxed_free.