swap client source and datetime fields

This commit is contained in:
Morgan McMillian 2020-12-27 21:10:40 -08:00
parent 36bef985f4
commit b0515a5e4a

View file

@ -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"<b>{post.user.name}</b>")
# 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"<b>{post.user.name}</b>")
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)