From d2bcc0165555dd9d05f7794e7b08fd4a73c51226 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sat, 25 May 2024 17:45:26 +0000 Subject: [PATCH] build based on 4b8a3d4 --- previews/PR68/diff3to4/index.html | 2 +- previews/PR68/doc/GLib_reference/index.html | 2 +- .../PR68/doc/GLib_types_reference/index.html | 4 ++-- .../PR68/doc/Gtk4_types_reference/index.html | 4 ++-- .../PR68/doc/constants_reference/index.html | 2 +- previews/PR68/doc/preferences/index.html | 2 +- previews/PR68/doc/reference/index.html | 18 +++++++++--------- previews/PR68/howto/async/index.html | 2 +- previews/PR68/howto/nonreplusage/index.html | 2 +- previews/PR68/howto/sysimage/index.html | 2 +- previews/PR68/index.html | 2 +- previews/PR68/manual/actions/index.html | 2 +- previews/PR68/manual/builder/index.html | 2 +- previews/PR68/manual/buttons/index.html | 2 +- previews/PR68/manual/canvas/index.html | 2 +- previews/PR68/manual/combobox/index.html | 2 +- previews/PR68/manual/dialogs/index.html | 2 +- previews/PR68/manual/display/index.html | 2 +- previews/PR68/manual/gettingStarted/index.html | 2 +- previews/PR68/manual/keyevents/index.html | 2 +- previews/PR68/manual/layout/index.html | 2 +- previews/PR68/manual/listtreeview/index.html | 2 +- previews/PR68/manual/methods/index.html | 2 +- previews/PR68/manual/properties/index.html | 2 +- previews/PR68/manual/signals/index.html | 2 +- previews/PR68/manual/textwidgets/index.html | 2 +- previews/PR68/search/index.html | 2 +- 27 files changed, 37 insertions(+), 37 deletions(-) diff --git a/previews/PR68/diff3to4/index.html b/previews/PR68/diff3to4/index.html index 27f14d0b..9ddd3ed7 100644 --- a/previews/PR68/diff3to4/index.html +++ b/previews/PR68/diff3to4/index.html @@ -1,2 +1,2 @@ -Gtk.jl to Gtk4.jl · Gtk4.jl

Differences between Gtk.jl and Gtk4.jl

Gtk4.jl builds on and is very similar to Gtk.jl. Here is a summary of what's different.

Properties

GObject properties can still be set and accessed using get_gtk_property and set_gtk_property!. However, properties are now mapped onto Julia properties, so one can set a window title using win.title = "My title". Also, the submodule GAccessor no longer exists. In Gtk4.jl, getter and setter methods are in the main Gtk4 module, but most are not exported. Whereas in Gtk.jl one uses GAccessor.title(win, "My title") to set the title, in Gtk4.jl the equivalent is Gtk4.title(win, "My title").

Constants, enums, and flags

GTK constants in Gtk4.jl are in the main module instead of a Constants submodule.

In Gtk.jl, GTK's enum and flags constants are turned into integers. In Gtk4.jl, these are now mapped onto Julia enums, specifically the implementations CEnum.jl for enums and BitFlags.jl for flags. This improves understandability when a function returns an enum or flag, but the downside is the sometimes extreme length of the enum's name. To mitigate this, convert methods are defined for commonly used enums so that shorter symbols can be used instead of the full enum name. For example, :h can be used instead of Gtk4.Orientation_HORIZONTAL in GtkBox(orientation, spacing).

G_ contains automatically generated methods

In Gtk.jl, the submodule Gtk.GAccessor contains getter and setter methods, which often correspond to object properties. In Gtk4.jl, the submodule Gtk4.G_ contains automatically generated methods, which include all methods in GAccessor and many more. These methods directly call the C functions in libgtk and thus use 0-based indexing. Where possible, they translate between Julia types and C types, for example converting nothing to C_NULL and vice versa.

For consistency, the getter and setter methods in G_ keep their full names, including "set" and "get". For example, to set the title of a window in Gtk4.jl use G_.set_title(w, "text") rather than GAccessor.title(w, "text") as in Gtk.jl.

GObject and struct names

The equivalent of Gtk.ShortNames doesn't exist. All GObject types are mapped onto Julia types with the same name. Leaving out the namespace, as is done in the Python pygobject bindings, would have led to name collisions between Gtk types and Julia types or between Gtk and other GObject libraries.

No showall

In GTK 4, widgets are shown by default, so showall does not exist. Controlling a widget's initial visibility can be done using the visible property.

No GtkContainer

In GTK 4, GtkContainer has been removed and most widgets derive directly from GtkWidget. Each class that can contain child widgets has its own functions for adding and/or removing them. In Gtk4.jl, collection interface methods like push! have been defined for containers that hold many widgets, such as GtkBox. For widgets that have one child, such as GtkWindow, getindex and setindex! have been defined, so that one can set a child widget using window[] = child.

Events

Events such as button presses are handled through "event controllers" in GTK 4.

Dialogs

Dialogs no longer have a run method that takes over the GLib main loop while waiting for the user's response.

GLib event loop

The GLib main loop starts automatically if Julia is in an interactive session. If not, you will have to start it by calling start_main_loop or by creating a GtkApplication and calling run (see the example application.jl).

MutableTypes and GValue

All uses of mutable from Gtk.jl's GLib.MutableTypes should be replaced by Julia's Ref. The type of a GValue can be set using settype! rather than setindex!.

More information

The GTK docs have a migration guide with detailed recommendations for migrating C code from GTK version 3 to version 4. Much of that advice applies to Julia code.

+Gtk.jl to Gtk4.jl · Gtk4.jl

Differences between Gtk.jl and Gtk4.jl

Gtk4.jl builds on and is very similar to Gtk.jl. Here is a summary of what's different.

Properties

GObject properties can still be set and accessed using get_gtk_property and set_gtk_property!. However, properties are now mapped onto Julia properties, so one can set a window title using win.title = "My title". Also, the submodule GAccessor no longer exists. In Gtk4.jl, getter and setter methods are in the main Gtk4 module, but most are not exported. Whereas in Gtk.jl one uses GAccessor.title(win, "My title") to set the title, in Gtk4.jl the equivalent is Gtk4.title(win, "My title").

Constants, enums, and flags

GTK constants in Gtk4.jl are in the main module instead of a Constants submodule.

In Gtk.jl, GTK's enum and flags constants are turned into integers. In Gtk4.jl, these are now mapped onto Julia enums, specifically the implementations CEnum.jl for enums and BitFlags.jl for flags. This improves understandability when a function returns an enum or flag, but the downside is the sometimes extreme length of the enum's name. To mitigate this, convert methods are defined for commonly used enums so that shorter symbols can be used instead of the full enum name. For example, :h can be used instead of Gtk4.Orientation_HORIZONTAL in GtkBox(orientation, spacing).

G_ contains automatically generated methods

In Gtk.jl, the submodule Gtk.GAccessor contains getter and setter methods, which often correspond to object properties. In Gtk4.jl, the submodule Gtk4.G_ contains automatically generated methods, which include all methods in GAccessor and many more. These methods directly call the C functions in libgtk and thus use 0-based indexing. Where possible, they translate between Julia types and C types, for example converting nothing to C_NULL and vice versa.

For consistency, the getter and setter methods in G_ keep their full names, including "set" and "get". For example, to set the title of a window in Gtk4.jl use G_.set_title(w, "text") rather than GAccessor.title(w, "text") as in Gtk.jl.

GObject and struct names

The equivalent of Gtk.ShortNames doesn't exist. All GObject types are mapped onto Julia types with the same name. Leaving out the namespace, as is done in the Python pygobject bindings, would have led to name collisions between Gtk types and Julia types or between Gtk and other GObject libraries.

No showall

In GTK 4, widgets are shown by default, so showall does not exist. Controlling a widget's initial visibility can be done using the visible property.

No GtkContainer

In GTK 4, GtkContainer has been removed and most widgets derive directly from GtkWidget. Each class that can contain child widgets has its own functions for adding and/or removing them. In Gtk4.jl, collection interface methods like push! have been defined for containers that hold many widgets, such as GtkBox. For widgets that have one child, such as GtkWindow, getindex and setindex! have been defined, so that one can set a child widget using window[] = child.

Events

Events such as button presses are handled through "event controllers" in GTK 4.

Dialogs

Dialogs no longer have a run method that takes over the GLib main loop while waiting for the user's response.

GLib event loop

The GLib main loop starts automatically if Julia is in an interactive session. If not, you will have to start it by calling start_main_loop or by creating a GtkApplication and calling run (see the example application.jl).

MutableTypes and GValue

All uses of mutable from Gtk.jl's GLib.MutableTypes should be replaced by Julia's Ref. The type of a GValue can be set using settype! rather than setindex!.

More information

The GTK docs have a migration guide with detailed recommendations for migrating C code from GTK version 3 to version 4. Much of that advice applies to Julia code.

diff --git a/previews/PR68/doc/GLib_reference/index.html b/previews/PR68/doc/GLib_reference/index.html index dd6726f0..9f2256d1 100644 --- a/previews/PR68/doc/GLib_reference/index.html +++ b/previews/PR68/doc/GLib_reference/index.html @@ -1,2 +1,2 @@ -GLib Reference · Gtk4.jl

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, it will stop it 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
+GLib Reference · Gtk4.jl

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, it will stop it 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
diff --git a/previews/PR68/doc/GLib_types_reference/index.html b/previews/PR68/doc/GLib_types_reference/index.html index b0db7224..bc784f60 100644 --- a/previews/PR68/doc/GLib_types_reference/index.html +++ b/previews/PR68/doc/GLib_types_reference/index.html @@ -1,3 +1,3 @@ -GLib Types · Gtk4.jl

GLib Types

