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


Commits:
67e62aec by wurstsalat at 2021-06-06T19:44:02+02:00
MessageRow: Implement MUC highlight

- - - - -


2 changed files:

- gajim/gtk/conversation/rows/base.py
- gajim/gtk/conversation/rows/message.py


Changes:

=====================================
gajim/gtk/conversation/rows/base.py
=====================================
@@ -31,6 +31,7 @@
 class BaseRow(Gtk.ListBoxRow):
     def __init__(self, account, widget=None):
         Gtk.ListBoxRow.__init__(self)
+        self.account = account
         self.type = ''
         self.timestamp = None
         self.kind = None


=====================================
gajim/gtk/conversation/rows/message.py
=====================================
@@ -68,11 +68,6 @@ def __init__(self,
         self._has_receipt = marker == 'received'
         self._has_displayed = marker == 'displayed'
 
-        # if is_groupchat:
-        #     if other_text_tags and 'marked' in other_text_tags:
-        #         self.get_style_context().add_class(
-        #             'conversation-mention-highlight')
-
         is_previewable = app.interface.preview_manager.get_previewable(
             text, additional_data)
         if is_previewable:
@@ -83,6 +78,8 @@ def __init__(self,
             result = process(text)
             self._message_widget = MessageWidget(account)
             self._message_widget.add_content(result)
+            if is_groupchat:
+                self._check_for_highlight(result)
 
         self._meta_box = Gtk.Box(spacing=6)
         self._meta_box.set_hexpand(True)
@@ -140,6 +137,14 @@ def __init__(self,
 
         self.show_all()
 
+    def _check_for_highlight(self, content):
+        highlight_words = app.settings.get('muc_highlight_words').split(';')
+        highlight_words.append(app.nicks[self.account])
+        highlight_words = [word.lower() for word in highlight_words if word]
+        if any(match in content.text.lower() for match in highlight_words):
+            self.get_style_context().add_class(
+                'conversation-mention-highlight')
+
     def is_same_sender(self, message):
         return message.name == self.name
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/67e62aec08c189a6b5740335a730c55e18f7c6ca

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/67e62aec08c189a6b5740335a730c55e18f7c6ca
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

Reply via email to