Module: DInstaller::DBus::Interfaces::Progress
- Included in:
- Manager, Software::Manager
- Defined in:
- lib/dinstaller/dbus/interfaces/progress.rb
Overview
Note:
This mixin is expected to be included in a class inherited from BaseObject class and it requires a #backend method that returns an instance of a class including the WithProgress mixin.
Mixin to define the Progress D-Bus interface
Constant Summary collapse
- PROGRESS_INTERFACE =
"org.opensuse.DInstaller.Progress1"
Class Method Summary collapse
Instance Method Summary collapse
-
#progress_current_step ⇒ Array(Number,String)
Current step data.
-
#progress_finished ⇒ Boolean
Whether the progress has finished.
-
#progress_properties ⇒ Hash
D-Bus properties of the Progress interface.
-
#progress_total_steps ⇒ Integer
Total number of steps of the progress.
-
#register_progress_callbacks ⇒ Object
Registers callbacks to be called when the progress changes or finishes.
Class Method Details
.included(base) ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/dinstaller/dbus/interfaces/progress.rb', line 101 def self.included(base) base.class_eval do dbus_interface PROGRESS_INTERFACE do dbus_reader :progress_total_steps, "u", dbus_name: "TotalSteps" dbus_reader :progress_current_step, "(us)", dbus_name: "CurrentStep" dbus_reader :progress_finished, "b", dbus_name: "Finished" end end end |
Instance Method Details
#progress_current_step ⇒ Array(Number,String)
Current step data
65 66 67 68 69 70 |
# File 'lib/dinstaller/dbus/interfaces/progress.rb', line 65 def progress_current_step current_step = backend.progress&.current_step return [0, ""] unless current_step [current_step.id, current_step.description] end |
#progress_finished ⇒ Boolean
Whether the progress has finished
75 76 77 78 79 |
# File 'lib/dinstaller/dbus/interfaces/progress.rb', line 75 def progress_finished return true unless backend.progress backend.progress.finished? end |
#progress_properties ⇒ Hash
D-Bus properties of the Progress interface
84 85 86 |
# File 'lib/dinstaller/dbus/interfaces/progress.rb', line 84 def progress_properties interfaces_and_properties[PROGRESS_INTERFACE] end |
#progress_total_steps ⇒ Integer
Total number of steps of the progress
56 57 58 59 60 |
# File 'lib/dinstaller/dbus/interfaces/progress.rb', line 56 def progress_total_steps return 0 unless backend.progress backend.progress.total_steps end |
#register_progress_callbacks ⇒ Object
Note:
This method is expected to be called in the constructor.
Registers callbacks to be called when the progress changes or finishes
91 92 93 94 95 96 97 98 99 |
# File 'lib/dinstaller/dbus/interfaces/progress.rb', line 91 def register_progress_callbacks backend.on_progress_change do dbus_properties_changed(PROGRESS_INTERFACE, progress_properties, []) end backend.on_progress_finish do dbus_properties_changed(PROGRESS_INTERFACE, progress_properties, []) end end |