class EditableCellsDemo
# Copyright © 2016 Ruby-GNOME2 Project Team # This program is licenced under the same licence as Ruby-GNOME2. #
Tree View/Editable Cells¶ ↑
This demo demonstrates the use of editable cells in a GtkTreeView. If you're new to the GtkTreeView widgets and associates, look into the GtkListStore example first. It also shows how to use the GtkCellRenderer::editing-started signal to do custom setup of the editable widget. The cell renderers used in this demo are GtkCellRendererText, GtkCellRendererCombo and GtkCellRendererProgress.
Constants
- COL_ITEM_YUMMY
- COL_NUM_TEXT
- Item
Public Class Methods
new(main_window)
click to toggle source
# File gtk3/sample/gtk-demo/editable_cells.rb, line 21 def initialize(main_window) @window = Gtk::Window.new(:toplevel) @window.screen = main_window.screen @window.title = "Editable Cells" vbox = Gtk::Box.new(:vertical, 5) vbox.margin = 5 @window.add(vbox) label = Gtk::Label.new("Shopping list (you can edit the cells)") vbox.pack_start(label, :expand => false, :fill => true, :padding => 0) 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 models create_items_model create_numbers_model # create tree view @treeview = Gtk::TreeView.new(@items_model) @treeview.selection.mode = :single add_columns sw.add(@treeview) # Some buttons hbox = Gtk::Box.new(:horizontal, 4) hbox.homogeneous = true vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0) button = Gtk::Button.new(:label => "Add item") button.signal_connect("clicked") { add_item } hbox.pack_start(button, :expand => true, :fill => true, :padding => 0) button = Gtk::Button.new(:label => "Remove item") button.signal_connect("clicked") { remove_item } hbox.pack_start(button, :expand => true, :fill => true, :padding => 0) @window.set_default_size(320, 200) end
Public Instance Methods
run()
click to toggle source
# File gtk3/sample/gtk-demo/editable_cells.rb, line 65 def run if !@window.visible? @window.show_all else @window.destroy end @window end