kdialog: initialize with empty text support

This commit is contained in:
Denis Knauf 2014-12-23 23:02:07 +01:00
parent b33d497f44
commit d1df28f03e

View file

@ -90,16 +90,19 @@ 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 max, text def initialize max, text = nil
super max, text super max, text
text = @text
text = nil if text.nil? or text.empty?
@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 ' '
@dialog_bus = DBus.session_bus @dialog_bus = DBus.session_bus
@dialog_service = @dialog_bus[@dialog_service_path] @dialog_service = @dialog_bus[@dialog_service_path]
@dialog_object = @dialog_service.object @dialog_object_path @dialog_object = @dialog_service.object @dialog_object_path
@dialog_object.introspect @dialog_object.introspect
@dialog_object.showCancelButton true @dialog_object.showCancelButton true
change_text if text.nil?
change_progress change_progress
rescue DBus::Error rescue DBus::Error
raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown' raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown'