I’m having a bit of difficulty trying to understand how one would set the background or border color of a widget with Gtk.jl. I’ve taken a look at this issue, but haven’t been able to make it work with Julia 0.6 and Gtk master (the color doesn’t change). Here’s my snippet:
using Gtk, Gtk.ShortNames
win = Window("Test")
lbl = Label("Some text")
push!(win, lbl)
showall(win)
sc = Gtk.GAccessor.style_context(lbl)
pr = CssProviderLeaf(data="GtkLabel {color:blue}")
push!(sc, StyleProvider(pr), 600)
sleep(5)
I’ve also attempted to read the Gtk documentation to find some semblance of an answer, but haven’t found it terribly helpful in relation to Gtk.jl. I’ve seen methods like G_.background_color
, but it seems like this just retrieves the current background color of the supplied StyleContext
.
I also noticed that there is a signal called “draw” that is apparently fired when a widget is supposed to draw itself. It’s supposed to provide both the GtkWidget being drawn, and the cairo_t struct (which I assume can be converted to a CairoContext somehow) to the supplied callback. However, the following snippet of code shows that cr
is some sort of object like Gtk.GLib.GBoxedUnkown(Ptr{Gtk.GLib.GBoxed} @0x0000000002c6d310)
, which I’m not sure how to handle.
using Gtk, Gtk.ShortNames, Cairo
win = Window("Test")
lbl = Label("Some text")
push!(win, lbl)
signal_connect(lbl, "draw") do widget, cr
@async info(widget)
@async info(cr)
nothing
end
showall(win)
sleep(5)
What I’m looking for is either some way to use the StyleContext for coloring and styling, or alternatively some way to access the underlying CairoContext of a widget, so that I can manually draw in the colors (or even a gradient or image). Could someone more experienced with Gtk.jl shed some light on what I’m missing? Thanks!