Skip to content

Commit

Permalink
use Documenter 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Sep 16, 2023
1 parent 3dd0f52 commit 2bdc21f
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "v0.24"
Documenter = "1"
4 changes: 3 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
File renamed without changes.
6 changes: 0 additions & 6 deletions docs/src/doc/GLib_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,3 @@ Public = true
Private = false
```

### Constants

```@autodocs
Modules = [Gtk4.GLib]
Order = [:constant]
```
12 changes: 3 additions & 9 deletions docs/src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Public interface

```@autodocs
Modules = [Gtk4]
Modules = [Gtk4, Gtk4.GdkPixbufLib]
Order = [:module, :function, :macro]
Public = true
Private = false
Expand All @@ -12,7 +12,7 @@ Private = false
### Private methods

```@autodocs
Modules = [Gtk4]
Modules = [Gtk4, Gtk4.GdkPixbufLib]
Order = [:module, :type, :function, :macro]
Public = false
Private = true
Expand All @@ -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]
```
41 changes: 41 additions & 0 deletions docs/src/manual/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
23 changes: 22 additions & 1 deletion src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
33 changes: 26 additions & 7 deletions src/buttons.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2bdc21f

Please sign in to comment.