Class: MittensUi::HeaderBar
Overview
A header bar widget that replaces the window title bar. Wraps Gtk::HeaderBar. Widgets passed in are placed on the left or right side of the header bar.
Instance Attribute Summary
Attributes inherited from Core
Instance Method Summary collapse
-
#initialize(widgets, options = {}) ⇒ HeaderBar
constructor
Creates a new HeaderBar widget.
-
#render ⇒ void
Places the header bar as the window titlebar.
Methods inherited from Core
#hidden?, #hide, #keyboard_shortcut, #remove, #remove_keyboard_shortcut, #shortcuts, #show
Methods included from Helpers
#icon_map, #list_system_icons, #set_margin_from_opts_for
Constructor Details
#initialize(widgets, options = {}) ⇒ HeaderBar
Creates a new HeaderBar widget.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mittens_ui/header_bar.rb', line 27 def initialize(, = {}) title = .fetch(:title, '') position = .fetch(:position, :left) @header = Gtk::HeaderBar.new @header. = true # use a Gtk::Label as the title widget title_label = Gtk::Label.new(title) @header. = title_label box = Gtk::Box.new(:horizontal, 0) box.add_css_class('linked') .each do |w| w.remove box.append(w.) end if position == :right @header.pack_end(box) else @header.pack_start(box) end super(@header, ) end |
Instance Method Details
#render ⇒ void
This method returns an undefined value.
Places the header bar as the window titlebar. Called automatically by Core#render.
60 61 62 |
# File 'lib/mittens_ui/header_bar.rb', line 60 def render MittensUi::Application.window. = @header end |