Daniel Brötzmann pushed to branch mainwindow at gajim / gajim

Commits:

2 changed files:

Changes:

  • gajim/gtk/chat_list.py
    ... ... @@ -38,6 +38,7 @@
    38 38
     from gajim.common.helpers import get_group_chat_nick
    
    39 39
     from gajim.common.helpers import get_retraction_text
    
    40 40
     from gajim.common.helpers import get_uf_relative_time
    
    41
    +from gajim.common.helpers import message_needs_highlight
    
    41 42
     from gajim.common.helpers import AdditionalDataDict
    
    42 43
     from gajim.common.preview_helpers import filename_from_uri
    
    43 44
     from gajim.common.preview_helpers import guess_simple_file_type
    
    ... ... @@ -361,7 +362,7 @@ def _on_message_received(self, event):
    361 362
             row.set_message_text(
    
    362 363
                 event.msgtxt, additional_data=event.additional_data)
    
    363 364
     
    
    364
    -        self._add_unread(row, event.properties)
    
    365
    +        self._add_unread(row, event.properties, event.msgtxt)
    
    365 366
             self.invalidate_sort()
    
    366 367
     
    
    367 368
         def _on_message_updated(self, event):
    
    ... ... @@ -442,7 +443,7 @@ def _on_file_request_received(self, event):
    442 443
                 _('File'), icon_name='text-x-generic-symbolic')
    
    443 444
     
    
    444 445
         @staticmethod
    
    445
    -    def _add_unread(row, properties):
    
    446
    +    def _add_unread(row, properties, text):
    
    446 447
             if properties.is_carbon_message and properties.carbon.is_sent:
    
    447 448
                 return
    
    448 449
     
    
    ... ... @@ -451,7 +452,7 @@ def _add_unread(row, properties):
    451 452
                 row.reset_unread()
    
    452 453
                 return
    
    453 454
     
    
    454
    -        row.add_unread()
    
    455
    +        row.add_unread(text)
    
    455 456
     
    
    456 457
         def _on_account_changed(self, *args):
    
    457 458
             for row in self.get_children():
    
    ... ... @@ -678,7 +679,7 @@ def _get_unread_string(count: int) -> str:
    678 679
                 return str(count)
    
    679 680
             return '999+'
    
    680 681
     
    
    681
    -    def add_unread(self) -> None:
    
    682
    +    def add_unread(self, text: str) -> None:
    
    682 683
             control = app.window.get_control(self.account, self.jid)
    
    683 684
             if self.is_active and control.get_autoscroll():
    
    684 685
                 return
    
    ... ... @@ -687,11 +688,24 @@ def add_unread(self) -> None:
    687 688
             self._update_unread()
    
    688 689
             self.get_parent().emit_unread_changed()
    
    689 690
     
    
    691
    +        needs_highlight = message_needs_highlight(
    
    692
    +            text,
    
    693
    +            self.contact.nickname,
    
    694
    +            self._client.get_own_jid().bare)
    
    695
    +        if needs_highlight:
    
    696
    +            self._ui.unread_label.get_style_context().remove_class(
    
    697
    +                'unread-counter-silent')
    
    698
    +
    
    690 699
         def reset_unread(self) -> None:
    
    691 700
             self._unread_count = 0
    
    692 701
             self._update_unread()
    
    693 702
             self.get_parent().emit_unread_changed()
    
    694 703
     
    
    704
    +        # Add class again in case we were mentioned previously
    
    705
    +        if self.contact.is_groupchat and not self.contact.can_notify():
    
    706
    +            self._ui.unread_label.get_style_context().add_class(
    
    707
    +                'unread-counter-silent')
    
    708
    +
    
    695 709
         @property
    
    696 710
         def is_active(self) -> bool:
    
    697 711
             return (self.is_selected() and
    

  • gajim/gtk/controls/base.py
    ... ... @@ -1234,8 +1234,8 @@ def _notify(self,
    1234 1234
                 else:
    
    1235 1235
                     sound = 'muc_message_received'
    
    1236 1236
     
    
    1237
    -            if not self.contact.can_notify():
    
    1238
    -                sound = None
    
    1237
    +            if not self.contact.can_notify() and not needs_highlight:
    
    1238
    +                return
    
    1239 1239
     
    
    1240 1240
             if self.is_privatechat:
    
    1241 1241
                 msg_type = 'private-chat-message'
    
    ... ... @@ -1250,9 +1250,6 @@ def _notify(self,
    1250 1250
                 if text.startswith('/me') or text.startswith('/me\n'):
    
    1251 1251
                     text = f'* {name} {text[3:]}'
    
    1252 1252
     
    
    1253
    -        if self.is_groupchat and not self.contact.can_notify():
    
    1254
    -            return
    
    1255
    -
    
    1256 1253
             app.nec.push_incoming_event(
    
    1257 1254
                 NetworkEvent('notification',
    
    1258 1255
                              account=self.account,