Class: MyListProgress
- Inherits:
-
Gtk::ProgressBar
- Object
- Gtk::ProgressBar
- MyListProgress
- Defined in:
- lib/SB/ListProgress.rb
Overview
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Instance Attribute Summary collapse
-
#counter ⇒ Object
readonly
Returns the value of attribute counter.
-
#done ⇒ Object
Returns the value of attribute done.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#visible_steps ⇒ Object
readonly
Returns the value of attribute visible_steps.
Instance Method Summary collapse
-
#initialize ⇒ MyListProgress
constructor
A new instance of MyListProgress.
- #set_counter(new_counter) ⇒ Object
- #set_visible_steps(new_vs) ⇒ Object
- #start_pulse ⇒ Object
- #zero(new_max, list_name = nil) ⇒ Object
Constructor Details
#initialize ⇒ MyListProgress
Returns a new instance of MyListProgress.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# 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 |
Instance Attribute Details
#counter ⇒ Object (readonly)
Returns the value of attribute counter.
23 24 25 |
# File 'lib/SB/ListProgress.rb', line 23 def counter @counter end |
#done ⇒ Object
Returns the value of attribute done.
24 25 26 |
# File 'lib/SB/ListProgress.rb', line 24 def done @done end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
23 24 25 |
# File 'lib/SB/ListProgress.rb', line 23 def max @max end |
#visible_steps ⇒ Object (readonly)
Returns the value of attribute visible_steps.
23 24 25 |
# File 'lib/SB/ListProgress.rb', line 23 def visible_steps @visible_steps end |
Instance Method Details
#set_counter(new_counter) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# 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) ⇒ Object
48 49 50 51 |
# File 'lib/SB/ListProgress.rb', line 48 def set_visible_steps(new_vs) @visible_steps=new_vs.to_f self end |
#start_pulse ⇒ Object
26 27 28 29 30 31 32 33 34 |
# 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) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# 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 |