From b0515a5e4a3fdd4631c486bc24e94ac825d441c5 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sun, 27 Dec 2020 21:10:40 -0800 Subject: [PATCH] swap client source and datetime fields --- src/widgets.py | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/widgets.py b/src/widgets.py index 161a335..bfd38f1 100644 --- a/src/widgets.py +++ b/src/widgets.py @@ -344,31 +344,41 @@ class PostItem(Gtk.ListBoxRow): super(Gtk.ListBoxRow, self).__init__() self.post = post - self.box = Gtk.Box(orientation='vertical') - self.add(self.box) + # Avatar + #self.avatar = Handy.Avatar(size=48, text=post.user.username, show_initials=True) + #self.avatar.set_image_load_func(self.get_avatar, post.user.content.avatar_image) + self.avatar = Gtk.Image.new_from_pixbuf(self.get_avatar(48, post.user.content.avatar_image)) + + # Source + self.source = Gtk.Label(label=post.source.name, xalign=1) + + self.username = Gtk.Label(label="@" + post.user.username, xalign=0) + self.name = Gtk.Label(xalign=0) + if 'name' in post.user: + self.name.set_markup(f"{post.user.name}") + + # datetime + post_date_local = post.created_at.astimezone(tzlocal()) + datetime_label = Gtk.Label(label=post_date_local.strftime("%Y-%m-%d %H:%M"), xalign=1, yalign=0) # post menu self.menu_button = Gtk.Button.new_from_icon_name('view-more-symbolic', 1) self.menu_button.connect('clicked', self.show_menu) + self.box = Gtk.Box(orientation='vertical') + self.add(self.box) + # name container self.name_box = Gtk.Box(orientation='vertical') - self.username = Gtk.Label(label="@" + post.user.username, xalign=0) - self.name = Gtk.Label(xalign=0) - if 'name' in post.user: - self.name.set_markup(f"{post.user.name}") self.name_box.pack_start(self.name, True, True, 0) self.name_box.pack_start(self.username, True, True, 0) # header container self.h_box = Gtk.Box(orientation='horizontal') - #self.avatar = Handy.Avatar(size=48, text=post.user.username, show_initials=True) - #self.avatar.set_image_load_func(self.get_avatar, post.user.content.avatar_image) - self.avatar = Gtk.Image.new_from_pixbuf(self.get_avatar(48, post.user.content.avatar_image)) - self.source = Gtk.Label(label=post.source.name, xalign=1, yalign=0) self.h_box.pack_start(self.avatar, False, False, 10) self.h_box.pack_start(self.name_box, False, False, 0) - self.h_box.pack_end(self.source, False, False, 10) + #self.h_box.pack_end(self.source, False, False, 10) + self.h_box.pack_end(datetime_label, False, False, 10) # content container self.c_box = Gtk.Box(orientation='vertical') @@ -376,7 +386,7 @@ class PostItem(Gtk.ListBoxRow): self.content = Gtk.Label(wrap=True, xalign=0) # TODO: parse content links if 'content' in post: - self.content.set_markup(post.content.text) + self.content.set_text(post.content.text) self.t_box.pack_start(self.content, False, False, 10) self.c_box.pack_start(self.t_box, False, False, 10) @@ -403,11 +413,9 @@ class PostItem(Gtk.ListBoxRow): # footer container self.f_box = Gtk.Box(orientation='horizontal') self.f_box.pack_end(self.menu_button, False, False, 10) + #self.f_box.pack_end(datetime_label, False, False, 10) + self.f_box.pack_end(self.source, False, False, 10) - # datetime - post_date_local = post.created_at.astimezone(tzlocal()) - datetime_label = Gtk.Label(label=post_date_local.strftime("%Y-%m-%d %H:%M"), xalign=1) - self.f_box.pack_end(datetime_label, False, False, 10) pad = Gtk.Label(label="") self.f_box.pack_start(pad, False, False, 5)