Gtk4.GLib.GSimpleActionMethod
GSimpleAction(name::AbstractString, 
-              [parameter_type::Type{T}, [initial_state]]; kwargs...) where T

Create an action with a name and optionally a parameter_type from a Julia type (only a few simple types are supported) and an initial_state. If initial_state is not provided, the action will be stateless.

Keyword arguments set the action's GObject properties.

source
+GLib Types · Gtk4.jl

GLib Types

Gtk4.GLib.GSimpleActionMethod
GSimpleAction(name::AbstractString, 
+              [parameter_type::Type{T}, [initial_state]]; kwargs...) where T

Create an action with a name and optionally a parameter_type from a Julia type (only a few simple types are supported) and an initial_state. If initial_state is not provided, the action will be stateless.

Keyword arguments set the action's GObject properties.

source
diff --git a/previews/PR68/doc/Gtk4_types_reference/index.html b/previews/PR68/doc/Gtk4_types_reference/index.html index 9d727961..092e46f2 100644 --- a/previews/PR68/doc/Gtk4_types_reference/index.html +++ b/previews/PR68/doc/Gtk4_types_reference/index.html @@ -1,4 +1,4 @@ -Gtk4 Types · Gtk4.jl

Gtk4 Types

Types

Gtk4.GdkMemoryTextureType
GdkMemoryTexture(img::Array, tp = true)

Creates a GdkMemoryTexture, copying an image array. If tp is set to true, the image will be transposed before copying so that the texture's orientation when displayed by GTK widgets like GtkPicture will match how the image is displayed in Julia apps like ImageShow.

source
Gtk4.GtkApplicationWindowMethod
GtkApplicationWindow(app::GtkApplication, title::AbstractString; kwargs...)

Create an empty GtkApplicationWindow for a GtkApplication app and a title. Keyword arguments can be used to set GObject properties.

source
Gtk4.GtkBoxType
GtkBox(orientation::Symbol, spacing::Integer=0; kwargs...)

Create and return a GtkBox widget. The orientation argument can be :h for horizontal, or :v for vertical. The spacing argument controls the spacing between child widgets in pixels. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkBuilderType
GtkBuilder(; kwargs...)
+Gtk4 Types · Gtk4.jl

Gtk4 Types

Types

Gtk4.GdkMemoryTextureType
GdkMemoryTexture(img::Array, tp = true)

Creates a GdkMemoryTexture, copying an image array. If tp is set to true, the image will be transposed before copying so that the texture's orientation when displayed by GTK widgets like GtkPicture will match how the image is displayed in Julia apps like ImageShow.

source
Gtk4.GtkApplicationWindowMethod
GtkApplicationWindow(app::GtkApplication, title::AbstractString; kwargs...)

Create an empty GtkApplicationWindow for a GtkApplication app and a title. Keyword arguments can be used to set GObject properties.

source
Gtk4.GtkBoxType
GtkBox(orientation::Symbol, spacing::Integer=0; kwargs...)

Create and return a GtkBox widget. The orientation argument can be :h for horizontal, or :v for vertical. The spacing argument controls the spacing between child widgets in pixels. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkBuilderType
GtkBuilder(; kwargs...)
 GtkBuilder(filename::AbstractString; kwargs...)
-GtkBuilder(string::AbstractString, _length::Integer; kwargs...)

Create a GtkBuilder object. If filename is given (the constructor with a single string argument), XML describing the user interface will be read from a file. If string and length are given (the constructor with a string and an integer), XML will be read from a string of a certain length. If length is -1 the full string will be used.

See the GTK docs.

source
Gtk4.GtkButtonMethod
GtkButton(w::GtkWidget)

Create a GtkButton and add a widget w as its child.

source
Gtk4.GtkButtonMethod
GtkButton(s::Symbol, str::AbstractString)

Create and return a GtkButton widget.

If s is :label, create a button with a string label.

If s is :mnemonic, create a button with a string label, where the first letter preceded by an underscore character defines a mnemonic. Pressing Alt and that letter activates the button.

If s is :icon_name, create a button with an icon from the current icon theme.

Related GTK functions: gtk_button_new_with_label(), gtk_button_new_with_mnemonic(), gtk_button_new_from_icon_name()

source
Gtk4.GtkCenterBoxMethod
GtkCenterBox(orientation::Symbol; kwargs...)

Create and return a GtkCenterBox widget. The orientation argument can be :h for horizontal, or :v for vertical. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkDropDownMethod
GtkDropDown(a::AbstractArray; kwargs...)

Create a dropdown widget with a GtkStringList as its model. The model will be populated with the elements of a converted to strings. Keyword arguments set GObject properties.

source
Gtk4.GtkDropDownMethod
GtkDropDown(; kwargs...)

Create a dropdown widget with no model (and thus no options to selected). A model can be added using model. Keyword arguments set GObject properties.

source
Gtk4.GtkFileDialogMethod
GtkFileDialog(; kwargs...)

Selected keyword arguments

  • accept_label: the text to show on the dialog's accept button
  • default_filter: the GtkFileFilter initially active in the file dialog
  • filters: a GListModel of file filters
  • initial_name: the filename or directory that is initially selected in the file chooser dialog
  • title: the title of the dialog
  • modal: whether the dialog is modal
source
Gtk4.GtkFrameType
GtkFrame(w::GtkWidget, label=nothing; kwargs...)

Create a GtkFrame with an optional string label and add w as its child. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkFrameMethod
GtkFrame(label=nothing; kwargs...)

Create a GtkFrame, a layout widget that can hold a single child widget, with an optional string label. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkGridViewType
GtkGridView(model=nothing; kwargs...)

Create a GtkGridView widget, optionally with a model. Keyword arguments set GObject properties.

source
Gtk4.GtkListViewType
GtkListView(model=nothing; kwargs...)

Create a GtkListView widget, optionally with a model. Keyword arguments set GObject properties.

source
Gtk4.GtkOverlayMethod
GtkOverlay(w=nothing; kwargs...)

Create a GtkOverlay, a layout widget that holds one main child and other child "overlay" widgets that are drawn on top of the main child. The main child can be set using the argument w.

source
Gtk4.GtkPanedMethod
GtkPaned(orientation::Symbol; kwargs...)

Create and return a GtkPaned widget. The orientation argument can be :h for horizontal, or :v for vertical. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkScaleMethod
GtkScale(orientation, [scale::AbstractRange]; kwargs...)

Create a scale widget with horizontal (:h) or vertical (:v) orientation and an optional range. Keyword arguments can be used to set properties.

source
Gtk4.GtkSignalListItemFactoryMethod
GtkSignalListItemFactory(setup_cb, bind_cb)

Create a GtkSignalListItemFactory and immediately connect "setup" and "bind" callback functions setup_cb and bind_cb, respectively.

source
Gtk4.GtkStringListMethod
GtkStringList()

Create an empty GtkStringList, which implements the GListModel interface and holds an array of strings.

source
Gtk4._GtkTextIterMethod
_GtkTextIter(text::GtkTextBuffer, char_offset::Integer)

Creates a _GtkTextIter with offset char_offset (one-based index).

source
+GtkBuilder(string::AbstractString, _length::Integer; kwargs...)

Create a GtkBuilder object. If filename is given (the constructor with a single string argument), XML describing the user interface will be read from a file. If string and length are given (the constructor with a string and an integer), XML will be read from a string of a certain length. If length is -1 the full string will be used.

See the GTK docs.

source
Gtk4.GtkButtonMethod
GtkButton(w::GtkWidget)

Create a GtkButton and add a widget w as its child.

source
Gtk4.GtkButtonMethod
GtkButton(s::Symbol, str::AbstractString)

Create and return a GtkButton widget.

If s is :label, create a button with a string label.

If s is :mnemonic, create a button with a string label, where the first letter preceded by an underscore character defines a mnemonic. Pressing Alt and that letter activates the button.

If s is :icon_name, create a button with an icon from the current icon theme.

Related GTK functions: gtk_button_new_with_label(), gtk_button_new_with_mnemonic(), gtk_button_new_from_icon_name()

source
Gtk4.GtkCenterBoxMethod
GtkCenterBox(orientation::Symbol; kwargs...)

Create and return a GtkCenterBox widget. The orientation argument can be :h for horizontal, or :v for vertical. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkDropDownMethod
GtkDropDown(a::AbstractArray; kwargs...)

Create a dropdown widget with a GtkStringList as its model. The model will be populated with the elements of a converted to strings. Keyword arguments set GObject properties.

source
Gtk4.GtkDropDownMethod
GtkDropDown(; kwargs...)

Create a dropdown widget with no model (and thus no options to selected). A model can be added using model. Keyword arguments set GObject properties.

source
Gtk4.GtkFileDialogMethod
GtkFileDialog(; kwargs...)

Selected keyword arguments

  • accept_label: the text to show on the dialog's accept button
  • default_filter: the GtkFileFilter initially active in the file dialog
  • filters: a GListModel of file filters
  • initial_name: the filename or directory that is initially selected in the file chooser dialog
  • title: the title of the dialog
  • modal: whether the dialog is modal
source
Gtk4.GtkFrameType
GtkFrame(w::GtkWidget, label=nothing; kwargs...)

Create a GtkFrame with an optional string label and add w as its child. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkFrameMethod
GtkFrame(label=nothing; kwargs...)

Create a GtkFrame, a layout widget that can hold a single child widget, with an optional string label. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkGridViewType
GtkGridView(model=nothing; kwargs...)

Create a GtkGridView widget, optionally with a model. Keyword arguments set GObject properties.

source
Gtk4.GtkListViewType
GtkListView(model=nothing; kwargs...)

Create a GtkListView widget, optionally with a model. Keyword arguments set GObject properties.

source
Gtk4.GtkOverlayMethod
GtkOverlay(w=nothing; kwargs...)

