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