Class: Rabbit::Progress

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbit/progress.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProgress

Returns a new instance of Progress.



6
7
8
9
10
11
12
13
14
15
# File 'lib/rabbit/progress.rb', line 6

def initialize
  @window = Gtk::Window.new(:popup)
  @window.app_paintable = true
  @bar = Gtk::ProgressBar.new
  @bar.show_text = true
  @window.add(@bar)
  @original_style = @bar.style
  @foreground = nil
  @background = nil
end

Instance Attribute Details

#backgroundObject

Returns the value of attribute background.



5
6
7
# File 'lib/rabbit/progress.rb', line 5

def background
  @background
end

#foregroundObject

Returns the value of attribute foreground.



5
6
7
# File 'lib/rabbit/progress.rb', line 5

def foreground
  @foreground
end

#windowObject (readonly)

Returns the value of attribute window.



5
6
7
# File 'lib/rabbit/progress.rb', line 5

def window
  @window
end

Instance Method Details

#clear_colorObject



27
28
29
30
31
# File 'lib/rabbit/progress.rb', line 27

def clear_color
  @foreground = nil
  @background = nil
  setup_progress_color
end

#end_progressObject



47
48
49
50
51
# File 'lib/rabbit/progress.rb', line 47

def end_progress
  return if @max.nil?
  @current = @max
  @bar.fraction = @current / @max
end

#start_progress(max, parent) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/rabbit/progress.rb', line 33

def start_progress(max, parent)
  return if max.zero?
  @window.transient_for = parent
  @window.show_all
  @bar.fraction = @current = 0
  @max = max.to_f
end

#update_progress(i) ⇒ Object



41
42
43
44
45
# File 'lib/rabbit/progress.rb', line 41

def update_progress(i)
  return if @max.nil?
  @current = i
  @bar.fraction = @current / @max
end