Create a GtkOverlay, a layout widget that holds one main child and other child "overlay" widgets that are drawn on top of the main child. The main child can be set using the argument w.

source
Gtk4.GtkPanedMethod
GtkPaned(orientation::Symbol; kwargs...)

Create and return a GtkPaned widget. The orientation argument can be :h for horizontal, or :v for vertical. Keyword arguments allow you to set GObject properties.

source
Gtk4.GtkScaleMethod
GtkScale(orientation, [scale::AbstractRange]; kwargs...)

Create a scale widget with horizontal (:h) or vertical (:v) orientation and an optional range. Keyword arguments can be used to set properties.

source
Gtk4.GtkSignalListItemFactoryMethod
GtkSignalListItemFactory(setup_cb, bind_cb)

Create a GtkSignalListItemFactory and immediately connect "setup" and "bind" callback functions setup_cb and bind_cb, respectively.

source
Gtk4.GtkStringListMethod
GtkStringList()

Create an empty GtkStringList, which implements the GListModel interface and holds an array of strings.

source
Gtk4._GtkTextIterMethod
_GtkTextIter(text::GtkTextBuffer, char_offset::Integer)

Creates a _GtkTextIter with offset char_offset (one-based index).

source
diff --git a/previews/PR68/doc/constants_reference/index.html b/previews/PR68/doc/constants_reference/index.html index bfc9f65f..9829e08d 100644 --- a/previews/PR68/doc/constants_reference/index.html +++ b/previews/PR68/doc/constants_reference/index.html @@ -1,2 +1,2 @@ -Constants · Gtk4.jl

Constants

Gtk4

Gtk4.GdkPixbufLib

Gtk4.GLib

+Constants · Gtk4.jl

Constants

Gtk4

Gtk4.GdkPixbufLib

Gtk4.GLib

diff --git a/previews/PR68/doc/preferences/index.html b/previews/PR68/doc/preferences/index.html index 1dc7ea8c..706194ac 100644 --- a/previews/PR68/doc/preferences/index.html +++ b/previews/PR68/doc/preferences/index.html @@ -1,4 +1,4 @@ Preference Settings · Gtk4.jl

Preference Settings

Here is a list of preferences for Gtk4 that can be set using Preferences.jl.

EGL directories (Linux & Wayland)

GTK4 has a few different rendering backends, and by default on Linux it uses one based on OpenGL. Gtk4.jl uses JLL based libraries rather than the ones that come with your Linux distribution, and on Wayland, unfortunately, unless you tell libglvnd_jll where to find libEGL, it will be unable to find an OpenGL provider. As a result, on Wayland a Cairo-based fallback backend will be used. This may work fine for you, but it means that GtkGLArea will not work. We can tell libglvnd_jll where to find libEGL by setting the environment variable __EGL_VENDOR_LIBRARY_DIRS. See here for details.

You can point libglvnd_jll to a libEGL location using the preference "EGL_vendorlib_dirs":

using Gtk4
 Gtk4.set_EGL_vendorlib_dirs("/usr/share/glvnd/egl_vendor.d")
-[ Info: Setting will take effect after restarting Julia.

where "/usr/share/glvnd/egl_vendor.d" is a typical location for Mesa's libEGL (this should be modified if it's somewhere else on your distribution). Other vendor-provided libraries may be in other locations, and a colon-separated list of directories can be used for that situation. Note that this has only been tested for the Mesa-provided libEGL on Fedora and Ubuntu.

UV loop integration

GTK relies on an event loop (provided by GLib) to process and handle mouse and keyboard events, while Julia relies on its own event loop (provided by libuv) for IO, timers, etc. Interactions between these event loops can cause REPL lag and can interfere with multithreading performance. Explicit integration of the two loops by creating a libuv event source in the GLib main loop is currently disabled because it caused slowdowns in multithreaded code. On some Macs, unfortunately, REPL lag occurs without this explicit integration (explicit in the sense that libuv can insert events in the GLib main loop through its own GSource).

By default, explicit GLib loop integration is only turned on on Macs in an interactive session. You can override this using the preference "uv_loop_integration". If it's set to "enabled", the libuv GSource will be created. If it's set to "disabled", the libuv GSource will not be created, even on Macs in an interactive session. The setting "auto" uses the default behavior. The functions GLib.set_uv_loop_integration and GLib.get_uv_loop_integration can be used to set and get the preference.

+[ Info: Setting will take effect after restarting Julia.

where "/usr/share/glvnd/egl_vendor.d" is a typical location for Mesa's libEGL (this should be modified if it's somewhere else on your distribution). Other vendor-provided libraries may be in other locations, and a colon-separated list of directories can be used for that situation. Note that this has only been tested for the Mesa-provided libEGL on Fedora and Ubuntu.

UV loop integration

GTK relies on an event loop (provided by GLib) to process and handle mouse and keyboard events, while Julia relies on its own event loop (provided by libuv) for IO, timers, etc. Interactions between these event loops can cause REPL lag and can interfere with multithreading performance. Explicit integration of the two loops by creating a libuv event source in the GLib main loop is currently disabled because it caused slowdowns in multithreaded code. On some Macs, unfortunately, REPL lag occurs without this explicit integration (explicit in the sense that libuv can insert events in the GLib main loop through its own GSource).

By default, explicit GLib loop integration is only turned on on Macs in an interactive session. You can override this using the preference "uv_loop_integration". If it's set to "enabled", the libuv GSource will be created. If it's set to "disabled", the libuv GSource will not be created, even on Macs in an interactive session. The setting "auto" uses the default behavior. The functions GLib.set_uv_loop_integration and GLib.get_uv_loop_integration can be used to set and get the preference.

diff --git a/previews/PR68/doc/reference/index.html b/previews/PR68/doc/reference/index.html index c500c0f0..2d48cc17 100644 --- a/previews/PR68/doc/reference/index.html +++ b/previews/PR68/doc/reference/index.html @@ -1,15 +1,15 @@ -Gtk4 Reference · Gtk4.jl

Gtk4 Reference

Widgets

Base.parentFunction
parent(w::GtkWidget)

Returns the parent widget of w, or nothing if the widget has not been set as the child of another widget (or is a toplevel widget, like a GtkWindow).

See also toplevel.

Related GTK function: gtk_widget_get_parent()

source
Gtk4.GLib.activateFunction
activate(a::GAction, par = nothing)

Activates an action, optionally with a parameter par, which if given should be a GVariant.

source
activate(w::GtkWidget)

Activates widgets like buttons, menu items, etc. that support being activated. Returns false if the widget is not activatable.

Related GTK function: gtk_widget_activate()

source
Gtk4.monitorFunction
monitor(w::GtkWidget)

Gets the GdkMonitor where w is displayed, or nothing if the widget is not part of a widget hierarchy.

source
Gtk4.isrealizedFunction
isrealized(w::GtkWidget)

Returns whether w is realized (that is, whether it has been associated with a drawing surface).

source

Windows

Gtk4.isactiveFunction
isactive(win::GtkWindow)

Returns whether win is the currently active toplevel. This is the window that receives keystrokes.

source
Gtk4.presentFunction
present(win::GtkWindow)
-present(win::GtkWindow, timestamp)

Presents a window to the user. Usually means move it to the front. According to the GTK docs, this function "should not be used" without including a timestamp for the user's request.

Related GTK function: gtk_window_present() Related GTK function: gtk_window_present_with_time()

source
Gtk4.toplevelsFunction
toplevels()

Returns a GListModel of all toplevel widgets (i.e. windows) known to GTK4.

source

Input widgets

Gtk4.configure!Function
configure!(adj::GtkAdjustment; value = nothing, lower = nothing, upper = nothing, step_increment = nothing, page_increment = nothing, page_size = nothing)

Sets all properties of an adjustment, while only resulting in one emission of the changed signal. If an argument is nothing, it is not changed.

Related GTK function: gtk_adjustment_configure()

source
configure!(sb::GtkSpinButton; adj = nothing, climb_rate = nothing, digits = nothing)

Sets the adjustment adj, the climb_rate, and the number of digits of a GtkSpinButton. If an argument is nothing, it is not changed.

Related GTK function: gtk_spin_button_configure()

source
Gtk4.selected_string!Function
selected_string!(d::GtkDropDown, s::AbstractString)

Set the selected item in a dropdown widget. This method assumes that the widget's model is a GtkStringList.

source
Gtk4.selected_stringFunction
selected_string(d::GtkDropDown)

Get the currently selected item in a dropdown widget. This method assumes that the widget's model is a GtkStringList or that items in the model have a "string" property.

source

Dialogs

Gtk4.ask_dialogFunction
ask_dialog(question::AbstractString, parent = nothing; timeout = -1)

Create a dialog with a message question and two buttons "No" and "Yes". Returns true if "Yes" is selected and false if "No" is selected or the dialog (or its parent window parent) is closed. The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and false will be returned.

source
Gtk4.info_dialogFunction
info_dialog(message::AbstractString, parent = nothing; timeout = -1)

Create a dialog with an informational message message. Returns when the dialog (or its parent window parent) is closed. The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and false will be returned.

source
Gtk4.input_dialogFunction
input_dialog(message::AbstractString, entry_default::AbstractString, buttons = (("Cancel", 0), ("Accept", 1)), parent = nothing; timeout = -1)

Create a dialog with a message message and a text entry. Returns the string in the entry when the "Accept" button is pressed, or entry_default if "Cancel" is pressed or the dialog or its parent window parent is closed. The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and entry_default will be returned.

source
Gtk4.open_dialogFunction
open_dialog(title::AbstractString, parent = nothing, filters::Union{AbstractVector, Tuple} = String[]; timeout = -1, multiple = false, start_folder = "")

Create a dialog for choosing a file or folder to be opened. Returns the path chosen by the user, or "" if "Cancel" is pressed or the dialog or its parent window parent is closed. The dialog title is set using title. The argument filters can be used to show only directory contents that match certain file extensions.

