34
34
Base controller for an option screen used for configuration.
36
It may be used either as a step of a configuration wizard, or as a
37
standalone option screen controller.
36
39
An option screen may use a backend to populate its data, retrieve the
37
40
current state of the configuration and save the new state back to the
39
Initial population should be implemented in the L{setup} method.
42
Initial population should be implemented in the L{setup} method (and this
43
method should be explicitely called after the initialization of the screen
44
is done, this is not done automatically).
40
45
Saving back the new state of the configuration should be implemented in the
48
@cvar actions: a list of possible actions
49
@type actions: C{list} of C{str}
50
@ivar standalone: whether the screen is standalone or part of a wizard
51
@type standalone: C{bool}
44
# The 'closed' signal is emitted when the screen is closed, with a boolean
45
# parameter indicating whether the new state of the configuration has been
54
# The 'closed' signal is emitted when the screen is closed, with a string
55
# parameter for the action selected by the user.
47
56
__gsignals__ = {'closed': (gobject.SIGNAL_RUN_LAST,
49
(gobject.TYPE_BOOLEAN,)),
58
(gobject.TYPE_STRING,)),
61
# Default actions. Override if needed.
62
actions = ['prev', 'next']
65
super(OptionScreen, self).__init__()
66
self.standalone = True
54
70
Set up the screen (i.e. retrieve the current state of the configuration
60
76
return defer.fail(NotImplementedError())
62
def close(self, save=False):
78
def close(self, action, save=False):
64
80
Close the configuration screen, and optionally save back the new state
65
81
of the configuration.
67
@param save: whether to save the new state of the configuration
83
@param action: the action chosen by the user
85
@param save: whether to save the new state of the configuration
72
self.emit('closed', save)
91
if action not in self.actions:
92
msg = "Unknown action: '%s'" % action
95
self.emit('closed', action)
93
116
Close the screen without altering the current configuration.
95
self.close(save=False)
118
self.close('prev', False)
122
In standalone mode, go up one level in the history of controllers.
124
@attention: should not be called when not in standalone mode.
126
browser = self.frontend.retrieve_controllers('/poblesec/browser')[0]
127
browser.history.go_back()
97
129
def handle_input(self, manager, input_event):
98
130
if input_event.value in (EventValue.KEY_OK, EventValue.KEY_RETURN):
99
131
self.handle_input_ok()
101
135
elif input_event.value == EventValue.KEY_MENU:
102
136
self.handle_input_cancel()
137
return not self.standalone
104
138
return super(OptionScreen, self).handle_input(manager, input_event)