Module MenuExtension
In: lib/json/editor.rb
Gtk MenuExtension dot/m_1_0.png

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

Methods

Included Modules

Gtk

Attributes

menu  [R]  Returns the menu.
treeview  [R]  Returns the Gtk::TreeView of this menu.

Public Class methods

Creates a Menu, that includes MenuExtension. treeview is the Gtk::TreeView, on which it operates.

[Source]

     # File lib/json/editor.rb, line 212
212:       def initialize(treeview)
213:         @treeview = treeview
214:         @menu = Menu.new
215:       end

Public Instance methods

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.

[Source]

     # 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.

[Source]

     # File lib/json/editor.rb, line 224
224:       def add_separator
225:         menu.append SeparatorMenuItem.new
226:       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.

[Source]

     # File lib/json/editor.rb, line 250
250:       def create
251:         raise NotImplementedError
252:       end

[Source]

     # File lib/json/editor.rb, line 254
254:       def method_missing(*a, &b)
255:         treeview.__send__(*a, &b)
256:       end

[Validate]