GLib Reference
Event loop
Gtk4.GLib.is_loop_running
— Functionis_loop_running()
Return true if the default GLib main event loop is running.
Related GTK function: g_main_depth
()
Gtk4.GLib.pause_main_loop
— Functionpause_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
.
Gtk4.GLib.start_main_loop
— Functionstart_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
.
Gtk4.GLib.stop_main_loop
— Functionstop_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
.
Gtk4.GLib.@idle_add
— Macro@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
()
Gtk4.GLib.g_idle_add
— Functiong_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
()
Gtk4.GLib.g_timeout_add
— Functiong_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
()
Gtk4.GLib.g_source_remove
— Functiong_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
()
Gtk4.GLib.get_uv_loop_integration
— Functionget_uv_loop_integration()
Get Gtk4.jl's libuv loop integration setting: "auto", "enabled", or "disabled".
See also set_uv_loop_integration
.
Gtk4.GLib.set_uv_loop_integration
— Functionset_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.
Gtk4.GLib.is_uv_loop_integration_enabled
— Functionis_uv_loop_integration_enabled()
Get whether Gtk4.jl's libuv loop integration is enabled.
See also set_uv_loop_integration
.
Base.run
— Functionrun(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.
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.propertyinfo
— Functionpropertyinfo(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.
Gtk4.GLib.gtk_propertynames
— Functiongtk_propertynames(w::GObject)
Get a list of property names for the GObject w
.
Gtk4.GLib.signalnames
— Functionsignalnames(::Type{T}) where T <: GObject
Returns a list of the names of supported signals for T.
Gtk4.GLib.signal_return_type
— Functionsignal_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
).
Gtk4.GLib.signal_argument_types
— Functionsignal_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
).
Properties
Gtk4.GLib.on_notify
— Functionon_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
.
Gtk4.GLib.bind_property
— Functionbind_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
Gtk4.GLib.unbind_property
— Functionunbind_property(b::GBinding)
Releases a binding created by bind_property
.
See also bind_property
.
Related GTK function: g_binding_unbind
Gtk4.GLib.setproperties!
— Functionsetproperties!(obj::GObject; kwargs...)
Set many GObject
properties at once using keyword arguments. For example for a GtkWindow
, setproperties!(win; title="New title", visible=true)
.
Gtk4.GLib.set_gtk_property!
— Functionset_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
.
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
.
Gtk4.GLib.get_gtk_property
— Functionget_gtk_property(w::GObject, name::AbstractString, ::Type{T})
Get a GObject property's value as type T
.
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!
.
Signals
Gtk4.GLib.signal_handler_is_connected
— Functionsignal_handler_is_connected(widget, id) -> Bool
Return true
/false
depending on whether widget
has a connected signal handler with the given id
.
Gtk4.GLib.signal_handler_disconnect
— Functionsignal_handler_disconnect(w::GObject, id)
Disconnect a signal handler from a widget w
by its id
.
Gtk4.GLib.signal_handler_block
— Functionsignal_handler_block(w::GObject, id)
Temporarily block a signal handler from running on a GObject
instance.
See also signal_handler_unblock
.
Gtk4.GLib.signal_handler_unblock
— Functionsignal_handler_block(w::GObject, id)
Unblock a signal handler that had been previously blocked.
See also signal_handler_block
.
Gtk4.GLib.signal_emit
— Functionsignal_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.
Gtk4.GLib.waitforsignal
— Functionwaitforsignal(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.
Actions and action groups
Gtk4.GLib.GSimpleAction
— TypeSee the GTK docs.
Gtk4.GLib.add_action
— Functionadd_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.
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.
Gtk4.GLib.add_stateful_action
— Functionadd_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.
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.
Gtk4.GLib.set_state
— Functionset_state(m::GSimpleAction, v)
Set the state of a stateful action.
GObject type system
Gtk4.GLib.g_type
— Functiong_type(x)
Get the GType corresponding to a Julia type or object. See GLib documentation for more information.
Gtk4.GLib.find_leaf_type
— Functionfind_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
.