### Method

# Gio Cancellable source_new

since: 2.28

#### Declaration [src]

    GSource*
    g_cancellable_source_new (
      GCancellable* cancellable
    )

#### Description [src]

Creates a source that triggers if `cancellable` is cancelled and calls its callback of type `GCancellableSourceFunc`. This is primarily useful for attaching to another (non-cancellable) source with `g_source_add_child_source()` to add cancellability to it.

For convenience, you can call this with a `NULL` `GCancellable`, in which case the source will never trigger.

The new `GSource` will hold a reference to the `GCancellable`.

Available since: 2.28

#### Parameters

`cancellable`

  Type: `GCancellable`

  A `GCancellable`, or `NULL`.

  The argument can be `NULL`.

#### Return value

Type: `GSource`

The new `GSource`.

The caller of the method takes ownership of the returned data, and is responsible for freeing it.