Keyword arguments: timeout: The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and "" will be returned. multiple: if true, multiple files can be selected, and a list of file paths is returned rather than a single path. start_folder: if set, the dialog will start out browsing a particular folder. Otherwise GTK will decide.

source
Gtk4.save_dialogFunction
save_dialog(title::AbstractString, parent = nothing, filters::Union{AbstractVector, Tuple} = String[]; timeout = -1, start_folder = "")

Create a dialog for choosing a file to be saved to. Returns the path chosen by the user, or "" if "Cancel" is pressed or the dialog or its parent window parent is closed. The window title is set using title. The argument filters can be used to show only directory contents that match certain file extensions.

Keyword arguments: timeout: The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and "" will be returned. start_folder: if set, the dialog will start out browsing a particular folder. Otherwise GTK will decide.

source

GtkCanvas (for Cairo drawing)

Gtk4.GtkCanvasType
GtkCanvas(w = -1, h = -1, init_back = false; kwargs...)

Create a GtkCanvas widget for drawing using Cairo (based on GtkDrawingArea). Optional arguments w and h can be used to set the minimum width and height of the drawing area in pixels. If init_back is set to true, the canvas's image CairoSurface will be initialized immediately, which is useful for precompilation.

Keyword arguments can be used to set properties of the GtkDrawingArea widget.

source
Gtk4.drawFunction
draw(redraw::Function, widget::GtkCanvas)

Set a function redraw to be called whenever the GtkCanvas's CairoSurface needs to be redrawn. The function should have a single argument, the GtkCanvas, from which the CairoSurface can be retrieved using getgc.

source
Graphics.getgcFunction
getgc(c::GtkCanvas)

Return the CairoContext of the CairoSurface backing store of a GtkCanvas.

source
Gtk4.cairo_surfaceFunction
cairo_surface(c::GtkCanvas)

Return the image CairoSurface backing store for a GtkCanvas.

source

GtkGLArea

Event controllers

Gtk4.find_controllerFunction
find_controller(w::GtkWidget, ::Type{T}) where T <: GtkEventController

Returns an event controller of type T connected to a widget, or nothing if one doesn't exist. This function is intended for testing purposes (to simulate events) and is not recommended otherwise, as there is a performance penalty for creating a list of a widget's event controllers.

Related GTK function: gtk_widget_observe_controllers)

source
Gtk4.widgetFunction
widget(c::GtkEventController)

Returns the widget associated with an event controller.

source
Gtk4.add_action_shortcutFunction
add_action_shortcut(scc::GtkShortcutController,trigger::AbstractString,action::AbstractString)

Adds a shortcut specified by a string like "<Control>S" for an action (such as "app.save") to a GtkShortcutController.

source

GtkTextView

Gtk4.bufferFunction
buffer(iter::Union{Ref{_GtkTextIter}, _GtkTextIter})

Returns the buffer associated with iter.

source
Gtk4.undo!Function
undo!(buffer::GtkTextBuffer)

Implements gtk_text_buffer_undo.

source
Gtk4.redo!Function
redo!(buffer::GtkTextBuffer)

Implements gtk_text_buffer_redo.

source
Gtk4.create_markFunction
create_mark(buffer::GtkTextBuffer, mark_name, it::TI, left_gravity::Bool)
-create_mark(buffer::GtkTextBuffer, it::TI)

Implements gtk_text_buffer_create_mark.

source
Gtk4.place_cursorFunction
place_cursor(buffer::GtkTextBuffer, it::_GtkTextIter)
-place_cursor(buffer::GtkTextBuffer, pos::Int)

Place the cursor at indicated position.

source
Gtk4.scroll_toFunction
scroll_to(view::GtkTextView, mark::GtkTextMark, within_margin::Real,
+Gtk4 Reference · Gtk4.jl

Gtk4 Reference

Widgets

Base.parentFunction
parent(w::GtkWidget)

Returns the parent widget of w, or nothing if the widget has not been set as the child of another widget (or is a toplevel widget, like a GtkWindow).

See also toplevel.

Related GTK function: gtk_widget_get_parent()

source
Gtk4.GLib.activateFunction
activate(a::GAction, par = nothing)

Activates an action, optionally with a parameter par, which if given should be a GVariant.

source
activate(w::GtkWidget)

Activates widgets like buttons, menu items, etc. that support being activated. Returns false if the widget is not activatable.

Related GTK function: gtk_widget_activate()

source
Gtk4.monitorFunction
monitor(w::GtkWidget)

Gets the GdkMonitor where w is displayed, or nothing if the widget is not part of a widget hierarchy.

source
Gtk4.isrealizedFunction
isrealized(w::GtkWidget)

Returns whether w is realized (that is, whether it has been associated with a drawing surface).

source

Windows

Gtk4.isactiveFunction
isactive(win::GtkWindow)

Returns whether win is the currently active toplevel. This is the window that receives keystrokes.

source
Gtk4.presentFunction
present(win::GtkWindow)
+present(win::GtkWindow, timestamp)

Presents a window to the user. Usually means move it to the front. According to the GTK docs, this function "should not be used" without including a timestamp for the user's request.

Related GTK function: gtk_window_present() Related GTK function: gtk_window_present_with_time()

source
Gtk4.toplevelsFunction
toplevels()

Returns a GListModel of all toplevel widgets (i.e. windows) known to GTK4.

source

Input widgets

Gtk4.configure!Function
configure!(adj::GtkAdjustment; value = nothing, lower = nothing, upper = nothing, step_increment = nothing, page_increment = nothing, page_size = nothing)

Sets all properties of an adjustment, while only resulting in one emission of the changed signal. If an argument is nothing, it is not changed.

Related GTK function: gtk_adjustment_configure()

source
configure!(sb::GtkSpinButton; adj = nothing, climb_rate = nothing, digits = nothing)

Sets the adjustment adj, the climb_rate, and the number of digits of a GtkSpinButton. If an argument is nothing, it is not changed.

Related GTK function: gtk_spin_button_configure()

source
Gtk4.selected_string!Function
selected_string!(d::GtkDropDown, s::AbstractString)

Set the selected item in a dropdown widget. This method assumes that the widget's model is a GtkStringList.

source
Gtk4.selected_stringFunction
selected_string(d::GtkDropDown)

Get the currently selected item in a dropdown widget. This method assumes that the widget's model is a GtkStringList or that items in the model have a "string" property.

source

Dialogs

Gtk4.ask_dialogFunction
ask_dialog(question::AbstractString, parent = nothing; timeout = -1)

Create a dialog with a message question and two buttons "No" and "Yes". Returns true if "Yes" is selected and false if "No" is selected or the dialog (or its parent window parent) is closed. The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and false will be returned.

source
Gtk4.info_dialogFunction
info_dialog(message::AbstractString, parent = nothing; timeout = -1)

Create a dialog with an informational message message. Returns when the dialog (or its parent window parent) is closed. The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and false will be returned.

source
Gtk4.input_dialogFunction
input_dialog(message::AbstractString, entry_default::AbstractString, buttons = (("Cancel", 0), ("Accept", 1)), parent = nothing; timeout = -1)

Create a dialog with a message message and a text entry. Returns the string in the entry when the "Accept" button is pressed, or entry_default if "Cancel" is pressed or the dialog or its parent window parent is closed. The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and entry_default will be returned.

source
Gtk4.open_dialogFunction
open_dialog(title::AbstractString, parent = nothing, filters::Union{AbstractVector, Tuple} = String[]; timeout = -1, multiple = false, start_folder = "")

Create a dialog for choosing a file or folder to be opened. Returns the path chosen by the user, or "" if "Cancel" is pressed or the dialog or its parent window parent is closed. The dialog title is set using title. The argument filters can be used to show only directory contents that match certain file extensions.

Keyword arguments: timeout: The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and "" will be returned. multiple: if true, multiple files can be selected, and a list of file paths is returned rather than a single path. start_folder: if set, the dialog will start out browsing a particular folder. Otherwise GTK will decide.

source
Gtk4.save_dialogFunction
save_dialog(title::AbstractString, parent = nothing, filters::Union{AbstractVector, Tuple} = String[]; timeout = -1, start_folder = "")

Create a dialog for choosing a file to be saved to. Returns the path chosen by the user, or "" if "Cancel" is pressed or the dialog or its parent window parent is closed. The window title is set using title. The argument filters can be used to show only directory contents that match certain file extensions.

Keyword arguments: timeout: The optional input timeout (disabled by default) can be used to set a time in seconds after which the dialog will close and "" will be returned. start_folder: if set, the dialog will start out browsing a particular folder. Otherwise GTK will decide.

source

GtkCanvas (for Cairo drawing)

Gtk4.GtkCanvasType
GtkCanvas(w = -1, h = -1, init_back = false; kwargs...)

Create a GtkCanvas widget for drawing using Cairo (based on GtkDrawingArea). Optional arguments w and h can be used to set the minimum width and height of the drawing area in pixels. If init_back is set to true, the canvas's image CairoSurface will be initialized immediately, which is useful for precompilation.

Keyword arguments can be used to set properties of the GtkDrawingArea widget.

source
Gtk4.drawFunction
draw(redraw::Function, widget::GtkCanvas)

Set a function redraw to be called whenever the GtkCanvas's CairoSurface needs to be redrawn. The function should have a single argument, the GtkCanvas, from which the CairoSurface can be retrieved using getgc.

source
Graphics.getgcFunction
getgc(c::GtkCanvas)

Return the CairoContext of the CairoSurface backing store of a GtkCanvas.

source
Gtk4.cairo_surfaceFunction
cairo_surface(c::GtkCanvas)

Return the image CairoSurface backing store for a GtkCanvas.

source

GtkGLArea

Event controllers

Gtk4.find_controllerFunction
find_controller(w::GtkWidget, ::Type{T}) where T <: GtkEventController

Returns an event controller of type T connected to a widget, or nothing if one doesn't exist. This function is intended for testing purposes (to simulate events) and is not recommended otherwise, as there is a performance penalty for creating a list of a widget's event controllers.

Related GTK function: gtk_widget_observe_controllers)

