Philipp Hörist pushed to branch unify-control at gajim / gajim
Commits:
7 changed files:
- gajim/common/modules/chat_markers.py
- gajim/common/modules/contacts.py
- gajim/gtk/chat_page.py
- gajim/gtk/control.py
- gajim/gtk/conversation/view.py
- gajim/gtk/groupchat_roster.py
- gajim/gtk/main.py
Changes:
| ... | ... | @@ -26,6 +26,8 @@ |
| 26 | 26 | from gajim.common.events import DisplayedReceived
|
| 27 | 27 | from gajim.common.events import ReadStateSync
|
| 28 | 28 | from gajim.common.modules.base import BaseModule
|
| 29 | +from gajim.common.modules.contacts import GroupchatContact
|
|
| 30 | +from gajim.common.modules.contacts import GroupchatParticipant
|
|
| 29 | 31 | from gajim.common.structs import OutgoingMessage
|
| 30 | 32 | |
| 31 | 33 | |
| ... | ... | @@ -112,23 +114,19 @@ def _raise_event(self, name: str, properties: Any) -> None: |
| 112 | 114 | def _send_marker(self,
|
| 113 | 115 | contact: types.ChatContactT,
|
| 114 | 116 | marker: str,
|
| 115 | - id_: str,
|
|
| 116 | - type_: str) -> None:
|
|
| 117 | + id_: str) -> None:
|
|
| 117 | 118 | |
| 118 | - jid = contact.jid
|
|
| 119 | - if contact.is_pm_contact:
|
|
| 120 | - jid = contact.jid.new_as_bare()
|
|
| 121 | - |
|
| 122 | - if type_ in ('gc', 'pm'):
|
|
| 119 | + if isinstance(contact, (GroupchatContact, GroupchatParticipant)):
|
|
| 120 | + typ = 'groupchat'
|
|
| 123 | 121 | if not app.settings.get_group_chat_setting(
|
| 124 | - self._account, jid, 'send_marker'):
|
|
| 122 | + self._account, contact.jid.new_as_bare(), 'send_marker'):
|
|
| 125 | 123 | return
|
| 126 | 124 | else:
|
| 125 | + typ = 'chat'
|
|
| 127 | 126 | if not app.settings.get_contact_setting(
|
| 128 | - self._account, jid, 'send_marker'):
|
|
| 127 | + self._account, contact.jid, 'send_marker'):
|
|
| 129 | 128 | return
|
| 130 | 129 | |
| 131 | - typ = 'groupchat' if type_ == 'gc' else 'chat'
|
|
| 132 | 130 | message = OutgoingMessage(account=self._account,
|
| 133 | 131 | contact=contact,
|
| 134 | 132 | message=None,
|
| ... | ... | @@ -140,6 +138,6 @@ def _send_marker(self, |
| 140 | 138 | |
| 141 | 139 | def send_displayed_marker(self,
|
| 142 | 140 | contact: types.ChatContactT,
|
| 143 | - id_: str,
|
|
| 144 | - type_: str) -> None:
|
|
| 145 | - self._send_marker(contact, 'displayed', id_, type_) |
|
| 141 | + id_: str) -> None:
|
|
| 142 | + |
|
| 143 | + self._send_marker(contact, 'displayed', id_) |
| ... | ... | @@ -21,7 +21,6 @@ |
| 21 | 21 | from typing import overload
|
| 22 | 22 | |
| 23 | 23 | import cairo
|
| 24 | -from gi.repository.GObject import Value
|
|
| 25 | 24 | from nbxmpp.const import Affiliation
|
| 26 | 25 | from nbxmpp.const import Chatstate
|
| 27 | 26 | from nbxmpp.const import Role
|
| ... | ... | @@ -14,8 +14,6 @@ |
| 14 | 14 | |
| 15 | 15 | from typing import Any
|
| 16 | 16 | from typing import Literal
|
| 17 | -from typing import Optional
|
|
| 18 | -from typing import Generator
|
|
| 19 | 17 | |
| 20 | 18 | import logging
|
| 21 | 19 |
| ... | ... | @@ -57,7 +57,6 @@ |
| 57 | 57 | from gajim.gui.conversation.jump_to_end_button import JumpToEndButton
|
| 58 | 58 | from gajim.gui.builder import get_builder
|
| 59 | 59 | from gajim.gui.util import set_urgency_hint
|
| 60 | -from gajim.gui.const import ControlType
|
|
| 61 | 60 | from gajim.gui.dialogs import DialogButton
|
| 62 | 61 | from gajim.gui.dialogs import ConfirmationDialog
|
| 63 | 62 | from gajim.gui.groupchat_roster import GroupchatRoster
|
| ... | ... | @@ -278,8 +277,7 @@ def mark_as_read(self, send_marker: bool = True) -> None: |
| 278 | 277 | # XEP-0333 Send <displayed> marker
|
| 279 | 278 | self._client.get_module('ChatMarkers').send_displayed_marker(
|
| 280 | 279 | self.contact,
|
| 281 | - self.last_msg_id,
|
|
| 282 | - str(self._type))
|
|
| 280 | + self.last_msg_id)
|
|
| 283 | 281 | self.last_msg_id = None
|
| 284 | 282 | |
| 285 | 283 | def set_encryption_state(self, encryption: Optional[str]) -> None:
|
| ... | ... | @@ -300,13 +298,14 @@ def _on_autoscroll_changed(self, |
| 300 | 298 | _widget: ScrolledView,
|
| 301 | 299 | autoscroll: bool
|
| 302 | 300 | ) -> None:
|
| 301 | + |
|
| 303 | 302 | if not autoscroll:
|
| 304 | 303 | self._jump_to_end_button.toggle(True)
|
| 305 | 304 | return
|
| 306 | 305 | |
| 307 | 306 | self._jump_to_end_button.toggle(False)
|
| 308 | - if app.window.is_chat_active(self.account, self.contact.jid):
|
|
| 309 | - app.window.mark_as_read(self.account, self.contact.jid)
|
|
| 307 | + if app.window.is_chat_active(self.contact.account, self.contact.jid):
|
|
| 308 | + app.window.mark_as_read(self.contact.account, self.contact.jid)
|
|
| 310 | 309 | |
| 311 | 310 | def _on_jump_to_end(self, _button: Gtk.Button) -> None:
|
| 312 | 311 | self.reset_view()
|
| ... | ... | @@ -36,7 +36,6 @@ |
| 36 | 36 | from nbxmpp.protocol import JID
|
| 37 | 37 | |
| 38 | 38 | from gajim.common import app
|
| 39 | -from gajim.common.client import Client
|
|
| 40 | 39 | from gajim.common.events import JingleRequestReceived
|
| 41 | 40 | from gajim.common.events import FileRequestReceivedEvent
|
| 42 | 41 | from gajim.common.events import FileRequestSent
|
| ... | ... | @@ -16,7 +16,6 @@ |
| 16 | 16 | |
| 17 | 17 | from typing import Any
|
| 18 | 18 | from typing import Optional
|
| 19 | -from typing import cast
|
|
| 20 | 19 | |
| 21 | 20 | import locale
|
| 22 | 21 | from enum import IntEnum
|
| ... | ... | @@ -42,7 +41,6 @@ |
| 42 | 41 | from .menus import get_groupchat_roster_menu
|
| 43 | 42 | from .tooltips import GCTooltip
|
| 44 | 43 | from .builder import get_builder
|
| 45 | -from .types import ControlT
|
|
| 46 | 44 | from .util import EventHelper
|
| 47 | 45 | |
| 48 | 46 |
| ... | ... | @@ -792,16 +792,19 @@ def get_chat_unread_count(self, |
| 792 | 792 | account, jid, include_silent)
|
| 793 | 793 | return count or 0
|
| 794 | 794 | |
| 795 | - def mark_as_read(self, account: str, jid: JID,
|
|
| 796 | - send_marker: bool = True) -> None:
|
|
| 797 | - # TODO
|
|
| 798 | - return
|
|
| 795 | + def mark_as_read(self,
|
|
| 796 | + account: str,
|
|
| 797 | + jid: JID,
|
|
| 798 | + send_marker: bool = True
|
|
| 799 | + ) -> None:
|
|
| 800 | + |
|
| 799 | 801 | set_urgency_hint(self, False)
|
| 800 | - control = self.get_control(account, jid)
|
|
| 801 | - if control is not None:
|
|
| 802 | + control = self.get_control()
|
|
| 803 | + if control.has_active_chat():
|
|
| 802 | 804 | # Send displayed marker and
|
| 803 | 805 | # reset jump to bottom button unread counter
|
| 804 | 806 | control.mark_as_read(send_marker=send_marker)
|
| 807 | + |
|
| 805 | 808 | # Reset chat list unread counter (emits unread-count-changed)
|
| 806 | 809 | chat_list_stack = self._chat_page.get_chat_list_stack()
|
| 807 | 810 | chat_list_stack.mark_as_read(account, jid)
|