Class: MittensUi::Button

Inherits:
Core
  • Object
show all
Includes:
Helpers
Defined in:
lib/mittens_ui/button.rb

Instance Attribute Summary

Attributes inherited from Core

#core_widget

Instance Method Summary collapse

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(options={})
  button_title  = options[:title] || "Button"  

  icon_type = options[: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: button_title)
  end

  super(@button, options)
end

Instance Method Details

#clickObject



28
29
30
31
32
# File 'lib/mittens_ui/button.rb', line 28

def click
  @button.signal_connect("clicked") do |button_widget|
    yield(button_widget)
  end
end

#enable(answer) ⇒ Object



24
25
26
# File 'lib/mittens_ui/button.rb', line 24

def enable(answer)
  @button.set_sensitive(answer)
end

#renderObject



34
35
36
37
# File 'lib/mittens_ui/button.rb', line 34

def render
  $vertical_box.pack_start(@button)
  return self
end