Class: MittensUi::HBox

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

Instance Method Summary collapse

Methods included from Helpers

#icon_map, #list_system_icons, #set_margin_from_opts_for

Constructor Details

#initialize(widgets, options = {}) ⇒ HBox

Returns a new instance of HBox.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mittens_ui/hbox.rb', line 7

def initialize(widgets, options={})
  box_spacing = options[:spacing].nil? ? 6 : options[:spacing]
  
  @box = Gtk::Box.new(:horizontal, box_spacing)

  set_margin_from_opts_for(@box, options)
  
  widgets.each do |w| 
    # We need to remove the widget from the global $vertical_box before hand
    # otherwise it won't render the widgets properly since they are already in another container.
    w.remove
    self.attach(w.core_widget, { position: :start }) 
  end
end

Instance Method Details

#removeObject



22
23
24
25
# File 'lib/mittens_ui/hbox.rb', line 22

def remove
  return if @box.nil?
  @box.destroy
end

#renderObject



27
28
29
30
# File 'lib/mittens_ui/hbox.rb', line 27

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