def initialize
super('Shopping list')
self.border_width = 5
vbox = Gtk::VBox.new(false, 5)
add(vbox)
vbox.pack_start(Gtk::Label.new('Shopping list (you can edit the cells!)'),
false, false, 0)
sw = Gtk::ScrolledWindow.new
sw.shadow_type = Gtk::SHADOW_ETCHED_IN
sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
vbox.pack_start(sw, true, true, 0)
model = create_model
treeview = Gtk::TreeView.new(model)
treeview.rules_hint = true
treeview.selection.mode = Gtk::SELECTION_SINGLE
add_columns(treeview)
sw.add(treeview)
hbox = Gtk::HBox.new(true, 4)
vbox.pack_start(hbox, false, false, 0)
button = Gtk::Button.new('Add item')
button.signal_connect('clicked') do
add_item(model)
end
hbox.pack_start(button, true, true, 0)
button = Gtk::Button.new('Remove item')
button.signal_connect('clicked') do
remove_item(treeview)
end
hbox.pack_start(button, true, true, 0)
set_default_size(320, 200)
end