Class: MittensUi::HeaderBar

Inherits:
Core
  • Object
show all
Defined in:
lib/mittens_ui/header_bar.rb

Instance Attribute Summary

Attributes inherited from Core

#core_widget

Instance Method Summary collapse

Methods inherited from Core

#hidden?, #hide, #remove, #show

Methods included from Helpers

#icon_map, #list_system_icons, #set_margin_from_opts_for

Constructor Details

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

Returns a new instance of HeaderBar.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mittens_ui/header_bar.rb', line 5

def initialize(widgets, options = {})
  title     = options[:title].nil? ? "" : options[:title]
  position  = options[:position].nil? ? :left : options[:position]

  box = Gtk::Box.new(:horizontal, 0)
  box.style_context.add_class("linked")

  @header = Gtk::HeaderBar.new
  @header.show_close_button = true
  @header.title = title
  @header.has_subtitle = false

  widgets.each do |w|
    w.remove
    case position
    when :left
      box.pack_start(w.core_widget)
    when :right
      box.pack_end(w.core_widget)
    else
      box.pack_start(w.core_widget)
    end  
  end

  if position == :left 
    @header.pack_start(box)
  end

  if position == :right
    @header.pack_end(box)
  end

  super(@header, options)
end

Instance Method Details

#renderObject



40
41
42
43
# File 'lib/mittens_ui/header_bar.rb', line 40

def render
  $app_window.titlebar = @header
  return self
end