source
Gtk4.widgetFunction
widget(c::GtkEventController)

Returns the widget associated with an event controller.

source
Gtk4.add_action_shortcutFunction
add_action_shortcut(scc::GtkShortcutController,trigger::AbstractString,action::AbstractString)

Adds a shortcut specified by a string like "<Control>S" for an action (such as "app.save") to a GtkShortcutController.

source

GtkTextView

Gtk4.bufferFunction
buffer(iter::Union{Ref{_GtkTextIter}, _GtkTextIter})

Returns the buffer associated with iter.

source
Gtk4.undo!Function
undo!(buffer::GtkTextBuffer)

Implements gtk_text_buffer_undo.

source
Gtk4.redo!Function
redo!(buffer::GtkTextBuffer)

Implements gtk_text_buffer_redo.

source
Gtk4.create_markFunction
create_mark(buffer::GtkTextBuffer, mark_name, it::TI, left_gravity::Bool)
+create_mark(buffer::GtkTextBuffer, it::TI)

Implements gtk_text_buffer_create_mark.

source
Gtk4.place_cursorFunction
place_cursor(buffer::GtkTextBuffer, it::_GtkTextIter)
+place_cursor(buffer::GtkTextBuffer, pos::Int)

Place the cursor at indicated position.

source
Gtk4.scroll_toFunction
scroll_to(view::GtkTextView, mark::GtkTextMark, within_margin::Real,
                use_align::Bool, xalign::Real, yalign::Real)
 
 scroll_to(view::GtkTextView, iter::TI, within_margin::Real,
-          use_align::Bool, xalign::Real, yalign::Real)

Implements gtk_text_view_scroll_to_mark and gtk_text_view_scroll_to_iter.

source
Gtk4.searchFunction
search(buffer::GtkTextBuffer, str::AbstractString, direction = :forward,
-    flag = GtkTextSearchFlags.GTK_TEXT_SEARCH_TEXT_ONLY)

Search text str in buffer in direction :forward or :backward starting from the cursor position in the buffer.

Returns a tuple (found, start, stop) where found indicates whether the search was successful and start and stop are _GtkTextIters containing the location of the match.

source
Gtk4.select_rangeFunction
select_range(buffer::GtkTextBuffer, ins::TI, bound::TI)
-select_range(buffer::GtkTextBuffer, range::GtkTextRange)

Select the text in buffer accorind to _GtkTextIter ins and bound.

Implements gtk_text_buffer_select_range.

source
Gtk4.selection_boundsFunction
selection_bounds(buffer::GtkTextBuffer)

Returns a tuple (selected, start, stop) indicating if text is selected in the buffer, and if so sets the _GtkTextIter start and stop to point to the selected text.

Implements gtk_text_buffer_get_selection_bounds.

source
Base.skipFunction
skip(iter::Ref{_GtkTextIter}, count::Integer)

Moves iter count characters. Returns a Bool indicating if the move was successful.

source
skip(iter::Ref{_GtkTextIter}, what::Symbol)

Moves iter according to the operation specified by what. Operations are :

  • :forward_line (gtk_text_iter_forward_line)
  • :backward_line (gtk_text_iter_backward_line)
  • :forward_to_line_end (gtk_text_iter_forward_to_line_end)
  • :backward_word_start (gtk_text_iter_forward_word_end)
  • :forward_word_end (gtk_text_iter_backward_word_start)
  • :backward_sentence_start (gtk_text_iter_backward_sentence_start)
  • :forward_sentence_end (gtk_text_iter_forward_sentence_end)
source
skip(iter::Ref{_GtkTextIter}, count::Integer, what::Symbol)

Moves iter according to the operation specified by what and count. Operations are :

  • :chars (gtk_text_iter_forward_chars)
  • :lines (gtk_text_iter_forward_lines)
  • :words (gtk_text_iter_forward_word_ends)
  • :word_cursor_positions (gtk_text_iter_forward_cursor_positions)
  • :sentences (gtk_text_iter_forward_sentence_ends)
  • :visible_words (gtk_text_iter_forward_visible_word_ends)
  • :visible_cursor_positions (gtk_text_iter_forward_visible_cursor_positions)
  • :visible_lines (gtk_text_iter_forward_visible_lines)
  • :line_ends (gtk_text_iter_forward_visible_lines)
source
Gtk4.backward_searchFunction
backward_search(iter::Ref{_GtkTextIter},
+          use_align::Bool, xalign::Real, yalign::Real)

Implements gtk_text_view_scroll_to_mark and gtk_text_view_scroll_to_iter.

source
Gtk4.searchFunction
search(buffer::GtkTextBuffer, str::AbstractString, direction = :forward,
+    flag = GtkTextSearchFlags.GTK_TEXT_SEARCH_TEXT_ONLY)

Search text str in buffer in direction :forward or :backward starting from the cursor position in the buffer.

Returns a tuple (found, start, stop) where found indicates whether the search was successful and start and stop are _GtkTextIters containing the location of the match.

source
Gtk4.select_rangeFunction
select_range(buffer::GtkTextBuffer, ins::TI, bound::TI)
+select_range(buffer::GtkTextBuffer, range::GtkTextRange)

Select the text in buffer accorind to _GtkTextIter ins and bound.

Implements gtk_text_buffer_select_range.

source
Gtk4.selection_boundsFunction
selection_bounds(buffer::GtkTextBuffer)

Returns a tuple (selected, start, stop) indicating if text is selected in the buffer, and if so sets the _GtkTextIter start and stop to point to the selected text.

Implements gtk_text_buffer_get_selection_bounds.

source
Base.skipFunction
skip(iter::Ref{_GtkTextIter}, count::Integer)

Moves iter count characters. Returns a Bool indicating if the move was successful.

source
skip(iter::Ref{_GtkTextIter}, what::Symbol)

Moves iter according to the operation specified by what. Operations are :

  • :forward_line (gtk_text_iter_forward_line)
  • :backward_line (gtk_text_iter_backward_line)
  • :forward_to_line_end (gtk_text_iter_forward_to_line_end)
  • :backward_word_start (gtk_text_iter_forward_word_end)
  • :forward_word_end (gtk_text_iter_backward_word_start)
  • :backward_sentence_start (gtk_text_iter_backward_sentence_start)
  • :forward_sentence_end (gtk_text_iter_forward_sentence_end)
source
skip(iter::Ref{_GtkTextIter}, count::Integer, what::Symbol)

Moves iter according to the operation specified by what and count. Operations are :

  • :chars (gtk_text_iter_forward_chars)
  • :lines (gtk_text_iter_forward_lines)
  • :words (gtk_text_iter_forward_word_ends)
  • :word_cursor_positions (gtk_text_iter_forward_cursor_positions)
  • :sentences (gtk_text_iter_forward_sentence_ends)
  • :visible_words (gtk_text_iter_forward_visible_word_ends)
  • :visible_cursor_positions (gtk_text_iter_forward_visible_cursor_positions)
  • :visible_lines (gtk_text_iter_forward_visible_lines)
  • :line_ends (gtk_text_iter_forward_visible_lines)
source
Gtk4.backward_searchFunction
backward_search(iter::Ref{_GtkTextIter},
     str::AbstractString, start::Ref{_GtkTextIter},
-    stop::Ref{_GtkTextIter}, limit::Ref{_GtkTextIter}, flag::Int32)

Implements gtk_text_iter_backward_search.

source
Gtk4.buffer_to_window_coordsFunction
buffer_to_window_coords(view::GtkTextView, buffer_x::Integer, buffer_y::Integer, wintype::Integer = 0)

Implements gtk_text_view_buffer_to_window_coords.

source
Gtk4.char_offsetFunction
char_offset(iter::Union{Ref{_GtkTextIter}, _GtkTextIter})

Returns the offset of iter (one-based index).

source
Gtk4.forward_searchFunction
forward_search(iter::Ref{_GtkTextIter},
+    stop::Ref{_GtkTextIter}, limit::Ref{_GtkTextIter}, flag::Int32)

Implements gtk_text_iter_backward_search.

source
Gtk4.buffer_to_window_coordsFunction
buffer_to_window_coords(view::GtkTextView, buffer_x::Integer, buffer_y::Integer, wintype::Integer = 0)

Implements gtk_text_view_buffer_to_window_coords.

source
Gtk4.char_offsetFunction
char_offset(iter::Union{Ref{_GtkTextIter}, _GtkTextIter})

Returns the offset of iter (one-based index).

source
Gtk4.forward_searchFunction
forward_search(iter::Ref{_GtkTextIter},
     str::AbstractString, start::Ref{_GtkTextIter},
-    stop::Ref{_GtkTextIter}, limit::Ref{_GtkTextIter}, flag::Int32)

Implements gtk_text_iter_forward_search.

source
Gtk4.window_to_buffer_coordsFunction
window_to_buffer_coords(view::GtkTextView, window_x::Integer, window_y::Integer, wintype::Integer = 2)

Implements gtk_text_view_window_to_buffer_coords.

source
Gtk4._GtkTextIterType
_GtkTextIter(text::GtkTextBuffer, char_offset::Integer)

Creates a _GtkTextIter with offset char_offset (one-based index).

source
+ stop::Ref{_GtkTextIter}, limit::Ref{_GtkTextIter}, flag::Int32)

Implements gtk_text_iter_forward_search.

source
Gtk4.window_to_buffer_coordsFunction
window_to_buffer_coords(view::GtkTextView, window_x::Integer, window_y::Integer, wintype::Integer = 2)

