From 0178c0f925f472f4c76a310695ce2650808e64c7 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sun, 24 Sep 2023 02:03:35 +0000 Subject: [PATCH] build based on d8c7868 --- dev/diff3to4/index.html | 2 +- dev/doc/GLib_reference/index.html | 2 +- dev/doc/constants_reference/index.html | 2 +- dev/doc/preferences/index.html | 2 +- dev/doc/reference/index.html | 18 +++++++++--------- dev/howto/async/index.html | 2 +- dev/howto/nonreplusage/index.html | 2 +- dev/howto/sysimage/index.html | 2 +- dev/index.html | 2 +- dev/manual/builder/index.html | 2 +- dev/manual/canvas/index.html | 2 +- dev/manual/combobox/index.html | 2 +- dev/manual/dialogs/index.html | 2 +- dev/manual/gettingStarted/index.html | 2 +- dev/manual/keyevents/index.html | 2 +- dev/manual/layout/index.html | 2 +- dev/manual/listtreeview/index.html | 2 +- dev/manual/methods/index.html | 2 +- dev/manual/properties/index.html | 2 +- dev/manual/signals/index.html | 2 +- dev/manual/textwidgets/index.html | 2 +- dev/search/index.html | 2 +- 22 files changed, 30 insertions(+), 30 deletions(-) diff --git a/dev/diff3to4/index.html b/dev/diff3to4/index.html index 97307bd8..e4c62936 100644 --- a/dev/diff3to4/index.html +++ b/dev/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, and calling show is no longer necessary in most situations. Exceptions include GtkDialogs and GtkApplicationWindows.

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, and calling show is no longer necessary in most situations. Exceptions include GtkDialogs and GtkApplicationWindows.

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/dev/doc/GLib_reference/index.html b/dev/doc/GLib_reference/index.html index 8ff6e39c..4c9f4384 100644 --- a/dev/doc/GLib_reference/index.html +++ b/dev/doc/GLib_reference/index.html @@ -1,2 +1,2 @@ -GLib Reference · Gtk4.jl

GLib Reference

Public interface

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.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_source_removeMethod
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.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. The function is expected to return a Cint. If it returns a nonzero value, the function will be called again after another interval milliseconds. Otherwise 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.

Related GTK function: g_timeout_add()

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

Private methods

Base.runMethod
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
Gtk4.GLib.pause_main_loopMethod
pause_main_loop(f)

Pauses the GLib eventloop around a function. Restores the original state of the eventloop after calling the function.

source
Gtk4.GLib.propertyinfoMethod
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.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
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.waitforsignalMethod
waitforsignal(obj::GObject, signal)

Returns when a GObject's signal is emitted. Can be used to wait for a window to be closed.

source

Types

+GLib Reference · Gtk4.jl

GLib Reference

Public interface

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.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_source_removeMethod
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.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. The function is expected to return a Cint. If it returns a nonzero value, the function will be called again after another interval milliseconds. Otherwise 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.

Related GTK function: g_timeout_add()

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

Private methods

Base.runMethod
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
Gtk4.GLib.pause_main_loopMethod
pause_main_loop(f)

Pauses the GLib eventloop around a function. Restores the original state of the eventloop after calling the function.

source
Gtk4.GLib.propertyinfoMethod
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.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
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.waitforsignalMethod
waitforsignal(obj::GObject, signal)

Returns when a GObject's signal is emitted. Can be used to wait for a window to be closed.

source

Types

diff --git a/dev/doc/constants_reference/index.html b/dev/doc/constants_reference/index.html index eb1425df..2966a786 100644 --- a/dev/doc/constants_reference/index.html +++ b/dev/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/dev/doc/preferences/index.html b/dev/doc/preferences/index.html index 4b494f38..91838aa4 100644 --- a/dev/doc/preferences/index.html +++ b/dev/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/dev/doc/reference/index.html b/dev/doc/reference/index.html index c9322d20..9b4aeab9 100644 --- a/dev/doc/reference/index.html +++ b/dev/doc/reference/index.html @@ -1,15 +1,15 @@ -Gtk4 Reference · Gtk4.jl

Gtk4 Reference

Public interface

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
Graphics.getgcMethod
getgc(c::GtkCanvas)

Return the CairoContext of the CairoSurface for a GtkCanvas.

source
Gtk4.activateMethod
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.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.bufferMethod
buffer(iter::Union{Ref{_GtkTextIter}, _GtkTextIter})

Returns the buffer associated with iter.

source
Gtk4.configure!Method
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
Gtk4.configure!Method
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.create_markMethod
create_mark(buffer::GtkTextBuffer, mark_name, it::TI, left_gravity::Bool)
-create_mark(buffer::GtkTextBuffer, it::TI)

