Class: MittensUi::Button
- Includes:
- Helpers
- Defined in:
- lib/mittens_ui/button.rb
Instance Attribute Summary
Attributes inherited from Core
Instance Method Summary collapse
- #click ⇒ Object
- #enable(answer) ⇒ Object
-
#initialize(options = {}) ⇒ Button
constructor
A new instance of Button.
- #render ⇒ Object
Methods included from Helpers
#icon_map, #list_system_icons, #set_margin_from_opts_for
Methods inherited from Core
#hidden?, #hide, #remove, #show
Constructor Details
#initialize(options = {}) ⇒ Button
Returns a new instance of Button.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mittens_ui/button.rb', line 8 def initialize(={}) = [:title] || "Button" icon_type = [:icon] || nil if icon_type image = Gtk::Image.new(icon_name: icon_map[icon_type], size: @button) @button = Gtk::Button.new @button.add(image) else @button = Gtk::Button.new(label: ) end super(@button, ) end |
Instance Method Details
#click ⇒ Object
28 29 30 31 32 |
# File 'lib/mittens_ui/button.rb', line 28 def click @button.signal_connect("clicked") do || yield() end end |
#enable(answer) ⇒ Object
24 25 26 |
# File 'lib/mittens_ui/button.rb', line 24 def enable(answer) @button.set_sensitive(answer) end |
#render ⇒ Object
34 35 36 37 |
# File 'lib/mittens_ui/button.rb', line 34 def render $vertical_box.pack_start(@button) return self end |