Class: Watobo::Gui::ProgressWindow

Inherits:
FXTopWindow
  • Object
show all
Defined in:
lib/watobo/gui/progress_window.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, opts = {}) ⇒ ProgressWindow

Returns a new instance of ProgressWindow.



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

def initialize(owner, opts={})
  super(owner, 'Progress Bar', nil, nil, DECOR_BORDER, 0, 0, 300, 100, 0, 0, 0, 0, 0, 0)
  frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
  @update_lock = Mutex.new

  @title_lbl = FXLabel.new(frame, "title")
  @title_lbl.setFont(FXFont.new(getApp(), "helvetica", 12, FONTWEIGHT_BOLD, FONTSLANT_ITALIC, FONTENCODING_DEFAULT))

  @task_lbl = FXLabel.new(frame, "task")

  @pbar = FXProgressBar.new(frame, nil, 0, LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK|PROGRESSBAR_HORIZONTAL)

  @job_lbl = FXLabel.new(frame, "job")

  @pbar.progress = 0
  @pbar.total = 100
  @increment = 0
  @total = 100
  @title = "-"
  @job = "-"
  @task = "-"

  start_update_timer
end

Instance Method Details

#increment(x) ⇒ Object



5
6
7
8
9
# File 'lib/watobo/gui/progress_window.rb', line 5

def increment(x)
  @update_lock.synchronize do
    @increment += x
  end
end

#job=(new_job) ⇒ Object



33
34
35
36
37
# File 'lib/watobo/gui/progress_window.rb', line 33

def job=(new_job)
  @update_lock.synchronize do
    @job = new_job
  end
end

#start_update_timerObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/watobo/gui/progress_window.rb', line 49

def start_update_timer
  Watobo.save_thread {
    @update_lock.synchronize do
      @title_lbl.text = @title
      @task_lbl.text = @task
      @job_lbl.text = @job

      @pbar.increment(@increment)
      @increment = 0
      @pbar.total = @total
    end
  }
end

#task=(new_task) ⇒ Object



27
28
29
30
31
# File 'lib/watobo/gui/progress_window.rb', line 27

def task=(new_task)
  @update_lock.synchronize do
    @task = new_task
  end
end

#title=(new_title) ⇒ Object



21
22
23
24
25
# File 'lib/watobo/gui/progress_window.rb', line 21

def title=(new_title)
  @update_lock.synchronize do
    @title = new_title
  end
end

#total=(x) ⇒ Object



11
12
13
14
15
# File 'lib/watobo/gui/progress_window.rb', line 11

def total=(x)
  @update_lock.synchronize do
    @total = x
  end
end

#UNUSED_progress=(x) ⇒ Object



17
18
19
# File 'lib/watobo/gui/progress_window.rb', line 17

def UNUSED_progress=(x)
  @pbar.progress = x
end

#update_progress(settings = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/watobo/gui/progress_window.rb', line 39

def update_progress(settings={})
  @update_lock.synchronize do
    @total = settings[:total] unless settings[:total].nil?
    @title = settings[:title] unless settings[:title].nil?
    @task = settings[:task] unless settings[:task].nil?
    @job = settings[:job] unless settings[:job].nil?
    @increment += settings[:increment] unless settings[:increment].nil?
  end
end