Gio.Initable.prototype.init

function init(cancellable: Gio.Cancellable): Boolean {
    // Gjs wrapper for g_initable_init()
}
  

Initializes the object implementing the interface.

The object must be initialized before any real use after initial construction, either with this function or Gio.AsyncInitable.prototype.init_async.

Implementations may also support cancellation. If cancellable is not null, then initialization can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.cancelled will be returned. If cancellable is not null and the object doesn't support cancellable initialization the error Gio.IOErrorEnum.not_supported will be returned.

If the object is not initialized, or initialization returns with an error, then all operations on the object except GObject.Object.prototype.ref and GObject.Object.prototype.unref are considered to be invalid, and have undefined behaviour. See the [introduction][ginitable] for more details.

Implementations of this method must be idempotent, i.e. multiple calls to this function with the same argument should return the same results. Only the first call initializes the object, further calls return the result of the first call. This is so that it's safe to implement the singleton pattern in the GObject constructor function.

Since 2.22

cancellable

optional Gio.Cancellable object, null to ignore.

Returns

true if successful. If an error has occurred, this function will return false and set @error appropriately if present.