I'd like to be able to dynamically change the background color a notebook page in ruby-gnome2 after the program has run. I've only found ONE way of setting the background color:
# Some page contents, for the sake of example
box1 = Gtk::HBox.new(false, 2)
box1.pack_start(Gtk::Label.new("Page 1"))
box2 = Gtk::HBox.new(false, 2)
box2.pack_start(Gtk::Label.new("Page 2"))
notebook = Gtk::Notebook.new # Create a notebook object
notebook.append_page(box1) # Create a page with box1 as contents
notebook.append_page(box2) # Create a page with box2 as contents
style = notebook.style # Copy the currently applied style
style.set_bg(Gtk::STATE_NORMAL, bg.red, bg.green, bg.blue) # Update the bg color
notebook.style = style # Set notebook's style to the updated object
This is fine if it's applied before Gtk.main
is kicked off. But it has no effect after the window has already launched. I've tried combinations of modify_bg
and modify_base
on both the notebook object and the page contents, to no effect.
Is there a proper way to set the color of a notebook page that isn't so hackish, and can be applied after the main loop is run?