| Module | JSON::Editor::MenuExtension |
| In: |
lib/json/editor.rb
|
This module bundles some method, that can be used to create a menu. It should be included into the class in question.
| menu | [R] | Returns the menu. |
| treeview | [R] | Returns the Gtk::TreeView of this menu. |
Creates a Menu, that includes MenuExtension. treeview is the Gtk::TreeView, on which it operates.
# File lib/json/editor.rb, line 190
190: def initialize(treeview)
191: @treeview = treeview
192: @menu = Menu.new
193: end
Adds a Gtk::MenuItem to this instance’s menu. label is the label string, klass is the item type, and callback is the procedure, that is called if the item is activated.
# File lib/json/editor.rb, line 209
209: def add_item(label, klass = MenuItem, &callback)
210: item = klass.new(label)
211: item.signal_connect(:activate, &callback)
212: menu.append item
213: item
214: end
Adds a Gtk::SeparatorMenuItem to this instance’s menu.
# File lib/json/editor.rb, line 202
202: def add_separator
203: menu.append SeparatorMenuItem.new
204: end
This method should be implemented in subclasses to create the menu of this instance. It has to be called after an instance of this class is created, to build the menu.
# File lib/json/editor.rb, line 219
219: def create
220: raise NotImplementedError
221: end