Class: MittensUi::Loader

Inherits:
Core
  • Object
show all
Defined in:
lib/mittens_ui/loader.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(options = {}) ⇒ Loader

Returns a new instance of Loader.



5
6
7
8
9
10
11
12
13
# File 'lib/mittens_ui/loader.rb', line 5

def initialize(options={})
  @spinner = Gtk::Spinner.new

  @processing = false

  super(@spinner, options)

  self.hide
end

Instance Method Details

#renderObject



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

def render
  $vertical_box.pack_end(@spinner)
  return self
end

#start(&block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mittens_ui/loader.rb', line 15

def start(&block)
  return if @processing

  return if @worker_thread && @worker_thread.alive?

  self.show

  @spinner.start

  @worker_thread = Thread.new { yield; self.remove; @processing = true }
end