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

- old
+ new

@@ -7,11 +7,10 @@ @window = Gtk::Window.new(:popup) @window.app_paintable = true @bar = Gtk::ProgressBar.new @bar.show_text = true @window.add(@bar) - @original_style = @bar.style @foreground = nil @background = nil end def foreground=(color) @@ -50,19 +49,32 @@ @bar.fraction = @current / @max end private def setup_progress_color - style = @original_style.copy - if @foreground - rgb = @foreground.to_gdk_rgb - style.set_bg(Gtk::STATE_PRELIGHT, *rgb) + if Gtk.const_defined?(:CssProvider) + css = "progressbar {\n" + if @foreground + css << " color: #{@foreground.to_css_rgba};\n" + end + if @background + css << " background-color: #{@background.to_css_rgba};\n" + end + css << "}\n" + provider = Gtk::CssProvider.default + provider.load(:data => css) + else + style = @bar.style.copy + if @foreground + rgb = @foreground.to_gdk_rgb + style.set_bg(Gtk::STATE_PRELIGHT, *rgb) + end + if @background + rgb = @background.to_gdk_rgb + style.set_bg(Gtk::STATE_NORMAL, *rgb) + end + @bar.style = style end - if @background - rgb = @background.to_gdk_rgb - style.set_bg(Gtk::STATE_NORMAL, *rgb) - end - @bar.style = style end end end