Implements gtk_text_view_window_to_buffer_coords.

source
Gtk4._GtkTextIterType
_GtkTextIter(text::GtkTextBuffer, char_offset::Integer)

Creates a _GtkTextIter with offset char_offset (one-based index).

source
diff --git a/previews/PR68/howto/async/index.html b/previews/PR68/howto/async/index.html index 285a9d14..25f83fb0 100644 --- a/previews/PR68/howto/async/index.html +++ b/previews/PR68/howto/async/index.html @@ -64,4 +64,4 @@ end end -win = GtkWindow(grid, "Distributed", 200, 200) +win = GtkWindow(grid, "Distributed", 200, 200) diff --git a/previews/PR68/howto/nonreplusage/index.html b/previews/PR68/howto/nonreplusage/index.html index 69df2c81..ce06a3e6 100644 --- a/previews/PR68/howto/nonreplusage/index.html +++ b/previews/PR68/howto/nonreplusage/index.html @@ -30,4 +30,4 @@ Gtk4.signal_connect(activate, app, :activate) -run(app)

In the activate function, you can create your windows, widgets, etc. and connect them to signals. When all GtkApplicationWindows have been closed, the script will exit.

Creating an app with PackageCompiler

PackageCompiler.jl can be used to create an executable file that can be transferred to other computers without installing Julia. An example can be found in the examples/ExampleApplication directory in the Gtk4.jl repo.

+run(app)

In the activate function, you can create your windows, widgets, etc. and connect them to signals. When all GtkApplicationWindows have been closed, the script will exit.

Creating an app with PackageCompiler

PackageCompiler.jl can be used to create an executable file that can be transferred to other computers without installing Julia. An example can be found in the examples/ExampleApplication directory in the Gtk4.jl repo.

diff --git a/previews/PR68/howto/sysimage/index.html b/previews/PR68/howto/sysimage/index.html index 9cc8f563..e95958f2 100644 --- a/previews/PR68/howto/sysimage/index.html +++ b/previews/PR68/howto/sysimage/index.html @@ -1,2 +1,2 @@ -Gtk4 in a sysimage · Gtk4.jl

Gtk4 in a sysimage

Note that if Gtk4 is included in a sysimage using PackageCompiler.jl, the main loop will not be started automatically when calling using Gtk4 even in an interactive Julia session. You will have to call GLib.start_main_loop() before windows will appear.

+Gtk4 in a sysimage · Gtk4.jl

Gtk4 in a sysimage

Note that if Gtk4 is included in a sysimage using PackageCompiler.jl, the main loop will not be started automatically when calling using Gtk4 even in an interactive Julia session. You will have to call GLib.start_main_loop() before windows will appear.

diff --git a/previews/PR68/index.html b/previews/PR68/index.html index 818c6d4f..1f9b795c 100644 --- a/previews/PR68/index.html +++ b/previews/PR68/index.html @@ -1,2 +1,2 @@ -Home · Gtk4.jl

Gtk4.jl

Julia Bindings for Gtk version 4.x.

Introduction

Gtk4.jl is a Julia package providing bindings for the Gtk library: https://www.gtk.org/

Complete Gtk documentation is available at https://www.gtk.org/docs/

Usage

History

This package and its documentation were adapted from Gtk.jl, which was written by Jameson Nash and others and supported GTK versions 2 and 3. With version 4 there were so many changes to the GTK API that it would have been messy to try to support it and previous versions in the same package. Note that much of the GLib/GObject functionality that underlies GTK is largely the same code as in Gtk.jl. Some changes were made to try to take better advantage of GObject introspection or to remove old code that was no longer necessary in recent versions of Julia.

+Home · Gtk4.jl

Gtk4.jl

Julia Bindings for Gtk version 4.x.

Introduction

Gtk4.jl is a Julia package providing bindings for the Gtk library: https://www.gtk.org/

Complete Gtk documentation is available at https://www.gtk.org/docs/

Usage

History

This package and its documentation were adapted from Gtk.jl, which was written by Jameson Nash and others and supported GTK versions 2 and 3. With version 4 there were so many changes to the GTK API that it would have been messy to try to support it and previous versions in the same package. Note that much of the GLib/GObject functionality that underlies GTK is largely the same code as in Gtk.jl. Some changes were made to try to take better advantage of GObject introspection or to remove old code that was no longer necessary in recent versions of Julia.

diff --git a/previews/PR68/manual/actions/index.html b/previews/PR68/manual/actions/index.html index ea8a94f9..408e812b 100644 --- a/previews/PR68/manual/actions/index.html +++ b/previews/PR68/manual/actions/index.html @@ -51,4 +51,4 @@ action_group = GSimpleActionGroup() add_stateful_action(GActionMap(action_group), "option", String, "1", opt_action_cb) -push!(win, Gtk4.GLib.GActionGroup(action_group), "win")

Actions in an application

As mentioned above, the objects GtkApplication and GtkApplicationWindow implement the GActionMap interface, so there is no need to create a GSimpleActionGroup and add it to the window. For GtkApplicationWindows, you can add window-associated actions using add_action(GActionMap(win), "fullscreen", fullscreen_cb). Assuming you have created a GtkApplication called app, you can add actions to the application using add_action(GActionMap(app), "fullscreen", fullscreen_cb).

+push!(win, Gtk4.GLib.GActionGroup(action_group), "win")

Actions in an application

As mentioned above, the objects GtkApplication and GtkApplicationWindow implement the GActionMap interface, so there is no need to create a GSimpleActionGroup and add it to the window. For GtkApplicationWindows, you can add window-associated actions using add_action(GActionMap(win), "fullscreen", fullscreen_cb). Assuming you have created a GtkApplication called app, you can add actions to the application using add_action(GActionMap(app), "fullscreen", fullscreen_cb).

diff --git a/previews/PR68/manual/builder/index.html b/previews/PR68/manual/builder/index.html index d8a09801..84f6e64a 100644 --- a/previews/PR68/manual/builder/index.html +++ b/previews/PR68/manual/builder/index.html @@ -13,4 +13,4 @@ </object> </interface>

In order to access the widgets from Julia we first create a GtkBuilder object that will serve as a connector between the XML definition and our Julia code.

b = GtkBuilder("path/to/myapp.ui")
Note

If you are developing the code in a package you can get the package directory using the @__DIR__ macro. For instance, if your UI file is located at MyPackage/src/builder/myuifile.ui, you can get the full path using uifile = joinpath(@__DIR__, "builder", "myuifile.ui").

Alternatively, if we store the above XML definition in a Julia string myapp we can initialize the builder by

b = GtkBuilder(myapp, -1)

Now we want to access a widget from the XML file in order to actually display it on the screen. To do so we can call

win = b["window1"]

for each widget we want to access in our Julia code. Widgets that we don't need to access from Julia, for example layout widgets like GtkBox that are being used only to arrange more interesting widgets for input or display, do not need to be loaded. You can thus see your builder as a kind of a widget store that you use when you need access to your widgets.

Note

Fetching an object from GtkBuilder is type unstable since the Julia compiler has no way of knowing the type of the object. A type assertion can be used to set a concrete type (ending in "Leaf") and potentially improve performance. In the example above, the correct assertion would be win = b["window1"]::GtkWindowLeaf.

In Gtk4.jl a macro @load_builder is defined that iterates over the GtkWidgets in a GtkBuilder object and automatically assigns them to Julia variables with the same id. For example, if a GtkEntry with an id entry1 and two GtkButtons with id's button1 and button2 are present in myapp.ui, calling

@load_builder(GtkBuilder(filename="myapp.ui"))

is equivalent to

entry1 = b["entry1"]
 button1 = b["button1"]
-button2 = b["button2"]

Note that this only works for GtkWidgets that implement the interface GtkBuildable, which excludes some objects often defined in UI files, for example GtkAdjustment. Those objects will have to be fetched using calls to get_object.

Callbacks

The XML file lets us only describe the visual structure of our widgets and not their behavior when the using is interacting with it. For this reason, we will have to add callbacks to the widgets which we do in Julia code as it was described in Signals and Callbacks. Alternatively you can use Actions, which are described in the next section.

+button2 = b["button2"]

Note that this only works for GtkWidgets that implement the interface GtkBuildable, which excludes some objects often defined in UI files, for example GtkAdjustment. Those objects will have to be fetched using calls to get_object.

Callbacks

The XML file lets us only describe the visual structure of our widgets and not their behavior when the using is interacting with it. For this reason, we will have to add callbacks to the widgets which we do in Julia code as it was described in Signals and Callbacks. Alternatively you can use Actions, which are described in the next section.

diff --git a/previews/PR68/manual/buttons/index.html b/previews/PR68/manual/buttons/index.html index a1aecb6a..3835f0a5 100644 --- a/previews/PR68/manual/buttons/index.html +++ b/previews/PR68/manual/buttons/index.html @@ -14,4 +14,4 @@ group(green_button, red_button) group(blue_button, red_button) -# now only one button can be active at a time

Selected signals:

signalargumentsreturns
"toggled"self::GtkToggleButtonNothingEmitted when the button state is changed

GtkCheckButton

This widget is a checkbox that can be used to control whether something is active (true) or inactive (false). Functionally it is identical to a GtkToggleButton but it is rendered differently. There is typically a label that is rendered next to the checkbox.

Like a toggle button, a check button can also be added to a group, in which case it is rendered as a "radio button" that can be used to choose from a few mutually exclusive options.

Selected signals:

signalargumentsreturns
"toggled"self::GtkCheckButtonNothingEmitted when the button state is changed

GtkSwitch

This widget is very much like a check button but looks like a switch.

Like GtkCheckButton, its "active" property can be used to get and set the switch's state.

GtkLinkButton

This widget can be used to open a URL:

