Class: Sirens::RadioButtonView
- Inherits:
-
WidgetView
- Object
- AbstractView
- WidgetView
- Sirens::RadioButtonView
- Defined in:
- lib/views/radio_button_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(previous_button:, on_toggled:) ⇒ RadioButtonView
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(previous_button:, on_toggled:) ⇒ RadioButtonView
Initializing
17 18 19 20 21 22 23 |
# File 'lib/views/radio_button_view.rb', line 17 def initialize(previous_button:, on_toggled:) @previous_button = .main_handle unless .nil? @on_toggled_block = on_toggled super() end |
Class Method Details
.view_accepted_styles ⇒ Object
Answer the styles accepted by this view.
10 11 12 |
# File 'lib/views/radio_button_view.rb', line 10 def view_accepted_styles() super() + [:label].freeze end |
Instance Method Details
#click ⇒ Object
Actions
47 48 49 |
# File 'lib/views/radio_button_view.rb', line 47 def click() main_handle.clicked end |
#get_value ⇒ Object
Querying
53 54 55 |
# File 'lib/views/radio_button_view.rb', line 53 def get_value() main_handle.active? end |
#initialize_handles ⇒ Object
25 26 27 |
# File 'lib/views/radio_button_view.rb', line 25 def initialize_handles() @main_handle = Gtk::RadioButton.new(member: @previous_button) end |
#label ⇒ Object
41 42 43 |
# File 'lib/views/radio_button_view.rb', line 41 def label() main_handle.label end |
#label=(value) ⇒ Object
Styles
37 38 39 |
# File 'lib/views/radio_button_view.rb', line 37 def label=(value) main_handle.label = value end |
#on_toggled ⇒ Object
Events
63 64 65 |
# File 'lib/views/radio_button_view.rb', line 63 def on_toggled() @on_toggled_block.call(state: get_value) end |
#set_value(boolean) ⇒ Object
57 58 59 |
# File 'lib/views/radio_button_view.rb', line 57 def set_value(boolean) main_handle.active = boolean end |
#subscribe_to_ui_events ⇒ Object
29 30 31 32 33 |
# File 'lib/views/radio_button_view.rb', line 29 def subscribe_to_ui_events() main_handle.signal_connect('clicked') { on_toggled } end |