Skip to content

Commit

Permalink
add docs and an example for menus
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Sep 28, 2024
1 parent a535d9e commit b9c4b63
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ makedocs(
"manual/builder.md",
"manual/actions.md",
"manual/buttons.md",
"manual/menus.md",
"manual/textwidgets.md",
"manual/display.md",
"manual/combobox.md",
Expand Down
21 changes: 21 additions & 0 deletions examples/menubutton.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Gtk4, Gtk4.GLib

# simple example defining a menu and showing it using a GtkMenuButton

# the menu items are grayed out and unresponsive because no actions are defined!

win = GtkWindow("MenuButton example")
mb = GtkMenuButton(;icon_name="open-menu-symbolic")

menu = GMenu()
item1 = GMenuItem("Open...", "app.open")
push!(menu,item1)
item2 = GMenuItem("Save...", "app.save")
push!(menu,item2)
item3 = GMenuItem("Quit", "app.quit")
push!(menu,item3)

Gtk4.menu_model(mb, menu)

win[] = mb

6 changes: 6 additions & 0 deletions src/GLib/actions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ function GMenu(i::GMenuItem)
G_.set_submenu(i,m)
m
end
"""
GMenuItem(label, [detailed_action])
Create a GMenuItem with attributes `label` and an optional `detailed_action`, which is
an action name with an optional detail argument.
"""
GMenuItem(label,detailed_action = nothing) = G_.MenuItem_new(label, detailed_action)

push!(m::GMenu, i::GMenuItem) = (G_.append_item(m,i); m)
Expand Down
2 changes: 1 addition & 1 deletion test/gui/window.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ visible(w,true)

@test Gtk4.issuspended(w) == false
@test Gtk4.isfullscreen(w) == false
#@test Gtk4.isactive(w) == true
#@test Gtk4.isactive(w) == true # fails on Ubuntu in CI

m = Gtk4.monitor(w)
if m!==nothing
Expand Down

0 comments on commit b9c4b63

Please sign in to comment.