| ... |
... |
@@ -83,14 +83,12 @@ def _add_custom_buttons(self): |
|
83
|
83
|
for button in list(action_area.get_children()):
|
|
84
|
84
|
self.remove_action_widget(button)
|
|
85
|
85
|
|
|
86
|
|
- cancel = Gtk.Button(label=_('Cancel'))
|
|
|
86
|
+ cancel = ActionButton(_('Cancel'), AdHocAction.CANCEL)
|
|
87
|
87
|
cancel.connect('clicked', self._abort)
|
|
88
|
|
- cancel.get_style_context().add_class('destructive-action')
|
|
89
|
88
|
self._buttons['cancel'] = cancel
|
|
90
|
89
|
self.add_action_widget(cancel)
|
|
91
|
90
|
|
|
92
|
|
- complete = Gtk.Button(label=_('Finish'))
|
|
93
|
|
- complete.action = AdHocAction.COMPLETE
|
|
|
91
|
+ complete = ActionButton(_('Finish'), AdHocAction.COMPLETE)
|
|
94
|
92
|
complete.connect('clicked', self._execute_action)
|
|
95
|
93
|
self._buttons['complete'] = complete
|
|
96
|
94
|
self.add_action_widget(complete)
|
| ... |
... |
@@ -101,28 +99,26 @@ def _add_custom_buttons(self): |
|
101
|
99
|
self._buttons['commands'] = commands
|
|
102
|
100
|
self.add_action_widget(commands)
|
|
103
|
101
|
|
|
104
|
|
- next_ = Gtk.Button(label=_('Next'))
|
|
105
|
|
- next_.action = AdHocAction.NEXT
|
|
|
102
|
+ next_ = ActionButton(_('Next'), AdHocAction.NEXT)
|
|
106
|
103
|
next_.connect('clicked', self._execute_action)
|
|
107
|
104
|
self._buttons['next'] = next_
|
|
108
|
105
|
self.add_action_widget(next_)
|
|
109
|
106
|
|
|
110
|
|
- prev = Gtk.Button(label=_('Previous'))
|
|
111
|
|
- prev.action = AdHocAction.PREV
|
|
|
107
|
+ prev = ActionButton(_('Previous'), AdHocAction.PREV)
|
|
112
|
108
|
prev.connect('clicked', self._execute_action)
|
|
113
|
109
|
self._buttons['prev'] = prev
|
|
114
|
110
|
self.add_action_widget(prev)
|
|
115
|
111
|
|
|
116
|
|
- execute = Gtk.Button(label=_('Execute'))
|
|
117
|
|
- execute.action = AdHocAction.EXECUTE
|
|
118
|
|
- execute.get_style_context().add_class('suggested-action')
|
|
|
112
|
+ execute = ActionButton(_('Execute'), AdHocAction.EXECUTE)
|
|
119
|
113
|
execute.connect('clicked', self._execute_action)
|
|
120
|
114
|
self._buttons['execute'] = execute
|
|
121
|
115
|
self.add_action_widget(execute)
|
|
122
|
116
|
|
|
123
|
117
|
def _set_button_visibility(self, page):
|
|
124
|
|
- for button in self._buttons.values():
|
|
|
118
|
+ for action, button in self._buttons.items():
|
|
125
|
119
|
button.hide()
|
|
|
120
|
+ if action in ('next', 'prev', 'complete'):
|
|
|
121
|
+ button.remove_default()
|
|
126
|
122
|
|
|
127
|
123
|
if page == Page.COMMANDS:
|
|
128
|
124
|
self._buttons['execute'].show()
|
| ... |
... |
@@ -132,10 +128,13 @@ def _set_button_visibility(self, page): |
|
132
|
128
|
stage_page = self.get_nth_page(page)
|
|
133
|
129
|
if not stage_page.actions:
|
|
134
|
130
|
self._buttons['complete'].show()
|
|
|
131
|
+ self._buttons['complete'].make_default()
|
|
135
|
132
|
else:
|
|
136
|
133
|
for action in stage_page.actions:
|
|
137
|
134
|
button = self._buttons.get(action.value)
|
|
138
|
135
|
if button is not None:
|
|
|
136
|
+ if button.action == stage_page.default:
|
|
|
137
|
+ button.make_default()
|
|
139
|
138
|
button.show()
|
|
140
|
139
|
|
|
141
|
140
|
elif page == Page.ERROR:
|
| ... |
... |
@@ -328,6 +327,7 @@ def __init__(self): |
|
328
|
327
|
self._dataform_widget = None
|
|
329
|
328
|
self._notes = []
|
|
330
|
329
|
self._last_stage_data = None
|
|
|
330
|
+ self.default = None
|
|
331
|
331
|
self.show_all()
|
|
332
|
332
|
|
|
333
|
333
|
@property
|
| ... |
... |
@@ -347,6 +347,7 @@ def process_stage(self, stage_data): |
|
347
|
347
|
self._last_stage_data = stage_data
|
|
348
|
348
|
self._show_notes(stage_data.notes)
|
|
349
|
349
|
self._show_form(stage_data.data)
|
|
|
350
|
+ self.default = stage_data.default
|
|
350
|
351
|
|
|
351
|
352
|
def _show_form(self, form):
|
|
352
|
353
|
if self._dataform_widget is not None:
|
| ... |
... |
@@ -482,3 +483,20 @@ def show_command_button(self): |
|
482
|
483
|
@show_command_button.setter
|
|
483
|
484
|
def show_command_button(self, value):
|
|
484
|
485
|
self._show_command_button = value
|
|
|
486
|
+
|
|
|
487
|
+
|
|
|
488
|
+class ActionButton(Gtk.Button):
|
|
|
489
|
+ def __init__(self, label, action):
|
|
|
490
|
+ Gtk.Button.__init__(self, label=label)
|
|
|
491
|
+ self.action = action
|
|
|
492
|
+
|
|
|
493
|
+ if action == AdHocAction.CANCEL:
|
|
|
494
|
+ self.get_style_context().add_class('destructive-action')
|
|
|
495
|
+ if action == AdHocAction.EXECUTE:
|
|
|
496
|
+ self.get_style_context().add_class('suggested-action')
|
|
|
497
|
+
|
|
|
498
|
+ def make_default(self):
|
|
|
499
|
+ self.get_style_context().add_class('suggested-action')
|
|
|
500
|
+
|
|
|
501
|
+ def remove_default(self):
|
|
|
502
|
+ self.get_style_context().remove_class('suggested-action')
|