class CssMultiplebgsDemo

Theming/Multiple Backgrounds

Gtk themes are written using CSS. Every widget is build of multiple items
that you can style very similarly to a regular website.

Public Class Methods

new(main_window) click to toggle source
# File gtk3/sample/gtk-demo/css_multiplebgs.rb, line 11
def initialize(main_window)
  @window = Gtk::Window.new(:toplevel)
  @window.screen = main_window.screen
  @window.title = "Mutiple Backgrounds"
  @window.transient_for = main_window
  @window.set_default_size(400, 300)

  container = Gtk::Overlay.new
  container.add_events([:enter_notify_mask, :leave_notify_mask,
                        :pointer_motion_mask])
  @window.add(container)

  da = initialize_drawing_area
  container.add(da)

  button = initialize_bricks_button
  container.add_overlay(button)

  paned = Gtk::Paned.new(:vertical)
  container.add_overlay(paned)
  css = "/css_multiplebgs/css_multiplebgs.css"
  @default_css = Gio::Resources.lookup_data(css)
  # Need a filler so we get a handle
  child = Gtk::Box.new(:vertical, 0)
  paned.add(child)

  initialize_text_buffer
  container = Gtk::ScrolledWindow.new
  paned.add(container)

  child = Gtk::TextView.new(@text)
  container.add(child)

  initialize_provider
  apply_style(@window, @provider)
end

Public Instance Methods

run() click to toggle source
# File gtk3/sample/gtk-demo/css_multiplebgs.rb, line 48
def run
  if !@window.visible?
    @window.show_all
  else
    @window.destroy
  end
  @window
end