Class: ProgressBar::KDialog
- Inherits:
-
Base
- Object
- Base
- ProgressBar::KDialog
show all
- Defined in:
- lib/progress-bar.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#error, #i, #start, #text
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#done_dur, #done_rel, #increment!, #total_dur
Constructor Details
#initialize(max, text) ⇒ KDialog
Returns a new instance of KDialog.
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/progress-bar.rb', line 87
def initialize max, text
super max, text
@errors = []
args = %w[kdialog --progressbar] + [text, max.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.object @dialog_object_path
@dialog_object.introspect
@dialog_object.showCancelButton true
change_progress
rescue DBus::Error
raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown'
raise
end
|
Instance Attribute Details
#dialog_object ⇒ Object
Returns the value of attribute dialog_object.
86
87
88
|
# File 'lib/progress-bar.rb', line 86
def dialog_object
@dialog_object
end
|
#dialog_object_path ⇒ Object
Returns the value of attribute dialog_object_path.
86
87
88
|
# File 'lib/progress-bar.rb', line 86
def dialog_object_path
@dialog_object_path
end
|
#dialog_service_path ⇒ Object
Returns the value of attribute dialog_service_path.
86
87
88
|
# File 'lib/progress-bar.rb', line 86
def dialog_service_path
@dialog_service_path
end
|
#errors ⇒ Object
Returns the value of attribute errors.
86
87
88
|
# File 'lib/progress-bar.rb', line 86
def errors
@errors
end
|
Class Method Details
.kdialog(*a) ⇒ Object
103
104
105
106
107
|
# File 'lib/progress-bar.rb', line 103
def self.kdialog *a
windowid = ENV['WINDOWID']
windowid = (windowid.is_a?(String) && !windowid.empty?) ? ['--attach', windowid] : []
system 'kdialog', *windowid, *a
end
|
Instance Method Details
#change_error ⇒ Object
126
|
# File 'lib/progress-bar.rb', line 126
def change_error() @errors.push error end
|
#change_progress ⇒ Object
110
111
112
113
114
115
116
|
# File 'lib/progress-bar.rb', line 110
def change_progress()
@dialog_object.Set '', 'value', i
raise Interrupt if @dialog_object.wasCancelled.first
rescue DBus::Error
raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown'
raise
end
|
#change_text ⇒ Object
118
119
120
121
122
123
124
|
# File 'lib/progress-bar.rb', line 118
def change_text()
@dialog_object.setLabelText text
raise Interrupt if @dialog_object.wasCancelled.first
rescue DBus::Error
raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown'
raise
end
|
#finish ⇒ Object
127
128
129
130
|
# File 'lib/progress-bar.rb', line 127
def finish()
@dialog_object.close rescue DBus::Error
kdialog '--detailederror', "Some errors occured:", errors.join( "<br/>\n") unless errors.empty?
end
|
#kdialog(*a) ⇒ Object
108
|
# File 'lib/progress-bar.rb', line 108
def kdialog(*a) self.class.kdialog *a end
|
#max ⇒ Object
136
137
138
|
# File 'lib/progress-bar.rb', line 136
def max
@dialog_object.Get '', 'maximum'
end
|
#max=(val) ⇒ Object
132
133
134
|
# File 'lib/progress-bar.rb', line 132
def max= val
@dialog_object.Set '', 'maximum', val
end
|