Now About Social Code
aboutsummaryrefslogtreecommitdiff
path: root/src/message.py
diff options
context:
space:
mode:
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)