Class: Sirens::MenuView
- Inherits:
-
WidgetView
- Object
- AbstractView
- WidgetView
- Sirens::MenuView
- Defined in:
- lib/views/menu_view.rb
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Asking.
-
#initialize(menu_handle: Gtk::Menu.new) ⇒ MenuView
constructor
Initializing.
-
#item(label:, enabled: true, action:) ⇒ Object
Adding.
- #open(props) ⇒ Object
- #separator ⇒ Object
-
#subscribe_to_ui_events ⇒ Object
Subscribes this View to the events/signals emitted by the GUI handle(s) of interest.
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 = end |
Instance Method Details
#empty? ⇒ Boolean
Asking
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:) = Gtk::MenuItem.new(label: label) .sensitive = enabled .signal_connect('activate') { |props| action.call } @main_handle.append() 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 |
#separator ⇒ Object
23 24 25 |
# File 'lib/views/menu_view.rb', line 23 def separator() @main_handle.append(Gtk::SeparatorMenuItem.new) end |
#subscribe_to_ui_events ⇒ Object
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 |