<s> from ajenti . api import plugin <EOL> from ajenti . plugins . dashboard . api import ConfigurableWidget <EOL> from ajenti . ui import on <EOL> from api import ServiceMultiplexor <EOL> @ plugin <EOL> class ServiceWidget ( ConfigurableWidget ) : <EOL> name = _ ( '<STR_LIT>' ) <EOL> icon = '<STR_LIT>' <EOL> def on_prepare ( self ) : <EOL> self . mgr = ServiceMultiplexor . get ( ) <EOL> self . append ( self . ui . inflate ( '<STR_LIT>' ) ) <EOL> def on_start ( self ) : <EOL> self . service = self . mgr . get_one ( self . config [ '<STR_LIT>' ] ) <EOL> if not self . service : <EOL> return <EOL> self . find ( '<STR_LIT:name>' ) . text = self . service . name <EOL> self . find ( '<STR_LIT>' ) . icon = self . service . icon <EOL> self . find ( '<STR_LIT:start>' ) . visible = not self . service . running <EOL> self . find ( '<STR_LIT>' ) . visible = self . service . running <EOL> self . find ( '<STR_LIT>' ) . visible = self . service . running <EOL> def create_config ( self ) : <EOL> return { '<STR_LIT>' : '<STR_LIT>' } <EOL> def on_config_start ( self ) : <EOL> service_list = self . dialog . find ( '<STR_LIT>' ) <EOL> service_list . labels = service_list . values = [ x . name for x in self . mgr . get_all ( ) ] <EOL> service_list . value = self . config [ '<STR_LIT>' ] <EOL> def on_config_save ( self ) : <EOL> self . config [ '<STR_LIT>' ] = self . dialog . find ( '<STR_LIT>' ) . value <EOL> @ on ( '<STR_LIT:start>' , '<STR_LIT>' ) <EOL> def on_s_start ( self ) : <EOL> self . service . start ( ) <EOL> self . on_start ( ) <EOL> @ on ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def on_s_restart ( self ) : <EOL> self . service . restart ( ) <EOL> self . on_start ( ) <EOL> @ on ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def on_s_stop ( self ) : <EOL> self . service . stop ( ) <EOL> self . on_start ( ) </s>
