class ProgressBar::KDialog
Attributes
dialog_object[R]
dialog_object_path[R]
dialog_service_path[R]
errors[R]
Public Class Methods
kdialog(*a)
click to toggle source
# File lib/progress-bar.rb, line 216 def self.kdialog *a windowid = ENV['WINDOWID'] windowid = (windowid.is_a?(String) && !windowid.empty?) ? ['--attach', windowid] : [] system 'kdialog', *windowid, *a end
new(max, text = nil, title: nil, **_options)
click to toggle source
Calls superclass method
ProgressBar::Base::new
# File lib/progress-bar.rb, line 181 def initialize max, text = nil, title: nil, **_options super max, text text = @text text = nil if text.nil? or text.empty? title = nil if title.nil? or title.empty? @title = title @errors = [] end
Public Instance Methods
change_progress()
click to toggle source
# File lib/progress-bar.rb, line 223 def change_progress() #@dialog_object.Set 'org.kde.kdialog.ProgressDialog', 'value', i @dialog_object['value'] = i raise Interrupt if @dialog_object.wasCancelled rescue DBus::Error raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown' raise end
change_text()
click to toggle source
# File lib/progress-bar.rb, line 232 def change_text() @dialog_object.setLabelText text raise Interrupt if @dialog_object.wasCancelled rescue DBus::Error raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown' raise end
error(text)
click to toggle source
# File lib/progress-bar.rb, line 240 def error text kdialog '--error', text end
finish()
click to toggle source
# File lib/progress-bar.rb, line 244 def finish() return if @finished @dialog_object.close rescue DBus::Error @finished = true end
kdialog(*a)
click to toggle source
# File lib/progress-bar.rb, line 221 def kdialog(*a) self.class.kdialog *a end
max=(val)
click to toggle source
Calls superclass method
ProgressBar::Base#max=
# File lib/progress-bar.rb, line 250 def max= val super val @dialog_object['maximum'] = val end
possible?()
click to toggle source
# File lib/progress-bar.rb, line 190 def possible? path = Pathname.new `which kdialog`.chomp $?.exitstatus and path.executable? end
start()
click to toggle source
Calls superclass method
ProgressBar::Base#start
# File lib/progress-bar.rb, line 195 def start @finished = false args = ['kdialog', @title ? ['--title', @title] : [], '--progressbar', @text || '.', @max].flatten.compact.map &:to_s @dialog_service_path, @dialog_object_path = IO.popen( args, 'r', &:readlines).join( "\n").split ' ' @dialog_bus = DBus.session_bus @dialog_service = @dialog_bus[@dialog_service_path] @dialog_object = @dialog_service[ @dialog_object_path] #STDERR.puts "%p" % @dialog_object.introspect @dialog_object.showCancelButton 1 super change_text if text.nil? change_progress self rescue DBus::Error raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown' raise end