Module | 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 212 212: def initialize(treeview) 213: @treeview = treeview 214: @menu = Menu.new 215: 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 231 231: def add_item(label, keyval = nil, klass = MenuItem, &callback) 232: label = "#{label} (C-#{keyval.chr})" if keyval 233: item = klass.new(label) 234: item.signal_connect(:activate, &callback) 235: if keyval 236: self.signal_connect('key-press-event''key-press-event') do |item, event| 237: if event.state & Gdk::Window::ModifierType::CONTROL_MASK != 0 and 238: event.keyval == keyval 239: callback.call item 240: end 241: end 242: end 243: menu.append item 244: item 245: end
Adds a Gtk::SeparatorMenuItem to this instance‘s menu.
# File lib/json/editor.rb, line 224 224: def add_separator 225: menu.append SeparatorMenuItem.new 226: end