Commit 6b9f691c authored by Nico's avatar Nico
Browse files

Make send button in chat input work

parent 3af0c282
......@@ -31,6 +31,7 @@ class WindowActions(Actions):
self._setup_open_emoji_menu_action()
self._setup_open_main_window_action()
self._setup_open_private_chat_action()
self._setup_send_message_action()
def _setup_back_to_sidebar_action(self):
self._setup_action("back-to-sidebar", None, self._back_to_sidebar)
......@@ -66,6 +67,9 @@ class WindowActions(Actions):
self._setup_action("open-private-chat", GLib.VariantType.new("i"),
self._open_private_chat)
def _setup_send_message_action(self):
self._setup_action("send-message", None, self._send_message)
# pylint: disable=unused-argument
def _back_to_sidebar(self, action, parameter):
if not isinstance(self.widget.current_view, MainWindowView):
......@@ -118,3 +122,9 @@ class WindowActions(Actions):
"Should open private chat only from MainWindowView")
self.widget.current_view.presenter.open_private_chat(
contact_id.get_int32())
# pylint: disable=unused-argument
def _send_message(self, action, parameter):
if not isinstance(self.widget.current_view, MainWindowView):
raise Exception("Should send message only from MainWindowView")
self.widget.current_view.presenter.send_message()
......@@ -53,6 +53,10 @@ class MainWindowPresenter:
self._view.builder, contact_id, self._sidebar_presenter)
self._private_chat_presenter = private_chat_view.presenter
def send_message(self):
if isinstance(self._private_chat_presenter, PrivateChatPresenter):
self._private_chat_presenter.send_message()
def _setup_destroy_listener(self):
self._view.connect("destroy", self._on_destroy)
......
......@@ -103,6 +103,15 @@ class PrivateChatPresenter:
self._hide_chat_menu_button()
self._disconnect_chat_entry_signals()
def send_message(self):
chat_entry = self._view.builder.get_object("chat_entry")
# Text does not only contain whitespace
if len(self._get_text_from_text_view(chat_entry).strip()) == 0:
return False
self._send_message(chat_entry)
self._sidebar_presenter.refresh_contacts()
return True
def disconnect_signals(self):
for signal in self._signals:
APP().api.socket_listener.disconnect(signal)
......
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