I am working on some Gtk4 demos using the shard hugopl/gtk4.cr.
Most things work but there are some small things not working like update the CSS for a label
in lesson09, see gummybears/gtk4_with_crystal.git
In lesson09 a menu is constructed with some stateful menu items and their callbacks. The menu has
a submenu Color where the user can change the background color of a label. This part is not working, see
def color_activated(action : Gio::SimpleAction, parameter : GLib::Variant)
new_color = parameter.to_s
#
# remove single quotes
#
new_color = new_color.gsub(/\'/,"")
new_css = sprintf("label.lb { background-color: %s; }",new_color)
# need to update the css for the label
# but unsure how to do that
#
# the C code uses gtk_css_provider_load_from_data (provider, new_css, -1)
# and looking at class Gtk::Provider there is a method load_from_data
# which accepts an Enumerable(UInt8) as data
#
# not sure how to do that
#
# Next line does not compile
#
@provider.load_from_data(new_css)
#
# set menu item state
#
action.state = parameter
end