### Struct

# GLib Source

#### Description [src]

    struct GSource {
      /* No available fields */
    }

The `GSource` struct is an opaque data type representing an event source.

#### Constructors

###### g_source_new

Creates a new `GSource` structure.

#### Functions

###### g_source_remove

Removes the source with the given ID from the default main context.

###### g_source_remove_by_funcs_user_data

Removes a source from the default main loop context given the source functions and user data.

###### g_source_remove_by_user_data

Removes a source from the default main loop context given the user data for the callback.

###### g_source_set_name_by_id

Sets the name of a source using its ID.

since: 2.26

#### Instance methods

###### g_source_add_child_source

Adds `child_source` to `source` as a ‘polled’ source.

since: 2.28

###### g_source_add_poll

Adds a file descriptor to the set of file descriptors polled for this source.

###### g_source_add_unix_fd

Monitors `fd` for the IO events in `events`.

since: 2.36

###### g_source_attach

Adds a `GSource` to a `context` so that it will be executed within that context.

###### g_source_destroy

Removes a source from its `GMainContext`, if any, and marks it as destroyed.

###### g_source_dup_context

Gets a reference to the `GMainContext` with which the source is associated.

since: 2.86

###### g_source_get_can_recurse

Checks whether a source is allowed to be called recursively.

###### g_source_get_context

Gets the `GMainContext` with which the source is associated.

###### g_source_get_current_time

This function ignores `source` and is otherwise the same as `g_get_current_time()`.

deprecated: 2.28

###### g_source_get_id

Returns the numeric ID for a particular source.

###### g_source_get_name

Gets a name for the source, used in debugging and profiling.

since: 2.26

###### g_source_get_priority

Gets the priority of a source.

###### g_source_get_ready_time

Gets the ‘ready time’ of `source`, as set by `g_source_set_ready_time()`.

###### g_source_get_time

Gets the time to be used when checking this source.

since: 2.28

###### g_source_is_destroyed

Returns whether `source` has been destroyed.

since: 2.12

###### g_source_modify_unix_fd

Updates the event mask to watch for the file descriptor identified by `tag`.

since: 2.36

###### g_source_query_unix_fd

Queries the events reported for the file descriptor corresponding to `tag` on `source` during the last poll.

since: 2.36

###### g_source_ref

Increases the reference count on a source by one.

###### g_source_remove_child_source

Detaches `child_source` from `source` and destroys it.

since: 2.28

###### g_source_remove_poll

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

###### g_source_remove_unix_fd

Reverses the effect of a previous call to `g_source_add_unix_fd()`.

since: 2.36

###### g_source_set_callback

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

###### g_source_set_callback_indirect

Sets the callback function storing the data as a reference counted callback ‘object’.

###### g_source_set_can_recurse

Sets whether a source can be called recursively.

###### g_source_set_dispose_function

Set `dispose` as dispose function on `source`.

since: 2.64

###### g_source_set_funcs

Sets the source functions of an unattached source.

since: 2.12

###### g_source_set_name

Sets a name for the source, used in debugging and profiling.

since: 2.26

###### g_source_set_priority

Sets the priority of a source.

###### g_source_set_ready_time

Sets a source to be dispatched when the given monotonic time is reached (or passed).

since: 2.36

###### g_source_set_static_name

A variant of `g_source_set_name()` that does not duplicate the `name`, and can only be used with string literals.

since: 2.70

###### g_source_unref

Decreases the reference count of a source by one.