Included Modules

Files

JSON::Editor::MenuExtension

This module bundles some method, that can be used to create a menu. It should be included into the class in question.

Attributes

treeview[R]

Returns the Gtk::TreeView of this menu.

Public Class Methods

new(treeview) click to toggle source

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

Public Instance Methods

add_item(label, keyval = nil, klass = MenuItem, &callback) click to toggle source

Adds a Gtk::MenuItem to this instance’s #. 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') 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
add_separator() click to toggle source

Adds a Gtk::SeparatorMenuItem to this instance’s #.

     # File lib/json/editor.rb, line 224
224:       def add_separator
225:         menu.append SeparatorMenuItem.new
226:       end
create() click to toggle source

This method should be implemented in subclasses to create the # 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 250
250:       def create
251:         raise NotImplementedError
252:       end
method_missing(*a, &b) click to toggle source
     # File lib/json/editor.rb, line 254
254:       def method_missing(*a, &b)
255:         treeview.__send__(*a, &b)
256:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.