Philipp Hörist pushed to branch master at gajim / gajim
Commits:
e7444431 by lovetox at 2022-02-05T12:41:44+01:00
ChatPage: Move set_control_active() to ChatStack
- - - - -
c81f009d by lovetox at 2022-02-05T12:43:00+01:00
ChatStack: Add type annotations
- - - - -
4 changed files:
- gajim/gtk/chat_page.py
- gajim/gtk/chat_stack.py
- gajim/gtk/controls/groupchat.py
- pyrightconfig.json
Changes:
=====================================
gajim/gtk/chat_page.py
=====================================
@@ -96,7 +96,6 @@ def __init__(self):
self._ui.paned.set_position(app.settings.get('chat_handle_position'))
self._ui.paned.connect('button-release-event', self._on_button_release)
- self._last_control: Optional[ControlT] = None
self._startup_finished: bool = False
self._add_actions()
@@ -183,16 +182,6 @@ def _on_chat_selected(self,
self.emit('chat-selected', workspace_id, account, jid)
self._reset_chat_idle_time(account, jid)
- control = self.get_control(account, jid)
- if control is None:
- return
-
- if control != self._last_control:
- if self._last_control is not None:
- self._last_control.set_control_active(False)
- control.set_control_active(True)
- self._last_control = control
-
def _on_chat_unselected(self, _chat_list_stack: ChatListStack) -> None:
self._chat_stack.clear()
self._search_view.set_context(None, None)
@@ -321,7 +310,6 @@ def remove_chat(self, account: str, jid: JID) -> None:
def _on_chat_removed(self, _chat_list: ChatList, account: str, jid: JID,
type_: str) -> None:
self._chat_stack.remove_chat(account, jid)
- self._last_control = None
if type_ == 'groupchat':
client = app.get_client(account)
client.get_module('MUC').leave(jid)
=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -26,7 +26,6 @@
from gajim.common import app
from gajim.common import ged
from gajim.common.i18n import _
-from gajim.common.events import ApplicationEvent
from .controls.chat import ChatControl
from .controls.groupchat import GroupchatControl
@@ -55,6 +54,7 @@ def __init__(self):
self.show_all()
self._controls: dict[tuple[str, JID], ControlT] = {}
+ self._current_control = None
def get_control(self, account: str, jid: JID) -> Optional[ControlT]:
try:
@@ -104,12 +104,24 @@ def remove_chat(self, account: str, jid: JID) -> None:
control.shutdown()
def show_chat(self, account: str, jid: JID) -> None:
- self.set_visible_child_name(f'{account}:{jid}')
+ new_name = f'{account}:{jid}'
+ current_name = self.get_visible_child_name()
+ assert current_name is not None
+
+ if current_name == new_name:
+ return
+
control = self.get_control(account, jid)
if control is None:
log.warning('No Control found for %s, %s', account, jid)
return
+ if self._current_control is not None:
+ self._current_control.set_control_active(False)
+ control.set_control_active(True)
+ self._current_control = control
+
+ self.set_visible_child_name(new_name)
GLib.idle_add(control.focus)
def is_chat_loaded(self, account: str, jid: JID) -> bool:
@@ -126,9 +138,12 @@ def unload_chat(self, account: str, jid: JID) -> None:
def clear(self) -> None:
self.set_visible_child_name('empty')
+ self._current_control = None
- def process_event(self, event: ApplicationEvent) -> None:
+ def process_event(self, event: Any) -> None:
control = self.get_control(event.account, event.jid)
+ if control is None:
+ return
control.process_event(event)
def remove_chats_for_account(self, account: str) -> None:
=====================================
gajim/gtk/controls/groupchat.py
=====================================
@@ -49,6 +49,7 @@
from gajim.common import ged
from gajim.common import helpers
from gajim.common.client import Client
+from gajim.common.config import Option
from gajim.common.const import AvatarSize
from gajim.common.const import SimpleClientState
from gajim.common.helpers import AdditionalDataDict
@@ -1160,7 +1161,7 @@ def send_message(self,
def _on_message_error(self, event: events.MessageError) -> None:
self.conversation_view.show_error(event.message_id, event.error)
- def shutdown(self, reason=None):
+ def shutdown(self, reason: Optional[str] = None) -> None:
app.settings.disconnect_signals(self)
self.contact.disconnect(self)
=====================================
pyrightconfig.json
=====================================
@@ -36,6 +36,7 @@
"gajim/gtk/chat_filter.py",
"gajim/gtk/chat_list_stack.py",
"gajim/gtk/chat_page.py",
+ "gajim/gtk/chat_stack.py",
"gajim/gtk/const.py",
"gajim/gtk/contact_info.py",
"gajim/gtk/contacts_flowbox.py",
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/023b5e8371c8933215591eae4f1e666142d865ef...c81f009d76dbea13abe17c26a4a4012b53c0863b
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/023b5e8371c8933215591eae4f1e666142d865ef...c81f009d76dbea13abe17c26a4a4012b53c0863b
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits