maximum changeable
This commit is contained in:
parent
85e7836e21
commit
c62294ce49
1 changed files with 15 additions and 2 deletions
|
@ -24,6 +24,11 @@ class ProgressBar::Base
|
||||||
change_progress
|
change_progress
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def max= val
|
||||||
|
@max = val
|
||||||
|
change_progress
|
||||||
|
end
|
||||||
|
|
||||||
def increment!( x = nil) self.i += (x || 1) end
|
def increment!( x = nil) self.i += (x || 1) end
|
||||||
alias to_i i
|
alias to_i i
|
||||||
alias inc! increment!
|
alias inc! increment!
|
||||||
|
@ -79,8 +84,8 @@ end
|
||||||
|
|
||||||
class ProgressBar::KDialog < ProgressBar::Base
|
class ProgressBar::KDialog < ProgressBar::Base
|
||||||
attr_reader :dialog_service_path, :dialog_object_path, :errors, :dialog_object
|
attr_reader :dialog_service_path, :dialog_object_path, :errors, :dialog_object
|
||||||
def initialize *a
|
def initialize max, text
|
||||||
super *a
|
super max, text
|
||||||
@errors = []
|
@errors = []
|
||||||
args = %w[kdialog --progressbar] + [text, max.to_s]
|
args = %w[kdialog --progressbar] + [text, max.to_s]
|
||||||
@dialog_service_path, @dialog_object_path = IO.popen( args, 'r', &:readlines).join("\n").split ' '
|
@dialog_service_path, @dialog_object_path = IO.popen( args, 'r', &:readlines).join("\n").split ' '
|
||||||
|
@ -123,4 +128,12 @@ class ProgressBar::KDialog < ProgressBar::Base
|
||||||
@dialog_object.close rescue DBus::Error
|
@dialog_object.close rescue DBus::Error
|
||||||
kdialog '--detailederror', "Some errors occured:", errors.join( "<br/>\n") unless errors.empty?
|
kdialog '--detailederror', "Some errors occured:", errors.join( "<br/>\n") unless errors.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def max= val
|
||||||
|
@dialog_object.Set '', 'maximum', val
|
||||||
|
end
|
||||||
|
|
||||||
|
def max
|
||||||
|
@dialog_object.Get '', 'maximum'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue