Class: Sirens::CheckboxView
- Inherits:
-
WidgetView
- Object
- AbstractView
- WidgetView
- Sirens::CheckboxView
- Defined in:
- lib/views/checkbox_view.rb
Class Method Summary collapse
-
.view_accepted_styles ⇒ Object
Answer the styles accepted by this view.
Instance Method Summary collapse
-
#click ⇒ Object
Actions.
-
#get_value ⇒ Object
Querying.
-
#initialize(on_toggled:) ⇒ CheckboxView
constructor
Initializing.
- #initialize_handles ⇒ Object
- #label ⇒ Object
-
#label=(value) ⇒ Object
Styles.
-
#on_toggled ⇒ Object
Events.
- #set_value(boolean) ⇒ Object
- #subscribe_to_ui_events ⇒ Object
Methods inherited from WidgetView
#add_view, #apply_prop, #apply_props, #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, #width, #width=
Constructor Details
#initialize(on_toggled:) ⇒ CheckboxView
Initializing
17 18 19 20 21 |
# File 'lib/views/checkbox_view.rb', line 17 def initialize(on_toggled:) super() @on_toggled_block = on_toggled end |
Class Method Details
.view_accepted_styles ⇒ Object
Answer the styles accepted by this view.
10 11 12 |
# File 'lib/views/checkbox_view.rb', line 10 def view_accepted_styles() super() + [:label].freeze end |
Instance Method Details
#click ⇒ Object
Actions
45 46 47 |
# File 'lib/views/checkbox_view.rb', line 45 def click() main_handle.clicked end |
#get_value ⇒ Object
Querying
51 52 53 |
# File 'lib/views/checkbox_view.rb', line 51 def get_value() main_handle.active? end |
#initialize_handles ⇒ Object
23 24 25 |
# File 'lib/views/checkbox_view.rb', line 23 def initialize_handles() @main_handle = Gtk::CheckButton.new() end |
#label ⇒ Object
39 40 41 |
# File 'lib/views/checkbox_view.rb', line 39 def label() main_handle.label end |
#label=(value) ⇒ Object
Styles
35 36 37 |
# File 'lib/views/checkbox_view.rb', line 35 def label=(value) main_handle.label = value end |
#on_toggled ⇒ Object
Events
61 62 63 |
# File 'lib/views/checkbox_view.rb', line 61 def on_toggled() @on_toggled_block.call(state: get_value) end |
#set_value(boolean) ⇒ Object
55 56 57 |
# File 'lib/views/checkbox_view.rb', line 55 def set_value(boolean) main_handle.active = boolean end |
#subscribe_to_ui_events ⇒ Object
27 28 29 30 31 |
# File 'lib/views/checkbox_view.rb', line 27 def subscribe_to_ui_events() main_handle.signal_connect('clicked') { on_toggled } end |