From c1682551038a380aeb68f8e26e82dfdb48887a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <philipp@hoerist.com> Date: Fri, 29 Nov 2019 23:55:31 +0100 Subject: [PATCH] Assistant: Add default progress page --- gajim/gtk/assistant.py | 31 +++++++++++++++++++++++++++++++ test/gtk/assistant.py | 27 +++++---------------------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/gajim/gtk/assistant.py b/gajim/gtk/assistant.py index 112f89b778..02f32439a6 100644 --- a/gajim/gtk/assistant.py +++ b/gajim/gtk/assistant.py @@ -100,6 +100,8 @@ def add_default_page(self, name): page = SuccessPage() elif name == 'error': page = ErrorPage() + elif name == 'progress': + page = ProgressPage() else: raise ValueError('Unknown page: %s' % name) @@ -194,3 +196,32 @@ def __init__(self): 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 diff --git a/test/gtk/assistant.py b/test/gtk/assistant.py index 6d818e1fce..c7378d063e 100644 --- a/test/gtk/assistant.py +++ b/test/gtk/assistant.py @@ -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 @@ def _on_page_changed(self, _assistant, page_name): 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' -- GitLab