From 589ec018c7880b741777032a3c3da555114ef12b Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Sat, 5 Oct 2024 20:41:39 +0100 Subject: chat: Get auto-scroll working, and fix ssh conn --- src/message.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'src/message.py') diff --git a/src/message.py b/src/message.py index a6e69a4..241ceab 100644 --- a/src/message.py +++ b/src/message.py @@ -30,19 +30,26 @@ class WeegtkMessage(Gtk.Box): def __init__(self, username="username", messages=[], **kwargs): super().__init__(**kwargs) - self.set_contents(username, messages) - - def set_contents(self, username, messages): - self.username.set_label(username) - self.avatar.set_text(username) - - first = True - for message in messages: - margin = 5 if not first else 0 - first = False - msg = Gtk.Label(label=message, selectable=True, - wrap=True, halign=0, hexpand=True, hexpand_set=True, - xalign=0, margin_top=margin) - self.message_list.append(msg) + data = { + "type": "empty" + } + self.set_contents(data) + + def set_contents(self, data): + if data["type"] == "empty": + self.set_visible(False) + else: + self.set_visible(True) + self.username.set_label(data["username"]) + self.avatar.set_text(data["username"]) + + first = True + for message in data["text"]: + margin = 5 if not first else 0 + first = False + msg = Gtk.Label(label=message, selectable=True, + wrap=True, halign=0, hexpand=True, hexpand_set=True, + xalign=0, margin_top=margin) + self.message_list.append(msg) -- cgit