Class: Sirens::MenuView

Inherits:
WidgetView show all
Defined in:
lib/views/menu_view.rb

Instance Method Summary collapse

Methods inherited from WidgetView

#add_view, #apply_prop, #apply_props, #initialize_handles, #main_handle

Methods inherited from AbstractView

accepted_styles, #accepted_styles, #add_view, #attribute_at, #background_color=, #foreground_color=, #height, #height=, #main_handle, #populate_popup_menu_block=, #remove_view, #set_attribute, #show, #show_popup_menu, #state_colors_from, view_accepted_styles, #width, #width=

Constructor Details

#initialize(menu_handle: Gtk::Menu.new) ⇒ MenuView

Initializing



6
7
8
# File 'lib/views/menu_view.rb', line 6

def initialize(menu_handle: Gtk::Menu.new)
    @main_handle = menu_handle
end

Instance Method Details

#empty?Boolean

Asking

Returns:

  • (Boolean)


37
38
39
# File 'lib/views/menu_view.rb', line 37

def empty?()
    main_handle.children.empty?
end

#item(label:, enabled: true, action:) ⇒ Object

Adding



12
13
14
15
16
17
18
19
20
21
# 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) ⇒ Object



41
42
43
44
# 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

#separatorObject



23
24
25
# File 'lib/views/menu_view.rb', line 23

def separator()
    @main_handle.append(Gtk::SeparatorMenuItem.new)
end

#subscribe_to_ui_eventsObject

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.



32
33
# File 'lib/views/menu_view.rb', line 32

def subscribe_to_ui_events()
end