GObject Reference

The GObject library contains GLib's type system, including the GObject type, subclasses of which can include properties and signals.

Properties

Properties of GObject are mapped onto Julia properties.

Gtk4.GLib.set_gtk_property!Function
set_gtk_property!(w::GObject, name, ::Type{T}, value)

Set a GObject property name (which can be a string or symbol) to value converted to type T.

source
set_gtk_property!(w::GObject, name, value)

Set a GObject property name (which can be a string or symbol) to value. The type of value will be converted to match the property type, if possible.

GObject properties are mapped onto Julia instance properties, so note that this function is equivalent to the more convenient syntax w.name = value.

See also get_gtk_property.

source
Gtk4.GLib.get_gtk_propertyFunction
get_gtk_property(w::GObject, name::AbstractString, ::Type{T})

Get a GObject property's value as type T.

source
get_gtk_property(w::GObject, name::AbstractString)

Get a GObject property's value. The type of the returned value depends on the property, so this function's output is type unstable.

GObject properties are mapped onto Julia instance properties, so this function is equivalent to the syntax w.name.

See also set_gtk_property!.

source
Gtk4.GLib.bind_propertyFunction
bind_property(source::GObject, source_property, target::GObject, target_property, flags = BindingFlags_DEFAULT)

Creates a binding between source_property on source and target_property on target. When source_property is changed, target_property will be updated to the same value. Returns a GBinding object that can be used to release the binding using unbind_property.

See also unbind_property.

Related GTK function: g_object_bind_property

source
Gtk4.GLib.setproperties!Function
setproperties!(obj::GObject; kwargs...)

Set many GObject properties at once using keyword arguments. For example for a GtkWindow, setproperties!(win; title="New title", visible=true).

source

These are functions that are intended to be used in the REPL to look up information about GObjects and their properties and signals.

Gtk4.GLib.propertyinfoFunction
propertyinfo(w::GObject, name)

Prints information about a property of the GObject w, including a brief description, its type, its default value, and its current value.

source

Signals

Gtk4.GLib.signal_emitFunction
signal_emit(w::GObject, sig::AbstractStringLike, ::Type{RT}, args...) where RT

Cause an object signal to be emitted. The return type RT and the correct number of arguments (of the correct type) must be provided. The argument list should exclude the user_data argument.

source
Gtk4.GLib.waitforsignalFunction
waitforsignal(obj::GObject, signal)

Returns when a GObject's signal is emitted. Can be used to wait for a window to be closed. This function should only be used for signals that return nothing, with one exception: the "close-request" signal of GtkWindow.

source
Gtk4.GLib.on_notifyFunction
on_notify(f, object::GObject, property, user_data = object, after = false)

Connect a callback f to the object's "notify::property" signal that will be called whenever the property changes. The callback signature should be f(::Ptr, param::Ptr{GParamSpec}, user_data) and the function should return nothing.

source
Gtk4.GLib.signalnamesFunction
signalnames(::Type{T}) where T <: GObject

Returns a list of the names of supported signals for T.

source
Gtk4.GLib.signal_return_typeFunction
signal_return_type(::Type{T}, name::Symbol) where T <: GObject

Gets the return type for the callback for the signal name of a GObject type (for example GtkWidget).

source
Gtk4.GLib.signal_argument_typesFunction
signal_argument_types(::Type{T}, name::Symbol) where T <: GObject

Gets the argument types for the callback for the signal name of a GObject type (for example GtkWidget).

source

GObject type system

These functions are not typically needed by most users.

Gtk4.GLib.find_leaf_typeFunction
find_leaf_type(hnd::Ptr{T}) where T <: GObject

For a pointer to a GObject, look up its type in the GType system and return the Julia leaf type that best matches it. For types supported by Gtk4, for example GtkWindow, this will be the leaf type GtkWindowLeaf. Some types defined in GTK4 and other libraries are not exported. In this case, the nearest parent type supported by the Julia package will be returned. For example, objects in GIO that implement the GFile interface are returned as GObjectLeaf.

source