Impements gtk_text_buffer_create_mark.

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.place_cursorMethod
place_cursor(buffer::GtkTextBuffer, it::_GtkTextIter)
-place_cursor(buffer::GtkTextBuffer, pos::Int)

Place the cursor at indicated position.

source
Gtk4.presentMethod
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.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
Gtk4.screen_sizeFunction
screen_size(widget=nothing)

Returns a tuple (width,height) that gives the primary monitor size for the display where widget is being displayed, or the default display if widget is unrealized or not given.

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

Gtk4 Reference

Public interface

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
Graphics.getgcMethod
getgc(c::GtkCanvas)

Return the CairoContext of the CairoSurface for a GtkCanvas.

source
Gtk4.activateMethod
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.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.bufferMethod
buffer(iter::Union{Ref{_GtkTextIter}, _GtkTextIter})

Returns the buffer associated with iter.

source
Gtk4.configure!Method
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
Gtk4.configure!Method
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.create_markMethod
create_mark(buffer::GtkTextBuffer, mark_name, it::TI, left_gravity::Bool)
+create_mark(buffer::GtkTextBuffer, it::TI)

Impements gtk_text_buffer_create_mark.

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.place_cursorMethod
place_cursor(buffer::GtkTextBuffer, it::_GtkTextIter)
+place_cursor(buffer::GtkTextBuffer, pos::Int)

Place the cursor at indicated position.

source
Gtk4.presentMethod
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.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
Gtk4.screen_sizeFunction
screen_size(widget=nothing)

Returns a tuple (width,height) that gives the primary monitor size for the display where widget is being displayed, or the default display if widget is unrealized or not given.

source
Gtk4.scroll_toMethod
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_rangeMethod
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_boundsMethod
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
Gtk4.widgetFunction
widget(c::GtkEventController)

Returns the widget associated with an event controller.

source
Gtk4.@load_builderMacro
@load_builder(b::GtkBuilder)

Loads all GtkBuildable objects from a GtkBuilder object and assigns them to Julia variables in the current scope. GtkBuilder ID's are mapped onto Julia variable names.

source

Private methods

Base.skipMethod
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
Base.skipMethod
skip(iter::Ref{_GtkTextIter}, count::Integer)

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

source
Base.skipMethod
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
Gtk4.backward_searchMethod
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_rangeMethod
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_boundsMethod
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
Gtk4.widgetFunction
widget(c::GtkEventController)

Returns the widget associated with an event controller.

source
Gtk4.@load_builderMacro
@load_builder(b::GtkBuilder)

Loads all GtkBuildable objects from a GtkBuilder object and assigns them to Julia variables in the current scope. GtkBuilder ID's are mapped onto Julia variable names.

source

Private methods

Base.skipMethod
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
Base.skipMethod
skip(iter::Ref{_GtkTextIter}, count::Integer)

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

source
Base.skipMethod
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
Gtk4.backward_searchMethod
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_offsetMethod
char_offset(iter::Union{Ref{_GtkTextIter}, _GtkTextIter})

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

source
Gtk4.find_controllerMethod
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.forward_searchMethod
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_offsetMethod
char_offset(iter::Union{Ref{_GtkTextIter}, _GtkTextIter})

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

source
Gtk4.find_controllerMethod
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.forward_searchMethod
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.monitorMethod
monitor(w::GtkWidget)

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

source
Gtk4.monitorsMethod
monitors()

Returns a list of GdkMonitors for the default GdkDisplay, or nothing if none are found.

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

Types

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.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.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._GtkTextIterMethod
_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.monitorMethod
monitor(w::GtkWidget)

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

source
Gtk4.monitorsMethod
monitors()

Returns a list of GdkMonitors for the default GdkDisplay, or nothing if none are found.

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

Types

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.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.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._GtkTextIterMethod
_GtkTextIter(text::GtkTextBuffer, char_offset::Integer)

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

source
diff --git a/dev/howto/async/index.html b/dev/howto/async/index.html index e6248c35..e9cc637c 100644 --- a/dev/howto/async/index.html +++ b/dev/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/dev/howto/nonreplusage/index.html b/dev/howto/nonreplusage/index.html index 248d4662..8874ef32 100644 --- a/dev/howto/nonreplusage/index.html +++ b/dev/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/dev/howto/sysimage/index.html b/dev/howto/sysimage/index.html index ea845247..b91eae03 100644 --- a/dev/howto/sysimage/index.html +++ b/dev/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/dev/index.html b/dev/index.html index 39c0995d..a69d9183 100644 --- a/dev/index.html +++ b/dev/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 was 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 was 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/dev/manual/builder/index.html b/dev/manual/builder/index.html index 6aa75711..8adcc841 100644 --- a/dev/manual/builder/index.html +++ b/dev/manual/builder/index.html @@ -15,4 +15,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")

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

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

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.

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

