Commit c1682551 authored by Philipp Hörist's avatar Philipp Hörist

Assistant: Add default progress page

parent a350f3ed
Pipeline #4664 passed with stages
in 6 minutes and 20 seconds
......@@ -100,6 +100,8 @@ class Assistant(Gtk.ApplicationWindow, EventHelper):
page = SuccessPage()
elif name == 'error':
page = ErrorPage()
elif name == 'progress':
page = ProgressPage()
else:
raise ValueError('Unknown page: %s' % name)
......@@ -194,3 +196,32 @@ class SuccessPage(Page):
Page.__init__(self,
icon_name='object-select-symbolic',
icon_css_class='success-color')
class ProgressPage(Gtk.Box):
def __init__(self):
super().__init__(orientation=Gtk.Orientation.VERTICAL)
self.set_spacing(18)
self.set_valign(Gtk.Align.CENTER)
self.title = ''
self._label = Gtk.Label()
self._label.set_max_width_chars(50)
self._label.set_line_wrap(True)
self._label.set_halign(Gtk.Align.CENTER)
self._label.set_justify(Gtk.Justification.CENTER)
spinner = Gtk.Spinner()
spinner.start()
self.pack_start(spinner, True, True, 0)
self.pack_start(self._label, False, True, 0)
self.show_all()
def set_text(self, text):
self._label.set_text(text)
def set_title(self, title):
self.title = title
......@@ -14,8 +14,11 @@ class TestAssistant(Assistant):
def __init__(self):
Assistant.__init__(self)
self.add_pages({'start': Start(),
'progress': Progress()})
self.add_pages({'start': Start()})
progress = self.add_default_page('progress')
progress.set_title('Executing...')
progress.set_text('Something is in progress...')
error = self.add_default_page('error')
error.set_title('Error')
......@@ -90,26 +93,6 @@ class TestAssistant(Assistant):
self.set_default_button('back')
class Progress(Gtk.Box):
title = 'Progress'
def __init__(self):
super().__init__(orientation=Gtk.Orientation.VERTICAL)
self.set_spacing(18)
self.set_valign(Gtk.Align.CENTER)
label = Gtk.Label(label='Test label...')
label.set_max_width_chars(50)
label.set_line_wrap(True)
label.set_halign(Gtk.Align.CENTER)
label.set_justify(Gtk.Justification.CENTER)
spinner = Gtk.Spinner()
self.pack_start(label, False, True, 0)
self.pack_start(spinner, False, True, 0)
spinner.start()
self.show_all()
class Start(Gtk.Box):
title = 'Start'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment