Class: Sirens::RadioButtonView

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

Class Method Summary collapse

Instance Method Summary collapse

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 = previous_button.main_handle unless previous_button.nil?

    @on_toggled_block = on_toggled

    super()
end

Class Method Details

.view_accepted_stylesObject

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

#clickObject

Actions



47
48
49
# File 'lib/views/radio_button_view.rb', line 47

def click()
    main_handle.clicked
end

#get_valueObject

Querying



53
54
55
# File 'lib/views/radio_button_view.rb', line 53

def get_value()
    main_handle.active?
end

#initialize_handlesObject



25
26
27
# File 'lib/views/radio_button_view.rb', line 25

def initialize_handles()
    @main_handle = Gtk::RadioButton.new(member: @previous_button)
end

#labelObject



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_toggledObject

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_eventsObject



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