diff --git a/dev/manual/canvas/index.html b/dev/manual/canvas/index.html index 49781189..ed5b8a2a 100644 --- a/dev/manual/canvas/index.html +++ b/dev/manual/canvas/index.html @@ -41,4 +41,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

A more complicated example can be found in the "examples" subdirectory. For interactive plots, you can try Gtk4Makie.jl, which draws GLMakie plots onto GTK's GtkGLArea widget.

+end

A more complicated example can be found in the "examples" subdirectory. For interactive plots, you can try Gtk4Makie.jl, which draws GLMakie plots onto GTK's GtkGLArea widget.

diff --git a/dev/manual/combobox/index.html b/dev/manual/combobox/index.html index de3dc0df..2fa5021f 100644 --- a/dev/manual/combobox/index.html +++ b/dev/manual/combobox/index.html @@ -35,4 +35,4 @@ end win = GtkWindow("ComboBoxText Example",400,200) -push!(win, cb) +push!(win, cb) diff --git a/dev/manual/dialogs/index.html b/dev/manual/dialogs/index.html index e018e573..63432b06 100644 --- a/dev/manual/dialogs/index.html +++ b/dev/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/dev/manual/gettingStarted/index.html b/dev/manual/gettingStarted/index.html index d0c58eb8..013f98c5 100644 --- a/dev/manual/gettingStarted/index.html +++ b/dev/manual/gettingStarted/index.html @@ -18,4 +18,4 @@ function on_button_clicked(w) println("The button has been clicked") end -signal_connect(on_button_clicked, b, "clicked") +signal_connect(on_button_clicked, b, "clicked") diff --git a/dev/manual/keyevents/index.html b/dev/manual/keyevents/index.html index b406ec5f..f5d7ff28 100644 --- a/dev/manual/keyevents/index.html +++ b/dev/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/dev/manual/layout/index.html b/dev/manual/layout/index.html index 9e4d1d67..bc0b5cfc 100644 --- a/dev/manual/layout/index.html +++ b/dev/manual/layout/index.html @@ -39,4 +39,4 @@ push!(s, GtkLabel("First label"), "id1", "Label 1") # first string is an id, second is a label push!(s, GtkLabel("Second label"), "id2", "Label 2") # widget can be retrieved using s[id]

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 w in widget
     myfunc(w)
-end
+end diff --git a/dev/manual/listtreeview/index.html b/dev/manual/listtreeview/index.html index 08ae462a..b3d98816 100644 --- a/dev/manual/listtreeview/index.html +++ b/dev/manual/listtreeview/index.html @@ -94,4 +94,4 @@ win = GtkWindow(tv, "Tree View") iter = Gtk4.iter_from_index(ts, [1]) -ts[iter,1] = "ONE" +ts[iter,1] = "ONE" diff --git a/dev/manual/methods/index.html b/dev/manual/methods/index.html index 1e616630..57fb11f5 100644 --- a/dev/manual/methods/index.html +++ b/dev/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 GObjectconstructorname, 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 GObjectconstructorname, 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/dev/manual/properties/index.html b/dev/manual/properties/index.html index 4b2f10dc..8a877f79 100644 --- a/dev/manual/properties/index.html +++ b/dev/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/dev/manual/signals/index.html b/dev/manual/signals/index.html index 7b7e3329..ac1f81c0 100644 --- a/dev/manual/signals/index.html +++ b/dev/manual/signals/index.html @@ -41,4 +41,4 @@ end

and then use the reported type in parameter_type_tuple.

@guarded

The "simple" callback interface includes protections against corrupting Gtk state from errors, but this @cfunction-based approach does not. Consequently, you may wish to use @guarded when writing these functions. (Canvas draw functions and mouse event-handling are called through this interface, which is why you should use @guarded there.) For functions that should return a value, you can specify the value to be returned on error as the first argument. For example:

    const unhandled = convert(Int32, false)
     @guarded unhandled function my_callback(widgetptr, ...)
         ...
-    end
+ end diff --git a/dev/manual/textwidgets/index.html b/dev/manual/textwidgets/index.html index f9a74b10..56588cbb 100644 --- a/dev/manual/textwidgets/index.html +++ b/dev/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.

Search Entry

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.

Search Entry

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/dev/search/index.html b/dev/search/index.html index d63de707..2721bde5 100644 --- a/dev/search/index.html +++ b/dev/search/index.html @@ -1,2 +1,2 @@ -Search · Gtk4.jl

Loading search...

    +Search · Gtk4.jl

    Loading search...