Skip to content

Commit

Permalink
Merge branch 'main' into jw/newdialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Jun 23, 2024
2 parents 77975fa + be7fcb3 commit 34f1e3c
Show file tree
Hide file tree
Showing 50 changed files with 1,020 additions and 282 deletions.
30 changes: 16 additions & 14 deletions GI/src/giexport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ end

function struct_cache_expr!(exprs)
gboxed_types_list = quote
gboxed_types = Any[]
const gboxed_types = Any[]
end
push!(exprs,unblock(gboxed_types_list))
end
Expand Down Expand Up @@ -89,10 +89,12 @@ function struct_exprs!(exprs,exports,ns,structs=nothing;print_summary=true,exclu
fields=get_fields(ssi)
if only_opaque && length(fields)>0 && !in(name,import_as_opaque)
imported-=1
push!(struct_skiplist,name)
continue
end
if occursin("Private",String(name))
imported-=1
push!(struct_skiplist,name)
continue
end
if is_gtype_struct(ssi) # these are "class structures" and according to the documentation we probably don't need them in bindings
Expand Down Expand Up @@ -120,19 +122,24 @@ function struct_exprs!(exprs,exports,ns,structs=nothing;print_summary=true,exclu
length(fields)>0 && push!(exports.args,get_struct_name(ssi,false))
end

for ss in structs
if print_summary
printstyled("Generated ",imported," structs out of ",length(structs),"\n";color=:green)
end

struct_skiplist
end

function struct_constructor_exprs!(exprs,ns;constructor_skiplist=[], struct_skiplist=[], exclude_deprecated=true,first_list=[])
s=get_non_skipped(ns,GIStructInfo,struct_skiplist,exclude_deprecated)
structs = get_name.(s)
for ss in vcat(first_list, structs)
println("struct constructor: ",ss)
ssi=gi_find_by_name(ns,ss)
constructors = get_constructors(ssi;skiplist=constructor_skiplist, struct_skiplist=struct_skiplist, exclude_deprecated=exclude_deprecated)
if !isempty(constructors)
append!(exprs,constructors)
end
end

if print_summary
printstyled("Generated ",imported," structs out of ",length(structs),"\n";color=:green)
end

struct_skiplist
end

function all_struct_exprs!(exprs,exports,ns;print_summary=true,excludelist=[],constructor_skiplist=[],import_as_opaque=Symbol[],output_cache_init=true,only_opaque=false,exclude_deprecated=true)
Expand Down Expand Up @@ -171,13 +178,7 @@ function all_struct_exprs!(exprs,exports,ns;print_summary=true,excludelist=[],co
end
push!(exprs,unblock(gboxed_types_init))
end


for ssi in ss
constructors = get_constructors(ssi;skiplist=constructor_skiplist, struct_skiplist=struct_skiplist, exclude_deprecated=exclude_deprecated)
isempty(constructors) || append!(exprs,constructors)
end

if print_summary
printstyled("Generated ",imported," structs out of ",length(ss),"\n";color=:green)
end
Expand Down Expand Up @@ -219,6 +220,7 @@ function export_struct_exprs!(ns,path,prefix, struct_skiplist, import_as_opaque;
end
all_interfaces!(exprs,exports,ns; skiplist = interface_skiplist, exclude_deprecated = exclude_deprecated)
c = all_objects!(exprs,exports,ns;handled=[:Object],skiplist=object_skiplist,output_cache_init = output_object_cache_init, output_cache_define = output_object_cache_define, constructor_skiplist = object_constructor_skiplist,exclude_deprecated=exclude_deprecated)
struct_constructor_exprs!(exprs,ns;constructor_skiplist=constructor_skiplist,exclude_deprecated=exclude_deprecated,struct_skiplist=struct_skiplist,first_list=first_list)
if doc_xml !== nothing
append_object_docs!(exprs, doc_prefix, doc_xml, c, ns; skiplist = doc_skiplist)
end
Expand Down
10 changes: 5 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Gtk4"
uuid = "9db2cae5-386f-4011-9d63-a5602296539b"
version = "0.6.4"
version = "0.6.7"

[deps]
BitFlags = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35"
Expand Down Expand Up @@ -33,20 +33,20 @@ Cairo = "1.0.0"
Cairo_jll = "1.16.0"
ColorTypes = "0.10, 0.11"
FixedPointNumbers = "0.5, 0.6, 0.7, 0.8"
GTK4_jll = "4.6.0"
Glib_jll = "2.74.0"
GTK4_jll = "4.12.0"
Glib_jll = "2.78.0"
Graphene_jll = "1.10"
Graphics = "1"
JLLWrappers = "1.4.0"
Libdl = "1.6"
libpng_jll = "<1.6.42"
Librsvg_jll = "2.54"
Pango_jll = "1.50"
Pango_jll = "1.51"
Preferences = "1"
Reexport = "1.0"
Scratch = "1.1.0"
Xorg_xkeyboard_config_jll = "2.27.0"
adwaita_icon_theme_jll = "3,43"
gdk_pixbuf_jll = "2.38.2"
gdk_pixbuf_jll = "2.42.0"
hicolor_icon_theme_jll = "0.17.0"
julia = "1.6"
2 changes: 2 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ makedocs(
"manual/signals.md",
"manual/builder.md",
"manual/actions.md",
"manual/buttons.md",
"manual/textwidgets.md",
"manual/display.md",
"manual/combobox.md",
"manual/listtreeview.md",
"manual/dialogs.md",
Expand Down
4 changes: 4 additions & 0 deletions docs/src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Gtk4.toplevels

```@docs
Gtk4.configure!
Gtk4.selected_string!
Gtk4.selected_string
```

## Dialogs
Expand Down Expand Up @@ -85,6 +87,8 @@ Gtk4.add_action_shortcut

```@docs
Gtk4.buffer
Gtk4.undo!
Gtk4.redo!
Gtk4.create_mark
Gtk4.place_cursor
Gtk4.scroll_to
Expand Down
3 changes: 2 additions & 1 deletion docs/src/howto/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ robustly.
Here is an example using [threads](https://docs.julialang.org/en/v1/manual/multi-threading/).
Notice that this example will freeze the UI during computation unless Julia is run with two
or more threads, for example by calling `julia -t2` or `julia -t1,1` to use the interactive
threadpool in recent versions of Julia.
thread pool in recent versions of Julia.
If an interactive thread pool exists, the GLib main loop will be started in an interactive thread.

```julia
using Gtk4
Expand Down
2 changes: 1 addition & 1 deletion docs/src/manual/actions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Actions

Actions are another way of associating callbacks with widgets. While they are a bit more complicated to set up, they have a few advantages over connecting to widget signals such as "clicked".
[Actions](https://docs.gtk.org/gtk4/actions.html) are another way of associating callbacks with widgets. While they are a bit more complicated to set up, they have a few advantages over connecting to widget signals such as "clicked".

Actions are based on an interface `GAction`, the most straightforward implementation of which is `GSimpleAction`. Actions have a property "name" which must be a non-empty string consisting of alphanumeric characters, dashes ('-'), and dots ('.'). Actions also have a method `activate` that takes an optional parameter argument (more on those later).

Expand Down
2 changes: 0 additions & 2 deletions docs/src/manual/builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ the extension `.ui`. Let's assume we have created a file `myapp.ui` that looks l
<property name="child">
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">button</property>
<property name="use_action_appearance">False</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
<property name="use_action_appearance">False</property>
</object>
</property>
</object>
Expand Down
77 changes: 77 additions & 0 deletions docs/src/manual/buttons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Buttons

GTK defines many button and button-like widgets.

## [GtkButton](https://docs.gtk.org/gtk4/class.Button.html)

We have already encountered the widget `GtkButton`, which defines a "clicked" signal that can be used to let the user trigger callback functions.

The button holds a child widget that can be a `GtkLabel` in the case of text, an image-displaying widget in the case of an icon, or potentially anything else you want. The child widget can be set and accessed using `getindex(b::GtkButton)` and `setindex!(b::GtkButton, child_widget::GtkWidget)`:
```julia
b = GtkButton()
b[] = my_widget
child_widget = b[]
```

You can also associate an action (see [Actions](@ref)) with a button by setting its property "action-name".

Selected signals:

| signal | arguments | returns | |
| :--- | :--- | :--- | :--- |
| "clicked" | self::GtkButton | `Nothing` | Emitted when the button is clicked |

## [GtkToggleButton](https://docs.gtk.org/gtk4/class.ToggleButton.html)

This widget looks like a button but it stays pressed when the user clicks it. The state of the button can be accessed or set using its property "active", which is `true` when the button is pressed.

A toggle button can be added to a group using the method `group`, in which case it can be used to select from mutually exclusive options:
```julia
using Gtk4

red_button = GtkToggleButton("red")
green_button = GtkToggleButton("green")
blue_button = GtkToggleButton("blue")
win = GtkWindow("choose one color")
win[] = box = GtkBox(:v)
push!(box, red_button)
push!(box, green_button)
push!(box, blue_button)

group(green_button, red_button)
group(blue_button, red_button)
# now only one button can be active at a time
```

Selected signals:

| signal | arguments | returns | |
| :--- | :--- | :--- | :--- |
| "toggled" | self::GtkToggleButton | `Nothing` | Emitted when the button state is changed |


## [GtkCheckButton](https://docs.gtk.org/gtk4/class.CheckButton.html)

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:

| signal | arguments | returns | |
| :--- | :--- | :--- | :--- |
| "toggled" | self::GtkCheckButton | `Nothing` | Emitted when the button state is changed |

## [GtkSwitch](https://docs.gtk.org/gtk4/class.Switch.html)

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](https://docs.gtk.org/gtk4/class.LinkButton.html)

This widget can be used to open a URL:

```julia
lb = GtkLinkButton("https://julialang.org","Julia website")
```
6 changes: 3 additions & 3 deletions docs/src/manual/combobox.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
One often needs a widget to allow a user to select something from a few options. There are
two easy ways to do this in Gtk4.jl.

## GtkDropDown
## [GtkDropDown](https://docs.gtk.org/gtk4/class.DropDown.html)

A simple option that was introduced in GTK version 4 is `GtkDropDown`. An example is shown below.

Expand Down Expand Up @@ -42,13 +42,13 @@ push!(m, "five")
More complex uses of `GtkDropDown` are possible by using models other than
`GtkStringList`. This may be supported in future versions of Gtk4.jl.

## GtkComboBox
## [GtkComboBox](https://docs.gtk.org/gtk4/class.ComboBox.html)

The older API for dropdown menu functionality is `GtkComboBox`.
The full, generic `GtkComboBox` widget is powerful but harder to use and won't be covered
here. The simpler `GtkComboBoxText` subtype allows the user to select from text options.

### GtkComboBoxText
### [GtkComboBoxText](https://docs.gtk.org/gtk4/class.ComboBoxText.html)

The following example shows how to fill a `GtkComboBoxText` with elements and
listen on the `changed` event (this example is functionally equivalent to the example above for `GtkDropDown`):
Expand Down
46 changes: 46 additions & 0 deletions docs/src/manual/display.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Display widgets

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

## [GtkSpinner](https://docs.gtk.org/gtk4/class.Spinner.html)

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](https://docs.gtk.org/gtk4/class.ProgressBar.html)

This widget shows a progress bar and optionally text.

```julia
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:
```julia
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:
```julia
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:

```julia
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](https://docs.gtk.org/gtk4/class.Picture.html) and [GtkImage](https://docs.gtk.org/gtk4/class.Image.html)

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`.
14 changes: 7 additions & 7 deletions docs/src/manual/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Gtk4 provides many layout widgets for arranging widgets in a window.
!!! note
For larger projects it might be a good idea to create the layout using Cambalache in combination with `GtkBuilder`. See [Builder](@ref).

## GtkBox
## [GtkBox](https://docs.gtk.org/gtk4/class.Box.html)

The layout widget used most often is `GtkBox`. It is one-dimensional and can be either be horizontally or vertical aligned.
```julia
Expand Down Expand Up @@ -49,7 +49,7 @@ Julia interface methods defined for `GtkBox`:
| `delete!(b::GtkBox, w::GtkWidget)` | Removes a widget from the box |
| `empty!(b::GtkBox)` | Removes all widgets from the box |

## GtkGrid
## [GtkGrid](https://docs.gtk.org/gtk4/class.Grid.html)

To create two-dimensional (tabular) layouts of widgets, you can use `GtkGrid`:
```julia
Expand Down Expand Up @@ -94,7 +94,7 @@ Julia interface methods defined for `GtkGrid`:
| `delete!(g::GtkGrid, w::GtkWidget)` | Removes a widget from the grid |
| `empty!(g::GtkGrid)` | Removes all widgets from the grid |

## GtkCenterBox
## [GtkCenterBox](https://docs.gtk.org/gtk4/class.CenterBox.html)

The `GtkCenterBox` widget can hold 3 widgets in a line, either horizontally or
vertically oriented. It keeps the middle widget centered. Child widgets can be set and accessed like this:
Expand All @@ -114,7 +114,7 @@ Julia interface methods defined for `GtkCenterBox`:
| `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
## [GtkPaned](https://docs.gtk.org/gtk4/class.Paned.html)

The `GtkPaned` widget creates two slots separated by a movable divider. Like `GtkBox` and `GtkCenterBox`, it can
be oriented either vertically or horizontally. To add child widgets, you can use
Expand All @@ -131,7 +131,7 @@ Julia interface methods defined for `GtkPaned`:
| `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
## [GtkNotebook](https://docs.gtk.org/gtk4/class.Notebook.html)

The `GtkNotebook` widget places child widgets in tabs like a browser window.
Child widgets can be inserted with a label like this:
Expand All @@ -154,7 +154,7 @@ Julia interface methods defined for `GtkNotebook`:
| `deleteat!(n::GtkNotebook, x::GtkWidget)` | Removes a widget from the notebook |
| `empty!(n::GtkNotebook)` | Removes all widgets from the notebook |

## GtkStack
## [GtkStack](https://docs.gtk.org/gtk4/class.Stack.html)

The `GtkStack` widget is a lot like `GtkNotebook`, but a separate widget `GtkStackSwitcher` controls what page is shown.
An interface very similar to `GtkNotebook` is defined:
Expand Down Expand Up @@ -183,7 +183,7 @@ Julia interface methods defined for `GtkStack`:
| `delete!(s::GtkStack, x::GtkWidget)` | Removes a widget from the stack |
| `empty!(s::GtkStack)` | Removes all widgets from the stack |

## GtkFrame, GtkAspectFrame, and GtkExpander
## [GtkFrame](https://docs.gtk.org/gtk4/class.Frame.html), [GtkAspectFrame](https://docs.gtk.org/gtk4/class.AspectFrame.html), and [GtkExpander](https://docs.gtk.org/gtk4/class.Expander.html)

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.

Expand Down
Loading

0 comments on commit 34f1e3c

Please sign in to comment.