diff --git a/docs/Project.toml b/docs/Project.toml index a064dd85..1814eb33 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -2,4 +2,4 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" [compat] -Documenter = "v0.24" +Documenter = "1" diff --git a/docs/make.jl b/docs/make.jl index e48211b2..f2750b21 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,7 +2,8 @@ using Documenter, Gtk4 makedocs( format = Documenter.HTML( - prettyurls = get(ENV, "CI", nothing) == "true" + prettyurls = get(ENV, "CI", nothing) == "true", + size_threshold_ignore = ["doc/GLib_reference.md","doc/reference.md","doc/constants_reference.md"] ), modules = [Gtk4], sitename = "Gtk4.jl", @@ -29,6 +30,7 @@ makedocs( "Gtk.jl to Gtk4.jl" => "diff3to4.md", "Reference" => ["doc/reference.md", "doc/GLib_reference.md", + "doc/constants_reference.md", "doc/preferences.md" ], #"GI Reference" => "doc/GI_reference.md" diff --git a/docs/src/doc/GI_reference.md b/docs/src/doc/GI_reference similarity index 100% rename from docs/src/doc/GI_reference.md rename to docs/src/doc/GI_reference diff --git a/docs/src/doc/GLib_reference.md b/docs/src/doc/GLib_reference.md index 825fd30d..738d2952 100644 --- a/docs/src/doc/GLib_reference.md +++ b/docs/src/doc/GLib_reference.md @@ -27,9 +27,3 @@ Public = true Private = false ``` -### Constants - -```@autodocs -Modules = [Gtk4.GLib] -Order = [:constant] -``` diff --git a/docs/src/doc/reference.md b/docs/src/doc/reference.md index 9f248d70..bb2cf8c1 100644 --- a/docs/src/doc/reference.md +++ b/docs/src/doc/reference.md @@ -3,7 +3,7 @@ ### Public interface ```@autodocs -Modules = [Gtk4] +Modules = [Gtk4, Gtk4.GdkPixbufLib] Order = [:module, :function, :macro] Public = true Private = false @@ -12,7 +12,7 @@ Private = false ### Private methods ```@autodocs -Modules = [Gtk4] +Modules = [Gtk4, Gtk4.GdkPixbufLib] Order = [:module, :type, :function, :macro] Public = false Private = true @@ -21,15 +21,9 @@ Private = true ### Types ```@autodocs -Modules = [Gtk4] +Modules = [Gtk4, Gtk4.GdkPixbufLib] Order = [:type] Public = true Private = false ``` -### Constants - -```@autodocs -Modules = [Gtk4] -Order = [:constant] -``` diff --git a/docs/src/manual/layout.md b/docs/src/manual/layout.md index a2ae480c..d97444e8 100644 --- a/docs/src/manual/layout.md +++ b/docs/src/manual/layout.md @@ -40,6 +40,15 @@ push!(hbox, sep) # add more widgets here ``` +Julia interface methods defined for `GtkBox`: + +| method | what it does | +| :--- | :--- | +| `push!(b::GtkBox, w::GtkWidget)` | Adds a widget to the end of the box | +| `pushfirst!(b::GtkBox, w::GtkWidget)` | Adds a widget to the beginning of the box | +| `delete!(b::GtkBox, w::GtkWidget)` | Removes a widget from the box | +| `empty!(b::GtkBox)` | Removes all widgets from the box | + ## GtkGrid To create two-dimensional (tabular) layouts of widgets, you can use `GtkGrid`: @@ -67,6 +76,24 @@ A range is used to indicate a span of grid cells. By default, each row/column will use only as much space as required to contain the objects, but you can force them to be of the same size by setting properties like `column_homogeneous`. +A useful method for `GtkGrid` is `query_child`, which can be used to get the coordinates and span of a widget currently in the grid: +```julia +julia> Gtk4.query_child(g,c) +(1, 2, 2, 1) +``` +Here, 1 is the column, 2 is the row, and the widget spans 2 columns and 1 row. + +Julia interface methods defined for `GtkGrid`: + +| method | what it does | +| :--- | :--- | +| `getindex(g::GtkGrid, c::Integer, r::Integer)` or `g[c,r]` | Gets a widget, where `c` and `r` are the column and row indices | +| `setindex!(g::GtkGrid, w::GtkWidget, c::Integer, r::Integer)` or `g[i,j] = w` | Sets a widget | +| `insert!(g::GtkGrid, i::Integer, side)` | Inserts a row or column next to the existing row or column with index `i`; `side` can be `:left`, `:right`, `top`, or `bottom`. | +| `insert!(g::GtkGrid, sibling::GtkWidget, side)` | Inserts a row or column next to the existing widget `sibling` that is already in the grid; `side` can be `:left`, `:right`, `top`, or `bottom`. | +| `delete!(g::GtkGrid, w::GtkWidget)` | Removes a widget from the grid | +| `empty!(g::GtkGrid)` | Removes all widgets from the grid | + ## GtkCenterBox The `GtkCenterBox` widget can hold 3 widgets in a line, either horizontally or @@ -80,6 +107,13 @@ cb[:end] = GtkButton("Right") For vertical orientation, `:start` refers to the top widget and `:end` to the bottom widget. +Julia interface methods defined for `GtkCenterBox`: + +| method | what it does | +| :--- | :--- | +| `getindex(b::GtkCenterBox, pos::Symbol)` or `b[pos]` | Gets a widget, where `pos` is `:start`, `:center`, or `:end` | +| `setindex!(b::GtkCenterBox, w::GtkWidget, pos::Symbol)` or `b[pos] = w` | Sets a widget | + ## GtkPaned The `GtkPaned` widget creates two slots separated by a movable divider. Like `GtkBox` and `GtkCenterBox`, it can @@ -90,6 +124,13 @@ paned[1] = top_or_left_widget paned[2] = bottom_or_right_widget ``` +Julia interface methods defined for `GtkPaned`: + +| method | what it does | +| :--- | :--- | +| `getindex(b::GtkPaned, i::Integer)` or `b[i]` | Gets a widget, where `i` is 1 or 2 | +| `setindex!(b::GtkPaned, w::GtkWidget, i::Integer)` or `b[i] = w` | Sets a widget | + ## GtkNotebook The `GtkNotebook` widget places child widgets in tabs like a browser window. diff --git a/src/base.jl b/src/base.jl index 5b250b9c..5233700d 100644 --- a/src/base.jl +++ b/src/base.jl @@ -192,6 +192,13 @@ end ## CSS, style +""" + GtkCssProvider(data, filename = nothing) + +Create a GtkCssProvider object using CSS from a string `data`. If `data` is set to `nothing`, CSS is instead loaded from a file `filename`. If both arguments are `nothing`, an empty GtkCssProvider is returned. + +Related GTK functions: [`gtk_css_provider_load_from_path`()]($(gtkdoc_method_url("gtk4","CssProvider","load_from_path"))), [`gtk_css_provider_load_from_data`()]($(gtkdoc_method_url("gtk4","CssProvider","load_from_data"))) +""" function GtkCssProvider(data::Union{AbstractString,Nothing}, filename = nothing) provider = G_.CssProvider_new() if data !== nothing @@ -223,9 +230,16 @@ function delete!(display::GdkDisplay, provider) end # because of a name collision this is annoying to generate using GI +""" + GtkIconTheme(d::GdkDisplay) + +Get the icon theme for a `GdkDisplay`. + +Related GTK function: [`gtk_icon_theme_get_for_display`()]($(gtkdoc_method_url("gtk4","IconTheme","get_for_display"))) +""" function GtkIconTheme(d::GdkDisplay) ret = ccall(("gtk_icon_theme_get_for_display",libgtk4), Ptr{GObject}, (Ptr{GObject},), d) - convert(GtkIconTheme, ret, false) + GtkIconThemeLeaf(ret, false) end function icon_theme_add_search_path(icon_theme::GtkIconTheme, path::AbstractString) @@ -234,6 +248,13 @@ end ## GtkApplication and actions +""" + GtkApplication(id = nothing, flags = GLib.ApplicationFlags_FLAGS_NONE) + +Create a `GtkApplication` with DBus id `id` and flags. + +Related GTK function: [`gtk_application_new`()]($(gtkdoc_method_url("gtk4","Application","new"))) +""" GtkApplication(id = nothing, flags = GLib.ApplicationFlags_FLAGS_NONE) = G_.Application_new(id,flags) function push!(app::GtkApplication, win::GtkWindow) G_.add_window(app, win) diff --git a/src/buttons.jl b/src/buttons.jl index 854eaa55..05d6b74d 100644 --- a/src/buttons.jl +++ b/src/buttons.jl @@ -1,10 +1,29 @@ ## GtkButton +""" + GtkButton(w::GtkWidget) + +Create a `GtkButton` and add a widget `w` as its child. +""" function GtkButton(w::GtkWidget) b = G_.Button_new() G_.set_child(b,w) b end + +""" + 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`()]($(gtkdoc_method_url("gtk4","Button","new_with_label"))), [`gtk_button_new_with_mnemonic`()]($(gtkdoc_method_url("gtk4","Button","new_with_mnemonic"))), [`gtk_button_new_from_icon_name`()]($(gtkdoc_method_url("gtk4","Button","new_from_icon_name"))) +""" function GtkButton(s::Symbol,str::AbstractString) if s === :mnemonic G_.Button_new_with_mnemonic(str) @@ -45,26 +64,26 @@ end ## GtkLinkButton -function GtkLinkButton(uri::AbstractString, label::AbstractString, visited::Bool) - b = GtkLinkButton(uri, label) +function GtkLinkButton(uri::AbstractString, label::AbstractString, visited::Bool; kwargs...) + b = GtkLinkButton(uri, label; kwargs...) G_.set_visited(b, visited) b end -function GtkLinkButton(uri::AbstractString, visited::Bool) - b = GtkLinkButton(uri) +function GtkLinkButton(uri::AbstractString, visited::Bool; kwargs...) + b = GtkLinkButton(uri; kwargs...) G_.set_visited(b, visited) b end -function GtkVolumeButton(value::Real) # 0 <= value <= 1 - b = GtkVolumeButton() +function GtkVolumeButton(value::Real; kwargs...) # 0 <= value <= 1 + b = GtkVolumeButton(; kwargs...) G_.set_value(b, value) b end popup(b::GtkMenuButton) = G_.popup(b) -function GtkPopoverMenu(model::GMenu, nested = false) +function GtkPopoverMenu(model::GMenu, nested::Bool = false) if nested G_.PopoverMenu_new_from_model_full(model, PopoverMenuFlags_Nested) else