class Rabbit::Progress
Attributes
background[R]
foreground[R]
window[R]
Public Class Methods
new()
click to toggle source
# File lib/rabbit/progress.rb, line 6 def initialize @width = 100 @height = 20 @foreground = nil @background = nil end
Public Instance Methods
background=(color)
click to toggle source
# File lib/rabbit/progress.rb, line 17 def background=(color) @background = color end
clear_color()
click to toggle source
# File lib/rabbit/progress.rb, line 21 def clear_color @foreground = nil @background = nil end
end_progress()
click to toggle source
# File lib/rabbit/progress.rb, line 49 def end_progress return if @max.nil? @current = @max @bar.fraction = @current / @max end
foreground=(color)
click to toggle source
# File lib/rabbit/progress.rb, line 13 def foreground=(color) @foreground = color end
hide()
click to toggle source
# File lib/rabbit/progress.rb, line 56 def hide @max = nil @window.destroy @bar = nil @window = nil end
start_progress(max, parent)
click to toggle source
# File lib/rabbit/progress.rb, line 26 def start_progress(max, parent) return if max.zero? @window = Gtk::Window.new(:popup) @window.transient_for = parent @window.app_paintable = true @window.set_default_size(@width, @height) @bar = Gtk::ProgressBar.new @window.add(@bar) @window.show_all @bar.fraction = @current = 0 @max = max.to_f setup_progress_color end
update_progress(i)
click to toggle source
# File lib/rabbit/progress.rb, line 42 def update_progress(i) return if @max.nil? @current = i @bar.fraction = @current / @max end
Private Instance Methods
setup_progress_color()
click to toggle source
# File lib/rabbit/progress.rb, line 64 def setup_progress_color css = <<-CSS progress { padding: 0px; padding-top: #{@height}px; padding-bottom: #{@height}px; } trough { border-width: 0px; } CSS if @foreground css << <<-CSS progress { background-color: #{@foreground.to_css_rgba}; border-color: #{@foreground.to_css_rgba}; } CSS end if @background css << <<-CSS progressbar, trough { background-color: #{@background.to_css_rgba}; } CSS end provider = Gtk::CssProvider.new provider.load(:data => css) @bar.style_context.add_provider(provider, Gtk::StyleProvider::PRIORITY_USER) end