Class: Sirens::CheckboxView

Inherits:
WidgetView show all
Defined in:
lib/views/checkbox_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(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_stylesObject

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

#clickObject

Actions



45
46
47
# File 'lib/views/checkbox_view.rb', line 45

def click()
    main_handle.clicked
end

#get_valueObject

Querying



51
52
53
# File 'lib/views/checkbox_view.rb', line 51

def get_value()
    main_handle.active?
end

#initialize_handlesObject



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

def initialize_handles()
    @main_handle = Gtk::CheckButton.new()
end

#labelObject



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_toggledObject

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_eventsObject



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