Class: UI
- Inherits:
-
FXMainWindow
- Object
- FXMainWindow
- UI
- Defined in:
- lib/bitferry/fx.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(app) ⇒ UI
constructor
A new instance of UI.
- #process ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(app) ⇒ UI
Returns a new instance of UI.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bitferry/fx.rb', line 8 def initialize(app) super(@app = app, 'BitferryFX', width: 400, padding: 4) FXToolTip.new(app) @progress = FXProgressBar.new(self, padding: 4, height: 16, opts: LAYOUT_FILL_X | JUSTIFY_BOTTOM | LAYOUT_FIX_HEIGHT) @simulate = FXCheckButton.new(self, "&Simulation mode (dry run)\tPrevent operations from making any on-disk changes") @simulate.checkState = Bitferry.simulate? = FXPacker.new(self, opts: LAYOUT_FILL_X | LAYOUT_SIDE_BOTTOM | PACK_UNIFORM_WIDTH | FRAME_SUNKEN) @process = FXButton.new(, "&Process\tProcess all intact tasks", opts: BUTTON_NORMAL | BUTTON_INITIAL | BUTTON_DEFAULT | LAYOUT_SIDE_LEFT) @process.connect(SEL_COMMAND) { process } @process.setFocus @quit = FXButton.new(, "&Quit\tStop any pending operations and exit", opts: BUTTON_NORMAL | LAYOUT_SIDE_RIGHT) @quit.connect(SEL_COMMAND) { exit } @reload = FXButton.new(, "&Reload\tReread volumes and tasks to capture volume changes", opts: BUTTON_NORMAL | LAYOUT_SIDE_RIGHT) @reload.connect(SEL_COMMAND) { reset } @sensible = [@process, @reload] # Controls which must be disabled during processing reset end |
Instance Method Details
#create ⇒ Object
51 52 53 54 |
# File 'lib/bitferry/fx.rb', line 51 def create super show(PLACEMENT_SCREEN) end |
#process ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bitferry/fx.rb', line 26 def process Bitferry.simulate = @simulate.checked? @progress.setBarColor(:blue) @progress.progress = 0 Thread.new { @app.runOnUiThread { @sensible.each(&:disable) } begin Bitferry.process { |total, processed, failed | @app.runOnUiThread { @progress.setBarColor(:red) if failed > 0 @progress.progress = processed @progress.total = total } } ensure @app.runOnUiThread { @sensible.each(&:enable) } end } end |
#reset ⇒ Object
46 47 48 49 |
# File 'lib/bitferry/fx.rb', line 46 def reset @progress.progress = 0 Bitferry.restore end |