Class: Watobo::Gui::ProgressInfo

Inherits:
FXVerticalFrame
  • Object
show all
Defined in:
lib/watobo/gui/dashboard.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, check_name, num_checks) ⇒ ProgressInfo

Returns a new instance of ProgressInfo.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/watobo/gui/dashboard.rb', line 67

def initialize(owner, check_name, num_checks)
        begin
   super(owner, :opts => LAYOUT_FILL_X|FRAME_GROOVE|LAYOUT_TOP)
   @lock = Mutex.new
   @check_name = check_name
   @label = FXLabel.new(self, check_name, :opts => LAYOUT_LEFT)

   #   puts l
   @pbar = FXProgressBar.new(self, nil, 0, LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK|PROGRESSBAR_HORIZONTAL)
   @pbar.progress = 0
   @pbar.total = num_checks
    puts "#{check_name} has #{num_checks} Checks"
   update_bar_color
rescue => bang
   puts "!!!ERROR: could not add progress info"
   puts bang
   puts bang.backtrace if $DEBUG
end
end

Instance Method Details

#finishedObject



61
62
63
64
65
# File 'lib/watobo/gui/dashboard.rb', line 61

def finished
   @lock.synchronize do
     @progress = @total
   end  
end

#increment(i) ⇒ Object



29
30
31
32
33
34
# File 'lib/watobo/gui/dashboard.rb', line 29

def increment(i)
   @lock.synchronize do
     @pbar.progress += i
     #@total += i
   end  
end

#progress(i) ⇒ Object



36
37
38
39
40
41
# File 'lib/watobo/gui/dashboard.rb', line 36

def progress(i)
   @lock.synchronize do
     @pbar.progress = i
     update_bar_color
   end  
end

#total(i) ⇒ Object



54
55
56
57
58
59
# File 'lib/watobo/gui/dashboard.rb', line 54

def total(i)
   @lock.synchronize do
     #@progress = i
     @pbar.total = i
   end  
end

#update_bar_colorObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/watobo/gui/dashboard.rb', line 43

def update_bar_color          
  if @pbar.total == 0 then
    @pbar.barColor = 'grey'
  else
    @pbar.barColor = FXRGB(255,0,0)
  end
  if @pbar.progress == @pbar.total
       @pbar.barColor = 'green' 
  end
end