Class: Yast2::ServiceWidget
- Inherits:
-
Object
- Object
- Yast2::ServiceWidget
- Extended by:
- Yast::I18n
- Includes:
- Yast::I18n, Yast::Logger, Yast::UIShortcuts
- Defined in:
- library/systemd/src/lib/yast2/service_widget.rb
Overview
Allow to specify the widget ID. Currently, it uses always the same, so you can not use more than one instance of this class at the same time.
Class that represents widget that allows configuration of services. It uses to hold configuration SystemService or CompoundService. It can work with both and for usage it really depends if it should configure single or multiple services
Instance Attribute Summary collapse
-
#current_action ⇒ Symbol
readonly
It stores the selected service action.
Instance Method Summary collapse
-
#content ⇒ Yast::Term
gets widget term.
-
#default_action=(value) ⇒ Object
Set the given action as the current action selected by the widget, when no action is given it will not touch the service unless modified in the selection list.
-
#handle_input(event_id) ⇒ nil
handles event to dynamically react on user configuration.
-
#help ⇒ String
Returns the service widget help text.
-
#initialize(service) ⇒ ServiceWidget
constructor
creates new widget instance for given service.
-
#refresh ⇒ nil
Updates the widget with current values of service.
-
#store ⇒ Object
Stores current configuration.
Constructor Details
#initialize(service) ⇒ ServiceWidget
creates new widget instance for given service
81 82 83 84 85 86 87 |
# File 'library/systemd/src/lib/yast2/service_widget.rb', line 81 def initialize(service) textdomain "base" @service = service # When the service is active, by default, propose to reload or restart # it after writting the configuration (bsc#1158946) init_default_action end |
Instance Attribute Details
#current_action ⇒ Symbol (readonly)
It stores the selected service action
77 78 79 |
# File 'library/systemd/src/lib/yast2/service_widget.rb', line 77 def current_action @current_action end |
Instance Method Details
#content ⇒ Yast::Term
gets widget term
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'library/systemd/src/lib/yast2/service_widget.rb', line 101 def content Frame( _("Service Configuration"), VBox( Left( HBox( Label(_("Current status:")), HSpacing(1), Label(Id(:service_widget_status), Opt(:hstretch), status) ) ), Left(), Left() ) ) end |
#default_action=(value) ⇒ Object
Set the given action as the current action selected by the widget, when no action is given it will not touch the service unless modified in the selection list
95 96 97 |
# File 'library/systemd/src/lib/yast2/service_widget.rb', line 95 def default_action=(value) @current_action = value || :nothing end |
#handle_input(event_id) ⇒ nil
handles event to dynamically react on user configuration. For events that does not happen inside widget it is ignored.
134 135 136 137 138 |
# File 'library/systemd/src/lib/yast2/service_widget.rb', line 134 def handle_input(event_id) log.info "handle event #{event_id}" nil end |
#help ⇒ String
Returns the service widget help text
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'library/systemd/src/lib/yast2/service_widget.rb', line 153 def help # TRANSLATORS: helptext for the service current status, the header helptext = _("<h2>Service configuration</h2>") # TRANSLATORS: helptext for the service current status helptext += _( "<h3>Current status</h3>" \ "Displays the current status of the service." ) # TRANSLATORS: helptext for the "After writting configuration" service widget option helptext += _( "<h3>After writing configuration</h3>" \ "Allow to change the service status immediately after accepting the changes. Available options depend on the current state. The <b>Keep current state</b> special action leaves the service state untouched." ) # TRANSLATORS: helptext for the "After reboot" service widget option helptext + _( "<h3>After reboot</h3>" \ "Let choose if service should be started automatically on boot. Some services could be configured <b>on demand</b>, which means that the associated socket will be running and start the service if needed." ) end |
#refresh ⇒ nil
Updates the widget with current values of service
Useful to update the information after certain actions like "Apply changes"
123 124 125 126 127 128 |
# File 'library/systemd/src/lib/yast2/service_widget.rb', line 123 def refresh Yast::UI.ChangeWidget(Id(:service_widget_status), :Value, status) Yast::UI.ChangeWidget(Id(:service_widget_action), :Items, action_items) Yast::UI.ChangeWidget(Id(:service_widget_autostart), :Items, autostart_items) nil end |
#store ⇒ Object
it requires content of dialog to query, so cannot be called after DialogClose or if
Stores current configuration. Should be called always before dialog close, even when going back so configuration is persistent when going again forward. another dialog is displayed instead of the one with #content
144 145 146 147 148 |
# File 'library/systemd/src/lib/yast2/service_widget.rb', line 144 def store service.reset # so we start from scratch store_action store_autostart end |