Gtk.jl
Gtk.jl copied to clipboard
GDK_BACKEND=broadway
I have a question about how to set the GDK_BACKEND. The desired behavior is to run the Gtk app remotely and serve it through a browser. The goal is to avoid having to use VNC or ssh with X forwarding, both of which have drawbacks.
For example:
~$ broadwayd -p 8080 :2
listening on /run/user/1001/broadway3.socket
~$ GDK_BACKEND=broadway BROADWAY_DISPLAY=:2 a-compiled-gtk-app
which then displays nicely on http://localhost:8080/
. The main advantage is that the browser can be closed, but the app remains attached to the display and can be viewed again later.
When running
GDK_BACKEND=broadway BROADWAY_DISPLAY=:2 julia
julia> using Gtk
I get the following error:
ERROR: InitError: Cannot open display:
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] Gtk.GLib.GError(f::Gtk.var"#318#324")
@ Gtk.GLib ~/.julia/packages/Gtk/3TfRG/src/GLib/gerror.jl:17
[3] __init__()
@ Gtk ~/.julia/packages/Gtk/3TfRG/src/Gtk.jl:125
[4] _include_from_serialized(path::String, depmods::Vector{Any})
@ Base ./loading.jl:674
[5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
@ Base ./loading.jl:760
[6] _require(pkg::Base.PkgId)
@ Base ./loading.jl:998
[7] require(uuidkey::Base.PkgId)
@ Base ./loading.jl:914
[8] require(into::Module, mod::Symbol)
@ Base ./loading.jl:901
during initialization of module Gtk
I poked through the Gtk.jl source code and could not find any explicity call that sets the GDK_BACKEND (https://developer.gnome.org/gdk3/stable/gdk3-General.html#gdk-set-allowed-backends). I tried to hack a ccall before the gtk_init_with_args
in Gtk.jl lines 125-129
GError() do error_check
ccall((:gtk_init_with_args, libgtk), Bool,
(Ptr{Nothing}, Ptr{Nothing}, Ptr{UInt8}, Ptr{Nothing}, Ptr{UInt8}, Ptr{GError}),
C_NULL, C_NULL, "Julia Gtk Bindings", C_NULL, C_NULL, error_check)
end
However, I have never worked with Gtk in C. I honestly have no idea what I am doing, so unsurprisingly, no luck. Any thoughts if this feature could be had without too much pain?
@mdpetters, may I ask you whether you somehow progressed on this topic in the meantime - or has it been a dead end?
This was too much out of my wheelhouse and I did not pursue this further.
OK, I see. Thanks @mdpetters!