How to create a modal dialog with Gtk.jl?

How can I create a modal dialog with Gtk.jl ?
The following code kind-of works:

# This example creates a modal dialog with two checkboxes.
using Gtk.ShortNames, GtkObservables

# define the default values
OPTION_A = false
OPTION_B = false
finished = false 

cb1 = checkbox(OPTION_A, label="Option A")
cb2 = checkbox(OPTION_B, label="Option B")
btnOK = button(label="OK")

win = Window("Dialog", 200, 72) |> (bx = Box(:v))
push!(bx, cb1)
push!(bx, cb2)
push!(bx, btnOK)

function on_button_clicked(win)
    global OPTION_A, OPTION_B, finished, win
    OPTION_A = observable(cb1)[]
    OPTION_B = observable(cb2)[]
    destroy(win)
    finished = true
end
signal_connect(on_button_clicked, widget(btnOK), "clicked")

Gtk.showall(win)
G_.keep_above(win, true)
G_.position(win, 800, 400)

while ! finished
    sleep(0.1)
end

println("Option A: $OPTION_A")
println("Option B: $OPTION_B")
nothing

The problem is, that this is a window with a close icon, and if I close the window the variable “finished” is not set to true and the script does not terminate…

How can I create a modal dialog window that does NOT have a close icon and no icon to enlarge to full screen?

Use a Dialog instead of a Window.

That file shows some examples. Messagedialog is a special form that has only a text widget. I usually define the dialog in glade.

Not working. I get:

julia> include("src/checkbox.jl")
ERROR: LoadError: MethodError(Gtk.GtkDialogLeaf, ("Dialog", 200, 72), 0xffffffffffffffff)
Stacktrace:
 [1] error(s::MethodError)
   @ Base ./error.jl:44
 [2] Gtk.GtkDialogLeaf(::String, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Gtk ~/.julia/packages/Gtk/OyCvN/src/GLib/gtype.jl:216
 [3] Gtk.GtkDialogLeaf(::String, ::Vararg{Any})
   @ Gtk ~/.julia/packages/Gtk/OyCvN/src/GLib/gtype.jl:214
 [4] Gtk.GtkDialog(::String, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Gtk ~/.julia/packages/Gtk/OyCvN/src/GLib/gtype.jl:226
 [5] Gtk.GtkDialog(::String, ::Vararg{Any})
   @ Gtk ~/.julia/packages/Gtk/OyCvN/src/GLib/gtype.jl:225
 [6] top-level scope
   @ ~/repos/dialog/src/checkbox.jl:13
 [7] include(fname::String)
   @ Base.MainInclude ./client.jl:476
 [8] top-level scope
   @ REPL[1]:1
in expression starting at /home/ufechner/repos/dialog/src/checkbox.jl:13

I am looking for a solution that does NOT require glade.

No need to use Glade, I found an example and it looks like this:

dialog = Dialog("My Dialog", GtkNullContainer(), GtkDialogFlags.MODAL,
                             Dict("gtk-cancel" => GtkResponseType.CANCEL,
                                  "gtk-ok"=> GtkResponseType.ACCEPT) )
  resize!(dialog, 1024, 600)
  box = G_.content_area(dialog)
  # now you can put things into the box. This will be shown above the buttons.

  ret = run(dialog)
  if ret == GtkResponseType.ACCEPT
   #....
  end
  destroy(dlg)

Not sure if you can omit the buttons.

This does not work:

julia> include("src/dialog.jl")
ERROR: LoadError: UndefVarError: GtkNullContainer not defined
Stacktrace:
 [1] top-level scope
   @ ~/repos/Dialog/src/dialog.jl:3
 [2] include(fname::String)
   @ Base.MainInclude ./client.jl:476
 [3] top-level scope
   @ REPL[1]:1
in expression starting at /home/ufechner/repos/Dialog/src/dialog.jl:3

I added using Gtk.ShortNames. Am I missing something?

OK, I changed using Gtk.ShortNames to using Gtk, and now I get the next error:

julia> include("src/dialog.jl")
ERROR: LoadError: UndefVarError: GtkDialogFlags not defined

using Gtk.GConstants