diff options
Diffstat (limited to 'src/message.py')
-rw-r--r-- | src/message.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/message.py b/src/message.py new file mode 100644 index 0000000..a6e69a4 --- /dev/null +++ b/src/message.py @@ -0,0 +1,48 @@ +# window.py +# +# Copyright 2024 Lucas Fryzek +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# SPDX-License-Identifier: GPL-3.0-or-later +from gi.repository import Adw +from gi.repository import Gtk + +@Gtk.Template(resource_path='/com/fryzekconcepts/weegtk/gtk/message.ui') +class WeegtkMessage(Gtk.Box): + __gtype_name__ = 'WeegtkMessage' + + username = Gtk.Template.Child() + avatar = Gtk.Template.Child() + message_list = Gtk.Template.Child() + + 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) + + |