class Sirens::MenuView

Public Class Methods

new(menu_handle: Gtk::Menu.new) click to toggle source

Initializing

# File lib/views/menu_view.rb, line 6
def initialize(menu_handle: Gtk::Menu.new)
    @main_handle = menu_handle
end

Public Instance Methods

empty?() click to toggle source

Asking

# File lib/views/menu_view.rb, line 37
def empty?()
    main_handle.children.empty?
end
item(label:, enabled: true, action:) click to toggle source

Adding

# File lib/views/menu_view.rb, line 12
def item(label:, enabled: true, action:)
    menu_item_handle = Gtk::MenuItem.new(label: label)
    menu_item_handle.sensitive = enabled

    menu_item_handle.signal_connect('activate') { |props|
       action.call
    }

    @main_handle.append(menu_item_handle)
end
open(props) click to toggle source
# File lib/views/menu_view.rb, line 41
def open(props)
    main_handle.show_all
    main_handle.popup(nil, nil, props[:button], props[:time])
end
separator() click to toggle source
# File lib/views/menu_view.rb, line 23
def separator()
    @main_handle.append(Gtk::SeparatorMenuItem.new)
end
subscribe_to_ui_events() click to toggle source

Subscribes this View to the events/signals emitted by the GUI handle(s) of interest. When an event/signal is received calls the proper event_handler provided by the PrimitiveComponent, if one was given.

# File lib/views/menu_view.rb, line 32
def subscribe_to_ui_events()
end