Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
dc61b224
by lovetox at 2022-01-21T22:48:24+01:00
8 changed files:
- gajim/common/storage/archive.py
- gajim/gtk/controls/base.py
- gajim/gtk/controls/chat.py
- gajim/gtk/controls/groupchat.py
- gajim/gtk/conversation/rows/muc_user_status.py → gajim/gtk/conversation/rows/user_status.py
- gajim/gtk/conversation/view.py
- gajim/gtk/types.py
- pyrightconfig.json
Changes:
| ... | ... | @@ -386,7 +386,8 @@ def get_conversation_before_after(self, |
| 386 | 386 |
"""
|
| 387 | 387 |
jids = [jid]
|
| 388 | 388 |
account_id = self.get_account_id(account)
|
| 389 |
- kinds = map(str, [KindConstant.ERROR])
|
|
| 389 |
+ kinds = map(str, [KindConstant.ERROR,
|
|
| 390 |
+ KindConstant.STATUS])
|
|
| 390 | 391 |
|
| 391 | 392 |
if before:
|
| 392 | 393 |
time_order = 'AND time < ? ORDER BY time DESC, log_line_id DESC'
|
| ... | ... | @@ -1486,11 +1486,6 @@ def add_messages(self, messages: list[ConversationRow]): |
| 1486 | 1486 |
if not msg.message:
|
| 1487 | 1487 |
continue
|
| 1488 | 1488 |
|
| 1489 |
- if msg.kind in (KindConstant.STATUS,
|
|
| 1490 |
- KindConstant.GCSTATUS):
|
|
| 1491 |
- self.conversation_view.add_info_message(msg.message)
|
|
| 1492 |
- continue
|
|
| 1493 |
- |
|
| 1494 | 1489 |
message_text = msg.message
|
| 1495 | 1490 |
|
| 1496 | 1491 |
contact_name = msg.contact_name
|
| ... | ... | @@ -740,15 +740,12 @@ def _on_client_state_changed(self, |
| 740 | 740 |
self.update_actions()
|
| 741 | 741 |
|
| 742 | 742 |
def _on_presence_received(self, event: events.PresenceReceived) -> None:
|
| 743 |
- uf_show = helpers.get_uf_show(event.show)
|
|
| 744 |
- name = self.contact.name
|
|
| 745 |
- |
|
| 746 | 743 |
self.update_ui()
|
| 747 | 744 |
|
| 748 | 745 |
if not app.settings.get('print_status_in_chats'):
|
| 749 | 746 |
return
|
| 750 | 747 |
|
| 751 |
- status = f'- {event.status}' if event.status else ''
|
|
| 752 |
- status_line = _('%(name)s is now %(show)s %(status)s') % {
|
|
| 753 |
- 'name': name, 'show': uf_show, 'status': status}
|
|
| 754 |
- self.add_info_message(status_line)
|
|
| 748 |
+ contact = self._client.get_module('Contacts').get_contact(event.fjid)
|
|
| 749 |
+ self.conversation_view.add_user_status(self.contact.name,
|
|
| 750 |
+ contact.show.value,
|
|
| 751 |
+ contact.status)
|
| ... | ... | @@ -1064,9 +1064,9 @@ def _on_user_status_show_changed(self, |
| 1064 | 1064 |
properties: MessageProperties
|
| 1065 | 1065 |
) -> None:
|
| 1066 | 1066 |
|
| 1067 |
- self.conversation_view.add_muc_user_status(
|
|
| 1068 |
- user_contact,
|
|
| 1069 |
- properties.is_muc_self_presence)
|
|
| 1067 |
+ self.conversation_view.add_user_status(user_contact.name,
|
|
| 1068 |
+ user_contact.show.value,
|
|
| 1069 |
+ user_contact.status)
|
|
| 1070 | 1070 |
|
| 1071 | 1071 |
def _on_user_affiliation_changed(self,
|
| 1072 | 1072 |
_contact: GroupchatContact,
|
| ... | ... | @@ -12,27 +12,32 @@ |
| 12 | 12 |
# You should have received a copy of the GNU General Public License
|
| 13 | 13 |
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
| 14 | 14 |
|
| 15 |
+from __future__ import annotations
|
|
| 16 |
+ |
|
| 17 |
+from typing import Optional
|
|
| 18 |
+ |
|
| 15 | 19 |
import time
|
| 16 | 20 |
from datetime import datetime
|
| 17 | 21 |
|
| 18 | 22 |
from gi.repository import Gtk
|
| 19 | 23 |
|
| 20 |
-from gajim.common.modules.contacts import GroupchatParticipant
|
|
| 21 | 24 |
from gajim.common.i18n import _
|
| 22 | 25 |
from gajim.common.const import AvatarSize
|
| 23 | 26 |
from gajim.common.helpers import get_uf_show
|
| 24 | 27 |
|
| 25 | 28 |
from .widgets import SimpleLabel
|
| 26 | 29 |
from .base import BaseRow
|
| 27 |
- |
|
| 28 | 30 |
from ..message_widget import MessageWidget
|
| 29 |
- |
|
| 30 | 31 |
from ...avatar import get_show_circle
|
| 31 | 32 |
|
| 32 | 33 |
|
| 33 |
-class MUCUserStatus(BaseRow):
|
|
| 34 |
- def __init__(self, account: str, user_contact: GroupchatParticipant,
|
|
| 35 |
- is_self: bool) -> None:
|
|
| 34 |
+class UserStatus(BaseRow):
|
|
| 35 |
+ def __init__(self,
|
|
| 36 |
+ account: str,
|
|
| 37 |
+ name: str,
|
|
| 38 |
+ show: str,
|
|
| 39 |
+ status: Optional[str]) -> None:
|
|
| 40 |
+ |
|
| 36 | 41 |
BaseRow.__init__(self, account)
|
| 37 | 42 |
|
| 38 | 43 |
self.type = 'muc-user-status'
|
| ... | ... | @@ -46,22 +51,23 @@ def __init__(self, account: str, user_contact: GroupchatParticipant, |
| 46 | 51 |
|
| 47 | 52 |
show_icon = Gtk.Image()
|
| 48 | 53 |
show_icon.set_opacity(0.6)
|
| 49 |
- surface = get_show_circle(
|
|
| 50 |
- user_contact.show.value,
|
|
| 51 |
- 16,
|
|
| 52 |
- self.get_scale_factor())
|
|
| 54 |
+ surface = get_show_circle(show, 16, self.get_scale_factor())
|
|
| 53 | 55 |
show_icon.set_from_surface(surface)
|
| 54 | 56 |
self.grid.attach(show_icon, 1, 0, 1, 1)
|
| 55 | 57 |
|
| 58 |
+ show = get_uf_show(show)
|
|
| 59 |
+ |
|
| 60 |
+ message = _('{nick} is now {show}').format(nick=name, show=show)
|
|
| 61 |
+ |
|
| 56 | 62 |
self._label = SimpleLabel()
|
| 57 |
- self._label.set_text(self._make_show_text(user_contact, is_self))
|
|
| 63 |
+ self._label.set_text(message)
|
|
| 58 | 64 |
self._label.get_style_context().add_class('gajim-status-message')
|
| 59 | 65 |
self.grid.attach(self._label, 2, 0, 1, 1)
|
| 60 | 66 |
|
| 61 |
- if user_contact.status is not None:
|
|
| 67 |
+ if status is not None:
|
|
| 62 | 68 |
message_widget = MessageWidget(account)
|
| 63 | 69 |
message_widget.get_style_context().add_class('gajim-status-message')
|
| 64 |
- message_widget.add_with_styling(user_contact.status)
|
|
| 70 |
+ message_widget.add_with_styling(status)
|
|
| 65 | 71 |
self.grid.attach(message_widget, 2, 1, 1, 1)
|
| 66 | 72 |
|
| 67 | 73 |
timestamp_widget = self.create_timestamp_widget(self.timestamp)
|
| ... | ... | @@ -71,17 +77,3 @@ def __init__(self, account: str, user_contact: GroupchatParticipant, |
| 71 | 77 |
self.grid.attach(timestamp_widget, 3, 0, 1, 1)
|
| 72 | 78 |
|
| 73 | 79 |
self.show_all()
|
| 74 |
- |
|
| 75 |
- @staticmethod
|
|
| 76 |
- def _make_show_text(user_contact: GroupchatParticipant,
|
|
| 77 |
- is_self: bool) -> str:
|
|
| 78 |
- nick = user_contact.name
|
|
| 79 |
- show = get_uf_show(user_contact.show.value)
|
|
| 80 |
- |
|
| 81 |
- if is_self:
|
|
| 82 |
- message = _('You are now {show}').format(show=show)
|
|
| 83 |
- |
|
| 84 |
- else:
|
|
| 85 |
- message = _('{nick} is now {show}').format(nick=nick,
|
|
| 86 |
- show=show)
|
|
| 87 |
- return message
|
| ... | ... | @@ -46,7 +46,6 @@ |
| 46 | 46 |
from gajim.common.storage.archive import ConversationRow
|
| 47 | 47 |
from gajim.common.modules.contacts import BareContact
|
| 48 | 48 |
from gajim.common.modules.contacts import GroupchatContact
|
| 49 |
-from gajim.common.modules.contacts import GroupchatParticipant
|
|
| 50 | 49 |
from gajim.common.types import ChatContactT
|
| 51 | 50 |
|
| 52 | 51 |
from .rows.base import BaseRow
|
| ... | ... | @@ -61,7 +60,7 @@ |
| 61 | 60 |
from .rows.file_transfer_jingle import FileTransferJingleRow
|
| 62 | 61 |
from .rows.muc_subject import MUCSubject
|
| 63 | 62 |
from .rows.muc_join_left import MUCJoinLeft
|
| 64 |
-from .rows.muc_user_status import MUCUserStatus
|
|
| 63 |
+from .rows.user_status import UserStatus
|
|
| 65 | 64 |
|
| 66 | 65 |
log = logging.getLogger('gajim.gui.conversation_view')
|
| 67 | 66 |
|
| ... | ... | @@ -222,9 +221,8 @@ def add_muc_user_joined(self, nick: str) -> None: |
| 222 | 221 |
nick)
|
| 223 | 222 |
self._insert_message(join_left)
|
| 224 | 223 |
|
| 225 |
- def add_muc_user_status(self, user_contact: GroupchatParticipant,
|
|
| 226 |
- is_self: bool) -> None:
|
|
| 227 |
- user_status = MUCUserStatus(self._account, user_contact, is_self)
|
|
| 224 |
+ def add_user_status(self, name: str, show: str, status: str) -> None:
|
|
| 225 |
+ user_status = UserStatus(self._account, name, show, status)
|
|
| 228 | 226 |
self._insert_message(user_status)
|
| 229 | 227 |
|
| 230 | 228 |
def add_info_message(self, text: str) -> None:
|
| ... | ... | @@ -33,7 +33,7 @@ |
| 33 | 33 |
from .conversation.rows.message import MessageRow
|
| 34 | 34 |
from .conversation.rows.muc_join_left import MUCJoinLeft
|
| 35 | 35 |
from .conversation.rows.muc_subject import MUCSubject
|
| 36 |
- from .conversation.rows.muc_user_status import MUCUserStatus
|
|
| 36 |
+ from .conversation.rows.user_status import UserStatus
|
|
| 37 | 37 |
from .conversation.rows.read_marker import ReadMarkerRow
|
| 38 | 38 |
from .conversation.rows.scroll_hint import ScrollHintRow
|
| 39 | 39 |
|
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 |
"gajim/gtk/conversation/rows/message.py",
|
| 46 | 46 |
"gajim/gtk/conversation/rows/muc_join_left.py",
|
| 47 | 47 |
"gajim/gtk/conversation/rows/muc_subject.py",
|
| 48 |
- "gajim/gtk/conversation/rows/muc_user_status.py",
|
|
| 48 |
+ "gajim/gtk/conversation/rows/user_status.py",
|
|
| 49 | 49 |
"gajim/gtk/conversation/rows/read_marker.py",
|
| 50 | 50 |
"gajim/gtk/conversation/rows/scroll_hint.py",
|
| 51 | 51 |
"gajim/gtk/conversation/rows/widgets.py",
|