lib/rabbit/progress.rb in rabbit-2.2.0 vs lib/rabbit/progress.rb in rabbit-2.2.1

- old
+ new

@@ -2,52 +2,60 @@ module Rabbit class Progress attr_reader :window, :foreground, :background def initialize - @window = Gtk::Window.new(:popup) - @window.app_paintable = true - @bar = Gtk::ProgressBar.new - @bar.show_text = true - @window.add(@bar) @foreground = nil @background = nil end def foreground=(color) @foreground = color - setup_progress_color end def background=(color) @background = color - setup_progress_color end def clear_color @foreground = nil @background = nil - setup_progress_color end def start_progress(max, parent) return if max.zero? + + @window = Gtk::Window.new(:popup) @window.transient_for = parent + @window.app_paintable = true + @bar = Gtk::ProgressBar.new + @bar.show_text = true + @window.add(@bar) @window.show_all @bar.fraction = @current = 0 @max = max.to_f + + setup_progress_color end def update_progress(i) return if @max.nil? + @current = i @bar.fraction = @current / @max end def end_progress return if @max.nil? + @current = @max @bar.fraction = @current / @max + end + + def hide + @window.destroy + @bar = nil + @window = nil end private def setup_progress_color if Gtk.const_defined?(:CssProvider)