Class: TECSCDE::CelltypeTreeView
- Defined in:
- lib/tecscde/celltype_tree_view.rb
Overview
CelltypeTreeView: show celltype list
formerly this class is sub-class of Gtk::TreeView currently this class has Gtk::TreeView
Constant Summary collapse
- COL_NAME =
0
- COL_NSPATH =
1
Instance Attribute Summary collapse
-
#tree_view ⇒ Object
readonly
Gtk::TreeView.
Instance Method Summary collapse
- #add(celltype) ⇒ Object
- #clear ⇒ Object
- #delete(item) ⇒ Object
-
#initialize(tree_view) ⇒ CelltypeTreeView
constructor
initialize.
- #selected ⇒ Object
Constructor Details
#initialize(tree_view) ⇒ CelltypeTreeView
initialize
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/tecscde/celltype_tree_view.rb', line 61 def initialize(tree_view) @tree_view = tree_view # create data model liststore = Gtk::ListStore.new(String, String) # set data model to tree view(self) @tree_view.set_model(liststore) # create renderer for text renderer = Gtk::CellRendererText.new # set column information col = Gtk::TreeViewColumn.new("name", renderer, text: COL_NAME) @tree_view.append_column(col) col = Gtk::TreeViewColumn.new("namespace", renderer, text: COL_NSPATH) @tree_view.append_column(col) liststore.set_sort_column_id(COL_NAME) end |
Instance Attribute Details
#tree_view ⇒ Object (readonly)
Gtk::TreeView
58 59 60 |
# File 'lib/tecscde/celltype_tree_view.rb', line 58 def tree_view @tree_view end |
Instance Method Details
#add(celltype) ⇒ Object
83 84 85 86 87 |
# File 'lib/tecscde/celltype_tree_view.rb', line 83 def add(celltype) iter = @tree_view.model.append iter[COL_NAME] = celltype.get_name iter[COL_NSPATH] = celltype.get_owner.get_namespace_path.to_s end |
#clear ⇒ Object
101 102 103 |
# File 'lib/tecscde/celltype_tree_view.rb', line 101 def clear @tree_view.model.clear end |
#delete(item) ⇒ Object
98 99 |
# File 'lib/tecscde/celltype_tree_view.rb', line 98 def delete(item) end |
#selected ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/tecscde/celltype_tree_view.rb', line 89 def selected iter = @tree_view.selection.selected if iter [iter[COL_NAME], iter[COL_NSPATH]] else [nil, nil] end end |