class MyListProgress

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)

Attributes

counter[R]
done[RW]
max[R]
visible_steps[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/SB/ListProgress.rb, line 6
        def initialize
                @counter=0.0
                @max=nil
                @visible_steps=1
                @progresses=Hash.new
                @list_name=nil
                @frac=0
                @pfrac=0
                super()
#               modify_font(Pango::FontDescription.new('Monospace 3'))
                set_height_request(6)
                set_width_request(100)
                set_activity_mode(false)
                modify_font(Pango::FontDescription.new("sans 7"))
#               set_show_text(false)
                @pulse_thread=nil
        end

Public Instance Methods

set_counter(new_counter) click to toggle source
# File lib/SB/ListProgress.rb, line 53
        def set_counter(new_counter)
                new_counter=max if new_counter>max
                @counter=new_counter.to_f
                
                if max==0
                        @frac=0
                        else
                        @frac=counter.to_f/max.to_f
=begin
                        if counter==0
                                else
                                set_text((100.0*counter/max).round.to_s+"%")
                        end
=end
                end
                if (@pfrac*100/visible_steps).round!=(@frac*100/visible_steps).round
                        Gtk.thread_protect{set_fraction(@frac) unless destroyed?}
                        Gtk.show_thread_changes
                        @pfrac=@frac
                end
        end
set_visible_steps(new_vs) click to toggle source
# File lib/SB/ListProgress.rb, line 48
def set_visible_steps(new_vs)
        @visible_steps=new_vs.to_f
        self
end
start_pulse() click to toggle source
# File lib/SB/ListProgress.rb, line 26
def start_pulse
        @pulse_thread=Thread.new{
                loop do
                        sleep 0.1
                        Gtk.thread_protect{pulse unless destroyed?}
                        Gtk.show_thread_changes
                end
        }
end
zero(new_max,list_name=nil) click to toggle source
# File lib/SB/ListProgress.rb, line 36
def zero(new_max,list_name=nil)
        Thread.kill(@pulse_thread) unless @pulse_thread.nil?
        @pulse_thread=nil
        @max=new_max
        @done=false
        set_counter(0)
        if @list_name!=list_name
                @list_name=list_name
                Gtk.thread_protect{set_text(@list_name) unless destroyed?}
        end
        self
end