Commit bbfc2726 authored by Nico Alt's avatar Nico Alt

Simplify registration container

parent a47cd11d
...@@ -27,7 +27,7 @@ class RegistrationContainer(Container): ...@@ -27,7 +27,7 @@ class RegistrationContainer(Container):
self._setup_registration_flow_stack() self._setup_registration_flow_stack()
self._setup_registration_flow_headers() self._setup_registration_flow_headers()
self._setup_nickname_keystroke_listener() self._setup_nickname_enter_listener()
def _setup_registration_flow_stack(self): def _setup_registration_flow_stack(self):
self.registration_flow_stack = self.builder.get_object(self.STACK_NAME) self.registration_flow_stack = self.builder.get_object(self.STACK_NAME)
...@@ -39,15 +39,12 @@ class RegistrationContainer(Container): ...@@ -39,15 +39,12 @@ class RegistrationContainer(Container):
registration_flow_headers.show_all() registration_flow_headers.show_all()
self._window.set_titlebar(registration_flow_headers) self._window.set_titlebar(registration_flow_headers)
def _setup_nickname_keystroke_listener(self): def _setup_nickname_enter_listener(self):
nickname_entry = self.builder.get_object("nickname_entry") nickname_entry = self.builder.get_object("nickname_entry")
nickname_entry.connect("key-press-event", nickname_entry.connect("activate", self._on_nickname_enter)
self._nickname_keystroke)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def _nickname_keystroke(self, widget, event): def _on_nickname_enter(self, event):
if event.hardware_keycode != 36 and event.hardware_keycode != 104:
return
self.on_nickname_next_pressed(None) self.on_nickname_next_pressed(None)
# pylint: disable=unused-argument # pylint: disable=unused-argument
...@@ -68,22 +65,20 @@ class RegistrationContainer(Container): ...@@ -68,22 +65,20 @@ class RegistrationContainer(Container):
self.registration_flow_stack.set_visible_child(passwords_page) self.registration_flow_stack.set_visible_child(passwords_page)
self._focus_password_entry() self._focus_password_entry()
self._setup_passwords_keystroke_listener() self._setup_passwords_enter_listener()
def _focus_password_entry(self): def _focus_password_entry(self):
password_entry = self.builder.get_object("password_entry") password_entry = self.builder.get_object("password_entry")
password_entry.grab_focus() password_entry.grab_focus()
def _setup_passwords_keystroke_listener(self): def _setup_passwords_enter_listener(self):
password_confirm_entry = self.builder.get_object( password_confirm_entry = self.builder.get_object(
"password_confirm_entry") "password_confirm_entry")
password_confirm_entry.connect( password_confirm_entry.connect(
"key-press-event", self._passwords_keystroke) "activate", self._on_passwords_enter)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def _passwords_keystroke(self, widget, event): def _on_passwords_enter(self, event):
if event.hardware_keycode != 36 and event.hardware_keycode != 104:
return
self.on_create_account_pressed(None) self.on_create_account_pressed(None)
# pylint: disable=unused-argument # pylint: disable=unused-argument
...@@ -96,11 +91,11 @@ class RegistrationContainer(Container): ...@@ -96,11 +91,11 @@ class RegistrationContainer(Container):
# pylint: disable=unused-argument # pylint: disable=unused-argument
def on_create_account_pressed(self, button): def on_create_account_pressed(self, button):
passwords_error_label = self.builder.get_object(
"passwords_error_label")
if not self._passwords_match(): if not self._passwords_match():
passwords_error_label.show() self._show_error_message(_("The passwords do not match"))
return return
passwords_error_label = self.builder.get_object(
"passwords_error_label")
passwords_error_label.hide() passwords_error_label.hide()
self._show_loading_animation() self._show_loading_animation()
self._register() self._register()
...@@ -128,11 +123,11 @@ class RegistrationContainer(Container): ...@@ -128,11 +123,11 @@ class RegistrationContainer(Container):
GLib.idle_add(function) GLib.idle_add(function)
def _registration_failed(self): def _registration_failed(self):
self._show_error_message() self._show_error_message(_("Couldn't register account"))
self._show_passwords_page() self._show_passwords_page()
def _show_error_message(self): def _show_error_message(self, error_message):
passwords_error_label = self.builder.get_object( passwords_error_label = self.builder.get_object(
"passwords_error_label") "passwords_error_label")
passwords_error_label.set_label(_("Couldn't register account")) passwords_error_label.set_label(error_message)
passwords_error_label.show() passwords_error_label.show()
...@@ -174,7 +174,6 @@ ...@@ -174,7 +174,6 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">The passwords do not match</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property> <property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property>
<style> <style>
......
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