lb = GtkLinkButton("https://julialang.org","Julia website")
+# now only one button can be active at a time

Selected signals:

signalargumentsreturns
"toggled"self::GtkToggleButtonNothingEmitted when the button state is changed

GtkCheckButton

This widget is a checkbox that can be used to control whether something is active (true) or inactive (false). Functionally it is identical to a GtkToggleButton but it is rendered differently. There is typically a label that is rendered next to the checkbox.

Like a toggle button, a check button can also be added to a group, in which case it is rendered as a "radio button" that can be used to choose from a few mutually exclusive options.

Selected signals:

signalargumentsreturns
"toggled"self::GtkCheckButtonNothingEmitted when the button state is changed

GtkSwitch

This widget is very much like a check button but looks like a switch.

Like GtkCheckButton, its "active" property can be used to get and set the switch's state.

GtkLinkButton

This widget can be used to open a URL:

lb = GtkLinkButton("https://julialang.org","Julia website")
diff --git a/previews/PR68/manual/canvas/index.html b/previews/PR68/manual/canvas/index.html index 7951a6c5..ea9ee17d 100644 --- a/previews/PR68/manual/canvas/index.html +++ b/previews/PR68/manual/canvas/index.html @@ -40,4 +40,4 @@ screen = CairoMakie.Screen(f.scene, config, Gtk4.cairo_surface(canvas)) CairoMakie.resize!(f.scene, Gtk4.width(widget), Gtk4.height(widget)) CairoMakie.cairo_draw(screen, f.scene) -end
Example

A more complicated example can be found in "canvas_cairomakie.jl" in the "examples" subdirectory.

+end
Example

A more complicated example can be found in "canvas_cairomakie.jl" in the "examples" subdirectory.

diff --git a/previews/PR68/manual/combobox/index.html b/previews/PR68/manual/combobox/index.html index 278f6769..1fc73359 100644 --- a/previews/PR68/manual/combobox/index.html +++ b/previews/PR68/manual/combobox/index.html @@ -35,4 +35,4 @@ end win = GtkWindow("ComboBoxText Example",400,200) -push!(win, cb) +push!(win, cb) diff --git a/previews/PR68/manual/dialogs/index.html b/previews/PR68/manual/dialogs/index.html index baab7846..3e0c4b22 100644 --- a/previews/PR68/manual/dialogs/index.html +++ b/previews/PR68/manual/dialogs/index.html @@ -24,4 +24,4 @@ if isdir(dir[]) # do something with dir -end

Custom dialogs

TODO

+end

Custom dialogs

TODO

diff --git a/previews/PR68/manual/display/index.html b/previews/PR68/manual/display/index.html index 0a154c37..d46a4013 100644 --- a/previews/PR68/manual/display/index.html +++ b/previews/PR68/manual/display/index.html @@ -2,4 +2,4 @@ Display widgets · Gtk4.jl

Display widgets

We have already encountered GtkLabel, which is used to display text. GTK has a few other widgets that are useful for displaying information.

GtkSpinner

This is a simple widget that optionally shows an animated spinning icon. It's used to indicate to the user that something is happening.

The widget is constructed using GtkSpinner(). There are just two methods, start to display the spinning icon and stop to not display it.

To check if the spinner is spinning, use the "spinning" property or the spinning getter method.

GtkProgressBar

This widget shows a progress bar and optionally text.

win = GtkWindow("Progress bar")
 progbar = GtkProgressBar()
 push!(win, progbar)

The fractional progress (between 0.0 and 1.0) can be set using the fraction setter or the "fraction" property:

fraction(progbar, 0.5)
-progbar.fraction

You can show text which might, for example, say something about what is happening or an estimated time left:

Gtk4.text(progbar, "11 seconds remaining")

For processes with no well defined concept of progress, you can periodically use the pulse method to cause the progress bar to show a back and forth motion (think "Knight Rider"), reassuring the user that something is continuing to happen:

Gtk4.pulse(progbar) # moves the progress bar a little

The step size (in fractional units) for pulse can be set using Gtk4.pulse_step.

GtkPicture and GtkImage

These two widgets can be used to display an image. GtkPicture shows the image at its natural size, while GtkImage shows it at a fixed, potentially smaller size (for example, an icon). The image can be set in a constructor or be set by a method.

For GtkPicture, there are constructors that read from a file (in PNG, JPEG, or TIFF format), either using a GFile object or a filename. Alternatively you can construct a GtkPicture from a GdkPixbuf or GdkPaintable.

+progbar.fraction

You can show text which might, for example, say something about what is happening or an estimated time left:

Gtk4.text(progbar, "11 seconds remaining")

For processes with no well defined concept of progress, you can periodically use the pulse method to cause the progress bar to show a back and forth motion (think "Knight Rider"), reassuring the user that something is continuing to happen:

Gtk4.pulse(progbar) # moves the progress bar a little

The step size (in fractional units) for pulse can be set using Gtk4.pulse_step.

GtkPicture and GtkImage

These two widgets can be used to display an image. GtkPicture shows the image at its natural size, while GtkImage shows it at a fixed, potentially smaller size (for example, an icon). The image can be set in a constructor or be set by a method.

For GtkPicture, there are constructors that read from a file (in PNG, JPEG, or TIFF format), either using a GFile object or a filename. Alternatively you can construct a GtkPicture from a GdkPixbuf or GdkPaintable.

diff --git a/previews/PR68/manual/gettingStarted/index.html b/previews/PR68/manual/gettingStarted/index.html index ae4ae829..3b4d16d3 100644 --- a/previews/PR68/manual/gettingStarted/index.html +++ b/previews/PR68/manual/gettingStarted/index.html @@ -22,4 +22,4 @@ true

The toplevel widget in a particular widget's hierarchy can be found using the method toplevel:

julia> toplevel(b) == win
 true

Iterating over a widget gives you its child widgets:

for child in widget
     myfunc(child)
-end

Widgets can be added and removed using interface methods defined by Gtk4.jl. For many widgets that can contain children, push! is defined to append a widget to another's children. Some widget types can only have one child. For this situation, Gtk4.jl defines setindex!(w,x) and getindex(w) methods with no arguments, which can be written as w[] = x and output = w[], respectively. For example, a GtkWindow can have only one child widget, so we could have added the button to the window in our example using

win[] = b
+end

Widgets can be added and removed using interface methods defined by Gtk4.jl. For many widgets that can contain children, push! is defined to append a widget to another's children. Some widget types can only have one child. For this situation, Gtk4.jl defines setindex!(w,x) and getindex(w) methods with no arguments, which can be written as w[] = x and output = w[], respectively. For example, a GtkWindow can have only one child widget, so we could have added the button to the window in our example using

win[] = b
diff --git a/previews/PR68/manual/keyevents/index.html b/previews/PR68/manual/keyevents/index.html index 2cd7776e..26e6b7cc 100644 --- a/previews/PR68/manual/keyevents/index.html +++ b/previews/PR68/manual/keyevents/index.html @@ -37,4 +37,4 @@ event = Gtk4.current_event(controller) duration = Gtk4.time(event) - start_time # key press duration in milliseconds println("You released key ", keyval, " after time ", duration, " msec.") -end +end diff --git a/previews/PR68/manual/layout/index.html b/previews/PR68/manual/layout/index.html index 43cf51ea..0adb655e 100644 --- a/previews/PR68/manual/layout/index.html +++ b/previews/PR68/manual/layout/index.html @@ -42,4 +42,4 @@ push!(s, GtkLabel("Second label"), "id2", "Label 2") # widget can be retrieved using s[id] win[]=vbox

Julia interface methods defined for GtkStack:

methodwhat it does
getindex(s::GtkStack, name::AbstractString) or s[name]Gets a widget by name
setindex!(s::GtkStack, x::GtkWidget, name::AbstractString) or s[name] = xSets a widget by name
push!(s::GtkStack, x::GtkWidget)Appends a widget
push!(s::GtkStack, x::GtkWidget, name::AbstractString)Appends a widget with a name
push!(s::GtkStack, x::GtkWidget, name::AbstractString, title::AbstractString)Appends a widget with a name and a title
delete!(s::GtkStack, x::GtkWidget)Removes a widget from the stack
empty!(s::GtkStack)Removes all widgets from the stack

GtkFrame, GtkAspectFrame, and GtkExpander

These widgets hold one child widget. GtkFrame and GtkAspectFrame display them in a decorative frame with an optional label. GtkExpander allows the user to hide the child.

Julia interface methods defined for GtkFrame, GtkAspectFrame, and GtkExpander:

methodwhat it does
getindex(f) or f[]Gets the child widget
setindex!(f, w::Union{GtkWidget,Nothing}) or f[] = wSets or clears the child widget

Iterating over child widgets

For any of the widgets described above (or any GtkWidget that has children), you can iterate over all child widgets using

for child in widget
     myfunc(child)
-end
+end diff --git a/previews/PR68/manual/listtreeview/index.html b/previews/PR68/manual/listtreeview/index.html index 87ebd7ff..b51e9e02 100644 --- a/previews/PR68/manual/listtreeview/index.html +++ b/previews/PR68/manual/listtreeview/index.html @@ -164,4 +164,4 @@ win = GtkWindow(tv, "Tree View") iter = Gtk4.iter_from_index(ts, [1]) -ts[iter,1] = "ONE" +ts[iter,1] = "ONE" diff --git a/previews/PR68/manual/methods/index.html b/previews/PR68/manual/methods/index.html index 9ac4907e..af600cb8 100644 --- a/previews/PR68/manual/methods/index.html +++ b/previews/PR68/manual/methods/index.html @@ -1,2 +1,2 @@ -Automatically generated methods · Gtk4.jl

Automatically generated methods

