Skip to content
Snippets Groups Projects
Commit cbb540ad authored by Nico's avatar Nico
Browse files

Put public functions to the top

parent f07e8304
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,34 @@ class AddContactContainer(Container):
self._setup_view()
self._load_content()
def proceed_from_links(self):
link_error_label = self.builder.get_object("link_error_label")
if self._link_is_empty():
link_error_label.set_label(_("Please enter a link"))
link_error_label.show()
return
if self._links_match():
link_error_label.show()
link_error_label.set_label(
_("Enter your contact's link, not your own"))
return
link_error_label.hide()
self._show_alias_page()
def show_links_page(self):
links_page = self.builder.get_object("links_page")
self.add_contact_flow_stack.set_visible_child(links_page)
def on_add_contact_pressed(self):
alias_error_label = self.builder.get_object(
"alias_error_label")
if self._alias_is_empty():
alias_error_label.show()
return
alias_error_label.hide()
self._add_contact()
APP().window.show_main_container()
def _setup_view(self):
self._add_from_resource(self.ADD_CONTACT_UI)
self.builder.connect_signals(self)
......@@ -58,20 +86,6 @@ class AddContactContainer(Container):
def _on_link_enter(self, widget):
self.proceed_from_links()
def proceed_from_links(self):
link_error_label = self.builder.get_object("link_error_label")
if self._link_is_empty():
link_error_label.set_label(_("Please enter a link"))
link_error_label.show()
return
if self._links_match():
link_error_label.show()
link_error_label.set_label(
_("Enter your contact's link, not your own"))
return
link_error_label.hide()
self._show_alias_page()
def _links_match(self):
their_link = self.builder.get_object("their_link_entry").get_text()
own_link = self.builder.get_object("own_link_entry").get_text()
......@@ -100,20 +114,6 @@ class AddContactContainer(Container):
def _on_alias_enter(self, widget):
self.on_add_contact_pressed()
def show_links_page(self):
links_page = self.builder.get_object("links_page")
self.add_contact_flow_stack.set_visible_child(links_page)
def on_add_contact_pressed(self):
alias_error_label = self.builder.get_object(
"alias_error_label")
if self._alias_is_empty():
alias_error_label.show()
return
alias_error_label.hide()
self._add_contact()
APP().window.show_main_container()
def _alias_is_empty(self):
alias = self.builder.get_object("alias_entry").get_text()
return len(alias) == 0
......
......@@ -72,6 +72,15 @@ class MainWindowContainer(Container):
self._prepare_chat_view(contact_name)
self._setup_private_chat_widget(contact_name, contact_id)
def show_sidebar(self):
self.main_window_leaflet.set_visible_child(
self.builder.get_object("sidebar_box"))
self.chat_view.hide()
self.chat_placeholder.show()
self._clear_history_container()
self.contacts_list_box.unselect_all()
self.room_name_label.set_text("")
def _prepare_chat_view(self, contact_name):
if self._no_chat_opened():
self.chat_placeholder.hide()
......@@ -149,12 +158,3 @@ class MainWindowContainer(Container):
contacts_list_box_children = self.contacts_list_box.get_children()
for child in contacts_list_box_children:
self.contacts_list_box.remove(child)
def show_sidebar(self):
self.main_window_leaflet.set_visible_child(
self.builder.get_object("sidebar_box"))
self.chat_view.hide()
self.chat_placeholder.show()
self._clear_history_container()
self.contacts_list_box.unselect_all()
self.room_name_label.set_text("")
......@@ -30,6 +30,19 @@ class PrivateChatContainer(Container):
self._setup_view()
self._load_content()
def send_message(self, widget):
message = widget.get_text()
private_chat = PrivateChat(APP().api, self._contact_id)
private_chat.send(message)
self._add_message(
{
"text": message,
"local": True,
"timestamp": int(round(time.time() * 1000))
})
widget.set_text("")
def _setup_view(self):
self._add_from_resource(self.CONTAINER_UI)
......@@ -67,16 +80,3 @@ class PrivateChatContainer(Container):
def _add_message_async(self, message):
GLib.idle_add(self._add_message, message)
def send_message(self, widget):
message = widget.get_text()
private_chat = PrivateChat(APP().api, self._contact_id)
private_chat.send(message)
self._add_message(
{
"text": message,
"local": True,
"timestamp": int(round(time.time() * 1000))
})
widget.set_text("")
......@@ -24,6 +24,30 @@ class RegistrationContainer(Container):
self._window = window
self._setup_view()
def proceed_from_nickname(self):
if self._nickname_is_empty():
self._show_nickname_error_message(_("Please enter a nickname"))
return
error_label = self.builder.get_object("nickname_error_label")
error_label.hide()
self._show_passwords_page()
def show_nickname_page(self):
nickname_page = self.builder.get_object("nickname_page")
self.registration_flow_stack.set_visible_child(nickname_page)
def on_create_account_pressed(self):
if self._password_is_empty():
self._show_passwords_error_message(_("Please enter a password"))
return
if not self._passwords_match():
self._show_passwords_error_message(_("The passwords do not match"))
return
error_label = self.builder.get_object("passwords_error_label")
error_label.hide()
self._show_loading_animation()
self._register()
def _setup_view(self):
self._add_from_resource(self.REGISTRATION_UI)
self.builder.connect_signals(self)
......@@ -53,14 +77,6 @@ class RegistrationContainer(Container):
def _on_nickname_enter(self, widget):
self.proceed_from_nickname()
def proceed_from_nickname(self):
if self._nickname_is_empty():
self._show_nickname_error_message(_("Please enter a nickname"))
return
error_label = self.builder.get_object("nickname_error_label")
error_label.hide()
self._show_passwords_page()
def _nickname_is_empty(self):
nickname = self.builder.get_object("nickname_entry").get_text()
return len(nickname) == 0
......@@ -86,22 +102,6 @@ class RegistrationContainer(Container):
def _on_passwords_enter(self, widget):
self.on_create_account_pressed()
def show_nickname_page(self):
nickname_page = self.builder.get_object("nickname_page")
self.registration_flow_stack.set_visible_child(nickname_page)
def on_create_account_pressed(self):
if self._password_is_empty():
self._show_passwords_error_message(_("Please enter a password"))
return
if not self._passwords_match():
self._show_passwords_error_message(_("The passwords do not match"))
return
error_label = self.builder.get_object("passwords_error_label")
error_label.hide()
self._show_loading_animation()
self._register()
def _password_is_empty(self):
password = self.builder.get_object("password_entry").get_text()
return len(password) == 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment