GLib Reference

Event loop

Gtk4.GLib.pause_main_loopFunction
pause_main_loop(f)

Pauses the GLib event loop around a function. Restores the original state of the event loop after calling the function. This function does not pause the event loop if it is being run by a GApplication.

source
Gtk4.GLib.start_main_loopFunction
start_main_loop(wait=false)

If the default GLib main event loop is not already running, start a Julia task that runs it. Returns the task. If wait is true, it will block until the main loop starts running.

See also stop_main_loop.

source
Gtk4.GLib.stop_main_loopFunction
stop_main_loop(wait=false)

Stops the default GLib main loop after the next iteration. If wait is true, it will block until the main loop stops running.

Does not affect loop operation if GApplication's run() method is being used instead of GLib.start_main_loop().

See also start_main_loop.

source
Gtk4.GLib.@idle_addMacro
@idle_add(ex)

Create a function from an expression ex that will be called when there are no higher priority GTK events to be processed. This function can be used from any thread.

See also g_idle_add.

Related GTK function: g_idle_add()

source
Gtk4.GLib.g_idle_addFunction
g_idle_add(f, priority=PRIORITY_DEFAULT_IDLE)

Add a Julia function f that will be called when there are no higher priority GTK events to be processed. This function can be used from any thread. The optional priority argument, which is an integer, sets the priority of the event source (smaller is higher priority). The GLib main loop uses this priority value to decide what sources to handle next.

See also @idle_add.

Related GTK function: g_idle_add_full()

source
Gtk4.GLib.g_timeout_addFunction
g_timeout_add(f, interval, priority=PRIORITY_DEFAULT)

Add a function f that will be called every interval milliseconds by the GTK main loop. If the function returns true, it will be called again after another interval milliseconds. If it returns false it will not be called again. The optional priority argument, which is an integer, sets the priority of the event source (smaller is higher priority). The GLib main loop uses this priority value to decide what sources to handle next.

This function returns an event source ID that can be used with g_source_remove to stop the timeout externally.

Related GTK function: g_timeout_add()

source
Gtk4.GLib.g_source_removeFunction
g_source_remove(id::Integer)

Remove the event source identified by id from the GLib main loop. The id is returned by g_idle_add and g_timeout_add. The main loop reuses id's so care should be taken that the source intended to be removed is still active.

Related GTK function: g_source_remove()

source
Gtk4.GLib.set_uv_loop_integrationFunction
set_uv_loop_integration(s = "auto")

Change Gtk4.jl's libuv loop integration setting. The argument s should be "auto" to use Gtk4.jl's default setting or "enabled" or "disabled" to override this. This setting will take effect after restarting Julia.

Enabling libuv loop integration may improve REPL response on some platforms (Mac) but negatively impacts multithreaded performance. This function has no effect when running on Windows.

source
Base.runFunction
run(app::GApplication)

Calls g_application_run, starting the main loop. If the loop is already running, this function will stop it and emit a warning before starting the application loop.

source

REPL helper functions

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
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

Properties

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.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
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

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

Actions and action groups

Gtk4.GLib.add_actionFunction
add_action(m::GActionMap, name::AbstractString, parameter::Type{T}, handler::Function)

Add an action with name and a parameter of type T to a GActionMap. Also connect a handler for the action's "activate" signal.

source
add_action(m::GActionMap, name::AbstractString, handler::Function)

Add an action with name to a GActionMap. Also connect a handler for the action's "activate" signal.

source
Gtk4.GLib.add_stateful_actionFunction
add_stateful_action(m::GActionMap, name::AbstractString, parameter::Type{T}, initial_state, handler::Function)

Add a stateful action with name, a parameter of type T, and an initial state to a GActionMap. Also connect a handler for the action's "change-state" signal.

source
add_stateful_action(m::GActionMap, name::AbstractString, initial_state, handler::Function)

Add a stateful action with name and an initial state to a GActionMap. Also connect a handler for the action's "change-state" signal.

source

GObject type system

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