Now About Social Code
aboutsummaryrefslogtreecommitdiff
path: root/src/message.py
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-10-05 20:41:39 +0100
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-10-05 20:41:39 +0100
commit589ec018c7880b741777032a3c3da555114ef12b (patch)
treea84a09796d0ae5a699d5d23b05d2d37a4f37295e /src/message.py
parentbe71bf80d290c98c0f6a66d3dcab28515b4ea371 (diff)
chat: Get auto-scroll working, and fix ssh conn
Diffstat (limited to 'src/message.py')
-rw-r--r--src/message.py35
1 files changed, 21 insertions, 14 deletions
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)