moved datetime label and fixed layout

This commit is contained in:
Morgan McMillian 2021-03-04 10:38:29 -08:00
parent d63795adbe
commit 2aaa986c3a

View file

@ -417,9 +417,9 @@ class PostItem(Gtk.ListBoxRow):
# datetime # datetime
now = datetime.datetime.now(tzlocal()) now = datetime.datetime.now(tzlocal())
post_date_local = post.created_at.astimezone(tzlocal()) post_date_local = post.created_at.astimezone(tzlocal())
#datetime_label = Gtk.Label(label=post_date_local.strftime("%Y-%m-%d %H:%M"), xalign=1)
datetime_label = Gtk.Label(xalign=1) datetime_label = Gtk.Label(xalign=1)
datetime_label.set_markup('<span size="small">' + timeago.format(post_date_local, now) + '</span>') datetime_label.set_markup('<span size="small">' + timeago.format(post_date_local, now) + '</span>')
#datetime_label.set_markup('<span size="small">' + post_date_local.strftime("%Y-%m-%d %H:%M") + '</span>')
# post menu # post menu
self.menu_button = Gtk.Button.new_from_icon_name('view-more-symbolic', 1) self.menu_button = Gtk.Button.new_from_icon_name('view-more-symbolic', 1)
@ -441,10 +441,17 @@ class PostItem(Gtk.ListBoxRow):
self.name_box.pack_start(self.name, True, True, 0) self.name_box.pack_start(self.name, True, True, 0)
self.name_box.pack_start(self.username, True, True, 0) self.name_box.pack_start(self.username, True, True, 0)
# right side container
self.r_box = Gtk.Box(orientation='vertical')
self.rc_box = Gtk.Box(orientation='horizontal')
self.r_box.pack_start(datetime_label, False, False, 0)
self.r_box.pack_start(self.rc_box, False, False, 10)
# header container # header container
self.h_box = Gtk.Box(orientation='horizontal') self.h_box = Gtk.Box(orientation='horizontal')
self.h_box.pack_start(self.avatar, False, False, 10) 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_start(self.name_box, False, False, 0)
self.h_box.pack_end(self.r_box, False, False, 10)
#self.h_box.pack_end(source_label, False, False, 10) #self.h_box.pack_end(source_label, False, False, 10)
#self.h_box.pack_end(datetime_label, False, False, 10) #self.h_box.pack_end(datetime_label, False, False, 10)
@ -492,28 +499,28 @@ class PostItem(Gtk.ListBoxRow):
self.f_box.pack_end(repost_button, False, False, 5) self.f_box.pack_end(repost_button, False, False, 5)
self.f_box.pack_end(bookmark_button, False, False, 5) self.f_box.pack_end(bookmark_button, False, False, 5)
self.f_box.pack_end(reply_button, False, False, 5) self.f_box.pack_end(reply_button, False, False, 5)
self.f_box.pack_start(datetime_label, False, False, 5) #self.f_box.pack_start(datetime_label, False, False, 5)
self.f_box.pack_start(source_label, False, False, 0) self.f_box.pack_start(source_label, False, False, 10)
# counters # counters
pad = Gtk.Label(label="") #pad = Gtk.Label(label="")
self.h_box.pack_end(pad, False, False, 5) #self.rc_box.pack_end(pad, False, False, 5)
if post.id != int(post.thread_id): if post.id != int(post.thread_id):
thread_icon = Gtk.Image.new_from_icon_name("user-available-symbolic", Gtk.IconSize.SMALL_TOOLBAR) thread_icon = Gtk.Image.new_from_icon_name("user-available-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
self.h_box.pack_end(thread_icon, False, False, 5) self.rc_box.pack_end(thread_icon, False, False, 5)
if post.counts.bookmarks > 0: if post.counts.bookmarks > 0:
if post.you_bookmarked: if post.you_bookmarked:
star_icon = Gtk.Image.new_from_icon_name("starred-symbolic", Gtk.IconSize.SMALL_TOOLBAR) star_icon = Gtk.Image.new_from_icon_name("starred-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
else: else:
star_icon = Gtk.Image.new_from_icon_name("non-starred-symbolic", Gtk.IconSize.SMALL_TOOLBAR) star_icon = Gtk.Image.new_from_icon_name("non-starred-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
star_count = Gtk.Label(label=post.counts.bookmarks) star_count = Gtk.Label(label=post.counts.bookmarks)
self.h_box.pack_end(star_icon, False, False, 5) self.rc_box.pack_end(star_count, False, False, 0)
self.h_box.pack_end(star_count, False, False, 0) self.rc_box.pack_end(star_icon, False, False, 5)
if post.counts.reposts > 0: if post.counts.reposts > 0:
repost_icon = Gtk.Image.new_from_icon_name("media-playlist-repeat-symbolic", Gtk.IconSize.SMALL_TOOLBAR) repost_icon = Gtk.Image.new_from_icon_name("media-playlist-repeat-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
repost_count = Gtk.Label(label=post.counts.reposts) repost_count = Gtk.Label(label=post.counts.reposts)
self.h_box.pack_end(repost_icon, False, False, 5) self.rc_box.pack_end(repost_count, False, False, 0)
self.h_box.pack_end(repost_count, False, False, 0) self.rc_box.pack_end(repost_icon, False, False, 5)
#postid = Gtk.Label(label=post.id) #postid = Gtk.Label(label=post.id)
#self.f_box.pack_start(postid, False, False, 5) #self.f_box.pack_start(postid, False, False, 5)