class TreeStoreDemo

# Copyright © 2017 Ruby-GNOME2 Project Team # This program is licenced under the same licence as Ruby-GNOME2. #

Tree View/Tree Store

The GtkTreeStore is used to store data in tree form, to be
used later on by a GtkTreeView to display it. This demo builds
a simple GtkTreeStore and displays it. If you're new to the
GtkTreeView widgets and associates, look into the GtkListStore
example first.

Constants

April
August
December
February
January
July
June
March
May
NUM_COLUMNS
November
October
September
Toplevel
TreeItem

Public Class Methods

new(main_window) click to toggle source
# File gtk3/sample/gtk-demo/tree_store.rb, line 138
def initialize(main_window)
  @window = Gtk::Window.new(:toplevel)
  @window.screen = main_window.screen
  @window.title = "Tree Store"

  vbox = Gtk::Box.new(:vertical, 8)
  vbox.margin = 8
  @window.add(vbox)
  label = Gtk::Label.new("Jonathan's Holiday Card Planning Sheet")
  vbox.pack_start(label)

  sw = Gtk::ScrolledWindow.new
  sw.shadow_type = :etched_in
  sw.set_policy(:automatic, :automatic)
  vbox.pack_start(sw, :expand => true, :fill => true, :padding => 0)

  create_model
  @treeview = Gtk::TreeView.new(@model)
  @treeview.selection.mode = :multiple

  add_columns
  sw.add(@treeview)

  # Expand all rows after the treeview widget has been realized
  @treeview.signal_connect("realize", &:expand_all)
  @window.set_default_size(650, 400)
end

Public Instance Methods

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