From f3201c850ed6fa967074e0a07d9d017540ae69f4 Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Tue, 21 Jan 2025 12:33:59 +0000 Subject: message: Grey out system messages --- src/chat.py | 5 ++++- src/message.py | 7 +++++-- src/style.css | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/chat.py b/src/chat.py index ef43e5a..e99a524 100644 --- a/src/chat.py +++ b/src/chat.py @@ -165,7 +165,10 @@ class WeegtkChat(Adw.Bin): last = self.model.get_string(count - 1) last_data = json.loads(last) if last_data["username"] == user: - msg_type = "message_append" + if msg_type == "system": + msg_type = "system_append" + else: + msg_type = "message_append" data = { "username": user, diff --git a/src/message.py b/src/message.py index db50829..0be93c2 100644 --- a/src/message.py +++ b/src/message.py @@ -65,7 +65,7 @@ class WeegtkMessage(Gtk.Box): else: self.avatar.set_text(data["username"]) - if data["type"] == "message_append": + if data["type"] in ["message_append", "system_append"]: self.avatar.set_visible(False) self.username.set_visible(False) @@ -80,7 +80,10 @@ class WeegtkMessage(Gtk.Box): msg = Gtk.Label(label=markuped, selectable=True, wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR, xalign=0, margin_top=margin, use_markup=True, - margin_start= padding_size if data["type"] == "message_append" else 0) + margin_start= padding_size if data["type"] in ["message_append", "system_append"] else 0) + + if data["type"] in ["system", "system_append"]: + msg.add_css_class("system-message") self.message_list.append(msg) diff --git a/src/style.css b/src/style.css index 44ec363..a95fb4d 100644 --- a/src/style.css +++ b/src/style.css @@ -11,3 +11,7 @@ box.message { .messages > row { min-height: 0px; } + +.system-message { + opacity: 0.6; +} -- cgit