Like Gtk.jl, the purpose of this package is to provide functions that wrap ccall's of GTK functions in a Julian and hopefully user friendly way. While in Gtk.jl these ccall's are handwritten, in Gtk4.jl most of the wrappers call automatically generated methods that contain the ccall's. If you don't see a particular functionality wrapped, you can call these autogenerated functions yourself by using a submodule G_ defined in each of the main modules (Gtk4, Pango, GLib, and GdkPixbufLib). The names of these functions and methods are intended to be easy to predict from the corresponding C library function names, and most are the same as in the pygobject bindings for GTK.

The autogenerated methods in G_, like the corresponding C functions, use 0-based indexing, while the more user-friendly wrappers outside G_ use 1-based indexing. Some types of methods are not yet supported. For example, methods involving callbacks must be wrapped by using ccall currently.

The following table lists a few examples that should give you an idea of how these work.

C functionGtk4.G_ Julia methodComments
void gtk_window_add_child (GtkWindow* window, GtkWidget* child)add_child (window::GtkWindow, child::GtkWidget)C arguments mapped directly onto Julia arguments
GtkStackPage* gtk_stack_add_child (GtkStack* stack, GtkWidget* child)add_child (stack::GtkStack, child::GtkWidget)many widgets have add_child methods, but we dispatch using the type of the first argument
void gtk_builder_add_from_file (GtkBuilder* builder, const gchar* filename, GError** error)add_from_file (builder::GtkBuilder, filename::AbstractString)if ccall fills GError argument, a Julia exception is thrown
guint gtk_get_major_version ()get_major_version ()Julia method returns a UInt32
void gtk_rgb_to_hsv (float r, float g, float b, float* h, float* s, float* v)rgb_to_hsv (r::Real, g::Real, b::Real)The arguments h, s, and v are outputs. Julia method returns (h, s, v)
gboolean gtk_tree_view_get_path_at_pos (GtkTreeView* tree_view, int x, int y, GtkTreePath** path, GtkTreeViewColumn** column, int* cell_x, int* cell_y)get_path_at_pos (instance::GtkTreeView, _x::Integer, _y::Integer)C function has a return value ret in addition to output arguments _path, _column, _cell_x, and _cell_y. The Julia method returns (ret, _path, _column, _cell_x, _cell_y)

If you are confused about what one of these automatically generated methods does, you can examine the code, which is defined in the src/gen directory. They are separated into "methods" (in an object-oriented sense, these are functions associated with a particular class) and "functions" (general C functions that aren't associated with a particular class). Constants and struct definitions are also generated using GObject introspection.

Constructors

Constructor methods in G_ are treated a little differently. They are named according to GObject_$constructor_name, as in the following table:

C functionGtk4.G_ Julia methodComments
GtkWidget* gtk_window_new()Window_new()Returns a newly constructed GtkWindow
GtkWidget* gtk_scale_new_with_range(GtkOrientation orientation, double min, double max, double step)Scale_new_with_range(orientation, min, max, step)Example with arguments
+Automatically generated methods · Gtk4.jl

Automatically generated methods

Like Gtk.jl, the purpose of this package is to provide functions that wrap ccall's of GTK functions in a Julian and hopefully user friendly way. While in Gtk.jl these ccall's are handwritten, in Gtk4.jl most of the wrappers call automatically generated methods that contain the ccall's. If you don't see a particular functionality wrapped, you can call these autogenerated functions yourself by using a submodule G_ defined in each of the main modules (Gtk4, Pango, GLib, and GdkPixbufLib). The names of these functions and methods are intended to be easy to predict from the corresponding C library function names, and most are the same as in the pygobject bindings for GTK.

The autogenerated methods in G_, like the corresponding C functions, use 0-based indexing, while the more user-friendly wrappers outside G_ use 1-based indexing. Some types of methods are not yet supported. For example, methods involving callbacks must be wrapped by using ccall currently.

The following table lists a few examples that should give you an idea of how these work.

C functionGtk4.G_ Julia methodComments
void gtk_window_add_child (GtkWindow* window, GtkWidget* child)add_child (window::GtkWindow, child::GtkWidget)C arguments mapped directly onto Julia arguments
GtkStackPage* gtk_stack_add_child (GtkStack* stack, GtkWidget* child)add_child (stack::GtkStack, child::GtkWidget)many widgets have add_child methods, but we dispatch using the type of the first argument
void gtk_builder_add_from_file (GtkBuilder* builder, const gchar* filename, GError** error)add_from_file (builder::GtkBuilder, filename::AbstractString)if ccall fills GError argument, a Julia exception is thrown
guint gtk_get_major_version ()get_major_version ()Julia method returns a UInt32
void gtk_rgb_to_hsv (float r, float g, float b, float* h, float* s, float* v)rgb_to_hsv (r::Real, g::Real, b::Real)The arguments h, s, and v are outputs. Julia method returns (h, s, v)
gboolean gtk_tree_view_get_path_at_pos (GtkTreeView* tree_view, int x, int y, GtkTreePath** path, GtkTreeViewColumn** column, int* cell_x, int* cell_y)get_path_at_pos (instance::GtkTreeView, _x::Integer, _y::Integer)C function has a return value ret in addition to output arguments _path, _column, _cell_x, and _cell_y. The Julia method returns (ret, _path, _column, _cell_x, _cell_y)

If you are confused about what one of these automatically generated methods does, you can examine the code, which is defined in the src/gen directory. They are separated into "methods" (in an object-oriented sense, these are functions associated with a particular class) and "functions" (general C functions that aren't associated with a particular class). Constants and struct definitions are also generated using GObject introspection.

Constructors

Constructor methods in G_ are treated a little differently. They are named according to GObject_$constructor_name, as in the following table:

C functionGtk4.G_ Julia methodComments
GtkWidget* gtk_window_new()Window_new()Returns a newly constructed GtkWindow
GtkWidget* gtk_scale_new_with_range(GtkOrientation orientation, double min, double max, double step)Scale_new_with_range(orientation, min, max, step)Example with arguments
diff --git a/previews/PR68/manual/properties/index.html b/previews/PR68/manual/properties/index.html index cad2e046..05ad9d98 100644 --- a/previews/PR68/manual/properties/index.html +++ b/previews/PR68/manual/properties/index.html @@ -18,4 +18,4 @@ julia> visible(win) false -julia> visible(win, true)

This sequence makes the window disappear and then reappear.

The most important accessors are exported from Gtk4 but the more obscure will have to be called including the module name. For example, the property resizable for a GtkWindow, which controls whether a user is allowed to resize the window, can be set using

julia> Gtk4.resizable(win, false)

Binding properties

Properties can be bound to one another through the GObject signal system using the method bind_property. For example, if one wanted the title of a window win2 to automatically track that of another window win1, one could use

julia> b = bind_property(win1, "title", win2, "title")

Now if one calls

julia> win1.title = "New title"

the title of win2 is automatically updated to the same value. The binding can be released using unbind_property(b).

+julia> visible(win, true)

This sequence makes the window disappear and then reappear.

The most important accessors are exported from Gtk4 but the more obscure will have to be called including the module name. For example, the property resizable for a GtkWindow, which controls whether a user is allowed to resize the window, can be set using

julia> Gtk4.resizable(win, false)

Binding properties

Properties can be bound to one another through the GObject signal system using the method bind_property. For example, if one wanted the title of a window win2 to automatically track that of another window win1, one could use

julia> b = bind_property(win1, "title", win2, "title")

Now if one calls

julia> win1.title = "New title"

the title of win2 is automatically updated to the same value. The binding can be released using unbind_property(b).

diff --git a/previews/PR68/manual/signals/index.html b/previews/PR68/manual/signals/index.html index 90d5509a..96b66d4d 100644 --- a/previews/PR68/manual/signals/index.html +++ b/previews/PR68/manual/signals/index.html @@ -67,4 +67,4 @@ signal_connect(button_cb, button, "clicked", Nothing, (), false, (label, counter))

You should note that the value of counter[] matches the display in the GUI.

Specifying the event type

If your callback function takes an event argument, it is important to declare its type correctly. An easy way to do that is to first write a callback using the "simple" interface, e.g.,

    signal_connect(win, "delete-event") do widget, event
         @show typeof(event)
         @show event
-    end

and then use the reported type in parameter_type_tuple.

+ end

and then use the reported type in parameter_type_tuple.

diff --git a/previews/PR68/manual/textwidgets/index.html b/previews/PR68/manual/textwidgets/index.html index 67483512..f95c8873 100644 --- a/previews/PR68/manual/textwidgets/index.html +++ b/previews/PR68/manual/textwidgets/index.html @@ -8,4 +8,4 @@ str = ent.text

A maximum number of characters can be set using ent.max_length = 10.

Sometimes you might want to make the widget non-editable. This can be done using the call

# using the accessor method
 Gtk4.editable(GtkEditable(ent),false)
 # using the property system
-ent.editable = false

If you want to use the entry to retrieve passwords you can hide the visibility of the entered text. This can be achieved by calling

ent.visibility = false

To get notified by changes to the entry one can listen to the "changed" event.

GtkSearchEntry

A special variant of the entry that can be used as a search box is GtkSearchEntry. It is equipped with a button to clear the entry.

+ent.editable = false

If you want to use the entry to retrieve passwords you can hide the visibility of the entered text. This can be achieved by calling

ent.visibility = false

To get notified by changes to the entry one can listen to the "changed" event.

GtkSearchEntry

A special variant of the entry that can be used as a search box is GtkSearchEntry. It is equipped with a button to clear the entry.

diff --git a/previews/PR68/search/index.html b/previews/PR68/search/index.html index 4ff82dc3..3e3a6e28 100644 --- a/previews/PR68/search/index.html +++ b/previews/PR68/search/index.html @@ -1,2 +1,2 @@ -Search · Gtk4.jl

Loading search...

    +Search · Gtk4.jl

    Loading search...